Exemplo n.º 1
0
 function __construct()
 {
     JLog::add(new JLogEntry(__METHOD__, JLOG::DEBUG, 'lib_j2xml'));
     // Merge the default translation with the current translation
     $jlang = JFactory::getLanguage();
     $jlang->load('lib_j2xml', JPATH_SITE, 'en-GB', true);
     $jlang->load('lib_j2xml', JPATH_SITE, $jlang->getDefault(), true);
     $jlang->load('lib_j2xml', JPATH_SITE, null, true);
     $db = JFactory::getDBO();
     $user = JFactory::getUser();
     $this->_nullDate = $db->getNullDate();
     $this->_user_id = $user->get('id');
     $this->_now = class_exists('JPlatform') && version_compare(JPlatform::RELEASE, '12', 'ge') ? JFactory::getDate()->format("%Y-%m-%d-%H-%M-%S") : JFactory::getDate()->toFormat("%Y-%m-%d-%H-%M-%S");
     $this->_option = PHP_SAPI != 'cli' ? JRequest::getCmd('option') : 'cli_' . strtolower(get_class(JApplicationCli::getInstance()));
     $execute = class_exists('JPlatform') && version_compare(JPlatform::RELEASE, '12', 'ge') ? 'execute' : 'query';
     $db->setQuery("\r\n\t\t\tCREATE TABLE IF NOT EXISTS `#__j2xml_usergroups` (\r\n\t\t\t\t`id` int(10) unsigned NOT NULL,\r\n\t\t\t\t`parent_id` int(10) unsigned NOT NULL DEFAULT '0',\r\n\t\t\t\t`title` varchar(100) NOT NULL DEFAULT ''\r\n\t\t\t) ENGINE=InnoDB  DEFAULT CHARSET=utf8;\r\n\t\t\t")->{$execute}();
     $db->setQuery("\r\n\t\t\tTRUNCATE TABLE\r\n\t\t\t\t`#__j2xml_usergroups`;\r\n\t\t\t")->{$execute}();
     $db->setQuery("\r\n\t\t\tINSERT INTO\r\n\t\t\t\t`#__j2xml_usergroups`\r\n\t\t\tSELECT\r\n\t\t\t\t`id`,`parent_id`,CONCAT('[\"',REPLACE(`title`,'\"','\\\"'),'\"]')\r\n\t\t\tFROM\r\n\t\t\t\t`#__usergroups`;\r\n\t\t\t")->{$execute}();
     do {
         $db->setQuery("\r\n\t\t\t\tUPDATE\r\n\t\t\t\t\t`#__j2xml_usergroups` j\r\n\t\t\t\tINNER JOIN\r\n\t\t\t\t\t`#__usergroups` g\r\n\t\t\t\tON\r\n\t\t\t\t\tj.parent_id = g.id\r\n\t\t\t\tSET\r\n\t\t\t\t\tj.parent_id = g.parent_id,\r\n\t\t\t\t\tj.title = CONCAT('[\"',REPLACE(`g`.`title`,'\"','\\\"'), '\",', SUBSTR(`j`.`title`,2));\r\n\t\t\t\t")->{$execute}();
         $n = $db->setQuery("\r\n\t\t\t\tSELECT\r\n\t\t\t\t\tCOUNT(*)\r\n\t\t\t\tFROM\r\n\t\t\t\t\t`#__j2xml_usergroups`\r\n\t\t\t\tWHERE\r\n\t\t\t\t\t`parent_id` > 0;\r\n\t\t\t\t")->loadResult();
     } while ($n > 0);
     $db->setQuery("\r\n\t\t\tINSERT INTO\r\n\t\t\t\t`#__j2xml_usergroups`\r\n\t\t\tSELECT\r\n\t\t\t\t`id`,`parent_id`,`title`\r\n\t\t\tFROM\r\n\t\t\t\t`#__usergroups`;\r\n\t\t\t")->{$execute}();
     $this->_usergroups = $db->setQuery("SELECT `title`,`id` FROM `#__j2xml_usergroups`")->loadAssocList('title', 'id');
 }
Exemplo n.º 2
0
 /**
  * Overrides JGithub constructor to initialise the api property.
  *
  * @param   mixed  $input       An optional argument to provide dependency injection for the application's
  *                              input object.  If the argument is a JInputCli object that object will become
  *                              the application's input object, otherwise a default input object is created.
  * @param   mixed  $config      An optional argument to provide dependency injection for the application's
  *                              config object.  If the argument is a JRegistry object that object will become
  *                              the application's config object, otherwise a default config object is created.
  * @param   mixed  $dispatcher  An optional argument to provide dependency injection for the application's
  *                              event dispatcher.  If the argument is a JDispatcher object that object will become
  *                              the application's event dispatcher, if it is null then the default event dispatcher
  *                              will be created based on the application's loadDispatcher() method.
  *
  * @see     loadDispatcher()
  * @since   11.1
  */
 public function __construct(JInputCli $input = null, JRegistry $config = null, JDispatcher $dispatcher = null)
 {
     parent::__construct($input, $config, $dispatcher);
     $options = new JRegistry();
     $options->set('headers.Accept', 'application/vnd.github.html+json');
     $this->api = new JGithub($options);
 }
