Skip to content
Browse files

Introduce CoreUpdate Admin Application to check, view, and apply core…

… updates
  • Loading branch information...
1 parent f919849 commit acf51238ea3ccf6414c1205d5daedc848e449b36 @haraldpdl committed Mar 21, 2011
Showing with 881 additions and 0 deletions.
  1. +1 −0 .gitignore
  2. +40 −0 osCommerce/OM/Core/Site/Admin/Application/CoreUpdate/Action/Apply.php
  3. +43 −0 osCommerce/OM/Core/Site/Admin/Application/CoreUpdate/Action/Apply/Process.php
  4. +28 −0 osCommerce/OM/Core/Site/Admin/Application/CoreUpdate/Controller.php
  5. +14 −0 osCommerce/OM/Core/Site/Admin/Application/CoreUpdate/CoreUpdate.php
  6. +37 −0 osCommerce/OM/Core/Site/Admin/Application/CoreUpdate/Model/applyPackage.php
  7. +28 −0 osCommerce/OM/Core/Site/Admin/Application/CoreUpdate/Model/canApplyPackage.php
  8. +21 −0 osCommerce/OM/Core/Site/Admin/Application/CoreUpdate/Model/deletePackage.php
  9. +38 −0 osCommerce/OM/Core/Site/Admin/Application/CoreUpdate/Model/downloadPackage.php
  10. +30 −0 osCommerce/OM/Core/Site/Admin/Application/CoreUpdate/Model/findAvailablePackages.php
  11. +30 −0 osCommerce/OM/Core/Site/Admin/Application/CoreUpdate/Model/findPackageContents.php
  12. +30 −0 osCommerce/OM/Core/Site/Admin/Application/CoreUpdate/Model/getAvailablePackageInfo.php
  13. +60 −0 osCommerce/OM/Core/Site/Admin/Application/CoreUpdate/Model/getAvailablePackages.php
  14. +85 −0 osCommerce/OM/Core/Site/Admin/Application/CoreUpdate/Model/getPackageContents.php
  15. +41 −0 osCommerce/OM/Core/Site/Admin/Application/CoreUpdate/Model/getPackageInfo.php
  16. +20 −0 osCommerce/OM/Core/Site/Admin/Application/CoreUpdate/Model/localPackageExists.php
  17. +28 −0 osCommerce/OM/Core/Site/Admin/Application/CoreUpdate/Model/packageExists.php
  18. +33 −0 osCommerce/OM/Core/Site/Admin/Application/CoreUpdate/RPC/GetAvailablePackages.php
  19. +33 −0 osCommerce/OM/Core/Site/Admin/Application/CoreUpdate/RPC/GetPackageContents.php
  20. +100 −0 osCommerce/OM/Core/Site/Admin/Application/CoreUpdate/pages/main.php
  21. +102 −0 osCommerce/OM/Core/Site/Admin/Application/CoreUpdate/pages/package_contents.php
  22. +33 −0 osCommerce/OM/Core/Site/Admin/languages/en_US/CoreUpdate.php
  23. +6 −0 osCommerce/OM/Work/CoreUpdate/update.phar.pubkey
  24. BIN public/sites/Admin/images/applications/16/coreupdate.png
  25. BIN public/sites/Admin/images/applications/32/coreupdate.png
  26. BIN public/sites/Admin/templates/oscom/images/icons/16x16/folder_contents.png
