shop.balmet.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

cron_functions.php (1202B)


      1 <?php
      2 
      3 function squareup_validate() {
      4     if (php_sapi_name() != 'cli') {
      5         die("Not in Command Line.");
      6     }
      7 }
      8 
      9 function squareup_chdir($current_dir) {
     10     $root_dir = dirname(dirname(dirname($current_dir)));
     11 
     12     chdir($root_dir);
     13 
     14     return $root_dir;
     15 }
     16 
     17 function squareup_define_route() {
     18     define('SQUAREUP_ROUTE', 'extension/recurring/squareup/recurring');
     19 
     20     $_GET['route'] = SQUAREUP_ROUTE;
     21 }
     22 
     23 function squareup_init($current_dir) {
     24     global $argc, $argv;
     25 
     26     // Validate environment
     27     squareup_validate();
     28 
     29     // Set up default server vars
     30     if (isset($argc) && isset($argv) && $argc >= 3) {
     31         $_SERVER["HTTP_HOST"] = $argv[1];
     32         $_SERVER["SERVER_NAME"] = $argv[1];
     33         $_SERVER["SERVER_PORT"] = $argv[2];
     34     } else {
     35         $_SERVER["HTTP_HOST"] = "localhost";
     36         $_SERVER["SERVER_NAME"] = "localhost";
     37         $_SERVER["SERVER_PORT"] = 80;
     38     }
     39 
     40     putenv("SERVER_NAME=" . $_SERVER["SERVER_NAME"]);
     41 
     42     // Change root dir
     43     $root_dir = squareup_chdir($current_dir);
     44 
     45     squareup_define_route();
     46 
     47     if (file_exists($root_dir . '/index.php')) {
     48         return $root_dir . '/index.php';
     49     }
     50 }