function is_consistency($arr_of_parse, $arr_of_result) { if (array_key_exists('empty', $arr_of_result)) { if ($arr_of_parse["msg"] == "no matched pattern") { return true; } else { return false; } } else { if ($arr_of_parse["code"] == "100") { $arr = array(); if (isset($arr_of_parse["global"])) { $arr = $arr_of_parse["global"]; } //获取解析后的数据信息 foreach ($arr as $key => $value) { $val = int(float($value)); if (int($arr_of_result[$key]) != $val) { return false; } } return true; } else { return false; } } }
public function info($time, $viewpoint = 'ms', $round = 5) { $ret = $time; if (stripos(' ', $time) > 0) { $ret = explode(' ', $time); $ret = float($ret[1]); +float($ret[0]); } $formats = array(self::US, self::MS, self::S, self::M, self::H); $multiplier = 1; switch ($viewpoint) { case self::US: $multiplier = 1000000; $formatter = 0; break; case self::MS: $multiplier = 1000; $formatter = 1; break; case self::S: $multiplier = 1; $formatter = 2; break; case self::M: $multiplier = 1 / 60; $formatter = 3; break; case self::H: $multiplier = 1 / (60 * 60); $formatter = 4; break; default: break; } $ret = $ret * $multiplier; return round($ret, $round) . ' ' . $formats[$formatter]; }
public static function number_to_human_size($size, $precision = 1) { $size = float($size); $return = null; if ($size == 1) { $return = "1 Byte"; } elseif ($size < 1024) { $return = sprintf("%d Bytes", $size); } elseif ($size < 1024 * 1024) { $return = sprintf("%.{$precision}f KB", $size / (1024 * 1024)); } elseif ($size < 1024 * 1024 * 1024) { $return = sprinf("%.{$precision}f MB", $size / (1024 * 1024 * 1024)); } elseif ($size < 1024 * 1024 * 1024 * 1024) { $return = sprinf("%.{$precision}f GB", $size / (1024 * 1024 * 1024 * 1024)); } else { $return = sprintf("%.{$precision}f TB", $size / (1024 * 1024 * 1024 * 1024 * 1024)); } return str_replace(".0", "", $return); }
public function toFloat() { return float($this); }
function doedit_user() { global $output, $user_name, $dbc_db, $logon_db, $corem_db, $send_mail_on_email_change, $lang, $defaultoption, $achievement_point_points, $achievement_point_credits, $credits_fractional, $url_path, $format_mail_html, $GMailSender, $smtp_cfg, $title, $sql, $core; if ((empty($_POST["pass"]) || $_POST["pass"] == "") && (empty($_POST["mail"]) || $_POST["mail"] == "") && (empty($_POST["expansion"]) || $_POST["expansion"] == "") && (empty($_POST["referredby"]) || $_POST["referredby"] == "")) { redirect("edit.php?error=1"); } // ArcEmu: find out if we're using an encrypted password for this account if ($core == 1) { $pass_query = "SELECT * FROM accounts WHERE login='******' AND encrypted_password<>''"; $pass_result = $sql["logon"]->query($pass_query); $arc_encrypted = $sql["logon"]->num_rows($pass_result); } // password if ($_POST["user_pass"] != "******") { if ($core == 1) { if ($arc_encrypted) { $new_pass = "******" . $sql["logon"]->quote_smart($_POST["pass"]) . "', "; } else { $new_pass = "******" . $sql["logon"]->quote_smart($_POST["pass"]) . "', "; } } else { $new_pass = "******" . $sql["logon"]->quote_smart($_POST["pass"]) . "', "; } } // other $screenname = $sql["logon"]->quote_smart(trim($_POST["screenname"])); $new_mail = $sql["logon"]->quote_smart(trim($_POST["mail"])); $new_expansion = isset($_POST["expansion"]) ? $sql["logon"]->quote_smart(trim($_POST["expansion"])) : $defaultoption; $referredby = $sql["logon"]->quote_smart(trim($_POST["referredby"])); $points_to_spend = is_numeric($_POST["points_to_spend"]) && $_POST["points_to_spend"] >= 0 ? $_POST["points_to_spend"] : 0; // if we received a Screen Name, make sure it does not conflict with other Screen Names or with // the game server's login names. if ($screenname) { $query = "SELECT * FROM config_accounts WHERE ScreenName='" . $screenname . "'"; $sn_result = $sql["mgr"]->query($query); $sn = $sql["mgr"]->fetch_assoc($sn_result); if ($sn["Login"] != $user_name) { if ($sql["mgr"]->num_rows($sn_result) != 0) { redirect("edit.php?error=6"); } if ($core == 1) { $query = "SELECT * FROM accounts WHERE login='******'"; } else { $query = "SELECT * FROM account WHERE username='******'"; } $sn_result = $sql["logon"]->query($query); if ($sql["logon"]->num_rows($sn_result) != 0) { redirect("edit.php?error=6"); } } } // set screen name if ($screenname) { $sn_check_query = "SELECT * FROM config_accounts WHERE Login='******'"; $sn_check_result = $sql["mgr"]->query($sn_check_query); // don't add a new entry if we already have one if ($sql["mgr"]->num_rows($sn_check_result) == 0) { $sn_result = $sql["mgr"]->query("INSERT INTO config_accounts (Login, ScreenName) VALUES ('" . $user_name . "', '" . $screenname . "')"); } else { $sn_result = $sql["mgr"]->query("UPDATE config_accounts SET ScreenName='" . $screenname . "' WHERE Login='******'"); } } //make sure the mail is valid mail format require_once "libs/valid_lib.php"; if (!(valid_email($new_mail) && strlen($new_mail) < 225)) { redirect("edit.php?error=2"); } // find out if our email changed if ($core == 1) { $email_query = "SELECT email FROM accounts WHERE login='******'"; } else { $email_query = "SELECT email FROM account WHERE username='******'"; } $email_result = $sql["logon"]->query($email_query); $email = $sql["logon"]->fetch_assoc($email_result); // if it did change, then save it // if we didn't have an email address already, we just accept the new one if ($email["email"] != "" && $email["email"] != $new_mail) { // if we have to send a confirm message, do so // if not, we're clear to just save it as usual if ($send_mail_on_email_change) { // generate a private key based on the new email $new_mail_sha = sha1($new_mail); // prepare our confirmation message if ($format_mail_html) { $file_name = "lang/mail_templates/" . $lang . "/change_email.tpl"; } else { $file_name = "lang/mail_templates/" . $lang . "/change_email_nohtml.tpl"; } $fh = fopen($file_name, "r"); $subject = fgets($fh, 4096); $body = fread($fh, filesize($file_name)); fclose($fh); $mail = $email["email"]; $subject = str_replace("<title>", $title, $subject); if ($format_mail_html) { $body = str_replace("\n", "<br />", $body); $body = str_replace("\r", " ", $body); } $body = str_replace("<username>", $user_name, $body); $body = str_replace("<email>", $new_mail, $body); $body = str_replace("<key>", $new_mail_sha, $body); $body = str_replace("<title>", $title, $body); $server_addr = $_SERVER["SERVER_PORT"] != 80 ? $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] : $_SERVER["SERVER_NAME"]; // if we aren't installed in / then append the path to $server_addr $server_addr .= $url_path != "" ? $url_path : ""; $body = str_replace("<base_url>", $server_addr, $body); if ($GMailSender) { require_once "libs/mailer/authgMail_lib.php"; $fromName = $title . " Admin"; authgMail($from_mail, $fromName, $mail, $mail, $subject, $body, $smtp_cfg); } else { require_once "libs/mailer/class.phpmailer.php"; $mailer = new PHPMailer(); $mailer->Mailer = $mailer_type; if ($mailer_type == "smtp") { $mailer->Host = $smtp_cfg["host"]; $mailer->Port = $smtp_cfg["port"]; if ($smtp_cfg["user"] != "") { $mailer->SMTPAuth = true; $mailer->Username = $smtp_cfg["user"]; $mailer->Password = $smtp_cfg["pass"]; } } $mailer->WordWrap = 50; $mailer->From = $from_mail; $mailer->FromName = $title . " Admin"; $mailer->Subject = $subject; $mailer->IsHTML($format_mail_html); $mailer->Body = $body; $mailer->AddAddress($mail); $mailer->Send(); $mailer->ClearAddresses(); } // save new email $temp_email_query = "UPDATE config_accounts SET TempEmail='" . $new_mail . "' WHERE Login='******'"; $temp_email_result = $sql["mgr"]->query($temp_email_query); // save OLD email back for now $new_mail = $email["email"]; } } // Achievement Points to Credits // just to be sure we have no cheating if ($achievement_point_credits) { if ($credits_fractional) { $new_credits = $achievement_point_credits / $achievement_point_points * $points_to_spend; } else { $new_credits = float($achievement_point_credits / $achievement_point_points * $points_to_spend); } $points_query = "UPDATE config_accounts SET Credits=Credits+'" . $new_credits . "', AchievePointsSpent=AchievePointsSpent+'" . $points_to_spend . "' WHERE Login='******'"; $points_result = $sql["mgr"]->query($points_query); } // Overriding Remember Me is done via a cookie // usage is backward from the name // 1 = show check box // 0 = hide if (!isset($_POST["override"])) { $override = 0; } else { $override = 1; } if ($override != $_COOKIE["corem_override_remember_me"] || !isset($_COOKIE["corem_override_remember_me"])) { if ($override) { setcookie("corem_override_remember_me", "1", time() + 60 * 60 * 24 * 30); } else { setcookie("corem_override_remember_me", "0", time() + 60 * 60 * 24 * 30); } $other_changes = 1; } // change other settings if ($core == 1) { $query = "UPDATE accounts SET email='" . $new_mail . "', " . $new_pass . " flags='" . $new_expansion . "' WHERE login='******'"; } else { $query = "UPDATE account SET email='" . $new_mail . "', " . $new_pass . " expansion='" . $new_expansion . "', v=0, s=0 WHERE username='******'"; } $acct_result = $sql["logon"]->query($query); if (doupdate_referral($referredby) || $acct_result || $sn_result || $other_changes) { redirect("edit.php?error=3"); } else { redirect("edit.php?error=4"); } }
function get_viewtopic_perm_of_current_user($topic_id, $topic_uid, $published = 0, $can_edit_day = 0) { global $xoopsUser; $topic_perm = $this->getTopicPermission($topic_id); if (empty($topic_perm)) { $topic_perm['can_read'] = 0; $topic_perm['can_post'] = 0; $topic_perm['can_edit'] = 0; $topic_perm['can_delete'] = 0; $topic_perm['post_auto_approved'] = 0; return $topic_perm; } $topic_perm['can_read'] = 1; if (empty($topic_perm) || !$this->group_perm(1)) { $topic_perm['can_post'] = 0; $topic_perm['can_edit'] = 0; $topic_perm['can_delete'] = 0; $topic_perm['post_auto_approved'] = 0; return $topic_perm; } //TODO user only--------------- if (!is_object($xoopsUser)) { $topic_perm['can_edit'] = 0; $topic_perm['can_delete'] = 0; return $topic_perm; } $module_handler =& xoops_gethandler('module'); $module = $module_handler->getByDirname($this->mydirname); $mid = $module->mid(); //user time limit,you can delete one day if (!$xoopsUser->isAdmin($mid)) { if (!$this->group_perm(2)) { //your aritcle if ($topic_uid === $xoopsUser->uid()) { //TODO if user,one day(86400) limit if ($can_edit_day != 0 && $published < time() - 86400 * float($can_edit_day)) { $topic_perm['can_edit'] = 0; $topic_perm['can_delete'] = 0; } } else { $topic_perm['can_edit'] = 0; $topic_perm['can_delete'] = 0; } } } return $topic_perm; }
public function guoji_list() { $this->language->load('app/app'); if ($this->request->server['REQUEST_METHOD'] == 'POST') { $str = str_replace(""", "\"", $this->request->post['param']); $param = json_decode($str, true); $page = $param['value']; $limit = $this->config->get('config_catalog_limit'); if (array_key_exists('status', $param)) { //=0全部,1待付款,2待发货,3待收货 //待付款数据库是0,待发货数据库是1,5,待收货数据库是2 $status = $param['status'] ? $param['status'] : 0; } else { $status = 0; } $this->load->model('order/order'); $data = array('username_id' => $param['customerId'], 'order_status_id' => $status, 'start' => ($page - 1) * $limit, 'limit' => $limit); $this->load->model('order/order'); $this->load->model('app/order'); $results = $this->model_app_order->select_send_porduct($data); $temp = array(); $goodsList = array(); $result = array(); foreach ($results as $yundan) { $oids = explode(',', $yundan['oids']); foreach ($oids as $oid) { $this->load->model('app/order'); $order = $this->model_app_order->getOrder($oid); $products = $this->model_order_order->getOrderProducts($oid); foreach ($products as $product) { $temp[] = array('url' => $product['producturl'] ? $product['producturl'] : '', 'goodsImage' => $product['img'] ? 'http://' . $this->request->server['HTTP_HOST'] . '/image/' . $product['img'] : '', 'name' => $product['name'] ? $product['name'] : '', 'buyColor' => $product['option_color'] ? $product['option_color'] : '', 'buySize' => $product['option_size'] ? $product['option_size'] : '', 'realPrice' => $product['total'] ? $product['total'] : float(0.0), 'remark' => $product['note'] ? $product['note'] : '', 'buyQuantity' => $product['quantity'] ? $product['quantity'] : 0); } $goodsList[] = array('oid' => $oid, 'type' => $order['order_status_buy'], 'goodsList' => $temp); $temp = array(); } $result[] = array('yunfei' => $yundan['totalfee'] ? $yundan['totalfee'] : float(0.0), 'wayStatus' => $yundan['state'], 'wayNo' => $yundan['sid'], 'receiveAddress' => $yundan['country'] . ' ' . $yundan['city'] . ' ' . $yundan['address'], 'mailCode' => $yundan['zip'] ? $yundan['zip'] : '', 'receiver' => $yundan['consignee'] ? $yundan['consignee'] : '', 'telePhone' => $yundan['tel'] ? $yundan['tel'] : '', 'weight' => $yundan['countweight'] ? $yundan['countweight'] : '', 'wayDate' => $yundan['uptime'] ? date('Y-m-d H:i:s', $yundan['uptime']) : date('Y-m-d H:i:s', $yundan['addtime']), 'express' => $yundan['deliveryname'] ? $yundan['deliveryname'] : '', 'express_number' => $yundan['sn'] ? $yundan['sn'] : '', 'ordersList' => $goodsList); $goodsList = array(); } $arr = array(); $arr = json_encode(array('data' => array('resultCode' => 1, 'result' => array()))); echo $arr; } else { $arr = json_encode(array('data' => array('resultCode' => 0, 'errorMessage' => $this->language->get('error_post')))); echo $arr; } }