/**
  * run - display template and edit data
  *
  * @access public
  */
 public function run()
 {
     $tpl = new template();
     $helper = new helper();
     $values = array('description' => '', 'dateFrom' => '', 'dateTo' => '', 'allDay' => '');
     if (isset($_POST['save']) === true) {
         if (isset($_POST['allDay']) === true) {
             $allDay = 'true';
         } else {
             $allDay = 'false';
         }
         if (isset($_POST['dateFrom']) === true && isset($_POST['timeFrom']) === true) {
             $dateFrom = $helper->date2timestamp($_POST['dateFrom'], $_POST['timeFrom']);
         }
         if (isset($_POST['dateTo']) === true && isset($_POST['timeTo']) === true) {
             $dateTo = $helper->date2timestamp($_POST['dateTo'], $_POST['timeTo']);
         }
         $values = array('description' => $_POST['description'], 'dateFrom' => $dateFrom, 'dateTo' => $dateTo, 'allDay' => $allDay);
         if ($values['description'] !== '') {
             if ($helper->validateTime($_POST['timeFrom']) === true) {
                 $this->addEvent($values);
                 $msgKey = $tpl->setNotification('SAVE_SUCCESS', 'success');
             } else {
                 $tpl->setNotification('WRONG_TIME_FORMAT', 'error');
             }
         } else {
             $tpl->setNotification('NO_DESCRIPTION', 'error');
         }
         $tpl->assign('values', $values);
     }
     $tpl->assign('helper', $helper);
     $tpl->display('calendar.addEvent');
 }
Exemple #2
0
 /**
  * View an article.
  * 
  * @param int $articleID 
  * @param int $currentCategory 
  * @access public
  * @return void
  */
 public function view($articleID, $currentCategory = 0)
 {
     $article = $this->loadModel('article')->getByID($articleID);
     if (!$article) {
         die($this->fetch('error', 'index'));
     }
     if ($article->link) {
         helper::header301($article->link);
     }
     /* fetch category for display. */
     $category = array_slice($article->categories, 0, 1);
     $category = $category[0]->id;
     $currentCategory = $this->session->articleCategory;
     if ($currentCategory > 0 && isset($article->categories[$currentCategory])) {
         $category = $currentCategory;
     }
     $category = $this->loadModel('tree')->getByID($category);
     $title = $article->title . ' - ' . $category->name;
     $keywords = $article->keywords . ' ' . $category->keywords . ' ' . $this->config->site->keywords;
     $desc = strip_tags($article->summary);
     $this->view->title = $title;
     $this->view->keywords = $keywords;
     $this->view->desc = $desc;
     $this->view->article = $article;
     $this->view->prevAndNext = $this->loadModel('article')->getPrevAndNext($article->id, $category->id);
     $this->view->category = $category;
     $this->view->contact = $this->loadModel('company')->getContact();
     $this->dao->update(TABLE_ARTICLE)->set('views = views + 1')->where('id')->eq($articleID)->exec(false);
     $this->display();
 }
Exemple #3
0
 /** 
  * Browse product in front.
  * 
  * @param int    $categoryID   the category id
  * @param int    $pageID       current page id
  * @access public
  * @return void
  */
 public function browse($categoryID = 0, $pageID = 1)
 {
     $category = $this->loadModel('tree')->getByID($categoryID, 'product');
     if ($category && $category->link) {
         helper::header301($category->link);
     }
     $this->app->loadClass('pager', $static = true);
     $pager = new pager(0, $this->config->product->recPerPage, $pageID);
     $categoryID = is_numeric($categoryID) ? $categoryID : $category->id;
     $products = $this->product->getList($this->tree->getFamily($categoryID), '`order` desc', $pager);
     if (!$category and $categoryID != 0) {
         die($this->fetch('error', 'index'));
     }
     if ($categoryID == 0) {
         $category = new stdclass();
         $category->id = 0;
         $category->name = $this->lang->product->home;
         $category->alias = '';
         $category->keywords = '';
         $category->desc = '';
     }
     $title = $category->name;
     $keywords = trim($category->keywords . ' ' . $this->config->site->keywords);
     $desc = strip_tags($category->desc) . ' ';
     $this->session->set('productCategory', $category->id);
     $this->view->title = $title;
     $this->view->keywords = $keywords;
     $this->view->desc = $desc;
     $this->view->category = $category;
     $this->view->products = $products;
     $this->view->pager = $pager;
     $this->view->contact = $this->loadModel('company')->getContact();
     $this->display();
 }
