Example #1
0
 /**
  * main action
  */
 public function mainAction()
 {
     $result = local_exec('fortune');
     $quote = array();
     $quote['text'] = $result;
     $this->tpl->assign("QUOTE", $quote);
     return true;
 }
Example #2
0
 /**
  * main action
  */
 public function mainAction()
 {
     $str = $this->GET['str'];
     if (preg_match("/[^a-zA-Z0-9\\.]/", $str)) {
         msg("whois: invalid string");
     } else {
         $result = local_exec("whois {$str}");
         $this->tpl->assign("RESULT", $result);
     }
     return true;
 }
Example #3
0
 /**
  * create project backup file
  */
 public function createProjectBackupFile()
 {
     $setting = $this->getSetting();
     $filename = "{$_SERVER['HTTP_HOST']}.tar.gz";
     if ($this->checkPermission($setting)) {
         local_exec("backup_project {$setting['PROJECT_DIR']}  {$filename}");
         //local_exec("backup_onxshop {$setting['ONXSHOP_DIR']}  $setting['PROJECT_DIR'] . 'var/backups/onxshop.tgz'");
         return $filename;
     } else {
         return false;
     }
 }
Example #4
0
 /**
  * Determines if ImageMagick is of version less than 6.7.5.
  */
 protected static function isOldImageMagickVersion()
 {
     $shell_command = "convert -version";
     $result = local_exec($shell_command);
     if (preg_match('/Version\\:\\s+ImageMagick\\s+(\\d)\\.(\\d)\\.(\\d)/', $result, $matches)) {
         if ($matches[1] < 6) {
             return true;
         }
         if ($matches[1] == 6 && $matches[2] < 7) {
             return true;
         }
         if ($matches[1] == 6 && $matches[2] == 7 && $matches[3] < 5) {
             return true;
         }
     }
     return false;
 }
 /**
  * generateSingleVoucher
  */
 public function generateSingleVoucher($voucher_basket_item)
 {
     if (!is_array($voucher_basket_item)) {
         return false;
     }
     $voucher_data = array();
     $voucher_data['variety_id'] = $voucher_basket_item['product_variety_id'];
     $voucher_data['recipient_name'] = $voucher_basket_item['other_data']['recipient_name'];
     $voucher_data['recipient_email'] = $voucher_basket_item['other_data']['recipient_email'];
     $voucher_data['message'] = $voucher_basket_item['other_data']['message'];
     $voucher_data['sender_name'] = $voucher_basket_item['other_data']['sender_name'];
     if ($voucher_basket_item['other_data']['delivery_date']) {
         $voucher_data['delivery_date'] = $voucher_basket_item['other_data']['delivery_date'];
     }
     if (!$this->validateData($voucher_data)) {
         msg("Voucher data are not valid", 'error');
         return false;
     }
     /**
      * create discount code
      */
     $code_pattern_base = "GIFT-{$voucher_basket_item['id']}" . '-';
     $promotion_data = array();
     $promotion_data['type'] = 4;
     // Gift Voucher
     $promotion_data['code_pattern'] = $code_pattern_base . $this->randomCode();
     $promotion_data['title'] = $promotion_data['code_pattern'];
     $promotion_data['discount_percentage_value'] = 0;
     $promotion_data['discount_fixed_value'] = $voucher_basket_item['total'];
     $promotion_data['uses_per_coupon'] = $voucher_basket_item['quantity'];
     $promotion_data['other_data'] = $voucher_basket_item['other_data'];
     $promotion_data['publish'] = 1;
     $promotion_data['generated_by_order_id'] = $this->GET['order_id'];
     require_once 'models/ecommerce/ecommerce_promotion.php';
     $Promotion = new ecommerce_promotion();
     $Promotion->setCacheable(false);
     //TODO: check if the code wasn't generated before for the same order
     if ($Promotion->checkCodeMatchPartially($code_pattern_base)) {
         msg("Code {$code_pattern_base}* was previously generated", 'error');
         return false;
     }
     //preg_match("/GIFT-{$voucher_basket_item['id']}/", $all_patterns_list)
     if ($promotion_id = $Promotion->addPromotion($promotion_data)) {
         msg("Promotion code {$promotion_data['code_pattern']} generated as promotion ID {$promotion_id}", 'ok', 1);
     } else {
         msg('Promotion code generation failed', 'error');
         //return false;
     }
     /**
      * create the voucher file
      */
     $url = "http://{$_SERVER['SERVER_NAME']}/request/sys/html5.node/site/print.component/ecommerce/gift_voucher~voucher_code={$promotion_data['code_pattern']}~";
     $gift_voucher_directory = ONXSHOP_PROJECT_DIR . "var/vouchers/";
     $gift_voucher_filename = "{$promotion_data['code_pattern']}.png";
     $gift_voucher_filename_fullpath = $gift_voucher_directory . $gift_voucher_filename;
     //check directory exits
     if (!is_dir($gift_voucher_directory)) {
         mkdir($gift_voucher_directory);
     }
     $shell_command = "wkhtmltoimage {$url} {$gift_voucher_filename_fullpath}";
     if ($result = local_exec($shell_command)) {
         msg("File {$gift_voucher_filename_fullpath} generated by wkhtmltoimage", 'ok', 1);
     }
     /**
      * send email
      * postpone if delivery_date is set
      */
     if (preg_match("/[0-9]{1,2}\\/[0-9]{1,2}\\/[0-9]{4}/", $voucher_data['delivery_date'])) {
         $this->postponeDelivery($promotion_id, $voucher_data['delivery_date']);
     } else {
         $this->sendEmail($promotion_data, $voucher_data, $gift_voucher_filename);
     }
     return true;
 }
