예제 #1
0
 public static function getLogPath($version)
 {
     $result = '';
     if (static::logExists($version)) {
         $result = FileSystem::displayPath(OSCOM::BASE_DIR . 'Work/OnlineUpdates/' . $version . '-log.txt');
     }
     return $result;
 }
예제 #2
0
 function getMessage()
 {
     if (OSCOM::getConfig('store_sessions') == '') {
         if (!is_dir(session_save_path())) {
             return OSCOM::getDef('warning_session_directory_non_existent', ['session_path' => session_save_path()]);
         } elseif (!FileSystem::isWritable(session_save_path())) {
             return OSCOM::getDef('warning_session_directory_not_writeable', ['session_path' => session_save_path()]);
         }
     }
 }
예제 #3
0
 public static function initialize()
 {
     ini_set('display_errors', false);
     ini_set('html_errors', false);
     ini_set('ignore_repeated_errors', true);
     if (FileSystem::isWritable(static::getDirectory(), true)) {
         if (!is_dir(static::getDirectory())) {
             mkdir(static::getDirectory(), 0777, true);
         }
     }
     if (FileSystem::isWritable(static::getDirectory())) {
         ini_set('log_errors', true);
         ini_set('error_log', static::getDirectory() . 'errors-' . date('Ymd') . '.txt');
     }
 }
예제 #4
0
function tep_opendir($path)
{
    $path = rtrim($path, '/') . '/';
    $exclude_array = array('.', '..', '.DS_Store', 'Thumbs.db');
    $result = array();
    if ($handle = opendir($path)) {
        while (false !== ($filename = readdir($handle))) {
            if (!in_array($filename, $exclude_array)) {
                $file = array('name' => $path . $filename, 'is_dir' => is_dir($path . $filename), 'writable' => FileSystem::isWritable($path . $filename));
                $result[] = $file;
                if ($file['is_dir'] == true) {
                    $result = array_merge($result, tep_opendir($path . $filename));
                }
            }
        }
        closedir($handle);
    }
    return $result;
}
예제 #5
0
 public static function clearAll()
 {
     if (FileSystem::isWritable(static::$path)) {
         foreach (glob(static::$path . '*.cache') as $c) {
             unlink($c);
         }
     }
 }
예제 #6
0
         }
         if (tep_not_null($date_scheduled)) {
             $date_scheduled = substr($date_scheduled, 0, 4) . substr($date_scheduled, 5, 2) . substr($date_scheduled, 8, 2);
             $OSCOM_Db->save('banners', ['status' => '0', 'date_scheduled' => $date_scheduled], ['banners_id' => (int) $banners_id]);
         }
         OSCOM::redirect(FILENAME_BANNER_MANAGER, 'page=' . $_GET['page']);
     } else {
         $action = 'new';
     }
     break;
 case 'deleteconfirm':
     $banners_id = HTML::sanitize($_GET['bID']);
     if (isset($_POST['delete_image']) && $_POST['delete_image'] == 'on') {
         $Qbanner = $OSCOM_Db->get('banners', 'banners_image', ['banners_id' => (int) $banners_id]);
         if (tep_not_null($Qbanner->value('banners_image')) && is_file(OSCOM::getConfig('dir_root', 'Shop') . 'images/' . $Qbanner->value('banners_image'))) {
             if (FileSystem::isWritable(OSCOM::getConfig('dir_root', 'Shop') . 'images/' . $Qbanner->value('banners_image'))) {
                 unlink(OSCOM::getConfig('dir_root', 'Shop') . 'images/' . $Qbanner->value('banners_image'));
             } else {
                 $OSCOM_MessageStack->add(OSCOM::getDef('error_image_is_not_writeable'), 'error');
             }
         } else {
             $OSCOM_MessageStack->add(OSCOM::getDef('error_image_does_not_exist'), 'error');
         }
     }
     $OSCOM_Db->delete('banners', ['banners_id' => (int) $banners_id]);
     $OSCOM_Db->delete('banners_history', ['banners_id' => (int) $banners_id]);
     $OSCOM_MessageStack->add(OSCOM::getDef('success_banner_removed'), 'success');
     OSCOM::redirect(FILENAME_BANNER_MANAGER, 'page=' . $_GET['page']);
     break;
 case 'preview':
     $banners_id = HTML::sanitize($_GET['banner']);