Exemple #4
0
 /**
  * Browse surveys.
  *
  * @param  string   $status
  * @access public
  * @return void
  */
 public function browse($status = 'installed')
 {
     $packages = $this->survey->getLocalPackages($status);
     $versions = array();
     if ($packages and $status == 'installed') {
         /* Get latest release from remote. */
         $extCodes = helper::safe64Encode(join(',', array_keys($packages)));
         $results = $this->survey->getPackagesByAPI('bycode', $extCodes, $recTotal = 0, $recPerPage = 1000, $pageID = 1);
         if (isset($results->extensions)) {
             $remoteReleases = $results->extensions;
             foreach ($remoteReleases as $release) {
                 if (!isset($packages[$release->code])) {
                     continue;
                 }
                 $package = $packages[$release->code];
                 $package->viewLink = $release->viewLink;
                 if (isset($release->latestRelease) and $package->version != $release->latestRelease->releaseVersion and $this->package->checkVersion($release->latestRelease->chanzhiCompatible)) {
                     $upgradeLink = inlink('upgrade', "package={$release->code}&downLink=" . helper::safe64Encode($release->latestRelease->downLink) . "&md5={$release->latestRelease->md5}&type={$release->type}");
                     $upgradeLink = ($release->latestRelease->charge or !$release->latestRelease->public) ? $release->latestRelease->downLink : $upgradeLink;
                     $package->upgradeLink = $upgradeLink;
                 }
             }
         }
     }
     $this->view->title = $this->lang->survey->browse;
     $this->view->position[] = $this->lang->survey->browse;
     $this->view->tab = $status;
     $this->view->packages = $packages;
     $this->view->versions = $versions;
     $this->view->status = $status;
     $this->display();
 }
Exemple #5
0
 /**
  * The error page.
  * 
  * @access public
  * @return void
  */
 public function index($type, $locate = '')
 {
     $this->view->title = $this->lang->error->common;
     $this->view->message = isset($this->lang->error->typeList[$type]) ? $this->lang->error->typeList[$type] : $this->lang->error->typeList['notFound'];
     $this->view->locate = helper::safe64Decode($locate);
     $this->display();
 }
 /**
  * Get efforts. 
  * 
  * @param  string $account 
  * @param  int    $date 
  * @param  string $project 
  * @access public
  * @return void
  */
 public function getEfforts($account = 'all', $date, $project = '', $begin = '', $end = '')
 {
     $this->loadModel('todo');
     $efforts = array();
     if ($date == 'today') {
         $begin = $this->todo->today();
         $end = $begin;
     } elseif ($date == 'thisweek') {
         extract($this->todo->getThisWeek());
     } elseif ($date == 'lastweek') {
         extract($this->todo->getLastWeek());
     } elseif ($date == 'thismonth') {
         extract($this->todo->getThisMonth());
     } elseif ($date == 'lastmonth') {
         extract($this->todo->getLastMonth());
     } elseif ($date == 'select') {
         if ($begin == '') {
             $begin = helper::today();
         }
         if ($end == '') {
             $end = helper::today();
         }
     } elseif ($date == 'all') {
         $begin = '1970-01-01';
         $end = '2109-01-01';
     } else {
         $begin = $end = $date;
     }
     $efforts = $this->dao->select('*')->from(TABLE_SUNEFFORTEVERYDAY)->where('account')->eq($this->app->user->account)->andWhere("date >= '{$begin}'")->andWhere("date <= '{$end}'")->beginIF($project != '')->andWhere('project')->eq($project)->fi()->beginIF($account != 'all')->andWhere('account')->eq($account)->fi()->fetchAll('id');
     return $efforts;
 }
 public function add($userId, $reason = "")
 {
     $result = array("error" => true, "error_code" => ERROR_UNKNOWN);
     $currentTime = time();
     $ip_addr = helper::ip_addr();
     $u_agent = helper::u_agent();
     $stmt = $this->db->prepare("INSERT INTO profile_blacklist (blockedByUserId, blockedUserId, reason, createAt, ip_addr, u_agent) value (:blockedByUserId, :blockedUserId, :reason, :createAt, :ip_addr, :u_agent)");
     $stmt->bindParam(":blockedByUserId", $this->requestFrom, PDO::PARAM_INT);
     $stmt->bindParam(":blockedUserId", $userId, PDO::PARAM_INT);
     $stmt->bindParam(":reason", $reason, PDO::PARAM_STR);
     $stmt->bindParam(":createAt", $currentTime, PDO::PARAM_INT);
     $stmt->bindParam(":ip_addr", $ip_addr, PDO::PARAM_STR);
     $stmt->bindParam(":u_agent", $u_agent, PDO::PARAM_STR);
     if ($stmt->execute()) {
         $result = array("error" => false, "error_code" => ERROR_SUCCESS);
         $my_profile = new profile($this->db, $this->requestFrom);
         if ($my_profile->is_friend_exists($userId)) {
             $friends = new friends($this->db, $this->requestFrom);
             $friends->remove($userId);
             unset($friends);
         } else {
             if ($my_profile->is_follower_exists($userId)) {
                 // Unfollow
                 $my_profile->addFollower($userId);
             }
             $profile = new profile($this->db, $userId);
             if ($profile->is_follower_exists($this->requestFrom)) {
                 $profile->addFollower($this->requestFrom);
             }
             unset($profile);
         }
         unset($my_profile);
     }
     return $result;
 }