Exemplo n.º 3
0
 public function __construct(JInputCli $input = null, JRegistry $config = null, JDispatcher $dispatcher = null)
 {
     // CLI Constructor
     parent::__construct($input, $config, $dispatcher);
     // Utilities
     $this->db = JFactory::getDBO();
     $this->updater = JUpdater::getInstance();
     $this->installer = JComponentHelper::getComponent('com_installer');
     // Validate Log Path
     $logPath = $this->config->get('log_path');
     if (!is_dir($logPath) || !is_writeable($logPath)) {
         $logPath = JPATH_BASE . '/logs';
         if (!is_dir($logPath) || !is_writeable($logPath)) {
             $this->out('Log Path not found - ' . $logPath);
         }
         $this->config->set('log_path', JPATH_BASE . '/logs');
     }
     // Validate Tmp Path
     $tmpPath = $this->config->get('tmp_path');
     if (!is_writeable($tmpPath)) {
         $tmpPath = JPATH_BASE . '/tmp';
         if (!is_dir($tmpPath) || !is_writeable($tmpPath)) {
             $this->out('Tmp Path not found - ' . $tmpPath);
         }
         $this->config->set('tmp_path', JPATH_BASE . '/tmp');
     }
     // Push to Global Config
     $config = JFactory::getConfig();
     $config->set('tmp_path', $this->config->get('tmp_path'));
     $config->set('log_path', $this->config->get('log_path'));
 }
Exemplo n.º 4
0
 /**
  * Class constructor.
  *
  * This constructor invokes the parent JApplicationCli class constructor,
  * and then creates a connector to the database so that it is
  * always available to the application when needed.
  *
  */
 public function __construct()
 {
     // Call the parent __construct method so it bootstraps the application class.
     parent::__construct();
     jimport('joomla.database.database');
     // Note, this will throw an exception if there is an error
     // creating the database connection.
     $this->dbo = JDatabase::getInstance(array('driver' => $this->get('dbDriver'), 'host' => $this->get('dbHost'), 'user' => $this->get('dbUser'), 'password' => $this->get('dbPass'), 'database' => $this->get('dbName'), 'prefix' => $this->get('dbPrefix')));
 }
Exemplo n.º 5
0
 /**
  * Class constructor.
  *
  * This constructor invokes the parent JApplicationCli class constructor,
  * and then creates a connector to the database so that it is
  * always available to the application when needed.
  *
  * @since   11.3
  * @throws  JDatabaseException
  */
 public function __construct()
 {
     // Call the parent __construct method so it bootstraps the application class.
     parent::__construct();
     jimport('joomla.database.database');
     $this->dbo = JFactory::getDbo();
     $this->app = JFactory::getApplication('site');
     $this->config = JFactory::getConfig();
 }
Exemplo n.º 6
0
 /**
  * CONSTRUCTOR
  * @param object $subject The object to observe
  * @param object $params  The object that holds the plugin parameters
  * @since 1.5
  */
 function __construct()
 {
     JLog::add(new JLogEntry(__METHOD__, JLOG::DEBUG, 'lib_j2xml'));
     $execute = class_exists('JPlatform') && version_compare(JPlatform::RELEASE, '12', 'ge') ? 'execute' : 'query';
     $db = JFactory::getDBO();
     $db->setQuery("\r\n\t\t\t\t\tCREATE TABLE IF NOT EXISTS `#__j2xml_usergroups` (\r\n\t\t\t\t\t\t`id` int(10) unsigned NOT NULL,\r\n\t\t\t\t\t\t`parent_id` int(10) unsigned NOT NULL DEFAULT '0',\r\n\t\t\t\t\t\t`title` varchar(100) NOT NULL DEFAULT ''\r\n\t\t\t\t\t) ENGINE=InnoDB  DEFAULT CHARSET=utf8;\r\n\t\t\t\t\t")->{$execute}();
     $db->setQuery("\r\n\t\t\t\t\tTRUNCATE TABLE\r\n\t\t\t\t\t\t`#__j2xml_usergroups`;\r\n\t\t\t\t\t")->{$execute}();
     $db->setQuery("\r\n\t\t\t\t\tINSERT INTO\r\n\t\t\t\t\t\t`#__j2xml_usergroups`\r\n\t\t\t\t\tSELECT\r\n\t\t\t\t\t\t`id`,`parent_id`,CONCAT('[\"',REPLACE(`title`,'\"','\\\"'),'\"]')\r\n\t\t\t\t\tFROM\r\n\t\t\t\t\t\t`#__usergroups`;\r\n\t\t\t\t\t")->{$execute}();
     do {
         $db->setQuery("\r\n\t\t\t\t\tUPDATE\r\n\t\t\t\t\t\t`#__j2xml_usergroups` j\r\n\t\t\t\t\tINNER JOIN\r\n\t\t\t\t\t\t`#__usergroups` g\r\n\t\t\t\t\tON\r\n\t\t\t\t\t\tj.parent_id = g.id\r\n\t\t\t\t\tSET\r\n\t\t\t\t\t\tj.parent_id = g.parent_id,\r\n\t\t\t\t\t\tj.title = CONCAT('[\"',REPLACE(`g`.`title`,'\"','\\\"'), '\",', SUBSTR(`j`.`title`,2));\r\n\t\t\t\t\t")->{$execute}();
         $n = $db->setQuery("\r\n\t\t\t\t\tSELECT\r\n\t\t\t\t\t\tCOUNT(*)\r\n\t\t\t\t\tFROM\r\n\t\t\t\t\t\t`#__j2xml_usergroups`\r\n\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t`parent_id` > 0;\r\n\t\t\t\t\t")->loadResult();
     } while ($n > 0);
     $this->option = PHP_SAPI != 'cli' ? JRequest::getCmd('option') : 'cli_' . strtolower(get_class(JApplicationCli::getInstance()));
 }
