/** * Sets and shows an alert * * @param string $message * @param string $type = "Error" * @param boolean $URL = NULL * @return string value */ function getAlert($message, $type = "error", $URL = NULL) { if (!is_null($URL)) { $message = a(__(_($message)), encode($URL), TRUE); } if ($type === "error") { return '<div id="alert-message" class="alert alert-error"> <a class="close">×</a> ' . __(_($message)) . ' </div>'; } elseif ($type === "success") { unset($_POST); return '<div id="alert-message" class="alert alert-success"> <a class="close">×</a> ' . __(_($message)) . ' </div>'; } elseif ($type === "warning") { return '<div id="alert-message" class="alert alert-warning"> <a class="close">×</a> ' . __(_($message)) . ' </div>'; } elseif ($type === "notice") { return '<div id="alert-message" class="alert alert-info"> <a class="close">×</a> ' . __(_($message)) . ' </div>'; } }
public function actiongetAutocompleteSuggestions() { $db = $this->_environment->getDBConnector(); list($search_word) = explode(' ', $this->_data['search_text']); /************************************************************************************ * Instead of joining with the index table and taking the matching count as reference, * we just read from the search_word table ************************************************************************************/ /* $query = ' SELECT sw_word FROM search_word LEFT JOIN search_index ON search_word.sw_id = search_index.si_sw_id WHERE sw_word LIKE "' . encode(AS_DB, $search_word) . '%" ORDER BY si_count LIMIT 0, 20 '; */ $query = "\n\t\t\t\tSELECT\n\t\t\t\t\tsw_word\n\t\t\t\tFROM\n\t\t\t\t\tsearch_word\n\t\t\t\tWHERE\n\t\t\t\t\tsw_word LIKE '" . encode(AS_DB, $search_word) . "%';\n\t\t\t"; $result = $db->performQuery($query); $words = array(); foreach ($result as $word) { $words[] = $word['sw_word']; } $this->setSuccessfullDataReturn($words); echo $this->_return; }
public function get_list() { if ($this->input->is_ajax_request() && $this->input->get()) { $search = $this->input->get('search'); $limit = $this->input->get('length'); $offset = $this->input->get('start'); $columns = $this->input->get('columns'); $order_arr = $this->input->get('order'); $order_direction = strtoupper($order_arr[0]['dir']); $order_column = $order_arr[0]['column']; $order_column = $columns[$order_column]['data']; $data = $this->account_model->get_list(trim($search), $order_column, $order_direction, $limit, $offset); $json['data'] = array(); $i = $offset + 1; foreach ($data['rows'] as $row) { $row->no = $i++; $row->account_id = encode($row->account_id); $edit_url = base_url("accounting/account/edit/{$row->account_id}"); $row->action = "<button title='Edit' class='btn btn-xs btn-success edit_btn' onclick='doEdit(\"{$edit_url}\")'><i class='fa fa-pencil'></i></button>\n <button title='Hapus' class='btn btn-xs btn-default' onclick='doDelete(\"{$row->account_id}\", \"{$row->account_name}\")'><i class='fa fa-remove'></i></button>"; array_push($json['data'], $row); } $json['recordsTotal'] = $data['total']; $json['recordsFiltered'] = $data['total']; $json['draw'] = $this->input->post('draw'); echo json_encode($json); } else { echo 'Forbidden access!'; } }
public function index($payid) { if (is_login()) { $uid = get_temp_uid(); if (empty($payid)) { $payid = I('payid'); } $db = D('Home/AccountGoods'); $map['payid'] = $payid; $map['uid'] = $uid; $list = $db->where($map)->relation(true)->select(); if (!empty($list)) { $this->assign('list', $list); $total = $this->total($list); $this->assign('total', $total); } // echo $db->getLastSql(); // echo dump($list); $db = M('member'); $user = $db->field('money,score')->find($uid); $score = intval($user['score']); $user['_score'] = $score; $score = floor($score / 100) * 100; $user['score'] = $score; $this->assign('account', $user); $this->assign('title', '结算支付'); $this->assign('payid', $payid); layout(false); $this->display(); } else { $this->redirect('Home/Person/login/' . encode('Pay/index')); } }
/** * formCheckbox * * Sets a specific <input /> type Checkbox tag and its attributes * * @param string $text = NULL * @param string $position = "Right" * @param string $name * @param string $value * @param string $ID = NULL * @param boolean $checked = FALSE * @param string $events = NULL * @param boolean $disabled = FALSE * @return string value */ function formCheckbox($attributes = FALSE) { if (isset($attributes) and is_array($attributes)) { $attrs = NULL; foreach ($attributes as $attribute => $value) { if ($attribute !== "position" and $attribute !== "text" and $attribute !== "type" and $attribute !== "checked") { $attrs .= ' ' . strtolower($attribute) . '="' . encode($value) . '"'; } else { ${$attribute} = encode($value); } } if (isset($checked) and $checked) { $check = ' checked="checked"'; } else { $check = NULL; } if (isset($position) and $position === "left" and isset($text)) { return $text . ' <input' . $attrs . ' type="checkbox"' . $check . ' />'; } elseif (isset($position) and $position === "right" and isset($text)) { return '<input' . $attrs . ' type="checkbox"' . $check . ' /> ' . $text; } elseif (isset($text)) { return $text . ' <input' . $attrs . ' type="checkbox"' . $check . ' />'; } else { return '<input' . $attrs . ' type="checkbox"' . $check . ' />'; } } else { return NULL; } }
function plugin_counter_get_count($page) { global $vars; static $counters = array(); static $default; $qm = get_qm(); if (!isset($default)) { $default = array('total' => 0, 'date' => get_date('Y/m/d'), 'today' => 0, 'yesterday' => 0, 'ip' => ''); } if (!is_page($page)) { return $default; } if (isset($counters[$page])) { return $counters[$page]; } // Set default $counters[$page] = $default; $modify = FALSE; $file = COUNTER_DIR . encode($page) . PLUGIN_COUNTER_SUFFIX; $fp = fopen($file, file_exists($file) ? 'r+' : 'w+') or die('counter.inc.php: ' . $qm->replace('fmt_err_open_counterdir', basename($file))); set_file_buffer($fp, 0); flock($fp, LOCK_EX); rewind($fp); foreach ($default as $key => $val) { // Update $counters[$page][$key] = rtrim(fgets($fp, 256)); if (feof($fp)) { break; } } if ($counters[$page]['date'] != $default['date']) { // New day $modify = TRUE; $is_yesterday = $counters[$page]['date'] == get_date('Y/m/d', time() - 86400); $counters[$page]['ip'] = $_SERVER['REMOTE_ADDR']; $counters[$page]['date'] = $default['date']; $counters[$page]['yesterday'] = $is_yesterday ? $counters[$page]['today'] : 0; $counters[$page]['today'] = 1; $counters[$page]['total']++; } else { if ($counters[$page]['ip'] != $_SERVER['REMOTE_ADDR']) { // Not the same host $modify = TRUE; $counters[$page]['ip'] = $_SERVER['REMOTE_ADDR']; $counters[$page]['today']++; $counters[$page]['total']++; } } // Modify if ($modify && $vars['cmd'] == 'read') { rewind($fp); ftruncate($fp, 0); foreach (array_keys($default) as $key) { fputs($fp, $counters[$page][$key] . "\n"); } } flock($fp, LOCK_UN); fclose($fp); return $counters[$page]; }
function __construct($schema) { if (!is_object($schema)) { $schema = decode(encode($schema)); } $this->schema = $schema; }
public function get_list() { if ($this->input->is_ajax_request() && $this->input->get()) { $data_post = $this->input->get(); $search = $data_post['search']; $limit = $data_post['length']; $offset = $data_post['start']; $columns = $data_post['columns']; $order_arr = $data_post['order']; $order_direction = strtoupper($order_arr[0]['dir']); $order_column = $order_arr[0]['column']; $order_column = $columns[$order_column]['data']; $data = $this->phonebook_model->get_list($search, $order_column, $order_direction, $limit, $offset); $json['data'] = array(); $i = $offset + 1; $this->load->helper('text_helper'); foreach ($data['rows'] as $row) { $phonebook_id = encode($row->phonebook_id); $row->no = $i++; $edit_url = base_url("messaging/phonebook/edit/{$row->phonebook_id}"); $row->action = "<button title='Edit' class='btn btn-xs btn-success edit_btn' onclick='doEdit(\"{$edit_url}\")'><i class='fa fa-pencil'></i></button>\n <button title='Hapus' class='btn btn-xs btn-default' onclick='doDelete(\"{$row->phonebook_id}\", \"{$row->name}\")'><i class='fa fa-remove'></i></button>"; array_push($json['data'], $row); } $json['recordsTotal'] = $data['total']; $json['recordsFiltered'] = $data['total']; $json['draw'] = $data_post['draw']; echo json_encode($json); } else { echo '{^_^) Gincusoft.'; } }
function formCheckbox($attributes = false) { if (isset($attributes) and is_array($attributes)) { $attrs = null; foreach ($attributes as $attribute => $value) { if ($attribute !== "position" and $attribute !== "text" and $attribute !== "type" and $attribute !== "checked") { $attrs .= ' ' . strtolower($attribute) . '="' . encode($value) . '"'; } else { ${$attribute} = encode($value); } } $check = (isset($checked) and $checked) ? ' checked="checked"' : null; if (isset($position) and $position === "left" and isset($text)) { return '' . decode($text) . ' <input' . $attrs . ' type="checkbox"' . $check . ' /> '; } elseif (isset($position) and $position === "right" and isset($text)) { return '<input' . $attrs . ' type="checkbox"' . $check . ' /> ' . decode($text) . ' '; } elseif (isset($text)) { return '' . decode($text) . ' <input' . $attrs . ' type="checkbox"' . $check . ' /> '; } else { return '<input' . $attrs . ' type="checkbox"' . $check . ' /> '; } } else { return null; } }
public function get_list() { if ($this->input->is_ajax_request() && $this->input->get()) { $data_post = $this->input->get(); $search = $data_post['search']; $limit = $data_post['length']; $offset = $data_post['start']; $columns = $data_post['columns']; $order_arr = $data_post['order']; $order_direction = strtoupper($order_arr[0]['dir']); $order_column = $order_arr[0]['column']; $order_column = $columns[$order_column]['data']; $data = $this->inbox_model->get_list($search, $order_column, $order_direction, $limit, $offset); $json['data'] = array(); $i = $offset + 1; $this->load->helper('text_helper'); foreach ($data['rows'] as $row) { $inbox_id = encode($row->sms_sender); $row->no = $i++; $url_edit = base_url("messaging/inbox/detail/{$inbox_id}"); $row->sms_sender = "<a class='text-black' onclick='doDetail(\"{$url_edit}\", this); return false;' href=''>{$row->sms_sender}</a>"; $row->sms_text_short = word_limiter($row->sms_text, 5); $row->sms_text = "<a class='text-black' onclick='doDetail(\"{$url_edit}\", this); return false;' href=''>" . word_limiter($row->sms_text, 15) . "</a>"; $row->sms_date = timestamp_to_human($row->sms_date); $row->action = "<button title='Hapus' class='btn btn-xs btn-default' onclick='doDelete(\"{$inbox_id}\")'><i class='fa fa-remove'></i></button>"; array_push($json['data'], $row); } $json['recordsTotal'] = $data['total']; $json['recordsFiltered'] = $data['total']; $json['draw'] = $data_post['draw']; echo json_encode($json); } else { echo '{^_^) Gincusoft.'; } }
public function get_list() { if ($this->input->is_ajax_request() && $this->input->post()) { $data_post = $this->input->post(); // $search = $data_post['search']; $limit = $data_post['length']; $offset = $data_post['start']; $columns = $data_post['columns']; $order_arr = $data_post['order']; $order_direction = strtoupper($order_arr[0]['dir']); $order_column = $order_arr[0]['column']; $order_column = $columns[$order_column]['data']; $data = $this->journals_model->get_list($data_post, $order_column, $order_direction, $limit, $offset); $json['data'] = array(); $i = $offset + 1; foreach ($data['rows'] as $row) { $journals_id = encode($row->journals_id); $row->no = $i++; $row->journals_date = sql_to_human($row->journals_date); $row->debit_txt = format_idr_currency($row->debit); $row->credit_txt = format_idr_currency($row->credit); $edit_url = base_url("accounting/journals/edit/{$journals_id}"); $row->action = "<button onclick='doEdit(\"{$edit_url}\")' title='Edit' class='btn btn-xs btn-success edit_btn')'><i class='fa fa-pencil'></i></button>\n <button title='Hapus' class='btn btn-xs btn-default' onclick='doDelete(\"{$journals_id}\", \"{$row->account_name}\")'><i class='fa fa-remove'></i></button>"; // $row->invoice = anchor("journals/view/{$journals_id}", $row->invoice, 'title="Klik untuk lebih lengkap" target="_blank"'); array_push($json['data'], $row); } $json['recordsTotal'] = $data['total']; $json['recordsFiltered'] = $data['total']; $json['draw'] = $data_post['draw']; echo json_encode($json); } else { echo 'Forbidden access!'; } }
function indexAction() { if (POST) { set_time_limit(999999); $emails = $users = array(); $emailRaw = $this->user->ImportContacts($_POST['of'], $_POST["n"], $_POST["p"]); foreach ($emailRaw["out"] as $k => $v) { if ($this->user->CheckEmail($v[0])) { $usr = $this->user->GetDetailsByEmail($v[0]); $usrNam = strlen($usr["fname"] . $usr["lname"]) < 10 ? $usr["fname"] . " " . $usr["lname"] : (strlen($usr["fname"]) < 10 ? $usr["fname"] : substr($usr["fname"], 0, 10) . '..'); $users[] = array(encode($usr["id"]), $usr["image"], $usrNam, ($usr["gender"] == "M" ? "Male" : "Female") . ", " . timeDiff(strtotime($usr["birthDay"]), array('parts' => 1, 'precision' => 'year', 'separator' => '', 'next' => ''))); } else { $eM = array("n" => $k, "i" => encode($v[1])); if (strpos($v[0], "@")) { $eM = array_merge($eM, array("e" => $v[0])); } if ($v[2] > 0) { $eM = array_merge($eM, array("m" => $v[2])); } $emails[] = $eM; } } die(json_encode(array("emails" => $emails, "users" => $users, "m" => count($emails) > 0 ? "You got " . count($emails) . " contacts from your " . $_POST["of"] . " id." : "<strong>No contacts found.</strong><br />May be your login are invalid.", "mT" => count($emails) > 0 ? "yeppe" : ""))); } $this->view->outContacts = $this->user->outContacts(); $this->view->inContacts = $this->user->inContacts(); }
function guestBookPost($intSpamFiler, $intIsSecret) { global $DMC, $DBPrefix, $arrSideModule; $parent = 0; $_POST['isSecret'] = !empty($_POST['isSecret']) ? $_POST['isSecret'] : 0; $author = !empty($_POST['username']) ? $_POST['username'] : $_SESSION['username']; $replypassword = !empty($_POST['replypassword']) ? md5($_POST['replypassword']) : ""; if (!empty($_POST['homepage'])) { if (strpos(";" . $_POST['homepage'], "http://") < 1) { $homepage = "http://" . $_POST['homepage']; } else { $homepage = $_POST['homepage']; } } else { $homepage = ""; } $email = !empty($_POST['email']) ? $_POST['email'] : ""; $_POST['bookface'] = !empty($_POST['bookface']) ? $_POST['bookface'] : "face1"; $sql = "insert into " . $DBPrefix . "guestbook(author,password,homepage,email,ip,content,postTime,isSecret,parent,face,isSpam) values('{$author}','{$replypassword}','" . encode($homepage) . "','" . encode($email) . "','" . getip() . "','" . encode($_POST['message']) . "','" . time() . "','" . max(intval($intIsSecret), intval($_POST['isSecret'])) . "','{$parent}','" . substr(encode($_POST['bookface']), 4) . "','" . $intSpamFiler . "')"; //echo $sql; $DMC->query($sql); //更新cache settings_recount("guestbook"); settings_recache(); recentGbooks_recache(); logs_sidebar_recache($arrSideModule); //保存时间 $_SESSION['replytime'] = time(); }
function indexAction() { if ($this->getRequest()->getParam('ref')) { $user = new UsersModel(); $this->view->InvitedUser = $user->InvitedContact(decode($this->getRequest()->getParam('ref'))); if ($this->session->user["id"] > 0) { $this->_redirect("bio/" . encode($this->view->InvitedUser["uid"]) . "#slams/post"); } $user = new UsersModel($this->view->InvitedUser["uid"]); $this->view->InviteeUser = $user->Info(); } if ($this->getRequest()->getParam('userid')) { if ($this->session->user["id"] > 0) { $this->_redirect("bio/" . $this->getRequest()->getParam('userid')); } $user = new UsersModel(decode($this->getRequest()->getParam("userid"))); $iV = $this->view->InviteeUser = $user->Info(); $this->view->error = array("<strong>Login</strong> to view " . ($iV['gender'] == 'M' ? 'his' : 'her') . " <strong>tweets</strong>, <strong>slambook</strong> and other <strong>exciting</strong> stuffs.<br />New users can <strong>signup</strong> with a <strong>single step »</strong>", 60, "welcome"); } if ($this->session->user["id"] > 0) { $this->_redirect("my"); } $user = new UsersModel(); $this->view->users = $user->Search(array(), array(0, 12), NULL, array("gender DESC")); }
function upload() { $uemail = $_POST['uemail']; $sql = "SELECT uid FROM customers_auth WHERE email ='{$uemail}'"; global $conn; $result = mysqli_query($conn, $sql); while ($row = $result->fetch_assoc()) { $userFolder = $row["uid"]; } $target_dir = "uploads/{$userFolder}/"; $exist = is_dir($target_dir); if (!$exist) { mkdir("{$target_dir}"); chmod("{$target_dir}", 0755); } else { } $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]); $uploadOk = 1; $imageFileType = pathinfo($target_file, PATHINFO_EXTENSION); // Check if image file is a actual image or fake image if (isset($_POST["submit"])) { $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]); if ($check !== false) { echo "File is an image - " . $check["mime"] . "."; $uploadOk = 1; } else { echo "File is not an image."; $uploadOk = 0; } } // Check if file already exists if (file_exists($target_file)) { echo $userFolder; echo "Sorry, file already exists."; echo $userFolder; $uploadOk = 0; } // Check file size if ($_FILES["fileToUpload"]["size"] > 50000000) { echo "Sorry, your file is too large."; $uploadOk = 0; } // Allow certain file formats if ($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif" && $imageFileType != "mp3" && $imageFileType != "mp4" && $imageFileType != "doc" && $imageFileType != "pptx") { echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed."; $uploadOk = 0; } // Check if $uploadOk is set to 0 by an error if ($uploadOk == 0) { echo "Sorry, your file was not uploaded."; // if everything is ok, try to upload file } else { if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) { encode($target_file); } else { echo "Sorry, there was an error uploading your file."; } } }
public function baozhengjin($gid) { if (is_login()) { parent::baozhengjin($gid); } else { $this->redirect('P/Main/login/' . encode('Pay/baozhengjin/' . $gid, '', '')); } }
function printjs2($array) { $arr = array(); foreach ($array as $a) { $arr[] = encode($a); } echo json_encode($arr); }
/** * 批量请求 * @param array $request_buffer_array ['ip:port'=>req_buf, 'ip:port'=>req_buf, ...] * @return multitype:unknown string */ function multiRequest($request_buffer_array) { \Statistics\Lib\Cache::$lastSuccessIpArray = array(); $client_array = $sock_to_ip = $ip_list = array(); foreach ($request_buffer_array as $address => $buffer) { list($ip, $port) = explode(':', $address); $ip_list[$ip] = $ip; $client = stream_socket_client("tcp://{$address}", $errno, $errmsg, 1); if (!$client) { continue; } $client_array[$address] = $client; stream_set_timeout($client_array[$address], 0, 100000); fwrite($client_array[$address], encode($buffer)); stream_set_blocking($client_array[$address], 0); $sock_to_address[(int) $client] = $address; } $read = $client_array; $write = $except = $read_buffer = array(); $time_start = microtime(true); $timeout = 0.99; // 轮询处理数据 while (count($read) > 0) { if (@stream_select($read, $write, $except, 0, 200000)) { foreach ($read as $socket) { $address = $sock_to_address[(int) $socket]; $buf = fread($socket, 8192); if (!$buf) { if (feof($socket)) { unset($client_array[$address]); } continue; } if (!isset($read_buffer[$address])) { $read_buffer[$address] = $buf; } else { $read_buffer[$address] .= $buf; } // 数据接收完毕 if (($len = strlen($read_buffer[$address])) && $read_buffer[$address][$len - 1] === "\n") { unset($client_array[$address]); } } } // 超时了 if (microtime(true) - $time_start > $timeout) { break; } $read = $client_array; } foreach ($read_buffer as $address => $buf) { list($ip, $port) = explode(':', $address); \Statistics\Lib\Cache::$lastSuccessIpArray[$ip] = $ip; } \Statistics\Lib\Cache::$lastFailedIpArray = array_diff($ip_list, \Statistics\Lib\Cache::$lastSuccessIpArray); ksort($read_buffer); return $read_buffer; }
/** * Generates a name of the product depending on the name and version of the product name. * @param str $productName product name * @param str $variantName variant name * @return str name for xml */ private function forName($productName, $variantName) { if (encode($productName) == encode($variantName)) { $name = encode($productName); } else { $name = encode($productName . ' ' . $variantName); } return $name; }
function set_page($page = '') { if ($page) { $this->page = $page; $this->tmpfile = CACHE_DIR . encode($page) . '.tmp'; $this->tmprfile = CACHE_DIR . encode($this->page) . '.tmpr'; $this->set_page = true; } }
/** * 生成卡 */ public function add() { if (isset($GLOBALS['submit'])) { $download = intval($GLOBALS['download']); $number = intval($GLOBALS['number']); $number = max($number, 1); $batchid = uniqid(); $tmpdata = iconv('gbk', 'utf-8', '卡号,密码,截至日期'); $ip = get_ip(); for ($i = 0; $i < $number; $i++) { $formdata = array(); $formdata['addtime'] = SYS_TIME; $formdata['endtime'] = strtotime($GLOBALS['endtime']); $formdata['status'] = $download == 1 ? 1 : 0; $formdata['adminname'] = get_cookie('username'); $formdata['id'] = $GLOBALS['form']['id']; $password = random_string('diy', 8, 'abcdefghjkmnpqrstuwxy23456789'); $formdata['password'] = encode($password, 'Hx0si1'); $formdata['batchid'] = $batchid; $cardid = $this->db->insert('order_card', $formdata); $card_no = $GLOBALS['pre'] . str_pad($cardid, 6, "0", STR_PAD_LEFT); $this->db->update('order_card', array('card_no' => $card_no), array('cardid' => $cardid)); $tmpdata .= "\r\n" . $card_no . ',' . $password . ',' . $GLOBALS['endtime']; if ($download) { $formdata2 = array(); $formdata2['cardid'] = $cardid; $formdata2['type'] = 0; $formdata2['senduser'] = $formdata['adminname']; $formdata2['sendtime'] = SYS_TIME; $formdata2['ip'] = $ip; $this->db->insert('order_card_send', $formdata2); } } if ($download) { $filename = $batchid . '.txt'; //$content = ob_get_contents(); header('Content-Description: File Transfer'); header('Content-Type: application/txt'); header('Content-Disposition: attachment; filename=' . $filename); // header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Pragma: public'); header('Content-Transfer-Encoding: binary'); header('Content-Encoding: none'); echo $tmpdata; } else { MSG('生成成功', '?m=order&f=card&v=listing' . $this->su()); } } else { $show_formjs = ''; $endtime = mktime(0, 0, 0, date('m') + 3, date('d'), date('Y')); $endtime = date('Y-m-d', $endtime); load_class('form'); include $this->template('card_add'); } }
function setAddress($postoffice = '', $extended = '', $street = '', $city = '', $region = '', $zip = '', $country = '', $type = 'HOME;POSTAL') { // $type may be DOM | INTL | POSTAL | PARCEL | HOME | WORK or any combination of these: e.g. "WORK;PARCEL;POSTAL" $key = 'ADR'; if ($type != '') { $key .= ';' . $type; } $key .= ';ENCODING=QUOTED-PRINTABLE'; $this->properties[$key] = encode($postoffice) . ';' . encode($extended) . ';' . encode($street) . ';' . encode($city) . ';' . encode($region) . ';' . encode($zip) . ';' . encode($country); }
private function create_cookie($info, $cookietime = 0) { set_cookie('auth', encode($info['uid'] . "\t" . $info['password'] . "\t" . $cookietime, substr(md5(_KEY), 8, 8)), $cookietime); set_cookie('_uid', $info['uid'], $cookietime); set_cookie('_username', $info['username'], $cookietime); set_cookie('_groupid', $info['groupid'], $cookietime); load_function('string'); setcookie(COOKIE_PRE . 'truename', escape($info['username']), $cookietime, COOKIE_PATH, COOKIE_DOMAIN, 0); setcookie(COOKIE_PRE . 'modelid', $info['modelid'], $cookietime, COOKIE_PATH, COOKIE_DOMAIN, 0); }
function encode($number) { $chars = str_split('XT7SAGzwDy8ORKNIhWfca1pmlsgVeZM9Fn6Y3b4joCBr5qtJ20kduEPivxLQUH'); if ($number / 62 < 1) { return $chars[$number % 62]; } else { $first = encode($number / 62); return $first . $chars[$number % 62]; } }
function _die($res = NULL, $err = 0, $name = '', $key = 'tajnehaslo') { global $errors, $result; $result['error'] = $err; $result['errors'] = $errors[$err] . ' ' . $name; if (is_array($res)) { $res = serialize($res); } $result['result'] = encode($res, $key); die(serialize($result)); }
/** *index *api令牌生成 * 支持操作post *@return json,xml *@author NewFuture */ public function index() { $pwd = I('post.pwd'); $type = I('post.type', null, 'int'); $Model = null; switch ($type) { case C('STUDENT'): case C('STUDENT_API'): $account = I('post.account', 0, C('REGEX_NUMBER')); $Model = M('user'); $where['student_number'] = $account; break; case C('PRINTER'): case C('PRINTER_WEB'): $account = I('post.account', null, C('REGEX_ACCOUNT')); $Model = M('printer'); $where['account'] = $account; break; default: $data['err'] = 'unknown user type'; } if (!isset($data)) { if ($account) { $key = 'api_' . $account; $times = S($key); if ($times > C('MAX_TRIES')) { \Think\Log::record('api爆破警告:ip:' . get_client_ip() . ',account:' . $account, 'NOTIC', true); $data['err'] = '此账号尝试次数过多,已经暂时封禁,请于一小时后重试!(ps:你的行为已被系统记录)'; } else { S($key, $times + 1, 3600); $info = $Model->where($where)->field('id,password,name')->find(); $id = $info['id']; $password = $info['password']; if ($password == encode($pwd, $account)) { $token = update_token($id, $type); if ($token) { S($key, null); $data['token'] = $token; $data['name'] = $info['name']; $data['id'] = $info['id']; } else { $data['err'] = '创建令牌失败'; } } else { $data['err'] = 'authored failed'; } } } else { $data['err'] == 'illegal account'; } } $data['version'] = C('API_VERSION'); $this->response($data, $this->_type == 'xml' ? 'xml' : 'json'); }
function Save($beer) { $sql = ""; if ($beer->get_id()) { $sql = "UPDATE beers " . "SET " . "name = '" . encode($beer->get_name()) . "', " . "beerStyleId = '" . encode($beer->get_beerStyleId()) . "', " . "notes = '" . encode($beer->get_notes()) . "', " . "ogEst = '" . $beer->get_og() . "', " . "fgEst = '" . $beer->get_fg() . "', " . "srmEst = '" . $beer->get_srm() . "', " . "ibuEst = '" . $beer->get_ibu() . "', " . "modifiedDate = NOW() " . "WHERE id = " . $beer->get_id(); } else { $sql = "INSERT INTO beers(name, beerStyleId, notes, ogEst, fgEst, srmEst, ibuEst, createdDate, modifiedDate ) " . "VALUES(" . "'" . encode($beer->get_name()) . "', " . $beer->get_beerStyleId() . ", " . "'" . encode($beer->get_notes()) . "', " . "'" . $beer->get_og() . "', " . "'" . $beer->get_fg() . "', " . "'" . $beer->get_srm() . "', " . "'" . $beer->get_ibu() . "' " . ", NOW(), NOW())"; } //echo $sql; exit(); mysql_query($sql); }
function foursquareEncrypt($plaintext) { $key1 = generateKey(); $key2 = generateKey(); $upperLeft = "abcdefghiklmnopqrstuvwxyz"; $upperRight = $key1; $lowerLeft = $key2; $lowerRight = "abcdefghiklmnopqrstuvwxyz"; $_SESSION["key"] = $key1 . " " . $key2; return encode($plaintext, $upperLeft, $upperRight, $lowerLeft, $lowerRight); }
/** * Check if the page timestamp is newer than the file timestamp * * PukiWiki API Extension * * @param string $page pagename * @param string $file filename * @param bool $ignore_notimestamp Ignore notimestamp edit and see the real time editted * @return boolean */ function is_page_newer($page, $file, $ignore_notimestamp = TRUE) { $filestamp = file_exists($file) ? filemtime($file) : 0; if ($ignore_notimestamp) { // See the diff file. PukiWiki Trick. $pagestamp = is_page($page) ? filemtime(DIFF_DIR . encode($page) . '.txt') : 0; } else { $pagestamp = is_page($page) ? filemtime(get_filename($page)) : 0; } return $pagestamp > $filestamp; }
function make_login_link($return) { $x1 = $x2 = ''; foreach ($return as $key => $val) { $r_val = $key == 'page' ? encode($val) : rawurlencode($val); $x1 .= $key . $r_val; $x2 .= '&' . $key . '=' . $r_val; } $api_sig = md5($this->sec_key . 'api_key' . $this->api_key . $x1); return HATENA_URL_AUTH . '?api_key=' . $this->api_key . '&api_sig=' . $api_sig . $x2; }