Exemple #8
0
function m__set_level()
{
    global $dbm;
    $_POST = helper::sqlxss($_POST);
    $aid = isset($_POST['aid']) ? intval($_POST['aid']) : 0;
    $gid = isset($_POST['gid']) ? intval($_POST['gid']) : 0;
    $_POST['level'] = isset($_POST['level']) ? $_POST['level'] : array();
    if ($aid < 0 && $gid < 0) {
        die('{"code":"1","msg":"请选择权限设置对象,无法设置"}');
    }
    if ($gid > 0) {
        if ($gid == 1) {
            die('{"code":"100","msg":"超级管理组权限无需设置"}');
        }
        check_level("B0301");
        $fields['g_urank'] = implode(',', $_POST['level']);
        $rs = $dbm->single_update(TB_PREFIX . 'admin_group', $fields, "group_id='{$gid}'");
        logs("设置组权限成功:" . $fields['g_urank']);
        die('{"code":"0","msg":"设置用户组权限成功"}');
    }
    if ($aid > 0) {
        check_level("B0302");
        //die(print_r($_POST));
        $fields['alevel'] = implode(',', $_POST['level']);
        $rs = $dbm->single_update(TB_PREFIX . 'admin_list', $fields, "admin_id='{$aid}'");
        logs("设置组权限成功:" . $fields['alevel']);
        die('{"code":"0","msg":"设置用户权限成功"}');
    }
}
Exemple #9
0
 public function __construct()
 {
     global $table;
     $this->table = $table;
     $this->cdb = helper::getDB('phpcms');
     $this->wdb = helper::getDB('cmsware');
 }
Exemple #10
0
function m__edit()
{
    global $l_obj, $t_obj;
    check_level("H0701");
    $post = $_POST;
    //处理数据隐藏安全
    foreach ($post as $k => $n) {
        $post[$k] = urldecode(helper::escape($n));
    }
    //验证数据合法性
    if (!is_numeric($post['keyword_id'])) {
        die('{"code":"100","msg":"标签ID必须是数字"}');
    }
    if (empty($post['keyword'])) {
        die('{"code":"100","msg":"标签不能为空"}');
    }
    if ($post['keyword_id'] > 0) {
        // 编辑
        $res = $t_obj->update($post, $post['keyword_id']);
        if ($res['state'] == 0) {
            $l_obj->insert("编辑成功:" . $post['keyword']);
            die('{"code":"0","msg":"编辑成功","kid":"' . $post['keyword_id'] . '"}');
        }
        die('{"code":"240","msg":"编辑失败"}');
    } else {
        // 添加
        $res = $t_obj->insert($post);
        if ($res['state'] == 0) {
            $l_obj->insert("添加成功:" . $post['keyword']);
            die('{"code":"0","msg":"添加成功","kid":"' . $res['msg'] . '"}');
        }
        die('{"code":"100","msg":"添加失败,"' . $res['msg'] . '}');
    }
}
Exemple #11
0
function m__list()
{
    //判断操作权限
    check_level("E08");
    global $dbm, $resource_list;
    // 查询 mcms_resource_list 表
    $params['where'] = " 1=1";
    $params['table_name'] = TB_PREFIX . "resource_list";
    $params['count'] = 1;
    $params['suffix'] = " order by id DESC ";
    $params['pagesize'] = PAGESIZE;
    $params['suffix'] .= $dbm->get_limit_sql(PAGESIZE, $_GET['p']);
    $resource_list = $dbm->single_query($params);
    //开始循环 进行比对数据 找出关联的资源
    $i = 0;
    //数组排序时用到
    foreach ($resource_list['list'] as $k => $v) {
        //调用函数对数据进行比对
        $result = check_resource($v['id'], $v['info_id'], $v['resource_url']);
        //添加排序元素
        if ($result['info']['table_name'] == 'undefined' && 'undefined' == $result['info']['qita']) {
            $resource_list['list'][$k]['paixu'] = ++$i;
        } else {
            $resource_list['list'][$k]['paixu'] = 0;
        }
        $resource_list['list'][$k]['info'] = $result['info'];
    }
    $resource_list['list'] = helper::array_sort($resource_list['list'], 'paixu', 'desc');
    //将无效资源排在前面
    //print_r($resource_list);exit;
}
Exemple #12
0
 /**
  * Obtain web app. 
  * 
  * @param  string $type 
  * @param  string $param 
  * @param  int    $recTotal 
  * @param  int    $recPerPage 
  * @param  int    $pageID 
  * @access public
  * @return void
  */
 public function obtain($type = 'byUpdatedTime', $param = '', $recTotal = 0, $recPerPage = 20, $pageID = 1)
 {
     $this->lang->webapp->menu = $this->lang->entry->menu;
     $this->lang->menuGroups->webapp = 'entry';
     /* Init vars. */
     $type = strtolower($type);
     $moduleID = $type == 'bymodule' ? (int) $param : 0;
     $webapps = array();
     $pager = null;
     /* Set the key. */
     if ($type == 'bysearch') {
         $param = helper::safe64Encode($this->post->key);
     }
     /* Get results from the api. */
     $recPerPage = $this->cookie->pagerWebappObtain ? $this->cookie->pagerWebappObtain : $recPerPage;
     $results = $this->webapp->getAppsByAPI($type, $param, $recTotal, $recPerPage, $pageID);
     if ($results) {
         $this->app->loadClass('pager', $static = true);
         $pager = new pager($results->dbPager->recTotal, $results->dbPager->recPerPage, $results->dbPager->pageID);
         $webapps = $results->webapps;
     }
     $this->view->title = $this->lang->webapp->common . $this->lang->colon . $this->lang->webapp->obtain;
     $this->view->position[] = $this->lang->webapp->obtain;
     $this->view->moduleTree = $this->webapp->getModulesByAPI();
     $this->view->webapps = $webapps;
     $this->view->installeds = $this->webapp->getLocalApps();
     $this->view->pager = $pager;
     $this->view->tab = 'obtain';
     $this->view->type = $type;
     $this->view->moduleID = $moduleID;
     $this->display();
 }