Exemplo n.º 7
0
 function invoke($numParams, &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6, $fnSuffix)
 {
     // ensure that we are running in a joomla context
     // we've not yet figured out how to bootstrap joomla, so we should
     // not execute hooks if joomla is not loaded
     if (defined('_JEXEC')) {
         //Invoke the Joomla plugin system to observe to civicrm events.
         jimport('joomla.plugin.helper');
         jimport('cms.plugin.helper');
         // Joomla 3.2
         JPluginHelper::importPlugin('civicrm');
         // get app based on cli or web
         if (PHP_SAPI != 'cli') {
             $app = JFactory::getApplication('administrator');
         } else {
             // condition on Joomla version
             if (version_compare(JVERSION, '3.0', 'lt')) {
                 $app = JCli::getInstance();
             } else {
                 $app = JApplicationCli::getInstance();
             }
         }
         $result = $app->triggerEvent($fnSuffix, array(&$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6));
         $moduleResult = $this->commonInvoke($numParams, $arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $fnSuffix, 'joomla');
         if (!empty($moduleResult) && is_array($moduleResult)) {
             if (empty($result)) {
                 $result = $moduleResult;
             } else {
                 if (is_array($moduleResult)) {
                     $result = array_merge($result, $moduleResult);
                 }
             }
         }
         if (!empty($result)) {
             // collapse result returned from hooks
             // CRM-9XXX
             $finalResult = array();
             foreach ($result as $res) {
                 if (!is_array($res)) {
                     $res = array($res);
                 }
                 $finalResult = array_merge($finalResult, $res);
             }
             $result = $finalResult;
         }
         return $result;
     }
 }
Exemplo n.º 8
0
 /**
  * Class constructor.
  *
  * This constructor invokes the parent JApplicationCli class constructor,
  * and then creates a connector to the database so that it is
  * always available to the application when needed.
  *
  * @since   11.3
  * @throws  JDatabaseException
  */
 public function __construct()
 {
     // Call the parent __construct method so it bootstraps the application class.
     parent::__construct();
     //
     // Prepare the logger.
     //
     // Include the JLog class.
     jimport('joomla.log.log');
     // Get the date so that we can roll the logs over a time interval.
     $date = JFactory::getDate()->format('Y-m-d');
     // Add the logger.
     JLog::addLogger(array('text_file' => 'cron.' . $date . '.php', 'text_file_path' => __DIR__ . '/logs'));
     //
     // Prepare the database connection.
     //
     jimport('joomla.database.database');
     // Note, this will throw an exception if there is an error
     // creating the database connection.
     $this->dbo = JDatabase::getInstance(array('driver' => $this->get('dbDriver'), 'host' => $this->get('dbHost'), 'user' => $this->get('dbUser'), 'password' => $this->get('dbPass'), 'database' => $this->get('dbName'), 'prefix' => $this->get('dbPrefix')));
 }
Exemplo n.º 9
0
        if (file_exists($jsonFile) == false) {
            return false;
        }
        $data = json_decode(file_get_contents($jsonFile), true);
        if (empty($data)) {
            return false;
        }
        $username = $data['credentials']['username'];
        $password = $data['credentials']['password'];
        $password = JUserHelper::hashPassword($password);
        $db = JFactory::getDBO();
        $query = $db->getQuery(true);
        $query->update($db->quoteName('#__users'))->set($db->quoteName('password') . ' = ' . $db->quote($password))->set($db->quoteName('username') . ' = ' . $db->quote($username))->where(array($db->quoteName('username') . '= "admin"'));
        $db->setQuery($query);
        $db->execute();
        return true;
    }
    public function togglePlugin($name, $folder, $state = 0)
    {
        $db = JFactory::getDBO();
        $query = $db->getQuery(true);
        $query->update($db->quoteName('#__extensions'))->set($db->quoteName('enabled') . ' = ' . (int) $state)->where(array($db->quoteName('type') . '=' . $db->quote('plugin'), $db->quoteName('element') . '=' . $db->quote($name), $db->quoteName('folder') . '=' . $db->quote($folder)));
        $db->setQuery($query);
        $db->execute();
        return true;
    }
}
// Instantiate the application object, passing the class name to JCli::getInstance
// and use chaining to execute the application.
JApplicationCli::getInstance('PbfCli')->execute();
        if ($result instanceof Exception || $result === false) {
            $this->out(" FAILED");
            return false;
        } else {
            $this->out(" SENT");
            return true;
        }
    }
    function memUsage()
    {
        if (function_exists('memory_get_usage')) {
            $size = memory_get_usage();
            $unit = array('b', 'Kb', 'Mb', 'Gb', 'Tb', 'Pb');
            return @round($size / pow(1024, $i = floor(log($size, 1024))), 2) . ' ' . $unit[$i];
        } else {
            return "(unknown)";
        }
    }
    function peakMemUsage()
    {
        if (function_exists('memory_get_peak_usage')) {
            $size = memory_get_peak_usage();
            $unit = array('b', 'Kb', 'Mb', 'Gb', 'Tb', 'Pb');
            return @round($size / pow(1024, $i = floor(log($size, 1024))), 2) . ' ' . $unit[$i];
        } else {
            return "(unknown)";
        }
    }
}
JApplicationCli::getInstance('AkeebaSubscriptionsExpirationNotifyApp')->execute();
 * A command line cron job to attempt to remove files that should have been deleted at update.
 *
 * @package  Joomla.Cli
 * @since    3.0
 */
