25 error_reporting(E_ALL);
26 if ((php_sapi_name() !=
'cli')) {
27 trigger_error(
"You can only run this script from the command line\n", E_USER_ERROR);
30 $SYSTEM_ROOT = (isset($_SERVER[
'argv'][1])) ? $_SERVER[
'argv'][1] :
'';
31 if (empty($SYSTEM_ROOT)) {
32 echo
"ERROR: You need to supply the path to the System Root as the first argument\n";
36 if (!is_dir($SYSTEM_ROOT) || !is_readable($SYSTEM_ROOT.
'/core/include/init.inc')) {
37 echo
"ERROR: Path provided doesn't point to a Matrix installation's System Root. Please provide correct path and try again.\n";
41 require_once $SYSTEM_ROOT.
'/core/include/init.inc';
44 echo
'Enter the root password for "'.SQ_CONF_SYSTEM_NAME.
'": ';
46 $root_password = rtrim(fgets(STDIN, 4094));
50 $root_user =& $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'root_user');
51 if (!$root_user->comparePassword($root_password)) {
52 echo
"ERROR: The root password entered was incorrect\n";
55 $GLOBALS[
'SQ_SYSTEM']->setCurrentUser($root_user);
59 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
60 $db =& $GLOBALS[
'SQ_SYSTEM']->db;
64 while ($action !=
'add' && $action !=
'remove') {
65 $action = get_line(
'Please specify whether you want to \'add\' or \'remove\' a URL: ');
68 require_once $SYSTEM_ROOT.
'/scripts/url_manager.inc';
70 if ($action ==
'add') {
71 $inputs = URL_Manager::cliInterfaceAddUrl();
72 $queries = URL_Manager::addUrl($inputs[
'http'], $inputs[
'https'], $inputs[
'new_url'], $inputs[
'existing_url'], $inputs[
'siteid'], $inputs[
'update_file_public_live_assets'], $inputs[
'existing_urlid'], $SYSTEM_ROOT);
73 }
else if ($action ==
'remove') {
74 $remove_url_info = URL_Manager::cliInterfaceRemoveUrl();
75 $queries = URL_Manager::removeUrl($remove_url_info[
'remove_urlid'], $remove_url_info[
'remove_assetid'], $remove_url_info[
'remove_url'], FALSE, $SYSTEM_ROOT);
79 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
80 $GLOBALS[
'SQ_SYSTEM']->restoreCurrentUser();
93 function get_line($prompt=
'')
97 return rtrim(fgets(STDIN, 4096));