Exemple #13
0
 /**
  * show notify in msgBox.
  * 
  * @access public
  * @return string
  */
 public function notify()
 {
     $messages = $this->dao->select('COUNT(*) as count')->from(TABLE_MESSAGE)->where('`to`')->eq($this->app->user->account)->andWhere('readed')->eq(0)->fetch('count');
     if ($messages) {
         echo html::a(helper::createLink('user', 'message'), sprintf($this->lang->user->message->mine, $messages));
     }
 }
Exemple #14
0
 /**
  * Request the api.
  * 
  * @param  string $moduleName 
  * @param  string $methodName 
  * @param  string $action 
  * @access public
  * @return void
  */
 public function request($moduleName, $methodName, $action)
 {
     $host = common::getSysURL() . $this->config->webRoot;
     $param = '';
     if ($action == 'extendModel') {
         if (!isset($_POST['noparam'])) {
             foreach ($_POST as $key => $value) {
                 $param .= ',' . $key . '=' . $value;
             }
             $param = ltrim($param, ',');
         }
         $url = rtrim($host, '/') . inlink('getModel', "moduleName={$moduleName}&methodName={$methodName}&params={$param}", 'json');
         $url .= $this->config->requestType == "PATH_INFO" ? '?' : '&';
         $url .= $this->config->sessionVar . '=' . session_id();
     } else {
         if (!isset($_POST['noparam'])) {
             foreach ($_POST as $key => $value) {
                 $param .= '&' . $key . '=' . $value;
             }
             $param = ltrim($param, '&');
         }
         $url = rtrim($host, '/') . helper::createLink($moduleName, $methodName, $param, 'json');
         $url .= $this->config->requestType == "PATH_INFO" ? '?' : '&';
         $url .= $this->config->sessionVar . '=' . session_id();
     }
     /* Unlock session. After new request, restart session. */
     session_write_close();
     $content = file_get_contents($url);
     session_start();
     return array('url' => $url, 'content' => $content);
 }