class DeletefilesCli extends JApplicationCli
{
    /**
     * Entry point for CLI script
     *
     * @return  void
     *
     * @since   3.0
     */
    public function doExecute()
    {
        // Import the dependencies
        jimport('joomla.filesystem.file');
        jimport('joomla.filesystem.folder');
        // We need the update script
        JLoader::register('JoomlaInstallerScript', JPATH_ADMINISTRATOR . '/components/com_admin/script.php');
        // Instantiate the class
        $class = new JoomlaInstallerScript();
        // Run the delete method
        $class->deleteUnexistingFiles();
    }
}
// Instantiate the application object, passing the class name to JCli::getInstance
// and use chaining to execute the application.
JApplicationCli::getInstance('DeletefilesCli')->execute();
            case 'plugin':
                $path = JPATH_PLUGINS . '/' . $group . '/' . $name . '/' . $name;
                break;
            case 'library':
                $path = JPATH_MANIFESTS . '/libraries/' . $name;
                break;
            default:
                throw new InvalidArgumentException(sprintf('Extension type "%s" does not support.', $type));
        }
        return Jpath::clean($reference ? str_replace(JPATH_ROOT, '', $path) : $path);
    }
    protected function getTempPath()
    {
        $path = JPath::clean($this->get('tmp_path'));
        if (!is_dir($path)) {
            throw new Exception(sprintf('Dir "%s" does not exists.', $path));
        }
        if (!is_writable($path)) {
            throw new Exception(sprintf('Dir "%s" does not writable.', $path));
        }
        return $path;
    }
    protected static function error($text)
    {
        return sprintf("[%sm%s", implode(';', self::$error), $text);
    }
}
// Instantiate the application object, passing the class name to JCli::getInstance
// and use chaining to execute the application.
JApplicationCli::getInstance('CreateExtensionCli')->execute();
Exemplo n.º 13
0
                    $paymentNew->retry_counter -= 1;
                    RApiPaymentHelper::updatePaymentCounter($paymentNew->id, $paymentNew->retry_counter);
                    $this->out('Retry checks left: ' . $paymentNew->retry_counter);
                }
                $this->out('============================');
            }
        }
        $this->out('============================');
        $this->out('Done !');
    }
    /**
     * Get payments pending for checking
     *
     * @return mixed
     */
    public function getPaymentsForChecking()
    {
        $db = JFactory::getDbo();
        $finalStatuses = array();
        $retryTime = RBootstrap::getConfig('payment_time_between_payment_check_requests', 24);
        foreach ($this->finalStatuses as $status) {
            $finalStatuses[] = $db->q($status);
        }
        $query = $db->getQuery(true)->select('p.*')->from($db->qn('#__redcore_payments', 'p'))->where('p.status NOT IN (' . implode(',', $finalStatuses) . ')')->where('p.retry_counter > 0')->where('TIMESTAMPDIFF(HOUR, p.modified_date, NOW()) > ' . (int) $retryTime);
        $db->setQuery($query);
        $items = $db->loadObjectList();
        return $items;
    }
}
JApplicationCli::getInstance('CheckpaymentsApplicationCli')->execute();
                $header = substr($response, 0, $pos);
                $body = substr($response, $pos + 2 * strlen($crlf));
                // parse headers
                $headers = array();
                $lines = explode($crlf, $header);
                foreach ($lines as $line) {
                    if (($pos = strpos($line, ':')) !== false) {
                        $headers[strtolower(trim(substr($line, 0, $pos)))] = trim(substr($line, $pos + 1));
                    }
                }
                //redirection?
                if (isset($headers['location'])) {
                    return $this->fetchURL($headers['location'], $method);
                } else {
                    return $body;
                }
                break;
            case 'fopen':
                $opts = array('http' => array('method' => "GET", 'header' => "Accept-language: en\r\n"));
                $context = stream_context_create($opts);
                $result = @file_get_contents($url, false, $context);
                break;
        }
        return $result;
    }
}
// Load the version file
require_once JPATH_ADMINISTRATOR . '/components/com_akeeba/version.php';
// Instanciate and run the application
JApplicationCli::getInstance('AkeebaBackupCLI')->execute();
Exemplo n.º 15
0
        // Let's cleanup the downloaded archive and the temp folder
        if (JFolder::exists($package['extractdir'])) {
            JFolder::delete($package['extractdir']);
        }
        if (JFile::exists($package['packagefile'])) {
            JFile::delete($package['packagefile']);
        }
        if ($installed) {
            $this->out("Extension successfully installed");
            $this->close(0);
        } else {
            $this->out("Extension installation failed");
            $this->close(250);
        }
    }
    public function getTemplate($params = false)
    {
        return '';
    }
    public function setHeader($name, $value, $replace = false)
    {
        return $this;
    }
    public function getCfg($name, $default = null)
    {
        return $this->get($name, $default);
    }
}
$app = JApplicationCli::getInstance('JoomlaExtensionInstallerCli');
JFactory::$application = $app;
$app->execute();
Exemplo n.º 16
0
        $this->out("\t silent - yes/no. In case set to 'yes' only error messages are going to be displayed. Default set to 'yes'");
        $this->out("\t section - section id of the section you want to crawl. If not given all valid sections are going to be crawled");
        $this->out("\t timeLimit - time limit (in seconds - default 3600). If the limit has been reached while crawling the crawler will stop any actions");
        $this->out("\t cleanCache - yes/no If set to 'yes' the cache will be invalidated first. Default set to 'yes'");
        $this->out("\t loopTimeLimit - time limit (in seconds - default 15) for a loop. When reached a new loop is going to be started");
        $this->out('');
        $this->out("All settings are defined like name=value (timeLimit=100). The order doesn't matter");
        $this->out('');
        $this->out('');
    }
    protected function SpOut($txt)
    {
        if (!$this->silent) {
            $this->out($txt);
        }
    }
    /**
     * @param SPRemote $connection
     * @param string $url
     * @return array
     */
    protected function SpConnect($connection, $url)
    {
        $connection->setOptions(array('url' => $url, 'connecttimeout' => 10, 'returntransfer' => true, 'useragent' => self::USER_AGENT, 'header' => true, 'verbose' => false));
        $content = $connection->exec();
        $response = $connection->info();
        return array($content, $response);
    }
}
JApplicationCli::getInstance('SobiProCrawler')->execute($argv);
Exemplo n.º 17
0
        $c = $c === 0 ? 1 : $c;
        try {
            // Process the batches.
            for ($i = 0; $i < $c; $i++) {
                // Set the batch start time.
                $this->_qtime = microtime(true);
                // Reset the batch offset.
                $state->batchOffset = 0;
                // Trigger the onBuildIndex event.
                JEventDispatcher::getInstance()->trigger('onBuildIndex');
                // Batch reporting.
                $this->out(JText::sprintf('FINDER_CLI_BATCH_COMPLETE', $i + 1, round(microtime(true) - $this->_qtime, 3)), true);
            }
        } catch (Exception $e) {
            // Display the error
            $this->out($e->getMessage(), true);
            // Reset the indexer state.
            FinderIndexer::resetState();
            // Close the app
            $this->close($e->getCode());
        }
        // Total reporting.
        $this->out(JText::sprintf('FINDER_CLI_PROCESS_COMPLETE', round(microtime(true) - $this->_time, 3)), true);
        // Reset the indexer state.
        FinderIndexer::resetState();
    }
}
// Instantiate the application object, passing the class name to JCli::getInstance
// and use chaining to execute the application.
JApplicationCli::getInstance('FinderCli')->execute();
Exemplo n.º 18
0
 /**
  * Class constructor.
  *
  * @param   mixed  $input       An optional argument to provide dependency injection for the application's
  *                              input object.  If the argument is a JInputCli object that object will become
  *                              the application's input object, otherwise a default input object is created.
  * @param   mixed  $config      An optional argument to provide dependency injection for the application's
  *                              config object.  If the argument is a JRegistry object that object will become
  *                              the application's config object, otherwise a default config object is created.
  * @param   mixed  $dispatcher  An optional argument to provide dependency injection for the application's
  *                              event dispatcher.  If the argument is a JEventDispatcher object that object will become
  *                              the application's event dispatcher, if it is null then the default event dispatcher
  *                              will be created based on the application's loadDispatcher() method.
  *
  * @see     loadDispatcher()
  * @since   11.1
  * @deprecated  12.3 Use JApplicationCli instead.
  */
 public function __construct(JInputCli $input = null, JRegistry $config = null, JEventDispatcher $dispatcher = null)
 {
     JLog::add('JCli is deprecated. Use JApplicationCli instead.', JLog::WARNING, 'deprecated');
     parent::__construct($input, $config, $dispatcher);
 }
