/**
  * 获取外键数据来源
  * @param string $key 指定key获取
  * @return array|string 获取到的数据或指定key的值
  */
 public function getProject($key = '')
 {
     $projectDB = new ProjectModelDB();
     if (empty($key)) {
         $sql = "SELECT `id`,`name` FROM `" . $projectDB->getTableName() . "` ORDER BY `name`";
         $projectModelDBArr = $projectDB->getData($sql);
         $data = Common::createArr($projectModelDBArr, 'id', 'name');
     } else {
         $sql = "SELECT `name` FROM `" . $projectDB->getTableName() . "` WHERE `id` = ?";
         $data = $projectDB->getFirst($sql, array($key));
     }
     return $data;
 }
 public function error()
 {
     $_GET = array();
     $_GET['id'] = intval($_GET['id']);
     $_GET['password'] = $_GET['password'];
     $_GET['type'] = $_GET['type'];
     $_GET['msg'] = addslashes($_GET['msg']);
     $_GET['msg'] = iconv('gb2312', 'utf-8', $interArray['msg']);
     $_GET['ip'] = $_SERVER['REMOTE_ADDR'];
     if ($_GET['pid'] == "" or $_GET['type_id'] == "" or $_GET['code'] == "" or $_GET['msg'] == "") {
         Message::showError('传入参数有误,请对照文档检查您的传入参数!');
     } else {
         if (!is_numeric($_GET['pid'])) {
             Message::showError('pid错误,不是数字', $_GET['id']);
             return 0;
         }
         //验证id和密码
         $projectDB = new ProjectModelDB();
         $passwd = $projectDB->getRow("SELECT * FROM `" . $projectDB->getTableName() . "` WHERE `id` = " . intval($_GET['id']));
         if ($_GET['password'] != $passwd['password']) {
             Message::showError('您所传入的项目passowrd不正确', $_GET['password']);
             return 0;
         } else {
             //type 是否为现有类型,不是则插入到setting表中;是则将有关id,type,msg写到err_msg表中
             if (!is_numeric(intval($_GET['type_id']))) {
                 Message::showError('type_id错误,不能为非数字类型,请对照后台查询类型号', $_GET['type_id']);
                 return 0;
             } else {
                 $settingsDB = new SettingsModelDB();
                 $sid = $settingsDB->getFirst("SELECT id FROM `" . $settingsDB->getTableName() . "` WHERE `type` = " . intval($_GET['type_id']));
                 if (empty($sid)) {
                     $settingsInsertArr['pid'] = $_GET['id'];
                     $settingsDB->insert($settingsInsertArr);
                 }
                 //不管type是什么都执行以下msg操作!
                 $errMsgDB = new ErrmsgModelDB();
                 $value = $errMsgDB->insertMsg($_GET['id'], intval($interArray['type']), $interArray['msg'], $interArray['ip']);
                 if ($value) {
                     //return true;
                     echo json_encode(array('stat' => 0, 'info' => 'insert message,ok'));
                 } else {
                     Message::showError('写入message时,数据库错误', $value);
                 }
             }
         }
     }
 }
 public function detail()
 {
     $sid = intval($_GET['sub_mid']);
     if (md5(md5(md5(implode('|', array($sid, '!mrala', date('Y-m-d')))))) !== $_GET['sign']) {
         Message::showError('sign fail');
     } else {
         $submoduleDB = new SubmoduleModelDB();
         $submodule = $submoduleDB->getRow('SELECT mid, code, name FROM `' . $submoduleDB->getTableName() . '` WHERE id=?', array(intval($sid)));
         $moduleDB = new ModuleModelDB();
         $module = $moduleDB->getRow('SELECT sys_mid, pid FROM `' . $moduleDB->getTableName() . '` WHERE id=?', array(intval($submodule['mid'])));
         $sysmoduleDB = new SysmoduleModelDB();
         $sysmodule = $sysmoduleDB->getRow('SELECT `name` FROM `' . $sysmoduleDB->getTableName() . '` WHERE id=?', array(intval($module['sys_mid'])));
         $projectDB = new ProjectModelDB();
         $project = $projectDB->getRow('SELECT `name` FROM `' . $projectDB->getTableName() . '` WHERE id=?', array(intval($module['pid'])));
         $this->setView('project', $project);
         $this->setView('sysmodule', $sysmodule);
         $this->setView('submodule', $submodule);
         $this->setView('sub_mid', $sid);
         $this->display('mobile/details.html');
     }
 }
 public function logicResume()
 {
     $projectDB = new ProjectModelDB();
     $updateArr = array('' => 0);
     $whereArr = array();
     $whereArr['id'] = $_GET['id'];
     $rs = $projectDB->update($updateArr, $whereArr);
     Log::write($this->adminUserName, $this->ip, $_GET['id'], self::$state . "__" . self::$action, $rs);
     $rs ? Message::showSucc('恢复成功') : Message::showError('恢复失败:' . implode(" ", $projectDB->getErrorInfo()));
 }
