/** * Update read counts of the document * @param documentItem $oDocument * @return bool|void */ function updateReadedCount(&$oDocument) { // Pass if Crawler access if (\Rhymix\Framework\UA::isRobot()) { return false; } $oDocumentModel = getModel('document'); $config = $oDocumentModel->getDocumentConfig(); if ($config->view_count_option == 'none') { return false; } $document_srl = $oDocument->document_srl; $member_srl = $oDocument->get('member_srl'); $logged_info = Context::get('logged_info'); // Call a trigger when the read count is updated (before) $trigger_output = ModuleHandler::triggerCall('document.updateReadedCount', 'before', $oDocument); if (!$trigger_output->toBool()) { return $trigger_output; } // Pass if read count is increaded on the session information if ($_SESSION['readed_document'][$document_srl] && $config->view_count_option == 'once') { return false; } else { if ($config->view_count_option == 'some') { if ($_SESSION['readed_document'][$document_srl]) { return false; } } } if ($config->view_count_option == 'once') { // Pass if the author's IP address is as same as visitor's. if ($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR'] && Context::getSessionStatus()) { $_SESSION['readed_document'][$document_srl] = true; return false; } // Pass ater registering sesscion if the author is a member and has same information as the currently logged-in user. if ($member_srl && $logged_info->member_srl == $member_srl) { $_SESSION['readed_document'][$document_srl] = true; return false; } } $oDB = DB::getInstance(); $oDB->begin(); // Update read counts $args = new stdClass(); $args->document_srl = $document_srl; executeQuery('document.updateReadedCount', $args); // Call a trigger when the read count is updated (after) ModuleHandler::triggerCall('document.updateReadedCount', 'after', $oDocument); $oDB->commit(); //remove document item from cache Rhymix\Framework\Cache::delete('document_item:' . getNumberingPath($document_srl) . $document_srl); // Register session if (!$_SESSION['banned_document'][$document_srl] && Context::getSessionStatus()) { $_SESSION['readed_document'][$document_srl] = true; } return TRUE; }
function getComments() { if (!$this->getCommentCount()) { return; } if (!$this->isGranted() && $this->isSecret()) { return; } // cpage is a number of comment pages $cpageStr = sprintf('%d_cpage', $this->document_srl); $cpage = Context::get($cpageStr); if (!$cpage) { $cpage = Context::get('cpage'); } // Get a list of comments $oCommentModel = getModel('comment'); $output = $oCommentModel->getCommentList($this->document_srl, $cpage, $is_admin); if (!$output->toBool() || !count($output->data)) { return; } // Create commentItem object from a comment list // If admin priviledge is granted on parent posts, you can read its child posts. $accessible = array(); $comment_list = array(); $setAccessibleComments = Context::getSessionStatus(); foreach ($output->data as $key => $val) { $oCommentItem = new commentItem(); $oCommentItem->setAttribute($val); // If permission is granted to the post, you can access it temporarily if ($oCommentItem->isGranted()) { $accessible[$val->comment_srl] = true; } // If the comment is set to private and it belongs child post, it is allowable to read the comment for who has a admin privilege on its parent post if ($val->parent_srl > 0 && $val->is_secret == 'Y' && !$oCommentItem->isAccessible() && $accessible[$val->parent_srl] === true) { if ($setAccessibleComments) { $oCommentItem->setAccessible(); } } $comment_list[$val->comment_srl] = $oCommentItem; } // Variable setting to be displayed on the skin Context::set($cpageStr, $output->page_navigation->cur_page); Context::set('cpage', $output->page_navigation->cur_page); if ($output->total_page > 1) { $this->comment_page_navigation = $output->page_navigation; } return $comment_list; }
/** * @brief Check if logged-in */ function isLogged() { if ($_SESSION['is_logged']) { if (Mobile::isFromMobilePhone()) { return true; } elseif (filter_var($_SESSION['ipaddress'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) { // IPv6: require same /48 if (strncmp(inet_pton($_SESSION['ipaddress']), inet_pton($_SERVER['REMOTE_ADDR']), 6) == 0) { return true; } } else { // IPv4: require same /24 if (ip2long($_SESSION['ipaddress']) >> 8 == ip2long($_SERVER['REMOTE_ADDR']) >> 8) { return true; } } } if (Context::getSessionStatus()) { $_SESSION['is_logged'] = false; } return false; }
function setAccessible() { if (Context::getSessionStatus()) { $_SESSION['accessibled_comment'][$this->comment_srl] = TRUE; } }
/** * Update read counts of the document * @param documentItem $oDocument * @return bool|void */ function updateReadedCount(&$oDocument) { // Pass if Crawler access if (isCrawler()) { return false; } $document_srl = $oDocument->document_srl; $member_srl = $oDocument->get('member_srl'); $logged_info = Context::get('logged_info'); // Call a trigger when the read count is updated (before) $trigger_output = ModuleHandler::triggerCall('document.updateReadedCount', 'before', $oDocument); if (!$trigger_output->toBool()) { return $trigger_output; } // Pass if read count is increaded on the session information if ($_SESSION['readed_document'][$document_srl]) { return false; } // Pass if the author's IP address is as same as visitor's. if ($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR'] && Context::getSessionStatus()) { $_SESSION['readed_document'][$document_srl] = true; return false; } // Pass ater registering sesscion if the author is a member and has same information as the currently logged-in user. if ($member_srl && $logged_info->member_srl == $member_srl) { $_SESSION['readed_document'][$document_srl] = true; return false; } $oDB = DB::getInstance(); $oDB->begin(); // Update read counts $args = new stdClass(); $args->document_srl = $document_srl; $output = executeQuery('document.updateReadedCount', $args); // Call a trigger when the read count is updated (after) $trigger_output = ModuleHandler::triggerCall('document.updateReadedCount', 'after', $oDocument); if (!$trigger_output->toBool()) { $oDB->rollback(); return $trigger_output; } $oDB->commit(); $oCacheHandler = CacheHandler::getInstance('object'); if ($oCacheHandler->isSupport()) { //remove document item from cache $cache_key = 'document_item:' . getNumberingPath($document_srl) . $document_srl; $oCacheHandler->delete($cache_key); } // Register session if (!$_SESSION['banned_document'][$document_srl] && Context::getSessionStatus()) { $_SESSION['readed_document'][$document_srl] = true; } return TRUE; }