public function update()
 {
     //$data = M(MODULE_NAME)->create ();
     $data = array();
     $data['id'] = intval($_REQUEST['id']);
     $data['name'] = strim($_REQUEST['name']);
     //$data['content'] = $_REQUEST['content'];
     $data['content'] = stripslashes($_REQUEST['content']);
     $data['is_html'] = intval($_REQUEST['is_html']);
     $return = array('info' => '', 'status' => '0');
     if ($data['name'] == '' || $data['id'] == 0) {
         $info = l("SELECT_MSG_TPL");
         header("Content-Type:text/html; charset=utf-8");
         echo $info;
     }
     $log_info = $data['name'];
     // 更新数据
     $list = M(MODULE_NAME)->save($data);
     if (false !== $list) {
         //成功提示
         save_log($log_info . L("UPDATE_SUCCESS"), 1);
         $info = '"' . L("LANG_" . $data['name']) . '"模板' . L("UPDATE_SUCCESS");
         $return['status'] = 1;
         header("Content-Type:text/html; charset=utf-8");
         echo $info;
     } else {
         //错误提示
         save_log($log_info . L("UPDATE_FAILED"), 0);
         $info = L("LANG_" . $data['name']) . "模板" . L("UPDATE_FAILED");
         $return['status'] = 0;
         header("Content-Type:text/html; charset=utf-8");
         echo $info;
     }
 }
 public function export_csv($page = 1)
 {
     set_time_limit(0);
     $limit = ($page - 1) * intval(app_conf("BATCH_PAGE_SIZE")) . "," . intval(app_conf("BATCH_PAGE_SIZE"));
     $map['ecv_type_id'] = intval($_REQUEST['ecv_type_id']);
     $list = M(MODULE_NAME)->where($map)->limit($limit)->findAll();
     if ($list) {
         register_shutdown_function(array(&$this, 'export_csv'), $page + 1);
         $ecv_value = array('sn' => '""', 'password' => '""', 'money' => '""', 'use_limit' => '""', 'begin_time' => '""', 'end_time' => '""');
         if ($page == 1) {
             $content = iconv("utf-8", "gbk", "序列号,密码,面额,使用数量,生效时间,过期时间");
             $content = $content . "\n";
         }
         foreach ($list as $k => $v) {
             $ecv_value['sn'] = '"' . iconv('utf-8', 'gbk', $v['sn']) . '"';
             $ecv_value['password'] = '******' . iconv('utf-8', 'gbk', $v['password']) . '"';
             $ecv_value['money'] = '"' . iconv('utf-8', 'gbk', format_price($v['money'])) . '"';
             $ecv_value['use_limit'] = '"' . iconv('utf-8', 'gbk', $v['use_limit']) . '"';
             $ecv_value['begin_time'] = '"' . iconv('utf-8', 'gbk', to_date($v['begin_time'])) . '"';
             $ecv_value['end_time'] = '"' . iconv('utf-8', 'gbk', to_date($v['end_time'])) . '"';
             $content .= implode(",", $ecv_value) . "\n";
         }
         header("Content-Disposition: attachment; filename=voucher_list.csv");
         echo $content;
     } else {
         if ($page == 1) {
             $this->error(L("NO_RESULT"));
         }
     }
 }
Example #3
0
 function show()
 {
     global $page, $db, $user, $fs, $proj;
     $page->setTitle($fs->prefs['page_title'] . L('reports'));
     $events = array(1 => L('taskopened'), 13 => L('taskreopened'), 2 => L('taskclosed'), 3 => L('taskedited'), 14 => L('assignmentchanged'), 29 => L('events.useraddedtoassignees'), 4 => L('commentadded'), 5 => L('commentedited'), 6 => L('commentdeleted'), 7 => L('attachmentadded'), 8 => L('attachmentdeleted'), 11 => L('relatedadded'), 12 => L('relateddeleted'), 9 => L('notificationadded'), 10 => L('notificationdeleted'), 17 => L('reminderadded'), 18 => L('reminderdeleted'));
     $user_events = array(30 => L('created'), 31 => L('deleted'));
     $page->assign('events', $events);
     $page->assign('user_events', $user_events);
     $sort = strtoupper(Get::enum('sort', array('desc', 'asc')));
     $where = array();
     $params = array();
     $orderby = '';
     switch (Get::val('order')) {
         case 'type':
             $orderby = "h.event_type {$sort}, h.event_date {$sort}";
             break;
         case 'user':
             $orderby = "user_id {$sort}, h.event_date {$sort}";
             break;
         case 'date':
         default:
             $orderby = "h.event_date {$sort}, h.event_type {$sort}";
     }
     foreach (Get::val('events', array()) as $eventtype) {
         $where[] = 'h.event_type = ?';
         $params[] = $eventtype;
     }
     $where = '(' . implode(' OR ', $where) . ')';
     if ($proj->id) {
         $where = $where . 'AND (t.project_id = ?  OR h.event_type > 29) ';
         $params[] = $proj->id;
     }
     if (($fromdate = Req::val('fromdate')) || Req::val('todate')) {
         $where .= ' AND ';
         $todate = Req::val('todate');
         if ($fromdate) {
             $where .= ' h.event_date > ?';
             $params[] = Flyspray::strtotime($fromdate) + 0;
         }
         if ($todate && $fromdate) {
             $where .= ' AND h.event_date < ?';
             $params[] = Flyspray::strtotime($todate) + 86400;
         } else {
             if ($todate) {
                 $where .= ' h.event_date < ?';
                 $params[] = Flyspray::strtotime($todate) + 86400;
             }
         }
     }
     $histories = array();
     if (count(Get::val('events'))) {
         if (Get::num('event_number') > 0) {
             $db->setLimit(Get::num('event_number'));
         }
         $histories = $db->x->getAll("SELECT h.*, t.*, p.project_prefix\n                                             FROM {history} h\n                                        LEFT JOIN {tasks} t ON h.task_id = t.task_id\n                                        LEFT JOIN {projects} p ON t.project_id = p.project_id\n                                            WHERE {$where}\n                                         ORDER BY {$orderby}", null, $params);
     }
     $page->assign('histories', $histories);
     $page->assign('sort', $sort);
     $page->pushTpl('reports.tpl');
 }