<?php

/**
 * @Copyright (c) 2011, 新浪网运营部-网络应用开发部
 * All rights reserved.
 * 根据新增的系统module,添加到原有项目中
 * @author          wangxin <*****@*****.**>
 * @time            2011/3/2 15:03
 * @version         Id: 0.9
*/
require dirname(__FILE__) . "/global.php";
$moduleDB = new ModuleModelDB();
$sysmoduleDB = new SysmoduleModelDB();
$sysmoduleArr = $sysmoduleDB->getData("SELECT * FROM `" . $sysmoduleDB->getTableName() . "`");
$projectDB = new ProjectModelDB();
$projectArr = $projectDB->getData("SELECT * FROM `" . $projectDB->getTableName() . "`");
foreach ($projectArr as $v) {
    $moduleArr = $moduleDB->getData("SELECT * FROM `" . $moduleDB->getTableName() . "` WHERE `pid` = ?", array($v['id']));
    $moduleIdArr = array();
    foreach ($moduleArr as $vv) {
        $moduleIdArr[] = $vv['sys_mid'];
    }
    foreach ($sysmoduleArr as $vv) {
        if (!in_array($vv['id'], $moduleIdArr)) {
            $insertArr = array();
            $insertArr['pid'] = $v['id'];
            $insertArr['sys_mid'] = $vv['id'];
            $insertArr['level'] = $vv['level'];
            $insertArr['sms_limit'] = $vv['sms_limit'];
            $insertArr['mail_limit'] = $vv['mail_limit'];
            $insertArr['sms_status'] = 1;
define('PATH_ROOT', rtrim(dirname(__FILE__), '/') . '/../');
require PATH_ROOT . 'config/SysInitConfig.php';
//用户配置
require PATH_ROOT . 'libs/DaggerSysInitConfig.php';
//系统配置
require PATH_LIBS . 'basics.php';
//__autoload函数
require PATH_ROOT . 'config/DBConfig.php';
//载入数据库配置
//==========取代global.php功能==========//
$time = time();
$db = new QueueRuntimeModelDB();
$sql = "SELECT * FROM " . $db->getTableName() . " WHERE `begin_time` < ?";
$data = $db->getData($sql, array($time - 60 * 50));
if (!empty($data)) {
    $ndb = new ProjectModelDB();
    $queueConfigDB = new QueueConfigModelDB();
    foreach ($data as $v) {
        $row = $ndb->getRow("SELECT `id`,`key`,`name` FROM `" . $ndb->getTableName() . "` WHERE `id` = ?", array($v['project_id']));
        $task = trim(array_shift(explode(' ', $v['task'])));
        $runTimeConfig = $queueConfigDB->getFirst("SELECT `time` FROM `" . $queueConfigDB->getTableName() . "` WHERE `project_id` = ? AND `task` = ?", array($v['project_id'], $task));
        if (empty($runTimeConfig)) {
            $runTimeConfig = 50;
        }
        $runTime = intval(($time - $v['begin_time']) / 60);
        if ($runTime >= $runTimeConfig) {
            $message = "[{$row['name']}]的队列[{$v['task']}]于[" . date("Y-m-d H:i:s", $v['begin_time']) . "]在[{$v['ip']}]开始运行,目前已超过{$runTime}分钟!";
            // 多个监控点,同一次错误只提醒一次
            $mc = new MyMemcache();
            $mcKey = md5($message . $row['key'] . $row['id']);
            if ($mc->addPlain($mcKey, 1, 50)) {