コード例 #1
0
 /**
  * update views of an item
  *
  * @param integer $intThreadId
  * @return bool success
  */
 function updateViews($intThreadId, $postId = 0)
 {
     global $objDatabase;
     if (checkForSpider()) {
         return true;
     }
     $where = '';
     if ($postId > 0) {
         $where = ' AND id=' . intval($postId);
     }
     $query = '  UPDATE `' . DBPREFIX . 'module_forum_postings`
                 SET `views` = (`views` + 1)
                 WHERE `thread_id` = ' . $intThreadId . $where . ' LIMIT 1';
     if ($objDatabase->Execute($query) === false) {
         return false;
         // Unreachable
         //            echo "DB error in function: updateViews()";
     }
     return true;
 }
コード例 #2
0
ファイル: News.class.php プロジェクト: nahakiole/cloudrexx
 private function countNewsMessageView($newsMessageId)
 {
     global $objDatabase, $objCounter;
     /*
      * count stat if option "top news" is activated
      */
     if (!$this->arrSettings['news_use_top']) {
         return;
     }
     if (checkForSpider()) {
         return;
     }
     $objDatabase->Execute(' DELETE FROM `' . DBPREFIX . 'module_news_stats_view`
                             WHERE `time` < "' . date_format(date_sub(date_create('now'), date_interval_create_from_date_string(intval($this->arrSettings['news_top_days']) . ' days')), 'Y-m-d H:i:s') . '"');
     $uniqueUserId = $objCounter->getUniqueUserId();
     $query = '
         SELECT 1
         FROM `' . DBPREFIX . 'module_news_stats_view`
         WHERE user_sid = "' . $uniqueUserId . '" 
           AND news_id  = ' . $newsMessageId . '
           AND time     > "' . date_format(date_sub(date_create('now'), date_interval_create_from_date_string('1 day')), 'Y-m-d H:i:s') . '"';
     $objResult = $objDatabase->SelectLimit($query);
     if (!$objResult || !$objResult->EOF) {
         return;
     }
     $query = "INSERT INTO " . DBPREFIX . "module_news_stats_view \n                     SET user_sid = '{$uniqueUserId}',\n                         news_id  = '{$newsMessageId}'";
     $objDatabase->Execute($query);
 }
コード例 #3
0
ファイル: Shop.class.php プロジェクト: nahakiole/cloudrexx
 /**
  * Initialises the session with regard to the Shop
  *
  * Does nothing but return if either
  *  - the visitor is a known spider bot, or
  *  - use_session() returns false
  * @global  \Cx\Modules\Shop\Controller\cmsSession  $sessionObj
  * @return  void
  */
 private static function init_session()
 {
     global $sessionObj;
     if (empty($sessionObj)) {
         if (checkForSpider()) {
             return;
         }
         if (!self::use_session()) {
             return;
         }
         $sessionObj = \cmsSession::getInstance();
     }
     if (empty($_SESSION['shop'])) {
         $_SESSION['shop'] = array();
     }
 }
コード例 #4
0
 /**
  * get hits
  *
  * get hits
  *
  * @access   public
  * @param    string  $id
  * @global   ADONewConnection
  */
 function getHits($id)
 {
     global $objDatabase;
     //get feed data
     $objResult = $objDatabase->Execute("SELECT  hits, lastip, popular_hits FROM " . DBPREFIX . "module_directory_dir WHERE status = '1' AND id = '" . contrexx_addslashes($id) . "'");
     if ($objResult !== false) {
         while (!$objResult->EOF) {
             $hits = $objResult->fields['hits'];
             $popular_hits = $objResult->fields['popular_hits'];
             $lastip = $objResult->fields['lastip'];
             $objResult->MoveNext();
         }
     }
     $hits++;
     $popular_hits++;
     $ip = $_SERVER['REMOTE_ADDR'];
     //update hits
     if (!checkForSpider() && $lastip != $ip) {
         $objResult = $objDatabase->Execute("UPDATE " . DBPREFIX . "module_directory_dir SET\n                    hits='" . $hits . "', popular_hits='" . $popular_hits . "', lastip='" . $ip . "' WHERE id='" . contrexx_addslashes($id) . "'");
     }
 }
コード例 #5
0
ファイル: Directory.class.php プロジェクト: Niggu/cloudrexx
 /**
  * votes for feeds
  * @access    public
  */
 function voteFeed()
 {
     global $objDatabase, $_ARRAYLANG;
     $this->_objTpl->setTemplate($this->pageContent, true, true);
     $client = "";
     //client/proxy info
     $this->arrClient['useragent'] = htmlspecialchars($_SERVER['HTTP_USER_AGENT'], ENT_QUOTES, CONTREXX_CHARSET);
     if (stristr($this->arrClient['useragent'], "phpinfo")) {
         $this->arrClient['useragent'] = "<b>p_h_p_i_n_f_o() Possible Hacking Attack</b>";
     }
     $this->arrClient['language'] = htmlspecialchars($_SERVER['HTTP_ACCEPT_LANGUAGE'], ENT_QUOTES, CONTREXX_CHARSET);
     $this->_getProxyInformations();
     $client = md5($this->arrClient['ip'] . $this->arrClient['useragent'] . $this->arrClient['language'] . $this->arrProxy['ip'] . $this->arrProxy['host']);
     $time = time();
     $voteNEW = intval($_GET['vote']);
     $id = intval($_GET['id']);
     $cid = intval($_GET['cid']);
     $lid = intval($_GET['lid']);
     //get clients
     $objResult = $objDatabase->SelectLimit("\n            SELECT client, vote, count\n              FROM " . DBPREFIX . "module_directory_vote\n             WHERE feed_id='{$id}'\n        ", 1);
     if ($objResult) {
         while (!$objResult->EOF) {
             $clientOLD = $objResult->fields['client'];
             $voteOLD = $objResult->fields['vote'];
             $countOLD = $objResult->fields['count'];
             $objResult->MoveNext();
         }
     }
     $feedTitle = '';
     if (!checkForSpider() && isset($id) && isset($voteNEW) && $client != $clientOLD) {
         if ($voteNEW > 10) {
             $voteNEW = 10;
         } elseif ($voteNEW < 1) {
             $voteNEW = 1;
         }
         if (id !== "") {
             //insert votes
             if ($objResult->RecordCount() != 0) {
                 $vote = $voteNEW + $voteOLD;
                 $count = $countOLD + 1;
                 $objResult = $objDatabase->Execute("\n                        UPDATE " . DBPREFIX . "module_directory_vote\n                           SET vote='" . contrexx_addslashes($vote) . "',\n                               count='" . contrexx_addslashes($count) . "',\n                               client='" . contrexx_addslashes($client) . "',\n                               time='" . contrexx_addslashes($time) . "'\n                         WHERE feed_id='" . contrexx_addslashes($id) . "'\n                    ");
             } else {
                 $objResult = $objDatabase->Execute("\n                        INSERT INTO " . DBPREFIX . "module_directory_vote\n                           SET feed_id=" . contrexx_addslashes($id) . ",\n                               count='1',\n                               vote='" . contrexx_addslashes($voteNEW) . "',\n                               client='" . contrexx_addslashes($client) . "',\n                               time='" . contrexx_addslashes($time) . "'\n                    ");
             }
         }
         $title = $_ARRAYLANG['TXT_DIRECTORY_VOTING_SUCCESFULL'];
         // TODO: $feedTitle is not defined!  No idea on what to place there.
         $link = '<a href="' . CONTREXX_SCRIPT_PATH . '?section=Directory&cmd=detail&id=' . $id . '" target="_blank">' . $feedTitle . '</a>';
         //            $link = '<a href="'.CONTREXX_SCRIPT_PATH.'?section=Directory&cmd=detail&id='.$id.'" target="_blank">???</a>';
         $text = str_replace('%LINK%', $link, $_ARRAYLANG['TXT_DIRECTORY_VOTING_SUCCESFULL_TEXT']);
         $text = str_replace('%VOTE%', $voteNEW, $text);
     } else {
         $title = $_ARRAYLANG['TXT_DIRECTORY_VOTING_FAILED'];
         $text = $_ARRAYLANG['TXT_DIRECTORY_VOTING_FAILED_TEXT'];
     }
     //get navtree
     $this->getNavtree($lid, $cid);
     //get search
     $this->getSearch();
     // set variables
     $this->_objTpl->setVariable(array('DIRECTORY_CATEGORY_NAVI' => $this->navtree, 'DIRECTORY_VOTE_TITLE' => $title, 'DIRECTORY_VOTE_TEXT' => $text, 'DIRECTORY_BACK' => '<a href="javascript:history.go(-1);">' . $_ARRAYLANG['TXT_DIRECTORY_BACK'] . '</a>', 'TXT_DIRECTORY_DIR' => $_ARRAYLANG['TXT_DIR_DIRECTORY']));
 }
コード例 #6
0
ファイル: Gallery.class.php プロジェクト: Niggu/cloudrexx
 /**
  * Add a new voting to database
  * @global     ADONewConnection
  * @global     Cache
  * @param     integer        $intPicId: The picture with this id will be rated
  * @param     integer        $intMark: This mark will be set for the picture
  */
 function countVoting($intPicId, $intMark)
 {
     global $objDatabase;
     $intPicId = intval($intPicId);
     $categoryId = $this->getCategoryId($intPicId);
     $boolVoting = $this->categoryAllowsVoting($categoryId);
     if (checkForSpider() || $this->arrSettings['show_voting'] == 'off' || !$boolVoting) {
         return;
     }
     $intMark = intval($intMark);
     $strMd5 = md5($_SERVER['REMOTE_ADDR'] . $_SERVER['HTTP_USER_AGENT']);
     $intCookieTime = time() + 7 * 24 * 60 * 60;
     $intVotingCheckTime = time() - 12 * 60 * 60;
     $objResult = $objDatabase->Execute("SELECT id FROM " . DBPREFIX . "module_gallery_votes " . "WHERE ip='" . $_SERVER['REMOTE_ADDR'] . "' AND md5='" . $strMd5 . "' AND date > {$intVotingCheckTime} AND picid={$intPicId} LIMIT 1");
     if ($objResult->RecordCount() == 1) {
         $boolIpCheck = false;
         setcookie('Gallery_Voting_' . $intPicId, $intMark, $intCookieTime, ASCMS_PATH_OFFSET . '/');
     } else {
         $boolIpCheck = true;
     }
     if ($intPicId != 0 && $intMark >= 1 && $intMark <= 10 && $boolIpCheck && !isset($_COOKIE['Gallery_Voting_' . $intPicId])) {
         $objDatabase->Execute("INSERT INTO " . DBPREFIX . "module_gallery_votes " . "SET picid={$intPicId}, date=" . time() . ", ip='" . $_SERVER['REMOTE_ADDR'] . "', " . "md5='" . $strMd5 . "', mark={$intMark}");
         setcookie('Gallery_Voting_' . $intPicId, $intMark, $intCookieTime, ASCMS_PATH_OFFSET . '/');
         $pageId = \Cx\Core\Core\Controller\Cx::instanciate()->getPage()->getId();
         $cacheManager = new \Cx\Core_Modules\Cache\Controller\CacheManager();
         $cacheManager->deleteSingleFile($pageId);
     }
 }
コード例 #7
0
ファイル: News.class.php プロジェクト: Cloudrexx/cloudrexx
 private function countNewsMessageView($newsMessageId)
 {
     global $objDatabase;
     /*
      * count stat if option "top news" is activated
      */
     if (!$this->arrSettings['news_use_top']) {
         return;
     }
     if (checkForSpider()) {
         return;
     }
     $objDatabase->Execute(' DELETE FROM `' . DBPREFIX . 'module_news_stats_view`
                             WHERE `time` < "' . date_format(date_sub(date_create('now'), date_interval_create_from_date_string(intval($this->arrSettings['news_top_days']) . ' days')), 'Y-m-d H:i:s') . '"');
     $componentRepo = \Cx\Core\Core\Controller\Cx::instanciate()->getDb()->getEntityManager()->getRepository('Cx\\Core\\Core\\Model\\Entity\\SystemComponent');
     $statsComponentContoller = $componentRepo->findOneBy(array('name' => 'Stats'));
     if (!$statsComponentContoller) {
         return;
     }
     $uniqueUserId = $statsComponentContoller->getCounterInstance()->getUniqueUserId();
     $query = '
         SELECT 1
         FROM `' . DBPREFIX . 'module_news_stats_view`
         WHERE user_sid = "' . $uniqueUserId . '"
           AND news_id  = ' . $newsMessageId . '
           AND time     > "' . date_format(date_sub(date_create('now'), date_interval_create_from_date_string('1 day')), 'Y-m-d H:i:s') . '"';
     $objResult = $objDatabase->SelectLimit($query);
     if (!$objResult || !$objResult->EOF) {
         return;
     }
     $query = "INSERT INTO " . DBPREFIX . "module_news_stats_view\n                     SET user_sid = '{$uniqueUserId}',\n                         news_id  = '{$newsMessageId}'";
     $objDatabase->Execute($query);
 }
コード例 #8
0
ファイル: Shop.class.php プロジェクト: Cloudrexx/cloudrexx
 /**
  * Initialises the session with regard to the Shop
  *
  * Does nothing but return if either
  *  - the visitor is a known spider bot, or
  *  - use_session() returns false
  * @return  void
  */
 private static function init_session()
 {
     if (empty($_SESSION)) {
         if (checkForSpider()) {
             return;
         }
         if (!self::use_session()) {
             return;
         }
         $cx = \Cx\Core\Core\Controller\Cx::instanciate();
         $sessionObj = $cx->getComponent('Session')->getSession();
     }
     if (empty($_SESSION['shop'])) {
         $_SESSION['shop'] = array();
     }
 }
コード例 #9
0
ファイル: Blog.class.php プロジェクト: Cloudrexx/cloudrexx
 /**
  * Count a new visitor for a message. Increments the field "hit" by one.
  *
  * @global  ADONewConnection
  * @param   integer     $intMessageId: The hit will be counted for this message.
  */
 function addHit($intMessageId)
 {
     global $objDatabase;
     if (checkForSpider()) {
         return;
     }
     $intMessageId = intval($intMessageId);
     if ($intMessageId > 0 && !$this->hasUserJustCommented() && !$this->hasUserAlreadyVoted($intMessageId)) {
         $objDatabase->Execute(' UPDATE  ' . DBPREFIX . 'module_blog_messages
                                 SET     hits = hits + 1
                                 WHERE   message_id=' . $intMessageId . '
                                 LIMIT   1
                             ');
     }
 }