Exemple #15
0
 /**
  * AJAX: the api to recive the file posted through ajax.
  * 
  * @param  string $uid 
  * @access public
  * @return array
  */
 public function ajaxUpload($uid)
 {
     if (RUN_MODE == 'front' and !commonModel::isAvailable('forum')) {
         exit;
     }
     if (!$this->loadModel('file')->canUpload()) {
         $this->send(array('error' => 1, 'message' => $this->lang->file->uploadForbidden));
     }
     $file = $this->file->getUpload('imgFile');
     $file = $file[0];
     if ($file) {
         if (!$this->file->checkSavePath()) {
             $this->send(array('error' => 1, 'message' => $this->lang->file->errorUnwritable));
         }
         if (!in_array(strtolower($file['extension']), $this->config->file->imageExtensions)) {
             $this->send(array('error' => 1, 'message' => $this->lang->fail));
         }
         move_uploaded_file($file['tmpname'], $this->file->savePath . $file['pathname']);
         if (in_array(strtolower($file['extension']), $this->config->file->imageExtensions) !== false) {
             $this->file->compressImage($this->file->savePath . $file['pathname']);
             $imageSize = $this->file->getImageSize($this->file->savePath . $file['pathname']);
             $file['width'] = $imageSize['width'];
             $file['height'] = $imageSize['height'];
         }
         $url = $this->file->webPath . $file['pathname'];
         $file['addedBy'] = $this->app->user->account;
         $file['addedDate'] = helper::now();
         $file['editor'] = 1;
         unset($file['tmpname']);
         $this->dao->insert(TABLE_FILE)->data($file)->exec();
         $_SESSION['album'][$uid][] = $this->dao->lastInsertID();
         die(json_encode(array('error' => 0, 'url' => $url)));
     }
 }
 /**
  * 应用程序入口
  * 负责调用其他类库和调用应用程序类库
  */
 public function run()
 {
     try {
         //载入其他配置文件
         $this->loadConfig();
         //取uri并解析
         $this->get_req_url()->prase_uri();
         //导入控制器
         $class_file = $this->getClassFile($_REQUEST['controller']);
         //虽然可以用include,不过防止多次载入,还是用Include_once加以限制
         include_once $class_file;
         //设置类名和方法名
         $class_name = $_REQUEST['controller'] . "Action";
         $Act_name = $_REQUEST['action'];
         //初始化运行
         $Act = new $class_name($Act_name);
         //检查是否存在该方法
         $class_methods = get_class_methods($class_name);
         //如果方法不存在,并且不存在魔术重载,那么就提示访问的页面不存在
         if (!in_array($Act_name, $class_methods) && !in_array("__call", $class_methods)) {
             throw new Exception("您访问的页面不存在");
         }
         //调用方法
         $Act->{$Act_name}();
         //flush buffer
         ob_end_flush();
     } catch (Exception $e) {
         helper::traceOut($e);
     }
 }