예제 #7
0
            break;
        case 'deleteconfirm':
            if (strstr($_GET['file'], '..')) {
                OSCOM::redirect(FILENAME_BACKUP);
            }
            if (unlink($backup_directory . '/' . $_GET['file'])) {
                $OSCOM_MessageStack->add(OSCOM::getDef('success_backup_deleted'), 'success');
                OSCOM::redirect(FILENAME_BACKUP);
            }
            break;
    }
}
// check if the backup directory exists
$dir_ok = false;
if (is_dir($backup_directory)) {
    if (FileSystem::isWritable($backup_directory)) {
        $dir_ok = true;
    } else {
        $OSCOM_MessageStack->add(OSCOM::getDef('error_backup_directory_not_writeable'), 'error');
    }
} else {
    $OSCOM_MessageStack->add(OSCOM::getDef('error_backup_directory_does_not_exist'), 'error');
}
$show_listing = true;
require $oscTemplate->getFile('template_top.php');
if (empty($action)) {
    ?>

<div class="pull-right">
  <?php 
    echo HTML::button(OSCOM::getDef('image_backup'), 'fa fa-clone', OSCOM::link('backup.php', 'action=backup'), null, 'btn-info') . HTML::button(OSCOM::getDef('image_restore'), 'fa fa-repeat', OSCOM::link('backup.php', 'action=restorelocal'), null, 'btn-info');
예제 #8
0
        $dir_fs_document_root .= '\\';
    } else {
        $dir_fs_document_root .= '/';
    }
}
$http_url = parse_url($_POST['HTTP_WWW_ADDRESS']);
$http_server = $http_url['scheme'] . '://' . $http_url['host'];
$http_catalog = $http_url['path'];
if (isset($http_url['port']) && !empty($http_url['port'])) {
    $http_server .= ':' . $http_url['port'];
}
if (substr($http_catalog, -1) != '/') {
    $http_catalog .= '/';
}
$admin_folder = 'admin';
if (isset($_POST['CFG_ADMIN_DIRECTORY']) && !empty($_POST['CFG_ADMIN_DIRECTORY']) && FileSystem::isWritable($dir_fs_document_root) && FileSystem::isWritable($dir_fs_document_root . 'admin')) {
    $admin_folder = preg_replace('/[^a-zA-Z0-9]/', '', trim($_POST['CFG_ADMIN_DIRECTORY']));
    if (empty($admin_folder)) {
        $admin_folder = 'admin';
    }
}
if ($admin_folder != 'admin') {
    @rename($dir_fs_document_root . 'admin', $dir_fs_document_root . $admin_folder);
}
$dbServer = trim($_POST['DB_SERVER']);
$dbUsername = trim($_POST['DB_SERVER_USERNAME']);
$dbPassword = trim($_POST['DB_SERVER_PASSWORD']);
$dbDatabase = trim($_POST['DB_DATABASE']);
$dbTablePrefix = trim($_POST['DB_TABLE_PREFIX']);
$timezone = trim($_POST['TIME_ZONE']);
$file_contents = <<<ENDCFG
예제 #9
0
                if ($store_logo->save()) {
                    $OSCOM_Db->save('configuration', ['configuration_value' => $store_logo->filename, 'last_modified' => 'now()'], ['configuration_key' => 'STORE_LOGO']);
                    $OSCOM_MessageStack->add(OSCOM::getDef('success_logo_updated'), 'success');
                } else {
                    $error = true;
                }
            } else {
                $error = true;
            }
            if ($error == false) {
                OSCOM::redirect(FILENAME_STORE_LOGO);
            }
            break;
    }
}
if (!FileSystem::isWritable(OSCOM::getConfig('dir_root', 'Shop') . 'images/')) {
    $OSCOM_MessageStack->add(OSCOM::getDef('error_images_directory_not_writeable', ['sec_dir_permissions_link' => OSCOM::link(FILENAME_SEC_DIR_PERMISSIONS)]), 'error');
}
require $oscTemplate->getFile('template_top.php');
?>

    <table border="0" width="100%" cellspacing="0" cellpadding="2">
      <tr>
        <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
            <td class="pageHeading"><?php 
