/** * * @return boolean */ public function startDownload() { $currentFiles = @file_get_contents($this->_lockFile); if (!$currentFiles) { $currentFiles = 1; } else { $currentFiles++; } if (@file_put_contents($this->_lockFile, $currentFiles)) { chmod($this->_lockFile, 0777); if ($currentFiles <= $this->_downloadCountPerMin) { $rev = true; } else { Pft_Log::addLog('Max download request [' . $currentFiles . ']!', Pft_Log::LEVEL_INFO); $rev = false; } } else { Pft_Log::addLog('Write lock file [' . $this->_lockFile . '] failed!', Pft_Log::LEVEL_ERROR); $rev = false; } return $rev; }
/** * 查询并返回结果集连接 * @param String $sql * @return resource */ private function _query($sql, $logSql = true) { Pft_Debug::addInfoToDefault('', "Pre execute sql"); //self::autoSelectDbBySql( $sql ); //return mysql_query( $sql, $this->_conn ); //如果return $rs 会慢 数十毫秒 @todo 再次验证 if ($this->_mutile_read_db) { //if ( is_object($this->_connection) && $this->_connection->getAutoCommit() ){ if ('Pft_Dbx' == get_class($this)) { self::superUpdateConnectionX(); } else { self::superUpdateConnection(); // 强制更新数据库连接,使只需只读的操作连接到“只读数据库服务器” } //} } $rev = mysql_query($sql, $this->_conn); Pft_Debug::addInfoToDefault(__FILE__, "Executed sql [<div> {$sql} </div>]"); if (mysql_errno()) { //如果使用System级别会重复记录db日志,可能死循环。 if ($this->_log) { Pft_Log::addLog('Execute sql [' . $sql . '] fail, error [' . mysql_errno() . ':' . mysql_error() . ']', Pft_Log::LEVEL_DEBUG); } throw new Pft_Db_Exception(mysql_errno() . ": " . mysql_error() . "\n"); } if ($logSql) { if ($this->_log) { Pft_Log::logDbOprate($sql); } } return $rev; }
/** * 回到之前所在组 * 如果组列表只有一个元素,则保持在该组 * @param int $backStep 回退步数,如果为0,退到初始状态 */ public function backToPrevGroup($backStep = 1) { if ($backStep > 0) { for (; $backStep > 0; $backStep--) { $prevGroupId = array_pop($this->_groupIdStack); if ($prevGroupId) { $this->_groupId = $prevGroupId; Pft_Log::addLog('Back to group [' . $prevGroupId . ']'); } } } else { //如果 步数 <= 0 回退到最起点 $prevGroupId = array_pop($this->_groupIdStack); while ($prevGroupId) { if ($prevGroupId) { $this->_groupId = $prevGroupId; } $prevGroupId = array_pop($this->_groupIdStack); } } }
/** * 循环进行 do 的处理 * */ function dispatch() { /** * 因为Tq是用Post传递参数过来的,所以不能用$_GET */ $do = empty($_REQUEST["do"]) ? "index" : trim($_REQUEST["do"]); /** * 这是为了兼容 do=xxx&action=yyy 的形式 */ $a = empty($_REQUEST["action"]) ? "" : trim($_REQUEST["action"]); if ($a) { $do .= "_" . $a; } /** * 获取view的type */ $v = empty($_REQUEST["v"]) ? "Html" : trim($_REQUEST["v"]); //TQ任务LINK //http://testtpm.transn.net/index.php?do=if_renwu_detail&sj_id=35c55571-80bb-c18b-6078-465a87c329bd&Username=dGVzdC1wcjE=&Password=MjAyY2I5NjJhYzU5MDc1Yjk2NGIwNzE1MmQyMzRiNzA=&pwdway=md5 /** * 获取用户名和密码进行快速登录 */ if (r('pwdway')) { if (!Pft_Session::getSession()->getUserId()) { //这个判断是为了不让TQ登录后,访问此链接时,冲掉session中[是否TQ]那个设置 $accounts = iconv('GB2312', 'UTF-8', base64_decode(str_replace(' ', '+', r("Username")))); $pwd = iconv('GB2312', 'UTF-8', base64_decode(str_replace(' ', '+', r("Password")))); } } else { if (r('login') == 'ok') { /** * 这是为了兼容TQ的那个点击“查收我的订单”,导致Web重登录的问题。 * @author terry * @version 0.1.0 * Thu Sep 06 16:44:53 CST 2007 */ $accounts = ''; $pwd = ''; } else { $accounts = r("user_name"); $pwd = r("user_pw"); } } if ($accounts && $pwd) { $login_rev = 0; $user = TpmYonghuPeer::checkUserLogin($accounts, $pwd, $login_rev); if ($login_rev == TpmYonghuPeer::USER_LOGIN_OK) { // 用户登陆成功后如果密码安全强度不够,跳转到修改密码页提示用户设置安全的密码 $pswdChecker = new Tpm_Passwordchecker($pwd); $cfgLevel = Pft_Config::getCfg('PSWD_CHECK_LEVEL'); if ($cfgLevel == '') { $cfgLevel = '0'; } if ($pswdChecker->getSecurityLevel() < $cfgLevel) { $_SESSION['LOW_PASSWORD'] = true; // header('Location:?do=ps_yonghu_changepwd&nosecurity=true'); // exit; } Pft_Log::addLog('Login ok, accounts[' . $accounts . ']', Pft_Log::LEVEL_INFO, 'LOGIN_WEB_DIRECT_LOGIN'); } } //如密码强度不够, 强制修改密码 $superDoList = array('ps_yonghu_changepwd', 'login_logout', ''); // 数组中的Action不在强制之列 if (@$_SESSION['LOW_PASSWORD'] && !in_array($do, $superDoList)) { header('Location:?do=ps_yonghu_changepwd&nosecurity=true'); exit; } $i = $this->_maxToDo; while ($do != "" && $i-- > 0) { $do = $this->processDo($do, $v); } //如果是渠道代理商客户,传神客户,客户则记录日志 2007-7-9 john if (Pft_Session::getSession()->getRoleShortname() == "QDKH" || Pft_Session::getSession()->getRoleShortname() == "CSKH" || Pft_Session::getSession()->getRoleShortname() == "CR") { $accessLoger = new Pft_Log_Db('tpm_rizhi_fangwen'); $accessLoger->log("", 0, $_REQUEST["do"]); } }
header( "HTTP/1.1 403.9 To Many Users" ); exit(); //die( '达到了每分钟请求上限['.DOWNLOAD_COUNT_PER_MIN.'],请稍候再下载.' ); } */ $thePathFileName = $_REQUEST['path_file_name']; /** * 为了安全,去掉不规范路径 * @author terry * @version 0.1.0 * Sat Sep 29 12:30:07 CST 2007 */ $thePathFileName = str_replace('../', '', $thePathFileName); //$theFileName = $_REQUEST['file_name']; $theFileName = basenameEx($thePathFileName); Pft_Log::addLog('Start download [' . $thePathFileName . ' as [' . $theFileName . ']. ', Pft_Log::LEVEL_INFO); //setlocale(LC_ALL,"zh_CN"); //print "<pre>";var_dump( $thePathFileName );print "</pre>"; //print "<pre>";var_dump( $theFileName );print "</pre>"; //exit; output_file($thePathFileName, $theFileName); function basenameEx($filename) { $pos = strrpos($filename, '/'); if ($pos !== false) { return substr($filename, $pos + 1); } else { return $filename; } } function output_file($file, $name)
/** * dispatch mobile * 如果分发成功,则返回 true * 否则返回 false * @param string $source 去掉特服号的source * @param string $_old_source 最原始的source * @return boolean */ public static function dispatchMobile($mobile, $msg, $source, $_old_source) { self::_init(); $arrSiteList = array(10 => 'testtpm.transn.net', 20 => 'demotpm.transn.net', 40 => 'tpm.transn.net', 50 => 'uetpm.transn.net', 60 => 'vtpm.transn.net', 70 => 'devtpm.transn.net'); $smsInterface = '/message/sms/get.php'; $siteCode = substr($source, 1, 2); if ($siteCode == self::$_site_code) { //如果刚好是本站地址 return false; //则不分发,return false } if (key_exists($siteCode, $arrSiteList)) { //如果存在于站点列表中 Pft_Log::addLog("Recieve sms: mobile[{$mobile}],msg[{$msg}],source[{$source}]. And dispatch to [{$arrSiteList[$siteCode]}]( sitecode[{$siteCode}] ).", Pft_Log::LEVEL_INFO, 'MSG_SMS'); $url = "http://" . $arrSiteList[$siteCode] . $smsInterface . "?mobile={$mobile}&msg={$msg}&source={$_old_source}"; file_get_contents($url); //print"<pre>Terry :";var_dump( file_get_contents($url) );print"</pre>"; //exit(); return true; //分发成功,不管结果 } else { return false; //否则依然在本站内处理 } }
require_once $config_path . "/loader.php"; //======================================== /** * 环境准备完毕 程序开始 */ Pft_Debug::addInfoToDefault('Pre dispatch.'); try { /** * 分发 */ $dispatch = new Pft_Dispatcher(); $dispatch->dispatch(); } catch (Exception $e) { $code = $e->getCode(); $errorInfo = $e->getMessage() . " at (" . $e->getFile() . " | Line:" . $e->getLine() . ") Code [" . $code . "]"; Pft_Log::addLog('Cache exception : ' . $errorInfo); if (defined('DEBUG') && DEBUG) { echo "<pre>" . $errorInfo . "</pre>"; echo "<pre>" . debug_print_backtrace() . "</pre>"; //todo: 此处转入debug 错误代码处理 switch ($code) { } } else { $_REQUEST['msg'] = $e->getMessage(); $_REQUEST['code'] = $code; include 'error.php'; //header( "Location:?do=error&code=$code&msg=".urlencode($e->getMessage()) ); //header( "Location:?do=error&code=$code&msg=".$e->getMessage() ); } } Pft_Debug::addInfoToDefault('After dispatch.');