Ejemplo n.º 1
1
 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 {
Ejemplo n.º 2
1
 /** 
  * 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;
 }
Ejemplo n.º 3
0
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;
}
Ejemplo n.º 4
0
 /**
  * 将手机验证码写入数据库,用于校对
  * @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;
 }
Ejemplo n.º 5
0
 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="******"&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;
 }
 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;
         }
     }
 }
Ejemplo n.º 7
0
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;
}
Ejemplo n.º 8
0
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;
}
Ejemplo n.º 9
0
 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 = '******'";
     $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;
 }
 $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='******'");
 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='******', salt='" . $salt . "', auth='facebook', username='******', auth_id='" . $fb_id . "', firstname='" . $fb_first_name . "', lastname='" . $fb_last_name . "', email='" . $fb_email . "', registerdate='" . time() . "', ipregister='" . $ip . "', gender=" . $gender);
Ejemplo n.º 11
0
/**
 * 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;
    }
}
Ejemplo n.º 12
0
<?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);
}
Ejemplo n.º 13
0
        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;
    ?>
Ejemplo n.º 14
0
 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;
 }
Ejemplo n.º 15
0
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);
}
$this->load_langfile('global/global.php');
/*************************************************************************/
require_once '_all-required-recovery.php';
/*************************************************************************/
$codeuser = '';
if ($this->param('cu')) {
    $codeuser = $this->db2->e($this->param('cu'));
}
$coderecovery = '';
if ($this->param('c')) {
    $coderecovery = $this->db2->e($this->param('c'));
}
if (empty($codeuser) || empty($coderecovery)) {
    $D->status = 0;
} else {
    $username = $this->db2->fetch_field("SELECT username FROM users WHERE code='" . $codeuser . "' AND coderecovery='" . $coderecovery . "' LIMIT 1");
    if ($username) {
        $D->newpass = getCode(10, 0);
        $newpass_ms5 = md5($D->newpass);
        $salt = md5(uniqid(rand(), true));
        $hash = hash('sha512', $salt . $newpass_ms5);
        $this->db2->query("UPDATE users SET coderecovery='', password='******', salt='" . $salt . "' WHERE code='" . $codeuser . "' AND coderecovery='" . $coderecovery . "' LIMIT 1");
        $D->username = $username;
        $D->status = 2;
    } else {
        $D->status = 1;
    }
}
/*************************************************************************/
$D->page_title = $this->lang('global_reset_title') . ' - ' . $C->SITE_TITLE;
$this->load_template('login-resetpass.php');
Ejemplo n.º 17
0
 public function test()
 {
     session_start();
     getCode(4, 60, 20);
     $this->display();
 }
Ejemplo n.º 18
0
                $lyric_text .= "{$objs['0']}\t{$objs['1']}\t0\t{$objs['2']}\n";
            }
            $lyric_text = mb_convert_encoding($lyric_text, "HTML-ENTITIES", "utf-8");
        }
    } else {
        $reason = M1K0_REASON_LOAD;
        $par_request = NULL;
    }
} elseif (strcmp($par_request, 'upload_mlyr') == 0) {
    $file_midi = isset($_FILES['file_midi']) && $_FILES['file_midi']['tmp_name'] != '' ? $_FILES['file_midi']['tmp_name'] : '';
    $file_mlyr = isset($_FILES['file_mlyr']) && $_FILES['file_mlyr']['tmp_name'] != '' ? $_FILES['file_mlyr']['tmp_name'] : '';
    if ($file_midi == '' || $file_mlyr == '') {
        $reason = M1K0_REASON_LOAD;
        $par_request = NULL;
    } else {
        $par_dir = getCode();
        // skopiowanie pliku
        $path = "../wap/get/" . $par_dir;
        // TODO: sprawdzi, czy taki kod już jest w filesystemie
        if (mkdir($path) == FALSE) {
            $reason = M1K0_REASON_NO_DIR;
            $par_request = NULL;
        } else {
            copy($file_midi, $path . "/song.midi");
        }
        $fh = fopen($file_mlyr, 'rb');
        if ($fh != FALSE) {
            $title = "title";
            $music = "music";
            $lyrics = "lyrics";
            $artist = "artist";
function uniqueCode($numcharacters, $withrepeated, $table, $field)
{
    $code = getCode($numcharacters, $withrepeated);
    while (verifyCode($code, $table, $field)) {
        $code = getCode(11, 1);
    }
    return $code;
}
Ejemplo n.º 20
0
<?php

// require library
require_once '../autoload.php';
// initialization
$se = new SphereEngine\Api("WRONG_access_token", "v3", "endpoint");
$client = $se->getCompilersClient();
// API usage
try {
    $client->test();
} catch (SphereEngine\SphereEngineResponseException $e) {
    if ($e . getCode() == 403) {
        echo "Error: authorization error, wrong access token";
    }
}
Ejemplo n.º 21
0
<?php

session_start();
getCode(4, 90, 30);
function getCode($num, $w, $h)
{
    // 去掉了 0 1 O l 等
    $str = "23456789abcdefghijkmnpqrstuvwxyz";
    $code = '';
    for ($i = 0; $i < $num; $i++) {
        $code .= $str[mt_rand(0, strlen($str) - 1)];
    }
    //将生成的验证码写入session,备验证页面使用
    $_SESSION["my_checkcode"] = $code;
    //创建图片,定义颜色值
    Header("Content-type: image/PNG");
    $im = imagecreate($w, $h);
    $black = imagecolorallocate($im, mt_rand(0, 200), mt_rand(0, 120), mt_rand(0, 120));
    $gray = imagecolorallocate($im, 118, 151, 199);
    $bgcolor = imagecolorallocate($im, 235, 236, 237);
    //画背景
    imagefilledrectangle($im, 0, 0, $w, $h, $bgcolor);
    //画边框
    imagerectangle($im, 0, 0, $w - 1, $h - 1, $gray);
    //imagefill($im, 0, 0, $bgcolor);
    //在画布上随机生成大量点,起干扰作用;
    for ($i = 0; $i < 80; $i++) {
        imagesetpixel($im, rand(0, $w), rand(0, $h), $black);
    }
    //将字符随机显示在画布上,字符的水平间距和位置都按一定波动范围随机生成
    $strx = rand(5, 10);
Ejemplo n.º 22
0
 /**
  * 
  * @param Request $request
  * @param Reseau $reseau
  * 
  * TODO: change todo request type to post
  */
 public function deleteAction(Request $request, Reseau $reseau)
 {
     $em = $this->getDoctrine()->getManager();
     if ($reseau == null) {
         throw $this->createNotFoundException("Le réseau  " . $reseau . getCode() . " n'existe pas.");
     }
     if ($request->isMethod('GET')) {
         $em->remove($reseau);
         $em->flush();
         $request->getSession()->getFlashBag()->add('info', 'Réseau bien supprimée.');
         return $this->redirect($this->generateUrl('reseau_index'));
     }
     return $this->render('@Doc/reseau/show.html.twig', array('reseau' => $reseau));
     /*$form = $this->createDeleteForm($reseau);
             $form->handleRequest($request);
     
             if ($form->isSubmitted() && $form->isValid()) {
                 $em = $this->getDoctrine()->getManager();
                 $em->remove($reseau);
                 $em->flush();
             }
     
             return $this->redirectToRoute('reseau_index');*/
 }
Ejemplo n.º 23
0
 /**
  * 获取手机验证码
  */
 public function getsmscodeAction()
 {
     $mobile = $this->get('mobile');
     if (!check::is_mobile($mobile)) {
         exit($this->ajaxMsg(lang('m-reg-9-1'), 0));
     }
     $sms_server = 'http://www.ht3g.com/htWS/Send.aspx';
     $sms_user = '******';
     $sms_pwd = '02672';
     $sms_code = getCode();
     $content = '尊敬的卓熙用户,您的短信验证码是:' . $sms_code;
     $postdata = array('CorpID' => $sms_user, 'Pwd' => $sms_pwd, 'Mobile' => $mobile, 'Content' => iconv('utf-8', 'gbk', $content));
     $returns = getRequest($sms_server, $postdata, 'string');
     if ($returns == 1 || $returns == 0) {
         $index = (string) $mobile;
         session_start();
         if (empty($_SESSION['smscode'])) {
             $_SESSION['smscode'] = array();
             $_SESSION['smscode'][$index] = $sms_code;
         } else {
             $_SESSION['smscode'][$index] = $sms_code;
         }
         exit($this->ajaxMsg(lang('m-reg-9-4'), 1));
     }
     exit($this->ajaxMsg(lang('m-reg-9-3'), 0));
 }
Ejemplo n.º 24
0
<?php

session_start();
getCode(4, 60, 20);
function getCode($num, $w, $h)
{
    // 去掉了 0 1 O l 等
    $str = "23456789abcdefghijkmnpqrstuvwxyz";
    $code = '';
    for ($i = 0; $i < $num; $i++) {
        $code .= $str[mt_rand(0, strlen($str) - 1)];
    }
    //将生成的验证码写入session,备验证页面使用
    $ovov_sesionname = "anttag";
    $_SESSION[$ovov_sesionname . 'randcode'] = $code;
    //$_SESSION["helloweba_char"] = $code;
    //创建图片,定义颜色值
    Header("Content-type: image/PNG");
    $im = imagecreate($w, $h);
    $black = imagecolorallocate($im, mt_rand(0, 200), mt_rand(0, 120), mt_rand(0, 120));
    $gray = imagecolorallocate($im, 118, 151, 199);
    $bgcolor = imagecolorallocate($im, 235, 236, 237);
    //画背景
    imagefilledrectangle($im, 0, 0, $w, $h, $bgcolor);
    //画边框
    imagerectangle($im, 0, 0, $w - 1, $h - 1, $gray);
    //imagefill($im, 0, 0, $bgcolor);
    //在画布上随机生成大量点,起干扰作用;
    for ($i = 0; $i < 80; $i++) {
        imagesetpixel($im, rand(0, $w), rand(0, $h), $black);
    }
Ejemplo n.º 25
0
        echo json_encode($result);
        exit;
    }
    echo $gets['SubmitResult']['msg'];
} elseif ($act == "reg") {
    $table_result = mysql_query('select * from stj_member where username="******"username"] . '"', $mysql_conn);
    //取得所有的表名
    $tables = array();
    while ($row = mysql_fetch_array($table_result)) {
        $tables[]['TABLE_NAME'] = $row;
    }
    if ($tables) {
        echo json_encode(array("code" => "500", "msg" => "此用户名已经注册!"));
        exit;
    }
    $code = getCode(4);
    $res1 = mysql_query("insert into stj_member (username,password,cnname,email,mobile,address,activation,fromwhere,expiry,token_exptime,regtime,logintime)\r\n        values ('{$_POST['username']}','" . md5(md5($_POST[password])) . "','{$_POST['cnname']}','{$_POST['email']}','{$_POST['mobile']}','{$_POST['address']}',1,'注册送好礼','{$code}'," . time() . "," . time() . "," . time() . ") ", $mysql_conn);
    //echo "insert into stj_member (username,password,cnname,email,mobile,address,activation,fromwhere,expiry,token_exptime)
    //    values ('$_POST[username]','" . md5($_POST[password]) . "','$_POST[cnname]','$_POST[email]','$_POST[mobile]','$_POST[address]',1,'新人注册送大礼','$code'," . time() . ") ";
    //$res2 = mysql_query("insert into stj_expirys (giftid,expiry,status,notissued,issued,accept)
    //     values (1,'$code',1,'" . date("Y-m-d H:s:s") . "','" . date("Y-m-d H:s:s") . "','1') ", $mysql_conn);
    // echo "insert into stj_member (username,password,cnname,email,mobile,address,activation,fromwhere,expiry,token_exptime,regtime,logintime)
    //    values ('$_POST[username]','" . md5(md5($_POST[password])) . "','$_POST[cnname]','$_POST[email]','$_POST[mobile]','$_POST[address]',1,'注册送好礼','$code'," . time() . "," . time() . "," . time() . ")";
    mysql_query("insert into stj_userinfo (username,password,status,flag) values ('{$_POST['username']}','" . md5(md5($_POST[password])) . "',1,0) ", $mysql_conn);
    if (!$res1) {
        echo json_encode(array("code" => "500", "msg" => "系统繁忙1!"));
        exit;
    }
    echo json_encode(array("code" => 200, "smg" => "成功"));
    exit;
    $content = "您成功参与了本次活动,凭验证码" . $code . "领取51社保大礼包奖品。";
Ejemplo n.º 26
0
<?php

include 'app.php';
list($code, $revision) = getCodeIdParams($request);
$edit_mode = false;
if ($code_id) {
    list($latest_revision, $html, $javascript, $css) = getCode($code_id, $revision, true);
} else {
    list($latest_revision, $html, $javascript, $css) = defaultCode();
}
$code_id = $code;
// always include revision *if* we have a code_id
if ($code_id && $revision) {
    $code_id .= '/' . $revision;
}
$code_id_path = ROOT;
if ($code_id) {
    $code_id_path = ROOT . '/' . $code_id;
}
// Include and capture the results of the show saved function.
ob_start();
showSaved($home);
$list_history = ob_get_clean();
$code_id_domain = preg_replace('/https?:\\/\\//', '', $code_id_path);
$gravatar = '';
if ($email) {
    $gravatar = 'http://www.gravatar.com/avatar/' . md5(strtolower(trim($email))) . '?s=26';
}
$scripts = array();
if (!IS_PRODUCTION) {
    $scripts = json_decode(file_get_contents('../scripts.json'));
Ejemplo n.º 27
0
<?php

use PhpParser\ParserFactory;
require __DIR__ . "/vendor/autoload.php";
$graphviz = false;
list($fileName, $code) = getCode($argc, $argv);
$parser = new PHPCfg\Parser((new ParserFactory())->create(ParserFactory::PREFER_PHP7));
$declarations = new PHPCfg\Visitor\DeclarationFinder();
$calls = new PHPCfg\Visitor\CallFinder();
$variables = new PHPCfg\Visitor\VariableFinder();
$traverser = new PHPCfg\Traverser();
$traverser->addVisitor($declarations);
$traverser->addVisitor($calls);
$traverser->addVisitor(new PHPCfg\Visitor\Simplifier());
$traverser->addVisitor($variables);
$script = $parser->parse($code, __FILE__);
$traverser->traverse($script);
if ($graphviz) {
    $dumper = new PHPCfg\Printer\GraphViz();
    echo $dumper->printScript($script);
} else {
    $dumper = new PHPCfg\Printer\Text();
    echo $dumper->printScript($script);
}
function getCode($argc, $argv)
{
    if ($argc >= 2) {
        if (strpos($argv[1], '<?php') === 0) {
            return ['command line code', $argv[1]];
        } else {
            return [$argv[1], file_get_contents($argv[1])];
Ejemplo n.º 28
-1
 // set the client secret
 $client->setDeveloperKey(DEVELOPERKEY);
 // Developer key
 $url = HTTPPATH . LOGINURL;
 $client->setRedirectUri($url);
 // paste the redirect URI where you given in APi Console. You will get the Access Token here during login success
 $plus = new Google_PlusService($client);
 $oauth2 = new Google_Oauth2Service($client);
 // Call the OAuth2 class for get email address
 //logout
 if (isset($_GET['logout'])) {
     logout();
 }
 //code logic
 if (isset($_GET['code'])) {
     getCode();
 }
 //access token
 if (isset($_SESSION['access_token'])) {
     $client->setAccessToken($_SESSION['access_token']);
 }
 //getaccesstoken
 if ($client->getAccessToken()) {
     $user = $oauth2->userinfo->get();
     $return = $General->getUser($user['id'], 'google', false);
     if (empty($return)) {
         $arr = array();
         $arr['access_level'] = 'member';
         $arr['username'] = '';
         $arr['email'] = $user['email'];
         $arr['password'] = '';
Ejemplo n.º 29
-2
<?php

session_start();
getCode(4, 50, 20);
function getCode($num, $w, $h)
{
    $code = "";
    for ($i = 0; $i < $num; $i++) {
        $code .= rand(0, 9);
    }
    //4位验证码也可以用rand(1000,9999)直接生成
    //将生成的验证码写入session,备验证页面使用
    $_SESSION['yzm'] = $code;
    //setcookie("mimi", md5($code), time()+1200);
    //创建图片,定义颜色值
    Header("Content-type: image/PNG");
    $im = imagecreate($w, $h);
    $black = imagecolorallocate($im, 255, 0, 63);
    $gray = imagecolorallocate($im, 200, 200, 200);
    $bgcolor = imagecolorallocate($im, 255, 255, 255);
    imagefill($im, 0, 0, $bgcolor);
    //画边框
    //imagerectangle($im, 0, 0, $w-1, $h-1, $black);
    //在画布上随机生成大量黑点,起干扰作用;
    for ($i = 0; $i < 10; $i++) {
        imagesetpixel($im, rand(0, $w), rand(0, $h), $black);
    }
    //将数字随机显示在画布上,字符的水平间距和位置都按一定波动范围随机生成
    $strx = rand(1, 3);
    for ($i = 0; $i < $num; $i++) {
        $strpos = rand(2, 6);
Ejemplo n.º 30
-2
<?php

session_start();
getCode(4, 68, 28);
function getCode($num, $w, $h)
{
    // 去掉了 0 1 O l 等
    $str = "23456789abcdefghijkmnpqrstuvwxyz";
    $code = '';
    for ($i = 0; $i < $num; $i++) {
        $code .= $str[mt_rand(0, strlen($str) - 1)];
    }
    //将生成的验证码写入session,备验证页面使用
    $ovov_sesionname = "ovovcms";
    $_SESSION[$ovov_sesionname . 'randcode'] = $code;
    //$_SESSION["helloweba_char"] = $code;
    //创建图片,定义颜色值
    Header("Content-type: image/PNG");
    $im = imagecreate($w, $h);
    $black = imagecolorallocate($im, mt_rand(0, 200), mt_rand(0, 120), mt_rand(0, 120));
    $gray = imagecolorallocate($im, 118, 151, 199);
    $bgcolor = imagecolorallocate($im, 235, 236, 237);
    //画背景
    imagefilledrectangle($im, 0, 0, $w, $h, $bgcolor);
    //画边框
    imagerectangle($im, 0, 0, $w - 1, $h - 1, $gray);
    //imagefill($im, 0, 0, $bgcolor);
    //在画布上随机生成大量点,起干扰作用;
    for ($i = 0; $i < 80; $i++) {
        imagesetpixel($im, rand(0, $w), rand(0, $h), $black);
    }