Example #6
0
 /**
  * get file list using unix file command
  * TODO: use PHP glob() instead
  *
  * @param string $directory
  * from this directory
  * 
  * @param string $attrs
  * files attributes
  * 
  * @param integer $display_hidden
  * with hidden files (1) or not (0)
  * 
  * @return mixed
  * files array or false
  */
 function getFlatArrayFromFs($directory, $attrs = '', $display_hidden = 0)
 {
     //FIND2GLOB PATCH: function getFlatArrayFromFs($directory, $type = '', $recursive = true, $display_hidden = 0) {
     msg("calling getFlatArrayFromFs({$directory})", 'ok', 3);
     if (!file_exists($directory)) {
         msg("Directory {$directory} does not exists!", 'error', 1);
         return false;
     }
     $csv_list = local_exec("csv_from_fs " . escapeshellarg($directory) . " " . escapeshellarg($attrs));
     //FIND2GLOB PATCH:  $csv_list = $this->csv_from_glob($directory, $type, $recursive);
     $csv_list = str_replace(rtrim($directory, '/'), '', $csv_list);
     $csv_array = explode("\n", $csv_list);
     $basename = '/' . basename($directory) . '/';
     foreach ($csv_array as $c) {
         $x = explode(';', $c);
         //dont populate base directory
         if ($x[0] != $basename) {
             $csv[] = $x;
         }
     }
     array_pop($csv);
     foreach ($csv as $c) {
         $l['id'] = ltrim($c[0], '/');
         $l['parent'] = ltrim($c[1], '/');
         $l['name'] = $c[2];
         $l['title'] = $c[2];
         if (is_dir($directory . $l['id'])) {
             $l['node_group'] = 'folder';
         } else {
             $l['node_group'] = 'file';
         }
         $l['publish'] = 1;
         $l['size'] = $this->resize_bytes($c[3]);
         $l['modified'] = str_replace('.0000000000', '', $c[4]);
         //remove seconds fraction
         if ($display_hidden) {
             $csvf[] = $l;
         } else {
             // don't display hidden files files beginning with "."
             if (!preg_match("/^\\./", $l['name'])) {
                 $csvf[] = $l;
             }
         }
     }
     if (!is_array($csvf)) {
         $csvf = array();
     }
     return $csvf;
 }
Example #7
0
     $image_file = null;
 }
 if ($width > $image_configuration['thumbnail_width_max']) {
     $image_file = null;
 }
 if ($width % $image_configuration['thumbnail_step'] > 0) {
     $image_file = null;
 }
 if (!is_readable(ONXSHOP_PROJECT_DIR . $image_file)) {
     $image_file = null;
 }
 if ($image_file) {
     /**
      * get content type
      */
     $mime_type = local_exec("file -bi " . escapeshellarg(ONXSHOP_PROJECT_DIR . $image_file));
     $mime_type = trim($mime_type);
     /**
      * check what to display
      */
     if (preg_match("/image/", $mime_type)) {
         //if image, process it
     } else {
         if ($mime_type == 'application/pdf') {
             $image_file = "public_html/share/images/mimetype/pdf.png";
         } else {
             if ($mime_type == 'application/msword') {
                 $image_file = "public_html/share/images/mimetype/document.png";
             } else {
                 if ($mime_type == 'application/vnd.ms-excel') {
                     $image_file = "public_html/share/images/mimetype/spreadsheet.png";
Example #8
0
    // log it
} else {
    //admin user can download any content from var/ directory
    if (Onxshop_Bo_Authentication::getInstance()->isAuthenticated()) {
        $check = addcslashes(ONXSHOP_PROJECT_DIR, '/') . 'var\\/';
    } else {
        //guest user can download only content of var/files
        //$check = addcslashes(ONXSHOP_PROJECT_DIR, '/') . 'var\/images\/';
        $check = addcslashes(ONXSHOP_PROJECT_DIR, '/') . 'var\\/files\\/';
    }
    if (!preg_match("/{$check}/", $realpath)) {
        header("HTTP/1.0 403 Forbidden");
        echo "forbidden";
        exit;
    }
    /**
     * Detect file type and send to the clien
     */
    $mimetype = local_exec("file -bi " . escapeshellarg($file));
    header('Pragma: private');
    header('Cache-control: private, must-revalidate');
    header("Content-type: {$mimetype}");
    if (!isset($_GET['view'])) {
        header('Content-Disposition: attachment; filename=' . basename($file));
    }
    header("Content-Length: " . filesize($file));
    ob_end_clean();
    $bytes = readfile($file);
    session_write_close();
    exit;
}