Exemplo n.º 19
0
 /**
  * Load an object or array into the application configuration object.
  *
  * @param   mixed  $data  Either an array or object to be loaded into the configuration object.
  *
  * @return  JCli  Instance of $this to allow chaining.
  *
  * @since   11.1
  */
 public function loadConfiguration($data)
 {
     // Execute the parent load method.
     parent::loadConfiguration($data);
     /*
      * Setup some application metadata options.  This is useful if we ever want to write out startup scripts
      * or just have some sort of information available to share about things.
      */
     // The application author name.  This string is used in generating startup scripts and has
     // a maximum of 50 characters.
     $tmp = (string) $this->config->get('author_name', 'Joomla Platform');
     $this->config->set('author_name', strlen($tmp) > 50 ? substr($tmp, 0, 50) : $tmp);
     // The application author email.  This string is used in generating startup scripts.
     $tmp = (string) $this->config->get('author_email', '*****@*****.**');
     $this->config->set('author_email', filter_var($tmp, FILTER_VALIDATE_EMAIL));
     // The application name.  This string is used in generating startup scripts.
     $tmp = (string) $this->config->get('application_name', 'JApplicationDaemon');
     $this->config->set('application_name', (string) preg_replace('/[^A-Z0-9_-]/i', '', $tmp));
     // The application description.  This string is used in generating startup scripts.
     $tmp = (string) $this->config->get('application_description', 'A generic Joomla Platform application.');
     $this->config->set('application_description', filter_var($tmp, FILTER_SANITIZE_STRING));
     /*
      * Setup the application path options.  This defines the default executable name, executable directory,
      * and also the path to the daemon process id file.
      */
     // The application executable daemon.  This string is used in generating startup scripts.
     $tmp = (string) $this->config->get('application_executable', basename($this->input->executable));
     $this->config->set('application_executable', $tmp);
     // The home directory of the daemon.
     $tmp = (string) $this->config->get('application_directory', dirname($this->input->executable));
     $this->config->set('application_directory', $tmp);
     // The pid file location.  This defaults to a path inside the /tmp directory.
     $name = $this->config->get('application_name');
     $tmp = (string) $this->config->get('application_pid_file', strtolower('/tmp/' . $name . '/' . $name . '.pid'));
     $this->config->set('application_pid_file', $tmp);
     /*
      * Setup the application identity options.  It is important to remember if the default of 0 is set for
      * either UID or GID then changing that setting will not be attempted as there is no real way to "change"
      * the identity of a process from some user to root.
      */
     // The user id under which to run the daemon.
     $tmp = (int) $this->config->get('application_uid', 0);
     $options = array('options' => array('min_range' => 0, 'max_range' => 65000));
     $this->config->set('application_uid', filter_var($tmp, FILTER_VALIDATE_INT, $options));
     // The group id under which to run the daemon.
     $tmp = (int) $this->config->get('application_gid', 0);
     $options = array('options' => array('min_range' => 0, 'max_range' => 65000));
     $this->config->set('application_gid', filter_var($tmp, FILTER_VALIDATE_INT, $options));
     // Option to kill the daemon if it cannot switch to the chosen identity.
     $tmp = (bool) $this->config->get('application_require_identity', 1);
     $this->config->set('application_require_identity', $tmp);
     /*
      * Setup the application runtime options.  By default our execution time limit is infinite obviously
      * because a daemon should be constantly running unless told otherwise.  The default limit for memory
      * usage is 128M, which admittedly is a little high, but remember it is a "limit" and PHP's memory
      * management leaves a bit to be desired :-)
      */
     // The maximum execution time of the application in seconds.  Zero is infinite.
     $tmp = $this->config->get('max_execution_time');
     if ($tmp !== null) {
         $this->config->set('max_execution_time', (int) $tmp);
     }
     // The maximum amount of memory the application can use.
     $tmp = $this->config->get('max_memory_limit', '256M');
     if ($tmp !== null) {
         $this->config->set('max_memory_limit', (string) $tmp);
     }
     return $this;
 }
