本文整理汇总了PHP中getCode函数的典型用法代码示例。如果您正苦于以下问题:PHP getCode函数的具体用法?PHP getCode怎么用?PHP getCode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getCode函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getMaxRevision
if ($action == 'latest') {
// find the latest revision and redirect to that.
$code_id = $subaction;
$latest_revision = getMaxRevision($code_id);
// header('Location: /' . $code_id . '/' . $latest_revision);
$edit_mode = false;
} else {
if ($subaction != 'gist') {
if ($subaction && is_numeric($action)) {
$code_id = $subaction;
$revision = $action;
} else {
$code_id = $action;
$revision = 1;
}
list($latest_revision, $html, $javascript) = getCode($code_id, $revision);
list($html, $javascript) = formatCompletedCode($html, $javascript, $code_id, $revision);
global $quiet;
// using new str_lreplace to ensure only the *last* </body> is replaced.
// FIXME there's still a bug here if </body> appears in the script and not in the
// markup - but I'll fix that later
if (!$quiet) {
$html = str_lreplace('</body>', '<script src="../js/render/edit.js"></script>' . "\n</body>", $html);
}
if ($no_code_found == false) {
$html = str_lreplace('</body>', googleAnalytics() . '</body>', $html);
}
if (false) {
if (stripos($html, '<head>')) {
$html = preg_replace('/<head>(.*)/', '<head><script>if (window.top != window.self) window.top.location.replace(window.location.href);</script>$1', $html);
} else {
示例2: lastError
/**
* Returns a formatted error message from previous database operation.
*
* @return string Error message with error number
*/
function lastError()
{
if (FX::isError($this->lastFXError)) {
return $this->lastFXError . getCode() . ': ' . $this->lastFXError . getMessage();
}
return null;
}
示例3: tt
function tt($artist, $title)
{
$s_doc = new DOMDocument();
$s_doc->load("http://ttlrcct.qianqian.com/dll/lyricsvr.dll?svrlst");
$s_list = $s_doc->getElementsByTagName("server");
if ($s_list->length == 0) {
return;
}
$s = $s_list->item(0);
$s_url = $s->getAttribute("url");
$l_url = $s_url . "?sh?Artist=" . tt_code($artist) . "&Title=" . tt_code($title) . "&Flags=0";
$l_doc = new DOMDocument();
$l_doc->load($l_url);
$l_list = $l_doc->getElementsByTagName("lrc");
if ($l_list->length == 0) {
return;
}
$l = $l_list->item(0);
$id = $l->getAttribute("id");
$ar = $l->getAttribute("artist");
$ti = $l->getAttribute("title");
$utf8Str = SetToHexString($ar . $ti);
$code = getCode($id, $utf8Str);
$url = $s_url . "?dl?Id=" . $id . "&Code=" . $code;
$data = file_get_contents($url);
$data = iconv('UTF-8', 'GBK', $data);
return $data;
}
示例4: savecode
/**
* 将手机验证码写入数据库,用于校对
* @param $user
* @return bool|string
*/
public function savecode($user)
{
$smscode = M('51_smscode');
$fromdb = $smscode->where("mobile='{$user}'")->select();
$sms_config = C('SMS');
$code = getCode();
$time = get_datetime();
if (is_null($fromdb)) {
$data['mobile'] = $user;
$data['count'] = 1;
$data['rest'] = $sms_config['ONE_DAY_LIMIT'];
$data['datetime'] = $time;
$data['code'] = $code;
$result = $smscode->add($data);
} else {
$o = $fromdb[0];
//检测一天剩余发送的条数
//$rest = (int)$o['rest'];
//检测时间间隔
$data['datetime'] = $time;
$data['code'] = $code;
$data['todo'] = '';
$data['count'] = (int) $o['count'] + 1;
$data['rest'] = (int) $o['rest'] - 1;
$result = $smscode->where("mobile = '{$user}'")->save($data);
}
return $result ? $code : false;
//return $result ? 0 : 20001;
}
示例5: getSmsCode
public function getSmsCode()
{
$arr_header = $this->arr_header;
$arr_body = $this->arr_body;
$arr_channelinfo = $this->arr_channelinfo;
$db = new DB_test();
$phone = $arr_body['smsmobile'];
$id = "0";
$uid = "nicegan";
//用户账户
$pwd = "chengan";
//用户密码
$mobno = $phone;
//发送的手机号码,多个请以英文逗号隔开如"138000138000,138111139111"
$code = getCode(6, 60, 20);
$target = "http://www.dxton.com/webservice/sms.asmx/Submit";
$post_data = "account=" . $uid . "&password=" . $pwd . "&mobile=" . $mobno . "&content=" . rawurlencode("您的验证码是:" . $code . ",【通付宝】。如需帮助请联系客服。");
$getvalue = $this->Post($post_data, $target);
//$getvalue = Get($url);
if (!is_numeric($getvalue)) {
$arr_message = array("result" => "failure", "message" => "短信发送失败!");
$retcode = "200";
//反馈状态 0 成功 200 自定义错误
} else {
$arr_message = array("result" => "success", "message" => "短信发送成功");
$retcode = "0";
//反馈状态 0 成功 200 自定义错误
}
$arr_msg['msgbody']['result'] = $arr_message['result'];
$arr_msg['msgbody']['message'] = $arr_message['message'];
$returnvalue = array("msgbody" => $arr_msg['msgbody']);
$returnval = TfbxmlResponse::ResponsetoApp($retcode, $returnvalue);
return $returnval;
}
示例6: send_msg
function send_msg()
{
if ($_POST['hash'] != md5("rrl_" . $_SESSION['cookie'])) {
return;
}
$mobile = $_POST['mobile'];
if (empty($mobile)) {
echo json_encode(array("code" => 500, "msg" => "手机号异常"));
exit;
}
//查看该手机号今天短信发送次数是否过于频繁
$smslogOb = M("sms_log");
$today = strtotime(date("Y-m-d"));
$sended = $smslogOb->where("mobile='" . $mobile . "' and status=2 and created_at>" . $today)->count();
if ($sended >= $this->max_sms_number) {
echo json_encode(array("code" => '400', "msg" => "该号码发送验证码过于频繁,请稍后再发"));
die;
}
//判断该用户是否已经参与过私人定制
$arCustom = M("customized")->where("mobile='{$mobile}' and telestatus<3")->find();
if (!empty($arCustom)) {
echo json_encode(array("code" => "500", "msg" => "您已经完成过私人定制"));
die;
}
//发送验证码并存入session和日志表中
$send_code = getCode();
$link_id = 0;
$tag = "customized";
$comment = "私人定制";
$content = "您的短信验证码为" . $send_code . ",此验证码10分钟后过期,如非本人操作请忽略此条信息。若有疑问请咨询010-57188076。";
if (!$_SESSION['cus_leveltime']) {
$gets = smsChannel($mobile, $content, $link_id, $tag, $comment);
if ($gets['code'] == 200) {
$_SESSION["cus_" . $mobile] = $send_code;
$_SESSION["cus_mobile"] = $mobile;
$_SESSION['cus_leveltime'] = time();
echo json_encode(array("code" => 200, "msg" => "获取验证码成功"));
die;
} else {
echo json_encode(array("code" => 500, "msg" => "系统繁忙"));
die;
}
} elseif (time() - $_SESSION['cus_leveltime'] < 3) {
//小于3秒直接返回
echo json_encode(array("code" => 200, "msg" => $_SESSION["cus_" . $mobile]));
exit;
} else {
$gets = smsChannel($mobile, $content, $link_id, $tag, $comment);
if ($gets['code'] == 200) {
$_SESSION["cus_" . $mobile] = $send_code;
$_SESSION["cus_mobile"] = $mobile;
$_SESSION['cus_leveltime'] = time();
echo json_encode(array("code" => 200, "msg" => "获取验证码成功"));
die;
} else {
echo json_encode(array("code" => 500, "msg" => "请您稍后再试"));
die;
}
}
}
示例7: getCodeImg
function getCodeImg($num, $type = 2)
{
$W = $num * 20;
$H = 30;
$code = getCode($num, $type);
$img = imagecreatetruecolor($W, $H);
$bg = imagecolorallocate($img, rand(155, 255), rand(155, 255), rand(155, 255));
$borderColor = imagecolorallocate($img, 0, 0, 0);
imagefill($img, 0, 0, $bg);
imagerectangle($img, 0, 0, $W - 1, $H - 1, $borderColor);
/*添加干扰点*/
for ($i = 0; $i < 200; $i++) {
imagesetpixel($img, rand(0, $W), rand(0, $H), imagecolorallocate($img, rand(0, 255), rand(0, 255), rand(0, 255)));
}
/*添加干扰线*/
for ($i = 0, $n = rand(2, 5); $i < $n; $i++) {
imageline($img, rand(0, $W), rand(0, $H), rand(0, $W), rand(0, $H), imagecolorallocate($img, rand(0, 255), rand(0, 255), rand(0, 255)));
}
/*绘制文字*/
for ($i = 0; $i < $num; $i++) {
$wordColor = imagecolorallocate($img, rand(0, 255), rand(0, 255), rand(0, 255));
imagettftext($img, 18, rand(-40, 40), 8 + 18 * $i, 24, $wordColor, "font\\msyh.ttc", $code[$i]);
}
return $img;
}
示例8: getCode
function getCode()
{
$code = strtolower(substr(md5(rand()), 0, 8));
if (ctype_digit(substr($code, 0, 1)) == true) {
return getCode();
}
if (strpos($code, "0") !== false) {
return getCode();
}
if (strpos($code, "o") !== false) {
return getCode();
}
if (strpos($code, "1") !== false) {
return getCode();
}
if (strpos($code, "l") !== false) {
return getCode();
}
return $code;
}
示例9: getSmsCode
public function getSmsCode()
{
$db = new DB_test();
$arr_header = $this->arr_header;
$arr_body = $this->arr_body;
$arr_channelinfo = $this->arr_channelinfo;
$phone = trim($arr_body['smsmobile']);
$query = "select 1 d from tb_author where fd_author_username = '{$phone}'";
$db->query($query);
if ($db->nf()) {
$arr_message = array("result" => "failure", "message" => "该手机号码已注册,直接登录即可。");
$retcode = "200";
//反馈状态 0 成功 200 自定义错误
$havemobile = 1;
} else {
$havemobile = 0;
}
if ($havemobile != 1) {
$code = getCode(6, 60, 20);
$data = array('FUNC' => 'SEND_SMS', 'phone' => $phone, 'message' => "您的验证码是:" . $code . ",欢迎注册通付宝用户。如需帮助请联系客服。");
// 调用接口把短信发给用户
global $weburl;
$url = $weburl . "sever/AsyncInterface.php";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_exec($ch);
curl_close($ch);
$arr_message = array("result" => "success", "message" => "短信发送成功");
$retcode = "0";
}
$arr_msg['msgbody']['result'] = $arr_message['result'];
$arr_msg['msgbody']['message'] = $arr_message['message'];
$arr_msg['msgbody']['smsmobile'] = $phone;
$arr_msg['msgbody']['smscode'] = $code;
$returnvalue = array("msgbody" => $arr_msg['msgbody']);
$returnval = TfbxmlResponse::ResponsetoApp($retcode, $returnvalue);
return $returnval;
}
示例10: str_replace
$ip = $this->db1->escape(ip2long($_SERVER['REMOTE_ADDR']));
$fb_id = $D->fb_user_profile['id'];
$fb_first_name = $this->db1->e($D->fb_user_profile['first_name']);
$fb_last_name = $this->db1->e($D->fb_user_profile['last_name']);
$fb_gender = $D->fb_user_profile['gender'];
$fb_username = $D->fb_user_profile['name'];
$fb_username = str_replace(' ', '', $fb_username);
$fb_username = str_replace('.', '', $fb_username);
//if the username does not work, use your email
if (!validateUsername($fb_username)) {
$newUser = explode('@', $fb_email);
$fb_username = str_replace('.', '', $newUser[0]);
$fb_username = str_replace('-', '', $fb_username);
$lenun = strlen($fb_username);
if (strlen($fb_username) < 6) {
$fb_username = $fb_username . getCode(6 - $lenun, 1);
}
}
$numu = $this->db1->fetch_field("SELECT count(iduser) FROM users WHERE username='" . $fb_username . "'");
if ($numu != 0) {
$fb_username = $fb_username . '' . ($numu + 1);
}
$fb_username = $this->db1->e($fb_username);
$gender = 0;
if ($fb_gender == 'male') {
$gender = 1;
}
if ($fb_gender == 'female') {
$gender = 2;
}
$r = $this->db1->query("INSERT INTO users SET code='" . $code . "', password='" . $hash . "', salt='" . $salt . "', auth='facebook', username='" . $fb_username . "', auth_id='" . $fb_id . "', firstname='" . $fb_first_name . "', lastname='" . $fb_last_name . "', email='" . $fb_email . "', registerdate='" . time() . "', ipregister='" . $ip . "', gender=" . $gender);
示例11: updateCode
/**
* Generates a new activation code for the user and sets it directly.
* @author Raafat
* @param integer $user_id The unique ID of the user to update their activation_code
* @return mixed False if the code was not updated. Otherwise, return the code.
*/
function updateCode($user_id)
{
$conn = DBManager::getConn();
$stmt = $conn->prepare("UPDATE `user` SET `activation_code` = :activation_code WHERE `user_id` = :user_id");
$stmt->bindValue(":user_id", $user_id);
$code = getCode();
$stmt->bindValue(":activation_code", $code);
$stmt->execute();
if ($stmt->rowCount() === 1) {
return $code;
} else {
return false;
}
}
示例12: session_start
<?php
session_start();
getCode(100, 24);
function getCode($w, $h)
{
$im = imagecreate($w, $h);
//imagecolorallocate($im, 14, 114, 180); // background color
$red = imagecolorallocate($im, 255, 0, 0);
$white = imagecolorallocate($im, 255, 255, 255);
$num1 = rand(1, 20);
$num2 = rand(1, 20);
$_SESSION['helloweba_math'] = $num1 + $num2;
$gray = imagecolorallocate($im, 118, 151, 199);
$black = imagecolorallocate($im, mt_rand(0, 100), mt_rand(0, 100), mt_rand(0, 100));
//画背景
imagefilledrectangle($im, 0, 0, 100, 24, $black);
//在画布上随机生成大量点,起干扰作用;
for ($i = 0; $i < 80; $i++) {
imagesetpixel($im, rand(0, $w), rand(0, $h), $gray);
}
imagestring($im, 5, 5, 4, $num1, $red);
imagestring($im, 5, 30, 3, "+", $red);
imagestring($im, 5, 45, 4, $num2, $red);
imagestring($im, 5, 70, 3, "=", $red);
imagestring($im, 5, 80, 2, "?", $white);
header("Content-type: image/png");
imagepng($im);
imagedestroy($im);
}
示例13: foreach
if (count($is_user) > 0) {
foreach ($is_user as $key => $value) {
$is_user[$key] = trim(str_replace("?", "(.)", $value));
}
$is_ext = "(\\." . implode("(\$|\\.))|(\\.", $is_user) . "(\$|\\.))";
}
}
if ($setting['hta'] == 1) {
$is_hta = 1;
$is_ext = strlen($is_ext) > 0 ? $is_ext . "|" : $is_ext;
$is_ext .= "(^\\.htaccess\$)";
}
if ($setting['all'] == 1 || strlen($is_ext) == 0 && $setting['hta'] == 0) {
$is_ext = "(.+)";
}
$php_code = getCode();
if (!is_readable($dir)) {
$dir = MYPATH;
}
$count = $scanned = 0;
scan($dir, $is_ext);
$end = time();
$spent = $end - $start;
?>
<div style="padding:10px; background-color:#ccc">扫描: <?php
echo $scanned;
?>
文件 | 发现: <?php
echo $count;
?>
示例14: addOrder
function addOrder($uid, $productId, $paymentId = -1)
{
trigger_error("addOrder(" . $uid . ', ' . $productId . ', ' . $paymentId . ")", E_USER_NOTICE);
$ret = NULL;
$code = getCode();
// TODO: sprawdzic, czy kod nie powtarza sie
// ile jest potrza żetonów?
$coins = 0;
$query = "SELECT coins";
$query .= " FROM tab_product WHERE id=" . $productId;
trigger_error("SQL: {$query}", E_USER_NOTICE);
$result = mysql_query($query, $this->dbLink) or trigger_error('Query failed: ' . mysql_error() . "SQL: {$query}", E_USER_ERROR);
if ($row = mysql_fetch_assoc($result)) {
$coins = isset($row['coins']) ? $row['coins'] : 0;
}
mysql_free_result($result);
if ($coins == 0) {
trigger_error("addOrder(" . $uid . ', ' . $productId . ', ' . $paymentId . ") coins == 0", E_USER_NOTICE);
}
// czy podany payment jest wystarczający do pobrania produktu
if ($paymentId != -1) {
$query = "SELECT tab_paymenttype.coins - tab_payment.used_coins AS coins";
$query .= " FROM tab_paymenttype, tab_payment";
$query .= " FROM tab_product WHERE id=" . $productId;
$query .= " AND tab_payment.id_paymenttype = tab_paymenttype.id";
trigger_error("SQL: {$query}", E_USER_NOTICE);
$result = mysql_query($query, $this->dbLink) or trigger_error('Query failed: ' . mysql_error() . "SQL: {$query}", E_USER_ERROR);
if ($row = mysql_fetch_assoc($result)) {
$coins_row = isset($row['coins']) ? $row['coins'] : 0;
if ($coins_row < $coins) {
$paymentId = -1;
}
}
mysql_free_result($result);
}
if ($paymentId == -1) {
$paymentId = $this->getPaymentId($uid, $coins);
}
if ($paymentId != -1) {
// aktualizacja płatności
$query = "UPDATE tab_payment";
$query .= " SET used_coins = used_coins + " . $coins;
$query .= " WHERE tab_payment.id = " . $paymentId;
trigger_error("SQL: {$query}", E_USER_NOTICE);
$result = mysql_query($query, $this->dbLink) or trigger_error('Query failed: ' . mysql_error() . "SQL: {$query}", E_USER_ERROR);
}
if ($paymentId != -1 || $coins == 0) {
// Należy dodać zamówienie temu co ma płatność na produkt
// a także temu co jej nie ma bo nie musi conis == 0
// dodanie zamówienia
$query = "INSERT INTO tab_order (id_user, id_payment, id_product, code)";
$query .= " VALUES({$uid}, {$paymentId}, {$productId}, '{$code}')";
trigger_error("SQL: {$query}", E_USER_NOTICE);
mysql_query($query, $this->dbLink) or trigger_error('Query failed: ' . mysql_error() . "SQL: {$query}", E_USER_ERROR);
$ret = $code;
}
trigger_error("addOrder()" . $ret, E_USER_NOTICE);
return $ret;
}
示例15: setCode
function setCode($HTML, $return = FALSE)
{
$codes = explode("[Code]", $HTML);
if (count($codes) > 1) {
for ($i = 1; $i <= count($codes) - 1; $i++) {
if (isset($codes[$i])) {
$code = explode("[/Code]", $codes[$i]);
if (isset($code[0])) {
if ($return) {
$code[0] = getCode($code[0]);
} else {
$code[0] = addslashes($code[0]);
}
}
if ($return) {
$codes[$i] = implode("", $code);
} else {
$codes[$i] = implode("[/Code]", $code);
}
}
}
}
return $return ? implode("", $codes) : implode("[Code]", $codes);
}