/** * 测试事务 */ public function txTest() { $d = D(); //开始事务 $d->begin(); try { $now = getCurrentTime(); //添加用户 $m = M("user"); $ud = array("mobile" => "1" . time(), "created" => $now); $id = $m->add($ud); //添加用户资料 $m = M("user_profile"); $profile = array("name" => "闵益飞" . $id, "user_id" => $id, "age" => 20, 'created' => $now, 'updated' => $now); $m->add($profile); //通过sql形式读取用户资料 $sql = "select a.mobile,b.name,b.age from user a,user_profile b where a.id=b.user_id"; $datas = $d->findSql($sql); //如果没问题事务提交 $d->commit(); var_dump($datas); } catch (Exception $e) { //如果报错 事务回滚 $d->rollBack(); var_dump($e); } }
function showScripttime() { global $scriptTimeStart; $scriptTimeEnd = getCurrentTime(); $scriptTimeDiv = intval(($scriptTimeEnd - $scriptTimeStart) * 1000) / 1000; return $scriptTimeDiv; }
/** * 敏感分析服务 * * @return void */ function searchEngine($data, $runtime = false) { $process_start_time = getCurrentTime(); $result = post(X::getConfigVar("searchEngine"), ["words" => cleanFormat($data['content']), 'if_spam' => $data['if_spam']]); $process_end_time = getCurrentTime(); if ($runtime) { $process_time = round($process_end_time - $process_start_time, 4); //运行时间 return [$result, $process_time]; } return $result; }
function BuildOCPSoap() { /* Select the right region for your CRM crmna:dynamics.com - North America crmemea:dynamics.com - Europe, the Middle East and Africa crmapac:dynamics.com - Asia Pacific */ $region = 'crmapac:dynamics.com'; $OCPRequest = '<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"> <s:Header> <a:Action s:mustUnderstand="1">http://schemas.xmlsoap.org/ws/2005/02/trust/RST/Issue</a:Action> <a:MessageID>urn:uuid:%s</a:MessageID> <a:ReplyTo> <a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address> </a:ReplyTo> <a:To s:mustUnderstand="1">%s</a:To> <o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> <u:Timestamp u:Id="_0"> <u:Created>%sZ</u:Created> <u:Expires>%sZ</u:Expires> </u:Timestamp> <o:UsernameToken u:Id="uuid-cdb639e6-f9b0-4c01-b454-0fe244de73af-1"> <o:Username>%s</o:Username> <o:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">%s</o:Password> </o:UsernameToken> </o:Security> </s:Header> <s:Body> <t:RequestSecurityToken xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust"> <wsp:AppliesTo xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"> <a:EndpointReference> <a:Address>' . $region . '</a:Address> </a:EndpointReference> </wsp:AppliesTo> <t:RequestType>http://schemas.xmlsoap.org/ws/2005/02/trust/Issue</t:RequestType> </t:RequestSecurityToken> </s:Body> </s:Envelope>'; $OCPRequest = sprintf($OCPRequest, gen_uuid(), 'https://login.microsoftonline.com/RST2.srf', getCurrentTime(), getNextDayTime(), $this->username, $this->password); return $OCPRequest; }
public function process() { try { $oTableOperate = new SingleTableOperation('cUser', "MYZL"); $data = $oTableOperate->getObject(array('userId' => $this->_args['userId'])); if (count($data)) { $this->_retValue = EC_RECORD_EXIST; $this->_retMsg = "user already exist!"; interface_log(ERROR, $this->_retValue, $this->_retMsg); return false; } //添加用户记录,设置相关的字段,这里可以根据自己的策略设置 $oTableOperate->addObject(array('userId' => $this->_args['userId'], 'password' => $this->_args['password'], 'email' => $this->_args['email'], 'money' => 100, 'bulletNum' => 5, 'xsft' => 5, 'hdcx' => 5, 'chxs' => 5, 'sszm' => 5, 'addTimeStamp' => getCurrentTime())); $this->_responseText = MYZL_HINT_ADDUSER_SUC; } catch (DB_Exception $e) { $errorNum = $oTableOperate->getErrorNum(); $this->_retMsg = $oTableOperate->getErrorInfo() . $e->getMessage(); $this->_retValue = genRetCode($errorNum); interface_log(ERROR, $this->_retValue, $this->_retMsg); return false; } return true; }
public function phpexcel() { require_once APP_SITE_PATH . '/plugins/phpexcel/PHPExcel.php'; $title = "MyfMvc"; $objPHPExcel = new PHPExcel(); $objPHPExcel->getProperties()->setCreator("myf")->setLastModifiedBy("minyifei.cn")->setTitle($title)->setSubject($title)->setDescription($title)->setKeywords($title)->setCategory($title); //设置excel的表头 $objPHPExcel->setActiveSheetIndex(0)->setCellValue('A1', '编号')->setCellValue('B1', '手机号')->setCellValue('C1', '姓名')->setCellValue('D1', '创建时间'); $objPHPExcel->getActiveSheet()->getPageSetup()->setRowsToRepeatAtTopByStartAndEnd(1, 1); $index = 2; for ($i = 1; $i <= 9; $i++) { $id = $i; $mobile = "1371760000" . $i; $name = "mvc" . $i; $time = getCurrentTime(); $objPHPExcel->getActiveSheet()->setCellValue('A' . $index, $id)->setCellValue('B' . $index, $mobile)->setCellValue('C' . $index, $name)->setCellValue('D' . $index, $time); $index++; } $objPHPExcel->getActiveSheet()->setTitle("客户统计"); $objPHPExcel->setActiveSheetIndex(0); header('Content-Type: application/vnd.ms-excel'); header('Content-Disposition: attachment;filename="' . $title . '.xls"'); header('Cache-Control: max-age=0'); header('Cache-Control: max-age=1'); header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified header('Cache-Control: cache, must-revalidate'); // HTTP/1.1 header('Pragma: public'); // HTTP/1.0 $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); $objWriter->save('php://output'); exit; }
function ProcessThread($threadid, $action, $params = array()) { $res = null; $newState = null; $forExactOperatorMode = false; $thread = Thread::getInstance()->GetThreadById($threadid); // without changing state switch ($action) { case 'visitor_message': $res = Thread::getInstance()->PostMessage($threadid, KIND_USER, $params['message'], $params['sendername']); MapperFactory::getMapper("Thread")->incrementVisitorMessageCount($threadid); case 'visitor_ping': $this->ping($thread, $params, 'lastpingvisitor', 'visitortyping'); $thread = Thread::getInstance()->GetThreadById($threadid); break; case 'operator_message': $res = Thread::getInstance()->PostMessage($threadid, KIND_AGENT, $params['message'], $params['sendername'], null, $params['operatorid']); case 'operator_ping': case 'operator_force_join': $this->ping($thread, $params, 'lastpingagent', 'agenttyping'); $thread = Thread::getInstance()->GetThreadById($threadid); break; } switch ($thread["state"]) { case STATE_INVITE: switch ($action) { case 'visitor_ping': case 'visitor_message': Thread::getInstance()->PostMessage($threadid, KIND_FOR_AGENT, Resources::Get('client.joined.thread', array(), $thread['locale'])); $newState = STATE_CHATTING; break; case "operator_close": $this->sendOperatorLeft($thread); $newState = STATE_CLOSED; break; case 'operator_ping': $session = VisitSession::getInstance()->GetVisitSessionById($thread['visitsessionid']); if (isset($session) && isset($session['updated']) && getCurrentTime() - $session['updated'] > VISITED_PAGE_TIMEOUT) { Thread::getInstance()->PostMessage($threadid, KIND_FOR_AGENT, Resources::Get('invite.window.closed', array(), $thread['locale'])); $newState = STATE_CLOSED; } break; case 'visitor_invite_close': Thread::getInstance()->PostMessage($threadid, KIND_FOR_AGENT, $params['message']); $newState = STATE_CLOSED; default: if ($this->isCreatedTimeout($thread, INVITE_ANIMATION_DURATION + 30)) { // TODO correct timeout $newState = STATE_CLOSED; } } break; case STATE_LOADING_FOR_EXACT_OPERATOR: $forExactOperatorMode = true; case STATE_LOADING: switch ($action) { case 'visitor_ping': case 'visitor_message': VisitSession::getInstance()->UpdateVisitSession($thread['visitsessionid'], array('waitmess' => 0)); Thread::getInstance()->PostMessage($threadid, KIND_INFO, Resources::Get('chat.wait', array(), $thread['locale'])); $newState = $forExactOperatorMode ? STATE_QUEUE_EXACT_OPERATOR : STATE_QUEUE; break; case "visitor_browser_unload": $newState = STATE_CLOSED; break; case 'operator_join': case 'operator_force_join': case 'operator_ping': case 'operator_message': $this->joinThreadAndSendMessage($thread, $params['operatorid']); $newState = STATE_CHATTING; break; default: if ($this->isCreatedTimeout($thread, TIMEOUT_VISITOR_PING)) { $this->sendVisitorLeft($thread); $newState = STATE_CLOSED; } } break; case STATE_QUEUE_EXACT_OPERATOR: if ($this->isOperatorTimeout($thread, TIMEOUT_EXACT_OPERATOR) || $this->isCreatedTimeout($thread, TIMEOUT_EXACT_OPERATOR)) { $newState = STATE_QUEUE; break; } case STATE_REDIRECTED: if ($this->isOperatorTimeout($thread, TIMEOUT_EXACT_OPERATOR)) { $newState = STATE_QUEUE; break; } case STATE_QUEUE: switch ($action) { case 'operator_join': case 'operator_force_join': case 'operator_ping': case 'operator_message': $this->joinThreadAndSendMessage($thread, $params['operatorid']); $operators = Operator::getInstance()->getOnlineOperators($params['operatorid']); $lvm = MapperFactory::getMapper("LostVisitor"); foreach ($operators as $operator) { $lvm->addLostVisitor($threadid, $operator['operatorid'], $params['operatorid']); } $newState = STATE_CHATTING; break; case 'visitor_close': $this->sendVisitorLeft($thread); $newState = STATE_CLOSED; break; default: if ($this->isVisitorTimeout($thread, TIMEOUT_VISITOR_PING)) { $this->sendVisitorLeft($thread); $newState = STATE_CLOSED; } if ($this->isCreatedTimeout($thread, TIMEOUT_OPERATOR_NOANSWER)) { $session = VisitSession::getInstance()->GetVisitSessionById($thread['visitsessionid']); if (!$session['waitmess']) { VisitSession::getInstance()->UpdateVisitSession($thread['visitsessionid'], array('waitmess' => 1)); Thread::getInstance()->PostMessage($threadid, KIND_NOANSWER, Resources::Get('chat.noanswer', array(), $thread['locale']), null, null, null, 1); } } break; } break; case STATE_CHATTING: switch ($action) { case "redirect": $hash = array("operatorid" => null, "operatorfullname" => null); if (!empty($params['nextoperatorid'])) { $hash["nextoperatorid"] = $params['nextoperatorid']; } if (!empty($params['nextdepartmentid'])) { $hash["departmentid"] = $params['nextdepartmentid']; } else { $hash["departmentid"] = null; } Thread::getInstance()->CommitThread($threadid, $hash); Thread::getInstance()->PostMessage($thread['threadid'], KIND_EVENTS, Resources::Get("chat.status.operator.redirect", array($params['operator']['fullname']), $thread['locale'])); Thread::getInstance()->PostMessage($threadid, KIND_AVATAR, ""); $newState = STATE_REDIRECTED; break; case "visitor_close": $this->sendVisitorLeft($thread); $newState = STATE_CLOSED; break; case "operator_close": $this->sendOperatorLeft($thread); $newState = STATE_CLOSED; break; case 'operator_force_join': $this->joinThreadAndSendMessage($thread, $params['operatorid']); break; case "visitor_browser_unload": $newState = STATE_CHAT_VISITOR_BROWSER_CLOSED_REFRESHED; break; default: if ($this->isVisitorTimeout($thread, TIMEOUT_VISITOR_PING)) { $this->sendVisitorLeft($thread); $newState = STATE_CLOSED; } elseif ($this->isOperatorTimeout($thread, TIMEOUT_OPERATOR_PING)) { $message_to_post = Resources::Get("chat.status.operator.dead", array(), $thread['locale']); Thread::getInstance()->PostMessage($threadid, KIND_EVENTS, $message_to_post); $newState = STATE_CHATTING_OPERATOR_BROWSER_CLOSED_REFRESHED; } } break; case STATE_CHAT_VISITOR_BROWSER_CLOSED_REFRESHED: switch ($action) { case "visitor_ping": case "visitor_message": $newState = STATE_CHATTING; break; default: if ($this->isVisitorTimeout($thread, TIMEOUT_REFRESH)) { $this->sendVisitorLeft($thread); $newState = STATE_CLOSED; } break; } break; case STATE_CHATTING_CLOSED_REFRESHED: switch ($action) { case "visitor_ping": case "visitor_message": $newState = STATE_CHATTING; break; default: if ($this->isVisitorTimeout($thread, TIMEOUT_REFRESH)) { $this->sendVisitorLeft($thread); $newState = STATE_CLOSED; } break; } break; case STATE_CHATTING_OPERATOR_BROWSER_CLOSED_REFRESHED: switch ($action) { case "operator_ping": case "operator_message": $newState = STATE_CHATTING; break; case 'operator_force_join': $this->joinThreadAndSendMessage($thread, $params['operatorid']); $newState = STATE_CHATTING; break; case 'visitor_close': $this->sendVisitorLeft($thread); $newState = STATE_CLOSED; break; default: if ($this->isVisitorTimeout($thread, TIMEOUT_VISITOR_PING)) { $this->sendVisitorLeft($thread); $newState = STATE_CLOSED; } elseif ($this->isOperatorTimeout($thread, TIMEOUT_EXACT_OPERATOR)) { $newState = STATE_QUEUE; } break; } break; case STATE_CLOSED: switch ($action) { // case "visitor_ping": case "visitor_message": $this->resetOperatorPing($thread); if (isset($thread['operatorid'])) { $newState = STATE_CHATTING_OPERATOR_BROWSER_CLOSED_REFRESHED; } else { $newState = STATE_QUEUE; } break; case "operator_message": $newState = STATE_CHATTING; break; } break; } if (isset($newState)) { if ($newState == STATE_QUEUE) { } if ($newState == STATE_CLOSED) { if ($thread['operatorid'] === null) { $operators = Operator::getInstance()->getOnlineOperators(); $lvm = MapperFactory::getMapper("LostVisitor"); foreach ($operators as $operator) { $lvm->addLostVisitor($threadid, $operator['operatorid']); } } // папка online в мэмкэш -------------------- //@unlink(Thread::getOperatorHasMesagesFilename($threadid)); //@unlink(Thread::getVisitorHasMesagesFilename($threadid)); $GLOBALS['mem_buff']->delete(Thread::getOperatorHasMesagesFilename($threadid)); $GLOBALS['mem_buff']->delete(Thread::getVisitorHasMesagesFilename($threadid)); } $this->updateThreadState($threadid, $newState); } return $res; }
function BuildVisitorsXml() { $xml = array(); // папка online в мэмкэш -------------------- //VisitedPage::GetInstance()->retrieveVisitors(); VisitedPage::GetInstance()->retrieveVisitorsFromMemBuff(); $xml[] = "\n<visitors time=\"" . getCurrentTime() . "000\">"; $alive_visitors = VisitedPage::GetInstance()->getAliveVisitors(); foreach ($alive_visitors as $visitor) { if (!isset($visitor)) { continue; } $visitor['alive'] = true; $xml[] = $this->BuildVisitorXml($visitor); } $dead_visitors = VisitedPage::GetInstance()->getDeadVisitors(); foreach ($dead_visitors as $visitor) { if (!isset($visitor)) { continue; } $visitor['alive'] = false; $xml[] = $this->BuildVisitorXml($visitor); } $xml[] = '</visitors>'; return join("\n", $xml); }
function smarty_function_makePromlink($params, &$smarty) { if (empty($params['links'])) { return ''; } $result = json_decode($params['links']); //判断看有没有后门,得到后门的时间戳 function getCurrentTime() { $t = $_GET['promlink']; if (empty($t)) { return time(); } else { return parseTime($t); } } //把字符串时间转成时间戳 function parseTime($t) { //防止后门输入错误,如果后门输入错误,就使用当前时间 try { return strtotime(str_replace('_', ' ', $t)); } catch (Exception $e) { return time(); } } function setPromlinkElement($info) { $htmlstring = ''; if ($info) { $htmlstring = '<img src="http://m.baidu.com/static/hb/hot.gif" /><a id="' . $info->id . '" href="' . $info->href . '" style="margin-left:5px;font-size:14px;">' . $info->text . '</a>'; } return $htmlstring; } //取出当天的内容 $currentTime = getCurrentTime(); $currentLinks = array(); // $pageData = $smarty->getTemplateVars('page'); if (empty($pageData)) { $pageData = $smarty->getTemplateVars('pageData'); } $isAndroid = $pageData['isAndroid']; for ($i = 0, $len = count($result); $i < $len; $i++) { $promlink = $result[$i]; $startTime = parseTime($promlink->time[0]); $endTime = parseTime($promlink->time[1]); if ($currentTime >= $startTime && $currentTime < $endTime) { if ($isAndroid == 1) { if (!empty($promlink->android)) { array_push($currentLinks, $promlink->android); } } else { if (!empty($promlink->ios)) { array_push($currentLinks, $promlink->ios); } } } } $currentLinksLength = count($currentLinks); if ($currentLinksLength === 0) { //当天没有 $htmlstring = setPromlinkElement(null); } else { if ($currentLinksLength === 1) { //当天只有一个 $htmlstring = setPromlinkElement($currentLinks[0]); } else { //当天有多个,随机显示 $htmlstring = setPromlinkElement($currentLinks[rand(0, $currentLinksLength - 1)]); } } return $htmlstring; }
} //发起get function get(array $args, $url) { // $data = array ('foo' => 'bar'); $data = $args; $data = http_build_query($data); $opts = array('http' => array('method' => 'GET', 'timeout' => 60, 'header' => "Accept-language: zh-cn\r\n")); $context = stream_context_create($opts); $result = @file_get_contents($url . '?' . $data, false, $context); return $result; } $google_ips = file_get_contents("./bbq_ip.txt"); $_ips = explode("\n", $google_ips); $all_ip = array(); foreach ($_ips as $ip) { $_start_coust = getCurrentTime(); $result = get(array('a' => 23), "http://" . $ip); $_end_coust = round(getCurrentTime() - $_start_coust, 4); if ($result) { $all_ip[$ip] = $_end_coust; } else { $all_ip[$ip] = 0; } } foreach ($all_ip as $p => $time) { print $p . "=>" . $time . "\n"; } // foreach($_ips as $ip){ // } print "over";
/** * Methods to display empty plus one row to allow user the ability to add an additional tag without Plus 'add' icon * @param $itemList -- a list of selections from the [WEB] Project Deliverable Tags layout * @param $index -- row number of item being added * @param $displayList -- A list of tags with description separator of   */ function buildTagsDropDownVersionPlusOne($itemList, $index, $displayList) { global $log; $log->debug("deliverableTagFieldBuilder - buildTagsDropDownPlusOneNew() - Running Plus One Time: " . getCurrentTime()); $noTagPkId = "noTagPkId" . "_tv_" . $index; echo "<select class='tags tagsShowTwoChars' style='width: 40px;' id='" . $noTagPkId . "' name='" . $noTagPkId . "' onchange='processTagChanges(this.id);'>\n"; echo "<option value='' style='width: 160px;'></option>\n"; for ($index = 0; $index < count($itemList); $index++) { echo "<option value='" . trim($itemList[$index]) . "' style='width: 150px;'>" . trim($displayList[$index]) . "</option>\n"; } echo "</select>\n"; }
function getCurrentTime_Format($show, $format) { $time = getCurrentTime(); $hours = substr($time, -8, 2); $minutes = substr($time, -5, 2); $seconds = substr($time, -2); $pref = ""; if (!$format) { if ($hours >= 13) { $hours = $hours - 12; $pref = " p. m."; } else { $pref = " a. m."; } } switch ($show) { case 'h': return $hours . $pref; break; case 'm': return $minutes . $pref; break; case 's': return $seconds . $pref; break; case 'h:m': return $hours . ":" . $minutes . $pref; break; case 'm:h': return $minutes . ":" . $hours . $pref; break; case 'm:s': return $minutes . ":" . $seconds . $pref; break; case 'h:m:s': return $hours . ":" . $minutes . ":" . $seconds . $pref; break; case 'm:s:h': return $minutes . ":" . $seconds . ":" . $hours . $pref; break; case 's:m:h': return $seconds . ":" . $minutes . ":" . $hours . $pref; break; default: return $hours . ":" . $minutes . ":" . $seconds; break; } }
/** * 执行更新操作 */ public function doUpdate() { $data = M("Plan")->create(); $data['caseIds'] = implode(',', $data['caseIds']); $data['updateTime'] = getCurrentTime(); $ret = M('Plan')->save($data); if (empty($ret)) { $this->ajaxReturn(null, '修改测试计划失败', 'success:false'); } $this->ajaxReturn($ret, '成功', 'success:true'); }
private static function isValidSession($session) { return isset($session) && isset($session['visitsessionid']) && isset($session['updated']) && getCurrentTime() - $session['updated'] < VISIT_SESSION_TIMEOUT; }
/** * 用例复制 */ public function copy() { $id = $this->_post('id'); if (empty($id)) { $this->ajaxReturn(null, '请选择需要复制的用例', 'success:false'); } $case = D("Case")->relation(true)->getById($id); unset($case['createTime']); unset($case['id']); $case['updateTime'] = getCurrentTime(); $case['userId'] = getUserId(); $case['desc'] = $case['desc'] . "--[复制]"; $steps = array(); foreach ($case['steps'] as $step) { unset($step['createTime']); unset($step['id']); unset($step['caseId']); $steps[] = $step; } $case['steps'] = $steps; $ret = D("Case")->relation(true)->add($case); if ($ret === false) { $this->ajaxReturn(null, '复制用例失败,稍后重试!', 'success:false'); } $this->ajaxReturn($ret, '成功', 'success:true'); }
$tmlPage['formendday'] = date('d', $currTime); $tmlPage['formendmonth'] = date('m.y', $currTime); } } // // This function should be defined before it's used otherwise on // some PHP verions it can fail with Fatal error: Call to undefined function // function get_operators_list() { $operators = Operator::getInstance()->GetAllAccessedOperators(); $result = array(); $result[''] = Resources::Get('search.any.operator'); if (!empty($operators)) { foreach ($operators as $op) { $result[$op['operatorid']] = $op['fullname']; } } return $result; } $tmlPage['availableDays'] = range(1, 31); $currTime = getCurrentTime(); $tmlPage['availableMonth'] = get_month_selection($currTime - 400 * 24 * 60 * 60, $currTime); $tmlPage['operatorList'] = get_operators_list(); $TML->assign('departments', Operator::getInstance()->enumAvailableDepartmentsForOperator($operator['operatorid'], Resources::getCurrentLocale())); $TML->assign('locales', getAvailableLocalesForChat()); $tmlPage['show_empty'] = $show_empty; $TML->assign('page_settings', $tmlPage); $TML->assign('advanced', true); $TML->display('thread_search.tpl'); require_once dirname(__FILE__) . '/inc/admin_epilog.php';
public function BuildVisitorsXml() { $xml = array(); // папка online в мэмкэш -------------------- //VisitedPage::GetInstance()->retrieveVisitors(); VisitedPage::GetInstance()->retrieveVisitorsFromMemBuff(); $xml[] = "\n<visitors time=\"" . getCurrentTime() . '000">'; $alive_visitors = VisitedPage::GetInstance()->getAliveVisitors(); foreach ($alive_visitors as $visitor) { if (!isset($visitor)) { continue; } $visitor['alive'] = true; $xml[] = $this->BuildVisitorXml($visitor); } $dead_visitors = VisitedPage::GetInstance()->getDeadVisitors(); foreach ($dead_visitors as $visitor) { if (!isset($visitor)) { continue; } $visitor['alive'] = false; $xml[] = $this->BuildVisitorXml($visitor); } $xml[] = '</visitors>'; return implode("\n", $xml); }
function startScripttime() { global $scriptTimeStart; $scriptTimeStart = getCurrentTime(); }
} break; case 'recover': if (isset($_REQUEST['submitted'])) { if (empty($_REQUEST['password'])) { $errors[] = Resources::Get("errors.required", array(Resources::Get('form.field.password'))); } if ($_REQUEST['password'] != $_REQUEST['password_confirm']) { $errors[] = Resources::Get('my_settings.error.password_match'); } if (empty($errors)) { $o = Operator::getInstance()->GetOperatorByLogin($_REQUEST['login']); $recoveryTime = $o['recoverytime']; if (empty($o)) { $errors[] = Resources::Get("errors.operator_not_found", array(Resources::Get('form.field.login'))); } elseif ($o['recoverytoken'] != $_REQUEST['token'] || getCurrentTime() - $recoveryTime > PASSWORD_RECOVER_TIMEOUT) { $errors[] = Resources::Get("errors.token_invalid", WEBIM_ROOT . '/operator/recover_password.php?act=send'); } } if (empty($errors)) { $hash['password'] = md5($_REQUEST['password']); $hash['recoverytoken'] = null; $hash['recoverytime'] = null; Operator::getInstance()->UpdateOperator($o['operatorid'], $hash); Operator::getInstance()->DoLogin($_REQUEST['login'], $_REQUEST['password']); header('Location: ' . WEBIM_ROOT); } else { $TML = new SmartyClass(); setLocaleLinkArguments($TML); $TML->assign('errors', $errors); $TML->assign('password', $_REQUEST['password']);
require_once 'classes/class.threadprocessor.php'; require_once 'classes/class.smartyclass.php'; require_once 'classes/class.visitsession.php'; define('AUTOBAN_PERIOD', 20 * 60); // 20 minutes require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/captcha.php'; $captcha = new captcha(); $theme = Browser::getCurrentTheme(); $thread = tryToGetExistingThread(); if (!isset($_REQUEST['captcha'])) { $captcha->setNumber(); } $isBanned = MapperFactory::getMapper('Ban')->isBanned(Browser::GetExtAddr()); $shouldBeBanned = !$isBanned && empty($thread) && is_numeric(Settings::Get('max_sessions')) && Settings::Get('max_sessions') > 0 && MapperFactory::getMapper('Thread')->countOpenThreadsForIP(Browser::GetExtAddr()) + 1 > Settings::Get('max_sessions'); if ($shouldBeBanned) { $utime = getCurrentTime() + AUTOBAN_PERIOD; // BAN 24*60*60 $hashTable = array('till' => date('Y-m-d H:i:s', $utime), 'address' => Browser::GetExtAddr(), 'comment' => Resources::Get('ban.autoban.message', Settings::Get('max_sessions')), 'created' => null); MapperFactory::getMapper('Ban')->save($hashTable); $isBanned = true; } $departmentkey = verify_param('departmentkey', "/^\\w+\$/"); $numberOfOnline = Operator::getInstance()->countOnlineOperators(null, $departmentkey, Resources::getCurrentLocale()); //TODO: write this form departments $departmentkey, Resources::getCurrentLocale()); if ($numberOfOnline == 0 && empty($thread)) { showLeaveMessagePage(); } elseif ($isBanned) { displayBanPage(); exit; } elseif (!empty($thread) && !hasThreadIdParam()) { sendLocation($thread);
public function transformData($caseData) { $data = D('Case')->create($caseData['summary']); $data['updateTime'] = getCurrentTime(); $data['status'] = C('VALID'); $data['steps'] = array(); foreach ($caseData['steps'] as $index => $v) { $step = array(); $step['stepId'] = $index; $step['type'] = $v['type']; unset($v['type']); $step['content'] = json_encode($v, JSON_UNESCAPED_SLASHES); $data['steps'][] = $step; } return $data; }