Exemplo n.º 20
0
        // You can also apply input filters found in the JFilterInput class.
        // Try running this file like this:
        // $ ./run.php -f one2
        $value = $this->input->get('f', 0, 'INT');
        $this->out(sprintf('%25s = %s', 'f (cast to int)', var_export($value, true)));
        // Print out all the remaining command line arguments used to run this file.
        if (false == empty($this->input->args)) {
            $this->out();
            $this->out('These are the remaining arguments passed:');
            $this->out();
            // Unallocated arguments are found in $this->input->args.
            // Try running the file like this:
            // $ ./run.php -f foo bar
            foreach ($this->input->args as $arg) {
                $this->out($arg);
            }
        }
        // Print a blank line at the end.
        $this->out();
    }
}
// Wrap the execution in a try statement to catch any exceptions thrown anywhere in the script.
try {
    // Instantiate the application object, passing the class name to JApplicationCli::getInstance
    // and use chaining to execute the application.
    JApplicationCli::getInstance('ECR_COM_NAME')->execute();
} catch (Exception $e) {
    // An exception has been caught, just echo the message.
    fwrite(STDOUT, $e->getMessage() . "\n");
    exit($e->getCode());
}
Exemplo n.º 21
0
}
/**
 * A.
 */
class JPath
{
    /**
     * @param $input
     *
     * @return mixed
     */
    public static function clean($input)
    {
        return $input;
    }
}
/*
 * Main.
 */