Exemple #17
0
 /**
  * The index page of whole site.
  * 
  * @access public
  * @return void
  */
 public function index($categoryID = 0, $pageID = 1)
 {
     if (isset($this->config->site->type) and $this->config->site->type == 'blog') {
         $param = ($categoryID == 0 and $pageID == 1) ? '' : "categoryID={$categoryID}&pageID={$pageID}";
         $this->locate($this->createLink('blog', 'index', $param));
     }
     //SMART 产品分类信息
     $product = $this->dao->select('*')->from('es_category')->where('type')->eq('product')->andWhere('parent')->eq(1)->andWhere('lang')->eq('zh-cn')->fetchAll();
     foreach ($product as &$top) {
         $top->child = $this->dao->select('*')->from('es_category')->where('type')->eq('product')->andWhere('parent')->eq($top->id)->andWhere('lang')->eq('zh-cn')->fetchAll();
     }
     //变更通知部分
     $field = $this->dao->select('t1.*, t2.*')->from('es_article')->alias('t1')->leftJoin('es_relation')->alias('t2')->on('t1.id = t2.id')->where('t2.category')->eq(19)->limit(5)->fetchAll();
     //公司新闻
     $company = $this->dao->select('*')->from('es_article')->alias('t1')->leftJoin('es_relation')->alias('t2')->on('t1.id = t2.id')->where('t2.category')->eq(20)->limit(3)->fetchAll();
     //应用与解决方案
     $solution = $this->dao->select('*')->from('es_category')->where('type')->eq('article')->andWhere('parent')->eq(2)->andWhere('lang')->eq('zh-cn')->fetchAll();
     $this->view->title = $this->config->site->indexKeywords;
     $this->view->mobileURL = helper::createLink('index', 'index', '', '', 'mhtml');
     $this->view->desktopURL = helper::createLink('index', 'index', '', '', 'html');
     $this->view->product = $product;
     $this->view->field = $field;
     $this->view->company = $company;
     $this->view->solution = $solution;
     $this->display();
 }
 public function add($mode, $comment, $originImgUrl = "", $previewImgUrl = "", $imgUrl = "", $photoArea = "", $photoCountry = "", $photoCity = "", $photoLat = "", $photoLng = "")
 {
     $result = array("error" => true, "error_code" => ERROR_UNKNOWN);
     if (strlen($originImgUrl) == 0 && strlen($previewImgUrl) == 0 && strlen($imgUrl) == 0) {
         return $result;
     }
     if (strlen($comment) != 0) {
         $comment = $comment . " ";
     }
     $currentTime = time();
     $ip_addr = helper::ip_addr();
     $u_agent = helper::u_agent();
     $stmt = $this->db->prepare("INSERT INTO photos (fromUserId, accessMode, comment, originImgUrl, previewImgUrl, imgUrl, area, country, city, lat, lng, createAt, ip_addr, u_agent) value (:fromUserId, :accessMode, :comment, :originImgUrl, :previewImgUrl, :imgUrl, :area, :country, :city, :lat, :lng, :createAt, :ip_addr, :u_agent)");
     $stmt->bindParam(":fromUserId", $this->requestFrom, PDO::PARAM_INT);
     $stmt->bindParam(":accessMode", $mode, PDO::PARAM_INT);
     $stmt->bindParam(":comment", $comment, PDO::PARAM_STR);
     $stmt->bindParam(":originImgUrl", $originImgUrl, PDO::PARAM_STR);
     $stmt->bindParam(":previewImgUrl", $previewImgUrl, PDO::PARAM_STR);
     $stmt->bindParam(":imgUrl", $imgUrl, PDO::PARAM_STR);
     $stmt->bindParam(":area", $photoArea, PDO::PARAM_STR);
     $stmt->bindParam(":country", $photoCountry, PDO::PARAM_STR);
     $stmt->bindParam(":city", $photoCity, PDO::PARAM_STR);
     $stmt->bindParam(":lat", $photoLat, PDO::PARAM_STR);
     $stmt->bindParam(":lng", $photoLng, PDO::PARAM_STR);
     $stmt->bindParam(":createAt", $currentTime, PDO::PARAM_INT);
     $stmt->bindParam(":ip_addr", $ip_addr, PDO::PARAM_STR);
     $stmt->bindParam(":u_agent", $u_agent, PDO::PARAM_STR);
     if ($stmt->execute()) {
         $result = array("error" => false, "error_code" => ERROR_SUCCESS, "photoId" => $this->db->lastInsertId(), "photo" => $this->info($this->db->lastInsertId()));
         $account = new account($this->db, $this->requestFrom);
         $account->updateCounters();
         unset($account);
     }
     return $result;
 }
 public function getArticle($type, $id)
 {
     $model = \ServiceFaq::find($id);
     if ($model === null) {
         return \Redirect::back();
     } else {
         $parent = \ServiceFaq::find($model->_parent);
     }
     // Views
     if (\helper::views_cookie('service_faq', $id)) {
         $model->views = $model->views + 1;
         $model->save();
     }
     $model->date = substr($model->created_at, 0, 10);
     // decode label and tab
     $lblIds = json_decode($model->labels, true);
     $labels = array();
     if (!empty($lblIds)) {
         $labels = \ServiceFaq::orderBy('id', 'asc')->find($lblIds, array('id', 'title'));
     }
     $tabs = json_decode($model->tabs);
     if (empty($tabs)) {
         $tabs = array();
     }
     $view = sprintf('aesthetics.%s.view_article', $type);
     return \View::make('aesthetics.serviceFaq.view_article', array('model' => &$model, 'parent' => &$parent, 'images' => \ServiceFaqImage::where('sid', '=', $model->id)->orderBy('sort', 'asc')->get(), 'labels' => &$labels, 'tabs' => &$tabs, 'navs' => $this->getNavigation($type), 'type' => $type));
 }
Exemple #20
0
 public function createModuleMenu($method)
 {
     if (!isset($this->lang->my->{$method}->menu)) {
         return false;
     }
     $string = "<nav id='menu'><ul class='nav'>\n";
     /* Get menus of current module and current method. */
     $moduleMenus = $this->lang->my->{$method}->menu;
     $currentMethod = $this->app->getMethodName();
     /* Cycling to print every menus of current module. */
     foreach ($moduleMenus as $methodName => $methodMenu) {
         /* Split the methodMenu to label, module, method, vars. */
         list($label, $module, $method, $vars) = explode('|', $methodMenu);
         $class = '';
         if ($method == $currentMethod) {
             $class = "class='active'";
         }
         $hasPriv = commonModel::hasPriv($module, $method);
         if ($module == 'my' and $method == 'order') {
             $hasPriv = commonModel::hasPriv('order', 'browse');
         }
         if ($module == 'my' and $method == 'contract') {
             $hasPriv = commonModel::hasPriv('contract', 'browse');
         }
         if ($hasPriv) {
             $string .= "<li {$class}>" . html::a(helper::createLink($module, $method, $vars), $label) . "</li>\n";
         }
     }
     $string .= "</ul></nav>\n";
     return $string;
 }
