Example #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');
 }
Example #2
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()));
 }
Example #3
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;
     }
 }
Example #4
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
Example #5
0
				DROP TABLE IF EXISTS `#__k2_recipe_map`;';
        $query_set = $this->dbo->setQuery($query);
        $this->dbo->execute();
        $query = 'CREATE table `#__k2_recipe_map` (
						`id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
						`k2_item_id` INT NOT NULL ,
						`new_item_id` INT NOT NULL ,
						`item_type` INT NOT NULL ,
						PRIMARY KEY (`id`)
				) ; ';
        $query_set = $this->dbo->setQuery($query);
        $this->dbo->execute();
    }
    public function getNewItemid($id)
    {
        $query = 'SELECT k2_item_id,new_item_id,item_type from #__k2_recipe_map where k2_item_id =  ' . $id . ';';
        $query_set = $this->dbo->setQuery($query);
        $newitem = $this->dbo->loadObject();
        return $newitem;
    }
}
// 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('FindHrefsApp')->execute();
} catch (Exception $e) {
    // An exception has been caught, just echo the message.
    fwrite(STDOUT, $e->getMessage() . "\n");
    exit($e->getCode());
}
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();
 * 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();
Example #8
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();
 * 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();
        $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();
Example #11
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();
        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();
    {
        //$query = "SELECT * from #__k2_categories WHERE trash != 1 and published = 1 and extraFieldsGroup = 1 order by id;" ;
        $query = "SELECT * from #__k2_categories WHERE trash != 1 and published = 1 order by id;";
        $query_set = $this->dbo->setQuery($query);
        $categories = $this->dbo->loadObjectList();
        return $categories;
    }
    public function createCategories($cats)
    {
        foreach ($cats as $key => $category) {
            //$this->out("Category Object --> " . print_r($category,true));
            $k2_catid = $category->id;
            //$this->out(print_r($params,true));
            if ($category->extraFieldsGroup == 1) {
                $this->recipe_catids = $this->recipe_catids . ', ' . $category->id;
            } else {
                $this->article_catids = $this->article_catids . ', ' . $category->id;
            }
        }
    }
}
// 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('ExtractK2Ingredients')->execute();
} catch (Exception $e) {
    // An exception has been caught, just echo the message.
    fwrite(STDOUT, $e->getMessage() . "\n");
    exit($e->getCode());
}
        // 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();
Example #15
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);
                if ($do_list) {
                    $this->out(implode('', array(str_pad($update_row->update_id, 10, ' ', STR_PAD_RIGHT), str_pad($update_row->extension_id, 15, ' ', STR_PAD_RIGHT), str_pad($update_row->element, 30, ' ', STR_PAD_RIGHT), str_pad($update_row->type, 15, ' ', STR_PAD_RIGHT), str_pad($update_row->version, 10, ' ', STR_PAD_RIGHT))));
                }
                if ($do_update) {
                    $this->out('Processing Update #' . $update_row->update_id . '...');
                    if (!$this->doInstallUpdate($update_row)) {
                        $this->out(' - Installation Failed - ABORT');
                        return false;
                    }
                }
            } while (count($update_lookup) && ($update_row = $this->getNextUpdateRow(array_shift($update_lookup))));
            if ($do_update) {
                $this->out('Update processing complete');
            }
        } else {
            $this->out('No updates found');
        }
    }
    public function doExecute()
    {
        if ($this->input->get('f', $this->input->get('fetch'))) {
            $this->doFetchUpdates();
        }
        if ($this->input->get('l', $this->input->get('list')) || $this->input->get('x', $this->input->get('export')) || $this->input->get('u', $this->input->get('update'))) {
            $this->doIterateUpdates();
        }
    }
}
// Trigger Execution
JApplicationCli::getInstance('AutoUpdateCron')->execute();
Example #17
0
        $this->out("Akeeba Release System Updater CLI");
        $this->out("Copyright (C) 2011-{$year} Nicholas K. Dionysopoulos");
        $this->out(str_repeat('-', 79));
        $this->out("Akeeba Release System is Free Software, distributed under the terms of the GNU General");
        $this->out("Public License version 3 or, at your option, any later version.");
        $this->out("This program comes with ABSOLUTELY NO WARRANTY as per sections 15 & 16 of the");
        $this->out("license. See http://www.gnu.org/licenses/gpl-3.0.html for details.");
        $this->out(str_repeat('-', 79));
        $this->out("You are using PHP {$phpversion} ({$phpenvironment})");
        $this->out("");
        $safe_mode = true;
        if (function_exists('ini_get')) {
            $safe_mode = ini_get('safe_mode');
        }
        if (!$safe_mode && function_exists('set_time_limit')) {
            $this->out("Unsetting time limit restrictions");
            @set_time_limit(0);
        }
        $this->out("Checking for new versions");
        $container = \FOF30\Container\Container::getInstance('com_akeebasubs');
        /** @var \Akeeba\ReleaseSystem\Admin\Model\Updates $updateModel */
        $updateModel = $container->factory->model('Updates')->tmpInstance();
        $result = $updateModel->autoupdate();
        echo implode("\n", $result['message']);
        $this->close(0);
    }
}
// Instanciate and run the application
$app = JApplicationCli::getInstance('ArsUpdate');
JFactory::$application = $app;
$app->execute();
Example #18
0
                $this->out('Inflecting ' . $string, true);
                if (strpos($string, '_CATEGORIES') !== false) {
                    $inflected = str_replace('_CATEGORIES', '_CATEGORY', $string);
                } elseif (strpos($string, '_USERS') !== false) {
                    $inflected = str_replace('_USERS', '_USER', $string);
                } elseif (strpos($string, '_CATEGORY') !== false) {
                    $inflected = str_replace('_CATEGORY', '_CATEGORIES', $string);
                } elseif (strpos($string, '_USER') !== false) {
                    $inflected = str_replace('_USER', '_USERS', $string);
                } else {
                    $inflected = '';
                }
                // Now try to validate the key
                if ($inflected !== '') {
                    $this->out('Validating key COM_ADMIN_HELP_' . $inflected, true);
                    if ($language->hasKey('COM_ADMIN_HELP_' . $inflected)) {
                        $this->out('Adding ' . $inflected, true);
                        $toc[$string] = $inflected;
                    }
                }
            }
        }
        $this->out('Number of strings: ' . count($toc), true);
        // JSON encode the file and write it to JPATH_ADMINISTRATOR/help/en-GB/toc.json
        file_put_contents(JPATH_ADMINISTRATOR . '/help/en-GB/toc.json', json_encode($toc));
        $this->out('Help Screen TOC written', true);
    }
}
// Instantiate the application and execute it
JApplicationCli::getInstance('MediawikiCli')->execute();
Example #19
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);
}
            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();
            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();
Example #22
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());
}
        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();
Example #24
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());
}
Example #25
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();
Example #26
0
    /**
     * Sets a named buffer.
     *
     * @param   string   $name    The name of the buffer.
     * @param   mixed    $text    The text to put into/append to the buffer.
     * @param   boolean  $append  Append to the array buffer.
     *
     * @return  void
     *
     * @since   12.1
     */
    protected function setBuffer($name, $text, $append = true)
    {
        if (!isset($this->buffers[$name])) {
            $this->buffers[$name] = array();
        }
        if (is_array($text) || !$append) {
            $this->buffers[$name] = $text;
        } else {
            $this->buffers[$name][] = $text;
        }
    }
}
// Catch any exceptions thrown.
try {
    JApplicationCli::getInstance('Changelog')->execute();
} catch (Exception $e) {
    // An exception has been caught, just echo the message.
    fwrite(STDOUT, $e->getMessage() . "\n");
    exit($e->getCode());
}
                $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();
Example #28
0
        $profile->ordering = 1;
        $db->insertObject('#__user_profiles', $profile);
        if (!empty($user->image)) {
            $profile = new stdClass();
            $profile->user_id = $user->userID;
            $profile->profile_key = 'akprofile.image';
            $profile->profile_value = 'media/k2/users/' . $user->image;
            $profile->ordering = 2;
            $db->insertObject('#__user_profiles', $profile);
        }
        $profile = new stdClass();
        $profile->user_id = $user->userID;
        $profile->profile_key = 'akprofile.website';
        $profile->profile_value = $user->url;
        $profile->ordering = 3;
        $db->insertObject('#__user_profiles', $profile);
    }
    public function cleanBeforeMigrate()
    {
    }
}
// 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('MigrateModulesApp')->execute();
} catch (Exception $e) {
    // An exception has been caught, just echo the message.
    fwrite(STDOUT, $e->getMessage() . "\n");
    exit($e->getCode());
}
Example #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();
Example #30
0
        $query->where($conditions);
        $this->dbo->setQuery($query);
        $this->dbo->execute();
        // now categories
        $query = $this->dbo->getQuery(true);
        $conditions = array($db->quoteName('extension') . ' = ' . $db->quote('com_content'), '!(' . $db->quoteName('id') . ' = 2 OR ' . $db->quoteName('id') . ' = 26)');
        $query->delete($db->quoteName('#__categories'));
        $query->where($conditions);
        $this->dbo->setQuery($query);
        //$this->dbo->execute();
    }
    public function modifyInternalUrls()
    {
        $query = 'SELECT * from #__akrecipes_recipe order by id ';
        $query_set = $this->dbo->setQuery($query);
    }
    public function migrateUsers()
    {
        # code...
    }
}
// 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('MigrateK2ItemsApp')->execute();
} catch (Exception $e) {
    // An exception has been caught, just echo the message.
    fwrite(STDOUT, $e->getMessage() . "\n");
    exit($e->getCode());
}