try {
    //-- Execute the application.
    $application = JApplicationCli::getInstance('EasyCreator');
    JFactory::$application = $application;
    $application->execute();
    exit(0);
} catch (Exception $e) {
    //-- An exception has been caught, just echo the message.
    fwrite(STDOUT, $e->getMessage() . "\n");
    echo $e->getTraceAsString();
    exit($e->getCode());
}
            case 4:
                $tp = "High";
                break;
            case 5:
                $tp = "Very High";
                break;
        }
        return $tp;
    }
    private function _SendCronEmail($theMessage, $theUser)
    {
        $mailer = JFactory::getMailer();
        $sender = array($this->mailfrom, $this->fromname);
        $mailer->setSender($sender);
        if (!empty($this->mailcc)) {
            $cc = array($this->mailcc);
            $mailer->addCC($cc);
        }
        if (!empty($this->mailbcc)) {
            $bcc = array($this->mailbcc);
            $mailer->addBCC($bcc);
        }
        $mailer->addRecipient($theUser);
        $mailer->setSubject($this->subject);
        $mailer->isHTML(true);
        $mailer->setBody($theMessage);
        $mailer->Send();
    }
}
JApplicationCli::getInstance('PFTaskExpiryNotifierCron')->execute();
Exemplo n.º 23
0
 /**
  * Returns a reference to the global JApplicationCli object, only creating it if it doesn't already exist.
  *
  * This method must be invoked as: $cli = JApplicationCli::getInstance();
  *
  * @param   string  $name  The name (optional) of the JApplicationCli class to instantiate.
  *
  * @return  JApplicationCli
  *
  * @since   11.1
  */
 public static function getInstance($name = null)
 {
     // Only create the object if it doesn't exist.
     if (empty(self::$instance)) {
         if (class_exists($name) && is_subclass_of($name, 'JApplicationCli')) {
             self::$instance = new $name();
         } else {
             self::$instance = new JApplicationCli();
         }
     }
     return self::$instance;
 }
Exemplo n.º 24
0
  create:
    Usage: create entry_name entry_value
    Creates a new entry in the keychain called "entry_name" with the plaintext value "entry_value".
    NOTE: This is an alias for change.

  change:
    Usage: change entry_name entry_value
    Updates the keychain entry called "entry_name" with the value "entry_value".

  delete:
    Usage: delete entry_name
    Removes an entry called "entry_name" from the keychain.

  read:
    Usage: read entry_name
    Outputs the plaintext value of "entry_name" from the keychain.

  init:
    Usage: init
    Creates a new passphrase file and prompts for a new passphrase.

HELP;
        $this->out($help);
    }
}
try {
    JApplicationCli::getInstance('KeychainManager')->execute();
} catch (Exception $e) {
    echo $e->getMessage() . "\n";
    exit(1);
}
Exemplo n.º 25
0
if (!defined('_JDEFINES')) {
    define('JPATH_BASE', dirname(__DIR__));
    require_once JPATH_BASE . '/includes/defines.php';
}
// Get the framework.
require_once JPATH_LIBRARIES . '/import.legacy.php';
// Bootstrap the CMS libraries.
require_once JPATH_LIBRARIES . '/cms.php';
/**
 * Cron job to trash expired cache data
 *
 * @package  Joomla.Cli
 * @since    2.5
 */
class GarbageCron extends JApplicationCli
{
    /**
     * Entry point for the script
     *
     * @return  void
     *
     * @since   2.5
     */
    public function doExecute()
    {
        $cache = JFactory::getCache();
        $cache->gc();
    }
}
JApplicationCli::getInstance('GarbageCron')->execute();
Exemplo n.º 26
0
 * @since    3.0
 */
class GenerateCss extends JApplicationCli
{
    /**
     * Entry point for the script
     *
     * @return  void
     *
     * @since   3.0
     */
    public function doExecute()
    {
        $templates = array(JPATH_ADMINISTRATOR . '/templates/isis/less/template.less' => JPATH_ADMINISTRATOR . '/templates/isis/css/template.css', JPATH_ADMINISTRATOR . '/templates/isis/less/template-rtl.less' => JPATH_ADMINISTRATOR . '/templates/isis/css/template-rtl.css', JPATH_ADMINISTRATOR . '/templates/hathor/less/template.less' => JPATH_ADMINISTRATOR . '/templates/hathor/css/template.css', JPATH_ADMINISTRATOR . '/templates/hathor/less/colour_blue.less' => JPATH_ADMINISTRATOR . '/templates/hathor/css/colour_blue.css', JPATH_ADMINISTRATOR . '/templates/hathor/less/colour_brown.less' => JPATH_ADMINISTRATOR . '/templates/hathor/css/colour_brown.css', JPATH_ADMINISTRATOR . '/templates/hathor/less/colour_standard.less' => JPATH_ADMINISTRATOR . '/templates/hathor/css/colour_standard.css', JPATH_SITE . '/templates/protostar/less/template.less' => JPATH_SITE . '/templates/protostar/css/template.css', __DIR__ . '/less/bootstrap-extended.less' => JPATH_SITE . '/media/jui/css/bootstrap-extended.css', __DIR__ . '/less/bootstrap-rtl.less' => JPATH_SITE . '/media/jui/css/bootstrap-rtl.css');
        // Load the RAD layer
        if (!defined('FOF_INCLUDED')) {
            require_once JPATH_LIBRARIES . '/fof/include.php';
        }
        $less = new FOFLess();
        $less->setFormatter(new FOFLessFormatterJoomla());
        foreach ($templates as $source => $output) {
            try {
                $less->compileFile($source, $output);
            } catch (Exception $e) {
                echo $e->getMessage();
            }
        }
    }
}
JApplicationCli::getInstance('GenerateCss')->execute();
Exemplo n.º 27
0
 * This script will fetch the update information for all extensions and store
 * them in the database, speeding up your administrator.
 *
 * @package  Joomla.Cli
 * @since    2.5
 */
