index.php (3509B)
1 <?php 2 3 /** 4 * 5 * @package Simple vQmod OpenCart install script 6 * @author Jay Gilford - http://vqmod.com/ 7 * @copyright Jay Gilford 2011 8 * @version 0.5 9 * @access public 10 * 11 * @information 12 * This file will perform all necessary file alterations for the 13 * OpenCart index.php files both in the root directory and in the 14 * Administration folder. Please note that if you have changed your 15 * default folder name from admin to something else, you will need 16 * to edit the admin/index.php in this file to install successfully 17 * 18 * @license 19 * Permission is hereby granted, free of charge, to any person to 20 * use, copy, modify, distribute, sublicense, and/or sell copies 21 * of the Software, subject to the following conditions: 22 * 23 * The above copyright notice and this permission notice shall be 24 * included in all copies or substantial portions of the Software 25 * 26 * @warning 27 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 28 * EXPRESSED OR IMPLIED. 29 * 30 */ 31 32 // CHANGE THIS IF YOU EDIT YOUR ADMIN FOLDER NAME 33 $admin = 'admin'; 34 35 // Counters 36 $changes = 0; 37 $writes = 0; 38 39 // Load class required for installation 40 require('ugrsr.class.php'); 41 42 // Get directory two above installation directory 43 $opencart_path = realpath(dirname(__FILE__) . '/../../') . '/'; 44 45 // Verify path is correct 46 if(empty($opencart_path)) die('ERROR - COULD NOT DETERMINE OPENCART PATH CORRECTLY - ' . dirname(__FILE__)); 47 48 $write_errors = array(); 49 if(!is_writeable($opencart_path . 'index.php')) { 50 $write_errors[] = 'index.php not writeable'; 51 } 52 if(!is_writeable($opencart_path . $admin . '/index.php')) { 53 $write_errors[] = 'Administrator index.php not writeable'; 54 } 55 56 if(!empty($write_errors)) { 57 die(implode('<br />', $write_errors)); 58 } 59 60 // Create new UGRSR class 61 $u = new UGRSR($opencart_path); 62 63 // remove the # before this to enable debugging info 64 #$u->debug = true; 65 66 // Set file searching to off 67 $u->file_search = false; 68 69 // Attempt upgrade if necessary. Otherwise just continue with normal install 70 $u->addFile('index.php'); 71 $u->addFile($admin . '/index.php'); 72 73 $u->addPattern('~\$vqmod->~', 'VQMod::'); 74 $u->addPattern('~\$vqmod = new VQMod\(\);~', 'VQMod::bootup();'); 75 76 $result = $u->run(); 77 78 if($result['writes'] > 0) { 79 if(file_exists('../mods.cache')) { 80 unlink('../mods.cache'); 81 } 82 die('UPGRADE COMPLETE'); 83 } 84 85 $u->clearPatterns(); 86 $u->resetFileList(); 87 88 // Add catalog index files to files to include 89 $u->addFile('index.php'); 90 91 // Pattern to add vqmod include 92 $u->addPattern('~// Startup~', '// VirtualQMOD 93 require_once(\'./vqmod/vqmod.php\'); 94 VQMod::bootup(); 95 96 // VQMODDED Startup'); 97 98 $result = $u->run(); 99 $writes += $result['writes']; 100 $changes += $result['changes']; 101 102 $u->clearPatterns(); 103 $u->resetFileList(); 104 105 // Add Admin index file 106 $u->addFile($admin . '/index.php'); 107 108 // Pattern to add vqmod include 109 $u->addPattern('~// Startup~', '//VirtualQMOD 110 require_once(\'../vqmod/vqmod.php\'); 111 VQMod::bootup(); 112 113 // VQMODDED Startup'); 114 115 116 $result = $u->run(); 117 $writes += $result['writes']; 118 $changes += $result['changes']; 119 120 $u->addFile('index.php'); 121 122 // Pattern to run required files through vqmod 123 $u->addPattern('/require_once\(DIR_SYSTEM \. \'([^\']+)\'\);/', 'require_once(VQMod::modCheck(DIR_SYSTEM . \'$1\'));'); 124 125 // Get number of changes during run 126 $result = $u->run(); 127 $writes += $result['writes']; 128 $changes += $result['changes']; 129 130 // output result to user 131 if(!$changes) die('VQMOD ALREADY INSTALLED!'); 132 if($writes != 4) die('ONE OR MORE FILES COULD NOT BE WRITTEN'); 133 die('VQMOD HAS BEEN INSTALLED ON YOUR SYSTEM!');