/** * Returns the href attribute value of an anchor element. */ function get_anchor_attrs($html) { $matches = array(); if (!preg_match('#<a\\s([^<>]*)>#u', $html, $matches)) { return false; } $attrs = string_to_array(html_entity_decode($matches[1], ENT_QUOTES, 'UTF-8')); return $attrs; }
/** * Untwist $twisted_string string based on $twister * * @param string $twisted_string * @param string $twister * @return string */ static function untwist($twisted_string, $twister) { if(strlen($twisted_string) <> strlen($twister)) return $twisted_string; $twisted_array = string_to_array($twisted_string); $untwisted_array = array(); for($i = 0, $strlen = strlen($twister); $i < $strlen; $i++) { $untwisted_array[] = $twisted_array[(integer) $twister[$i]]; } // for return implode('', $untwisted_array); } // untwist
function testArr() { // $arr1 = array("1" => "111", "2" => "222"); // $arr2 = array("3" => "222", "4" => "333"); // $arr = $arr1 + $arr2; // my_log($arr); $arr3 = array("aaaaa", "b" => "nullsss", "ccc", array("1", "2")); //$arr3 = "123"; my_log($arr3); $str3 = array_to_string($arr3); my_log($str3); my_log(string_to_array($str3)); my_log("======"); my_log(explode("|", null)); }
function session_restore_messages() { if (!session_exists()) { return false; } $messages = session_get('wfpl_messages'); if ($messages !== false) { $messages = string_to_array($messages); if (!(isset($GLOBALS['wfpl_messages']) && is_array($GLOBALS['wfpl_messages']))) { $GLOBALS['wfpl_messages'] = array(); } # messages from the previous run happened first $GLOBALS['wfpl_messages'] = array_merge($messages, $GLOBALS['wfpl_messages']); } session_clear('wfpl_messages'); }
/** * Adds lazysize.js class to classes of the Image. * * @param string $_class Classes of the Image. * @return string of classes with lazysizes.js marker. */ function do_class($_class = '') { $class_arr = string_to_array($_class); if (!in_array(LAZY_CLASS, $class_arr)) { $class_arr[] = LAZY_CLASS; } // return string of classes: return implode(' ', $class_arr); }
/** * gets the current URI and removes given GET variables * * @param string $remove_GET GET variables to be removed, separated by , or | * @return string URI with or without the GET variables */ function get_URI($remove_GET = '') { $return = ''; // replace all pipes (|) by a comma and create an array $remove_GET = string_to_array($remove_GET, ',|'); // only check GET variables if they don't have to be removed all if (!in_array('{ALL}', $remove_GET)) { foreach ($_GET as $key => $value) { // if the actual variable must not be removed, add them to the URI if (!in_array($key, $remove_GET)) { $return .= ($return != '' ? '&' : '?') . $key . '=' . $value; } } } // get the filename and attach the URI $filename = substr($_SERVER['PHP_SELF'], strrpos($_SERVER['PHP_SELF'], '/') + 1); $return = $filename . $return; return $return; }
<?php include_once 'encrtest.php'; include_once 'decrtest.php'; if (isset($_POST['encrypt'])) { $array2 = key_calculation($_POST['key']); $array = string_to_array($_POST['string1']); $_POST['string2'] = transform_string($array, $array2); } else { if (isset($_POST['decrypt'])) { $array2 = key_calculation1($_POST['key']); $array = string_to_array1($_POST['string2']); $_POST['string1'] = transform_string1($array, $array2); } }
/** * Convierte un string en un array (método análogo a array_to_string) * @param unknown_type $string */ function string_to_array($string) { $retval = array(); $string = urldecode($string); $tmp_array = explode('||', $string); $null_value = urlencode(base64_encode("^^^")); foreach ($tmp_array as $tmp_val) { list($index, $value) = explode('|', $tmp_val); $decoded_index = base64_decode(urldecode($index)); if ($value != $null_value) { $val = base64_decode(urldecode($value)); if (substr($val, 0, 8) == '^^array^') { $val = string_to_array(substr($val, 8)); } $retval[$decoded_index] = $val; } else { $retval[$decoded_index] = NULL; } } return $retval; }
/** * Set parameters based on a string with whitespace-delimited "key=value" pairs. */ public function setString($paramstring) { $params = string_to_array($paramstring); if ($params !== false) { $this->setArray($params); } }
function encrypt_user_password($key, $password) { $array1 = string_to_array($password); $array2 = key_calculation($key); return transform_string($array1, $array2); }
function welive_call($data, $accept, $index) { $data = string_to_array($data); switch ($data['x']) { case 4: if (!$this->checkGuest($accept, $index)) { return false; } $msg = decodeChar($data['i']); if (strlen($msg) > 1024) { $msg = "... too long ..."; } $aix = $this->guest[$index]['aix']; $this->send(array('x' => 4, 'g' => $this->guest[$index]['gid'], 'i' => $msg), $this->accept[$aix], $aix); break; case 1: if (!$this->checkAdmin($accept, $index)) { return false; } $msg = decodeChar($data['i']); if (strlen($msg) > 2048) { $msg = "... too long ..."; } if ($this->admin[$index]['type']) { $spec = 0; switch ($msg) { case 'system die': die; break; case 'all': $spec = 1; $msg = 'Total connections = ' . count($this->accept) . '<br>Total admins = ' . count($this->admin) . '<br>Total guests = ' . count($this->guest); break; case 'admin': $spec = 1; $msg = 'Total admins = ' . count($this->admin); foreach ($this->admin as $a) { $msg .= "<br>{$a['fullname']} = {$a['guests']}"; } break; case 'guest': $spec = 1; $msg = 'Total guests = ' . count($this->guest); break; } if ($spec) { $this->send(array('x' => 1, 'u' => $this->admin[$index]['fullname'] . ' (' . $this->admin[$index]['post'] . ')', 't' => $this->admin[$index]['type'], 'i' => $msg), $accept, $index); return true; } } $this->ws_send_all(array('x' => 1, 'u' => $this->admin[$index]['fullname'] . ' (' . $this->admin[$index]['post'] . ')', 't' => $this->admin[$index]['type'], 'i' => $msg), $index); break; case 2: if ($data['a'] != 8 and !$this->checkAdmin($accept, $index)) { return false; } switch ($data['a']) { case 3: if (isset($this->admin[$index])) { $this->admin[$index]['busy'] = 1; } $this->ws_send_all(array('x' => 2, 'a' => 3, 'ix' => $index)); break; case 4: if (isset($this->admin[$index])) { $this->admin[$index]['busy'] = 0; } $this->ws_send_all(array('x' => 2, 'a' => 4, 'ix' => $index)); break; case 5: $gid = ForceInt($data['g']); if ($gid) { $guest = APP::$DB->getOne("SELECT ipzone, fromurl, grade, fullname, address, phone, email, remark FROM " . TABLE_PREFIX . "guest WHERE gid = '{$gid}'"); if (!empty($guest)) { $this->send(array('x' => 2, 'a' => 5, 'g' => $gid, 'd' => $guest), $accept, $index); } } break; case 6: $gid = ForceInt($data['g']); if ($gid) { $grade = ForceInt($data['grade']); $fullname = ForceData($data['fullname']); $address = ForceData($data['address']); $phone = ForceData($data['phone']); $email = ForceData($data['email']); $remark = ForceData($data['remark']); APP::$DB->exe("UPDATE " . TABLE_PREFIX . "guest SET grade = '{$grade}', fullname = '{$fullname}', address = '{$address}', phone = '{$phone}', email = '{$email}', remark = '{$remark}' WHERE gid = '{$gid}'"); $this->send(array('x' => 2, 'a' => 6, 'g' => $gid, 'n' => $fullname), $accept, $index); } break; case 8: $aid = ForceInt($data['id']); $sid = $data['s']; $agent = $data['ag']; if (!$aid or !IsAlnum($sid) or !IsAlnum($agent)) { $this->close($accept, $index, 0); return false; } $sql = "SELECT a.aid, a.type, a.username, a.fullname, a.fullname_en, a.post, a.post_en, a.lastip AS ip FROM " . TABLE_PREFIX . "session s LEFT JOIN " . TABLE_PREFIX . "admin a ON a.aid = s.aid WHERE s.sid = '{$sid}' AND s.aid = '{$aid}' AND s.agent = '{$agent}' AND a.activated = 1"; $admin = APP::$DB->getOne($sql); if (!$admin or !$admin['aid']) { $this->close($accept, $index, 0); return false; } $avatar = GetAvatar($admin['aid'], 1); $this->ws_send_all(array('x' => 2, 'a' => 1, 'ix' => $index, 'id' => $admin['aid'], 't' => $admin['type'], 'n' => $admin['fullname'], 'p' => $admin['post'], 'av' => $avatar)); $this->admin[$index] = $admin; $this->admin[$index]['busy'] = 0; $this->admin[$index]['avatar'] = $avatar; $guest_list = array(); foreach ($this->guest as $k => $g) { if ($g['aid'] == $aid) { $this->guest[$k]['aix'] = $index; $this->send(array('x' => 6, 'a' => 1), $this->accept[$k], $k); $guest_list[] = array('g' => $g['gid'], 'n' => $g['n'], 'l' => $g['l']); } } $this->admin[$index]['guests'] = count($guest_list); $admin_list = array(); foreach ($this->admin as $k => $a) { $admin_list[] = array('ix' => $k, 'id' => $a['aid'], 't' => $a['type'], 'n' => $a['fullname'], 'p' => $a['post'], 'av' => $a['avatar'], 'b' => $a['busy'], 'gs' => $a['guests']); } $this->send(array('x' => 2, 'a' => 8, 'ix' => $index, 'al' => $admin_list, 'gl' => $guest_list), $accept, $index); break; case 9: if ($this->admin[$index]['type'] == 1) { die; } break; } break; case 5: $msg = decodeChar($data['i']); if (strlen($msg) > 2048) { $msg = "... too long ..."; } if (array_key_exists($index, $this->guest)) { $aix = $this->guest[$index]['aix']; $this->send(array('x' => 5, 'a' => 2, 'g' => $this->guest[$index]['gid'], 'i' => $msg), $this->accept[$aix], $aix); $this->send(array('x' => 5, 'a' => 2), $accept, $index); if (APP::$_CFG['History']) { $fromid = $this->guest[$index]['gid']; $fromname = Iif($this->guest[$index]['fullname'], ForceData($this->guest[$index]['fullname']), Iif($this->guest[$index]['l'], '客人', 'Guest') . $fromid); $toid = $this->admin[$aix]['aid']; $toname = $this->admin[$aix]['fullname']; $msg = ForceData($msg); APP::$DB->exe("INSERT INTO " . TABLE_PREFIX . "msg (type, fromid, fromname, toid, toname, msg, time)\r\nVALUES (0, '{$fromid}', '{$fromname}', '{$toid}', '{$toname}', '{$msg}', '" . time() . "')"); } } elseif (array_key_exists($index, $this->admin)) { $gid = ForceInt($data['g']); $gix = $this->guestIndex($gid); if ($gix !== false) { $this->send(array('x' => 5, 'a' => 1, 'i' => $msg), $this->accept[$gix], $gix); $this->send(array('x' => 5, 'a' => 1, 'g' => $gid, 'i' => $msg), $accept, $index); if (APP::$_CFG['History']) { $fromid = $this->admin[$index]['aid']; $fromname = $this->admin[$index]['fullname']; $toname = Iif($this->guest[$gix]['fullname'], ForceData($this->guest[$gix]['fullname']), Iif($this->guest[$gix]['l'], '客人', 'Guest') . $gid); $msg = ForceData($msg); APP::$DB->exe("INSERT INTO " . TABLE_PREFIX . "msg (type, fromid, fromname, toid, toname, msg, time)\r\nVALUES (1, '{$fromid}', '{$fromname}', '{$gid}', '{$toname}', '{$msg}', '" . time() . "')"); } } } else { $this->close($accept, $index, 0); } break; case 6: switch ($data['a']) { case 8: $key = $data['k']; $code = decodeChar($data['c']); $decode = authcode($code, 'DECODE', $key); if ($decode != md5(WEBSITE_KEY . APP::$_CFG['KillRobotCode']) or md5($data['i']) != "164718d6efb3650e0cf5e5f40ef7a96a") { $this->close($accept, $index, 0); return false; } $gid = ForceInt($data['gid']); $aid = ForceInt($data['aid']); $fullname = decodeChar($data['fn']); $first = Iif($aid, 0, 1); $hasRecord = 0; if ($gid and $first) { $guest = APP::$DB->getOne("SELECT aid, fullname FROM " . TABLE_PREFIX . "guest WHERE gid = '{$gid}'"); if ($guest and $guest['aid']) { $aid = $guest['aid']; $fullname = $guest['fullname']; $hasRecord = 1; } } $admin_index = $this->select_admin($aid); if ($admin_index === false) { $this->send(array('x' => 6, 'a' => 9), $accept, $index); $this->close($accept, $index, 0); return false; } if (isset($this->admin[$admin_index])) { $this->admin[$admin_index]['guests'] += 1; } $aid = $this->admin[$admin_index]['aid']; $lang = ForceInt($data['l']); $fromurl = ForceData($data['fr']); $browser = ForceData($data['ag']); $lastip = $this->ip($accept); $ipzone = convertip($lastip); $timenow = time(); if ($gid) { $this->clearGuest($gid); } $recs = array(); if ($first and $gid and $hasRecord) { APP::$DB->exe("UPDATE " . TABLE_PREFIX . "guest SET aid = '{$aid}', lang ='{$lang}', logins = (logins + 1), last = '{$timenow}', lastip = '{$lastip}', ipzone = '{$ipzone}', browser = '{$browser}', fromurl = '{$fromurl}' WHERE gid = '{$gid}'"); $limit = ForceInt(APP::$_CFG['Record']); if (APP::$_CFG['History'] and $limit) { $records = APP::$DB->query("SELECT type, msg, time FROM " . TABLE_PREFIX . "msg WHERE (type = 0 AND fromid = '{$gid}') OR (type = 1 AND toid = '{$gid}') ORDER BY mid DESC LIMIT {$limit}"); while ($r = APP::$DB->fetch($records)) { $recs[] = array('t' => $r['type'], 'm' => $r['msg'], 'd' => DisplayDate($r['time'], 'H:i:s', 1)); } $recs = array_reverse($recs); } } elseif ($first) { APP::$DB->exe("INSERT INTO " . TABLE_PREFIX . "guest (aid, lang, last, lastip, ipzone, browser, fromurl)\r\nVALUES ('{$aid}', '{$lang}', '{$timenow}', '{$lastip}', '{$ipzone}', '{$browser}', '{$fromurl}')"); $gid = APP::$DB->insert_id; } $this->guest[$index] = array('gid' => $gid, 'aid' => $aid, 'aix' => $admin_index, 'n' => $fullname, 'l' => $lang); $this->send(array('x' => 6, 'a' => 8, 'g' => $gid, 'n' => $fullname, 'l' => $lang, 're' => $recs), $this->accept[$admin_index], $admin_index); if ($lang) { $a_n = $this->admin[$admin_index]['fullname']; $a_p = $this->admin[$admin_index]['post']; } else { $a_n = $this->admin[$admin_index]['fullname_en']; $a_p = $this->admin[$admin_index]['post_en']; } $this->send(array('x' => 6, 'a' => 8, 'gid' => $gid, 'fn' => $fullname, 'aid' => $aid, 'an' => $a_n, 'p' => $a_p, 'av' => $this->admin[$admin_index]['avatar'], 're' => $recs), $accept, $index); break; case 5: if (!$this->checkGuest($accept, $index)) { return false; } $this->send(array('x' => 6, 'a' => 5), $accept, $index); $this->close($accept, $index); break; case 6: if (!$this->checkAdmin($accept, $index)) { return false; } $gid = ForceInt($data['g']); $gix = $this->guestIndex($gid); if ($gix !== false) { if (isset($this->admin[$index])) { $this->admin[$index]['guests'] -= 1; } $this->send(array('x' => 6, 'a' => 6), $this->accept[$gix], $gix); unset($this->guest[$gix]); $this->close($this->accept[$gix], $gix, 0); } if ($gid) { APP::$DB->exe("UPDATE " . TABLE_PREFIX . "guest SET banned = (banned + 1) WHERE gid = '{$gid}'"); } break; case 7: if (!$this->checkAdmin($accept, $index)) { return false; } $gid = ForceInt($data['g']); $gix = $this->guestIndex($gid); if ($gix !== false) { $this->send(array('x' => 6, 'a' => 7), $this->accept[$gix], $gix); } break; case 10: if (!$this->checkAdmin($accept, $index)) { return false; } $gid = ForceInt($data['g']); $gix = $this->guestIndex($gid); if ($gix !== false) { $this->send(array('x' => 6, 'a' => 10), $this->accept[$gix], $gix); } break; case 11: if (!$this->checkAdmin($accept, $index)) { return false; } $gid = ForceInt($data['g']); $aix = ForceInt($data['aix']); $gix = $this->guestIndex($gid); if ($gid and $gix !== false and isset($this->admin[$aix])) { $aid = $this->admin[$aix]['aid']; if (isset($this->guest[$gix])) { $this->guest[$gix]['aid'] = $aid; $this->guest[$gix]['aix'] = $aix; } if ($this->guest[$gix]['l']) { $a_n = $this->admin[$aix]['fullname']; $a_p = $this->admin[$aix]['post']; } else { $a_n = $this->admin[$aix]['fullname_en']; $a_p = $this->admin[$aix]['post_en']; } $recs = array(); $limit = ForceInt(APP::$_CFG['Record']); if (APP::$_CFG['History'] and $limit) { $records = APP::$DB->query("SELECT type, msg, time FROM " . TABLE_PREFIX . "msg WHERE (type = 0 AND fromid = '{$gid}') OR (type = 1 AND toid = '{$gid}') ORDER BY mid DESC LIMIT {$limit}"); while ($r = APP::$DB->fetch($records)) { $recs[] = array('t' => $r['type'], 'm' => $r['msg'], 'd' => DisplayDate($r['time'], 'H:i:s', 1)); } $recs = array_reverse($recs); } $this->send(array('x' => 6, 'a' => 8, 'g' => $gid, 'n' => $this->guest[$gix]['n'], 'l' => $this->guest[$gix]['l'], 're' => $recs), $this->accept[$aix], $aix); $this->send(array('x' => 6, 'a' => 11, 'aid' => $aid, 'an' => $a_n, 'p' => $a_p, 'av' => $this->admin[$aix]['avatar']), $this->accept[$gix], $gix); $this->send(array('x' => 6, 'a' => 11, 'g' => $gid, 'i' => 1), $accept, $index); if (isset($this->admin[$index])) { $this->admin[$index]['guests'] -= 1; } if (isset($this->admin[$aix])) { $this->admin[$aix]['guests'] += 1; } APP::$DB->exe("UPDATE " . TABLE_PREFIX . "guest SET aid = '{$aid}' WHERE gid = '{$gid}'"); } else { $this->send(array('x' => 6, 'a' => 11, 'g' => $gid, 'i' => 0), $accept, $index); } break; } break; default: $this->close($accept, $index, 0); break; } }
function _parse_attributes($string) { return is_array($string) ? $string : string_to_array($string); }
<? $libs = array('jquery'); foreach($this->e->modules_by_slug as $module_slug=>$m) { if (!isset($m->jquery)) continue; $m->jquery = string_to_array($m->jquery); $libs = array_merge($libs, $m->jquery); } $libs = array_unique($libs); $deps = array( 'ui.effects'=>array('ui'), 'ui.interactions'=>array('ui','ui.effects'), 'ui.widgets'=>array('ui', 'ui.effects', 'ui.interactions', 'dynamicform'), 'daterangepicker'=>array('urlencode','ui', 'ui.effects', 'ui.interactions', 'clockpick'), 'styled_button'=>array('urlencode','ui','ui.widgets', 'ui.effects', 'ui.interactions'), 'validate'=>array('ajax_form', 'metadata'), ); $final_libs = array(); //$conflicts = array(array('tabs', 'ui.widgets')); $conflicts=array(); $added=true; while($added) { $added=false; foreach($libs as $lib) {
function welive_call($data, $accept, $index) { $data = string_to_array($data); switch ($data['x']) { case 4: if (!$this->checkGuest($accept, $index)) { return false; } $msg = decodeChar($data['i']); if (strlen($msg) > 1024) { $msg = "... too long ..."; } $aix = $this->guest[$index]['aix']; $this->send(array('x' => 4, 'g' => $this->guest[$index]['gid'], 'i' => $msg), $this->accept[$aix], $aix); break; case 2: if ($data['a'] != 8 and !$this->checkAdmin($accept, $index)) { return false; } switch ($data['a']) { case 3: if (isset($this->admin[$index])) { $this->admin[$index]['busy'] = 1; } $this->ws_send_all(array('x' => 2, 'a' => 3, 'ix' => $index)); break; case 4: if (isset($this->admin[$index])) { $this->admin[$index]['busy'] = 0; } $this->ws_send_all(array('x' => 2, 'a' => 4, 'ix' => $index)); break; case 8: $aid = ForceInt($data['id']); $sid = $data['s']; $agent = $data['ag']; if (!$aid or !IsAlnum($sid) or !IsAlnum($agent)) { $this->close($accept, $index, 0); return false; } $sql = "SELECT a.aid, a.type, a.username, a.fullname, a.fullname_en, a.post, a.post_en, a.lastip AS ip\nFROM " . TABLE_PREFIX . "session s\nLEFT JOIN " . TABLE_PREFIX . "admin a ON a.aid = s.aid\nWHERE s.sid = '{$sid}'\nAND s.aid = '{$aid}'\nAND s.agent = '{$agent}'\nAND a.activated = 1"; $admin = APP::$DB->getOne($sql); if (!$admin or !$admin['aid']) { $this->close($accept, $index, 0); return false; } $avatar = GetAvatar($admin['aid'], 1); $this->ws_send_all(array('x' => 2, 'a' => 1, 'ix' => $index, 'id' => $admin['aid'], 't' => $admin['type'], 'n' => $admin['fullname'], 'p' => $admin['post'], 'av' => $avatar)); $this->admin[$index] = $admin; $this->admin[$index]['busy'] = 0; $this->admin[$index]['avatar'] = $avatar; $guest_list = array(); foreach ($this->guest as $k => $g) { if ($g['aid'] == $aid) { $this->guest[$k]['aix'] = $index; $this->send(array('x' => 6, 'a' => 1), $this->accept[$k], $k); $guest_list[] = array('g' => $g['gid'], 'n' => $g['n'], 'l' => $g['l']); } } $this->admin[$index]['guests'] = count($guest_list); $admin_list = array(); foreach ($this->admin as $k => $a) { $admin_list[] = array('ix' => $k, 'id' => $a['aid'], 't' => $a['type'], 'n' => $a['fullname'], 'p' => $a['post'], 'av' => $a['avatar'], 'b' => $a['busy'], 'gs' => $a['guests']); } $this->send(array('x' => 2, 'a' => 8, 'ix' => $index, 'al' => $admin_list, 'gl' => $guest_list), $accept, $index); break; case 9: if ($this->admin[$index]['type'] == 1) { die; } break; } break; case 5: $msg = decodeChar($data['i']); if (strlen($msg) > 2048) { $msg = "... too long ..."; } if (array_key_exists($index, $this->guest)) { $aix = $this->guest[$index]['aix']; $this->send(array('x' => 5, 'a' => 2, 'g' => $this->guest[$index]['gid'], 'i' => $msg), $this->accept[$aix], $aix); $this->send(array('x' => 5, 'a' => 2), $accept, $index); } elseif (array_key_exists($index, $this->admin)) { $gid = ForceInt($data['g']); $gix = $this->guestIndex($gid); if ($gix !== false) { $this->send(array('x' => 5, 'a' => 1, 'i' => $msg), $this->accept[$gix], $gix); $this->send(array('x' => 5, 'a' => 1, 'g' => $gid, 'i' => $msg), $accept, $index); } } else { $this->close($accept, $index, 0); } break; case 6: switch ($data['a']) { case 8: $key = $data['k']; $code = decodeChar($data['c']); $decode = authcode($code, 'DECODE', $key); if ($decode != md5(WEBSITE_KEY . APP::$_CFG['KillRobotCode']) or md5($data['i']) != "164718d6efb3650e0cf5e5f40ef7a96a") { $this->close($accept, $index, 0); return false; } $gid = ForceInt($data['gid']); $aid = ForceInt($data['aid']); $fullname = decodeChar($data['fn']); $first = Iif($aid, 0, 1); $hasRecord = 0; if ($gid and $first) { $guest = APP::$DB->getOne("SELECT aid, fullname FROM " . TABLE_PREFIX . "guest WHERE gid = '{$gid}'"); if ($guest and $guest['aid']) { $aid = $guest['aid']; $fullname = $guest['fullname']; $hasRecord = 1; } } $admin_index = $this->select_admin($aid); if ($admin_index === false) { $this->send(array('x' => 6, 'a' => 9), $accept, $index); $this->close($accept, $index, 0); return false; } if (isset($this->admin[$admin_index])) { $this->admin[$admin_index]['guests'] += 1; } $aid = $this->admin[$admin_index]['aid']; $lang = ForceInt($data['l']); $fromurl = ForceData($data['fr']); $browser = ForceData($data['ag']); $lastip = $this->ip($accept); $ipzone = convertip($lastip); $timenow = time(); if ($gid) { $this->clearGuest($gid); } $recs = array(); if ($first and $gid and $hasRecord) { APP::$DB->exe("UPDATE " . TABLE_PREFIX . "guest SET aid = '{$aid}', lang ='{$lang}', logins = (logins + 1), last = '{$timenow}', lastip = '{$lastip}', ipzone = '{$ipzone}', browser = '{$browser}', fromurl = '{$fromurl}' WHERE gid = '{$gid}'"); } elseif ($first) { APP::$DB->exe("INSERT INTO " . TABLE_PREFIX . "guest (aid, lang, last, lastip, ipzone, browser, fromurl)\nVALUES ('{$aid}', '{$lang}', '{$timenow}', '{$lastip}', '{$ipzone}', '{$browser}', '{$fromurl}')"); $gid = APP::$DB->insert_id; } $this->guest[$index] = array('gid' => $gid, 'aid' => $aid, 'aix' => $admin_index, 'n' => $fullname, 'l' => $lang); $this->send(array('x' => 6, 'a' => 8, 'g' => $gid, 'n' => $fullname, 'l' => $lang, 're' => $recs), $this->accept[$admin_index], $admin_index); if ($lang) { $a_n = $this->admin[$admin_index]['fullname']; $a_p = $this->admin[$admin_index]['post']; } else { $a_n = $this->admin[$admin_index]['fullname_en']; $a_p = $this->admin[$admin_index]['post_en']; } $this->send(array('x' => 6, 'a' => 8, 'gid' => $gid, 'fn' => $fullname, 'aid' => $aid, 'an' => $a_n, 'p' => $a_p, 'av' => $this->admin[$admin_index]['avatar'], 're' => $recs), $accept, $index); break; case 5: if (!$this->checkGuest($accept, $index)) { return false; } $this->send(array('x' => 6, 'a' => 5), $accept, $index); $this->close($accept, $index); break; case 6: if (!$this->checkAdmin($accept, $index)) { return false; } $gid = ForceInt($data['g']); $gix = $this->guestIndex($gid); if ($gix !== false) { if (isset($this->admin[$index])) { $this->admin[$index]['guests'] -= 1; } $this->send(array('x' => 6, 'a' => 6), $this->accept[$gix], $gix); unset($this->guest[$gix]); $this->close($this->accept[$gix], $gix, 0); } if ($gid) { APP::$DB->exe("UPDATE " . TABLE_PREFIX . "guest SET banned = (banned + 1) WHERE gid = '{$gid}'"); } break; case 7: if (!$this->checkAdmin($accept, $index)) { return false; } $gid = ForceInt($data['g']); $gix = $this->guestIndex($gid); if ($gix !== false) { $this->send(array('x' => 6, 'a' => 7), $this->accept[$gix], $gix); } break; case 10: if (!$this->checkAdmin($accept, $index)) { return false; } $gid = ForceInt($data['g']); $gix = $this->guestIndex($gid); if ($gix !== false) { $this->send(array('x' => 6, 'a' => 10), $this->accept[$gix], $gix); } break; case 11: if (!$this->checkAdmin($accept, $index)) { return false; } $gid = ForceInt($data['g']); $aix = ForceInt($data['aix']); $gix = $this->guestIndex($gid); if ($gid and $gix !== false and isset($this->admin[$aix])) { $aid = $this->admin[$aix]['aid']; if (isset($this->guest[$gix])) { $this->guest[$gix]['aid'] = $aid; $this->guest[$gix]['aix'] = $aix; } if ($this->guest[$gix]['l']) { $a_n = $this->admin[$aix]['fullname']; $a_p = $this->admin[$aix]['post']; } else { $a_n = $this->admin[$aix]['fullname_en']; $a_p = $this->admin[$aix]['post_en']; } $recs = array(); $this->send(array('x' => 6, 'a' => 8, 'g' => $gid, 'n' => $this->guest[$gix]['n'], 'l' => $this->guest[$gix]['l'], 're' => $recs), $this->accept[$aix], $aix); $this->send(array('x' => 6, 'a' => 11, 'aid' => $aid, 'an' => $a_n, 'p' => $a_p, 'av' => $this->admin[$aix]['avatar']), $this->accept[$gix], $gix); $this->send(array('x' => 6, 'a' => 11, 'g' => $gid, 'i' => 1), $accept, $index); if (isset($this->admin[$index])) { $this->admin[$index]['guests'] -= 1; } if (isset($this->admin[$aix])) { $this->admin[$aix]['guests'] += 1; } APP::$DB->exe("UPDATE " . TABLE_PREFIX . "guest SET aid = '{$aid}' WHERE gid = '{$gid}'"); } else { $this->send(array('x' => 6, 'a' => 11, 'g' => $gid, 'i' => 0), $accept, $index); } break; } break; default: $this->close($accept, $index, 0); break; } }
function get($key) { if ($this->redis) { $value = $this->redis->get($key); return string_to_array($value); } return false; }