Example #4
0
function send_reminders()
{
    global $db, $fs;
    //we touch the file on every single iteration to avoid
    //the possible restart done by Startremiderdaemon method
    //in class.flyspray.conf
    $notify =& new Notifications();
    $user =& new User(0);
    $now = time();
    $get_reminders = $db->Query("SELECT  r.*, t.*, p.*\n                               FROM  {reminders} r\n                         INNER JOIN  {users}     u ON u.user_id = r.to_user_id\n                         INNER JOIN  {tasks}     t ON r.task_id = t.task_id\n                         INNER JOIN  {projects}  p ON t.project_id = p.project_id\n                              WHERE  t.is_closed = '0' AND r.start_time < ?\n                                                       AND r.last_sent + r.how_often < ?\n                           ORDER BY  r.reminder_id", array(time(), time()));
    while ($row = $db->FetchRow($get_reminders)) {
        $jabber_users = array();
        $email_users = array();
        // Get the user's notification type and address
        $get_details = $db->Query("SELECT  notify_type, jabber_id, email_address\n                                 FROM  {users}\n                                WHERE  user_id = ?", array($row['to_user_id']));
        while ($subrow = $db->FetchRow($get_details)) {
            if ($fs->prefs['user_notify'] == '1' && $subrow['notify_type'] == '1' or $fs->prefs['user_notify'] == '2') {
                $email_users[] = $subrow['email_address'];
            } elseif ($fs->prefs['user_notify'] == '1' && $subrow['notify_type'] == '2' or $fs->prefs['user_notify'] == '3') {
                $jabber_users[] = $subrow['jabber_id'];
            }
        }
        $subject = L('notifyfromfs');
        $message = $row['reminder_message'];
        // Pass the recipients and message onto the notification function
        $notify->SendEmail($email_users, $subject, $message);
        $notify->StoreJabber($jabber_users, $subject, $message);
        // Update the database with the time sent
        $update_db = $db->Query("UPDATE  {reminders}\n                               SET  last_sent = ?\n                             WHERE  reminder_id = ?", array(time(), $row['reminder_id']));
    }
    // send those stored notifications
    $notify->SendJabber();
    unset($notify, $user);
}
 public function run(&$_data)
 {
     $engine = strtolower(C('TMPL_ENGINE_TYPE'));
     $_content = empty($_data['content']) ? $_data['file'] : $_data['content'];
     $_data['prefix'] = !empty($_data['prefix']) ? $_data['prefix'] : C('TMPL_CACHE_PREFIX');
     if ('think' == $engine) {
         // 采用Think模板引擎
         if (!empty($_data['content']) && $this->checkContentCache($_data['content'], $_data['prefix']) || $this->checkCache($_data['file'], $_data['prefix'])) {
             // 缓存有效
             //载入模版缓存文件
             Storage::load(C('CACHE_PATH') . $_data['prefix'] . md5($_content) . C('TMPL_CACHFILE_SUFFIX'), $_data['var'], 'tpl');
         } else {
             $tpl = Think::instance('Think\\Template');
             // 编译并加载模板文件
             $tpl->fetch($_content, $_data['var'], $_data['prefix']);
         }
     } else {
         // 调用第三方模板引擎解析和输出
         if (strpos($engine, '\\')) {
             $class = $engine;
         } else {
             $class = 'Think\\Template\\Driver\\' . ucwords($engine);
         }
         if (class_exists($class)) {
             $tpl = new $class();
             $tpl->fetch($_content, $_data['var']);
         } else {
             // 类没有定义
             E(L('_NOT_SUPPORT_') . ': ' . $class);
         }
     }
 }
 /**
  *  显示菜单
  */
 public function index()
 {
     if (empty($_REQUEST['cid'])) {
         $navcat = $this->navcat_model->find();
         $cid = $navcat['navcid'];
     } else {
         $cid = $_REQUEST['cid'];
     }
     $result = $this->nav_model->where("cid={$cid}")->order(array("listorder" => "ASC"))->select();
     import("Tree");
     $tree = new \Tree();
     $tree->icon = array('&nbsp;&nbsp;&nbsp;│ ', '&nbsp;&nbsp;&nbsp;├─ ', '&nbsp;&nbsp;&nbsp;└─ ');
     $tree->nbsp = '&nbsp;&nbsp;&nbsp;';
     foreach ($result as $r) {
         $r['str_manage'] = '<a href="' . U("nav/add", array("parentid" => $r['id'], "cid" => $r['cid'])) . '">' . L('ADD_SUB_NAV') . '</a> | <a href="' . U("nav/edit", array("id" => $r['id'], "parentid" => $r['parentid'], "cid" => $r['cid'])) . '">' . L('EDIT') . '</a> | <a class="js-ajax-delete" href="' . U("nav/delete", array("id" => $r['id'])) . '">' . L('DELETE') . '</a> ';
         $r['status'] = $r['status'] ? L('DISPLAY') : L('HIDDEN');
         $array[] = $r;
     }
     $tree->init($array);
     $str = "<tr>\r\n\t\t\t\t<td><input name='listorders[\$id]' type='text' size='3' value='\$listorder' class='input input-order'></td>\r\n\t\t\t\t<td>\$id</td>\r\n\t\t\t\t<td >\$spacer\$label</td>\r\n\t\t\t    <td>\$status</td>\r\n\t\t\t\t<td>\$str_manage</td>\r\n\t\t\t</tr>";
     $categorys = $tree->get_tree(0, $str);
     $this->assign("categorys", $categorys);
     $cats = $this->navcat_model->select();
     $this->assign("navcats", $cats);
     $this->assign("navcid", $cid);
     $this->display();
 }