class Updatecron extends JApplicationCli
{
    /**
     * Entry point for the script
     *
     * @return  void
     *
     * @since   2.5
     */
    public function doExecute()
    {
        // Get the update cache time
        $component = JComponentHelper::getComponent('com_installer');
        $params = $component->params;
        $cache_timeout = $params->get('cachetimeout', 6, 'int');
        $cache_timeout = 3600 * $cache_timeout;
        // Find all updates
        $this->out('Fetching updates...');
        $updater = JUpdater::getInstance();
        $updater->findUpdates(0, $cache_timeout);
        $this->out('Finished fetching updates');
    }
}
JApplicationCli::getInstance('Updatecron')->execute();
        print "\n\n";
        print "\nMatching against " . count($rules) . " rules \n";
        // Get all the log files that need to be processed.
        $files = JFolder::files(JPATH_BASE . "/logs", $filter = '.php');
        foreach ($files as $file) {
            $logs = file_get_contents(JPATH_BASE . "/logs/" . $file);
            $matches = [];
            preg_match_all("/(.*)\t(.*) (.*)\t(.*)\t(.*)/", $logs, $matches);
            // regex based on the format in the Joomla JLogLoggerFormattedtext class
            // matches 1 will have date matches 2 will have priority matches 4 will have category and matches 5 message
            for ($i = 0; $i < count($matches); $i++) {
                $log_date = $matches[1][$i];
                $log_level = $matches[2][$i];
                $log_category = $matches[4][$i];
                $log_message = $matches[5][$i];
                $sig = md5($log_category . $log_level);
                if (isset($signatures[$sig])) {
                    $rule = $signatures[$sig];
                    // Now process the log files checking each element against a sig and if it matches taking the appropriate action via the plugin.
                    echo "Sig match for " . $matches[0][$i] . "\n";
                    JEventDispatcher::getInstance()->trigger("doSendLog", array(array("date" => $log_date, "level" => $log_level, "category" => $log_category, "log_message" => $log_message), $rule));
                }
            }
        }
        // Push into the database so that we don't keep messaging using a variation of the signature
    }
}
// Instantiate the application object, passing the class name to JCli::getInstance
// and use chaining to execute the application.
JApplicationCli::getInstance('SimpleLoggerProcessLogs')->execute();
Exemplo n.º 29
0
    public function doExecute()
    {
        jimport('joomla.filesystem.file');
        if (file_exists(JPATH_BASE . '/configuration.php') || file_exists(JPATH_BASE . '/config.php')) {
            $configfile = file_exists(JPATH_BASE . 'configuration.php') ? JPATH_BASE . '/config.php' : JPATH_BASE . '/configuration.php';
            if (is_writable($configfile)) {
                $config = file_get_contents($configfile);
                //Do a simple replace for the CMS and old school applications
                $newconfig = str_replace('public $offline = \'0\'', 'public $offline = \'1\'', $config);
                // Newer applications generally use JSON instead.
                if (!$newconfig) {
                    $newconfig = str_replace('"public $offline":"0"', '"public $offline":"1"', $config);
                }
                if (!$newconfig) {
                    $this->out('This application does not have an offline configuration setting.');
                } else {
                    JFile::Write($configfile, &$newconfig);
                    $this->out('Site is offline');
                }
            } else {
                $this->out('The file is not writable, you need to change the file permissions first.');
                $this->out();
            }
        } else {
            $this->out('This application does not have a configuration file');
        }
        $this->out();
    }
}
JApplicationCli::getInstance('TakeOffline')->execute();
Exemplo n.º 30
0
 */
function jgettext($string)
{
    return $string;
}
/**
 * Dummy.
 */
class JUri
{
    /**
     * Dummy.
     *
     * @static
     * @return string
     */
    public static function root()
    {
        return '';
    }
}
try {
    //-- Execute the application.
    JApplicationCli::getInstance('EcrCliBuilder')->execute();
    exit(0);
} catch (Exception $e) {
    //-- An exception has been caught, just echo the message.
    fwrite(STDOUT, $e->getMessage() . "\n");
    exit($e->getCode());
}
//try