/**
  * Etablissement d'un challenge, sur la base d'un identifiant SSO
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2006/12/08
  * @param integer $id_sso Id SSO
  * @return string résultat du challenge. -ERR xxx si erreur, +OK xxx si c'est bon
  */
 public function challenge()
 {
     $id_sso = $this->getRequest('id_sso', null);
     if (!$id_sso) {
         echo "-ERR ACC: id_sso manquant";
     } elseif (!preg_match('/^[0-9]+$/', $id_sso)) {
         echo "-ERR ACC: id_sso doit être un nombre";
     } else {
         $token = false;
         $sql = "SELECT login FROM kernel_sso_users WHERE id_sso = {$id_sso}";
         $sso = _doQuery($sql);
         //print_r($sso);
         if ($sso) {
             // On efface l'éventuel challenge courant
             $daoChallenges = CopixDAOFactory::create('sso|sso_challenges');
             $daoChallenges->deleteByIdSso($id_sso);
             // On insère le nouveau challenge
             $token = randomkeys(CopixConfig::get('sso|in_encrypt_size'));
             $res = record('kernel_sso_challenges');
             $res->id_sso = $id_sso;
             $res->challenge = $token;
             $res->date = mktime();
             _ioDao('kernel_sso_challenges')->insert($record);
             //print_r($res);
             // if ($res->_idResult != 1)	{ echo "-ERR BDD: Erreur lors de l'enregistrement dans la base de données"; }
             //Kernel::deb (md5($token.'FobVVbarwb'));
             //die();
             $token = "+OK " . $token;
         } else {
             echo "-ERR ACC: id_sso inexistant";
         }
         echo $token;
     }
     return new CopixActionReturn(COPIX_AR_NONE, 0);
 }
示例#2
0
 public function add()
 {
     $this->init();
     if (IS_POST) {
         $Room = M("Room");
         $data['name'] = I('post.name');
         $data['password'] = I('post.password');
         $result = $Room->where(array('name' => $data['name']))->find();
         if ($result == null or $result == false) {
             $data['salt'] = randomkeys(6);
             $data['password'] = md5($data['salt'] . $data['password']);
             $data['belong_to_user'] = session(C("USERID"));
             if (false === $Room->create($data)) {
                 echo json_encode(1);
             } else {
                 $id = $Room->add($data);
                 echo json_encode(0);
             }
         } else {
             echo json_encode(2);
         }
     } else {
         $this->display();
     }
 }
示例#3
0
function randomkeys()
{
    $time = str_replace("0.", "", str_replace(" ", "", microtime()));
    $sub = substr($time, 0, 6);
    $time = substr($time, 6, 12);
    $rand = rand(0, 100000000000);
    list($usec, $sec) = explode(' ', microtime());
    $rand = $usec * 10000000;
    $rand = mt_rand(0, $rand);
    $card_no = str_pad($time + $sub + $rand, 12, '0', STR_PAD_LEFT);
    $user = M('user');
    $user = $user->where('vip_card =' . $card_no)->find();
    if (!empty($user)) {
        randomkeys();
    } else {
        return $card_no;
    }
}
示例#4
0
文件: useraction.php 项目: Zocoo/zune
 function adduser($email, $name, $age, $address, $sex, $password)
 {
     // add new user
     $em = new email();
     $code = randomkeys(7);
     $rs = $em->send($email, $code);
     if ($rs == 1) {
         $u = new user();
         $u->setCode($code);
         $u->setEmail($email);
         $ud = new userdao();
         $result = $ud->add($u);
         if ($result > 0) {
             $nu = $ud->selectbyid($result);
             reobj($nu[0]);
         } else {
             remsg(0, "新增用户失败!");
         }
     } else {
         remsg(0, "发送邮件失败!");
     }
 }
