By using this class for script execution startup, initializing and shutdown the amount code required to write a new script is reduced significantly. It is also recommended to use the eZCLI class in addition to this class. What this class will handle is: - Startup of database - Startup/shutdown of session - Debug initialize and display - Text codec initialize This class consists of the static functions startup(), initialize() and shutdown(). A typical usage: \code $script = eZScript::instance(); $script->startup(); Read arguments and modify script accordingly $script->initialize(); Do the actual script here $script->shutdown(); // Finish execution \endcode
    public function __construct()
    {
        $this->cli = new \QuestionInteractiveCli();
        $this->script = \eZScript::instance( array(
            'description'    => "Debug (auto)login",
            'use-modules'    => true,
            'use-extensions' => true,
            'debug-output'   => false,
        ) );
        $this->script->startup();
        $this->script->initialize();

        $this->options = $this->script->getOptions( "[type:][nlt:][frq:]", array(
            'type'   => 'Type of action (login|autologin)',
            'nlt'       => 'Newsletter type [news|education]',
            'frq'       => 'Frequency [daily|ẁeekly|monthly]'
        ) );

        $clusterDomains = \eZINI::instance( 'merck.ini' )->variable( 'DomainMappingSettings', 'ClusterDomains' );
        $this->domains = array_flip( $clusterDomains );
    }
#!/usr/bin/env php
<?php 
/**
 * Trash purge script
 *
 * @copyright Copyright (C) 1999-2012 eZ Systems AS. All rights reserved.
 * @license http://ez.no/Resources/Software/Licenses/eZ-Business-Use-License-Agreement-eZ-BUL-Version-2.1 eZ Business Use License Agreement eZ BUL Version 2.1
 * @version 4.7.0
 * @package kernel
 */
require 'autoload.php';
$script = eZScript::instance(array('description' => "Empty eZ Publish trash.\n" . "Permanently deletes all objects in the trash.\n" . "\n" . "./bin/php/trashpurge.php", 'use-session' => false, 'use-modules' => false, 'use-extensions' => true));
$script->startup();
$options = $script->getOptions("[iteration-sleep:][iteration-limit:][memory-monitoring]", "", array('iteration-sleep' => 'Amount of seconds to sleep between each iteration when performing a purge operation, can be a float. Default is one second.', 'iteration-limit' => 'Amount of items to remove in each iteration when performing a purge operation. Default is 100.', 'memory-monitoring' => 'If set, memory usage will be logged in var/log/trashpurge.log.'));
$script->initialize();
$script->setIterationData('.', '~');
$purgeHandler = new eZScriptTrashPurge(eZCLI::instance(), false, (bool) $options['memory-monitoring'], $script);
if ($purgeHandler->run($options['iteration-limit'] ? (int) $options['iteration-limit'] : null, $options['iteration-sleep'] ? (int) $options['iteration-sleep'] : null)) {
    $script->shutdown();
} else {
    $script->shutdown(1);
}
Esempio n. 3
0
#!/usr/bin/env php
<?php 
/**
 * File containing the checkdbfiles.php script.
 *
 * @deprecated and unmaintained since 5.0
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
 * @license For full copyright and license information view LICENSE file distributed with this source code.
 * @version 2014.11.1
 * @package kernel
 */
require_once 'autoload.php';
$cli = eZCLI::instance();
$script = eZScript::instance(array('description' => "eZ Publish DB file verifier\n\n" . "Checks the database update files and gives a report on them.\n" . "It will show which files are missing and which should not be present.\n" . "\n" . "For each file with problems it will output a status and the filepath\n" . "The status will be one of these:\n" . " '?' file is not defined in upgrade path\n" . " '!' file defined in upgrade path but missing on filesystem\n" . " 'A' file is present in working copy but not in the original stable branch\n" . " 'C' file data conflicts with the original stable branch\n" . "\n" . "Example output:\n" . "  checkdbfiles.php\n" . "  ? update/database/mysql/3.5/dbupdate-3.5.0-to-3.5.1.sql", 'use-session' => false, 'use-modules' => false, 'use-extensions' => true));
$script->startup();
$options = $script->getOptions("[no-verify-branches][export-path:]", "", array('no-verify-branches' => "Do not verify the content of the files with previous branches (To avoid SVN usage)", 'export-path' => "Directory to use for doing SVN exports."));
$script->initialize();
$dbTypes = array();
$dbTypes[] = 'mysql';
$dbTypes[] = 'postgresql';
$branches = array();
$branches[] = '4.1';
$branches[] = '4.2';
$branches[] = '4.3';
$branches[] = '4.4';
// Controls the lowest version which will be exported and verified against current data
$lowestExportVersion = '4.3';
/********************************************************
*** NOTE: The following arrays do not follow the
***       coding standard, the reason for this is
***       to make it easy to merge any changes between
 *
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
 * @license For full copyright and license information view LICENSE file distributed with this source code.
 * @version //autogentag//
 * @package
 */
/**
 * This script starts parallel publishing processes in order to trigger lock wait timeouts
 * Launch it using $./bin/php/ezexec.phhp contentwaittimeout.php
 *
 * To customize the class, parent node or concurrency level, modify the 3 variables below.
 * @package tests
 */
