https://www.icyphoenix.com/viewtopic.php?f=17&t=9364&p=59933#p59933 ----------------------------------- mort Mon 08 Dec, 2014 01:53 Anyone Want To Help By Having A Look At This Script? ----------------------------------- Hey Fella's, [b][i](Informpro - MG)[/i][/b] :lol: :mryellow: Anyone want to help by having a look at this script? Like is there [b]"Anything"[/b] else that I should do to make it secure besides change the [b]'rand'[/b] to something more secure? This is the "Clean" functions I use... [spoiler][code linenumbers=false]function html_escape($raw_input) { return htmlspecialchars($raw_input, ENT_QUOTES | ENT_HTML401, 'UTF-8'); // important! don't forget to specify ENT_QUOTES and the correct encoding } // Do a clean up of POST. function sanitize($val){ if(get_magic_quotes_gpc()) { $val = stripslashes($val); } $val = trim($val); return mysql_real_escape_string($val); } // Convert the html layer to readable script function Zap($val){ $val = trim($val); $val = htmlspecialchars(stripslashes($val)); return ($val); } // Stops the monkey's from adding script in the Game Comments. function stripTags($val) { $val = strip_tags($val); return $val; } [/code][/spoiler] [spoiler][code linenumbers=false]. */ if (!defined('IN_ARCADE')) {die('Please use the front door');} function getbody() { include "includes/db-global.php"; if(!isset($suserid)){ echo ' '.IMG_THL.''.$lang['general_error'].''.IMG_THR.'
'.$lang['login_first'].''.GO_BACK.'
'.IMG_THB.''; return; }; function change_avatar(){ include "includes/db-global.php"; $userid = $usrdata['userid']; if($avatar == 0) {$avatar0 = 'selected="selected"';}; if($avatar == 1) {$avatar1 = 'selected="selected"';}; if(isset($_POST['avatar'])){ $avatar = sanitize($_POST['avatar']); if ($avatar == 0) { $db->query("UPDATE " . USERS_TABLE . " SET avatar='$avatar', avatar_file='' WHERE userid='$userid'") or die(mysql_error()); echo ' '.IMG_THL.''.$lang['general_message'].''.IMG_THR.'
'.$lang['profile_update'].''.GO_BACK.'
'.IMG_THB.'
'; }else{ function findexts ($filename) { $filename = strtolower($filename); $exts = mb_split("[/\\.]", $filename); $n = count($exts)-1; $exts = $exts[$n]; return $exts; } if ($_FILES['uploaded']['size'] > 40000) { echo ' '.IMG_THL.''.$lang['general_error'].''.IMG_THR.'
'.$lang['file_too_big'].''.GO_BACK.'
'.IMG_THB.''; return; }; $ext = findexts ($_FILES['uploaded']['name']); $os = array("gif", "jpg", "jpeg", "png"); if (!in_array($ext, $os)) { echo ' '.IMG_THL.''.$lang['general_error'].''.IMG_THR.'
'.$lang['file_type_no'].''.GO_BACK.'
'.IMG_THB.''; return; }else{/*Do Nothing*/}; $ava = "avatar"; $ava3 = $usrdata['userid']; $ava4 = $ava.$userid.'.'; $avatar_file = $ava4.$ext; //This is the directory. Make sure it exists and is chmodded to 0755 or 0777 as required! $target = "avatars/"; //This combines the directory, the userid, and the extension $target = $target . $ava4.$ext; if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) { echo ' '.IMG_THL.''.$lang['general_message'].''.IMG_THR.'
'.$lang['file_uploaded'].''.GO_BACK.'
'.IMG_THB.''; $db->query("UPDATE " . USERS_TABLE . " SET avatar='$avatar', avatar_file='$avatar_file' WHERE userid='$userid'") or die(mysql_error()); }else{ echo ' '.IMG_THL.''.$lang['general_error'].''.IMG_THR.'
'.$lang['file_sorry'].''.GO_BACK.'
'.IMG_THB.''; }; }; }else{ echo ' '.IMG_THL.''.$lang['manage_avatar'].''.IMG_THR.' '.SCRST.'
'.$lang['use_avatar'].':
'.$lang['file_choose'].':
'.SCRSB.' '.IMG_THB.''; }; }; function account(){ include "includes/db-global.php"; if (!isset($_POST['email'])) $_POST['email'] = null; if(isset($_POST['newsletter'])){ $userid = intval($usrdata['userid']); $newsletter = sanitize($_POST['newsletter']); $email = sanitize($_POST['email']); $aim = sanitize($_POST['aim']); $icq = sanitize($_POST['icq']); $msn = sanitize($_POST['msn']); $yim = sanitize($_POST['yim']); $location = sanitize($_POST['location']); $user_flag = sanitize($_POST['user_flag']); $user_style = sanitize($_POST['user_style']); $occupation = sanitize($_POST['occupation']); $website = sanitize($_POST['website']); $link_a = sanitize($_POST['link_a']); $link_b = sanitize($_POST['link_b']); $link_c = sanitize($_POST['link_c']); $link_d = sanitize($_POST['link_d']); $link_e = sanitize($_POST['link_e']); $link_f = sanitize($_POST['link_f']); $link_g = sanitize($_POST['link_g']); $link_h = sanitize($_POST['link_h']); $sex = sanitize($_POST['sex']); $interests = sanitize($_POST['interests']); $bio = sanitize($_POST['bio']); $ip = $_SERVER['REMOTE_ADDR']; $db->query("UPDATE " . USERS_TABLE . " SET newsletter='$newsletter', aim='$aim', icq='$icq', msn='$msn', yim='$yim', location='$location', user_flag='$user_flag', user_style='$user_style', occupation='$occupation', website='$website', link_a='$link_a', link_b='$link_b', link_c='$link_c', link_d='$link_d', link_e='$link_e', link_f='$link_f', link_g='$link_g', link_h='$link_h', sex='$sex', interests='$interests', bio='$bio', ip='$ip' WHERE userid='$userid'") or die(mysql_error()); echo ' '.IMG_THL.' '.$lang['general_message'].''.IMG_THR.'
'.$lang['profile_update'].''.GO_BACK.'
'.IMG_THB.'
'; }; $userid = intval($usrdata['userid']); $query = $db->query(sprintf("SELECT username, plays, sex, avatar, avatar_file, newsletter, aim, icq, msn, yim, location, user_style, user_flag, occupation, website, link_a, link_b, link_c, link_d, link_e, link_f, link_g, link_h, interests, bio FROM " . USERS_TABLE . " WHERE userid='%u'", $userid)) or die(mysql_error()); $row = $db->fetch_row($query); $username = html_escape($row['username']); $plays = intval($row['plays']); $sex = Zap($row['sex']); $avatar = Zap($row['avatar']); $avatar_file = Zap($row['avatar_file']); $newsletter = Zap($row['newsletter']); $aim = Zap($row['aim']); $icq = Zap($row['icq']); $msn = Zap($row['msn']); $yim = Zap($row['yim']); $location = html_escape($row['location']); $user_flag = Zap($row['user_flag']); $user_style = Zap($row['user_style']); $occupation = html_escape($row['occupation']); $website = Zap($row['website']); $link_a = Zap($row['link_a']); $link_b = Zap($row['link_b']); $link_c = Zap($row['link_c']); $link_d = Zap($row['link_d']); $link_e = Zap($row['link_e']); $link_f = Zap($row['link_f']); $link_g = Zap($row['link_g']); $link_h = Zap($row['link_h']); $interests = html_escape($row['interests']); $bio = html_escape($row['bio']); $query = $db->query(sprintf("SELECT flag_id, flag_name, flag_image FROM " . FLAGS_TABLE . " ")) or die(mysql_error()); while($row = $db->fetch_row($query)){ $flagID = intval($row['flag_id']); $flag_name = Zap($row['flag_name']); $flag_image = Zap($row['flag_image']); if(!empty($user_flag) && ($user_flag == $flag_image)){$Country = $flag_name;} } if(!empty($user_flag)){ $show_flag = ' '.$location.' '.$Country.'   '.$Country.'';}else{$show_flag = '';} if(!empty($user_style)){ $show_style = $user_style; }else{ $show_style = '';} include "templates/$template/ranks.php"; $rank = ''; }else{ if (empty($avatar_file) && ($sex == 2) && ($avatar == "0") || ($avatar == "") ){$avatar_url = ''; }else{ if (empty($avatar_file) && ($sex == 1) && ($avatar == "0") || ($avatar == "")){$avatar_url = ''; }else{ if (empty($avatar_file) && ($sex == 0) && ($avatar == "0") || ($avatar == "")){$avatar_url = ''; }else{ if (empty($avatar_file) && ($avatar == "")){$avatar_url = ''; }}}}} echo ' '.IMG_THL.''.$lang['myaccount'].''.IMG_THR.' '.SCRTOP.'
'.$avatar_url.'
'.$rank.'		   '.IMG_ACC_FAV.' '.IMG_ACC_MES.' '.IMG_ACC_CHA.' '.IMG_ACC_CHE.' '.IMG_ACC_CHP.' '.IMG_ACC_CHQ.' '.IMG_ACC_PRO.'
'.$lang['games_played'].': '.$plays.'
'.$lang['template'].': '; $query = $db->query(sprintf("SELECT template_name, style_name FROM " . THEMES_TABLE . " WHERE visible=1 ORDER BY template_name ASC")) or die(mysql_error()); $style_list = ' '; echo ' '.$style_list.'
'.$lang['newsletter'].':
'.$lang['location'].': ('.$lang['location_exp'].')
'.$lang['country_flag'].': '.$show_flag.' '; $query = $db->query(sprintf("SELECT flag_id, flag_name, flag_image FROM " . FLAGS_TABLE . " ORDER BY flag_name ASC")) or die(mysql_error()); $flag_list = ' '; echo ' '.$flag_list.'
'.$lang['website_a'].': ('.$lang['website_b'].')
'.$lang['occupation'].':
'.$lang['gender'].':
'.$lang['im'].':
('.$lang['im_b'].')		  
'.IM_AIM.'
'.IM_ICQ.'
'.IM_MSN.'
'.IM_YIM.'
'.$lang['social_bookmarks_a'].':
('.$lang['im_b'].')		  
'.SB_FB.'
'.SB_TW.'
'.SB_MS.'
'.SB_FL.'
'.SB_DG.'
'.SB_YT.'
'.SB_DL.'
'.SB_VM.'
'.$lang['interests'].':
100 '.$lang['characters'].'
'.$lang['html_script'].'
'.$lang['about_me'].':
300 '.$lang['characters'].'
'.$lang['html_script'].'
'.SCRBOT.' '.IMG_THB.''; }; function delete_favourite(){ include "includes/db-global.php"; $delete_ID = isset($_GET['deleteID']) ? intval($_GET['deleteID']) : 0; $del1 = $db->query(sprintf("SELECT name FROM " . GAMES_TABLE . " WHERE ID='%u'", intval($delete_ID))) or die(mysql_error()); $row4 = $db->fetch_row($del1); $gamename = Zap(urlencode($row4['name'])); $game_name = Zap(urldecode($row4['name'])); echo ' '.IMG_THL.''.$lang['general_message'].''.IMG_THR.'
'.$lang['are_you_sure_remove_a'].' » '.$game_name.' « '.$lang['are_you_sure_remove_b'].'
'.$lang['yes'].'   '.$lang['no'].'
'.IMG_THB.''; } function favourites(){ include "includes/db-global.php"; $delete_ID = isset($_GET['deleteID']) ? intval($_GET['deleteID']) : 0; $delete_name = isset($_GET['deletename']) ? Zap($_GET['deletename']) : 0; if (!empty($delete_ID)){ $db->query("DELETE FROM " . USERS_FAVS_TABLE . " WHERE userid=".$usrdata['userid']." AND gameid=".intval($delete_ID)."") or die(mysql_error()); echo ' '.IMG_THL.''.$lang['general_message'].''.IMG_THR.'
'.$lang['deleted'].' » '.$delete_name.' « '.$lang['are_you_sure_remove_b'].'
'.$lang['go_back'].'
'.IMG_THB.'
'; } echo ' '.IMG_THL.''.$lang['myfavs'].''.IMG_THR.' '.SCRST.''; $sql4 = $db->query(sprintf("SELECT gameid FROM " . USERS_FAVS_TABLE . " WHERE userid=".$usrdata['userid']."")) or die(mysql_error()); while($row3 = $db->fetch_row($sql4)){ $row3_gameid = intval($row3['gameid']); $del1 = $db->query(sprintf("SELECT ID, file, description, name, views, type, thumb, thumb_url FROM " . GAMES_TABLE . " WHERE ID='%u'", $row3_gameid)) or die(mysql_error()); $row4 = $db->fetch_row($del1); $row4_id = intval($row4['ID']); $row4_views = intval($row4['views']); $row4_type = intval($row4['type']); if($row4['type'] == 1) {$row4_thumb = Zap($row4['thumb']); }else{ $row4_thumb_url = Zap($row4['thumb_url']);} $row4_file = Zap($row4['file']); $body = Zap($row4['description']); $row4_name = Zap($row4['name']); include "editor/editor_bodystring.php"; $row4_name = Zap($row4_name); $body = htmlspecialchars_decode($body); $body = str_replace("&", "&", $body); $gamelink = ''.U_GAME_LINK.$row4_id.''; echo '
'.$row4_name.' '.$lang['total_views'].' » '.$row4_views.'
'; if($row4['type'] == 1){ echo ''.IMG_THUMB_B1.$row4_thumb.IMG_THUMB_55.''; }else{ echo ''.IMG_THUMB_B2.$row4_thumb_url.IMG_THUMB_55.''; } echo ' '.stripslashes(myfavsdesclimit($body)).'
'.IMG_PLAY.''; if($row4['type'] == 1){echo '   '.IMG_PLAY_FULL.''; }else{echo ' '.IMG_NO_FULL.'';} $db->query("DELETE FROM " . USERS_FAVS_TABLE . " WHERE ID=".$row4['ID']."") or die(mysql_error()); $ID = intval($row4['ID']); echo'
'.ICO_DEL.'   
'; } echo ' '.SCRSB.' '.IMG_THB.''; } function change_email(){ include "includes/db-global.php"; $userid = intval($usrdata['userid']); $query = $db->query(sprintf("SELECT email FROM " . USERS_TABLE . " WHERE userid='%u'", $userid)) or die(mysql_error()); $row = $db->fetch_row($query); $current_email = html_escape($row['email']); if(isset($_POST['submit'])){ $email = sanitize($_POST['email']); $password = sanitize(md5($_POST['password'])); $password2 = sanitize(md5($_POST['password2'])); if(!$password || !$email || !$password2){ echo ' '.IMG_THL.''.$lang['general_error'].''.IMG_THR.'
'.$lang['all_fields_req'].''.GO_BACK.'
'.IMG_THB.''; return; } $invalMail = ''.IMG_THL.''.$lang['general_error'].''.IMG_THR.'
'.$lang['email_not_valid'].''.GO_BACK.'
'.IMG_THB.''; function isValidEmail($email){ if(preg_match("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$^", $email)) return true; else return false; } if(!isValidEmail($email)){ echo ''.$invalMail.''; return; } if($_POST['password'] != $_POST['password2']){ echo ' '.IMG_THL.''.$lang['general_error'].''.IMG_THR.'
'.$lang['password_not_match'].' '.GO_BACK.'
'.IMG_THB.'
'; return; } if($password != $usrdata['password']){ echo ' '.IMG_THL.''.$lang['general_error'].''.IMG_THR.'
'.$lang['password_wrong_a'].' '.GO_BACK.'
'.IMG_THB.'
'; return; } if($email == $current_email){ echo ' '.IMG_THL.''.$lang['general_error'].''.IMG_THR.'
'.$lang['current_email'].''.GO_BACK.'
'.IMG_THB.''; return; } $sql = $db->query("SELECT email, username FROM " . USERS_TABLE . " WHERE email='.$email.'") or die(mysql_error()); if($db->num_rows($sql) == 1){ echo ' '.IMG_THL.''.$lang['general_error'].''.IMG_THR.'
'.$lang['email_in_use'].''.GO_BACK.'
'.IMG_THB.''; return; } $user_name = Zap($usrdata['username']); $activation_number = rand( ); $subject = ''.$lang['email_change'].''; $message = ''.$lang['dear'].' '.$user_name.',
'.$lang['email_change_a'].' '.$sitename.'. '.$lang['click_here'].' '.$lang['email_change_b'].'
'.$lang['thanks'].'
'.$sitename.' '.$lang['administration'].''; $headers = ''.$lang['from'].': '.$supportemail.'' . "\r\n" . 'Content-Type: text/html; charset=UTF-8' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); $sent = mail($email, $subject, $message, $headers); $db->query("UPDATE " . USERS_TABLE . " SET new_email='$email', new_email_key='$activation_number' WHERE userid='{$usrdata['userid']}'") or die(mysql_error()); #Confirm email sent or notify them of a problem if ($sent) { echo ' '.IMG_THL.''.$lang['general_message'].''.IMG_THR.'
'.$lang['email_correct'].'
'.IMG_THB.'
'; }else{ echo ' '.IMG_THL.''.$lang['general_message'].''.IMG_THR.'
'.$lang['no_connect_db'].''.GO_BACK.'
'.IMG_THB.''; } } echo ' '.IMG_THL.''.$lang['change_email'].''.IMG_THR.' '.SCRST.'
'.$lang['email_address_new'].' »
'.$lang['password_current'].' »
'.$lang['password_rep'].' »
'.SCRSB.' '.IMG_THB.''; } function change_question(){ include "includes/db-global.php"; if(isset($_POST['submit'])){ $password = sanitize(md5($_POST['password'])); $answer = sanitize(md5($_POST['answer'])); $question = sanitize($_POST['question']); $password2 = sanitize(md5($_POST['password2'])); if(!$question || !$answer || !$password || !$password2){ echo ' '.IMG_THL.''.$lang['general_error'].''.IMG_THR.'
'.$lang['not_all_fields'].'
'.$lang['go_back'].'
'.IMG_THB.''; return; } if($_POST['password'] != $_POST['password2']){ echo ' '.IMG_THL.''.$lang['general_error'].''.IMG_THR.'
'.$lang['password_not_match'].' '.GO_BACK.'
'.IMG_THB.'
'; return; } if($password != $usrdata['password']){ echo ' '.IMG_THL.''.$lang['general_error'].''.IMG_THR.'
'.$lang['password_wrong_a'].''.GO_BACK.'
'.IMG_THB.'
'; }else{ $db->query("UPDATE " . USERS_TABLE . " SET pass_question='$question', pass_answer='$answer' WHERE userid='{$usrdata['userid']}'") or die(mysql_error()); echo ' '.IMG_THL.''.$lang['general_message'].''.IMG_THR.'
'.$lang['updated_qa'].''.GO_BACK.'
'.IMG_THB.'
'; } } echo ' '.IMG_THL.''.$lang['change_pass_qa'].''.IMG_THR.' '.SCRST.'
'.$lang['question'].' »
'.$lang['answer'].' »
'.$lang['current_password'].' »
'.$lang['password_rep'].' »
'.SCRSB.' '.IMG_THB.''; } function change_password(){ include "includes/db-global.php"; if(isset($_POST['submit'])){ $oldpass = sanitize(md5($_POST['oldpass'])); $newpass = sanitize(md5($_POST['newpass'])); $password2 = sanitize(md5($_POST['password2'])); if(!$oldpass || !$newpass || !$password2){ echo ' '.IMG_THL.''.$lang['general_error'].''.IMG_THR.'
'.$lang['not_all_fields'].' '.GO_BACK.'
'.IMG_THB.'
'; return; } if($_POST['newpass'] != $_POST['password2']){ echo ' '.IMG_THL.''.$lang['general_error'].''.IMG_THR.'
'.$lang['password_not_match'].' '.GO_BACK.'
'.IMG_THB.'
'; return; } if($oldpass != $usrdata['password']){ echo ' '.IMG_THL.''.$lang['general_error'].''.IMG_THR.'
'.$lang['password_wrong_b'].''.GO_BACK.'
'.IMG_THB.'
'; }else{ $db->query(sprintf("UPDATE " . USERS_TABLE . " SET password='%s' WHERE userid='%u'", $newpass, $usrdata['userid'])) or die(mysql_error()); echo ' '.IMG_THL.''.$lang['general_message'].''.IMG_THR.'
'.$lang['password_updated'].''.GO_BACK.'
'.IMG_THB.'
'; }} echo ' '.IMG_THL.''.$lang['change_password'].''.IMG_THR.' '.SCRST.'
'.$lang['password_old'].' »
'.$lang['password_new'].' »
'.$lang['password_rep'].' »
'.SCRSB.' '.IMG_THB.''; } $cmd = isset($_GET['cmd']) ? $_GET['cmd'] : null; switch($cmd) { default: account(); break; case 'delete_favourite': delete_favourite(); break; case 'favourites': favourites(); break; case 'change_password': change_password(); break; case 'change_question': change_question(); break; case 'change_email': change_email(); break; case 'change_avatar': change_avatar(); break; } }; ?>[/code][/spoiler] I know it's not phpBB or Icy - but I also know you'll be dying to help - So I'll thank you in advance for your time and opinions. :twisted: 8)