예제 #1
0
<?php

/**
 * @version		$Id: default.php 01 2012-08-13 11:37:09Z maverick $
 * @package		CoreJoomla.CjLib
 * @subpackage	Components
 * @copyright	Copyright (C) 2009 - 2012 corejoomla.com. All rights reserved.
 * @author		Maverick
 * @link		http://www.corejoomla.com/
 * @license		License GNU General Public License version 2 or later
 */
// no direct access
defined('_JEXEC') or die('Restricted access');
$config = CJLib::get_cjconfig(true);
$link = JRoute::_('index.php?option=com_cjlib&task=process&secret=' . $config['cron_secret'], false, -1);
$link = str_replace('/administrator/', '/', $link);
?>

<h1>CoreJoomla Framework API Library</h1>
<p><strong>Version:</strong> <?php 
echo CJLIB_VER;
?>
</p>

<div id="cjlib-configuration" style="margin: 0 10px;">
	<div style="border: 1px solid #ccc; padding: 5px; ">
		<div><strong><?php 
echo JText::_('LBL_CRON_URL');
?>
</strong></div>
		<div><?php 
예제 #2
0
 public static function send_messages_from_queue($records = 60, $delay = 0, $simulated = true, $force_ids = array())
 {
     if ($simulated) {
         $cjconfig = CJLib::get_cjconfig();
         if ($cjconfig['manual_cron'] == '1') {
             require_once CJLIB_PATH . DS . 'framework' . DS . 'virtualcron.php';
             $delay = $delay > 0 ? $delay : intval($cjconfig['cron_delay']);
             $vcron = new virtualcron($delay, 'virtualcron.txt');
             if (!$vcron->allowAction()) {
                 return false;
             }
         } else {
             return false;
         }
     }
     $db = JFactory::getDbo();
     $app = JFactory::getApplication();
     $from = $app->getCfg('mailfrom');
     $fromname = $app->getCfg('fromname');
     $message_ids = array();
     $sent = array();
     $query = $db->getQuery(true);
     $query->select('id, to_addr, cc_addr, bcc_addr, html, message_id, params')->from('#__corejoomla_messagequeue');
     if (!empty($force_ids)) {
         $query->where('id in (' . implode(',', $force_ids) . ') and status = 0');
     } else {
         $query->where('status = 0');
     }
     $db->setQuery($query, 0, $records);
     $queue_items = array();
     try {
         $queue_items = $db->loadObjectList();
     } catch (Exception $e) {
         return false;
     }
     if (!empty($queue_items)) {
         foreach ($queue_items as $item) {
             $message_ids[] = $item->message_id;
         }
         $message_ids = array_unique($message_ids);
         $query = $db->getQuery(true);
         $query->select('id, asset_id, asset_name, subject, description, params')->from('#__corejoomla_messages')->where('id in (' . implode(',', $message_ids) . ')');
         $db->setQuery($query);
         $messages = array();
         try {
             $messages = $db->loadObjectList('id');
         } catch (Exception $e) {
             return false;
         }
         if (!empty($messages)) {
             $template_path = CJLIB_PATH . DS . 'framework' . DS . 'mail_templates' . DS;
             foreach ($messages as &$message) {
                 $params = json_decode($message->params);
                 if (!empty($params->template) && JFile::exists($template_path . $params->template)) {
                     $template = file_get_contents($template_path . $params->template);
                     if (!empty($params->placeholders)) {
                         foreach ($params->placeholders as $key => $value) {
                             $template = str_replace($key, $value, $template);
                         }
                     }
                     $message->description = str_replace('{description}', $message->description, $template);
                 }
             }
             $ids = array();
             foreach ($queue_items as $item) {
                 $ids[] = $item->id;
                 if (!empty($messages[$item->message_id])) {
                     $description = $messages[$item->message_id]->description;
                     if (!empty($item->params)) {
                         $params = json_decode($item->params);
                         if (!empty($params->placeholders)) {
                             foreach ($params->placeholders as $key => $value) {
                                 $description = str_replace($key, $value, $description);
                             }
                         }
                     }
                     try {
                         $return = CJFunctions::send_email($from, $fromname, $item->to_addr, $messages[$item->message_id]->subject, $description, $item->html, $item->cc_addr, $item->bcc_addr);
                         if ($return === true) {
                             $sent[] = $item->id;
                         }
                     } catch (Exception $e) {
                         // Add logger
                         $date = JFactory::getDate()->format('Y.m.d');
                         JLog::addLogger(array('text_file' => 'com_cjlib.' . $date . '.log.php'), JLog::ALL, 'com_cjlib');
                         JLog::add('Send Messages From Queue - Error: ' . print_r($e, true), JLog::ERROR, 'com_cjlib');
                     }
                 }
             }
             if (!empty($ids)) {
                 $created = JFactory::getDate()->toSql();
                 $query = $db->getQuery(true);
                 $query->update($db->qn('#__corejoomla_messagequeue'))->set($db->qn('status') . ' = 1, processed = ' . $db->q($created))->where('id in (' . implode(',', $ids) . ')');
                 $db->setQuery($query);
                 try {
                     $db->execute();
                 } catch (Exception $e) {
                     return false;
                 }
             }
         }
     }
     return $sent;
 }
예제 #3
0
파일: cjlib.php 프로젝트: pguilford/vcomcc
/**
 * @version		$Id: cjlib.php 01 2011-01-11 11:37:09Z maverick $
 * @package		CoreJoomla.CJLib
 * @subpackage	Components.framework
 * @copyright	Copyright (C) 2009 - 2010 corejoomla.com. All rights reserved.
 * @author		Maverick
 * @link		http://www.corejoomla.com/
 * @license		License GNU General Public License version 2 or later
 */
// no direct access
defined('_JEXEC') or die('Restricted access');
require_once 'framework.php';
require_once JPATH_COMPONENT . DS . 'controller.php';
CJLib::import('corejoomla.framework.core');
$config = CJLib::get_cjconfig();
$task = JRequest::getCmd('task', '');
$secret = JRequest::getCmd('secret', null);
$component = 'com_cjlib';
if ($task == 'process' && !empty($secret) && strcmp($config['cron_secret'], $secret) == 0) {
    $emails = (int) $config['cron_emails'];
    $delay = (int) $config['cron_delay'];
    $sent = CJFunctions::send_messages_from_queue($emails, $delay, false);
    if (!empty($sent)) {
        echo json_encode($sent);
    }
} else {
    if ($task = 'socialcounts') {
        require_once CJLIB_PATH . DS . 'jquery' . DS . 'social' . DS . 'socialcounts.php';
        $url = base64_decode(JFactory::getApplication()->input->getString('url'));
        if (!SocialCount::REQUIRE_LOCAL_URL || SocialCount::isLocalUrl($url)) {