Example #7
0
 public function loginoutOp()
 {
     session_unset();
     session_destroy();
     setNcCookie('goodsnum', '', -3600);
     showDialog(L('login_logout_success'), '', 'succ', '', 2);
 }
Example #8
0
function B($a)
{
    if (C($a)) {
        $this->D($a);
    } elseif ($a instanceof E) {
        $a->F($this);
    } elseif (G($a)) {
    } elseif (H($a)) {
        I($a);
        foreach ($a as $b => $c) {
            if (J($b)) {
                if (!H($c) || !L('M', $c) || !L('O', $c)) {
                    throw new P('Q');
                }
                $d = isset($c['R']) ? $c['R'] : [];
                $b = $c['M'];
                $c = $c['O'];
            } elseif (H($c) && L('O', $c)) {
                $d = isset($c['R']) ? $c['R'] : [];
                $c = $c['O'];
            } else {
                $d = [];
            }
            $this->AB($b);
            $this->AC($d);
            $this->B($c);
            $this->AE();
        }
    } elseif (AF($a)) {
        throw new P('AH' . AI($a));
    }
}
Example #9
0
 /**
  * 日志搜索
  */
 public function search_log()
 {
     $where = '';
     extract($_GET['search'], EXTR_SKIP);
     if ($username) {
         $where .= $where ? " AND username='******'" : " username='******'";
     }
     if ($module) {
         $where .= $where ? " AND module='{$module}'" : " module='{$module}'";
     }
     if ($start_time && $end_time) {
         $start = $start_time;
         $end = $end_time;
         $where .= "AND `time` >= '{$start}' AND `time` <= '{$end}' ";
     }
     $page = isset($_GET['page']) && intval($_GET['page']) ? intval($_GET['page']) : 1;
     $infos = $this->db->listinfo($where, $order = 'logid DESC', $page, $pages = '12');
     $pages = $this->db->pages;
     //模块数组
     $module_arr = array();
     $modules = getcache('modules', 'commons');
     $default = $module ? $module : L('open_module');
     //未设定则显示 不限模块 ,设定则显示指定的
     foreach ($modules as $module => $m) {
         $module_arr[$m['module']] = $m['module'];
     }
     include $this->admin_tpl('log_search_list');
 }