Exemple #21
0
 /**
  * The board page.
  * 
  * @param int    $boardID       the board id
  * @param int    $pageID        the current page id
  * @access public
  * @return void
  */
 public function board($boardID = 0, $pageID = 1)
 {
     $board = $this->loadModel('tree')->getByID($boardID, 'forum');
     if (!$board) {
         die(js::locate('back'));
     }
     if ($board->link) {
         helper::header301($board->link);
     }
     /* Get common threads. */
     $recPerPage = !empty($this->config->site->forumRec) ? $this->config->site->forumRec : $this->config->forum->recPerPage;
     $this->app->loadClass('pager', $static = true);
     $pager = new pager(0, $recPerPage, $pageID);
     $threads = $this->loadModel('thread')->getList($board->id, $orderBy = 'repliedDate_desc', $pager);
     $this->view->title = $board->name;
     $this->view->keywords = $board->keywords . '' . $this->config->site->keywords;
     $this->view->desc = strip_tags($board->desc);
     $this->view->board = $board;
     $this->view->sticks = $this->thread->getSticks($board->id);
     $this->view->threads = $threads;
     $this->view->pager = $pager;
     $this->view->mobileURL = helper::createLink('forum', 'board', "borderID={$boardID}&pageID={$pageID}", "category={$board->alias}", 'mhtml');
     $this->view->desktopURL = helper::createLink('forum', 'board', "borderID={$boardID}&pageID={$pageID}", "category={$board->alias}", 'html');
     $this->display();
 }
Exemple #22
0
 /**
  * links profile.
  * 
  * @access public
  * @return void
  */
 public function index()
 {
     $this->view->links = $this->config->links;
     $this->view->mobileURL = helper::createLink('links', 'index', '', '', 'mhtml');
     $this->view->desktopURL = helper::createLink('links', 'index', '', '', 'html');
     $this->display();
 }
Exemple #23
0
function m__edit()
{
    global $u_obj, $l_obj;
    //验证权限
    check_level("B0201");
    $post = $_POST;
    foreach ($post as $key => $val) {
        $post[$key] = trim(urldecode($val));
    }
    if (empty($post['uname'])) {
        die('{"code":"100","msg":"用户不能为空"}');
    }
    if ($post['group_id'] <= 0) {
        die('{"code":"100","msg":"请选择分组"}');
    }
    if (!is_numeric($post['discount'])) {
        die('{"code":"100","msg":"折扣必须是数字"}');
    }
    if ($post['discount'] > 10 || $post['discount'] < 0) {
        die('{"code":"100","msg":"折扣不合理,请重新填写"}');
    }
    if ($post['user_id'] <= 0) {
        if (empty($post['upass']) || empty($post['reupass'])) {
            die('{"code":"100","msg":"密码不能为空"}');
        }
        if ($post['upass'] != $post['reupass']) {
            die('{"code":"100","msg":"输入的密码不一致"}');
        }
        unset($post['reupass']);
        //不需要重复验证的密码
        //给密码加密
        $post['upass'] = helper::password_encrypt($post['upass']);
        //判断是否重复
        $where = ' where uname = "' . $post['uname'] . '"';
        $group = $u_obj->get_all($where);
        if (!empty($group['list']) && count($group['list']) > 0) {
            die('{"code":"100","msg":"用户组名称不能重复"}');
        }
        //添加
        $res = $u_obj->insert($post);
        if ($res['state'] == 0) {
            $l_obj->insert("添加用户【{$post['uname']}】");
            die('{"code":"0","msg":"添加用户组成功","uid":"' . $res['msg'] . '"}');
        }
        die('{"code":"100","msg":"添加用户组失败"}');
    } else {
        //编辑
        if (empty($post['upass'])) {
            unset($post['upass']);
        }
        unset($post['reupass']);
        //不需要重复验证的密码
        $res = $u_obj->update($post, $post['user_id']);
        if ($res['state'] == 0) {
            $l_obj->insert("更新用户【{$post['uname']}】");
            die('{"code":"0","msg":"更新用户成功","uid":"' . $post['user_id'] . '"}');
        }
        die('{"code":"100","msg":"编辑用户失败"}');
    }
}
 /**
  * Responds to requests to POST create
  */
 public function postCreate(Request $request)
 {
     $howMany = $request->Input('howMany');
     $user = helper::generateuser($howMany);
     //dd($user);
     return view('pages.randomuser')->with('user', $user);
 }