echo OSCOM::getDef('heading_title');
?>
</td>
          </tr>
        </table></td>
예제 #10
0
</td>
      <td class="text-right"><?php 
        echo $f['size'];
        ?>
</td>
      <td class="action"><a href="<?php 
        echo OSCOM::link('error_log.php', 'action=view&log=' . $f['key']);
        ?>
"><i class="fa fa-file-text-o" title="<?php 
        echo OSCOM::getDef('button_view');
        ?>
"></i></a></td>
    </tr>

<?php 
    }
    ?>

  </tbody>
</table>

<p>
  <?php 
    echo OSCOM::getDef('log_directory', ['path' => FileSystem::displayPath(ErrorHandler::getDirectory())]);
    ?>
</p>

<?php 
}
require $oscTemplate->getFile('template_bottom.php');
require 'includes/application_bottom.php';
예제 #11
0
 function pass()
 {
     return !FileSystem::isWritable(OSCOM::getConfig('dir_root', 'Shop') . 'includes/configure.php');
 }
예제 #12
0
    ?>
</td>
      <td class="text-right"><?php 
    echo count($cache_files[$key]);
    ?>
</td>
      <td class="action"><a href="<?php 
    echo OSCOM::link(FILENAME_CACHE, 'action=reset&block=' . $key);
    ?>
"><i class="fa fa-recycle" title="<?php 
    echo OSCOM::getDef('image_delete');
    ?>
"></i></a></td>
    </tr>

<?php 
}
?>

  </tbody>
</table>

<p>
  <?php 
echo '<strong>' . OSCOM::getDef('text_cache_directory') . '</strong> ' . FileSystem::displayPath(Cache::getPath());
?>
</p>