Example #10
0
 public function update()
 {
     $conf_res = M("Conf")->where("is_effect = 1 and is_conf = 1")->findAll();
     foreach ($conf_res as $k => $v) {
         conf($v['name'], $_REQUEST[$v['name']]);
         if ($v['name'] == 'URL_MODEL' && $v['value'] != $_REQUEST[$v['name']]) {
             clear_dir_file(get_real_path() . "public/runtime/app/data_caches/");
             clear_dir_file(get_real_path() . "public/runtime/app/tpl_caches/");
             clear_dir_file(get_real_path() . "public/runtime/app/tpl_compiled/");
             clear_dir_file(get_real_path() . "public/runtime/app/data_caches/");
             clear_dir_file(get_real_path() . "public/runtime/data/page_static_cache/");
             clear_dir_file(get_real_path() . "public/runtime/data/dynamic_avatar_cache/");
         }
     }
     //开始写入配置文件
     $sys_configs = M("Conf")->findAll();
     $config_str = "<?php\n";
     $config_str .= "return array(\n";
     foreach ($sys_configs as $k => $v) {
         $config_str .= "'" . $v['name'] . "'=>'" . addslashes($v['value']) . "',\n";
     }
     $config_str .= ");\n ?>";
     $filename = get_real_path() . "public/sys_config.php";
     if (!($handle = fopen($filename, 'w'))) {
         $this->error(l("OPEN_FILE_ERROR") . $filename);
     }
     if (fwrite($handle, $config_str) === FALSE) {
         $this->error(l("WRITE_FILE_ERROR") . $filename);
     }
     fclose($handle);
     save_log(l("CONF_UPDATED"), 1);
     //clear_cache();
     write_timezone();
     $this->success(L("UPDATE_SUCCESS"));
 }
 public function getType()
 {
     //$map = "uid = 0 or uid = ".$this->mid;
     //$friendType = D("FriendGroup")->where($map)->field("id,name")->findAll();
     $typeId = array(array('id' => 1, 'name' => L('follow_each_other')), array('id' => 2, 'name' => L('following')), array('id' => 3, 'name' => L('follower')));
     echo json_encode($typeId);
 }
Example #12
0
 public function __construct()
 {
     $this->contentid = isset($_GET['contentid']) && trim(urldecode($_GET['contentid'])) ? trim(urldecode($_GET['contentid'])) : $this->_show_msg(L('illegal_parameters'));
     $this->contentid = safe_replace($this->contentid);
     $this->db = Loader::model('digg_model');
     $this->db_log = Loader::model('digg_log_model');
 }
 /**
  * 我的收藏页面
  */
 public function index()
 {
     $map['uid'] = $GLOBALS['ts']['uid'];
     $weiboSet = model('Xdata')->get('admin_Config:feed');
     $this->assign($weiboSet);
     // TODO:后续可能由表中获取语言KEY
     $d['tabHash'] = array('feed' => L('PUBLIC_WEIBO'));
     $d['tab'] = model('Collection')->getCollTab($map);
     $this->assign($d);
     // 安全过滤
     $t = t($_GET['t']);
     !empty($t) && ($map['source_table_name'] = $t);
     $key = t($_POST['collection_key']);
     if ($key === '') {
         $list = model('Collection')->getCollectionList($map, 20);
     } else {
         $list = model('Collection')->searchCollections($key, 20);
         $this->assign('collection_key', $key);
         $this->assign('jsonKey', json_encode($key));
     }
     $this->assign($list);
     $this->setTitle(L('PUBLIC_COLLECTION_INDEX'));
     // 我的收藏
     // 是否有返回按钮
     $this->assign('isReturn', 1);
     // 获取用户统计信息
     $userData = model('UserData')->getUserData($GLOBALS['ts']['mid']);
     $this->assign('favoriteCount', $userData['favorite_count']);
     $userInfo = model('User')->getUserInfo($this->mid);
     $this->setTitle('我的收藏');
     $this->setKeywords($userInfo['uname'] . '的收藏');
     $this->display();
 }
Example #14
0
 public function init()
 {
     $page = isset($_GET['page']) && intval($_GET['page']) ? intval($_GET['page']) : 1;
     $userid = param::get_cookie('_userid');
     $sql = " `userid` = '{$userid}'";
     if (isset($_GET['dosubmit'])) {
         $type = isset($_GET['type']) && intval($_GET['type']) ? intval($_GET['type']) : '';
         $endtime = isset($_GET['endtime']) && trim($_GET['endtime']) ? strtotime(trim($_GET['endtime'])) : '';
         $starttime = isset($_GET['starttime']) && trim($_GET['starttime']) ? strtotime(trim($_GET['starttime'])) : '';
         if (!empty($starttime) && empty($endtime)) {
             $endtime = SYS_TIME;
         }
         if (!empty($starttime) && !empty($endtime) && $endtime < $starttime) {
             showmessage(L('wrong_time_over_time_to_time_less_than'));
         }
         if (!empty($starttime)) {
             $sql .= $sql ? " AND `creat_at` BETWEEN '{$starttime}' AND '{$endtime}' " : " `creat_at` BETWEEN '{$starttime}' AND '{$endtime}' ";
         }
         if (!empty($type)) {
             $sql .= $sql ? " AND `type` = '{$type}' " : " `type` = '{$type}'";
         }
     }
     $list = $this->spend_db->listinfo($sql, '`id` desc', $page);
     $pages = $this->spend_db->pages;
     include template('pay', 'spend_list');
 }
