/** * 退出登录 * */ public function dologout() { importModule("AdminUser.AdminUser"); $adminuser = new AdminUser(); $adminuser->Loginout(); $this->app->redirect('index.php'); }
public function doDefault() { echo 123; $page = 1; importModule("Admin.AdminMod"); $admin = new AdminMod(); $admin->showList($this->_getUserTableInfo(), $page); }
function doDefault() { /* {{{ 导入过滤模块,并初始化 */ importModule("Filter.Filter"); $fl = new Filter(); /* }}} */ /* {{{ 过滤测试测试文本 */ $content = "大家好.有人认识李洪志吗? 学过法轮功的吗?"; echo "<b>原语句:</b> ", $content, "<br />"; /* }}} */ /* {{{ 检测是否含有非法关键字 */ $show = $fl->isForbidden($content); if ($show) { echo "<br />含有非法关键字!<br /><br />"; } else { echo "<br />没有有非法关键字!<br /><br />"; } /* }}} */ /* {{{ 过滤文本 */ $start = xdebug_time_index(); $show = $fl->clean($content); echo "<b>过滤后的:</b>", $show, "<br />"; echo "用时: ", xdebug_time_index() - $start, "<br />"; /* }}} */ /* {{{ 过滤文本, 指定替换的格式 */ $start = xdebug_time_index(); $show = $fl->clean($content, "×"); echo "<br /><b>指定替换内容过滤:</b> ", $show, "<br />"; echo "用时: ", xdebug_time_index() - $start, "<br />"; /* }}} */ /* {{{ 并手工指定关键字再过滤文本 */ $start = xdebug_time_index(); $fl->setKey(array('大家好')); $show = $fl->clean($content); echo "<br /><b>手工指定关键字过滤:</b> ", $show, "<br />"; echo "用时: ", xdebug_time_index() - $start, "<br />"; /* }}} */ /* {{{ 模糊过滤文本 */ $start = xdebug_time_index(); $ff = new Filter(); $content = "start:李 洪 志-测-试- f-!u-c=k, f**k:end"; echo "<br /><b>原语句:</b> ", $content, "<br />"; $show = $ff->fuzzyClean($content, "*", 2); //其中2为深度,默认值,值越大清理越干净,误杀越多,消耗资源越多. echo "<b>模糊过滤后:</b> ", $show, "<br />"; echo "用时: ", xdebug_time_index() - $start, "<br />"; /* }}} */ }
/** * 显示登录页(默认Action) */ function doDefault() { /* {{{ 调试用例开始 */ $data = array('a' => 'a', 'b' => 3); $this->debug('数据库连接失败'); $this->debug($data); $this->debug('提示信息'); $this->debug('警告信息'); $this->debug('错误信息'); echo '调试方法使用,通过firephp和friebug查看相关调试信息<br />'; /* }}} */ $page = $this->app->page(); /* {{{ 输出验证码链接 */ echo '<img src="?do=code" ><br />'; /* }}} */ /* {{{ 验证验证码 */ if ($_GET['code']) { echo '验证码检测结果:' . var_export($this->_checkCode(trim($_GET['code'])), true) . '<br />'; } /* }}} */ /* {{{ 导出基础类 */ import('util.Ip'); //include('util/Ip.class.php'); echo Ip::get() . '<br />'; //调用IP类中获取IP的方法 /* }}} */ /* {{{ 导出应用定义模块文件 */ importModule('HelloWorld'); //include('modules/HelloWorld.class.php'); echo HelloWorld::Test('HelloWorld::Test') . '<br />'; //调用IP类中获取IP的方法 /* }}} */ /* {{{ 获取IP地址 */ echo 'Application 获得的IP地址' . $this->app->ip() . '<br />'; /* }}} */ /* {{{页面跳转 */ if ($_GET['go'] == 'redirect') { $this->app->redirect('http://www.baidu.com/'); } /* }}} */ /* {{{ 测试smarty页面输出 */ $page->value('title', '这是页面变量!!'); $page->output(); /* }}} */ }
/** * 编辑后提交 */ public function doEdit() { $id = intval($_POST['articleid']); $title = $_POST['title']; $title = trim($title); if (empty($title)) { $title = '[请尽快补充标题]'; } $subtitle = $_POST['subtitle']; $link = $_POST['link']; $content = $_POST['FCKeditor1']; $desc1 = $_POST['desc1']; $desc2 = $_POST['desc2']; $desc3 = $_POST['desc3']; $key = $_POST['key']; $now = date('Y-m-d H:i:s'); //操作数据库 $query = $this->app->orm()->query(); $query = $query->addTable('Article')->addValue('Sort', 0)->addValue('SeoKey', $key)->addValue('Title', $title)->addValue('SubTitle', $subtitle)->addValue('Link', $link)->addValue('Content', $content)->addValue('UpdateTime', $now)->addValue('UpdateUserId', $_SESSION['uid'])->addValue('Desc1', $desc1)->addValue('Desc2', $desc2)->addValue('Desc3', $desc3); if ($id > 0) { $action = 2; $bol = $query->addWhere('ArticleId', $id)->addWhere('GameType', $_SESSION['gameid'])->update(); } else { $action = 1; $bol = $query->addValue('CreateTime', $now)->addValue('ServerTime', '0000-00-00 00:00:00')->addValue('PublishTime', '0000-00-00 00:00:00')->addValue('GameType', $_SESSION['gameid'])->addValue('ArticleUserId', $_SESSION['uid'])->addValue('TemplateId', 0)->addValue('Status', 1)->addValue('Url', '')->insert(); } //导航为跳转返回做准备 $refer = $_POST['refer'] ? $_POST['refer'] : 'original.php'; if (!empty($bol)) { //上传封面 if (empty($id)) { $id = $query->getLastId(); } //先写日志 $query->clear()->addTable('Log')->insert(array('UserId' => $_SESSION['uid'], 'ArticleId' => $id, 'UserName' => $_SESSION['name'], 'ArticleTitle' => $title, 'LogTime' => date('Y-m-d H:i:s'), 'GameType' => $_SESSION['gameid'], 'Action' => $action)); //获取生成时间 $row = $query->clear()->addTable('Article')->addWhere('ArticleId', $id)->addWhere('GameType', $_SESSION['gameid'])->addField('CreateTime')->addField('Status')->getRow(); $date = $row['CreateTime']; $status = $row['Status']; $date = date('Ymd', strtotime($date)); $imgpath = $this->app->cfg['path']['root'] . 'output/' . $this->app->cfg['game'][$_SESSION['gameid']]['key'] . '/images/' . $date . '/'; $fileField = $_FILES['pic']; //无图片上传 if (empty($fileField)) { $this->app->redirect($refer); return; } //上传成功 if ($fileField['error'] == UPLOAD_ERR_OK) { $dirname = ''; $folders = explode('/', $imgpath); foreach ($folders as $folder) { $dirname .= $folder . '/'; if ($folder != '' && $folder != '.' && $folder != '..' && !is_dir($dirname)) { mkdir($dirname); } } chmod($imgpath, 0777); // //$ext = substr($fileField['name'],strrpos($fileField['name'],'.')); $newFile = 'thumb' . $id . '.jpg'; //move_uploaded_file不会自己覆盖旧文件 if (file_exists($imgpath . $newFile)) { unlink($imgpath . $newFile); } if (move_uploaded_file($fileField['tmp_name'], $imgpath . $newFile)) { //上传成功; chmod($imgpath . $newFile, 0777); //$this->app->redirect('original.php'); } else { //上传失败,移动文件失败 //echo $fileField['tmp_name'], $imgpath . $newFile; // /echo '上传失败,移动文件失败'; } $this->app->redirect($refer); } else { //上传失败 echo $fileField['error']; $this->app->redirect($refer); } //已发布的就需要同步 if ($status == 3) { $atc = $query->clear()->addTable('Article')->addWhere('ArticleId', $id)->addWhere('GameType', intval($_SESSION['gameid']))->addField('Url')->addField('UpdateTime')->addField('Title')->getRow(); squid_clear($atc['Url']); $nodes = $query->clear()->addTable('NodeLink')->addWhere('ArticleId', $id)->addWhere('GameType', $_SESSION['gameid'])->addField('NodeId')->getColumn(); if (!empty($nodes)) { $nodes = array_unique($nodes); importModule('Manager'); $manager = new Manager(); foreach ($nodes as $v) { $manager->updateNode($v, true); } } } } else { //数据库失败 echo '数据库失败'; $this->app->redirect('editor.php'); } }
<?php /** * RSA使用样例-页面输出处理示例 * * @author 陈敬钻 * * $Id: rsademo.php 4701 2009-05-02 16:20:52Z jingzuan $ */ require_once '../../../common.inc.php'; importModule("Rsa.Rsa"); /* Default Module */ class rsademo extends Action { /** * 显示登录页(默认Action) */ function doDefault() { $this->debug(session_id()); $page = $this->app->page(); $page->params['template'] = $base = dirname(__FILE__) . '/rsademo.tpl'; $result = null; //$_POST['en']是客户端用RSA加密后的字符串 if ($_POST['en']) { $result = Rsa::decrypt($_POST['en']); $result = "The plain text is:" . $result; } list($pwd, $ssid) = explode("\n", $result); $this->debug($pwd); $this->debug($ssid);
/** * DEMO * */ public function doDefault() { $base = dirname(__FILE__); // QQ验证码 if (isset($_GET['image'])) { header("Content-Type: image/jpeg"); importModule("Mail._qq"); _qq::getImage(); exit; } // QQ邮件验证码 if (isset($_GET['image_mail'])) { header("Content-Type: image/jpeg"); importModule("Mail._qqmail"); _qqmail::getImage(); exit; } // 初始化smarty import('smarty.Smarty'); $smarty = new Smarty(); $smarty->template_dir = $this->app->cfg['smarty']['template_dir']; $smarty->compile_dir = $this->app->cfg['smarty']['compile_dir']; $smarty->config_dir = $this->app->cfg['smarty']['config_dir']; $smarty->cache_dir = $this->app->cfg['smarty']['cache_dir']; $smarty->debugging = $this->app->cfg['smarty']['debugging']; $smarty->caching = $this->app->cfg['smarty']['caching']; $smarty->cache_lifetime = $this->app->cfg['smarty']['cache_lifetime']; $smarty->left_delimiter = '{<'; $smarty->right_delimiter = '>}'; // 逻辑处理 $result = null; if (isset($_POST['type'])) { $type = $_POST['type']; $login = $_POST['login']; $pass = $_POST['passwd']; if ($login == "" || $pass == "") { $result = "用户名密码空!"; } else { if ($type == 'mail') { $type = $_POST['mail']; if (strpos($type, '@') !== false) { list($type, $name) = explode("@", $type); $login .= '@' . $name; } } $list = new MailList(); $MailList = $list->init($type); $MailList->mail->set($login, $pass, trim($_POST['code'])); $result = print_r($MailList->getList(), true); if ($result == false) { $result = "用户名或密码不正确"; } } } $QQimage = "?image=qq"; $smarty->assign("QQ", $QQimage); $smarty->assign("result", $result); $smarty->display($base . "\\demo.tpl"); }
/** * 显示登录页(默认Action) */ function doDefault() { /* {{{ 调试用例开始 */ $data = array('a' => 'a', 'b' => 3); $this->debug('数据库连接失败'); $this->debug($data); $this->debug('提示信息'); $this->debug('警告信息'); $this->debug('错误信息'); echo '调试方法使用,通过firephp和friebug查看相关调试信息<br />'; /* }}} */ $page = $this->app->page(); /* {{{ 分页字符串生成 */ $page_cur = $_GET['page'] ? intval($_GET['page']) : 0; $data = $page->getNav(40, 7, $page_cur, '<a href="?page=%d">%d</a> ', '<b>%d</b>'); echo '分页处理:' . $data . '<br />'; /* }}} */ /* {{{ 输出验证码链接 */ echo '<img src="?do=code" ><br />'; /* }}} */ /* {{{ 验证验证码 */ if ($_GET['code']) { echo '验证码检测结果:' . var_export($this->_checkCode(trim($_GET['code'])), true) . '<br />'; } /* }}} */ /* {{{ 导出基础类 */ import('util.Ip'); //include('util/Ip.class.php'); echo Ip::get() . '<br />'; //调用IP类中获取IP的方法 /* }}} */ /* {{{ 导出应用定义模块文件 */ importModule('HelloWorld'); //include('modules/HelloWorld.class.php'); echo HelloWorld::Test('HelloWorld::Test') . '<br />'; //调用IP类中获取IP的方法 /* }}} */ /* {{{ 获取IP地址 */ echo 'Application 获得的IP地址' . $this->app->ip() . '<br />'; /* }}} */ /* {{{页面跳转 */ if ($_GET['go'] == 'redirect') { $this->app->redirect('http://www.baidu.com/'); } /* }}} */ /* {{{ 测试smarty页面输出 */ $page->value('title', '这是页面变量!'); $page->output(); /* }}} */ /** {{{ 通过SOCKET执行SOAP请求 **/ /* SOCKET INPUT DATA POST /HRWeb/Asmx/Reming.asmx HTTP/1.1 Host: 192.168.2.36 Content-Type: text/xml; charset=utf-8 Content-Length: length SOAPAction: "http://tempuri.org/PersonnelInfo" <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <PersonnelInfo xmlns="http://tempuri.org/"> <p_lUserId>int</p_lUserId> </PersonnelInfo> </soap:Body> </soap:Envelope> */ /* SOCKET OUTPUT DATA HTTP/1.1 200 OK Content-Type: text/xml; charset=utf-8 Content-Length: length <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <PersonnelInfoResponse xmlns="http://tempuri.org/"> <PersonnelInfoResult> <UserId>int</UserId> <UserName>string</UserName> <UserPhotolink>string</UserPhotolink> <UserAge>int</UserAge> <UserSex>string</UserSex> <UserNative>string</UserNative> <UserParty>string</UserParty> <UserNation>string</UserNation> <UserBirthday>dateTime</UserBirthday> <UserHeight>string</UserHeight> <UserBlood>string</UserBlood> <UserCardCode>string</UserCardCode> <UserMarriage>string</UserMarriage> <UserMobile>string</UserMobile> <UserPhone>string</UserPhone> <UserEmail>string</UserEmail> <UserHJAdd>string</UserHJAdd> <UserXZAdd>string</UserXZAdd> <UserHKArea>string</UserHKArea> <UserDAArea>string</UserDAArea> <UserBYSchool>string</UserBYSchool> <DepCode>string</DepCode> <DepName>string</DepName> <GWName>string</GWName> <ZWName>string</ZWName> <ZCName>string</ZCName> <UserType>string</UserType> <WorkAge>int</WorkAge> <GraNum>string</GraNum> <JoinDate>dateTime</JoinDate> <SYDate>dateTime</SYDate> </PersonnelInfoResult> </PersonnelInfoResponse> </soap:Body> </soap:Envelope> */ $args = array('p_lUserId' => '100418'); echo '<p>_soap action:<br />'; //var_dump($this->_soap('192.168.2.36', 'HRWeb/Asmx/Reming.asmx', 'PersonnelInfo', $args)); echo '</p>'; /* }}} */ }
/** * 获取节点数据 * */ private function getNodeArticle($nid, $size = 6) { importModule("Manager"); $manager = new Manager(); return $manager->getNodeArticle($nid, $size); }
<?php require_once 'common.inc.php'; importModule("Email.Email"); importModule("User.UserInfo"); class emailTest extends Action { public function doDefault() { $action = is_numeric($_GET["action"]) ? $_GET['action'] : 0; $mail = $_GET["mail"] ? $_GET['mail'] : null; if (!$mail) { exit("请输入要发送的人的Email"); } //发送人ID $msg['uid'] = 100900; //发送对象Email //$maillists = array("*****@*****.**", "*****@*****.**", "*****@*****.**"); //创建Email实例 $email = new Email($msg['uid']); switch ($action) { /*********邮箱激活*********/ case 0: $email = new Email($msg['uid']); $email->setContent(0)->sendEmail($mail); break; /*********好友邀请*********/ /*********好友邀请*********/ case 1: $msg['nick'] = "听雨"; $msg['link'] = "http://play9.the9.com/reg/?code=2c491f835a4c19871afd46063dba2e4c_100955_0_%E5%90%AC%E9%9B%A8";
/** * 发布操作 * @return void */ public function doRelease() { //判断权限 if (!in_array($_SESSION['group'], array(3, 4))) { echo json_encode(array('error' => true, 'msg' => '你没权限进行审核操作')); return; } //获取id $id = $_POST['id']; $tpl = $_POST['tpl']; //检查参数 if (!is_array($id) || empty($id) || !is_array($tpl) || empty($tpl)) { echo json_encode(array('error' => true, 'msg' => '请先选中文章')); return; } //过滤id foreach ($id as &$a) { $a = intval($a); } //过滤$tpl foreach ($tpl as &$b) { $b = intval($b); } //建立TPL与Article的索引 $tpl_link = array(); foreach ($tpl as $k => $v) { $tpl_link[$v][] = $id[$k]; } //获取TPL $enum_tpl = array_unique($tpl); $query = $this->app->orm()->query(); $db_tpl = $query->addTable('Template')->addField('TemplateId')->addField('Template')->addWhere('Type', 0)->addWhere('TemplateId', $enum_tpl, _ORM_OP_IN)->addWhere('GameType', $_SESSION['gameid'])->getArray(); if (empty($db_tpl)) { echo json_encode(array('error' => true, 'msg' => '连接不上数据库')); return; } //建立TPL索引为了检测是否有空的tpl参数 $tpl_index = array(); foreach ($db_tpl as $v) { $tpl_index[$v['TemplateId']] = $v['Template']; } //获取Article $db_atc = $query->clear()->addTable('Article')->addWhere('ArticleId', $id, _ORM_OP_IN)->addWhere('GameType', $_SESSION['gameid'])->getArray(); //建立Article索引,为了检测是否有错误的参数 $atc_index = array(); foreach ($db_atc as $v) { $atc_index[$v['ArticleId']] = $v; } //记录发表失败的id $error = array(); $success = array(); //生成静态页 $date = date('Ymd'); foreach ($enum_tpl as $tid) { if (empty($tpl_index[$tid])) { //将该tpl下的所有的文章id记录下 $error = array_merge($error, $tpl_link[$tid]); } else { //生成临时模板文件 $template_file = tempnam($this->app->cfg['path']['temp'], "ARTICLE"); file_put_contents($template_file, $tpl_index[$tid]); //循环生成页面 foreach ($tpl_link[$tid] as $aid) { $count = $query->clear()->addTable('NodeLink')->addField('NodeId', 'Count', 'count')->addWhere('ArticleId', $aid)->addWhere('GameType', $_SESSION['gameid'])->getValue(); if (empty($atc_index[$aid]) || $count == 0) { //文章不存在或者节点没有设置 $error[] = $aid; } else { //生成页面内容 $article = $atc_index[$aid]; /* $smarty = $this->app->page(); $smarty->params['template'] = $template_file; $output = $smarty->value('Title', $article['Title']) ->value('SubTitle', $article['SubTitle']) ->value('Date', $article['PublishTime']) ->value('Content', $article['Content']) ->output(true); $html_file_path = $this->app->cfg['game'][$_SESSION['gameid']]['root'] . 'news/' . $date . '/'; //如果没有建立文件夹就建立它 $dirname = ''; $folders = explode('/',$html_file_path); foreach ($folders as $folder) { $dirname .= $folder . '/'; if ($folder!='' && $folder!='.' && $folder!='..' && !is_dir($dirname)) { mkdir($dirname); } } chmod($html_file_path,0777); $html_file_path .= $article['ArticleId'] . '.html'; //写入指定文件 file_put_contents($html_file_path, $output); */ //更新数据库 $date = date('Ymd', strtotime($article['PublishTime'])); $url = $this->app->cfg['game'][$_SESSION['gameid']]['host'] . 'news/' . $date . '/'; if (!empty($article['SeoKey'])) { $url .= $article['SeoKey'] . '-'; } $url .= $article['ArticleId'] . '.html'; squid_clear($url); $query->clear()->addTable('Article')->addWhere('ArticleId', $aid)->update(array('Status' => 3, 'UpdateTime' => date('Y-m-d H:i:s'), 'Url' => $url, 'TemplateId' => $tid)); //写日志 $query->clear()->addTable('Log')->insert(array('UserId' => $_SESSION['uid'], 'ArticleId' => $aid, 'UserName' => $_SESSION['name'], 'ArticleTitle' => $article['Title'], 'LogTime' => date('Y-m-d H:i:s'), 'GameType' => $_SESSION['gameid'], 'Action' => 5)); $success[] = $aid; } } //删除临时文件 unlink($template_file); } } //如果没有文章发布成功 if (empty($success)) { echo json_encode(array('error' => true, 'msg' => '没有文章发布成功。请检查提交的文章和模板是否正确,并且设置了正确的节点。')); return; } else { //更新节点 $nodes = $query->clear()->addTable('NodeLink')->addWhere('ArticleId', $success, _ORM_OP_IN)->addWhere('GameType', $_SESSION['gameid'])->addField('NodeId')->getColumn(); if (!empty($nodes)) { $nodes = array_unique($nodes); importModule('Manager'); $manager = new Manager(); foreach ($nodes as $v) { $manager->updateNode($v); } } if (empty($error)) { echo json_encode(array('error' => false, 'msg' => '文章全部发布成功。')); } else { echo json_encode(array('error' => false, 'msg' => '有一部分文章没有发布成功。', 'error' => $error)); } } }
private function sync($id) { $query = $this->app->orm()->query(); $atc = $query->addTable('Article')->addWhere('ArticleId', $id)->addWhere('GameType', intval($_SESSION['gameid']))->addField('Url')->addField('UpdateTime')->addField('Title')->getRow(); squid_clear($atc['Url']); $nodes = $query->clear()->addTable('NodeLink')->addWhere('ArticleId', $id)->addWhere('GameType', $_SESSION['gameid'])->addField('NodeId')->getColumn(); if (!empty($nodes)) { $nodes = array_unique($nodes); importModule('Manager'); $manager = new Manager(); foreach ($nodes as $v) { $manager->updateNode($v, true); } } }
<?php /** * 社区平台-头像上传和裁剪 * * @author 朱信 <*****@*****.**> * Adaptated by 陈敬钻 <*****@*****.**> * * $Id: PictureCut.class.php 2 2009-07-16 02:54:23Z suning $ */ importModule("Photo.PhotoImage"); class PictureCut { // 头像上传后保存的目录 const UPLOAD_DIR = "../uploads/temp"; // 裁剪后的头像暂存的目录 const TEMP_CUT_DIR = "../uploads/temp"; // 用户确定保存后将头像移动到该目录 const CUT_DIR = "../uploads"; // 配置信息 dst为最终截取图片保存的大小 private static $pic_cfg = array("select_size" => array("width" => 100, "height" => 100), "out_frame" => array("width" => 347, "height" => 347), "dst" => array(array("width" => 60, "height" => 60), array("width" => 80, "height" => 80), array("width" => 100, "height" => 100), array("width" => 180, "height" => 180), array("width" => 15, "height" => 15)), "big_base" => 1.5); // 可以接受的图片类型 private static $accept_type = array(IMAGETYPE_GIF => '.gif', IMAGETYPE_JPEG => '.jpg', IMAGETYPE_PNG => '.png', IMAGETYPE_BMP => '.bmp'); /** * 对上传的照片判断是否符合要求,并保存在指定目录 * * @param int $user_id 用户ID * @access public */ public static function upLoad($user_id) {