本文整理匯總了PHP中JCommentsFactory::getCmdHash方法的典型用法代碼示例。如果您正苦於以下問題:PHP JCommentsFactory::getCmdHash方法的具體用法?PHP JCommentsFactory::getCmdHash怎麽用?PHP JCommentsFactory::getCmdHash使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類JCommentsFactory
的用法示例。
在下文中一共展示了JCommentsFactory::getCmdHash方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: executeCmd
public static function executeCmd()
{
$app = JFactory::getApplication('site');
$cmd = strtolower($app->input->get('cmd', ''));
$hash = $app->input->get('hash', '');
$id = $app->input->getInt('id', 0);
$message = '';
$link = str_replace('/administrator', '', JURI::root()) . 'index.php';
$checkHash = JCommentsFactory::getCmdHash($cmd, $id);
if ($hash == $checkHash) {
$config = JCommentsFactory::getConfig();
if ($config->getInt('enable_quick_moderation') == 1) {
JTable::addIncludePath(JCOMMENTS_TABLES);
$comment = JTable::getInstance('Comment', 'JCommentsTable');
if ($comment->load($id)) {
$link = JCommentsObjectHelper::getLink($comment->object_id, $comment->object_group, $comment->lang);
$link = str_replace('&', '&', $link);
switch ($cmd) {
case 'publish':
$comment->published = 1;
$comment->store();
// send notification to comment subscribers
JComments::sendToSubscribers($comment, true);
$link .= '#comment-' . $comment->id;
break;
case 'unpublish':
$comment->published = 0;
$comment->store();
$acl = JCommentsFactory::getACL();
if ($acl->canPublish()) {
$link .= '#comment-' . $comment->id;
} else {
$link .= '#comments';
}
break;
case 'delete':
if ($config->getInt('delete_mode') == 0) {
$comment->delete();
$link .= '#comments';
} else {
$comment->markAsDeleted();
$link .= '#comment-' . $comment->id;
}
break;
case 'ban':
if ($config->getInt('enable_blacklist') == 1) {
$acl = JCommentsFactory::getACL();
// we will not ban own IP ;)
if ($comment->ip != $acl->getUserIP()) {
$options = array();
$options['ip'] = $comment->ip;
// check if this IP already banned
if (JCommentsSecurity::checkBlacklist($options)) {
$blacklist = JTable::getInstance('Blacklist', 'JCommentsTable');
$blacklist->ip = $comment->ip;
$blacklist->store();
$message = JText::_('SUCCESSFULLY_BANNED');
} else {
$message = JText::_('ERROR_IP_ALREADY_BANNED');
}
} else {
$message = JText::_('ERROR_YOU_CAN_NOT_BAN_YOUR_IP');
}
}
break;
}
JCommentsNotificationHelper::send();
} else {
$message = JText::_('ERROR_NOT_FOUND');
}
} else {
$message = JText::_('ERROR_QUICK_MODERATION_DISABLED');
}
} else {
$message = JText::_('ERROR_QUICK_MODERATION_INCORRECT_HASH');
}
$app->redirect($link, $message);
}
示例2: getCmdLink
public static function getCmdLink($cmd, $id)
{
$hash = JCommentsFactory::getCmdHash($cmd, $id);
$liveSite = trim(str_replace('/administrator', '', JURI::root()), '/');
$liveSite = str_replace(JURI::root(true), '', $liveSite);
$link = $liveSite . JRoute::_('index.php?option=com_jcomments&task=cmd&cmd=' . $cmd . '&id=' . $id . '&hash=' . $hash . '&format=raw');
return $link;
}
示例3: getCmdLink
public static function getCmdLink($cmd, $id)
{
$app = JCommentsFactory::getApplication();
$hash = JCommentsFactory::getCmdHash($cmd, $id);
$liveSite = $app->getCfg('live_site');
if (JCOMMENTS_JVERSION == '1.0') {
$link = $liveSite . '/index2.php?option=com_jcomments&task=cmd&cmd=' . $cmd . '&id=' . $id . '&hash=' . $hash . '&no_html=1';
} else {
$liveSite = str_replace(JURI::root(true), '', $liveSite);
$link = $liveSite . JRoute::_('index.php?option=com_jcomments&task=cmd&cmd=' . $cmd . '&id=' . $id . '&hash=' . $hash . '&format=raw');
}
return $link;
}
示例4: executeCmd
function executeCmd()
{
global $mainframe;
$cmd = strtolower(JCommentsInput::getVar('cmd', ''));
$hash = JCommentsInput::getVar('hash', '');
$id = (int) JCommentsInput::getVar('id', 0);
$error = '';
$link = $mainframe->getCfg('live_site') . '/index.php';
$checkHash = JCommentsFactory::getCmdHash($cmd, $id);
if ($hash == $checkHash) {
$config =& JCommentsFactory::getConfig();
if ($config->getInt('enable_quick_moderation') == 1) {
$dbo =& JCommentsFactory::getDBO();
$comment = new JCommentsDB($dbo);
if ($comment->load($id)) {
$link = JCommentsObjectHelper::getLink($comment->object_id, $comment->object_group);
$link = str_replace('&', '&', $link);
switch ($cmd) {
case 'publish':
$comment->published = 1;
$comment->store();
$link .= '#comment-' . $comment->id;
break;
case 'unpublish':
$comment->published = 0;
$comment->store();
$acl =& JCommentsFactory::getACL();
if ($acl->canPublish()) {
$link .= '#comment-' . $comment->id;
} else {
$link .= '#comments';
}
break;
case 'delete':
$comment->delete();
$link .= '#comments';
break;
}
}
} else {
$error = JText::_('Quick moderation function is disabled by administrator!');
}
} else {
$error = JText::_('Incorrect hash for this operation!');
}
JCommentsRedirect($link, $error);
}