public function Draw() { $jsession = JFactory::getSession(); $cid = $mid = 0; switch (JFactory::getApplication()->input->get("owner", NULL)) { case "component": $cid = JFactory::getApplication()->input->get("id", NULL); break; case "module": $mid = JFactory::getApplication()->input->get("id", NULL); } $fsession = new FSession($jsession->getId(), $cid, $mid); // Store the answer in the session if ($fsession->Save($this->Answer, "captcha_answer")) { $this->DebugLog->Write("Answer saved into session"); } else { $this->DebugLog->Write("Database query failed"); } // White background imagefill($this->Image['data'], 0, 0, $this->Colors['Background']); // Background grid $this->DrawGrid(); $len = strlen($this->Question); // Space available for one single char. It is based on image width and number of characters to display $space = $this->Image['width'] / $len; // Single disturb characters rendering. Doubles the characters and halves the space for ($p = 0; $p < 2 * $len; ++$p) { // render a random character from ascii 33 and ascii 126 $this->Render(chr(rand(33, 126)), $p, $space / 2, $this->Colors['Disturb']); } // Single characters rendering for ($p = 0; $p < $len; ++$p) { $this->Render($this->Question[$p], $p, $space, $this->Colors['Text']); } $this->DebugLog->Write("Render done"); // Debug with &noimage=1 if (JFactory::getApplication()->input->get("noimage", NULL)) { return; } // http://stackoverflow.com/questions/9884513/avoid-caching-of-the-http-responses // Must not be cached neither by client browsers or proxies $now = gmdate("D, d M Y H:i:s") . " GMT"; header("Expires: " . $now); header("Last-Modified: " . $now); // no-cache: cacheable, but mustn't use the response without first checking with the originating server // private: is intended for a single user and MUST NOT be cached by a shared cache // must-revalidate: MUST NOT use the entry after it becomes stale without first revalidating it with the origin server. In all circumstances an HTTP/1.1 cache MUST obey the must-revalidate directive; in particular, if the cache cannot reach the origin server for any reason, it MUST generate a 504 (Gateway Timeout) response. // max-age=0: The content is stale and should be validated before use. header("Cache-Control: no-cache, private, must-revalidate, max-age=0"); header("Pragma: no-cache"); header("Content-Type: image/jpeg"); header("Content-Disposition: inline; filename=\"foxcaptcha.jpg\""); // Send the stream to the client browser imagejpeg($this->Image['data']); imagedestroy($this->Image['data']); $this->DebugLog->Write("Image sent to client"); }
/** * +---------------------------------------------------------- * 应用程序初始化 * +---------------------------------------------------------- * @access public * +---------------------------------------------------------- * @return void +---------------------------------------------------------- */ public static function init() { global $_F; if (FConfig::get('global.debug')) { $_F['debug'] = true; } if (FConfig::get('global.session.type') == 'db') { $handler = new FSession(); session_set_save_handler(array(&$handler, "open"), array(&$handler, "close"), array(&$handler, "read"), array(&$handler, "write"), array(&$handler, "destroy"), array(&$handler, "gc")); $handler->start(); } }
public function Show() { // Load into <head> needed js only once and only if upload feature is enabled if (!(bool) $this->Params->get("uploaddisplay")) { return ""; } if (!isset($GLOBALS[$GLOBALS["ext_name"] . '_upload_js_loaded'])) { $placeholders = $values = array(); $placeholders[] = '{%BROWSE_FILES%}'; $placeholders[] = '{%FLOAT%}'; $placeholders[] = '{%JCANCEL%}'; $placeholders[] = '{%FAILED%}'; $placeholders[] = '{%SUCCESS%}'; $placeholders[] = '{%Action%}'; $values[] = JTEXT::_($GLOBALS["COM_NAME"] . '_BROWSE_FILES'); $values[] = $GLOBALS["left"]; $values[] = JTEXT::_('JCANCEL'); $values[] = JTEXT::_($GLOBALS["COM_NAME"] . '_FAILED'); $values[] = JTEXT::_($GLOBALS["COM_NAME"] . '_SUCCESS'); // Use "/" instead of "DS", since this string is used on client side in Javascript createUploader function $values[] = JURI::base(true) . '/components/' . $GLOBALS["com_name"] . '/lib/file-uploader.php'; // Show main uploader javascript in <head> section as a source $this->js_load("fileuploader-min.js", 1, 0, $placeholders, $values); $GLOBALS[$GLOBALS["ext_name"] . '_upload_js_loaded'] = true; } $id = $this->GetId(); //$cid = ((bool)$this->Application->mid) ? 0 : $this->GetComponentId(); $result = '<div style="clear:both;">' . '<label ' . 'style="' . '">' . $this->Params->get('upload') . ". " . JTEXT::_($GLOBALS["COM_NAME"] . '_FILE_SIZE_LIMIT') . " " . $this->human_readable($this->Params->get("uploadmax_file_size") * 1024) . '</label>' . '<div id="foxupload_' . $id . '" ' . '></div>' . PHP_EOL . "<script language=\"javascript\" type=\"text/javascript\">createUploader('foxupload_{$id}', " . $this->Application->cid . ", " . $this->Application->mid . ");</script>" . '<noscript>' . '<input ' . 'type="file" ' . 'name="foxstdupload"' . " />" . '</noscript>'; $jsession = JFactory::getSession(); $fsession = new FSession($jsession->getId(), $this->Application->cid, $this->Application->mid); $data = $fsession->Load('filelist'); // Read the list from the session if ($data) { $filelist = explode("|", $data); } else { $filelist = array(); } if (count($filelist)) { // Previuosly completed uploads $result .= '<ul class="qq-upload-list">'; foreach ($filelist as &$file) { $result .= '<li class="qq-upload-success" style="background-position:' . $GLOBALS["left"] . ';">' . '<span class="qq-upload-file" style="float:' . $GLOBALS["left"] . '">' . substr($file, 14) . '</span>' . '<span class="qq-upload-success-text" style="background-position:' . $GLOBALS["left"] . ';">' . JTEXT::_($GLOBALS["COM_NAME"] . '_SUCCESS') . '</span>' . '</li>'; } $result .= '</ul>' . PHP_EOL; } // Close row container $result .= "</div>" . PHP_EOL; return $result; }
public function shenheAction() { global $_F; // $_F["debug"] = true; $tid = FRequest::getPostInt('tid'); $params = array("tid" => $tid); // $params =json_encode($params); // echo($params); $url = FConfig::get('global.service_mumu_url') . "/s/topic/IClose"; // $url = "http://yfservice.admin.docker:8081/s/topic/IClose"; // echo( $url); //$params=Service_Common::post($url,$params); //$cookie = "sid=306123456;uid=5000513;key=306123456"; $cookie = "sid=" . FSession::get('sid') . ";uid=" . FSession::get('user_id') . ";key=" . FSession::get('sid'); $params = FHttp::doPost($url, $params, $cookie); //print_r($params); $params = json_decode($params); if ($params->status == "ok") { $this->showMessage("封闭成功", $messageType = 'success'); echo "<script LANGUAGE='javascript'>guanbi('guanbi_" . $tid . "');</script>"; } else { $this->showMessage("封闭失败", $messageType = 'success'); } return; }
public function loginAction() { global $_F; // $_F['debug'] = 1; if ($this->isPost()) { $username = trim($_POST['username']); $password = trim($_POST['password']); /*$checkCode = FRequest::getPostString('check_code'); if (!$checkCode) { return $this->error('请输入验证码!'); }*/ session_start(); // if ($checkCode != $_SESSION['rand_code']) { // return $this->error('验证码错误!'); // } $refer = trim($_POST['refer']); if (strpos($refer, 'login')) { $refer = null; } $managerTable = new FTable('manager'); $encryptPassword = Service_Manager::getEncryptPassword($password); $managerData = $managerTable->where(array('username' => $username))->find(); $managerLoginLogTable = new FTable('manager_login_log'); $newLoginLogData = array('username' => $username, 'login_time' => date('Y-m-d H:i:s'), 'login_ip' => FRequest::getClientIP()); if (!$managerData) { $newLoginLogData['result'] = 2; $newLoginLogData['comment'] = '用户名不存在'; $managerLoginLogTable->insert($newLoginLogData); return $this->error('用户名不存在!'); } else { if ($managerData['password'] == $encryptPassword) { $user_id = $managerData['user_id']; // 获取管理员user_id 和 密钥 $user_table = new FTable("user_main"); $user = $user_table->where(array("uid" => $user_id))->find(); // $auth_str = md5("{$managerData['username']}|{$managerData['password']}|{$managerData['gid']}"); FSession::set('manager_uid', $managerData['uid']); FSession::set('user_id', $user_id); FSession::set('sid', $user['sid']); // 更新登录时间 $managerTable->where(array("uid" => $managerData['uid']))->update(array('last_login_time' => date('Y-m-d H:i:s'))); $newLoginLogData['uid'] = $managerData['uid']; $newLoginLogData['result'] = 1; $managerLoginLogTable->insert($newLoginLogData); // FCookie::set('manager_auth', "{$managerData['uid']}\t{$auth_str}", 3600000); FResponse::redirect('/'); return true; } else { $newLoginLogData['result'] = 2; $newLoginLogData['comment'] = '密码错误'; $managerLoginLogTable->insert($newLoginLogData); return $this->error('对不起,密码错误!'); } } } $this->display('admin/login'); }
/** * +---------------------------------------------------------- * 应用程序初始化 * +---------------------------------------------------------- * @access public * +---------------------------------------------------------- * @return void +---------------------------------------------------------- */ public static function init() { $session_type = FConfig::get('global.session.type'); if ($session_type == 'db') { $handler = new FSession(); session_set_save_handler(array(&$handler, "open"), array(&$handler, "close"), array(&$handler, "read"), array(&$handler, "write"), array(&$handler, "destroy"), array(&$handler, "gc")); $handler->start(); } elseif ($session_type == 'memcache') { ini_set('session.save_handler', 'memcache'); ini_set('session.save_path', 'tcp:/' . '/127.0.0.1:11211'); // . FConfig::get('global.memcache.ip') $handler = new FSession(); $handler->start(); } else { $handler = new FSession(); $handler->start(); } }
public function Show() { if (!(bool) $this->Params->get("uploaddisplay")) { return ""; } $id = $this->GetId(); //$cid = ((bool)$this->Application->mid) ? 0 : $this->GetComponentId(); $action = JRoute::_("index.php?option=" . $GLOBALS["com_name"] . "&view=loader" . "&owner=" . $this->Application->owner . "&id=" . $this->Application->oid . "&root=none" . "&filename=none" . "&type=uploader"); $label = ""; $span = ""; // Label beside: generates a label if ((bool) $this->Params->get("labelsdisplay")) { $label = '<label class="control-label">' . $this->Params->get('upload') . '</label>'; } else { $span = '<span class="help-block">' . $this->Params->get('upload') . '</span>'; } $result = '<div class="control-group">' . $label . '<div class="controls">' . $span . '<div id="foxupload_' . $id . '"></div>' . '<span class="help-block">' . JText::_($GLOBALS["COM_NAME"] . '_FILE_SIZE_LIMIT') . " " . $this->human_readable($this->Params->get("uploadmax_file_size") * 1024) . '</span>' . '</div>' . "<script language=\"javascript\" type=\"text/javascript\">" . "jQuery(document).ready(function () {" . "if (typeof Joomla == 'undefined')" . "{" . "\tJoomla = {};" . "\tJoomla.JText =" . "\t{" . "\t\tstrings:{}," . "\t\t'_':function (key, def)" . "\t\t{" . "\t\t\treturn typeof this.strings[key.toUpperCase()] !== 'undefined' ? this.strings[key.toUpperCase()] : def;" . "\t\t}," . "\t\tload:function (object)" . "\t\t{" . "\t\t\tfor (var key in object)" . "\t\t\t{" . "\t\t\t\tthis.strings[key.toUpperCase()] = object[key];" . "\t\t\t}" . "\t\t\treturn this;" . "\t\t}" . "\t};" . "}" . "Joomla.JText.load(" . "{" . "\"COM_FOXCONTACT_BROWSE_FILES\":'" . JText::_("COM_FOXCONTACT_BROWSE_FILES") . "'," . "\"JCANCEL\":'" . JText::_("JCANCEL") . "'," . "\"COM_FOXCONTACT_FAILED\":'" . JText::_("COM_FOXCONTACT_FAILED") . "'," . "\"COM_FOXCONTACT_SUCCESS\":'" . JText::_("COM_FOXCONTACT_SUCCESS") . "'," . "\"COM_FOXCONTACT_NO_RESULTS_MATCH\":'" . JText::_("COM_FOXCONTACT_NO_RESULTS_MATCH") . "'" . "}" . ");" . "CreateUploadButton('foxupload_{$id}', '{$action}', " . $this->Application->cid . ", " . $this->Application->mid . ", '" . $this->Application->owner . "', " . $this->Application->oid . ");" . "});" . "</script>" . '<noscript>' . '<input ' . 'type="file" ' . 'name="foxstdupload"' . " />" . '</noscript>' . "</div>" . PHP_EOL; // control-group $jsession = JFactory::getSession(); $fsession = new FSession($jsession->getId(), $this->Application->cid, $this->Application->mid); $data = $fsession->Load('filelist'); // Read the list from the session if ($data) { $filelist = explode("|", $data); } else { $filelist = array(); } // List of files $result .= '<div class="control-group">' . '<div class="controls">'; // Previuosly completed uploads $result .= '<ul id="uploadlist-' . $this->Application->owner . $this->Application->oid . '" class="qq-upload-list">'; foreach ($filelist as &$file) { $result .= '<li class="qq-upload-success">' . '<span class="qq-upload-file">' . $this->format_filename(substr($file, 14)) . '</span>' . '<span class="qq-upload-success-text">' . JTEXT::_($GLOBALS["COM_NAME"] . '_SUCCESS') . '</span>' . '</li>'; } $result .= '</ul>' . PHP_EOL; $result .= '</div>' . '</div>' . PHP_EOL; // control-group return $result; }
function listAction() { global $_F; //$_F["debug"] = true; $admin_uid = FSession::get('manager_uid'); $uid = FRequest::getInt("uid"); $page = max(1, FRequest::getInt('page')); $user_table = new FTable("user_detail"); $user_nickname = $user_table->fields(array("nickname"))->where(array("uid" => $uid))->find(); $where = array('uadd.uid' => $uid); $table = new FTable("user_address", "uadd"); $useradds = $table->fields(array("uadd.uid", "uadd.addrid", "uadd.phone", "uadd.province", "uadd.city", "uadd.address", "uadd.username"))->where($where)->page($page)->limit(20)->order(array("uadd.addrid" => "desc"))->select(); $page_info = $table->getPagerInfo(); $this->assign('page_info', $page_info); $this->assign("useradds", $useradds); $this->assign("uid", $uid); $this->assign("user_nickname", $user_nickname['nickname']); $this->display('admin/y_user_address_list'); }
/** * 用户资料首审 */ function verifyUserFirstAction() { $uid = FRequest::getInt("uid"); $status = FRequest::getInt("status"); $reason = FRequest::getString("reason"); if (CommonUtil::parmIsEmpty($uid) || CommonUtil::parmIsEmpty($status)) { FResponse::output(CommonUtil::GetDefRes(201, "参数错误")); return; } // 检测如果已经存在需要复审记录,则直接返回 $table2 = new FTable("verify_user"); $n = $table2->where(array("uid" => $uid, "flag" => 0))->count(); if ($n > 0) { FResponse::output(CommonUtil::GetDefRes(200, "操作成功")); return; } // 原子操作,开启事务处理 FDB::begin(); try { // 修改用户资料修改记录状态 $table = new FTable("update_record"); $table->where(array("uid" => $uid, "status" => 0))->update(array("status" => 1)); // 插入到复审的表里 $table2 = new FTable("verify_user"); $id = $table2->insert(array("uid" => $uid, "status" => $status, "reason" => $reason, "aid" => FSession::get('user_id'))); FDB::commit(); } catch (Exception $e) { FDB::rollBack(); //写入日志 $log = new FLogger("user_log"); $log->append("verifyUserFirstAction:" . $e); FResponse::output(CommonUtil::GetDefRes(201, "操作失败")); return; } // FResponse::output(CommonUtil::GetDefRes(200,"操作成功")); //下面是一审完了,走二审接口 /*$table2 = new FTable("verify_user","vu"); $verify_user = $table2->fields(array("vu.id")) ->where(array("vu.uid"=>$uid,"vu.flag"=>0))->find();*/ $url = FConfig::get('global.service_mumu_url') . "/s/user/IUserInfoVerify"; $res = Service_Common::secPost($url, array("id" => $id, "uid" => $uid, "level" => $status)); FResponse::output($res); }
public function shenheAction() { global $_F; // $_F["debug"] = true; $size = FRequest::getPostInt('size'); $list = FRequest::getPostString('avatarlevel' . $size); $query = explode(",", $list); $params_uid = array("id" => $query[0], "status" => $query[1]); $url_rztz = FConfig::get('global.service_mumu_url') . "/s/user/ICertifyVideo"; $cookie = "sid=" . FSession::get('sid') . ";uid=" . FSession::get('user_id') . ";key=" . FSession::get('sid'); $params_rztz = FHttp::doPost($url_rztz, $params_uid, $cookie); $params = json_decode($params_rztz); if ($params->status == "ok") { // $this->showMessage("审核成功",$messageType = 'success'); } else { // $this->showMessage("审核失败",$messageType = 'success'); } //echo(json_encode($params_uid)); // $this->showMessage("审核失败",$messageType = 'success'); //exit; return; }
function listAction() { global $_F; //$_F["debug"] = true; $province = FRequest::getString('province'); $city = FRequest::getString('city'); $gender = CommonUtil::getComParam(FRequest::getInt('gender'), 2); $age = FRequest::getInt('age'); $table = new FTable("user_province_area"); $provinces = $table->order(array("region_id" => "asc"))->select(); if ($province) { $where = array("city" => $province); $user_province = new FTable("user_province_area"); $user_provinces = $user_province->where($where)->find(); $stm_str = "-" . $age . " year"; $etm_str = "-" . ($age - 1) . " year"; $stm_birthday = date("Y-01-01 00:00:00", strtotime($stm_str)); $etm_birthday = date("Y-01-01 00:00:00", strtotime($etm_str)); $query_str = " ud.birthday >= '" . $stm_birthday . "' and ud.birthday < '" . $etm_birthday . "' "; $user_table = new FTable("user_main", "um"); $user = $user_table->where(array("um.gender" => $gender, "str" => $query_str))->leftJoin("user_detail", "ud", "um.uid=ud.uid")->find(); $url = FConfig::get('global.service_mumu_url') . "/s/discovery/IAdjacent"; //$url = "http://yfservice.admin.docker:8081/s/discovery/IAdjacent"; //echo($url); $post_data = array("lng" => $user_provinces['x'], "lat" => $user_provinces['y'], "cur" => 1, "refresh" => true, "ps" => 30, "uid" => $user["uid"]); //$cookie = "sid=306123456;uid=5000513;key=306123456"; $cookie = "sid=" . FSession::get('sid') . ";uid=" . FSession::get('user_id') . ";key=" . FSession::get('sid'); $output = FHttp::doPost($url, $post_data, $cookie); // print_r($output); $output = json_decode($output); $status = $output->status; $users = $output->res; $users = $users->users; $users = $users->list; if (count($users) <= 30) { $post_data = array("lng" => $user_provinces['x'], "lat" => $user_provinces['y'], "cur" => 2, "refresh" => true, "ps" => 30, "uid" => $user["uid"]); $output2 = FHttp::doPost($url, $post_data, $cookie); $output2 = json_decode($output2); $users2 = $output2->res; $users2 = $users2->users; $users2 = $users2->list; } $users = array_merge($users, $users2); $ids = array(); foreach ($users as $u) { array_push($ids, $u->uid); } if (count($ids) > 0) { $users_table = new FTable("user_main", "um"); $u_arr = $users_table->fields(array("um.uid", "um.gender", "ud.localtag", "ud.birthday"))->where(array("um.uid" => array("in" => $ids)))->leftJoin("user_detail", "ud", "um.uid = ud.uid")->select(); } $u_m = array(); foreach ($u_arr as $u) { $u_m[$u["uid"]] = $u; } foreach ($users as &$u) { $uid = $u->uid; $r_u = $u_m[$uid]; $u->age = CommonUtil::birthdayToAge($r_u["birthday"]); $u->tag = $r_u["localtag"]; $u->gender = $r_u["gender"]; } $this->assign('users', $users); $this->assign('status', $status); $this->assign('province', $province); $this->assign('city', $city); $this->assign('age', $age); } $this->assign('gender', $gender); $this->assign('provinces', $provinces); $this->display('admin/user_avataradd_list'); }
function display($tpl = null) { $this->Application = JFactory::getApplication(); // The following code will access the Component-wide default parameters, // already overridden with those for the menu item (if applicable): $this->cparams = $this->Application->getParams('com_foxcontact'); $this->Submitter = new FSubmitter($this->cparams, $this->messages); $this->FieldsBuilder = new FieldsBuilder($this->cparams, $this->messages); $this->AjaxUploader = new FAjaxUploader($this->cparams, $this->messages); $this->Uploader = new FUploader($this->cparams, $this->messages); $this->FoxCaptcha = new FCaptcha($this->cparams, $this->messages); $this->JMessenger = new FJMessenger($this->cparams, $this->messages, $this->FieldsBuilder); $this->Antispam = new FAntispam($this->cparams, $this->messages, $this->FieldsBuilder); $this->AdminMailer = new FAdminMailer($this->cparams, $this->messages, $this->FieldsBuilder); $this->SubmitterMailer = new FSubmitterMailer($this->cparams, $this->messages, $this->FieldsBuilder); // Build $FormText $this->FormText .= $this->FieldsBuilder->Show(); $this->FormText .= $this->AjaxUploader->Show(); $this->FormText .= $this->FoxCaptcha->Show(); $this->FormText .= $this->Antispam->Show(); // Usually we want the submit button at the bottom $this->FormText .= $this->Submitter->Show(); switch (0) { case $this->Submitter->IsValid(): break; case $this->FieldsBuilder->IsValid(): break; case $this->AjaxUploader->IsValid(): break; case $this->Uploader->IsValid(): break; case $this->FoxCaptcha->IsValid(): break; case $this->Antispam->IsValid(): break; // Spam check passed or disabled // Spam check passed or disabled case $this->JMessenger->Process(): break; case $this->AdminMailer->Process(): break; case $this->SubmitterMailer->Process(): break; default: // None of the previous checks are failed // Avoid to show the Form and the button again $this->FormText = ""; // Reset captcha solution in the session after read it, avoiding that a f****d lamer // abuse of the *same session* without request the captcha again, to send tons of email $jsession = JFactory::getSession(); $fsession = new FSession($jsession->getId(), $this->Application->cid, $this->Application->mid); $fsession->PurgeValue("captcha_answer"); HeaderRedirect($this->cparams); } // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode('<br />', $errors)); return false; } // Display the view parent::display($tpl); }
public function Draw() { $jsession = JFactory::getSession(); $fsession = new FSession($jsession->getId(), JRequest::getVar("cid", NULL, 'GET'), JRequest::getVar("mid", NULL, 'GET')); // Store the answer in the session if ($fsession->Save($this->Answer, "captcha_answer")) { $this->DebugLog->Write("Answer saved into session"); } else { $this->DebugLog->Write("Database query failed"); } // White background imagefill($this->Image['data'], 0, 0, $this->Colors['Background']); // Background grid $this->DrawGrid(); $len = strlen($this->Question); // Space available for one single char. It is based on image width and number of characters to display $space = $this->Image['width'] / $len; // Single disturb characters rendering. Doubles the characters and halves the space for ($p = 0; $p < 2 * $len; ++$p) { // render a random character from ascii 33 and ascii 126 $this->Render(chr(rand(33, 126)), $p, $space / 2, $this->Colors['Disturb']); } // Single characters rendering for ($p = 0; $p < $len; ++$p) { $this->Render($this->Question[$p], $p, $space, $this->Colors['Text']); } $this->DebugLog->Write("Render done"); // Debug with ?cid=xxx&noimage=1 if (JRequest::getVar("noimage", NULL, 'GET')) { return; } // Prepare some useful headers header("Expires: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // must not be cached by the client browser or any proxy header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); header("Content-type:image/jpeg"); header("Content-Disposition:inline ; filename=fcaptcha.jpg"); // Send the stream to the client browser imagejpeg($this->Image['data']); imagedestroy($this->Image['data']); $this->DebugLog->Write("Image sent to client"); }
public function shenheAction() { global $_F; // $_F["debug"] = true; $size = FRequest::getPostInt('size'); $list = array(); /* for($j=1;$j <$size;$j++) { $list[$j-1] =FRequest::getPostString('avatarlevel'.$j); } $list[$size-1] = FRequest::getPostString('avatarlevel'.$size); */ $list[0] = FRequest::getPostString('avatarlevel' . $size); $params = array("list" => $list); $query = explode(",", $list[0]); $query = $query[0]; $params_uid = array("uid" => $query); $params = json_encode($params); //$this->showMessage($params,$messageType = 'success'); // exit; $url = FConfig::get('global.service_mumu_url') . "/user/AdminSetAvatarStat"; $params = Service_Common::post($url, $params); /*$url_rztz = FConfig::get('global.service_mumu_url')."/s/user/ICertifyAvatar"; $params_rztz=Service_Common::post($url_rztz,json_encode($params_uid));*/ $url_rztz = FConfig::get('global.service_mumu_url') . "/s/user/ICertifyAvatar"; $cookie = "sid=" . FSession::get('sid') . ";uid=" . FSession::get('user_id') . ";key=" . FSession::get('sid'); $params_rztz = FHttp::doPost($url_rztz, $params_uid, $cookie); $params = json_decode($params); /* $url_rztz = FConfig::get('global.service_mumu_url')."/s/user/ICertifyAvatar"; $params_rztz=Service_Common::post($url_rztz,$params_uid);*/ if ($params->status == "ok") { //$this->showMessage("审核成功",$messageType = 'success'); } else { $this->showMessage("审核失败", $messageType = 'success'); } return; }
// Fields properties $captcha['show'] = (bool)$params->get("stdcaptchadisplay"); // $captcha['label'] = $params->get("stdcaptcha"); $captcha['src'] = JURI::base(true) . '/components/com_foxcontact/lib/captcha-drawer.php?cid=0&mid=' . $module->id; $captcha['transparent'] = JURI::base(true) . '/media/com_foxcontact/images/transparent.gif'; //$captcha['id'] = 'fcaptcha_mid_' . $module->id; $captcha['width'] = $params->get("stdcaptchawidth", ""); $captcha['height'] = $params->get("stdcaptchaheight", ""); $upload['show'] = (bool)$params->get("uploaddisplay"); $direction = intval(JFactory::getLanguage()->get('rtl', 0)); $style['float'] = $direction ? "right" : "left"; $upload['label'] = $params->get("upload"); $jsession = JFactory::getSession(); $fsession = new FSession($jsession->getId(), 0, $module->id); $data = $fsession->Load('filelist'); // Read the list from the session if ($data) $upload['filelist'] = explode("|", $data); else $upload['filelist'] = array(); if (intval($params->get("top_textdisplay", "0"))) $toptext = $params->get("top_text", ""); else $toptext = ""; if (!empty($toptext)) $toptext = '<div class="foxmessage" style="clear:both;">' . $toptext . '</div>'; if (intval($params->get("bottom_textdisplay", "0"))) $bottomtext = $params->get("bottom_text", ""); else $bottomtext = ""; if (!empty($bottomtext)) $bottomtext = '<div class="foxmessage" style="clear:both;">' . $bottomtext . '</div>'; $page_subheading = $params->get("page_subheading", ""); // Module xml
case $fcaptcha->IsValid(): break; case $antispam->IsValid(): break; // Spam check passed or disabled // Spam check passed or disabled case $jMessenger->Process(): break; case $newsletter->Process(): break; case $acymailing->Process(): break; case $jnews->Process(): break; case $adminMailer->Process(): break; case $submitterMailer->Process(): break; default: // None of the previous checks are failed // Avoid to show the Form and the button again $form_text = ""; // Reset the solution of the captcha in the session after read, // avoiding further uses (abuses) of the same valid session, // in order to send tons of email $jsession = JFactory::getSession(); $fsession = new FSession($jsession->getId(), 0, $module->id); $fsession->PurgeValue("captcha_answer"); HeaderRedirect($params); } require JModuleHelper::getLayoutPath($app->scope, $params->get('layout', 'default'));
/** * 检查验证码是否正确 */ public static function checkCaptcha($captcha) { return $captcha == FSession::get('captcha'); }
protected function DoUpload() { //Retrieve file details from uploaded file, sent from upload form $file = JRequest::getVar('foxstdupload', NULL, 'files', 'array'); // $file is null when a browser with javascipt didn't send $_FILES at all // $file['error'] is UPLOAD_ERR_NO_FILE when a browser without javascipt sent $_FILES empty if (!$this->Submitted || !$file || $file['error'] == UPLOAD_ERR_NO_FILE) { return true; } $upload_directory = JPATH_SITE . "/components/" . $GLOBALS["com_name"] . "/uploads/"; if (!is_writable($upload_directory)) { $this->MessageBoard->Add(JText::_($GLOBALS["COM_NAME"] . '_ERR_DIR_NOT_WRITABLE'), FoxMessageBoard::error); return false; } // Check for http $_FILES upload errors if ($file['error']) { // case 1 UPLOAD_ERR_INI_SIZE: 'The uploaded file exceeds the upload_max_filesize directive in php.ini'; // case 2 UPLOAD_ERR_FORM_SIZE: 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form'; // case 3 UPLOAD_ERR_PARTIAL: 'The uploaded file was only partially uploaded'; // case 4 UPLOAD_ERR_NO_FILE: 'No file was uploaded'; // case 6 UPLOAD_ERR_NO_TMP_DIR: 'Missing a temporary folder'; // case 7 UPLOAD_ERR_CANT_WRITE: 'Failed to write file to disk'; // case 8 UPLOAD_ERR_EXTENSION: 'File upload stopped by extension'; $this->MessageBoard->Add(JText::sprintf($GLOBALS["COM_NAME"] . '_ERR_UPLOAD', $file['error']), FoxMessageBoard::error); return false; } // Check file size $size = $file['size']; if ($size == 0) { $this->MessageBoard->Add(JText::_($GLOBALS["COM_NAME"] . '_ERR_FILE_EMPTY'), FoxMessageBoard::error); return false; } $max_filesize = intval($this->Params->get("uploadmax_file_size", "0")) * KB; if ($size > $max_filesize) { $this->MessageBoard->Add(JText::_($GLOBALS["COM_NAME"] . '_ERR_FILE_TOO_LARGE'), FoxMessageBoard::error); return false; } $mimetype = new FMimeType(); if (!$mimetype->Check($file['tmp_name'], $this->Params)) { // Noo need to delete the file uploaded //unlink($file['tmp_name']); $this->MessageBoard->Add(JText::_($GLOBALS["COM_NAME"] . '_ERR_MIME') . " [" . $mimetype->Mimetype . "]", FoxMessageBoard::error); return false; } //Import filesystem libraries. Perhaps not necessary, but does not hurt jimport('joomla.filesystem.file'); //Clean up filename to get rid of strange characters like spaces and others $filename = JFile::makeSafe($file['name']); // Assign a random unique id to the file name, to avoid that lamers can force the server to execute their uploaded shit $filename = uniqid() . "-" . $filename; $dest = $upload_directory . $filename; // Todo: This attempt doesn't intercept the exception /* try { JFile::upload($file['tmp_name'], $dest); } catch (Exception $e) { //$e->getMessage() return false; } */ if (!JFile::upload($file['tmp_name'], $dest)) { return false; } // Upload successful. Add an element to the uploads list $jsession =& JFactory::getSession(); $fsession = new FSession($jsession->getId(), $this->Application->cid, $this->Application->mid); // session_id, cid, mid // Store the answer in the session $data = $fsession->Load('filelist'); // Read the list from the session if ($data) { $filelist = explode("|", $data); } else { $filelist = array(); } $filelist[] = $filename; // Append this file to the list $data = implode("|", $filelist); $fsession->Save($data, "filelist"); return true; }
function display($tpl = null) { $this->Application = JFactory::getApplication(); // Access the Component-wide default parameters, already overridden with those for the menu item (if applicable): //$this->cparams = $this->Application->getParams('com_foxcontact'); // Can't use getParams('com_foxcontact') because JRegistry::merge converts StdClass properties to arrays $this->cparams = $this->Application->getMenu()->getActive()->params; // Set Meta Description if ($description = $this->cparams->get('menu-meta_description')) { $this->document->setDescription($description); } // Set Meta Keywords if ($keywords = $this->cparams->get('menu-meta_keywords')) { $this->document->setMetadata('keywords', $keywords); } // Set robots (index, follow) if ($robots = $this->cparams->get('robots')) { $this->document->setMetadata('robots', $robots); } $foxDocument = FoxDocument::getInstance(); // User interface stylesheet $foxDocument->addResource(array("root" => "media", "filename" => "chosen", "type" => "css")); $foxDocument->addResource(array("root" => "media", "filename" => "bootstrap", "type" => "css")); // User selected stylesheet $stylesheet = $this->cparams->get("css", "bootstrap.css"); // Removes the extension part from the file name $stylesheet = preg_replace("/\\.[^.\\s]{3,4}\$/", "", $stylesheet); $foxDocument->addResource(array("root" => "components", "filename" => $stylesheet, "type" => "css")); $this->MessageBoard = new FoxMessageBoard(); $this->Submitter = new FSubmitter($this->cparams, $this->MessageBoard); $this->FieldsBuilder = new FieldsBuilder($this->cparams, $this->MessageBoard); $this->AjaxUploader = new FAjaxUploader($this->cparams, $this->MessageBoard); $this->Uploader = new FUploader($this->cparams, $this->MessageBoard); $this->FoxCaptcha = new FCaptcha($this->cparams, $this->MessageBoard); $this->JMessenger = new FJMessenger($this->cparams, $this->MessageBoard, $this->FieldsBuilder); $this->Antispam = new FAntispam($this->cparams, $this->MessageBoard, $this->FieldsBuilder); $this->Newsletter = new FNewsletter($this->cparams, $this->MessageBoard, $this->FieldsBuilder); $this->AcyMailing = new FAcyMailing($this->cparams, $this->MessageBoard, $this->FieldsBuilder); $this->JNews = new FJNewsSubscriber($this->cparams, $this->MessageBoard, $this->FieldsBuilder); $this->AdminMailer = new FAdminMailer($this->cparams, $this->MessageBoard, $this->FieldsBuilder); $this->SubmitterMailer = new FSubmitterMailer($this->cparams, $this->MessageBoard, $this->FieldsBuilder); $this->FormText .= $this->FieldsBuilder->Show(); $this->FormText .= $this->AjaxUploader->Show(); $this->FormText .= $this->AcyMailing->Show(); $this->FormText .= $this->JNews->Show(); $this->FormText .= $this->FoxCaptcha->Show(); $this->FormText .= $this->Antispam->Show(); $this->FormText .= $this->Submitter->Show(); switch (0) { case $this->Submitter->IsValid(): break; case $this->FieldsBuilder->IsValid(): break; case $this->AjaxUploader->IsValid(): break; case $this->Uploader->IsValid(): break; case $this->FoxCaptcha->IsValid(): break; case $this->Antispam->IsValid(): break; case $this->JMessenger->Process(): break; case $this->Newsletter->Process(): break; case $this->AcyMailing->Process(): break; case $this->JNews->Process(): break; case $this->AdminMailer->Process(): break; case $this->SubmitterMailer->Process(): break; default: // None of the previous checks are failed // Avoid to show the Form and the button again $this->FormText = ""; // Reset captcha solution in the session after reading, // avoiding further uses (abuses) of the same valid session, // in order to send tons of email $jsession = JFactory::getSession(); $fsession = new FSession($jsession->getId(), $this->Application->cid, $this->Application->mid); $fsession->PurgeValue("captcha_answer"); HeaderRedirect($this->cparams); } // Check for errors. if (count($errors = $this->get('Errors'))) { $this->Application->enqueueMessage(implode('<br />', $errors), 'error'); //return false; } // Display the view parent::display($tpl); }
/** * 安全post请求,会追加当前登录用户cookie */ public static function secPost($url, $params) { $cookie = "sid=" . FSession::get('sid') . ";uid=" . FSession::get('user_id') . ";key=" . FSession::get('sid'); $res = FHttp::doPost($url, $params, $cookie); $params = json_decode($res); if ($params->status == "ok") { $res = CommonUtil::GetDefRes(200, "正确"); } else { $res = CommonUtil::GetDefRes(201, "错误"); } echo "----" . $res; return $res; }
public function HandleUpload($uploadDirectory) { $this->DebugLog->Write("HandleUpload() started"); if (!is_writable($uploadDirectory)) { $this->DebugLog->Write("Directory " . $uploadDirectory . " is not writable"); return array('error' => JFactory::getLanguage()->_($GLOBALS["COM_NAME"] . '_ERR_DIR_NOT_WRITABLE')); } $this->DebugLog->Write("Directory " . $uploadDirectory . " is ok"); // Check file size $size = $this->get_file_size(); if ($size == 0) { $this->DebugLog->Write("File size is 0"); return array('error' => JFactory::getLanguage()->_($GLOBALS["COM_NAME"] . '_ERR_FILE_EMPTY')); } $this->DebugLog->Write("File size is > 0"); // uploadmax_file_size defaults to 0 to prevent hack attempts $max = $this->Params->get("uploadmax_file_size", 0) * KB; // and < max limit if ($size > $max) { $this->DebugLog->Write("File size too large ({$size} > {$max})"); return array('error' => JFactory::getLanguage()->_($GLOBALS["COM_NAME"] . '_ERR_FILE_TOO_LARGE')); } $this->DebugLog->Write("File size ({$size} / {$max}) is ok"); // Clean file name $filename = preg_replace("/[^\\w\\.-_]/", "_", $this->get_file_name()); // Assign a random unique id to the file name, to avoid that lamers can force the server to execute their uploaded shit $filename = uniqid() . "-" . $filename; $full_filename = $uploadDirectory . $filename; if (!$this->save_file($full_filename)) { $this->DebugLog->Write("Error saving file"); return array('error' => JFactory::getLanguage()->_($GLOBALS["COM_NAME"] . '_ERR_SAVE_FILE')); } $this->DebugLog->Write("File saved"); $mimetype = new FMimeType(); if (!$mimetype->Check($full_filename, $this->Params)) { // Delete the file uploaded unlink($full_filename); $this->DebugLog->Write("File type [" . $mimetype->Mimetype . "] is not allowed. Allowed types are:" . PHP_EOL . print_r($mimetype->Allowed, true)); return array('error' => JFactory::getLanguage()->_($GLOBALS["COM_NAME"] . '_ERR_MIME') . " [" . $mimetype->Mimetype . "]"); } $this->DebugLog->Write("File type [" . $mimetype->Mimetype . "] is allowed"); $cid = JFactory::getApplication()->input->get("cid", NULL); $mid = JFactory::getApplication()->input->get("mid", NULL); $owner = JFactory::getApplication()->input->get("owner", NULL); $id = JFactory::getApplication()->input->get("id", NULL); $jsession = JFactory::getSession(); $fsession = new FSession($jsession->getId(), $cid, $mid); // Store the answer in the session $data = $fsession->Load('filelist'); // Read the list from the session if ($data) { $filelist = explode("|", $data); } else { $filelist = array(); } $filelist[] = $filename; // Append this file to the list $data = implode("|", $filelist); $fsession->Save($data, "filelist"); $this->Log->Write("File " . $filename . " uploaded succesful."); $this->DebugLog->Write("File uploaded succesful."); return array("success" => true); }