require_once 'autoload.php';
$cli = eZCLI::instance();
$script = eZScript::instance(array('description' => "eZ Publish Parallel publishing benchmark", 'use-session' => false, 'use-modules' => true, 'use-extensions' => true));
$script->startup();
$options = $script->getOptions("[b:|batches-count:][c:|content-class:][l:|concurrency-level:][p:|parent-node:][g|generate-content]", "", array('content-class' => "Identifier of the content class used for testing [default: article]", 'concurrency-level' => "Parallel processes to use [default: 20]", 'generate-content' => "Wether content should  be generated or not (not fully supported yet) [default: off]", 'parent-node' => "Container content should be created in [default: 2]", 'batches-count' => "How many times a concurrent batch should be started [default: 1]"));
$sys = eZSys::instance();
$script->initialize();
$optParentNode = 2;
$optContentClass = 'article';
$optConcurrencyLevel = 20;
$optGenerateContent = false;
$optQuiet = false;
$optBatchesCount = 1;
if ($options['content-class']) {
    $optContentClass = $options['content-class'];
}
if ($options['batches-count']) {
    $optBatchesCount = $options['batches-count'];
{
    global $cli, $fileHandler;
    $cli->output("Exporting files from database:");
    $filePathList = $fileHandler->getFileList($excludeScopes, true);
    foreach ($filePathList as $filePath) {
        $cli->output("- " . $filePath);
        eZDir::mkdir(dirname($filePath), false, true);
        $fileHandler->fileFetch($filePath);
        if ($remove) {
            $fileHandler->fileDelete($filePath);
        }
    }
    $cli->output();
}
$cli = eZCLI::instance();
$script = eZScript::instance(array('description' => "eZ Publish (un)clusterize\n" . "Script for moving var_dir files from " . "filesystem to database and vice versa\n" . "\n" . "./bin/php/clusterize.php", 'use-session' => false, 'use-modules' => false, 'use-extensions' => true));
$script->startup();
$options = $script->getOptions("[u][skip-binary-files][skip-media-files][skip-images][r][n]", "", array('u' => 'Unclusterize', 'skip-binary-files' => 'Skip copying binary files', 'skip-media-files' => 'Skip copying media files', 'skip-images' => 'Skip copying images', 'r' => 'Remove files after copying', 'n' => 'Do not wait'));
$script->initialize();
$clusterize = !isset($options['u']);
$remove = isset($options['r']);
$copyFiles = !isset($options['skip-binary-files']);
$copyMedia = !isset($options['skip-media-files']);
$copyImages = !isset($options['skip-images']);
$wait = !isset($options['n']);
if ($wait) {
    $warningMsg = sprintf("This script will now %s your files and/or images %s database.", $remove ? "move" : "copy", $clusterize ? 'to' : 'from');
    $cli->warning($warningMsg);
    $cli->warning("You have 10 seconds to break the script (press Ctrl-C).");
    sleep(10);
}
#!/usr/bin/env php
<?php 
/**
 * File containing the ezsqldumpschema.php script.
 *
 * @copyright Copyright (C) 1999-2012 eZ Systems AS. All rights reserved.
 * @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2
 * @version  2012.8
 * @package kernel
 */
require 'autoload.php';
$cli = eZCLI::instance();
$script = eZScript::instance(array('description' => "eZ Publish SQL Schema dump\n\n" . "Dump sql schema to specified file or standard output\n" . "ezsqldumpschema.php --type=mysql --user=root stable33 schema.sql", 'use-session' => false, 'use-modules' => true, 'use-extensions' => true));
$script->startup();
$options = $script->getOptions("[type:][user:][host:][password;][port:][socket:][output-array][output-serialized][output-sql]" . "[diff-friendly][meta-data][table-type:][table-charset:][compatible-sql][no-sort]" . "[format:]" . "[output-types:][allow-multi-insert][schema-file:]", "[database][filename]", array('type' => "Which database type to use for source, can be one of:\n" . "mysql, postgresql, oracle", 'host' => "Connect to host source database", 'user' => "User for login to source database", 'password' => "Password to use when connecting to source database", 'port' => 'Port to connect to source database', 'socket' => 'Socket to connect to match and source database (only for MySQL)', 'output-array' => 'Create file with array structures (Human readable)', 'output-serialized' => 'Create file with serialized data (Saves space)', 'output-sql' => 'Create file with SQL data (DB friendly)', 'compatible-sql' => 'Will turn SQL to be more compatible to existing dumps', 'no-sort' => 'Do not sort table columns in the dumped data structure', 'table-type' => "The table storage type to use for SQL output when creating tables.\n" . "MySQL: bdb, innodb and myisam\n" . "PostgreSQL: \n" . "Oracle: ", 'table-charset' => 'Defines the charset to use on tables, the names of the charset depends on database type', 'schema-file' => 'The schema file to use when dumping data structures, is only required when dumping from files', 'format' => "The output format (default is generic)\n" . "generic - Format which suits all databases\n" . "local - Format which suits only the database it was dumped from.", 'meta-data' => 'Will include extra meta-data information specific to the database.', 'diff-friendly' => 'Will make the output friendlier towards the diff command (applies to SQL output only)', 'allow-multi-insert' => 'Will create INSERT statements with multiple data entries (applies to data output only)' . "\n" . 'Multi-inserts will only be created for databases that support it', 'output-types' => "A comma separated list of types to include in dump (default is schema only):\n" . "schema - Table schema\n" . "data - Table data\n" . "all - Both table schema and data"));
$script->initialize();
$type = $options['type'];
$host = $options['host'];
$user = $options['user'];
$port = $options['port'];
$socket = $options['socket'];
$password = $options['password'];
if (!is_string($password)) {
    $password = '';
}
switch (count($options['arguments'])) {
    case 0:
        $cli->error("Missing match database and/or filename");
        $script->shutdown(1);
        break;
    case 1:
#!/usr/bin/env php
<?php 
/**
 * File containing the upgrade script to fix older occurrences of link items
 * not being present in the ezurl_object_table for all versions/translations.
 *
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
 * @license For full copyright and license information view LICENSE file distributed with this source code.
 *
 */
require 'autoload.php';
set_time_limit(0);
$cli = eZCLI::instance();
$script = eZScript::instance(array('description' => "Fix older occurrences of link items in XML-blocks, where they might not be\n" . "linked correctly for all versions/translations. This script will update\n" . "these references for existing entries. Note that URLs which have been lost\n" . "already will not be restored in this process, these need to be re-entered.\n" . "\n" . "fixezurlobjectlink.php", 'use-session' => false, 'use-modules' => true, 'use-extensions' => true));
$config = "[fix][fetch-limit:]";
$argConfig = "";
$optionHelp = array("fix" => "Fix missing ezurl-object-link references. This will make sure that URLs\n" . "created with older versions, will not be lost, when older\nversions/translations are removed.", "fetch-limit" => "The number of attributes to fetch in one chunk. Default value is 200,\nthe limit must be higher than 1.");
$arguments = false;
$useStandardOptions = true;
$script->startup();
$options = $script->getOptions($config, $argConfig, $optionHelp, $arguments, $useStandardOptions);
$script->initialize();
$script->setIterationData('.', '+');
$linkUpdate = new ezpUrlObjectLinkUpdate($cli, $script, $options);
$cli->output($cli->stylize('red', "Found ") . $cli->stylize('green', $linkUpdate->xmlTextContentObjectAttributeCount()) . $cli->stylize('red', " occurrences of 'ezxmltext'."));
$cli->output();
$cli->output("Starting to process content object attributes.");
$cli->output("Fetch limit: " . $cli->stylize('green', $linkUpdate->fetchLimit));
$cli->output();
$linkUpdate->processData();
$cli->output();
 public function __destruct()
 {
     if (self::$script instanceof eZScript) {
         self::$script->shutdown(0);
     }
 }
Esempio n. 9
0
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//   GNU General Public License for more details.
//
//   You should have received a copy of version 2.0 of the GNU General
//   Public License along with this program; if not, write to the Free
//   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
//   MA 02110-1301, USA.
//
//
// ## END COPYRIGHT, LICENSE AND WARRANTY NOTICE ##
//
/*! \file
*/
require 'autoload.php';
$cli = eZCLI::instance();
$script = eZScript::instance(array('description' => "eZ Publish CSV export script\n" . "\n" . "ezcsvexport.php --storage-dir=export 2", 'use-session' => false, 'use-modules' => true, 'use-extensions' => true, 'user' => true));
$script->startup();
$options = $script->getOptions("[storage-dir:]", "[node]", array('storage-dir' => 'directory to place exported files in'), false, array('user' => true));
$script->initialize();
if (count($options['arguments']) < 1) {
    $cli->error('Specify a node to export');
    $script->shutdown(1);
}
$nodeID = $options['arguments'][0];
if (!is_numeric($nodeID)) {
    $cli->error('Specify a numeric node ID');
    $script->shutdown(2);
}
if ($options['storage-dir']) {
    $storageDir = $options['storage-dir'];
} else {
 * @license http://ez.no/Resources/Software/Licenses/eZ-Business-Use-License-Agreement-eZ-BUL-Version-2.1 eZ Business Use License Agreement eZ BUL Version 2.1
 * @version 4.7.0
 * @package kernel
 */
/**
 * This script updates the different ranges used by the ISBN standard to
 * calculate the length of Registration group, Registrant and Publication element
 *
 * It gets the values from xml file normally provided by International ISBN Agency
 * http://www.isbn-international.org/agency?rmxml=1
 */
require 'autoload.php';
$url = '';
// http://www.isbn-international.org/agency?rmxml=1 url with the xml.
$cli = eZCLI::instance();
$script = eZScript::instance(array('description' => "eZ Publish ISBN-13 update\n\n" . "Update the database with new updated ISBN data to the database.", 'use-session' => false, 'use-modules' => true, 'use-extensions' => true));
$script->startup();
$options = $script->getOptions("[url:][db-host:][db-user:][db-password:][db-database:][db-driver:]", "", array('url' => "URL containing the xml file for the different ranges", 'db-host' => "Database host.", 'db-user' => "Database user.", 'db-password' => "Database password.", 'db-database' => "Database name.", 'db-driver' => "Database driver."));
$script->initialize();
if (isset($options['url'])) {
    $url = $options['url'];
} else {
    $cli->error('Error: you need to specify a url to the xml file containing the ranges');
    $script->shutdown(1);
}
$db = eZDB::instance();
if (!$db->IsConnected) {
    // default settings are not valid
    // try user-defined settings
    $dbUser = $options['db-user'] ? $options['db-user'] : false;
    $dbPassword = $options['db-password'] ? $options['db-password'] : false;
Esempio n. 11
0
#!/usr/bin/env php
<?php 
/**
 * File containing the script to cleanup files in a DFS setup
 *
 * @copyright Copyright (C) 1999-2013 eZ Systems AS. All rights reserved.
 * @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2
 * @version //autogentag//
 * @package
 */
require_once 'autoload.php';
$cli = eZCLI::instance();
$script = eZScript::instance(array('description' => "Script for checking database and DFS file consistency", 'use-session' => false, 'use-modules' => true, 'use-extensions' => true));
$script->startup();
$options = $script->getOptions("[S][B][D][path:][iteration-limit:]", "", array("D" => "Delete nonexistent files", "S" => "Check files on DFS share against files in the database", "B" => "Checks files in database against files on DFS share", "path" => "Path to limit checks to (e.g.: var/storage/content - Default: var/)", "iteration-limit" => "Amount of items to remove in each iteration when performing a purge operation. Default is all in one iteration."));
$script->initialize();
$fileHandler = eZClusterFileHandler::instance();
if (!$fileHandler instanceof eZDFSFileHandler) {
    $cli->error("Your installation does not use DFS clustering.");
    $script->shutdown(2);
}
$delete = isset($options['D']);
$checkBase = isset($options['S']);
$checkDFS = isset($options['B']);
if (isset($options['path'])) {
    $checkPath = trim($options['path']);
} else {
    $checkPath = eZINI::instance()->variable('FileSettings', 'VarDir');
}
$optIterationLimit = isset($options['iteration-limit']) ? (int) $options['iteration-limit'] : false;
$pause = 1000;
#!/usr/bin/env php
<?php 
/**
 * File containing the section identifier upgrade script.
 *
 * @copyright Copyright (C) 1999-2013 eZ Systems AS. All rights reserved.
 * @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2
 * @version  2013.11
 * @package update
 */
require 'autoload.php';
$script = eZScript::instance(array('description' => 'eZ Publish section identifier update script. ' . 'This script will update existing sections with missing identifiers.', 'use-session' => false, 'use-modules' => false, 'use-extensions' => true));
$script->startup();
$options = $script->getOptions('', '', array('-q' => 'Quiet mode'));
$script->initialize();
$cli = eZCLI::instance();
$trans = eZCharTransform::instance();
// Fetch 50 items per iteration
$limit = 50;
$offset = 0;
do {
    // Fetch items with empty identifier
    $rows = eZSection::fetchFilteredList(null, $offset, $limit);
    if (!$rows) {
        break;
    }
    foreach ($rows as $row) {
        if ($row->attribute('identifier') == '') {
            // Create a new section identifier with NAME_ID pattern
            $name = $row->attribute('name');
            $identifier = $trans->transformByGroup($name, 'identifier') . '_' . $row->attribute('id');
/**
 * Signal handler
 * @param int $signo Signal number
 */
function childHandler($signo)
{
    switch ($signo) {
        case SIGALRM:
            eZScript::instance()->shutdown(1);
            break;
        case SIGUSR1:
            eZScript::instance()->shutdown(0);
            break;
        case SIGCHLD:
            eZScript::instance()->shutdown(1);
            break;
    }
}
Esempio n. 14
0
#!/usr/bin/env php
<?php 
/**
 * File containing the eztc.php script.
 *
 * @copyright Copyright (C) 1999-2012 eZ Systems AS. All rights reserved.
 * @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2
 * @version //autogentag//
 * @package kernel
 */
require 'autoload.php';
$cli = eZCLI::instance();
$script = eZScript::instance(array('description' => "eZ Publish Template Compiler\n" . "\n" . "./bin/php/eztc.php -snews --www-dir='/mypath' --index-file='/index.php' --access-path='news'", 'use-session' => false, 'use-modules' => true, 'use-extensions' => true));
$script->startup();
$options = $script->getOptions("[compile-directory:][www-dir:][index-file:][access-path:][force][full-url][no-full-url]", "", array('force' => "Force compilation of template whether it has changed or not", 'compile-directory' => "Where to place compiled files,\ndefault is template/compiled in current cache directory", 'full-url' => "Makes sure generated urls have http:// in them (i.e. global), used mainly by sites that include the eZ Publish HTML (e.g payment gateways)", 'no-full-url' => "Makes sure generated urls are relative to the site. (default)", 'www-dir' => "The part before the index.php in your URL, you should supply this if you are running in non-virtualhost mode", 'index-file' => "The name of your index.php if you are running in non-virtualhost mode", 'access-path' => "Extra access path"));
$sys = eZSys::instance();
$forceCompile = false;
$useFullURL = false;
if ($options['www-dir']) {
    $sys->WWWDir = $options['www-dir'];
}
if ($options['index-file']) {
    $sys->IndexFile = $options['index-file'];
}
if ($options['access-path']) {
    $sys->AccessPath = array($options['access-path']);
}
if ($options['force']) {
    $forceCompile = true;
}
if ($options['full-url']) {
Esempio n. 15
0
#!/usr/bin/env php
<?php 
/**
 * File containing the ezsqldiff.php script.
 *
 * @copyright Copyright (C) 1999-2013 eZ Systems AS. All rights reserved.
 * @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2
 * @version  2013.11
 * @package kernel
 */
require_once 'autoload.php';
$cli = eZCLI::instance();
$script = eZScript::instance(array('description' => "eZ Publish SQL diff\n\n" . "Displays differences between two database schemas,\n" . "and sets exit code based whether there is a difference or not\n" . "\n" . "ezsqldiff.php --type mysql --user=root stable32 stable33", 'use-session' => false, 'use-modules' => true, 'use-extensions' => true));
$script->startup();
$options = $script->getOptions("[source-type:][source-host:][source-user:][source-password;][source-socket:]" . "[match-type:][match-host:][match-user:][match-password;][match-socket:]" . "[t:|type:][host:][u:|user:][p:|password;][socket:]" . "[lint-check]" . "[reverse][check-only]", "[source][match]", array('source-type' => "Which database type to use for source, can be one of:\n" . "mysql, postgresql", 'source-host' => "Connect to host source database", 'source-user' => "User for login to source database", 'source-password' => "Password to use when connecting to source database", 'source-socket' => 'Socket to connect to source database (only for MySQL)', 'match-type' => "Which database type to use for match, can be one of:\n" . "mysql, postgresql", 'match-host' => "Connect to host match database", 'match-user' => "User for login to match database", 'match-password' => "Password to use when connecting to match database", 'match-socket' => 'Socket to connect to match database (only for MySQL)', 'type' => "Which database type to use for match and source, can be one of:\n" . "mysql, postgresql", 'host' => "Connect to host match and source database", 'user' => "User for login to match and source database", 'password' => "Password to use when connecting to match and source database", 'socket' => 'Socket to connect to match and source database (only for MySQL)', 'lint-check' => 'Instead of comparing 2 datase schemas, verify source database schema for standards compliance', 'reverse' => "Reverse the differences", 'check-only' => "Don't show SQLs for the differences, just set exit code and return"));
$script->initialize();
if (count($options['arguments']) < 1) {
    $cli->error("Missing source database");
    $script->shutdown(1);
}
if (count($options['arguments']) < 2 and !$options['lint-check']) {
    $cli->error("Missing match database");
    $script->shutdown(1);
}
$sourceType = $options['source-type'] ? $options['source-type'] : $options['type'];
$sourceDBHost = $options['source-host'] ? $options['source-host'] : $options['host'];
$sourceDBUser = $options['source-user'] ? $options['source-user'] : $options['user'];
$sourceDBPassword = $options['source-password'] ? $options['source-password'] : $options['password'];
$sourceDBSocket = $options['source-socket'] ? $options['source-socket'] : $options['socket'];
$sourceDB = $options['arguments'][0];
if (!is_string($sourceDBPassword)) {
Esempio n. 16
0
 * @version 4.7.0
 * @package kernel
 */

require 'autoload.php';

set_time_limit( 0 );

$cli = eZCLI::instance();
$endl = $cli->endlineString();

$script = eZScript::instance( array( 'description' => ( "eZ Publish database cleanup.\n\n" .
                                                        "Will cleanup various data from the currently used database in eZ Publish\n" .
                                                        "\n" .
                                                        "Possible values for NAME is:\n" .
                                                        "session, expired_session, preferences, browse, tipafriend, shop, forgotpassword, workflow,\n" .
                                                        "collaboration, collectedinformation, notification, searchstats or all (for all items)\n" .
                                                        "cleanup.php -s admin session"),
                                     'use-session' => false,
                                     'use-modules' => true,
                                     'use-extensions' => true ) );

$script->startup();

$options = $script->getOptions( "[db-host:][db-user:][db-password:][db-database:][db-type:|db-driver:][sql]",
                                "[name]",
                                array( 'db-host' => "Database host",
                                       'db-user' => "Database user",
                                       'db-password' => "Database password",
                                       'db-database' => "Database name",
                                       'db-driver' => "Database driver",
                                       'db-type' => "Database driver, alias for --db-driver",
<?php

/**
 * File containing the ${NAME} class.
 *
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
 * @license For full copyright and license information view LICENSE file distributed with this source code.
 * @version 2014.11.1
 */
require_once 'autoload.php';
$cli = eZCLI::instance();
$script = eZScript::instance(array('description' => "Re-creates missing references to image files in ezimagefile. See issue EZP-21324\n", 'use-session' => true, 'use-modules' => false, 'use-extensions' => true));
$script->startup();
$options = $script->getOptions("[dry-run]", "", array('n' => 'Dry run'));
$optDryRun = (bool) $options['dry-run'];
$script->initialize();
$imageAttributes = eZPersistentObject::fetchObjectList(eZContentObjectAttribute::definition(), array('id', 'contentobject_id', 'version', 'data_text'), array('data_type_string' => 'ezimage'), null, null, false);
$cli->output("Re-creating missing ezcontentobject_attribute / ezimagefile references");
if ($optDryRun) {
    $cli->warning("dry-run mode");
}
foreach ($imageAttributes as $imageAttribute) {
    if (($doc = simplexml_load_string($imageAttribute["data_text"])) === false) {
        continue;
    }
    // Creates ezimagefile entries
    foreach ($doc->xpath("//*/@url") as $url) {
        $url = (string) $url;
        echo "Processing {$imageAttribute['contentobject_id']}#{$imageAttribute['version']} ({$url})\n";
        if ($url === "") {
            continue;
Esempio n. 18
0
<?php

/**
 * Cluster files purge script
 *
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
 * @license For full copyright and license information view LICENSE file distributed with this source code.
 * @version 2014.11.1
 * @package kernel
 */
require_once 'autoload.php';
$cli = eZCLI::instance();
$script = eZScript::instance(array('description' => "eZ Publish cluster files purge\n" . "Physically purges files\n" . "\n" . "./bin/php/clusterpurge.php --scopes=scope1,scope2", 'use-session' => false, 'use-modules' => false, 'use-extensions' => true));
$script->startup();
$options = $script->getOptions("[dry-run][iteration-sleep:][iteration-limit:][memory-monitoring][scopes:][expiry:]", "", array('dry-run' => 'Test mode, output the list of affected files without removing them', 'iteration-sleep' => 'Amount of seconds to sleep between each iteration when performing a purge operation, can be a float. Default is one second.', 'iteration-limit' => 'Amount of items to remove in each iteration when performing a purge operation. Default is 100.', 'memory-monitoring' => 'Generates memory monitoring output. If set, memory usage will be logged in var/log/clusterpurge.log.', 'scopes' => 'Comma separated list of file types to purge. Possible values are: classattridentifiers, classidentifiers, content, expirycache, statelimitations, user-info-cache, viewcache, wildcard-cache-index, image, binaryfile, media.', 'expiry' => 'Number of days since the file was expired. Only files older than this will be purged. Default is 30, minimum is 1.'));
$sys = eZSys::instance();
$script->initialize();
if (!eZScriptClusterPurge::isRequired()) {
    $cli->error("Your current cluster handler does not require files purge");
    $script->shutdown(1);
}
$purgeHandler = new eZScriptClusterPurge();
if ($options['dry-run']) {
    $purgeHandler->optDryRun = true;
}
if ($options['iteration-sleep']) {
    $purgeHandler->optIterationSleep = (int) ($options['iteration-sleep'] * 1000000);
}
if ($options['iteration-limit']) {
    $purgeHandler->optIterationLimit = (int) $options['iteration-limit'];
}
 *
 * @copyright Copyright (C) 1999-2012 eZ Systems AS. All rights reserved.
 * @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2
 * @version  2012.8
 * @package kernel
 * @subpackage content
 */
/**
 * This script, given a queued contentobject_id + version, will resume the publishing operation on it
 * @package kernel
 * @subpackage content
 */
require 'autoload.php';
$pid = getmypid();
$cli = eZCLI::instance();
$script = eZScript::instance(array('description' => 'Asynchronous publishing handler, not meant to be used directly', 'use-session' => false, 'use-modules' => true, 'use-extensions' => true));
$script->startup();
$argumentConfig = '[OBJECT_ID] [VERSION_ID]';
$optionsConfig = '';
$options = $script->getOptions($optionsConfig, $argumentConfig);
$script->initialize();
if (count($options['arguments']) != 2) {
    eZLog::write("Wrong arguments count", 'publishqueue.log');
    $script->shutdown(1, 'wrong argument count');
}
$objectId = $options['arguments'][0];
$version = $options['arguments'][1];
eZLog::write("[{$pid}] Publishing #{$objectId}/{$version}", 'async.log');
$operationResult = eZOperationHandler::execute('content', 'publish', array('object_id' => $objectId, 'version' => $version));
if (isset($operationResult['status']) && $operationResult['status'] == eZModuleOperationInfo::STATUS_CONTINUE) {
    eZLog::write("[{$pid}] Published #{$objectId}/{$version}", 'async.log');
Esempio n. 20
0
/*!
  \class Writesurveyschema writesurveyschema.php
  \brief The class Writesurveyschema does

*/
//include_once( 'lib/ezdbschema/classes/ezdbschema.php' );
//include_once( 'lib/ezdb/classes/ezdb.php' );
//include_once( 'lib/ezutils/classes/ezcli.php' );
//include_once( 'kernel/classes/ezscript.php' );
require 'autoload.php';
$fileNameDba = 'db_data.dba';
$fileNameSql = 'cleandata.sql';
$stdOutSQL = null;
$stdOutDBA = null;
$cli = eZCLI::instance();
$script = eZScript::instance(array('description' => "eZ Publish SQL Survey data dump\n\n" . "Dump sql data to file or standard output from the tables:\n" . "  ezsurvey_group\n" . "  ezsurvey_group_range\n" . "  ezsurvey_registrant_range\n\n" . "Default is file, wich will be written to:\n" . "  kernel/classes/datatypes/ezsurvey/sql/<database>/cleandata.sql\n" . "  kernel/classes/datatypes/ezsurvey/share/db_data.dba\n\n" . "Script can be runned as:\n" . "php bin/php/ezsqldumpsurveydata.php --stdout-sql\n" . "                                  --stdout-dba\n" . "                                  --filename-sql=customname.sql\n" . "                                  --filename-dba=customname.dba", 'use-session' => false, 'use-modules' => true, 'use-extensions' => true));
$script->startup();
$options = $script->getOptions("[stdout-sql][stdout-dba][filename-sql:][filename-dba:]", "", array('stdout-sql' => "Result of sql output will be printed to standard output instead of to file.", 'stdout-dba' => "Result of dba output will be printed to standard output instead of to file.", 'filename-sql' => "Custom name for the sql file. Will be stored in the directory: \n" . "kernel/classes/datatypes/ezsurvey/sql/<database>/", 'filename-dba' => "Custom name for the dba file. Will be stored in the directory: \n" . "kernel/classes/datatypes/ezsurvey/share/"));
$script->initialize();
$db = eZDB::instance();
$dbSchema = eZDbSchema::instance($db);
if (isset($options['filename-sql'])) {
    $fileNameSql = $options['filename-sql'];
}
if (isset($options['filename-dba'])) {
    $fileNameDba = $options['filename-dba'];
}
if (isset($options['stdout-sql']) !== null) {
    $stdOutSQL = $options['stdout-sql'];
}
if (isset($options['stdout-dba']) !== null) {
Esempio n. 21
0
#!/usr/bin/env php
<?php 
/**
 * @copyright Copyright (C) 1999-2013 eZ Systems AS. All rights reserved.
 * @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2
 * @version //autogentag//
 * @package kernel
 */
require_once 'autoload.php';
set_time_limit(0);
$cli = eZCLI::instance();
$script = eZScript::instance(array('debug-message' => '', 'use-session' => true, 'use-modules' => true, 'use-extensions' => true));
$script->startup();
$webOutput = $cli->isWebOutput();
function help()
{
    $argv = $_SERVER['argv'];
    $cli = eZCLI::instance();
    $cli->output("Usage: " . $argv[0] . " [OPTION]...\n" . "eZ Publish content object name update.\n" . "Goes trough all objects and updates all content object names\n" . "\n" . "General options:\n" . "  -h,--help          display this help and exit \n" . "  -q,--quiet         do not give any output except when errors occur\n" . "  -s,--siteaccess    selected siteaccess for operations, if not specified default siteaccess is used\n" . "  -d,--debug         display debug output at end of execution\n" . "  --db-host=HOST     Use database host HOST\n" . "  --db-user=USER     Use database user USER\n" . "  --db-password=PWD  Use database password PWD\n" . "  --db-database=DB   Use database named DB\n" . "  --db-driver=DRIVER Use database driver DRIVER\n" . "  -c,--colors        display output using ANSI colors\n" . "  --sql              display sql queries\n" . "  --logfiles         create log files\n" . "  --no-logfiles      do not create log files (default)\n" . "  --no-colors        do not use ANSI coloring (default)\n");
}
function changeSiteAccessSetting(&$siteaccess, $optionData)
{
    $cli = eZCLI::instance();
    if (in_array($optionData, eZINI::instance()->variable('SiteAccessSettings', 'AvailableSiteAccessList'))) {
        $siteaccess = $optionData;
        $cli->output("Using siteaccess {$siteaccess} for content object name update");
    } else {
        $cli->notice("Siteaccess {$optionData} does not exist, using default siteaccess");
    }
}
$siteaccess = false;
Esempio n. 22
0
//   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
//   MA 02110-1301, USA.
//
//
// ## END COPYRIGHT, LICENSE AND WARRANTY NOTICE ##
//
define("QUERY_LIMIT", 100);
// gives more information about changed xml (unless in quite mode)
$extraVerbosOutput = false;
if (!file_exists('update/common/scripts') || !is_dir('update/common/scripts')) {
    echo "Please run this script from the root document directory!\n";
    exit;
}
require 'autoload.php';
$cli = eZCLI::instance();
$script = eZScript::instance(array('description' => "\nThis script performs tasks needed to upgrade to 4.1:\n" . "\n- Converting custom:align attributes to align attiribute on supported tags" . "\n- Setting missing align attribute on <embed> and <embed-inline> to align=right." . "\nYou can optionally perform only some of these tasks.", 'use-session' => false, 'use-modules' => false, 'use-extensions' => true));
$script->startup();
$options = $script->getOptions("[db-host:][db-user:][db-password:][db-database:][db-type:][skip-embed-align][skip-custom-align][custom-align-attribute]", '', array('db-host' => "Database host", 'db-user' => "Database user", 'db-password' => "Database password", 'db-database' => "Database name", 'db-type' => "Database type, e.g. mysql or postgresql", 'skip-embed-align' => "Skip adding align='right' on <embed> and <embed-inline> on tags that don't have these.", 'skip-custom-align' => "Skip converting custom:align attribute to align attribute on supported tags.", 'custom-align-attribute' => "Lets you specify name of custom:align attribute, default is 'align'."));
$script->initialize();
$dbUser = $options['db-user'];
$dbPassword = $options['db-password'];
$dbHost = $options['db-host'];
$dbName = $options['db-database'];
$dbImpl = $options['db-type'];
$customAlignAttribute = 'align';
$skipEmbedAlign = $options['skip-embed-align'];
$skipCustomAlign = $options['skip-custom-align'];
if ($options['custom-align-attribute']) {
    $customAlignAttribute = $options['custom-align-attribute'];
}
$isQuiet = $script->isQuiet();
<?php
/**
 * File containing the ezconvertmysqltabletype.php script.
 *
 * @copyright Copyright (C) 1999-2011 eZ Systems AS. All rights reserved.
 * @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2
 * @version //autogentag//
 * @package kernel
 */

require 'autoload.php';

$cli = eZCLI::instance();
$script = eZScript::instance( array( 'description' => ( "eZ Publish Database Converter\n\n" .
                                                        "Convert the database to the given type\n".
                                                        "ezconvertmysqltabletype.php [--host=VALUE --user=VALUE --database=VALUE [--password=VALUE]] [--list] [--newtype=TYPE] [--usecopy]" ),
                                     'use-session' => false,
                                     'use-modules' => false,
                                     'use-extensions' => true ) );

$script->startup();

$options = $script->getOptions( "[host:][user:][password:][database:][list][newtype:][usecopy]",
                                "",
                                array(
                                       'list' => "List the table types",
                                       'host' => "Connect to host database",
                                       'user' => "User for login to the database",
                                       'password' => "Password to use when connecting to the database",
                                       'newtype' => "Convert the database to the given type.\nType can either be: myisam or innodb\n".
                                                    "Make sure that you have made a BACKUP UP of YOUR DATABASE!",
                                       'usecopy' => "To convert the table we rename the original table and copy the data to the new table structure.\n".
<?php
/**
 * Created by PhpStorm.
 * User: bostalowski
 * Date: 14/02/14
 * Time: 10:16
 */

require 'autoload.php';

$script =& eZScript::instance( array(
    'description' => ( "Use this script to generate rss with custom time parameters" ),
    'use-modules' => true,
    'use-extensions' => true,
    'debug-output' => false,
) );

$options = $script->getOptions( "[beginDaily:][endDaily:][beginMonthly:][endMonthly:][beginWeekly:][endWeekly:][cluster:]", "", array(
    'beginDaily' => 'Date to begin daily',
    'endDaily' => 'Date to end daily',
    'beginMonthly' => 'Date to begin monthly',
    'endMonthly' => 'Date to end monthly',
    'beginWeekly' => 'Date to begin weekly',
    'endWeekly' => 'Date to end weekly',
    'cluster' => 'Cluster'
) );

$script->startup();
$script->initialize();

if(!isset($options['cluster']) || empty($options['cluster']) || is_null($options['cluster'])) {
Esempio n. 25
0
<?php
/**
 * File containing the makestaticcache.php script.
 *
 * @copyright Copyright (C) 1999-2011 eZ Systems AS. All rights reserved.
 * @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2
 * @version //autogentag//
 * @package kernel
 */

require 'autoload.php';

$cli = eZCLI::instance();
$script = eZScript::instance( array( 'description' => ( "eZ Publish static cache generator\n" .
                                                        "\n" .
                                                        "./bin/makestaticcache.php --siteaccess user" ),
                                     'use-session' => false,
                                     'use-modules' => true,
                                     'use-extensions' => true ) );

$script->startup();

$options = $script->getOptions( "[f|force]",
                                "",
                                array( 'force' => "Force generation of cache files even if they already exist." ) );

$force = $options['force'];

$script->initialize();

$staticCache = new eZStaticCache();
$staticCache->generateCache( $force, false, $cli, false );
Esempio n. 26
0
#!/usr/bin/env php
<?php 
/**
 * File containing the ezsqlinsertschema.php.php script.
 *
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
 * @license For full copyright and license information view LICENSE file distributed with this source code.
 * @version 2014.11.1
 * @package kernel
 */
require_once 'autoload.php';
$cli = eZCLI::instance();
$script = eZScript::instance(array('description' => "eZ Publish SQL Schema insert\n\n" . "Insert database schema and data to specified database\n" . "ezsqlinsertschema.php --type=mysql --user=root share/db_schema.dba ezp35stable", 'use-session' => false, 'use-modules' => true, 'use-extensions' => true));
$script->startup();
$options = $script->getOptions("[type:][user:][host:][password;][port:][socket:]" . "[table-type:][table-charset:]" . "[insert-types:][allow-multi-insert][schema-file:][clean-existing]", "[filename][database]", array('type' => "Which database type to use, can be one of:\n" . "mysql, postgresql or any other supported by extensions", 'host' => "Connect to host database", 'user' => "User for login to database", 'password' => "Password to use when connecting to database", 'port' => 'Port to connect to database', 'socket' => 'Socket to connect to match and database (only for MySQL)', 'table-type' => "The table storage type to use when creating tables.\n" . "MySQL: bdb, innodb and myisam\n" . "PostgreSQL: \n" . "Oracle: ", 'clean-existing' => 'Clean up existing schema (remove all database objects)', 'table-charset' => 'Defines the charset to use on tables, the names of the charset depends on database type', 'schema-file' => 'The schema file to use when importing data structures, is only required when importing a schema', 'allow-multi-insert' => 'Will create INSERT statements with multiple data entries (applies to data import only)' . "\n" . 'Multi-inserts will only be created for databases that support it', 'insert-types' => "A comma separated list of types to import (default is schema only):\n" . "schema - Table schema\n" . "data - Table data\n" . "all - Both table schema and data\n" . "none - Insert nothing (useful if you want to clean up schema only)"));
$script->initialize();
$type = $options['type'];
$host = $options['host'];
$user = $options['user'];
$socket = $options['socket'];
$password = $options['password'];
$port = $options['port'];
if (!is_string($password)) {
    $password = '';
}
$includeSchema = true;
$includeData = false;
if ($options['insert-types']) {
    $includeSchema = false;
    $includeData = false;
    $includeTypes = explode(',', $options['insert-types']);
Esempio n. 27
0
#!/usr/bin/env php
<?php 
/**
 * File iniloader.php
 *
 * -script to get a serialized ini object of the siteaccess<br>
 * -iniloader.php -s siteaccess<br>
 *
 * @copyright Copyright (C) 2007-2012 CJW Network - Coolscreen.de, JAC Systeme GmbH, Webmanufaktur. All rights reserved.
 * @license http://ez.no/licenses/gnu_gpl GNU GPL v2
 * @version //autogentag//
 * @package cjw_newsletter
 * @author Felix Woldt 2008
 * @subpackage phpscript
 * @filesource
 */
require 'autoload.php';
$cli = eZCLI::instance();
$script = eZScript::instance(array('description' => "eZ Publish INI Reader\n\n" . "Read INI Files\n" . "\n" . "iniloader.php -s siteaccess site.ini", 'use-session' => false, 'use-modules' => true, 'use-extensions' => true));
$script->startup();
$options = $script->getOptions("", "[ininame]", array());
$script->initialize();
$iniName = $options['arguments'][0];
$ini = eZINI::instance('site.ini');
//serialize( $ini );
$cli->output(serialize($ini));
$script->shutdown();
/**
 * File containing the ezgeneratetranslationcache.php script.
 *
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
 * @license For full copyright and license information view LICENSE file distributed with this source code.
 * @version 2014.11.1
 * @package kernel
 */
// Generate caches for translations
// file  bin/php/ezgeneratetranslationcache.php
/**************************************************************
* script initializing                                         *
***************************************************************/
require_once 'autoload.php';
$cli = eZCLI::instance();
$script = eZScript::instance(array('description' => "\n" . "This script will generate caches for translations.\n" . "Default usage: ./bin/php/ezgeneratetranslationcache -s setup\n", 'use-session' => false, 'use-modules' => true, 'use-extensions' => true, 'user' => true));
$script->startup();
$scriptOptions = $script->getOptions("[ts-list:]", "", array('ts-list' => "A list of translations to generate caches for, for example 'rus-RU nor-NO'\n" . "By default caches for all translations will be generated"), false, array('user' => true));
$script->initialize();
/**************************************************************
* process options                                             *
***************************************************************/
//
// 'ts-list' option
//
$translations = isset($scriptOptions['ts-list']) ? explode(' ', $scriptOptions['ts-list']) : array();
$translations = eZTSTranslator::fetchList($translations);
/**************************************************************
* do the work
***************************************************************/
$cli->output($cli->stylize('blue', "Processing: "), false);
 * and below the mount point.
 *
 * @param string $directory
 */
function dfsCleanup($directory)
{
    list($host, $user, $pass, $db, $port, $socket, $mountPoint) = eZINI::instance("file.ini")->variableMulti("eZDFSClusteringSettings", array("DBHost", "DBUser", "DBPassword", "DBName", "DBPort", "DBSocket", "MountPointPath"));
    $db = new mysqli($host, $user, $pass, $db, $port, $socket);
    // Replacing \ and / by a regex equivalent matching both.
    $imagesDirectory = str_replace(array("\\", "/"), "[\\\\/]", rtrim($directory, "\\/"));
    $db->query("\n        DELETE FROM ezdfsfile\n        WHERE scope = 'image' AND\n        name REGEXP '^{$imagesDirectory}[\\\\/].*[\\\\/].*[\\\\/]trashed[\\\\/]'");
    $db->close();
    array_map("filesystemCleanup", glob("{$mountPoint}/{$directory}/*"));
}
require "autoload.php";
$script = eZScript::instance(array("description" => "eZ Publish trashed images sanitizer script (#017781).", "use-session" => false, "use-modules" => false, "use-extensions" => true));
$script->startup();
$options = $script->getOptions("[n]", "", array("-q" => "Quiet mode", "n" => "Do not wait"));
$script->initialize();
$cli = eZCLI::instance();
if (!isset($options['n'])) {
    $cli->warning("This cleanup script will remove any images from trashed objects.");
    $cli->warning("For more details about this cleanup, take a look at: http://issues.ez.no/17781.");
    $cli->warning();
    $cli->warning("IT IS YOUR RESPONSABILITY TO TAKE CARE THAT NO ITEMS REMAINS IN TRASH BEFORE RUNNING THIS SCRIPT.");
    $cli->warning();
    $cli->warning("You have 30 seconds to break the script (press Ctrl-C).");
    sleep(30);
}
$fileHandler = eZINI::instance("file.ini")->variable("ClusteringSettings", "FileHandler");
$directory = eZSys::varDirectory() . "/storage/images";
/**
 * File containing the convertezenumtoezselection.php script.
 *
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
 * @license For full copyright and license information view LICENSE file distributed with this source code.
 * @version 2014.11.1
 * @package kernel
 */
require_once 'autoload.php';
$cli = eZCLI::instance();
$scriptSettings = array();
$scriptSettings['description'] = 'Convert attributes of the type ezenum to ezselection';
$scriptSettings['use-session'] = true;
$scriptSettings['use-modules'] = true;
$scriptSettings['use-extensions'] = true;
$script = eZScript::instance($scriptSettings);
$script->startup();
$config = '[preview]';
$argumentConfig = '[ATTRIBUTE_ID]';
$optionHelp = array('preview' => 'show a preview, do not really make changes');
$arguments = false;
$useStandardOptions = true;
$options = $script->getOptions($config, $argumentConfig, $optionHelp, $arguments, $useStandardOptions);
$script->initialize();
if (count($options['arguments']) != 1) {
    $script->shutdown(1, 'wrong argument count');
}
$preview = $options['preview'] !== null;
$attributeID = $options['arguments'][0];
if (!is_numeric($attributeID)) {
    $attributeID = eZContentObjectTreeNode::classAttributeIDByIdentifier($attributeID);