function countStats()
{
    $resultData = array();
    $today = date('Y-m-d');
    $loadData = Post::get(array('query' => "select count(postid)as totalcount from " . Database::getPrefix() . "post"));
    $resultData['post']['total'] = $loadData[0]['totalcount'];
    $loadData = Post::get(array('query' => "select count(postid)as totalcount from " . Database::getPrefix() . "post where DATE(date_added)='{$today}'"));
    $resultData['post']['today'] = $loadData[0]['totalcount'];
    $loadData = Post::get(array('query' => "select count(postid)as totalcount from " . Database::getPrefix() . "post where status='1'"));
    $resultData['post']['published'] = $loadData[0]['totalcount'];
    $loadData = Post::get(array('query' => "select count(postid)as totalcount from " . Database::getPrefix() . "post where status='0'"));
    $resultData['post']['pending'] = $loadData[0]['totalcount'];
    $loadData = Comments::get(array('query' => "select count(commentid)as totalcount from " . Database::getPrefix() . "comments"));
    $resultData['comments']['total'] = $loadData[0]['totalcount'];
    $loadData = Comments::get(array('query' => "select count(commentid)as totalcount from " . Database::getPrefix() . "comments where DATE(date_added)='{$today}'"));
    $resultData['comments']['today'] = $loadData[0]['totalcount'];
    $loadData = Comments::get(array('query' => "select count(commentid)as totalcount from " . Database::getPrefix() . "comments where status='1'"));
    $resultData['comments']['approved'] = $loadData[0]['totalcount'];
    $loadData = Comments::get(array('query' => "select count(commentid)as totalcount from " . Database::getPrefix() . "comments where status='0'"));
    $resultData['comments']['pending'] = $loadData[0]['totalcount'];
    $loadData = Contactus::get(array('query' => "select count(contactid)as totalcount from " . Database::getPrefix() . "contactus"));
    $resultData['contactus']['total'] = $loadData[0]['totalcount'];
    $loadData = Contactus::get(array('query' => "select count(contactid)as totalcount from " . Database::getPrefix() . "contactus where DATE(date_added)='{$today}'"));
    $resultData['contactus']['today'] = $loadData[0]['totalcount'];
    $loadData = Users::get(array('query' => "select count(userid)as totalcount from " . Database::getPrefix() . "users"));
    $resultData['users']['total'] = $loadData[0]['totalcount'];
    $loadData = Users::get(array('query' => "select count(userid)as totalcount from " . Database::getPrefix() . "users where DATE(date_added)='{$today}'"));
    $resultData['users']['today'] = $loadData[0]['totalcount'];
    return $resultData;
}
 public function view()
 {
     if (!($match = Uri::match('\\/view\\/(\\d+)'))) {
         Redirect::to(ADMINCP_URL . 'comments/');
     }
     $commentid = $match[1];
     $loadData = Comments::get(array('query' => "select p.title,c.* from " . Database::getPrefix() . "post p," . Database::getPrefix() . "comments c where p.postid=c.postid AND c.commentid='{$commentid}'"));
     $post['edit'] = $loadData[0];
     System::setTitle('View comment - ' . ADMINCP_TITLE);
     View::make('admincp/head');
     self::makeContents('commentView', $post);
     View::make('admincp/footer');
 }
 public function edit()
 {
     if (!($match = Uri::match('\\/edit\\/(\\d+)'))) {
         Redirect::to(ADMINCP_URL . 'post/');
     }
     $postid = $match[1];
     $post = array('alert' => '');
     if (Request::has('btnSave')) {
         try {
             updateProcess($postid);
             $post['alert'] = '<div class="alert alert-success">Save changes success.</div>';
         } catch (Exception $e) {
             $post['alert'] = '<div class="alert alert-warning">' . $e->getMessage() . '</div>';
         }
     }
     $loadData = Post::get(array('cache' => 'no', 'isHook' => 'no', 'query' => "select p.*,c.title as cattitle from " . Database::getPrefix() . "post p," . Database::getPrefix() . "categories c where p.catid=c.catid AND p.postid='{$postid}'"));
     $post['edit'] = $loadData[0];
     $post['tags'] = PostTags::renderToText($postid);
     System::setTitle('Edit post - ' . ADMINCP_TITLE);
     View::make('admincp/head');
     self::makeContents('postEdit', $post);
     View::make('admincp/footer');
 }
