public function __call($name, $arguments)
 {
     if ($this->results()) {
         // If the requirements pass
         if (count($arguments) == 1) {
             $res = FileModifier::file($this->file)->{$name}($arguments[0])->execute($this->execute);
         } else {
             if (count($arguments) == 2) {
                 $res = FileModifier::file($this->file)->{$name}($arguments[0], $arguments[1])->execute($this->execute);
             }
         }
         $this->finalResults = array_merge($this->finalResults, $res);
     }
 }
예제 #2
0
 function whereNoSearch($search, $count = null)
 {
     $execution = FileModifier::file($this->file)->find($search)->execute();
     $result = true;
     if ($execution) {
         if (is_numeric($count)) {
             $result = count($execution) != $count;
         } else {
             if (count($execution) > 0) {
                 $result = false;
             }
         }
     }
     $this->results[] = $result;
     $this->addValidation('whereNoSearch', $search, $result);
 }
예제 #3
0
define('API_VERSION', 'v1');
define('DIR_OPENCART', str_replace('\'', '/', realpath(DIR_APPLICATION . '../')) . '/');
define('DIR_API', str_replace('\'', '/', realpath(dirname(__FILE__) . '/../../../api/')) . '/');
define('DIR_API_VERSION', DIR_API . API_VERSION . '/');
$apiIndexFilePath = DIR_API_VERSION . 'index.php';
$apiConfigFilePath = DIR_API_VERSION . 'config.php';
chmod($apiIndexFilePath, 0755);
chmod($apiConfigFilePath, 0755);
if (!is_writable($apiIndexFilePath)) {
    die('Error: Could not write to index.php please check you have set the correct permissions on: ' . $apiIndexFilePath);
}
if (!is_writable($apiConfigFilePath)) {
    die('Error: Could not write to config.php please check you have set the correct permissions on: ' . $apiConfigFilePath);
}
// index.php
$indexFileModifier = new FileModifier(DIR_OPENCART . 'index.php', $apiIndexFilePath);
$indexFileModifier->replaceLine('require_once(\'./vqmod/vqmod.php\');', 'require_once(\'../../vqmod/vqmod.php\');', true);
$indexFileModifier->replaceLine('rtrim(dirname($_SERVER[\'PHP_SELF\'])', 'rtrim(dirname(dirname(dirname($_SERVER[\'PHP_SELF\'])))');
$indexFileModifier->replaceLine('rtrim(dirname($_SERVER[\'PHP_SELF\']),', 'rtrim(dirname(dirname(dirname($_SERVER[\'PHP_SELF\']))),');
$indexFileModifier->replaceLine('new Loader', 'new ApiLoader');
$indexFileModifier->replaceLine('new Url(', 'new ApiUrl(');
$indexFileModifier->replaceLine('new Request();', 'new ApiRequest($registry);');
$indexFileModifier->replaceLine('new Response();', 'new ApiResponse($registry);');
$indexFileModifier->replaceLine('Content-Type: text/html; charset=utf-8', 'Content-Type: application/json');
$indexFileModifier->replaceLine('$session = new Session();', '$session = new ApiSession($registry);');
$indexFileModifier->replaceLine('new Action(\'common/maintenance\')', 'new ApiAction(\'common/maintenance\')');
$indexFileModifier->replaceLine('new Action($request->get[\'route\'])', 'new ApiAction($request->get[\'route\'])');
$indexFileModifier->replaceLine('new Action(\'common/home\')', 'new ApiAction(\'error/not_found\')');
$indexFileModifier->deleteLine('// SEO URL\'s', 2);
$indexFileModifier->deleteLine('$controller->dispatch($action, new Action(\'error/not_found\'));', 1);
$indexFileModifier->deleteLine('(!isset($request->cookie[\'language\'])', 4, true);