openbay.php - <?php class ModelExtensionOpenBayOpenbay...

This preview shows page 1 - 4 out of 21 pages.

The preview shows page 2 - 4 out of 21 pages.
<?phpclass ModelExtensionOpenBayOpenbay extends Model {private $url = '';private $error;public function patch() {}public function updateV2Test() {$this->error = array();$this->openbay->log('Starting update test');if (!function_exists("exception_error_handler")) {function exception_error_handler($errno, $errstr, $errfile,$errline ) {throw new ErrorException($errstr, 0, $errno, $errfile,$errline);}}set_error_handler('exception_error_handler');// check for mkdir enabledif (!function_exists('mkdir')) {$this->error[] = $this->language->get('error_mkdir');}// create a tmp folderif (!is_dir(DIR_DOWNLOAD . '/tmp')) {try {mkdir(DIR_DOWNLOAD . '/tmp');} catch(ErrorException $ex) {$this->error[] = $ex->getMessage();}}// create tmp filetry {$tmp_file = fopen(DIR_DOWNLOAD . '/tmp/test_file.php', 'w+');} catch(ErrorException $ex) {$this->error[] = $ex->getMessage();}// open and write over tmp filetry {$output= '<?php' . "\n";$output.= '$test = \'12345\';' . "\n";$output.= 'echo $test;' . "\n";fwrite($tmp_file, $output);fclose($tmp_file);} catch(ErrorException $ex) {$this->error[] = $ex->getMessage();}// try and read the file
// remove tmp filetry {unlink(DIR_DOWNLOAD . '/tmp/test_file.php');} catch(ErrorException $ex) {$this->error[] = $ex->getMessage();}// delete tmp foldertry {rmdir(DIR_DOWNLOAD . '/tmp');} catch(ErrorException $ex) {$this->error[] = $ex->getMessage();}// reset to the OC error handlerrestore_error_handler();$this->openbay->log('Finished update test');if (!$this->error) {$this->openbay->log('Finished update test - no errors');return array('error' => 0, 'response' => '', 'percent_complete'=> 20, 'status_message' => $this->language->get('text_check_new'));} else {$this->openbay->log('Finished update test - errors: ' .print_r($this->error));return array('error' => 1, 'response' => $this->error);}}public function updateV2CheckVersion($beta = 0) {$current_version = $this->config->get('openbay_version');$this->openbay->log('Start check version, beta: ' . $beta . ', current:' . $current_version);$post = array('version' => 4, 'beta' => $beta);$data = $this->call('update/version/', $post);if ($this->lasterror == true) {$this->openbay->log('Check version error: ' . $this->lastmsg);return array('error' => 1, 'response' => $this->lastmsg . ' (' .VERSION . ')');} else {if ($data['version'] > $current_version) {$this->openbay->log('Check version new available: ' .$data['version']);return array('error' => 0, 'response' => $data['version'],'percent_complete' => 40, 'status_message' => $this->language->get('text_downloading'));} else {$this->openbay->log('Check version - already latest');return array('error' => 1, 'response' => $this->language->get('text_version_ok') . $current_version);}}}
public function updateV2Download($beta = 0) {$this->openbay->log('Downloading');$local_file = DIR_DOWNLOAD . '/openbaypro_update.zip';$handle = fopen($local_file, "w+");$post = array('version' => 4, 'beta' => $beta);$defaults = array(CURLOPT_POST => 1,CURLOPT_HEADER => 0,CURLOPT_URL => $this->url . 'update/download/',CURLOPT_USERAGENT => 'OpenBay Pro update script',CURLOPT_FRESH_CONNECT => 1,CURLOPT_RETURNTRANSFER => 1,CURLOPT_FORBID_REUSE => 1,CURLOPT_TIMEOUT => 0,CURLOPT_SSL_VERIFYPEER => 0,CURLOPT_SSL_VERIFYHOST => 0,CURLOPT_POSTFIELDS => http_build_query($post, '', "&"),CURLOPT_FILE => $handle);$ch = curl_init();curl_setopt_array($ch, $defaults);curl_exec($ch);$curl_error = curl_error ($ch);$this->openbay->log('Download errors: ' . $curl_error);curl_close($ch);return array('error' => 0, 'response' => $curl_error,'percent_complete' => 60, 'status_message' => $this->language->get('text_extracting'));}public function updateV2Extract() {$this->error = array();

Upload your study docs or become a

Course Hero member to access this document

Upload your study docs or become a

Course Hero member to access this document

End of preview. Want to read all 21 pages?

Upload your study docs or become a

Course Hero member to access this document

Term
Fall
Professor
N/A
Tags

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture