function b1n_doLogin($sql, &$ret_msgs, &$logging) { $ret_msgs = array(); session_unset(); if (!b1n_getVar("page0", $page0) || !b1n_getVar("action0", $action0) || !b1n_getVar("login", $login) || !b1n_getVar("passwd", $passwd) || $page0 != "login" || $action0 != "login") { return false; } $query = "\n SELECT\n usr_id,\n usr_name,\n usr_start_page,\n usr_email\n FROM\n view_active_usr\n WHERE\n usr_login = '******'\n AND usr_passwd = '" . b1n_inBd(b1n_crypt($passwd)) . "'"; $rs = $sql->singleQuery($query); if (!is_array($rs)) { b1n_retMsg($ret_msgs, b1n_FIZZLES, "Login incorrect"); return false; } $user = array("usr_id" => $rs["usr_id"], "usr_name" => ucfirst(strtok($rs["usr_name"], " ")), "usr_email" => $rs["usr_email"]); if (!empty($rs['usr_start_page'])) { $aux = explode(': ', $rs['usr_start_page']); if (sizeof($aux)) { $user += array("usr_toc" => $aux[0]); if (isset($aux[1])) { } $user += array("usr_content" => $aux[1]); } } $user["permission"] = b1n_getPermissions($sql, $user["usr_id"]); $user["bookmark"] = b1n_getBookmarks($sql, $user["usr_id"]); $_SESSION["user"] = $user; $logging = 1; return true; }
function b1n_regPdfCheckCaterer($sql, &$ret_msgs, $reg_data, $reg_config) { $ret = b1n_regCheck($sql, $ret_msgs, $reg_data, $reg_config); if ($ret) { $ret = false; $aux = $reg_data; if (is_array($aux)) { // Contacts array_pop($aux); // Remarks array_shift($aux); foreach ($aux as $x) { if ($x > 0) { $ret = true; break; } } if (!$ret) { b1n_retMsg($ret_msgs, b1n_FIZZLES, "At least, one item must have its quantity greater than 0."); } } else { b1n_retMsg($ret_msgs, b1n_FIZZLES, "No items were found."); } } return $ret; }
function b1n_regCheckChangeUser($sql, &$ret_msgs, $reg_data, $reg_config) { $ret = b1n_regCheckChange($sql, $ret_msgs, $reg_data, $reg_config); if ($reg_data["usr_passwd"] != $reg_data["usr_passwd2"]) { b1n_retMsg($ret_msgs, b1n_FIZZLES, '<b>Password</b> and <b>Confirmation</b> do not match.'); $ret = false; } return $ret; }
function b1n_regLoadLink($sql, &$ret_msgs, &$reg_data, $reg_config) { // Testing if the link really belongs to the current user $rs = $sql->singleQuery("SELECT COUNT(lnk_id) AS c FROM \"link\" WHERE usr_id = '" . b1n_inBd($_SESSION['user']['usr_id']) . "' AND lnk_id = '" . b1n_inBd($reg_data['id']) . "'"); if ($rs['c'] == '1') { return b1n_regLoad($sql, $ret_msgs, $reg_data, $reg_config, "link"); } else { b1n_retMsg($ret_msgs, b1n_FIZZLES, "This Link does not belongs to you, What are you Trying to Do?"); return false; } }
function b1n_regChangeCatererPlus($sql, &$ret_msgs, $reg_data, $reg_config) { // Deleting Contacts if ($sql->query("DELETE FROM \"cat_ctc\" WHERE cat_id = '" . b1n_inBd($reg_data["id"]) . "'")) { // Adding New $ret = b1n_regAddCatererPlus($sql, $ret_msgs, $reg_data, $reg_config); } else { b1n_retMsg($ret_msgs, b1n_FIZZLES, "Could not delete entries in cat_ctc."); $ret = false; } return $ret; }
function b1n_regCheckChangePax_vst($sql, &$ret_msgs, $reg_data, $reg_config) { $ret = b1n_regCheckChange($sql, $ret_msgs, $reg_data, $reg_config); if ($ret) { $query = "SELECT pvs_id FROM \"pax_vst\" WHERE pax_id = '" . b1n_inBd($reg_data['pax_id']) . "' AND vst_id = '" . b1n_inBd($reg_data['vst_id']) . "' AND pvs_id != '" . $reg_data['id'] . "'"; $rs = $sql->singleQuery($query); if (is_array($rs)) { b1n_retMsg($ret_msgs, b1n_FIZZLES, "This combination of <b>Pax</b> and <b>Visa Type</b> already exists."); $ret = false; } } return $ret; }
function b1n_regChangeFoodtypePlus($sql, &$ret_msgs, $reg_data, $reg_config) { $ret = false; // Deleting Functions if ($sql->query("DELETE FROM \"fdt_fod\" WHERE fdt_id = '" . b1n_inBd($reg_data["id"]) . "'")) { // Adding New $ret = b1n_regAddFoodtypePlus($sql, $ret_msgs, $reg_data, $reg_config); } else { b1n_retMsg($ret_msgs, b1n_FIZZLES, "Could not delete entries in fdt_fod."); $ret = false; } return $ret; }
function b1n_playerChangePasswd($data) { global $sql, $lang; if (b1n_cmp($data['newpasswd'], $data['newpasswd2'])) { b1n_retMsg($lang['player_password_mismatch']); return false; } $query = ' UPDATE player SET pla_passwd = ' . b1n_inBd(b1n_crypt($data['newpasswd'])) . ' WHERE pla_login = '******'pla_login']) . ' AND pla_passwd = ' . b1n_inBd(b1n_crypt($data['curpasswd'])); if ($sql->sqlQuery($query)) { b1n_retMsg($lang['player_password_success'], array(), b1n_SUCCESS); } else { b1n_retMsg($lang['player_password_wrong']); } }
function b1n_regCheckChangeAirport($sql, &$ret_msgs, $reg_data, $reg_config) { $ret = b1n_regCheckChange($sql, $ret_msgs, $reg_data, $reg_config); if ($ret) { if ($reg_data['apt_timezone'] > 12 || $reg_data['apt_timezone'] < -12) { b1n_retMsg($ret_msgs, b1n_FIZZLES, 'Invalid <b>TimeZone</b> (valid values are between +12 and -12).'); $ret = false; } $dst_start = mktime(0, 0, 0, $reg_data['apt_dst_start_dt']['month'], $reg_data['apt_dst_start_dt']['day'], $reg_data['apt_dst_start_dt']['year']); $dst_end = mktime(0, 0, 0, $reg_data['apt_dst_end_dt']['month'], $reg_data['apt_dst_end_dt']['day'], $reg_data['apt_dst_end_dt']['year']); if ($dst_start > $dst_end) { b1n_retMsg($ret_msgs, b1n_FIZZLES, '<b>DST Start</b> cannot be bigger than <b>DST End</b>.'); $ret = false; } elseif (!empty($dst_start['month']) && $dst_start == $dst_end) { b1n_retMsg($ret_msgs, b1n_FIZZLES, '<b>DST Start</b> cannot be equal to <b>DST End</b>.'); $ret = false; } } return $ret; }
function b1n_mapMoveCityPlayer($cit_id, $x, $y) { global $sql, $lang; if ($ret = b1n_mapCheckMoveCityPlayer($cit_id, $x, $y)) { // Updating User data $query = "\n UPDATE player SET\n cit_id = " . b1n_inBd($cit_id) . "\n WHERE\n pla_id = " . b1n_inBd($_SESSION['player']['pla_id']); if ($sql->sqlQuery($query)) { // Updating session data $_SESSION['player']['cit_id'] = $cit_id; $_SESSION['player']['cit_code'] = $ret['cit_code']; $_SESSION['player']['cit_pos_x0'] = $ret['cit_pos_x0']; $_SESSION['player']['cit_pos_x1'] = $ret['cit_pos_x1']; $_SESSION['player']['cit_pos_y0'] = $ret['cit_pos_y0']; $_SESSION['player']['cit_pos_y1'] = $ret['cit_pos_y1']; $_SESSION['player']['cit_cols'] = ($ret['cit_pos_x1'] - $ret['cit_pos_x0'] - 2) / 2; $_SESSION['player']['cit_rows'] = ($ret['cit_pos_y1'] - $ret['cit_pos_y0'] - 2) / 2; $_SESSION['player']['pla_pos_x'] = $x; $_SESSION['player']['pla_pos_y'] = $y; } else { $ret = false; b1n_retMsg($lang['unexpected']); } } else { b1n_retMsg($lang['map_move_illegal']); } return $ret; }
function b1n_permNewPlayer($login, $passwd, $email, $seccode, $master) { global $sql, $lang; $seccode = b1n_crypt($seccode); if (!b1n_cmp($seccode, $_SESSION['seccode'])) { $msg = b1n_decrypt($seccode); $msg .= ' != '; $msg .= b1n_decrypt($_SESSION['seccode']); b1n_retMsg($lang['login_err_wrong_code'], array('{code}' => $msg)); return false; } if (b1n_permCheckNewPlayer($login, $passwd, $email, $master)) { $query = ' SELECT func_newPlayer( ' . b1n_inBd($login) . ', ' . b1n_inBd(b1n_crypt($passwd)) . ', ' . b1n_inBd($email) . ', ' . b1n_inBd($master) . ') AS ret'; $rs = $sql->sqlSingleQuery($query); $rs['ret'] = b1n_checkTrue($rs['ret']); if ($rs['ret']) { b1n_retMsg($lang['unexpected']); } return $rs['ret']; } return false; }
function b1n_regCheckFileUpload(&$ret_msgs, &$reg_data) { global $action0; if ($action0 == 'change' && $_FILES['file']['size'] == 0 && $_FILES['file']['error'] == 0) { $reg_data['do_not_upload'] = true; return true; } else { $reg_data['fil_fake_name'] = $_FILES['file']['name']; } if (is_uploaded_file($_FILES['file']['tmp_name'])) { if ($_FILES['file']['error'] == 0) { if ($_FILES['file']['size'] != 0) { clearstatcache(); if (is_writable(b1n_UPLOAD_DIR)) { return true; } else { b1n_retMsg($ret_msgs, b1n_FIZZLES, "Cannot write to Upload Directory ('" . b1n_UPLOAD_DIR . "')."); } } else { b1n_retMsg($ret_msgs, b1n_FIZZLES, "<b>File</b> is invalid (ie. 0 bytes long)."); } } else { switch ($_FILES['file']['error']) { case 1: $msg = "Uploaded <b>File</b> exceeded upload_max_filesize."; break; case 2: $msg = "Uploaded <b>File</b> exceeded MAX_FILE_SIZE."; break; case 3: $msg = "<b>File</b> was not fully uploaded."; break; case 4: $msg = "No <b>File</b> was uploaded."; break; case 5: $msg = "<b>File</b> is Invalid (ie. 0 bytes long)."; break; default: $msg = "Unexpected Error! Undefined Error Code (weird indeed)..."; break; } b1n_retMsg($ret_msgs, b1n_FIZZLES, $msg); } } else { b1n_retMsg($ret_msgs, b1n_FIZZLES, "<b>File</b> is invalid."); } return false; }
function b1n_regChangeGroupPlus($sql, &$ret_msgs, $reg_data, $reg_config) { // Deleting Functions if ($sql->query("DELETE FROM \"grp_fnc\" WHERE grp_id = '" . b1n_inBd($reg_data["id"]) . "'")) { // Deleting Users if ($sql->query("DELETE FROM \"grp_usr\" WHERE grp_id = '" . b1n_inBd($reg_data["id"]) . "'")) { // Adding New $ret = b1n_regAddGroupPlus($sql, $ret_msgs, $reg_data, $reg_config); } else { b1n_retMsg($ret_msgs, b1n_FIZZLES, "Could not delete entries in grp_usr."); $ret = false; } } else { b1n_retMsg($ret_msgs, b1n_FIZZLES, "Could not delete entries in grp_fnc."); $ret = false; } return $ret; }
if ($func['checkDelete']($sql, $ret_msgs, $reg_data, $reg_config)) { if ($func['delete']($sql, $ret_msgs, $reg_data, $reg_config)) { $action1 = 'list'; } } } else { b1n_retMsg($ret_msgs, b1n_FIZZLES, b1n_MSG_ACCESS_DENIED); } break; case "load": if (b1n_havePermission($perm['view']) || b1n_havePermission($perm['change'])) { if (!$func['load']($sql, $ret_msgs, $reg_data, $reg_config)) { $action1 = "list"; } } else { b1n_retMsg($ret_msgs, b1n_FIZZLES, b1n_MSG_ACCESS_DENIED); } } unset($func); if (sizeof($ret_msgs)) { ?> <center> <table cellspacing="0" cellpadding="0" class="maintable"> <tr> <td> <table cellspacing="1" cellpadding="5" class="inttable"> <tr> <td class="box">System Messages</td> </tr> <?php require b1n_INCPATH . "/ret.inc.php";
break; case 'asknpc': $msg = $lang['unexpected']; b1n_getVar('bty_id', $data['bty_id']); if ($ret = b1n_mapNearest($data['bty_id'])) { $msg = str_replace('{bty}', $lang[$ret['bty_code']], $lang['map_action_asknpc_answer']); //if(is_null(strpos($ret['bty_code'], 'bank'))){ $msg = str_replace('{building}', $lang[$ret['bui_code']], $msg); //} //else { // $msg = str_replace('{building}', '', $msg); //} $msg = str_replace('{str1}', $lang[$ret['str1_code']], $msg); $msg = str_replace('{str2}', $lang[$ret['str2_code']], $msg); } b1n_retMsg($msg, array(), b1n_SUCCESS); break; case 'show_more_commands': $_SESSION['show_more_commands'] = 1; break; case 'hide_more_commands': if (isset($_SESSION['show_more_commands'])) { unset($_SESSION['show_more_commands']); } break; case 'deposit_money': b1n_getVar('money', $data['money']); b1n_mapDeposit($data['money']); break; case 'withdraw_money': b1n_getVar('money', $data['money']);
function b1n_sessionGC($life_time) { global $ses_sql; if (isset($_REQUEST['PHPSESSID'])) { $ses_id = $_REQUEST['PHPSESSID']; } else { $ses_id = ''; } $query = "\n SELECT\n ses_id, ses_ip,\n ses_data, ses_last_updated\n FROM\n session\n WHERE\n (CURRENT_TIMESTAMP - ses_last_updated)::interval >\n '" . $life_time . "'::interval"; $rs = $ses_sql->sqlQuery($query); if (is_array($rs)) { // Logging off foreach ($rs as $p) { if (strstr($p['ses_data'], 'pla_id')) { $pla_id = ereg_replace('.*:"pla_id";s:[0-9]+:"([0-9]+)";.*', '\\1', $p['ses_data']); if (!empty($pla_id)) { $aux = "'" . $p['ses_last_updated'] . "'::timestamp + "; $aux .= "'" . $life_time / 2 . " seconds'::interval"; b1n_logAction('logoff', array(), $pla_id, 0, $aux); if (b1n_cmp($ses_id, $p['ses_id'])) { global $lang; b1n_retMsg($lang['session_has_expired']); if (!b1n_cmp($_SERVER['REMOTE_ADDR'], $p['ses_ip'])) { b1n_retMsg($lang['log_cheater']); } } } } } } $query = "\n DELETE FROM session WHERE\n (CURRENT_TIMESTAMP - ses_last_updated)::interval >\n '" . $life_time . "'::interval"; $ses_sql->sqlQuery($query); return true; }
function b1n_regCheckLegCmb($sql, &$ret_msgs, &$reg_data) { $ret = false; if ($reg_data['cmb_id_pic'] != $reg_data['cmb_id_sic']) { if ($reg_data['cmb_id_pic'] != $reg_data['cmb_id_extra1']) { if ($reg_data['cmb_id_pic'] != $reg_data['cmb_id_extra2']) { if ($reg_data['cmb_id_sic'] != $reg_data['cmb_id_extra1']) { if ($reg_data['cmb_id_sic'] != $reg_data['cmb_id_extra2']) { if ($reg_data['cmb_id_extra2'] && !$reg_data['cmb_id_extra1']) { $reg_data['cmb_id_extra1'] = $reg_data['cmb_id_extra2']; $reg_data['cmb_id_extra2'] = ''; $ret = true; } elseif ($reg_data['cmb_id_extra1'] && $reg_data['cmb_id_extra1'] == $reg_data['cmb_id_extra2']) { b1n_retMsg($ret_msgs, b1n_FIZZLES, 'You cannot assign the same Crew Member to <b>Extra1</b> and <b>Extra2</b> Duty.'); } else { $ret = true; } } else { b1n_retMsg($ret_msgs, b1n_FIZZLES, 'You cannot assign the same Crew Member to <b>SIC</b> and <b>Extra 2</b> Duty.'); } } else { b1n_retMsg($ret_msgs, b1n_FIZZLES, 'You cannot assign the same Crew Member to <b>SIC</b> and <b>Extra 1</b> Duty.'); } } else { b1n_retMsg($ret_msgs, b1n_FIZZLES, 'You cannot assign the same Crew Member to <b>PIC</b> and <b>Extra 2</b> Duty.'); } } else { b1n_retMsg($ret_msgs, b1n_FIZZLES, 'You cannot assign the same Crew Member to <b>PIC</b> and <b>Extra 1</b> Duty.'); } } else { b1n_retMsg($ret_msgs, b1n_FIZZLES, 'You cannot assign the same Crew Member to <b>PIC</b> and <b>SIC</b> Duty.'); } return $ret; }
function b1n_regCheckRelationship($sql, &$ret_msgs, $ids, $rel, $table, $col_id, $col_name, $msg) { if (!is_array($rel)) { b1n_retMsg($ret_msgs, b1n_FIZZLES, 'Rel is not an Array.'); return false; } $ret = true; foreach ($ids as $id) { foreach ($rel as $d) { $query = ' SELECT ' . $d['col_name'] . ' FROM "' . $d['table'] . '" WHERE ' . $d['col_ref_id'] . ' = \'' . b1n_inBd($id) . '\''; $rs = $sql->singleQuery($query); if (is_array($rs) && sizeof($rs)) { $rs2 = $sql->singleQuery(' SELECT ' . $col_name . ' FROM "' . $table . '" WHERE ' . $col_id . ' = \'' . b1n_inBd($id) . '\''); $msg = 'You cannot delete the <b><i>' . $rs2[$col_name] . '</i> ' . $msg . '</b> because it is still refered by the <b><i>' . $rs[$d['col_name']] . '</i> ' . $d['title'] . '</b>'; if (!empty($d['as'])) { $msg .= ' as <b>' . $d['as'] . '</b>'; } $msg .= '.<br />Process Aborted'; b1n_retMsg($ret_msgs, b1n_FIZZLES, $msg); $ret = false; break 2; } } } return $ret; }