Example #15
0
 /**
  * return_url get形式响应
  */
 public function respond_get()
 {
     if ($_GET['code']) {
         $payment = $this->get_by_code($_GET['code']);
         if (!$payment) {
             showmessage(L('payment_failed'));
         }
         $cfg = unserialize_config($payment['config']);
         $pay_name = ucwords($payment['pay_code']);
         pc_base::load_app_class('pay_factory', '', 0);
         $payment_handler = new pay_factory($pay_name, $cfg);
         $return_data = $payment_handler->receive();
         if ($return_data) {
             if ($return_data['order_status'] == 0) {
                 $this->update_member_amount_by_sn($return_data['order_id']);
             }
             $this->update_recode_status_by_sn($return_data['order_id'], $return_data['order_status']);
             showmessage(L('pay_success'), APP_PATH . 'index.php?m=pay&c=deposit');
         } else {
             showmessage(L('pay_failed'), APP_PATH . 'index.php?m=pay&c=deposit');
         }
     } else {
         showmessage(L('pay_success'));
     }
 }
Example #16
0
 function insert()
 {
     $rid = $_POST['rid'];
     $nid = $_POST['nid'];
     if (!empty($rid)) {
         if ($nid) {
             $node_id = implode(',', $nid);
             $node = M('Node');
             $list = $node->where('id in(' . $node_id . ')')->select();
             $this->dao->where('role_id = ' . $rid)->delete();
             foreach ($list as $key => $node) {
                 $data[$key]['role_id'] = $rid;
                 $data[$key]['node_id'] = $node['id'];
                 $data[$key]["level"] = $node['level'];
                 $data[$key]["pid"] = $node['pid'];
             }
             $r = $this->dao->addAll($data);
         } else {
             $r = $this->dao->where('role_id = ' . $rid)->delete();
         }
         if (false !== $r) {
             $this->success(L('role_ok'));
         } else {
             $this->error(L('role_error'));
         }
     } else {
         $this->error(L('do_empty'));
     }
 }
 public function index()
 {
     $name = I("name", '');
     //get.startdatetime
     //		$startdatetime = I('startdatetime',date('Y/m/d H:i',time()-24*3600),'urldecode');
     //		$enddatetime = I('enddatetime',date('Y/m/d H:i',time()+24*3600),'urldecode');
     //分页时带参数get参数
     $params = array('name' => $name);
     $map = array();
     $map['post_author'] = UID;
     $map['name'] = array('like', '%' . $name . '%');
     $page = array('curpage' => I('get.p', 0), 'size' => C('LIST_ROWS'));
     $order = " post_modified desc ";
     //
     $result = apiCall('Admin/Post/query', array($map, $page, $order, $params));
     //
     if ($result['status']) {
         $this->assign('name', $name);
         $this->assign('show', $result['info']['show']);
         $this->assign('list', $result['info']['list']);
         $this->display();
     } else {
         LogRecord('INFO:' . $result['info'], '[FILE] ' . __FILE__ . ' [LINE] ' . __LINE__);
         $this->error(L('UNKNOWN_ERR'));
     }
 }
 public function run(&$_data)
 {
     $engine = strtolower(C('TMPL_ENGINE_TYPE'));
     $_content = empty($_data['content']) ? $_data['file'] : $_data['content'];
     $_data['prefix'] = !empty($_data['prefix']) ? $_data['prefix'] : C('TMPL_CACHE_PREFIX');
     if ('think' == $engine) {
         // 采用Think模板引擎
         if (!empty($_data['content']) && $this->checkContentCache($_data['content'], $_data['prefix']) || $this->checkCache($_data['file'], $_data['prefix'])) {
             // 缓存有效
             // 分解变量并载入模板缓存
             extract($_data['var'], EXTR_OVERWRITE);
             //载入模版缓存文件
             include C('CACHE_PATH') . $_data['prefix'] . md5($_content) . C('TMPL_CACHFILE_SUFFIX');
         } else {
             $tpl = Think::instance('ThinkTemplate');
             // 编译并加载模板文件
             $tpl->fetch($_content, $_data['var'], $_data['prefix']);
         }
     } else {
         // 调用第三方模板引擎解析和输出
         $class = 'Template' . ucwords($engine);
         if (class_exists($class)) {
             $tpl = new $class();
             $tpl->fetch($_content, $_data['var']);
         } else {
             // 类没有定义
             throw_exception(L('_NOT_SUPPERT_') . ': ' . $class);
         }
     }
 }
