public static function getDbNo($identifier) { $sign = $identifier; is_numeric($identifier) || ($sign = Sign::sign64($identifier)); $tag = intval(Sign::mod($sign, AppConf::$dbConf['db_num'] * AppConf::$dbConf['tb_num']) / AppConf::$dbConf['tb_num']); return $tag; }
public function testEncode() { $signature = Sign::encode("", "KEY"); $this->assertEquals("405b4e6c5e0370034caa8d9261be1819", $signature); $signature = Sign::encode("", "a"); $this->assertEquals("025b69987847314c3445f5cdb5c23830", $signature); }
public function signAction() { $form = new SignForm(); //password try and catch $form->get('submit')->setValue('Add'); $request = $this->getRequest(); if ($request->isPost()) { $user = new Sign(); //WTF?? $form->setInputFilter($user->getInputFilter()); $form->setData($request->getPost()); if ($form->isValid()) { $album->exchangeArray($form->getData()); $this->getAlbumTable()->saveUser($user); // Redirect to profile page return $this->redirect()->toRoute('profile'); } } return array('form' => $form); }
private function genRequestId() { if (isset($_SERVER['HTTP_CLIENTAPPID'])) { return intval($_SERVER['HTTP_CLIENTAPPID']); } $reqip = App::getClientIp(); $time = gettimeofday(); $time = $time['sec'] * 100 + $time['usec']; $ip = ip2long($reqip); $id = ($time ^ $ip) & 0xffffffff; $id = Sign::sign64($id . '_' . rand(1, 800000000)); return $id; }
//unicode private use area $fswcm = ''; //signwriting cartesian markup $fswpm = ''; //signwriting polar markup $fbswml = ''; //binary signwriting markup foreach ($units as $ubsw) { if (isPunc($ubsw)) { $fbsw .= $ubsw . ' '; $fupua .= bsw2utf($ubsw) . ' '; $fswcm .= bsw2utf($ubsw, 1); $fswpm .= bsw2utf($ubsw, 1); $fbswml .= '<punc>' . bsw2key($ubsw) . '</punc><br>'; } else { $unit = new Sign($ubsw); $ubsw = moveBSW($unit->getBSW(), $unit->getCenterX(), $unit->getCenterY()); $fbsw .= $ubsw . ' '; $fupua .= bsw2utf($ubsw) . ' '; $first = substr($ubsw, 0, 3); $cluster = bsw2cluster($ubsw); $seq = bsw2seq($ubsw); $chars = str_split($cluster, 3); $fswcm .= char2token($first); $fswpm .= char2token($first); $fbswml .= '<sign lane="' . char2lane($first) . '"><br>'; for ($i = 0; $i < count($chars); $i++) { //first 3 are symbol $sbsw = $chars[$i]; $i++; $sbsw .= $chars[$i];
//请求类型(1-支付) $transid = $paylog->getVar('payid'); //订单编号[商户网站] $objid = $jieqiPayset[JIEQI_PAY_TYPE]['objid']; //交易商品编码 $money = $amount; //交易金额 $retweb = $jieqiPayset[JIEQI_PAY_TYPE]['payreturn']; //商家接受支付结果的URL $param = "op=" . $op . "&unitid=" . $unitid . "&transid=" . $transid . "&objid=" . $objid . "&money=" . $money . "&retweb=" . $retweb; // Using My Private Key File (here 100001 is a Test ID) //商户证书(私钥)地址(此示例为测试密钥,正式密钥需要到自服务平台下载) $filename = JIEQI_ROOT_PATH . '/configs/pay/' . $jieqiPayset[JIEQI_PAY_TYPE]['prikeyfile']; $xmlKey = new KeyFile($filename); $xmlKey->getCRTPrivateKey($modulus, $p, $q, $dp, $dq, $invq); $sign = new Sign(); $sign->setCRTPrivateKeyFromXML($modulus, $p, $q, $dp, $dq, $invq); $signData = $sign->getSign($param); //将数据POST到支付网关地址(正式测试时地址改为http://pay.118pay.cn/PhonePay.aspx?) $reqURL = $jieqiPayset[JIEQI_PAY_TYPE]['payurl'] . "?" . $param . "&sign=" . $signData; // let client redirect to 118PAY Gateway with params & sign //echo $reqURL;exit; header("Location: {$reqURL}"); exit; /* include_once(JIEQI_ROOT_PATH.'/header.php'); include_once(JIEQI_ROOT_PATH.'/lib/template/template.php'); $jieqiTpl =& JieqiTpl::getInstance(); $jieqiTpl->assign('url_pay', $jieqiPayset[JIEQI_PAY_TYPE]['payurl']); $jieqiTpl->assign('buyname', $_SESSION['jieqiUserName']); $jieqiTpl->assign('egold', $_REQUEST['egold']);
/** * @param $mode * @param $action * @return string */ private static function sign_request($mode, $action) { $url = $action; if (strpos($url, '?') !== false) { $url .= "&apiKey=" . \Itwapp::$apiKey; } else { $url .= "?apiKey=" . \Itwapp::$apiKey; } $milliseconds = round(microtime(true) * 1000); $url .= "×tamp=" . strval($milliseconds); $signature = Sign::encode($mode . ":" . $url, Itwapp::$secretKey); return $url . "&signature=" . $signature; }
//3-----------判断返回信息,如果支付成功,并且支付结果可信,则做进一步的处理---------------------------- if ($unitid != $myunitid) { jieqi_printfail($jieqiLang['pay']['customer_id_error']); } if ($retcode == 12 || $paycode == 1 && $retcode == 0) { $query_string = $_SERVER['QUERY_STRING']; $pos = strpos($query_string, "&sign="); if ($pos == false) { jieqi_printfail($jieqiLang['pay']['return_checkcode_error']); } else { $param = substr($query_string, 0, $pos); } $filename = JIEQI_ROOT_PATH . '/configs/pay/' . $jieqiPayset[JIEQI_PAY_TYPE]['pubkeyfile']; $xmlKey = new KeyFile($filename); $xmlKey->getPublicKey($modulus, $exp); $sign = new Sign(); $sign->setPublicKeyFromXML($exp, $modulus); if (!$sign->VerifySign($param, $signData)) { jieqi_printfail($jieqiLang['pay']['return_checkcode_error']); } else { include_once $jieqiModules['pay']['path'] . '/class/paylog.php'; $paylog_handler = JieqiPaylogHandler::getInstance('JieqiPaylogHandler'); $orderid = intval($transid); $paylog = $paylog_handler->get($orderid); if (is_object($paylog)) { $buyname = $paylog->getVar('buyname'); $buyid = $paylog->getVar('buyid'); $payflag = $paylog->getVar('payflag'); $egold = $paylog->getVar('egold'); if ($payflag == 0) { include_once JIEQI_ROOT_PATH . '/class/users.php';
public static function checkRetriPassParam($db, $euid, $code, $timestamp, $jump = 'reject') { $now = time(); if ($timestamp + AppConf::$emailRetriPassExpire < $now) { if (is_string($jump)) { throw new Exception("param {$jump} time expired [ now: {$now}, timestamp: " . "{$timestamp}, expire time: " . AppConf::$emailRetriPassExpire . ' ].', 1); } throw new Exception("param time expired [ now: {$now}, timestamp: " . "{$timestamp}, expire time: " . AppConf::$emailRetriPassExpire . ' ].'); } $uid = Uc_Com_Utils::decodeUserId($euid); $sql = "SELECT uid, account, password, email, phone, qq, regist_time FROM uc_user_info WHERE uid = {$uid}"; $dbRet = $db->query($sql, is_string($jump) ? 'error' : true); if (count($dbRet) <= 0) { if (is_string($jump)) { throw new Exception("nouser {$jump} such user does not exists [ uid: " . $uid . ' ].', 1); } throw new Exception('nouser such user does not exists [ uid: ' . $uid . ' ].'); } $uInfo = $dbRet[0]; $orgStr = AppConf::$emailVeriPrefix . '_' . $euid . '_' . $uInfo['account'] . '_' . $uInfo['password'] . '_' . $uInfo['email'] . '_' . $uInfo['phone'] . '_' . $uInfo['qq'] . '_' . date('Y-m-d H:i:s', $uInfo['regist_time']) . '_' . date('Y-m-d H:i:s', $timestamp); $str = md5(base64_encode($orgStr)); $dbCode = Sign::sign64($str); if ($dbCode != $code) { if (is_string($jump)) { throw new Exception("param {$jump} invalid code [ uid: {$uid}, code: {$code}, db code: {$dbCode}, str: {$orgStr} ]", 1); } throw new Exception("param invalid code [ uid: {$uid}, code: {$code}, db code: {$dbCode}, str: {$orgStr} ]"); } KC_LOG_DEBUG("check retrieve password params succ [ euid: {$euid}, uid: {$uid}, code: {$code}, str: {$orgStr} ]."); }
public function __construct($bsw, $size = 1, $height = 1919, $spacing = 10, $offset = 50) { //set variables// $this->bsw = $bsw; $this->size = $size; $this->height = $height / $size; $this->spacing = $spacing; $this->offset = $offset; $this->units = bsw2unit($bsw); //init variables $curH = $this->padding; $prev = ''; $col = ''; $posX = array(); $posY = array(); //punc vs sign, spacing and lanes $prev = ''; $cnt = count($this->units); for ($i = 0; $i < $cnt; $i++) { $unitbsw = $this->units[$i]; $chars = str_split($unitbsw, 3); $first = $chars[0]; //unit type for spacing test later if (isPunc($first)) { $cur = "P"; //punctuation $lane = 0; } else { $cur = "S"; //sign $lane = char2lane($first); } //adjust padding based on punc/sign order switch ($prev . $cur) { case 'SS': //sign sign $padding = $this->spacing * 2; break; case 'SP': //sign punctuation //sign punctuation case 'PP': //punctuation punctuation $padding = $this->spacing; break; case 'PS': //punctuation sign $padding = $this->spacing * 3; break; default: $padding = 0; } $prev = $cur; if ($cur == "P") { $unit = new Symbol($unitbsw); } else { $unit = new Sign($first . bsw2cluster($unitbsw)); $unitbsw = $unit->getBSW(); } if ($curH + $padding + $unit->getHeight() < $this->height) { //go ahead and add $col .= $unitbsw; //this is the value to center $posX[] = $unit->getCenterX() - $this->offset * $lane; $posY[] = $curH + $padding; $curH += $padding + $unit->getHeight(); } else { //finalize column list $this->cols[] = $col; $this->posX[] = $posX; $this->posY[] = $posY; $col = ''; $posX = array(); $posY = array(); $curH = $this->padding; $prev = ''; $i--; } } if ($col) { $this->cols[] = $col; $this->posX[] = $posX; $this->posY[] = $posY; } }