<?php 
require $oscTemplate->getFile('template_bottom.php');
require 'includes/application_bottom.php';
예제 #13
0
                            }
                        }
                    }
                }
                if (isset($OU) && $OU instanceof \OSC\OM\OnlineUpdate\Update && method_exists($OU, 'runAfter')) {
                    OnlineUpdate::log('Executing update package runAfter()', $_POST['version']);
                    $OU->runAfter();
                }
                if (file_put_contents(OSCOM::BASE_DIR . 'version.txt', $_POST['version'])) {
                    OnlineUpdate::log('+ UPDATED: ' . FileSystem::displayPath(OSCOM::BASE_DIR . 'version.txt'), $_POST['version']);
                } else {
                    OnlineUpdate::log('+++ UPDATE ERROR: Could not update the following file: ' . FileSystem::displayPath(OSCOM::BASE_DIR . 'version.txt'), $_POST['version']);
                }
                OnlineUpdate::log('Finished update', $_POST['version']);
                $result['result'] = 1;
                FileSystem::rmdir($work_dir);
            } catch (\Exception $e) {
                OnlineUpdate::log($e->getMessage(), $_POST['version']);
            }
            echo json_encode($result);
            exit;
            break;
    }
}
$new_version = [];
if (is_array($releases) && !empty($releases)) {
    if (!empty($versions)) {
        $new_version = array_slice($versions, -1)[0];
    }
    if (!empty($new_version)) {
        $OSCOM_MessageStack->add(OSCOM::getDef('version_upgrades_available', ['version' => $new_version['version']]), 'warning', 'versionCheck');
예제 #14
0
 function check_destination()
 {
     $OSCOM_MessageStack = Registry::get('MessageStack');
     if (!FileSystem::isWritable($this->destination)) {
         if (is_dir($this->destination)) {
             if ($this->message_location == 'direct') {
                 $OSCOM_MessageStack->add(OSCOM::getDef('error_destination_not_writeable', ['destination' => $this->destination]), 'error');
             } else {
                 $OSCOM_MessageStack->add(OSCOM::getDef('error_destination_not_writeable', ['destination' => $this->destination]), 'error');
             }
         } else {
             if ($this->message_location == 'direct') {
                 $OSCOM_MessageStack->add(OSCOM::getDef('error_destination_does_not_exist', ['destination' => $this->destination]), 'error');
             } else {
                 $OSCOM_MessageStack->add(OSCOM::getDef('error_destination_does_not_exist', ['destination' => $this->destination]), 'error');
             }
         }
         return false;
     } else {
         return true;
     }
 }
예제 #15
0
        <?php 
echo HTML::inputField('CFG_ADMINISTRATOR_USERNAME', null, 'required aria-required="true" id="adminUsername"');
?>
        <span class="help-block">The administrator username to use for the administration tool.</span>
      </div>

      <div class="form-group has-feedback">
        <label for="adminPassword">Administrator Password</label>
        <?php 
echo HTML::inputField('CFG_ADMINISTRATOR_PASSWORD', null, 'required aria-required="true" id="adminPassword"');
?>
        <span class="help-block">The password to use for the administrator account.</span>
      </div>

<?php 
if (FileSystem::isWritable($dir_fs_document_root) && FileSystem::isWritable($dir_fs_document_root . 'admin')) {
    ?>

      <div class="form-group has-feedback">
        <label for="adminDir">Administration Directory Name</label>
        <?php 
    echo HTML::inputField('CFG_ADMIN_DIRECTORY', 'admin', 'required aria-required="true" id="adminDir"');
    ?>
        <span class="help-block">This is the directory where the administration section will be installed. You should change this for security reasons.</span>
      </div>

<?php 
}
?>

      <div class="form-group has-feedback">
예제 #16
0
      <p><i>Changing webserver configuration parameters may require the webserver service to be restarted before the changes take affect.</i></p>
    </div>

<?php 
}
if (!empty($configfile_array)) {
    ?>

    <div class="alert alert-danger">
      <p>The webserver is not able to save to the following installation configuration files. Please update the file permissions of the following files to world-writable (chmod 777) and try the installation procedure again:</p>

      <ul style="margin-top: 20px;">

<?php 
    foreach ($configfile_array as $file) {
        echo '<li>' . FileSystem::displayPath($file) . '</li>';
    }
    ?>

      </ul>
    </div>

<?php 
}
if (!empty($configfile_array) || !empty($warning_array)) {
    ?>

    <p><a href="index.php" class="btn btn-danger" role="button">Retry Installation</a></p>

<?php 
} else {
예제 #17
0
  <div class="col-xs-12 col-sm-push-3 col-sm-9">
    <h1>Web Server</h1>

    <form name="install" id="installForm" action="install.php?step=3" method="post">
      <div class="form-group has-feedback">
        <label for="wwwAddress">WWW Address</label>
        <?php 
echo HTML::inputField('HTTP_WWW_ADDRESS', $www_location, 'required aria-required="true" id="wwwAddress" placeholder="http://"');
?>
        <span class="help-block">The web address to the online store.</span>
      </div>

      <div class="form-group has-feedback">
        <label for="webRoot">Webserver Root Directory</label>
        <?php 
echo HTML::inputField('DIR_FS_DOCUMENT_ROOT', str_replace('\\', '/', FileSystem::displayPath($dir_fs_www_root)), 'required aria-required="true" id="webRoot"');
?>
        <span class="help-block">The directory where the online store is installed on the server.</span>
      </div>

      <p><?php 
echo HTML::button('Continue to Step 3', 'triangle-1-e', null, null, 'btn-success');
?>
</p>

<?php 
foreach ($_POST as $key => $value) {
    if ($key != 'x' && $key != 'y') {
        echo HTML::hiddenField($key, $value);
    }
}
예제 #18
0
 protected function init()
 {
     global $PHP_SELF, $login_request, $cfgModules, $oscTemplate;
     $OSCOM_Cookies = new Cookies();
     Registry::set('Cookies', $OSCOM_Cookies);
     try {
         $OSCOM_Db = Db::initialize();
         Registry::set('Db', $OSCOM_Db);
     } catch (\Exception $e) {
         include OSCOM::getConfig('dir_root', 'Shop') . 'includes/error_documents/maintenance.php';
         exit;
     }
     Registry::set('Hooks', new Hooks());
     Registry::set('MessageStack', new MessageStack());
     // set the application parameters
     $Qcfg = $OSCOM_Db->get('configuration', ['configuration_key as k', 'configuration_value as v']);
     //, null, null, null, 'configuration'); // TODO add cache when supported by admin
     while ($Qcfg->fetch()) {
         define($Qcfg->value('k'), $Qcfg->value('v'));
     }
     // Used in the "Backup Manager" to compress backups
     define('LOCAL_EXE_GZIP', 'gzip');
     define('LOCAL_EXE_GUNZIP', 'gunzip');
     define('LOCAL_EXE_ZIP', 'zip');
     define('LOCAL_EXE_UNZIP', 'unzip');
     // set php_self in the global scope
     $req = parse_url($_SERVER['SCRIPT_NAME']);
     $PHP_SELF = substr($req['path'], strlen(OSCOM::getConfig('http_path')));
     $OSCOM_Session = Session::load();
     Registry::set('Session', $OSCOM_Session);
     $OSCOM_Session->start();
     $OSCOM_Language = new Language();
     Registry::set('Language', $OSCOM_Language);
     // set the language
     if (!isset($_SESSION['language']) || isset($_GET['language'])) {
         if (isset($_GET['language']) && !empty($_GET['language']) && $OSCOM_Language->exists($_GET['language'])) {
             $OSCOM_Language->set($_GET['language']);
         }
         $_SESSION['language'] = $OSCOM_Language->get('code');
     }
     // redirect to login page if administrator is not yet logged in
     if (!isset($_SESSION['admin'])) {
         $redirect = false;
         $current_page = $PHP_SELF;
         // if the first page request is to the login page, set the current page to the index page
         // so the redirection on a successful login is not made to the login page again
         if ($current_page == FILENAME_LOGIN && !isset($_SESSION['redirect_origin'])) {
             $current_page = FILENAME_DEFAULT;
         }
         if ($current_page != FILENAME_LOGIN) {
             if (!isset($_SESSION['redirect_origin'])) {
                 $_SESSION['redirect_origin'] = ['page' => $current_page, 'get' => []];
             }
             // try to automatically login with the HTTP Authentication values if it exists
             if (!isset($_SESSION['auth_ignore'])) {
                 if (isset($_SERVER['PHP_AUTH_USER']) && !empty($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW']) && !empty($_SERVER['PHP_AUTH_PW'])) {
                     $_SESSION['redirect_origin']['auth_user'] = $_SERVER['PHP_AUTH_USER'];
                     $_SESSION['redirect_origin']['auth_pw'] = $_SERVER['PHP_AUTH_PW'];
                 }
             }
             $redirect = true;
         }
         if (!isset($login_request) || isset($_GET['login_request']) || isset($_POST['login_request']) || isset($_COOKIE['login_request']) || isset($_SESSION['login_request']) || isset($_FILES['login_request']) || isset($_SERVER['login_request'])) {
             $redirect = true;
         }
         if ($redirect == true) {
             OSCOM::redirect(FILENAME_LOGIN, isset($_SESSION['redirect_origin']['auth_user']) ? 'action=process' : '');
         }
     }
     // include the language translations
     $OSCOM_Language->loadDefinitions('main');
     // Prevent LC_ALL from setting LC_NUMERIC to a locale with 1,0 float/decimal values instead of 1.0 (see bug #634)
     $system_locale_numeric = setlocale(LC_NUMERIC, 0);
     setlocale(LC_ALL, explode(';', OSCOM::getDef('system_locale')));
     setlocale(LC_NUMERIC, $system_locale_numeric);
     $current_page = basename($PHP_SELF);
     if ($OSCOM_Language->definitionsExist(pathinfo($current_page, PATHINFO_FILENAME))) {
         $OSCOM_Language->loadDefinitions(pathinfo($current_page, PATHINFO_FILENAME));
     }
     $oscTemplate = new \oscTemplate();
     $cfgModules = new \cfg_modules();
     if (!FileSystem::isWritable(ErrorHandler::getDirectory())) {
         Registry::get('MessageStack')->add('The log directory is not writable. Please allow the web server to write to: ' . FileSystem::displayPath(ErrorHandler::getDirectory()));
     }
 }