View
1 .gitignore
@@ -1,4 +1,5 @@
osCommerce/OM/Work/*
+!osCommerce/OM/Work/CoreUpdate/update.phar.pubkey
osCommerce/OM/Config/local_settings.ini
osCommerce/OM/Custom/*
!osCommerce/OM/Custom/README
View
40 osCommerce/OM/Core/Site/Admin/Application/CoreUpdate/Action/Apply.php
@@ -0,0 +1,40 @@
+<?php
+/*
+ osCommerce Online Merchant $osCommerce-SIG$
+ Copyright (c) 2010 osCommerce (http://www.oscommerce.com)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License v2 (1991)
+ as published by the Free Software Foundation.
+*/
+
+ namespace osCommerce\OM\Core\Site\Admin\Application\CoreUpdate\Action;
+
+ use osCommerce\OM\Core\ApplicationAbstract;
+ use osCommerce\OM\Core\Site\Admin\Application\CoreUpdate\CoreUpdate;
+ use osCommerce\OM\Core\Registry;
+ use osCommerce\OM\Core\OSCOM;
+
+ class Apply {
+ public static function execute(ApplicationAbstract $application) {
+ if ( !isset($_GET['v']) || !CoreUpdate::packageExists($_GET['v']) ) {
+ Registry::get('MessageStack')->add(null, OSCOM::getDef('ms_error_select_version_to_view'), 'error');
+
+ osc_redirect_admin(OSCOM::getLink());
+ }
+
+ if ( CoreUpdate::localPackageExists() && (CoreUpdate::getPackageInfo('version_to') != $_GET['v']) ) {
+ CoreUpdate::deletePackage();
+ }
+
+ if ( !CoreUpdate::localPackageExists() && !CoreUpdate::downloadPackage($_GET['v']) ) {
+ Registry::get('MessageStack')->add(null, OSCOM::getDef('ms_error_local_update_package_does_not_exist'), 'error');
+
+ osc_redirect_admin(OSCOM::getLink());
+ }
+
+ $application->setPageContent('package_contents.php');
+ $application->setPageTitle(sprintf(OSCOM::getDef('action_heading_apply'), CoreUpdate::getPackageInfo('version_from'), CoreUpdate::getPackageInfo('version_to')));
+ }
+ }
+?>
View
43 osCommerce/OM/Core/Site/Admin/Application/CoreUpdate/Action/Apply/Process.php
@@ -0,0 +1,43 @@
+<?php
+/*
+ osCommerce Online Merchant $osCommerce-SIG$
+ Copyright (c) 2010 osCommerce (http://www.oscommerce.com)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License v2 (1991)
+ as published by the Free Software Foundation.
+*/
+
+ namespace osCommerce\OM\Core\Site\Admin\Application\CoreUpdate\Action\Apply;
+
+ use osCommerce\OM\Core\ApplicationAbstract;
+ use osCommerce\OM\Core\Site\Admin\Application\CoreUpdate\CoreUpdate;;
+ use osCommerce\OM\Core\Registry;
+ use osCommerce\OM\Core\OSCOM;
+
+ class Process {
+ public static function execute(ApplicationAbstract $application) {
+ if ( !CoreUpdate::localPackageExists() || (CoreUpdate::getPackageInfo('version_from') != OSCOM::getVersion()) ) {
+ Registry::get('MessageStack')->add(null, OSCOM::getDef('ms_error_wrong_version_to_update_from'), 'error');
+
+ osc_redirect_admin(OSCOM::getLink());
+ }
+
+ if ( CoreUpdate::canApplyPackage() ) {
+ if ( CoreUpdate::applyPackage() ) {
+ CoreUpdate::deletePackage();
+
+ Registry::get('MessageStack')->add(null, OSCOM::getDef('ms_success_action_performed'), 'success');
+ } else {
+ Registry::get('MessageStack')->add(null, OSCOM::getDef('ms_error_action_not_performed'), 'error');
+ }
+ } else {
+ Registry::get('MessageStack')->add(null, OSCOM::getDef('ms_error_check_target_permissions'), 'error');
+
+ osc_redirect_admin(OSCOM::getLink(null, null, 'Apply&v=' . $_GET['v']));
+ }
+
+ osc_redirect_admin(OSCOM::getLink());
+ }
+ }
+?>
View
28 osCommerce/OM/Core/Site/Admin/Application/CoreUpdate/Controller.php
@@ -0,0 +1,28 @@
+<?php
+/*
+ osCommerce Online Merchant $osCommerce-SIG$
+ Copyright (c) 2010 osCommerce (http://www.oscommerce.com)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License v2 (1991)
+ as published by the Free Software Foundation.
+*/
+
+ namespace osCommerce\OM\Core\Site\Admin\Application\CoreUpdate;
+
+ use osCommerce\OM\Core\OSCOM;
+
+ class Controller extends \osCommerce\OM\Core\Site\Admin\ApplicationAbstract {
+ protected $_group = 'tools';
+ protected $_icon = 'coreupdate.png';
+ protected $_sort_order = 5;
+
+ protected function initialize() {
+ $this->_title = OSCOM::getDef('app_title');
+ }
+
+ protected function process() {
+ $this->_page_title = OSCOM::getDef('heading_title');
+ }
+ }
+?>
View
14 osCommerce/OM/Core/Site/Admin/Application/CoreUpdate/CoreUpdate.php
@@ -0,0 +1,14 @@
+<?php
+/*
+ osCommerce Online Merchant $osCommerce-SIG$
+ Copyright (c) 2010 osCommerce (http://www.oscommerce.com)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License v2 (1991)
+ as published by the Free Software Foundation.
+*/
+
+ namespace osCommerce\OM\Core\Site\Admin\Application\CoreUpdate;
+
+ class CoreUpdate extends \osCommerce\OM\Core\ApplicationModelAbstract { }
+?>
View
37 osCommerce/OM/Core/Site/Admin/Application/CoreUpdate/Model/applyPackage.php
@@ -0,0 +1,37 @@
+<?php
+/*
+ osCommerce Online Merchant $osCommerce-SIG$
+ Copyright (c) 2010 osCommerce (http://www.oscommerce.com)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License v2 (1991)
+ as published by the Free Software Foundation.
+*/
+
+ namespace osCommerce\OM\Core\Site\Admin\Application\CoreUpdate\Model;
+
+ use \Phar;
+ use osCommerce\OM\Core\OSCOM;
+
+ class applyPackage {
+ public static function execute() {
+ $phar_can_open = true;
+
+ try {
+ $phar = new Phar(OSCOM::BASE_DIRECTORY . 'Work/CoreUpdate/update.phar');
+ $phar->extractTo(realpath(OSCOM::BASE_DIRECTORY . '../../'), null, true);
+ } catch ( \Exception $e ) {
+// ignore when file permissions from the phar archive cannot be set to the
+// extracted files
+// HPDL look for a more elegant solution
+ if ( strpos($e->getMessage(), 'setting file permissions failed') === false ) {
+ $phar_can_open = false;
+
+ trigger_error($e->getMessage());
+ }
+ }
+
+ return $phar_can_open;
+ }
+ }
+?>
View
28 osCommerce/OM/Core/Site/Admin/Application/CoreUpdate/Model/canApplyPackage.php
@@ -0,0 +1,28 @@
+<?php
+/*
+ osCommerce Online Merchant $osCommerce-SIG$
+ Copyright (c) 2010 osCommerce (http://www.oscommerce.com)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License v2 (1991)
+ as published by the Free Software Foundation.
+*/
+
+ namespace osCommerce\OM\Core\Site\Admin\Application\CoreUpdate\Model;
+
+ use osCommerce\OM\Core\Site\Admin\Application\CoreUpdate\CoreUpdate;
+
+ class canApplyPackage {
+ public static function execute() {
+ $contents = CoreUpdate::getPackageContents();
+
+ foreach ( $contents['entries'] as $file ) {
+ if ( $file['writable'] === false ) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+ }
+?>
View
21 osCommerce/OM/Core/Site/Admin/Application/CoreUpdate/Model/deletePackage.php
@@ -0,0 +1,21 @@
+<?php
+/*
+ osCommerce Online Merchant $osCommerce-SIG$
+ Copyright (c) 2010 osCommerce (http://www.oscommerce.com)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License v2 (1991)
+ as published by the Free Software Foundation.
+*/
+
+ namespace osCommerce\OM\Core\Site\Admin\Application\CoreUpdate\Model;
+
+ use \Phar;
+ use osCommerce\OM\Core\OSCOM;
+
+ class deletePackage {
+ public static function execute() {
+ return Phar::unlinkArchive(OSCOM::BASE_DIRECTORY . 'Work/CoreUpdate/update.phar');
+ }
+ }
+?>
View
38 osCommerce/OM/Core/Site/Admin/Application/CoreUpdate/Model/downloadPackage.php
@@ -0,0 +1,38 @@
+<?php
+/*
+ osCommerce Online Merchant $osCommerce-SIG$
+ Copyright (c) 2010 osCommerce (http://www.oscommerce.com)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License v2 (1991)
+ as published by the Free Software Foundation.
+*/
+
+ namespace osCommerce\OM\Core\Site\Admin\Application\CoreUpdate\Model;
+
+ use osCommerce\OM\Core\Site\Admin\Application\CoreUpdate\CoreUpdate;
+ use osCommerce\OM\Core\HttpRequest;
+ use osCommerce\OM\Core\OSCOM;
+
+ class downloadPackage {
+ public static function execute($version = null) {
+ if ( empty($version) ) {
+ $link = CoreUpdate::getAvailablePackageInfo('update_package');
+ } else {
+ $versions = CoreUpdate::getAvailablePackages();
+
+ foreach ( $versions['entries'] as $v ) {
+ if ( $v['version'] == $version ) {
+ $link = $v['update_package'];
+
+ break;
+ }
+ }
+ }
+
+ $response = HttpRequest::getResponse(array('url' => $link, 'parameters' => 'check=true'));
+
+ return file_put_contents(OSCOM::BASE_DIRECTORY . 'Work/CoreUpdate/update.phar', $response);
+ }
+ }
+?>
View
30 osCommerce/OM/Core/Site/Admin/Application/CoreUpdate/Model/findAvailablePackages.php
@@ -0,0 +1,30 @@
+<?php
+/*
+ osCommerce Online Merchant $osCommerce-SIG$
+ Copyright (c) 2010 osCommerce (http://www.oscommerce.com)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License v2 (1991)
+ as published by the Free Software Foundation.
+*/
+
+ namespace osCommerce\OM\Core\Site\Admin\Application\CoreUpdate\Model;
+
+ use osCommerce\OM\Core\Site\Admin\Application\CoreUpdate\CoreUpdate;
+
+ class findAvailablePackages {
+ public static function execute($search) {
+ $result = CoreUpdate::getAvailablePackages();
+
+ foreach ( $result['entries'] as $k => $v ) {
+ if ( strpos($v['version'], $search) === false ) {
+ unset($result['entries'][$k]);
+ }
+ }
+
+ $result['total'] = count($result['entries']);
+
+ return $result;
+ }
+ }
+?>
View
30 osCommerce/OM/Core/Site/Admin/Application/CoreUpdate/Model/findPackageContents.php
@@ -0,0 +1,30 @@
+<?php
+/*
+ osCommerce Online Merchant $osCommerce-SIG$
+ Copyright (c) 2010 osCommerce (http://www.oscommerce.com)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License v2 (1991)
+ as published by the Free Software Foundation.
+*/
+
+ namespace osCommerce\OM\Core\Site\Admin\Application\CoreUpdate\Model;
+
+ use osCommerce\OM\Core\Site\Admin\Application\CoreUpdate\CoreUpdate;
+
+ class findPackageContents {
+ public static function execute($search) {
+ $result = CoreUpdate::getPackageContents();
+
+ foreach ( $result['entries'] as $k => $v ) {
+ if ( strpos($v['name'], $search) === false ) {
+ unset($result['entries'][$k]);
+ }
+ }
+
+ $result['total'] = count($result['entries']);
+
+ return $result;
+ }
+ }
+?>
View
30 osCommerce/OM/Core/Site/Admin/Application/CoreUpdate/Model/getAvailablePackageInfo.php
@@ -0,0 +1,30 @@
+<?php
+/*
+ osCommerce Online Merchant $osCommerce-SIG$
+ Copyright (c) 2010 osCommerce (http://www.oscommerce.com)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License v2 (1991)
+ as published by the Free Software Foundation.
+*/
+
+ namespace osCommerce\OM\Core\Site\Admin\Application\CoreUpdate\Model;
+
+ use osCommerce\OM\Core\Site\Admin\Application\CoreUpdate\CoreUpdate;
+
+ class getAvailablePackageInfo {
+ public static function execute($key = null) {
+ $versions = CoreUpdate::getAvailablePackages();
+
+ if ( !empty($versions['entries']) ) {
+ if ( !empty($key) && isset($versions['entries'][0][$key]) ) {
+ return $versions['entries'][0][$key];
+ } else {
+ return $versions['entries'][0];
+ }
+ }
+
+ return false;
+ }
+ }
+?>
View
60 osCommerce/OM/Core/Site/Admin/Application/CoreUpdate/Model/getAvailablePackages.php
@@ -0,0 +1,60 @@
+<?php
+/*
+ osCommerce Online Merchant $osCommerce-SIG$
+ Copyright (c) 2010 osCommerce (http://www.oscommerce.com)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License v2 (1991)
+ as published by the Free Software Foundation.
+*/
+
+ namespace osCommerce\OM\Core\Site\Admin\Application\CoreUpdate\Model;
+
+ use osCommerce\OM\Core\Registry;
+ use osCommerce\OM\Core\HttpRequest;
+ use osCommerce\OM\Core\OSCOM;
+ use osCommerce\OM\Core\DateTime;
+
+ class getAvailablePackages {
+ public static function execute() {
+ $OSCOM_Cache = Registry::get('Cache');
+
+ $result = array('entries' => array());
+
+ if ( $OSCOM_Cache->read('coreupdate-availablepackages', 360) ) {
+ $versions = $OSCOM_Cache->getCache();
+ } else {
+ $versions = HttpRequest::getResponse(array('url' => 'http://www.oscommerce.com/version/online_merchant/3', 'method' => 'get'));
+
+ $OSCOM_Cache->write($versions);
+ }
+
+ $versions_array = explode("\n", $versions);
+
+ $counter = 0;
+
+ foreach ( $versions_array as $v ) {
+ $v_info = explode('|', $v);
+
+ if ( version_compare(OSCOM::getVersion(), $v_info[0], '<') ) {
+ $result['entries'][] = array('key' => $counter,
+ 'version' => $v_info[0],
+ 'date' => DateTime::getShort(DateTime::fromUnixTimestamp(DateTime::getTimestamp($v_info[1], 'Ymd'))),
+ 'announcement' => $v_info[2],
+ 'update_package' => (isset($v_info[3]) ? $v_info[3] : null));
+
+ $counter++;
+ }
+ }
+
+ usort($result['entries'], function ($a, $b) {
+ return version_compare($a['version'], $b['version'], '>');
+ });
+
+
+ $result['total'] = count($result['entries']);
+
+ return $result;
+ }
+ }
+?>
View
85 osCommerce/OM/Core/Site/Admin/Application/CoreUpdate/Model/getPackageContents.php
@@ -0,0 +1,85 @@
+<?php
+/*
+ osCommerce Online Merchant $osCommerce-SIG$
+ Copyright (c) 2010 osCommerce (http://www.oscommerce.com)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License v2 (1991)
+ as published by the Free Software Foundation.
+*/
+
+ namespace osCommerce\OM\Core\Site\Admin\Application\CoreUpdate\Model;
+
+ use \Phar;
+ use \RecursiveIteratorIterator;
+ use osCommerce\OM\Core\OSCOM;
+ use osCommerce\OM\Core\DirectoryListing;
+
+ class getPackageContents {
+ public static function execute() {
+ $result = array('entries' => array());
+
+ $phar_can_open = true;
+
+ try {
+ $phar = new Phar(OSCOM::BASE_DIRECTORY . 'Work/CoreUpdate/update.phar');
+ } catch ( \Exception $e ) {
+ $phar_can_open = false;
+
+ trigger_error($e->getMessage());
+ }
+
+ if ( $phar_can_open === true ) {
+ $update_pkg = array();
+ $core_fs = array();
+
+ foreach ( new RecursiveIteratorIterator($phar) as $iteration ) {
+ if ( ($pos = strpos($iteration->getPathName(), 'update.phar')) !== false ) {
+ $update_pkg[] = substr($iteration->getPathName(), $pos+12);
+ }
+ }
+
+ natcasesort($update_pkg);
+
+ $DL = new DirectoryListing(OSCOM::BASE_DIRECTORY);
+ $DL->setRecursive(true);
+ $DL->setIncludeDirectories(false);
+ $DL->setAddDirectoryToFilename(true);
+ $DL->setStats(false);
+
+ foreach ( $DL->getFiles() as $file ) {
+ $core_fs[] = 'osCommerce/OM/' . $file['name'];
+ }
+
+ $counter = 0;
+
+ foreach ( $update_pkg as $update_file ) {
+ $result['entries'][] = array('key' => $counter,
+ 'name' => $update_file,
+ 'exists' => in_array($update_file, $core_fs),
+ 'writable' => self::isWritable(realpath(OSCOM::BASE_DIRECTORY . '/../../') . '/' . $update_file));
+
+ $counter++;
+ }
+ }
+
+ $result['total'] = count($result['entries']);
+
+ return $result;
+ }
+
+ public static function isWritable($location) {
+ if ( !file_exists($location) ) {
+ while ( true ) {
+ $location = dirname($location);
+
+ if ( file_exists($location) ) {
+ break;
+ }
+ }
+ }
+
+ return is_writable($location);
+ }
+ }
+?>
View
41 osCommerce/OM/Core/Site/Admin/Application/CoreUpdate/Model/getPackageInfo.php
@@ -0,0 +1,41 @@
+<?php
+/*
+ osCommerce Online Merchant $osCommerce-SIG$
+ Copyright (c) 2010 osCommerce (http://www.oscommerce.com)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License v2 (1991)
+ as published by the Free Software Foundation.
+*/
+
+ namespace osCommerce\OM\Core\Site\Admin\Application\CoreUpdate\Model;
+
+ use \Phar;
+ use osCommerce\OM\Core\OSCOM;
+
+ class getPackageInfo {
+ public static function execute($key = null) {
+ $phar_can_open = true;
+
+ try {
+ $phar = new Phar(OSCOM::BASE_DIRECTORY . 'Work/CoreUpdate/update.phar');
+ } catch ( \Exception $e ) {
+ $phar_can_open = false;
+
+ trigger_error($e->getMessage());
+ }
+
+ if ( $phar_can_open === true ) {
+ $result = $phar->getMetadata();
+
+ if ( !empty($key) && isset($result[$key]) ) {
+ $result = $result[$key];
+ }
+
+ return $result;
+ }
+
+ return false;
+ }
+ }
+?>
View
20 osCommerce/OM/Core/Site/Admin/Application/CoreUpdate/Model/localPackageExists.php
@@ -0,0 +1,20 @@
+<?php
+/*
+ osCommerce Online Merchant $osCommerce-SIG$
+ Copyright (c) 2010 osCommerce (http://www.oscommerce.com)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License v2 (1991)
+ as published by the Free Software Foundation.
+*/
+
+ namespace osCommerce\OM\Core\Site\Admin\Application\CoreUpdate\Model;
+
+ use osCommerce\OM\Core\OSCOM;
+
+ class localPackageExists {
+ public static function execute() {
+ return file_exists(OSCOM::BASE_DIRECTORY . 'Work/CoreUpdate/update.phar');
+ }
+ }
+?>
View
28 osCommerce/OM/Core/Site/Admin/Application/CoreUpdate/Model/packageExists.php
@@ -0,0 +1,28 @@
+<?php
+/*
+ osCommerce Online Merchant $osCommerce-SIG$
+ Copyright (c) 2010 osCommerce (http://www.oscommerce.com)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License v2 (1991)
+ as published by the Free Software Foundation.
+*/
+
+ namespace osCommerce\OM\Core\Site\Admin\Application\CoreUpdate\Model;
+
+ use osCommerce\OM\Core\Site\Admin\Application\CoreUpdate\CoreUpdate;
+
+ class packageExists {
+ public static function execute($version) {
+ $versions = CoreUpdate::getAvailablePackages();
+
+ foreach ( $versions['entries'] as $v ) {
+ if ( $v['version'] == $version ) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+ }
+?>
View
33 osCommerce/OM/Core/Site/Admin/Application/CoreUpdate/RPC/GetAvailablePackages.php
@@ -0,0 +1,33 @@
+<?php
+/*
+ osCommerce Online Merchant $osCommerce-SIG$
+ Copyright (c) 2010 osCommerce (http://www.oscommerce.com)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License v2 (1991)
+ as published by the Free Software Foundation.
+*/
+
+ namespace osCommerce\OM\Core\Site\Admin\Application\CoreUpdate\RPC;
+
+ use osCommerce\OM\Core\Site\Admin\Application\CoreUpdate\CoreUpdate;
+ use osCommerce\OM\Core\Site\RPC\Controller as RPC;
+
+ class GetAvailablePackages {
+ public static function execute() {
+ if ( !isset($_GET['search']) ) {
+ $_GET['search'] = '';
+ }
+
+ if ( !empty($_GET['search']) ) {
+ $result = CoreUpdate::findAvailablePackages($_GET['search']);
+ } else {
+ $result = CoreUpdate::getAvailablePackages();
+ }
+
+ $result['rpcStatus'] = RPC::STATUS_SUCCESS;
+
+ echo json_encode($result);
+ }
+ }
+?>
View
33 osCommerce/OM/Core/Site/Admin/Application/CoreUpdate/RPC/GetPackageContents.php
@@ -0,0 +1,33 @@
+<?php
+/*
+ osCommerce Online Merchant $osCommerce-SIG$
+ Copyright (c) 2010 osCommerce (http://www.oscommerce.com)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License v2 (1991)
+ as published by the Free Software Foundation.
+*/
+
+ namespace osCommerce\OM\Core\Site\Admin\Application\CoreUpdate\RPC;
+
+ use osCommerce\OM\Core\Site\Admin\Application\CoreUpdate\CoreUpdate;
+ use osCommerce\OM\Core\Site\RPC\Controller as RPC;
+
+ class GetPackageContents {
+ public static function execute() {
+ if ( !isset($_GET['search']) ) {
+ $_GET['search'] = '';
+ }
+
+ if ( !empty($_GET['search']) ) {
+ $result = CoreUpdate::findPackageContents($_GET['search']);
+ } else {
+ $result = CoreUpdate::getPackageContents();
+ }
+
+ $result['rpcStatus'] = RPC::STATUS_SUCCESS;
+
+ echo json_encode($result);
+ }
+ }
+?>
View
100 osCommerce/OM/Core/Site/Admin/Application/CoreUpdate/pages/main.php
@@ -0,0 +1,100 @@
+<?php
+/*
+ osCommerce Online Merchant $osCommerce-SIG$
+ Copyright (c) 2010 osCommerce (http://www.oscommerce.com)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License v2 (1991)
+ as published by the Free Software Foundation.
+*/
+
+ use osCommerce\OM\Core\OSCOM;
+?>
+
+<h1><?php echo $OSCOM_Template->getIcon(32) . osc_link_object(OSCOM::getLink(), $OSCOM_Template->getPageTitle()); ?></h1>
+
+<?php
+ if ( $OSCOM_MessageStack->exists() ) {
+ echo $OSCOM_MessageStack->get();
+ }
+?>
+
+<form id="liveSearchForm">
+ <input type="text" id="liveSearchField" name="search" class="searchField fieldTitleAsDefault" title="Search.." /><?php echo osc_draw_button(array('type' => 'button', 'params' => 'onclick="osC_DataTable.reset();"', 'title' => 'Reset')); ?>
+</form>
+
+<div style="padding: 20px 5px 5px 5px; height: 16px;">
+ <span id="batchTotalPages"></span>
+ <span id="batchPageLinks"></span>
+</div>
+
+<table border="0" width="100%" cellspacing="0" cellpadding="2" class="dataTable" id="coreUpdateDataTable">
+ <thead>
+ <tr>
+ <th><?php echo OSCOM::getDef('table_heading_release_version'); ?></th>
+ <th><?php echo OSCOM::getDef('table_heading_release_date'); ?></th>
+ <th width="150"><?php echo OSCOM::getDef('table_heading_action'); ?></th>
+ </tr>
+ </thead>
+ <tfoot>
+ <tr>
+ <th colspan="3">&nbsp;</th>
+ </tr>
+ </tfoot>
+ <tbody>
+ </tbody>
+</table>
+
+<div style="padding: 5px;">
+ <span id="dataTableLegend"><?php echo '<b>' . OSCOM::getDef('table_action_legend') . '</b> ' . osc_icon('folder_contents.png', OSCOM::getDef('icon_view_contents')) . '&nbsp;' . OSCOM::getDef('icon_view_contents'); ?></span>
+ <span id="batchPullDownMenu"></span>
+</div>
+
+<script type="text/javascript">
+ var moduleParamsCookieName = 'oscom_admin_' + pageModule;
+ var dataTablePageSetName = 'page';
+
+ var moduleParams = new Object();
+ moduleParams[dataTablePageSetName] = 1;
+ moduleParams['search'] = '';
+
+ if ( $.cookie(moduleParamsCookieName) != null ) {
+ moduleParams = $.secureEvalJSON($.cookie(moduleParamsCookieName));
+ }
+
+ var dataTableName = 'coreUpdateDataTable';
+ var dataTableDataURL = '<?php echo OSCOM::getRPCLink(null, null, 'GetAvailablePackages'); ?>';
+
+ var updateInstallLink = '<?php echo OSCOM::getLink(null, null, 'Apply&v=VCODE'); ?>';
+ var updateInstallLinkIcon = '<?php echo osc_icon('folder_contents.png', OSCOM::getDef('icon_view_contents')); ?>';
+
+ var osC_DataTable = new osC_DataTable();
+ osC_DataTable.load();
+
+ function feedDataTable(data) {
+ var rowCounter = 0;
+
+ for ( var r in data.entries ) {
+ var record = data.entries[r];
+
+ var newRow = $('#' + dataTableName)[0].tBodies[0].insertRow(rowCounter);
+ newRow.id = 'row' + record.key;
+
+ $('#row' + record.key).hover( function() { $(this).addClass('mouseOver'); }, function() { $(this).removeClass('mouseOver'); }).css('cursor', 'pointer');
+
+ var newCell = newRow.insertCell(0);
+ newCell.innerHTML = htmlSpecialChars(record.version);
+
+ var newCell = newRow.insertCell(1);
+ newCell.innerHTML = htmlSpecialChars(record.date);
+
+ newCell = newRow.insertCell(2);
+ if ( record.update_package ) {
+ newCell.innerHTML = '<a href="' + updateInstallLink.replace('VCODE', htmlSpecialChars(record.version)) + '">' + updateInstallLinkIcon + '</a>';
+ newCell.align = 'right';
+ }
+
+ rowCounter++;
+ }
+ }
+</script>
View
102 osCommerce/OM/Core/Site/Admin/Application/CoreUpdate/pages/package_contents.php
@@ -0,0 +1,102 @@
+<?php
+/*
+ osCommerce Online Merchant $osCommerce-SIG$
+ Copyright (c) 2010 osCommerce (http://www.oscommerce.com)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License v2 (1991)
+ as published by the Free Software Foundation.
+*/
+
+ use osCommerce\OM\Core\OSCOM;
+ use osCommerce\OM\Core\Site\Admin\Application\CoreUpdate\CoreUpdate;
+?>
+
+<h1><?php echo $OSCOM_Template->getIcon(32) . osc_link_object(OSCOM::getLink(), $OSCOM_Template->getPageTitle()); ?></h1>
+
+<?php
+ if ( $OSCOM_MessageStack->exists() ) {
+ echo $OSCOM_MessageStack->get();
+ }
+?>
+
+<form id="liveSearchForm">
+ <input type="text" id="liveSearchField" name="search" class="searchField fieldTitleAsDefault" title="Search.." /><?php echo osc_draw_button(array('type' => 'button', 'params' => 'onclick="osC_DataTable.reset();"', 'title' => 'Reset')); ?>
+
+ <span style="float: right;"><?php echo osc_draw_button(array('href' => OSCOM::getLink(), 'priority' => 'secondary', 'icon' => 'triangle-1-w', 'title' => OSCOM::getDef('button_back'))) . (CoreUpdate::getPackageInfo('version_from') == OSCOM::getVersion() ? ' ' . osc_draw_button(array('href' => OSCOM::getLink(null, null, 'Apply&Process&v=' . $_GET['v']), 'icon' => 'disk', 'title' => OSCOM::getDef('button_apply_update'))) : ''); ?></span>
+</form>
+
+<div style="padding: 20px 5px 5px 5px; height: 16px;">
+ <span id="batchTotalPages"></span>
+ <span id="batchPageLinks"></span>
+</div>
+
+<table border="0" width="100%" cellspacing="0" cellpadding="2" class="dataTable" id="coreUpdateDataTable">
+ <thead>
+ <tr>
+ <th><?php echo OSCOM::getDef('table_heading_files'); ?></th>
+ <th width="150"><?php echo OSCOM::getDef('table_heading_file_replace'); ?></th>
+ <th width="150"><?php echo OSCOM::getDef('table_heading_file_writable'); ?></th>
+ </tr>
+ </thead>
+ <tfoot>
+ <tr>
+ <th colspan="3">&nbsp;</th>
+ </tr>
+ </tfoot>
+ <tbody>
+ </tbody>
+</table>
+
+<div style="padding: 2px; min-height: 16px;">
+ <span id="dataTableLegend"></span>
+ <span id="batchPullDownMenu"></span>
+</div>
+
+<script type="text/javascript">
+ var moduleParamsCookieName = 'oscom_admin_' + pageModule;
+ var dataTablePageSetName = 'page';
+
+ var moduleParams = new Object();
+ moduleParams[dataTablePageSetName] = 1;
+ moduleParams['search'] = '';
+
+ if ( $.cookie(moduleParamsCookieName) != null ) {
+ moduleParams = $.secureEvalJSON($.cookie(moduleParamsCookieName));
+ }
+
+ var dataTableName = 'coreUpdateDataTable';
+ var dataTableDataURL = '<?php echo OSCOM::getRPCLink(null, null, 'GetPackageContents'); ?>';
+
+ var checkboxTickedIcon = '<?php echo osc_icon('checkbox_ticked.gif'); ?>';
+ var checkboxCrossedIcon = '<?php echo osc_icon('checkbox_crossed.gif'); ?>';
+
+ var osC_DataTable = new osC_DataTable();
+ osC_DataTable.load();
+
+ function feedDataTable(data) {
+ var rowCounter = 0;
+
+ for ( var r in data.entries ) {
+ var record = data.entries[r];
+
+ var newRow = $('#' + dataTableName)[0].tBodies[0].insertRow(rowCounter);
+ newRow.id = 'row' + record.key;
+
+ $('#row' + record.key).hover( function() { $(this).addClass('mouseOver'); }, function() { $(this).removeClass('mouseOver'); }).css('cursor', 'pointer');
+
+ var newCell = newRow.insertCell(0);
+ newCell.innerHTML = htmlSpecialChars(record.name);
+
+ var newCell = newRow.insertCell(1);
+ newCell.innerHTML = record.exists == true ? checkboxTickedIcon : checkboxCrossedIcon;
+ newCell.align = 'center';
+
+ var newCell = newRow.insertCell(2);
+ newCell.innerHTML = record.writable == true ? checkboxTickedIcon : checkboxCrossedIcon;
+ newCell.align = 'center';
+
+ rowCounter++;
+ }
+ }
+</script>
View
33 osCommerce/OM/Core/Site/Admin/languages/en_US/CoreUpdate.php
@@ -0,0 +1,33 @@
+# $Id: $
+#
+# osCommerce, Open Source E-Commerce Solutions
+# http://www.oscommerce.com
+#
+# Copyright (c) 2010 osCommerce
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License v2 (1991)
+# as published by the Free Software Foundation.
+
+app_title = Core Update
+
+heading_title = Core Update
+
+table_heading_release_version = Version
+table_heading_release_date = Date
+table_heading_action = Action
+
+table_heading_files = Files
+table_heading_file_replace = Replace
+table_heading_file_writable = Writable
+
+action_heading_apply = Core Update: Update from v%s to v%s
+
+button_apply_update = Apply Update
+
+icon_view_contents = View Contents
+
+ms_error_select_version_to_view = Error: Please select an available package version to view.
+ms_error_local_update_package_does_not_exist = Error: Cannot download and save the update package. Please verify the osCommerce/OM/Work/CoreUpdate directory permissions and try again.
+ms_error_wrong_version_to_update_from = Error: Please verify the package to update from.
+ms_error_check_target_permissions = Error: Please verify the file and directory permissions before applying the update package again.
View
6 osCommerce/OM/Work/CoreUpdate/update.phar.pubkey
@@ -0,0 +1,6 @@
+-----BEGIN PUBLIC KEY-----
+MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDuc+QtTgCuUOKrjfJm1UWXdK88
+F/tQdqN66FOaP6cjv8mX9eceMC/Xi/VfHRz+Pt6qbWWpqFbRyH02j7oMX1COeax1
+/sBQvBxeCDUg+qZta+PIgIIBVP8bpG/DIl3gAkBMHXOqJ9gmGjd5OoywcBCuMFmR
+kjLUZy6A0MdqcQGrWQIDAQAB
+-----END PUBLIC KEY-----
View
BIN public/sites/Admin/images/applications/16/coreupdate.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN public/sites/Admin/images/applications/32/coreupdate.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN public/sites/Admin/templates/oscom/images/icons/16x16/folder_contents.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit acf5123

Please sign in to comment.
Something went wrong with that request. Please try again.