Example #19
0
 public function run(&$params)
 {
     $lang = $group_lang = $module_lang = array();
     $lang_dir = LANG_PATH . C('DEFAULT_LANG');
     // 读取项目公共语言包
     if (is_file($lang_dir . '/common.php')) {
         $lang = (include $lang_dir . '/common.php');
     }
     // 读取当前分组公共语言包
     if (defined('GROUP_NAME')) {
         $group_lang_file = $lang_dir . '/' . GROUP_NAME . '/common.php';
         if (is_file($group_lang_file)) {
             $group_lang = (include $group_lang_file);
         }
     }
     // 读取当前模块语言包
     $module_lang_file = $lang_dir . '/' . GROUP_NAME . '/' . MODULE_NAME . '.php';
     if (is_file($module_lang_file)) {
         $module_lang = (include $module_lang_file);
     }
     $lang = array_merge($lang, $group_lang, $module_lang);
     $js_lang = isset($lang['js_lang']) ? $lang['js_lang'] : array();
     $module_js_lang = isset($lang['js_lang_' . MODULE_NAME]) ? $lang['js_lang_' . MODULE_NAME] : array();
     $lang['js_lang'] = array_merge($js_lang, $module_js_lang);
     L($lang);
 }
Example #20
0
 public function addTag()
 {
     // $tags = model('Tag')->setAppName('public')->setAppTable('user')->getAppTags($this->mid);
     // if (count($tags) >= 5) {
     //     return array(
     //             'status' => 0,
     //             'info' => '最多只能选择5个'
     //     );
     // }
     // 获取标签内容
     $_REQUEST['name'] = t($_REQUEST['name']);
     $tags = explode(',', $_REQUEST['name']);
     // 判断是否为空
     if (empty($tags)) {
         return array('status' => 0, 'info' => L('PUBLIC_TAG_NOEMPTY'));
     }
     if (count($tags) > 5) {
         return array('status' => 0, 'info' => '最多只能选择5个');
     }
     M('app_tag')->where(array('app' => 'public', 'table' => 'user', 'row_id' => $this->mid))->delete();
     // 其他相关参数
     $appName = 'public';
     $appTable = 'user';
     $row_id = $this->mid;
     $result = model('Tag')->setAppName($appName)->setAppTable($appTable)->addAppTags($row_id, $tags);
     // 返回相关参数
     $return['info'] = model('Tag')->getError();
     $return['status'] = !empty($result) > 0 ? 1 : 0;
     $return['data'] = $result;
     return $return;
 }
Example #21
0
 public function insert()
 {
     $name = $this->getActionName();
     $model = D($name);
     if (false === ($data = $model->create())) {
         $this->error($model->getError());
     }
     if ($data['module_name'] == '') {
         $data['module_name'] = $data['module'];
     }
     if ($_REQUEST['module'] == "" && $_REQUEST['action'] != "") {
         $data['auth_type'] = 2;
     } elseif ($_REQUEST['module'] != "" && $_REQUEST['action'] == "") {
         $data['auth_type'] = 1;
     } else {
         $data['auth_type'] = 0;
     }
     if (D("RoleNode")->where("module='" . $data['module'] . "' and action='" . $data['action'] . "'")->count() > 0) {
         $this->error(L('ROLENODE_UNIQUE'));
     }
     //保存当前数据对象
     $list = $model->add($data);
     if ($list !== false) {
         $this->saveLog(1, $list);
         $this->success(L('ADD_SUCCESS'));
     } else {
         $this->saveLog(0, $list);
         $this->error(L('ADD_ERROR'));
     }
 }