Exemple #25
0
 /**
  * Cat a file.
  * 
  * @param  string $path
  * @param  int    $revision 
  * @access public
  * @return void
  */
 public function cat($path, $revision)
 {
     $path = helper::safe64Decode($path);
     $this->view->path = $path;
     $this->view->revision = $revision;
     $this->view->code = $this->git->cat($path, $revision);
     $this->display();
 }
Exemple #26
0
 /** MODULE : Redirection */
 public function index()
 {
     // Redirection vers l'URL saisie
     $url = $this->getData([$this->getUrl(0), 'url']);
     if ($url) {
         helper::redirect($url, false);
     }
 }
Exemple #27
0
 /**
  * Cat a file.
  * 
  * @param  string $url 
  * @param  int    $revision 
  * @access public
  * @return void
  */
 public function cat($url, $revision)
 {
     $url = helper::safe64Decode($url);
     $this->view->url = $url;
     $this->view->revision = $revision;
     $this->view->code = $this->svn->cat($url, $revision);
     $this->display();
 }
Exemple #28
0
 /**
  * Test converting formatted time to seconds
  */
 public function testSecondsFromFormattedTime()
 {
     // validate
     $this->assertsame(100.5279, helper::secondsfromformattedtime('01:40.5279'));
     $this->assertsame(5516.5879, helper::secondsfromformattedtime('01:31:56.5879'));
     $this->assertsame(123.506, helper::secondsfromformattedtime('02:03:506', true));
     $this->assertsame(3723.506, helper::secondsfromformattedtime('01:02:03:506', true));
 }
Exemple #29
0
 /**
  * Check current version is latest or not.
  * 
  * @access public
  * @return void
  */
 public function checkUpdate()
 {
     $note = isset($_GET['note']) ? $_GET['note'] : '';
     $browser = isset($_GET['browser']) ? $_GET['browser'] : '';
     $this->view->note = urldecode(helper::safe64Decode($note));
     $this->view->browser = $browser;
     $this->display();
 }
Exemple #30
-1
 public function uploadExcel($filename = '', $productID, $planID, $sprintID)
 {
     if ($_FILES['excelFile']['size'] == 0) {
         return;
     }
     // uploadFile
     $filePath = $this->getSavePath();
     $fname = $this->setPathName(0, $file['extension']);
     $uploadfile = $filePath . $fname;
     $tmp_name = $_FILES['excelFile']["tmp_name"];
     require_once 'PHPExcel.php';
     require_once 'PHPExcel/IOFactory.php';
     require_once 'PHPExcel/Reader/Excel2007.php';
     $result = move_uploaded_file($_FILES['excelFile']["tmp_name"], $this->getSavePath() . $fname);
     if ($result) {
         $objReader = PHPExcel_IOFactory::createReader('Excel2007');
         $objPHPExcel = PHPExcel_IOFactory::load($uploadfile);
         $sheet = $objPHPExcel->getSheet(0);
         $highestRow = $sheet->getHighestRow();
         $highestColumn = $sheet->getHighestColumn();
         for ($j = 2; $j <= $highestRow; $j++) {
             $str = "";
             for ($k = 'A'; $k <= $highestColumn; $k++) {
                 // $str .= iconv('utf-8', 'gbk', $objPHPExcel->getActiveSheet()->getCell("$k$j")->getValue())."|";//读取单元格
                 $str .= $objPHPExcel->getActiveSheet()->getCell("{$k}{$j}")->getValue() . "|";
                 //读取单元格
             }
             $strs = explode("|", $str);
             $bug = new stdclass();
             $bug->product = $productID;
             $bug->plan = $planID;
             if ($sprintID) {
                 $bug->project = $sprintID;
             }
             $bug->title = $strs[0];
             $bug->stage = $this->lang->importbugs->stageMap[$strs[1]];
             $bug->type = $this->lang->importbugs->typeMap[$strs[2]];
             $bug->severity = $strs[3];
             $bug->steps = $strs[4];
             $bug->openedBy = $this->app->user->account;
             $this->dao->insert(TABLE_BUG)->data($bug)->exec();
             $bugID = $this->dao->lastInsertID();
             $action = new stdclass();
             $action->objectType = 'bug';
             $action->objectID = $bugID;
             $action->product = $productID;
             $action->project = $sprintID;
             $action->actor = $this->app->user->account;
             $action->action = 'opened';
             $action->date = helper::now();
             $action->read = 0;
             $this->dao->insert(TABLE_ACTION)->data($action)->exec();
         }
         unlink($uploadfile);
         $msg = $this->lang->importbugs->success;
     } else {
         $msg = $this->lang->importbugs->fail;
     }
     return $msg;
 }