示例#5
0
function create_credit_link($userID, $urlID, $type = 0)
{
    global $db;
    if ($urlID == '' or !is_numeric($urlID) or $urlID < 1) {
        return 0;
    }
    if (!$db->Query("SELECT id FROM userlinks WHERE id='{$urlID}' LIMIT 1")) {
        return 0;
    }
    $i = 0;
    while (true) {
        $i++;
        if ($i > 1000) {
            return 0;
        }
        $seed = randomkeys(10);
        $link = $seed . $userID . $urlID . $type;
        $mixup = mixup($link);
        $hash = makehash($link);
        if (!$db->Query("SELECT link FROM earnedlinks WHERE link='{$mixup}' LIMIT 1")) {
            return "c={$mixup}&h={$hash}";
        }
    }
}
        } else {
            if ($_REQUEST["back"] == "2") {
                $backurl = "users.php";
            }
        }
    }
    echo "<script>location.href='" . $backurl . "?p=" . $_REQUEST["p"] . "&r=1';</script>";
    exit;
}
if ($_REQUEST["action"] == "insert") {
    $createtime = $_REQUEST["createtime"] == "" ? date('Y-m-d H:i:s') : $_REQUEST["createtime"];
    $companymail = $_REQUEST["companymail"];
    $name = $companymail;
    if (trim($_REQUEST["user_type"]) == 1 || trim($_REQUEST["user_type"]) == 3) {
        $users_sn = "A10" . date("Y") . randomkeys(5);
        $companynum = "B10" . date("Y") . randomkeys(5);
    }
    if (trim($_REQUEST["user_type"]) == 2 || trim($_REQUEST["user_type"]) == 4) {
        $users_sn = "A20" . date("Y") . $xnum;
        $companynum = "B20" . date("Y") . $xnum;
    }
    $userpwd = md5(trim($_REQUEST["userpwd"]));
    $userpwd2 = trim($_REQUEST["userpwd"]);
    $sql = "insert into users(name,users_sn,userpwd,userpwd2,truename,user_type,ispass,jobtitle,companymail,telephone,mobile,countryid,provincialid,city,companyname,companywebsite,industry,mestype1,mestype2,mycontent,isdujia,pro_type,trade,img,companynum,contact_mail,createtime)values('" . $name . "','" . $users_sn . "','" . $userpwd . "','" . $userpwd2 . "','" . trim($_REQUEST["truename"]) . "'," . trim($_REQUEST["user_type"]) . ",1,'" . trim($_REQUEST["jobtitle"]) . "','" . $companymail . "','" . trim($_REQUEST["telephone"]) . "','" . trim($_REQUEST["mobile"]) . "'," . $_REQUEST["countrySlc"] . "," . trim($_REQUEST["provincialid"]) . ",'" . trim($_REQUEST["citySlc"]) . "','" . $_REQUEST["companyname"] . "','" . $_REQUEST["companywebsite"] . "','" . $_REQUEST["industry"] . "','" . $_REQUEST["mestype1"] . "','" . $_REQUEST["mestype2"] . "','" . $_REQUEST["mycontent"] . "'," . trim($_REQUEST["isdujia"]) . ",'" . trim($_REQUEST["pro_type"]) . "'," . trim($_REQUEST["trade"]) . ",'" . $_REQUEST["img"] . "','" . $companynum . "','" . trim($_REQUEST["contact_mail"]) . "',now());";
    $rs = mysql_query($sql, $conn);
    if ($_REQUEST["back"] == 0) {
        $backurl = "users_all.php";
    } else {
        if ($_REQUEST["back"] == 1) {
            $backurl = "users_root.php?p=" . $_REQUEST["p"] . "&search_type=" . $_REQUEST["search_type"] . "&user_type=" . $_REQUEST["search_type"];
        } else {
示例#7
0
/**
 * Return a new random filename, with the given extension
 * @param type $extension
 * @return string
 */
function safe_filename($extension = '')
{
    $prefix = sprintf('%08x', time()) . randomkeys(4);
    if (empty($extension)) {
        return $prefix;
    } else {
        return $prefix . '.' . $extension;
    }
}
 public function sendPasswordChange()
 {
     $id = I('post.id');
     $a = $this->getAccountById($id);
     $identify = randomkeys(11);
     $relUrl = 'Account/resetPassword';
     $requestUrl = U($relUrl, array('identify' => $identify), '', true);
     //加true显示域名
     $title = "软件工程b课程网站密码重置";
     $message = "请在一小时内访问以下地址重置密码:\n" . $requestUrl;
     $email = $a['aemail'];
     $data['id'] = $id;
     $data['identify'] = $identify;
     $data['expiretime'] = 3600;
     //单位为秒
     $data['requesttime'] = date('Y-m-d H:i:s');
     //$this->success('发送成功!');
     $Form = M('requestpassword');
     $pre = $Form->find($id);
     if ($pre != null) {
         if (time() - strtotime($pre['requesttime']) > 60) {
             //如果多次请求,前一次请求过期,删除前一次
             $Form->delete($id);
         } else {
             $this->error('请求过于频繁!请稍后再试');
         }
     }
     if ($Form->create($data)) {
         //create方法将post中的数据转化到$data数组中,add()函数默认$data为参数
         $result = $Form->add();
         if ($result) {
             if (sendMail($email, $title, $message)) {
                 $this->success('正在返回首页……', U('Index/index'));
             } else {
                 $this->error('发送失败');
                 $Form->delete($id);
             }
         } else {
             $this->error('数据添加错误!');
         }
     } else {
         $this->error($Form->getError());
     }
 }
示例#9
0
 function reg($uname, $password, $email, $uarray = array())
 {
     global $cfg_reg_score, $cfg_reg_checkemail;
     //注册送积分
     $timestamp = time();
     $this->activekey = randomkeys(5, "ALL");
     //激活用户使用
     $this->uname = $uname;
     //变量放入对象中
     $this->email = $email;
     //变量放入对象中
     $ckname = $this->checkuname($uname, true);
     $ckmail = $this->checkemail($email, true);
     if ($ckname == "OK" && $ckmail == "OK") {
         $pwd = md5($password);
         //加密方式 两次MD5
         #api{{
         if (defined('UC_API') && @(include_once ROOT_PATH . '/uc_client/client.php')) {
             $uid = uc_user_register($uname, $password, $email);
             if ($uid <= 0) {
                 if ($uid == -1) {
                     return lang('User_notvalid');
                 } elseif ($uid == -2) {
                     return lang('Contains_rege_words');
                 } elseif ($uid == -3) {
                     return lang('user_already_exists', array('$uname' => $uname));
                 } elseif ($uid == -5) {
                     return lang('Email_notallowrege');
                 } elseif ($uid == -6) {
                     return lang('Email_already_registered');
                 } else {
                     return lang('register_failed');
                 }
             } else {
                 //插入本地数据库操作
                 $uarray['uid'] = $uid;
                 $uarray['password'] = $pwd;
                 $uarray['uname'] = $uname;
                 $uarray['email'] = $email;
                 $uarray['regtime'] = $timestamp;
                 $uarray['logintime'] = $timestamp;
                 $uarray['activekey'] = $this->activekey;
                 //激活使用
                 if ($cfg_reg_checkemail == "Y") {
                     $uarray['state'] = 0;
                 } else {
                     $uarray['state'] = 1;
                 }
                 //$uarray['scores']=$cfg_reg_score;//注册送积分
                 if (is_numeric(inserttable($this->table, $uarray, 1))) {
                     $this->ucsynlogin = uc_user_synlogin($uid);
                     $auth = $uid . "\t" . $uname . "\t" . $pwd;
                     set_cookie('loginauth', cookie_authcode($auth, 'ENCODE'));
                     include_once INC_PATH . "/cart.class.php";
                     $Cart = CartClass::init();
                     $Cart->amonymoustouname($uid, $uname);
                     //注册送积分
                     $note = lang('rege_send_point') . $cfg_reg_score;
                     $this->scoreedit($uname, $cfg_reg_score, $note);
                     if ($cfg_reg_checkemail == "Y") {
                         //发送验证邮件
                         $this->sendactiveemail();
                     }
                     return 'OK';
                 }
             }
         } else {
             #/aip}}
             //不是ucenter状态
             //插入数据库用户
             $activekey = $this->activekey;
             if ($cfg_reg_checkemail == "Y") {
                 $userstate = 0;
             } else {
                 $userstate = 1;
             }
             $tel = $uarray['tel'];
             $this->db->query("INSERT INTO `{$this->table}`(uname,email,password,tel,scores,money,regtime,logintime,activekey,state) values('{$uname}','{$email}','{$pwd}','{$tel}',0,0,{$timestamp},{$timestamp},'{$activekey}',{$userstate})");
             $uid = $this->db->insert_id();
             $auth = $uid . "\t" . $uname . "\t" . $pwd;
             set_cookie('loginauth', cookie_authcode($auth, 'ENCODE'), $this->cookietime);
             include_once INC_PATH . "/cart.class.php";
             $Cart = CartClass::init();
             $Cart->amonymoustouname($uid, $uname);
             $note = lang('rege_send_point') . $cfg_reg_score;
             $this->scoreedit($uname, $cfg_reg_score, $note);
             if ($cfg_reg_checkemail == "Y") {
                 //发送验证邮件
                 $this->sendactiveemail();
             }
             return 'OK';
         }
     } else {
         $errormsg = "";
         if ($ckname != 'OK') {
             $errormsg .= $ckname;
         }
         if ($ckmail != 'OK') {
             $errormsg .= $ckmail;
         }
         return $errormsg;
     }
 }
示例#10
0
     // 带演示版本
     $sqlfile = $sqldemofile;
 }
 $sql = file_get_contents($sqlfile);
 $sql = str_replace("\r\n", "\n", $sql);
 include INSTALL_ROOT . 'tpl' . DIRECTORY_SEPARATOR . $step . '.tpl.php';
 runquery($sql, $tablepre, $db);
 // ob
 for ($i = 1; $i <= 3; $i++) {
     $sql_district = file_get_contents(INSTALL_ROOT . 'data/keke_witkey_district_' . $i . '.sql');
     $sql_district = str_replace("\r\n", "\n", $sql_district);
     runquery($sql_district, $tablepre, $db);
     // ob
 }
 $password = md5($admin_password);
 $slt = randomkeys(6);
 // 随机码
 $sec_code = get_password($password, $slt);
 if ($data_type == 'b') {
     // 演示版本,更新数据
     $db->query("update `{$tablepre}witkey_member` set username = '******',password = '******',email = '{$admin_email}',rand_code='{$slt}' where uid = 1");
     $db->query("update `{$tablepre}witkey_space` set username = '******',password = '******',email = '{$admin_email}',sec_code='{$sec_code}',group_id = 1,status = 1 where uid = 1");
 } else {
     // 纯净版本、插入数据
     $db->query("replace INTO `{$tablepre}witkey_member`(`uid`,`username`,`password`,`email`,`rand_code`) VALUES ('1', '{$admin_account}','{$password}','{$admin_email}','{$slt}')");
     $db->query("replace INTO `{$tablepre}witkey_space` (`uid`,`username`,`password`,`email`,`sec_code`,`group_id`,`status`,`reg_time`) VALUES('1','{$admin_account}','{$password}','{$admin_email}','{$sec_code}','1','1','" . time() . "')");
     $db->query("replace INTO `{$tablepre}witkey_shop`(`uid`,`username`,`shop_name`,`shop_status`,`shop_type`) VALUES ('1', '{$admin_account}','{$admin_account}','1','1')");
 }
 $db->query("update `{$tablepre}witkey_basic_config` set v = '{$weburl}' where config_id=3");
 $file_obj = new keke_file_class();
 $file_obj->delete_files($data_cache_path);
示例#11
0
        if (GetNum($info)) {
            include_once INC_PATH . "/member.class.php";
            $m = new memberclass();
            if ($m->moneyedit($uname, $money, "后台转账充值")) {
                showmsg("充值成功!", PHP_SELF);
                //出错!
                exit("<script language='javascript'>alert('编辑成功');parent.parent.\$.fn.colorbox.close();</script>");
            } else {
                $Table->del($info);
                showmsg("充值失败!", "-1");
                //出错!
            }
        } else {
            showmsg("充值失败!", "-1");
            //出错!
            exit("<script language='javascript'>alert('编辑失败');parent.location.reload();</script>");
        }
    } else {
        $evalue = $Table->getone($uid);
        //充值编号
        $autokeys = randomkeys(3, "123");
        //随机5位数字
        $timestr = date('YmdHis');
        $sn = $timestr . $autokeys;
        //print_r($evalue);
        include "tpl/userrecharge.htm";
    }
} else {
    showmsg("未知请求", "-1");
    //出错!
}
示例#12
0
             $doc->ofaddr1 = $ofaddr1;
             $doc->ofaddr2 = $ofaddr2;
             $doc->ofcity = $ofcity;
             $doc->ofzip = $ofzip;
             if (!empty($ofstate)) {
                 $doc->ofstate = $ofstate;
             }
             $doc->homephone = $homephone;
             $doc->cellphone = $cellphone;
             $doc->officephone = $officephone;
             $doc->officeext = $officeext;
             if (!empty($spec)) {
                 $doc->spec = $spec;
             }
             $doc->email = $email;
             $newp = randomkeys(rand(6, 12));
             $doc->password = sha1($newp);
             $doc->save_res();
             $saved = true;
             if (!isset($nodb)) {
                 $nodb = db_notes();
                 $sql = "insert into gestapo (phid,opid,action) values ({$doc->ph_id},{$UUID},'RESNEW EDIT')";
                 $result = $nodb->query($sql);
             }
             $redir = "showdocpc.php?id={$docid}&lid=0";
         }
     }
     if (!isset($resdb)) {
         $resdb = db_career();
     }
 } catch (Exception $e) {
示例#13
0
                                             <a href='$_SERVER[SCRIPT_NAME]?course=$course_code'>$langBack</a></div><br>";
             draw($tool_content, $menuTypeID, null, $head_content);
             exit;
         } else {
             $tmpfile = $_FILES['userFile']['tmp_name'];
         }
     }
     validateUploadedFile($file_name, $menuTypeID);
     // convert php file in phps to protect the platform against malicious codes
     $file_name = php2phps($file_name);                    
     $file_name = str_replace(" ", "%20", $file_name);
     $file_name = str_replace("%20", "", $file_name);
     $file_name = str_replace("\'", "", $file_name);
     $uploaded = true;
 if ($uploaded) {
     $safe_filename = sprintf('%x', time()) . randomkeys(16) . "." . get_file_extension($file_name);
     if (isset($cloudfile)) {
         $iscopy = ($cloudfile->storeToLocalFile("$updir/$safe_filename") == CloudDriveResponse::OK);                    
     } else {                    
         $iscopy = copy("$tmpfile", "$updir/$safe_filename");
     }
     if (!$iscopy) {
         $tool_content .= "<div class='alert alert-success'>$langFileNot<br>
                                     <a href='$_SERVER[SCRIPT_NAME]?course=$course_code'>$langBack</a></div>";
         draw($tool_content, $menuTypeID, null, $head_content);
         exit;
     }
     
     $path = '/' . $safe_filename;
     $url = $file_name;
     $id = Database::get()->query('INSERT INTO video
示例#14
0
*------------------------------------------------------------------------*/
defined('_JEXEC') or die('Restricted access');
if (!function_exists('randomkeys')) {
    function randomkeys($length)
    {
        $pattern = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
        $key = '';
        for ($i = 0; $i < $length; $i++) {
            $key .= $pattern[rand(0, strlen($pattern) - 1)];
        }
        return $key;
    }
}
$rid = $params->get('unique_id');
if ($rid == '') {
    $rid = randomkeys(16);
}
$style = "\n    #ot_{$rid} .tab_selector {\n        margin: 0;\n        padding: 0;\n        list-style-type: none;\n    }\n    \n    #ot_{$rid} .tab_selector li {\n        display: block;\n        float: left;\n        margin: 0;\n        padding: 0;\n        cursor: pointer;\n    }\n    \n    #ot_{$rid} .tab_selector li span {\n        padding: 2px 6px;\n        text-align: center;\n        font-size: 14px;\n        font-weight: bold;\n        line-height: 24px;\n    }\n    \n    #ot_{$rid} .ot-title {\n        margin: 0 0 5px;\n        line-height: 22px;\n    }\n    \n    /* for prevent default joomla template css */\n    #ot_{$rid} .tab_panel ul.menu {\n        list-style-type: none;\n        padding: 0;\n    }\n    #ot_{$rid} .tab_panel ul.menu a {\n        background-position: 5px 50%;\n    }";
$doc->addStyleDeclaration($style);
$doc->addStyleSheet(JURI::root() . 'modules/mod_otminitabs/css/mod_otminitabs_default.css');
?>
<div class="ot-wrapper" id="ot_<?php 
echo $rid;
?>
">
    <div class="tab_selector_wrapper">
        <ul class="tab_selector">
            <?php 
// tab title
foreach ($list_of_tabs as $tab) {
    echo '<li class="tab"><span>' . $tab[1] . '</span></li>';
示例#15
0
 public function reply($data)
 {
     // $appID = 'wxeed8f73343e03675';
     // $appsecret = '124bc1b116d4e895654f4b97a19766f2';
     $appID = 'wxfd3e0d3a3ecad9d9';
     $appsecret = '4f238b819708f75ce8ec79fad5232a4c';
     if ('text' == $data['MsgType']) {
         $info = explode(" ", $data['Content']);
         switch ($info[0]) {
             case '0':
                 $reply = array("发弹幕", 'text');
                 break;
             case '1':
                 $reply = array("创建房间", 'text');
                 break;
             case '弹幕':
                 $Wx = M('Wx')->where(array('openid' => $data['FromUserName']))->find();
                 if ($Wx == null or $Wx == false) {
                     $reply = array("微信号未登记", 'text');
                 } else {
                     $this->sock($info[1], $Wx['nickname'], $Wx['roomid']);
                     $reply = array('弹幕发送成功', 'text');
                 }
                 // $content = date("Y-m-d H:i:s",time())."\nopenid:".$user_info['openid']."\nnickname:".$user_info['nickname'];
                 break;
             case '登记':
                 $Wx = M('Wx')->where(array('openid' => $data['FromUserName']))->find();
                 if ($Wx != null && $Wx != false) {
                     $reply = array("微信号已登记", 'text');
                     break;
                 }
                 $token_access_url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" . $appID . "&secret=" . $appsecret;
                 $access_token_json = file_get_contents($token_access_url);
                 $access_token = json_decode($access_token_json, true);
                 $user_info_url = "https://api.weixin.qq.com/cgi-bin/user/info?access_token=" . $access_token['access_token'] . "&openid=" . $data['FromUserName'] . "&lang=zh_CN";
                 $user_info_json = file_get_contents($user_info_url);
                 $user_info = json_decode($user_info_json, true);
                 $new_wx = M("Wx");
                 $new_data['openid'] = $user_info['openid'];
                 $new_data['nickname'] = $user_info['nickname'];
                 $new_data['sex'] = $user_info['sex'];
                 if (false === $new_wx->create($new_data)) {
                     $reply = array("登记失败", 'text');
                 } else {
                     $id = $new_wx->add($new_data);
                     $reply = array("登记成功,登记id:" . $id, 'text');
                 }
                 break;
             case '注册':
                 if ($info[1] == null or $info[1] == false or $info[2] == null or $info[2] == false) {
                     $reply = array("注册格式:注册 用户名 密码", 'text');
                     break;
                 }
                 $Wx = M('Wx')->where(array('openid' => $data['FromUserName']))->find();
                 if ($Wx == null or $Wx == false) {
                     $reply = array("微信号未登记", 'text');
                     break;
                 }
                 $User2 = M('User')->where(array('wx_id' => $Wx['id']))->find();
                 if ($User2 != null && $User2 != false) {
                     $reply = array("微信号已注册\n" . "用户名:" . $User2['username'], 'text');
                     break;
                 }
                 $User = M('User')->where(array('username' => $info[1]))->find();
                 if ($User != null && $User != false) {
                     $reply = array("用户名已使用", 'text');
                     break;
                 }
                 $data['username'] = $info[1];
                 $data['loginname'] = $Wx['nickname'];
                 $data['salt'] = randomkeys(6);
                 $data['wx_id'] = $Wx['id'];
                 $data['password'] = md5($data['salt'] . $info[2]);
                 if (false === M('User')->create($data)) {
                     $reply = array("用户创建失败", 'text');
                 } else {
                     $id = M('User')->add($data);
                     $reply = array("用户创建成功", 'text');
                 }
                 break;
             case '绑定':
                 $reply = $this->bind($data, $info);
                 break;
             case '格式':
                 $reply = array("绑定格式:绑定 账号 密码\n" . "弹幕格式:弹幕 信息\n" . "注册格式:注册 用户名 密码", 'text');
                 break;
             case '位置':
                 $reply = array("位置", 'text');
                 break;
             case '颜色':
                 $reply = array("颜色", 'text');
                 break;
             case '帮助':
                 $help = "使用步骤\n" . "->第一次使用需要登记账号(发送登记)\n" . "->绑定房间(扫码或发送绑定信息)\n" . "->发弹幕\n" . "->注册用户可在官网使用更多功能\n" . "发送格式查看基本格式";
                 $reply = array($help, 'text');
                 break;
             default:
                 $reply = array($info[0], 'text');
                 break;
         }
     } elseif ('event' == $data['MsgType'] && 'subscribe' == $data['Event']) {
         $reply = array("欢迎您关注公众号!\n" . "发送帮助查看使用说明", 'text');
     } elseif ('event' == $data['MsgType'] && 'SCAN' == $data['Event']) {
         $reply = $this->bind_scan($data);
     } elseif ('event' == $data['MsgType'] && 'CLICK' == $data['Event']) {
         switch ($data['EventKey']) {
             case '弹幕':
                 $reply = array('弹幕格式:弹幕 信息', 'text');
                 break;
             case '登记':
                 $Wx = M('Wx')->where(array('openid' => $data['FromUserName']))->find();
                 if ($Wx != null && $Wx != false) {
                     $reply = array("微信号已登记", 'text');
                     break;
                 }
                 $token_access_url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" . $appID . "&secret=" . $appsecret;
                 $access_token_json = file_get_contents($token_access_url);
                 $access_token = json_decode($access_token_json, true);
                 $user_info_url = "https://api.weixin.qq.com/cgi-bin/user/info?access_token=" . $access_token['access_token'] . "&openid=" . $data['FromUserName'] . "&lang=zh_CN";
                 $user_info_json = file_get_contents($user_info_url);
                 $user_info = json_decode($user_info_json, true);
                 $new_wx = M("Wx");
                 $new_data['openid'] = $user_info['openid'];
                 $new_data['nickname'] = $user_info['nickname'];
                 $new_data['sex'] = $user_info['sex'];
                 if (false === $new_wx->create($new_data)) {
                     $reply = array("登记失败", 'text');
                 } else {
                     $id = $new_wx->add($new_data);
                     $reply = array("登记成功,登记id:" . $id, 'text');
                 }
                 break;
             case '注册':
                 $reply = array("注册格式:注册 用户名 密码", 'text');
                 break;
             case '绑定':
                 $reply = array("绑定格式:绑定 账号 密码", 'text');
                 break;
             case '位置':
                 $reply = array("位置", 'text');
                 break;
             case '颜色':
                 $reply = array("颜色", 'text');
                 break;
             case '帮助':
                 $help = "使用步骤\n" . "->第一次使用需要登记账号(发送登记)\n" . "->绑定房间(扫码或发送绑定信息)\n" . "->发弹幕\n" . "->注册用户可在官网使用更多功能\n" . "发送格式查看基本格式";
                 $reply = array($help, 'text');
                 break;
             default:
                 break;
         }
     } else {
         exit;
     }
     return $reply;
 }
示例#16
0
$appkey2 = "62PNF9abhLg4DsbYkrgrlNrZB8xaDK7MKWoWC6WibB96n25pKJD4pMvsksxZlTn5rE0VIjIyMxdu3a3TUEt72fZjpwG7WFeZcnT5VTXzzwWib4zd10r038ztHXFMlyn3";
//替换appkey
$partner2 = "1220019101";
//替换partnerid
$partnerKey2 = "b01d961b83bd549b5593f0f0a41b18a2";
//替换partnerkey
$notify_url2 = "http://www.jinguishop.com/auth/wxpaynotify.php";
$input_charset2 = "UTF-8";
//传递下列参数
$body2 = !empty($_GET['orderName']) ? $_GET['orderName'] : '';
$out_trade_no2 = !empty($_GET['orderid']) ? $_GET['orderid'] : '';
//订单号,商户需要保证该字段对于本商户的唯一性
$total_fee2 = !empty($_GET['price']) ? $_GET['price'] : '';
$packageString = getPackage($body2, $input_charset2, $notify_url2, $out_trade_no2, $partner2, $spbill_create_ip2, $total_fee2, $partnerKey2);
$time_stamp = time();
$nonce_str = randomkeys();
$sign = getSign($appid2, $appkey2, $nonce_str, $packageString, $time_stamp);
function getPackage($body2, $input_charset2, $notify_url2, $out_trade_no2, $partner2, $spbill_create_ip2, $total_fee2, $partnerKey2)
{
    $banktype = "WX";
    $fee_type = "1";
    //费用类型,这里1为默认的人民币
    $body = $body2;
    $input_charset = $input_charset2;
    $notify_url = $notify_url2;
    $out_trade_no = $out_trade_no2;
    $partner = $partner2;
    $spbill_create_ip = $spbill_create_ip2;
    $total_fee = $total_fee2;
    $partnerKey = $partnerKey2;
    $signString = "bank_type=" . $banktype . "&body=" . $body . "&fee_type=" . $fee_type . "&input_charset=" . $input_charset . "&notify_url=" . $notify_url . "&out_trade_no=" . $out_trade_no . "&partner=" . $partner . "&spbill_create_ip=" . $spbill_create_ip . "&total_fee=" . $total_fee . "&key=" . $partnerKey;
示例#17
0
 function reset_password($conn)
 {
     // this is for any user or operator, even not logged in.
     global $UUID;
     global $REMOTE_ADDR;
     if (!$conn) {
         throw new Exception('Valid connection required', 1);
     }
     $newp = randomkeys(rand(6, 12));
     $this->uobj->password = sha1($newp);
     $result = $conn->query("update {$this->table} set password='******',editedby={$UUID},editeddt=now() where uid = " . $this->uid);
     if (!$result) {
         throw new Exception('Can not reset password', __LINE__);
     }
     // now email the password
     $from = "From: help@physiciancareer.com\r\nX-Requested-by: {$UUID}/{$REMOTE_ADDR}\r\n";
     $msg = "Dear " . $this->uobj->firstname . ":\r\n\r\nThe password for your PhysicianCareer.com account has been reset. Please note your\r\nnew password is: {$newp} (case-sensitive). We recommend that you log in now using your \r\nnew password and change it to something you will remember and use going forward.\r\n\r\nClick here to do that now: http://physiciancareer.com/employers/client-login/\r\n\r\nIf you believe you have received this email in error or that an unauthorized person has \r\naccessed your account, please log in now using your new password and then change it \r\nto something secure.\r\n\r\nPlease feel free to contact us by replying to this message if you have any questions or \r\nconcerns about our website.\r\n\r\nThank you,\r\nPhysicianCareer.com Support\r\n";
     if (!mail(stripslashes($this->uobj->email), 'PhysicianCareer.com password reset request', $msg, $from)) {
         throw new Exception('Can not send email', 17);
     }
 }
 /**
  * 随机生成编号
  *
  * @return string
  */
 function makesn()
 {
     $autokeys = randomkeys(3, '123');
     //随机5位数字
     $timestr = date('YmdHis');
     $sn = $timestr . $autokeys;
     return $sn;
 }
<?php

/* 
* This test just echo SQL INSERTS for the tags table.
* I used it to test the tag cloud.
*/
function randomkeys($length)
{
    $pattern = "abcdefghijklmnopqrstuvwxyz";
    for ($i = 0; $i < $length; $i++) {
        $key .= $pattern[rand(0, 35)];
    }
    return $key;
}
for ($i = 0; $i <= 110; $i++) {
    /*echo 'TAG: ',*/
    $tag = randomkeys(8);
    /*echo '<br /> WIE OFT: ', */
    $counter = rand(1, 200);
    echo "INSERT INTO `tags` (`id`, `tag`, `counter` ) VALUES (NULL, '", $tag, "','", $counter, "' ); <br />";
}
?>