Example #22
0
 /**
  * 编辑保存
  */
 public function payment_saveOp()
 {
     $payment_id = intval($_POST["payment_id"]);
     $data = array();
     $data['payment_state'] = intval($_POST["payment_state"]);
     switch ($_POST['payment_code']) {
         case 'alipay':
             $payment_config = array('alipay_account' => $_POST['alipay_account'], 'alipay_key' => $_POST['alipay_key'], 'alipay_partner' => $_POST['alipay_partner']);
             break;
         case 'wxpay':
             $payment_config = array('wxpay_appid' => $_POST['wxpay_appid'], 'wxpay_mch_id' => $_POST['wxpay_mch_id'], 'wxpay_appsecret' => $_POST['wxpay_appsecret'], 'wxpay_key' => $_POST['wxpay_key']);
             break;
         case 'unionpay':
             $payment_config = array('unionpay_account' => $_POST['unionpay_account'], 'cert_passwd' => $_POST['cert_passwd']);
             break;
         default:
             showMessage(L('param_error'), '');
     }
     $data['payment_config'] = $payment_config;
     $model_mb_payment = Model('mb_payment');
     $result = $model_mb_payment->editMbPayment($data, array('payment_id' => $payment_id));
     if ($result) {
         showMessage(Language::get('nc_common_save_succ'), urlAdmin('mb_payment', 'payment_list'));
     } else {
         showMessage(Language::get('nc_common_save_fail'), urlAdmin('mb_payment', 'payment_list'));
     }
 }
 public function run(&$_data)
 {
     $engine = strtolower(C('TMPL_ENGINE_TYPE'));
     if ('think' == $engine) {
         //[sae] 采用Think模板引擎
         if ($this->checkCache($_data['file'])) {
             // 缓存有效
             SaeMC::include_file(md5($_data['file']) . C('TMPL_CACHFILE_SUFFIX'), $_data['var']);
         } else {
             $tpl = Think::instance('ThinkTemplate');
             // 编译并加载模板文件
             $tpl->fetch($_data['file'], $_data['var']);
         }
     } else {
         // 调用第三方模板引擎解析和输出
         $class = 'Template' . ucwords($engine);
         if (is_file(CORE_PATH . 'Driver/Template/' . $class . '.class.php')) {
             // 内置驱动
             $path = CORE_PATH;
         } else {
             // 扩展驱动
             $path = EXTEND_PATH;
         }
         if (require_cache($path . 'Driver/Template/' . $class . '.class.php')) {
             $tpl = new $class();
             $tpl->fetch($_data['file'], $_data['var']);
         } else {
             // 类没有定义
             throw_exception(L('_NOT_SUPPERT_') . ': ' . $class);
         }
     }
     //[sae] 添加trace信息。
     trace(array('[SAE]核心缓存' => $_SERVER['HTTP_APPVERSION'] . '/' . RUNTIME_FILE, '[SAE]模板缓存' => $_SERVER['HTTP_APPVERSION'] . '/' . md5($_data['file']) . C('TMPL_CACHFILE_SUFFIX')));
 }
Example #24
0
 function ajax()
 {
     $model = M('Order');
     $id = intval($_POST['id']);
     $order = $model->find($id);
     if ($order['userid'] != $this->_userid) {
         die(json_encode(array('msg' => L('do_empty'))));
     }
     $_POST = get_safe_replace($_POST);
     if ($_GET['do'] == 'saveaddress') {
         $r = $model->save($_POST);
         die(json_encode(array('id' => 1)));
     } elseif ($_GET['do'] == 'order_status') {
         $_POST['status'] = 3;
         $_POST['confirm_time'] = time();
         $r = $model->save($_POST);
         die(json_encode(array('id' => 1)));
     } elseif ($_GET['do'] == 'pay_status') {
         $_POST['pay_status'] = 3;
         $r = $model->save($_POST);
         die(json_encode(array('id' => 1)));
     } elseif ($_GET['do'] == 'shipping_status') {
         $_POST['shipping_status'] = $_POST['num'];
         unset($_POST['num']);
         $_POST['accept_time'] = $_POST['shipping_status'] == 2 ? time() : '';
         $r = $model->save($_POST);
         die(json_encode(array('id' => 1)));
     }
 }
Example #25
0
    public function update() {
        $_POST['rtime']=time();
		$model = D($this->getActionName());
		/*
		//用于事件处理
		if(in_array($this->getActionName(),$this->eventlist)){
			//保留一下原始数据
			$_POST["jsoninfo"]=$model->where("id=".$_POST['id'])->find();
			$_POST["jsoninfo"]["actionname"]=$this->getActionName();
		}
		*/
		if(false === $model->create()) {
			$this->error($model->getError());
		}
        // 更新数据
		if(false !== $model->save()) {
			// 回调接口
			if (method_exists($this, '_tigger_update')) {
				$this->_tigger_update($model);
            }
			//成功提示
			$this->success(L('更新成功'));
		} else {
			//错误提示
			$this->error(L('更新失败'));
        }
	}
Example #26
0
 public function parseXmlAttr($attr, $tag)
 {
     $attr = str_replace('&', '___', $attr);
     $xml = '<tpl><tag ' . $attr . ' /></tpl>';
     $xml = simplexml_load_string($xml);
     if (!$xml) {
         throw_exception(L('_XML_TAG_ERROR_') . ' : ' . $attr);
     }
     $xml = (array) $xml->tag->attributes();
     $array = array_change_key_case($xml['@attributes']);
     if ($array) {
         $attrs = explode(',', $this->tags[strtolower($tag)]['attr']);
         if (isset($this->tags[strtolower($tag)]['must'])) {
             $must = explode(',', $this->tags[strtolower($tag)]['must']);
         } else {
             $must = array();
         }
         foreach ($attrs as $name) {
             if (isset($array[$name])) {
                 $array[$name] = str_replace('___', '&', $array[$name]);
             } elseif (false !== array_search($name, $must)) {
                 throw_exception(L('_PARAM_ERROR_') . ':' . $name);
             }
         }
         return $array;
     }
 }