Example #4
0
 public static function update($listID, $post = array(), $whereQuery = '', $addWhere = '')
 {
     if (isset($post['content'])) {
         // $post['content']=Shortcode::toBBCode($post['content']);
         $post['content'] = String::encode(strip_tags($post['content'], '<p><br>'));
     }
     if (is_numeric($listID)) {
         $catid = $listID;
         unset($listID);
         $listID = array($catid);
     }
     $listIDs = "'" . implode("','", $listID) . "'";
     $keyNames = array_keys($post);
     $total = count($post);
     $setUpdates = '';
     for ($i = 0; $i < $total; $i++) {
         $keyName = $keyNames[$i];
         $setUpdates .= "{$keyName}='{$post[$keyName]}', ";
     }
     $setUpdates = substr($setUpdates, 0, strlen($setUpdates) - 2);
     $whereQuery = isset($whereQuery[5]) ? $whereQuery : "commentid in ({$listIDs})";
     $addWhere = isset($addWhere[5]) ? $addWhere : "";
     Database::query("update " . Database::getPrefix() . "comments set {$setUpdates} where {$whereQuery} {$addWhere}");
     // DBCache::removeDir('system/comment');
     DBCache::removeCache($listIDs, 'system/comment');
     if (!($error = Database::hasError())) {
         return true;
     }
     return false;
 }
Example #5
0
 public static function update($listID, $post = array(), $whereQuery = '', $addWhere = '')
 {
     if (is_numeric($listID)) {
         $userid = $listID;
         unset($listID);
         $listID = array($userid);
     }
     $listIDs = "'" . implode("','", $listID) . "'";
     $keyNames = array_keys($post);
     $total = count($post);
     $setUpdates = '';
     for ($i = 0; $i < $total; $i++) {
         $keyName = $keyNames[$i];
         $setUpdates .= "{$keyName}='{$post[$keyName]}', ";
     }
     $setUpdates = substr($setUpdates, 0, strlen($setUpdates) - 2);
     $whereQuery = isset($whereQuery[5]) ? $whereQuery : "userid in ({$listIDs})";
     $addWhere = isset($addWhere[5]) ? $addWhere : "";
     Database::query("update " . Database::getPrefix() . "address set {$setUpdates} where {$whereQuery} {$addWhere}");
     // DBCache::removeDir('system/address');
     DBCache::removeCache($listIDs, 'system/address');
     if (!($error = Database::hasError())) {
         return true;
     }
     return false;
 }
 public static function update($listID, $post = array(), $whereQuery = '', $addWhere = '')
 {
     if (isset($post['groupdata']) && !is_array($post['groupdata'])) {
         $post['groupdata'] = self::lineToArray($post['groupdata']);
     }
     if (is_numeric($listID)) {
         $catid = $listID;
         unset($listID);
         $listID = array($catid);
     }
     $listIDs = "'" . implode("','", $listID) . "'";
     $keyNames = array_keys($post);
     $total = count($post);
     $setUpdates = '';
     for ($i = 0; $i < $total; $i++) {
         $keyName = $keyNames[$i];
         $setUpdates .= "{$keyName}='{$post[$keyName]}', ";
     }
     $setUpdates = substr($setUpdates, 0, strlen($setUpdates) - 2);
     $whereQuery = isset($whereQuery[5]) ? $whereQuery : "groupid in ({$listIDs})";
     $addWhere = isset($addWhere[5]) ? $addWhere : "";
     $prefix = '';
     $prefixall = Database::isPrefixAll();
     if ($prefixall != false || $prefixall == 'no') {
         $prefix = Database::getPrefix();
     }
     Database::query("update " . $prefix . "usergroups set {$setUpdates} where {$whereQuery} {$addWhere}");
     // DBCache::removeDir('system/usergroup');
     // DBCache::removeCache($listIDs,'system/usergroup');
     if (!($error = Database::hasError())) {
         $loadData = self::get(array('where' => "where groupid IN ({$listIDs})"));
         $total = count($loadData);
         for ($i = 0; $i < $total; $i++) {
             $loadData[$i]['groupdata'] = self::lineToArray($loadData[$i]['groupdata']);
             Cache::saveKey($prefix . 'userGroup_' . $loadData[$i]['groupid'], serialize($loadData[$i]));
         }
         return true;
     }
     return false;
 }
