public function upload() { // $last = !empty($this->request->post['last']) ? $this->request->post['last'] : array( // 'step' => 'list', // 'continue_from' => '' // ); $response =& $this->request->post['last']; $valid_extensions = $this->get_valid_extensions(array('css' => getNitroPersistence('CDNRackspace.SyncCSS'), 'js' => getNitroPersistence('CDNRackspace.SyncJavaScript'), 'images' => getNitroPersistence('CDNRackspace.SyncImages'))); if (empty($valid_extensions)) { throw new Exception("No file types selected for upload."); } $files = $this->cdn_prepare_files(array('valid_extensions' => $valid_extensions, 'cdn' => '2')); if (!empty($files) && $response['step'] == 'upload') { require_once NITRO_LIB_FOLDER . 'rackspace/php-opencloud.php'; if (phpversion() >= '5.3.0') { require_once NITRO_INCLUDE_FOLDER . 'rackspace_init.php'; } else { throw new Exception("Your PHP version is " . phpversion() . '. Rackspace CDN can be used on PHP 5.3.0+'); } $data = array('rackspace' => &$objstore); foreach ($files as $file) { $data['file'] = $file; $this->rackspace_upload_file($data); $this->cdn_after_upload($file); } } else { if (empty($files) && $response['step'] == 'upload') { $persistence = getNitroPersistence(); $persistence['Nitro']['CDNRackspace']['LastUpload'] = date($this->language->get('date_format_long') . ' ' . $this->language->get('time_format')); setNitroPersistence($persistence); } } }
public function upload() { // $last = !empty($this->request->post['last']) ? $this->request->post['last'] : array( // 'step' => 'list', // 'continue_from' => '' // ); $response =& $this->request->post['last']; $valid_extensions = $this->get_valid_extensions(array('css' => getNitroPersistence('CDNAmazon.SyncCSS'), 'js' => getNitroPersistence('CDNAmazon.SyncJavaScript'), 'images' => getNitroPersistence('CDNAmazon.SyncImages'))); if (empty($valid_extensions)) { throw new Exception("No file types selected for upload."); } $files = $this->cdn_prepare_files(array('valid_extensions' => $valid_extensions, 'cdn' => '1')); if (!empty($files) && $response['step'] == 'upload') { if (!class_exists('S3')) { require_once NITRO_LIB_FOLDER . 'S3.php'; } $s3 = new S3(getNitroPersistence('CDNAmazon.AccessKeyID'), getNitroPersistence('CDNAmazon.SecretAccessKey')); $data = array('s3' => &$s3); foreach ($files as $file) { $data['file'] = $file; $this->amazon_upload_file($data); $this->cdn_after_upload($file); } } else { if (empty($files) && $response['step'] == 'upload') { $persistence = getNitroPersistence(); $persistence['Nitro']['CDNAmazon']['LastUpload'] = date($this->language->get('date_format_long') . ' ' . $this->language->get('time_format')); setNitroPersistence($persistence); } } }
public function upload() { // $last = !empty($this->request->post['last']) ? $this->request->post['last'] : array( // 'step' => 'list', // 'continue_from' => '' // ); $response =& $this->request->post['last']; $valid_extensions = $this->get_valid_extensions(array('css' => getNitroPersistence('CDNStandardFTP.SyncCSS'), 'js' => getNitroPersistence('CDNStandardFTP.SyncJavaScript'), 'images' => getNitroPersistence('CDNStandardFTP.SyncImages'))); if (empty($valid_extensions)) { throw new Exception("No file types selected for upload."); } $files = $this->cdn_prepare_files(array('valid_extensions' => $valid_extensions, 'cdn' => '3')); if (!empty($files) && $response['step'] == 'upload') { $ftp =& $this->get_ftp_connection(); $data = array('ftp' => $ftp); np($files, 0, FILE_APPEND); foreach ($files as $file) { $data['file'] = $file; $this->ftp_upload_file($data); $this->cdn_after_upload($file); } } else { if (empty($files) && $response['step'] == 'upload') { $persistence = getNitroPersistence(); $persistence['Nitro']['CDNStandardFTP']['LastUpload'] = date($this->language->get('date_format_long') . ' ' . $this->language->get('time_format')); setNitroPersistence($persistence); } } }
public function setPersistence($data) { $this->loadCore(); return setNitroPersistence($data); }
public function cdn() { if ($this->request->server['REQUEST_METHOD'] != 'POST') { $this->response->setOutput(''); return; } $this->load->model('tool/nitro'); $this->model_tool_nitro->loadCore(); set_error_handler(create_function('$severity, $message, $file, $line', 'throw new Exception($message . " in file " . $file . " on line " . $line . ". Debug backtrace: <pre>" . print_r(debug_backtrace(), true) . "</pre>");')); // Save config if (!empty($this->request->post['config']['Nitro'])) { $nitro_persistence = getNitroPersistence(); foreach ($this->request->post['config']['Nitro'] as $key => $config_vals) { $nitro_persistence['Nitro'][$key] = $config_vals; } setNitroPersistence($nitro_persistence); } if (empty($this->request->post['last'])) { $this->request->post['last'] = array('response_type' => 'error', 'percent' => 0, 'message' => 'CDN type not valid.'); } $response =& $this->request->post['last']; try { if (!empty($this->request->post['cdn'])) { switch ($this->request->post['cdn']) { case 'amazon': $this->load->model('tool/nitro_amazon'); $this->model_tool_nitro_amazon->upload(); break; case 'rackspace': $this->load->model('tool/nitro_rackspace'); $this->model_tool_nitro_rackspace->upload(); break; case 'ftp': $this->load->model('tool/nitro_ftp'); $this->model_tool_nitro_ftp->upload(); break; } } } catch (Exception $e) { $response['percent'] = 0; $response['response_type'] = 'error'; $response['message'] = $e->getMessage(); } restore_error_handler(); $this->response->setOutput(json_encode($response)); }