Example #27
0
 /**
 +----------------------------------------------------------
 * 架构函数
 +----------------------------------------------------------
 * @access public
 +----------------------------------------------------------
 * @param array $config 数据库配置数组
 +----------------------------------------------------------
 */
 public function __construct($config = '')
 {
     if (!extension_loaded('mysql')) {
         throw_exception(L('_NOT_SUPPERT_') . ':mysql');
     }
     $this->config = $this->parseConfig($config);
 }
Example #28
0
 public function update()
 {
     set_time_limit(120);
     $old_attachment_path = isset($_POST['old_attachment_path']) && trim($_POST['old_attachment_path']) ? trim($_POST['old_attachment_path']) : showmessage(L('old_attachment_address_empty'));
     $new_attachment_path = isset($_POST['new_attachment_path']) && trim($_POST['new_attachment_path']) ? trim($_POST['new_attachment_path']) : showmessage(L('new_attachment_address_empty'));
     //获取数据表列表
     $db = pc_base::load_model('site_model');
     $r = $db->query("show tables");
     $r = $db->fetch_array($db_list);
     foreach ($r as $k => $v) {
         $v = array_pop($v);
         if (strpos($v, $db->db_tablepre) === false) {
             continue;
         }
         $table_name = str_replace($db->db_tablepre, '', $v);
         //获取每个表的数据表结构
         if (!($modle_table_db = pc_base::load_model($table_name . '_model'))) {
             $modle_table_db = $db;
         }
         $s = $modle_table_db->get_fields($table_name);
         if ($s) {
             $sql = '';
             foreach ($s as $key => $val) {
                 //对数据表进行过滤,只有CHAR、TEXT或mediumtext类型的字段才可以保存下附件的地址。
                 if (preg_match('/(char|text|mediumtext)+/i', $val)) {
                     $sql .= !empty($sql) ? ", `{$key}`=replace(`{$key}`, '{$old_attachment_path}', '{$new_attachment_path}')" : "`{$key}`=replace(`{$key}`, '{$old_attachment_path}', '{$new_attachment_path}')";
                 }
             }
             if (!empty($sql)) {
                 $modle_table_db->query("UPDATE " . $db->db_tablepre . $table_name . " SET {$sql}");
             }
         }
     }
     showmessage(L('operation_success'));
 }
 public function run(&$_data)
 {
     $engine = strtolower(C('TMPL_ENGINE_TYPE'));
     if ('think' == $engine) {
         // 采用Think模板引擎
         if ($this->checkCache($_data['file'])) {
             // 缓存有效
             // 分解变量并载入模板缓存
             extract($_data['var'], EXTR_OVERWRITE);
             //载入模版缓存文件
             include C('CACHE_PATH') . md5($_data['file']) . C('TMPL_CACHFILE_SUFFIX');
         } else {
             $tpl = Think::instance('ThinkTemplate');
             // 编译并加载模板文件
             $tpl->fetch($_data['file'], $_data['var']);
         }
     } else {
         // 调用第三方模板引擎解析和输出
         $class = 'Template' . ucwords($engine);
         if (is_file(CORE_PATH . 'Driver/Template/' . $class . '.class.php')) {
             // 内置驱动
             $path = CORE_PATH;
         } else {
             // 扩展驱动
             $path = EXTEND_PATH;
         }
         if (require_cache($path . 'Driver/Template/' . $class . '.class.php')) {
             $tpl = new $class();
             $tpl->fetch($_data['file'], $_data['var']);
         } else {
             // 类没有定义
             throw_exception(L('_NOT_SUPPERT_') . ': ' . $class);
         }
     }
 }
 public function remove()
 {
     //删除指定记录
     $result = array('isErr' => 0, 'content' => '');
     $id = $_REQUEST['id'];
     if (!empty($id)) {
         Vendor('common');
         $model = D("Event");
         $pk = $model->getPk();
         $condition = array($pk => array('in', explode(',', $id)));
         $list = $model->where($condition)->findAll();
         if (false !== $model->where($condition)->delete()) {
             foreach ($list as $k => $v) {
                 D("Share")->removeHandler($v['share_id']);
                 $post_share_ids = D("EventShare")->where("event_id=" . $v['id'])->field("share_id")->findAll();
                 foreach ($post_share_ids as $k => $share_ids) {
                     D("Share")->removeHandler($share_ids['share_id']);
                 }
                 $model->where("event_id=" . $v['id'])->delete();
             }
             $this->saveLog(1, $id);
         } else {
             $result['isErr'] = 1;
             $result['content'] = L('REMOVE_ERROR');
         }
     } else {
         $result['isErr'] = 1;
         $result['content'] = L('ACCESS_DENIED');
     }
     die(json_encode($result));
 }