Example #7
0
 public static function update($listID, $post = array(), $whereQuery = '', $addWhere = '')
 {
     if (is_numeric($listID)) {
         $catid = $listID;
         unset($listID);
         $listID = array($catid);
     }
     $listIDs = "'" . implode("','", $listID) . "'";
     if (isset($post['title'])) {
         $postTitle = isset($post['addTitle']) ? $post['addTitle'] : $post['title'];
         $post['title'] = String::encode(strip_tags($post['title']));
         $post['friendly_url'] = String::makeFriendlyUrl(strip_tags($postTitle));
         $loadPost = self::get(array('where' => "where friendly_url='" . $post['friendly_url'] . "'"));
         if (isset($loadPost[0]['postid']) && (int) $loadPost[0]['postid'] != (int) $listID[0]) {
             return false;
         }
     }
     if (isset($post['content'])) {
         // $post['content']=Shortcode::toBBCode($post['content']);
         $post['content'] = String::encode($post['content']);
     }
     $keyNames = array_keys($post);
     $total = count($post);
     $setUpdates = '';
     for ($i = 0; $i < $total; $i++) {
         $keyName = $keyNames[$i];
         $setUpdates .= "{$keyName}='{$post[$keyName]}', ";
     }
     $setUpdates = substr($setUpdates, 0, strlen($setUpdates) - 2);
     $whereQuery = isset($whereQuery[5]) ? $whereQuery : "postid in ({$listIDs})";
     $addWhere = isset($addWhere[5]) ? $addWhere : "";
     Database::query("update " . Database::getPrefix() . "post set {$setUpdates} where {$whereQuery} {$addWhere}");
     // DBCache::removeDir('system/post');
     // DBCache::removeCache($listIDs,'system/post');
     if (!($error = Database::hasError())) {
         return true;
     }
     return false;
 }
 public function profile()
 {
     $post = array('alert' => '');
     $match = Uri::match('\\/profile$');
     $userid = Users::getCookieUserId();
     if (Request::has('btnSave')) {
         try {
             updateProcess($userid);
             $post['alert'] = '<div class="alert alert-success">Save changes success.</div>';
         } catch (Exception $e) {
             $post['alert'] = '<div class="alert alert-warning">' . $e->getMessage() . '</div>';
         }
     }
     if (Request::has('btnChangePassword')) {
         Users::changePassword($userid, Request::get('password', ''));
     }
     $prefix = '';
     $prefixall = Database::isPrefixAll();
     if ($prefixall != false || $prefixall == 'no') {
         $prefix = Database::getPrefix();
     }
     $loadData = Users::get(array('query' => "select u.*,ug.*,a.* from " . $prefix . "users u," . $prefix . "usergroups ug," . $prefix . "address a where u.groupid=ug.groupid AND u.userid=a.userid AND u.userid='{$userid}' order by u.userid desc"));
     $post['edit'] = $loadData[0];
     $post['listGroups'] = UserGroups::get();
     System::setTitle('Profile - ' . ADMINCP_TITLE);
     View::make('admincp/head');
     self::makeContents('userEdit', $post);
     View::make('admincp/footer');
 }