public function reg() { if (isset($_POST['submit-1'])) { $username = safe_replace($_POST['username']); if ($username != $_POST['username'] || empty($username)) { _message("用户名格式错误!"); } if (_strlen($username) > 15) { _message("用户名长度为2-15个字符,1个汉字等于2个字符!"); } $password1 = $_POST['password']; $password2 = $_POST['pwdconfirm']; if (empty($password2) || $password1 != $password2) { _message("2次密码不一致!"); } if (!_checkemail($_POST['email'])) { _message("邮箱格式错误!"); } $pmid = isset($_POST['mid']) ? intval($_POST['mid']) : 0; $password = md5($password2); $addtime = time(); $ip = _get_ip(); $this->db->Query("INSERT INTO `@#_admin` (`mid`, `username`, `userpass`, `useremail`, `addtime`, `logintime`, `loginip`) VALUES ('{$pmid}', '{$username}', '{$password}', '{$_POST['email']}','{$addtime}','0','{$ip}')"); if ($this->db->affected_rows()) { $path = WEB_PATH . '/' . ROUTE_M . '/user/lists'; _message("添加管理员成功!", $path); } else { _message("添加管理员失败!"); } } include $this->tpl(ROUTE_M, 'user.reg'); }
public function test_main() { $str = 'Mutual Friends (пользователь должен быть у Вас в друзьях а Вы у него)'; $this->assertEquals(111, strlen($str)); $this->assertEquals(69, _strlen($str)); $this->assertEquals(26, strlen(_substr($str, 0, 21))); $this->assertEquals(21, _strlen(_substr($str, 0, 21))); }
public static function strlen($str) { if (UTF8::$server_utf8) { return mb_strlen($str, JsonApiApplication::$charset); } if (!isset(UTF8::$called[__FUNCTION__])) { require JsonApiApplication::find_file("utf8", __FUNCTION__); // Function has been called UTF8::$called[__FUNCTION__] = TRUE; } return _strlen($str); }
public function musername() { if (isset($_POST['ajax'])) { $usernamelen = 15; $pusername = isset($_POST['username']) ? $_POST['username'] : ''; $len = _strlen($pusername); if ($len > $usernamelen || $len <= 0) { echo 'no'; } else { echo 'yes'; } } }
/** * Automatic translator via Google translate */ function autotranslate() { if ($_POST['translate'] && $_POST['locale']) { set_time_limit(1800); $LOCALE_RES = $_POST['locale']; $base_url = 'http://ajax.googleapis.com/ajax/services/language/translate' . '?v=1.0'; $vars = db()->query_fetch_all("SELECT id,value FROM " . db('locale_vars') . " WHERE id NOT IN( \n\t\t\t\t\tSELECT var_id FROM " . db('locale_translate') . " \n\t\t\t\t\tWHERE locale = '" . $LOCALE_RES . "' AND value != '' \n\t\t\t\t)"); $_info = []; $max_threads = 4; $buffer = []; $translated = []; _debug_log("LOCALE_NUM_VARS: " . count($vars)); foreach ((array) $vars as $A) { $translated = []; $url = $base_url . "&q=" . urlencode(str_replace("_", " ", $A["value"])) . "&langpair=en%7C" . $LOCALE_RES; $_temp[$url] = $A["id"]; if (count($buffer) < $max_threads) { $buffer[$url] = $url; continue; } foreach ((array) common()->multi_request($buffer) as $url => $response) { $response_array = json_decode($response); $response_text = trim($response_array->responseData->translatedText); $ID = $_temp[$url]; $source = str_replace("_", " ", $vars[$ID]["value"]); _debug_log("LOCALE: " . ++$j . " ## " . $ID . " ## " . $source . " ## " . $response_text . " ## " . $url); if (_strlen($response_text) && $response_text != $source) { $translated[$ID] = $response_text; } } if ($translated) { $Q = db()->query("DELETE FROM " . db('locale_translate') . " \n\t\t\t\t\t\tWHERE locale = '" . _es($LOCALE_RES) . "' \n\t\t\t\t\t\t\tAND var_id IN(" . implode(",", array_keys($translated)) . ")"); } foreach ((array) $translated as $_id => $_value) { db()->REPLACE('locale_translate', ['var_id' => intval($_id), 'value' => _es($_value), 'locale' => _es($LOCALE_RES)]); } $buffer = []; $_temp = []; } cache_del('locale_translate_' . $LOCALE_RES); return js_redirect('./?object=' . $_GET['object']); } $Q = db()->query('SELECT * FROM ' . db('locale_langs') . ' ORDER BY name'); while ($A = db()->fetch_assoc($Q)) { $locales[$A['locale']] = $A['name']; } $replace = ['locale_box' => common()->select_box('locale', $locales), 'locale_editor_url' => './?object=locale_editor', 'form_action' => './?object=' . $_GET['object'] . '&action=' . $_GET['action']]; return tpl()->parse($_GET['object'] . '/autotranslate', $replace); }
public function reg() { function randomkeys($length) { $pattern = '1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLOMNOPQRSTUVWXYZ'; for ($i = 0; $i < $length; $i++) { $key .= $pattern[mt_rand(0, 35)]; //生成php随机数 } return $key; } if (isset($_POST['submit-1'])) { $username = safe_replace($_POST['username']); if ($username != $_POST['username'] || empty($username)) { _message("用户名格式错误!"); } if (_strlen($username) > 15) { _message("用户名长度为2-15个字符,1个汉字等于2个字符!"); } $password1 = $_POST['password']; $password2 = $_POST['pwdconfirm']; if (empty($password2) || $password1 != $password2) { _message("2次密码不一致!"); } if (!_checkemail($_POST['email'])) { _message("邮箱格式错误!"); } $pmid = isset($_POST['mid']) ? intval($_POST['mid']) : 0; $password = md5($password2); $uid = $password; $addtime = time(); $ip = _get_ip(); $this->db->Query("INSERT INTO `@#_admin` (`uid`, `mid`, `username`, `userpass`, `useremail`, `addtime`, `logintime`, `loginip`) VALUES ('{$uid}', '{$pmid}', '{$username}', '{$password}', '{$_POST['email']}','{$addtime}','0','{$ip}')"); if ($this->db->affected_rows()) { $path = WEB_PATH . ROUTE_M . '/user/lists'; _message("添加管理员成功!", $path); } else { _message("添加管理员失败!"); } } include $this->tpl(ROUTE_M, 'user.reg'); }
/** * Returns the length of the given string. * @see http://php.net/strlen * * @param string string being measured for length * @return integer */ public static function strlen($str) { require_once dirname(__FILE__) . '/' . __FUNCTION__ . '.php'; return _strlen($str); }
/** * Verify a password against a hash using a timing attack resistant approach * * @param string $password The password to verify * @param string $hash The hash to verify against * * @return boolean If the password matches the hash */ function password_verify($password, $hash) { if (!function_exists('crypt')) { trigger_error("Crypt must be loaded for password_verify to function", E_USER_WARNING); return false; } $ret = crypt($password, $hash); if (!is_string($ret) || _strlen($ret) != _strlen($hash) || _strlen($ret) <= 13) { return false; } $status = 0; for ($i = 0; $i < _strlen($ret); $i++) { $status |= ord($ret[$i]) ^ ord($hash[$i]); } return $status === 0; }
/** * Returns the length of the given string. This is a UTF8-aware version * of [strlen](http://php.net/strlen). * * $length = UTF8::strlen($str); * * @param string $str string being measured for length * @return integer * @uses UTF8::$server_utf8 * @uses Kohana::$charset */ public static function strlen($str) { if (UTF8::$server_utf8) { return mb_strlen($str, Kohana::$charset); } if (!isset(UTF8::$called[__FUNCTION__])) { require Kohana::find_file('utf8', __FUNCTION__); // Function has been called UTF8::$called[__FUNCTION__] = TRUE; } return _strlen($str); }
/** * Returns the length of the given string. This is a UTF8-aware version * of [strlen](http://php.net/strlen). * * $length = UTF8::strlen($str); * * @param string $str string being measured for length * @return integer * @uses UTF8::$server_utf8 * @uses Phalcana\Phalcana::$charset */ public static function strlen($str) { if (UTF8::$server_utf8) { return mb_strlen($str, Phalcana::$charset); } if (!isset(UTF8::$called[__FUNCTION__])) { require Phalcana::$di->get('fs')->findFile('utf8', __FUNCTION__); // Function has been called UTF8::$called[__FUNCTION__] = true; } return _strlen($str); }
/** * Returns the length of the given string. This is a UTF8-aware version * of [strlen](http://php.net/strlen). * * $length = UTF8::strlen($str); * * @param string $str string being measured for length * @return integer * @uses UTF8::$server_utf8 * @uses Kohana::$charset */ public static function strlen($str) { if (UTF8::$server_utf8) { return mb_strlen($str, 'utf-8'); } return _strlen($str); }
/** */ function chart_flash($data, $params) { if (empty($data)) { return; } include_once YF_PATH . 'libs/yf_open_flash_chart/open-flash-chart.php'; $width = isset($params['width']) ? $params['width'] : '90%'; $height = isset($params['height']) ? $params['height'] : '90%'; $g = new graph(); $g->js_path = isset($params['js_path']) ? $params['js_path'] : '/js/'; $g->swf_path = isset($params['swf_path']) ? $params['swf_path'] : '/js/'; $g->title(' ', '{font-size: 20px;}'); $g->bg_colour = '#e9e9e9'; $g->x_axis_colour('#000000', '#c1c1c1'); $g->y_axis_colour('#000000', '#c1c1c1'); $g->set_data($data); // Find maximal strlen of x axis label foreach ((array) $data as $k => $v) { $xlabel_len[] = _strlen($k); } if (max($xlabel_len) > 7) { $orientation = 2; } else { $orientation = 0; } $g->set_x_labels(array_keys($data)); $g->set_x_label_style(10, '#000000', $orientation, 2); $g->set_y_max(max($data)); $g->set_y_label_style(10, '#000000', 0, 2); $g->set_y_legend('Price', 10, '#000000'); $g->set_x_legend('Date', 10, '#000000'); $g->set_tool_tip('#val# EUR on #x_label#'); $g->line_dot(2, 3, '#0750D9', '', 10); // формат значений $g->set_num_decimals(0); $g->set_y_format('#val#€'); $g->set_width($width); $g->set_height($height); $g->set_output_type('js'); return $g->render(); }
/** * Analyze text, find top keywords and return string ready for use inside 'MATCH ... AGAINST ...' */ function _get_keywords_from_text($text = '') { $num_to_ret = $this->NUM_KEYWORDS; $wordlist = preg_split($this->_PATTERN_KWORDS, _strtolower(strip_tags($text))); // Build an array of the unique words and number of times they occur. $a = array_count_values($wordlist); // Remove the stop words from the list. foreach ((array) $this->STOP_WORDS as $_word) { unset($a[$_word]); } // Remove short words from the list. foreach ((array) $a as $k => $v) { if (_strlen($k) < 4) { unset($a[$k]); } } arsort($a, SORT_NUMERIC); $num_words = count($a); $num_to_ret = $num_words > $this->num_to_ret ? $num_to_ret : $num_words; $outwords = array_slice($a, 0, $num_to_ret); $result = implode(' ', array_keys($outwords)); return $result; }
function getTextBetweenTags($text, $tag) { $StartTag = "<{$tag}"; $EndTag = "</{$tag}"; $StartPosTemp = _strpos($text, $StartTag); $StartPos = _strpos($text, '>', $StartPosTemp); $StartPos = $StartPos + 1; $EndPos = _strpos($text, $EndTag); $StartAttr = $StartPosTemp + _strlen($StartTag) + 1; $EndAttr = $StartPos; if ($EndAttr > $StartAttr) { $attribute = _substr($text, $StartAttr, $EndAttr - $StartAttr - 1); $datas = explode(' ', $attribute); for ($i = 0; $i < sizeof($datas); $i++) { if (preg_match('/^([a-zA-Z:]+)=["\'](.*)["\']/', $datas[$i], $match)) { $items[$match[1]] = $match[2]; } } } $text = _substr($text, $StartPos, $EndPos - $StartPos); if (_strpos($text, '[CDATA[') == false) { $text = str_replace('<', '<', $text); $text = str_replace('>', '>', $text); $text = str_replace('&', '&', $text); $text = str_replace('"', '"', $text); } else { $text = str_replace('<![CDATA[', '', $text); $text = str_replace(']]>', '', $text); } $items['data'] = trim($text); return $items; }
/** * Returns the length of the given string. This is a UTF8-aware version * of [strlen](http://php.net/strlen). * * $length = UTF8::strlen($str); * * @param string string being measured for length * @return integer * @uses UTF8::$server_utf8 */ public static function strlen($str) { if (UTF8::$server_utf8) { return mb_strlen($str, Kohana::$charset); } if (!isset(self::$called[__FUNCTION__])) { require SYSPATH . 'utf8' . DIRECTORY_SEPARATOR . __FUNCTION__ . EXT; // Function has been called self::$called[__FUNCTION__] = TRUE; } return _strlen($str); }
/** */ function _fix_page_name($in = null) { if (!strlen($in)) { return ''; } // Detect non-latin characters if (strlen($in) !== _strlen($in)) { $in = common()->make_translit(_strtolower($in)); } $in = preg_replace('/[^a-z0-9\\_\\-]/i', '_', strtolower($in)); $in = trim(str_replace(['__', '___'], '_', $in), '_'); return $in; }
public function detail() { $member = $this->userinfo; $sd_id = abs(intval($this->segment(4))); $shaidan = $this->db->GetOne("select * from `@#_shaidan` where `sd_id`='{$sd_id}'"); $goods = $this->db->GetOne("select sid from `@#_shoplist` where `id` = '{$shaidan['sd_shopid']}'"); $goods = $this->db->GetOne("select id,qishu,money,q_uid,maxqishu,thumb,title from `@#_shoplist` where `sid` = '{$goods['sid']}' order by `qishu` DESC"); if (isset($_POST['submit'])) { $sdhf_id = $shaidan['sd_id']; $sdhf_userid = $member['uid']; $sdhf_content = $_POST['sdhf_content']; $sdhf_time = time(); $sdhf_username = get_user_name($member); $sdhf_img = $member['img']; if ($sdhf_content == null) { _message("页面错误"); } $this->db->Query("INSERT INTO `@#_shaidan_hueifu`(`sdhf_id`,`sdhf_userid`,`sdhf_content`,`sdhf_time`,`sdhf_username`,`sdhf_img`)VALUES\n\t\t\t('{$sdhf_id}','{$sdhf_userid}','{$sdhf_content}','{$sdhf_time}','{$sdhf_username}','{$sdhf_img}')"); $sd_ping = $shaidan['sd_ping'] + 1; $this->db->Query("UPDATE `@#_shaidan` SET sd_ping='{$sd_ping}' where sd_id='{$shaidan['sd_id']}'"); _message("评论成功", WEB_PATH . "/go/shaidan/detail/" . $sd_id); } $shaidannew = $this->db->GetList("select * from `@#_shaidan` order by `sd_id` DESC limit 5"); $shaidan_hueifu = $this->db->GetList("select * from `@#_shaidan_hueifu` where `sdhf_id`='{$sd_id}'"); foreach ($shaidan_hueifu as $k => $v) { $shaidan_hueifu[$k]['sdhf_content'] = _htmtocode($shaidan_hueifu[$k]['sdhf_content']); } if (!$shaidan) { _message("页面错误"); } $substr = substr($shaidan['sd_photolist'], 0, -1); $sd_photolist = explode(";", $substr); $title = $shaidan['sd_title'] . "_" . _cfg("web_name"); $keywords = $shaidan['sd_title']; $description = _strlen($shaidan['sd_content'], 0, 250); include templates("index", "detail"); }
/** * Returns the length of the given string. * @see http://php.net/strlen * * @param string string being measured for length * @return integer */ public static function strlen($str) { if (!isset(self::$called[__FUNCTION__])) { require SYSPATH . 'core/utf8/' . __FUNCTION__ . EXT; // Function has been called self::$called[__FUNCTION__] = TRUE; } return _strlen($str); }
/** * Returns the length of the given string * * This is a UTF8-aware version of [strlen](http://php.net/strlen). * * Example: * ~~~ * $length = UTF8::strlen($str); * ~~~ * * @param string $str String being measured for length * * @return integer * * @uses UTF8::$server_utf8 * @uses Kohana::$charset * @uses Kohana::find_file */ public static function strlen($str) { if (self::$server_utf8) { return mb_strlen($str, Kohana::$charset); } UTF8::_load(__FUNCTION__); return _strlen($str); }