示例#1
0
 function authenticateCustomerInfo()
 {
     $post = JRequest::get('post');
     $post['customer_password'] = JRequest::getString('customer_password', '', 'post', JREQUEST_ALLOWRAW);
     $link = JSN_TEMPLATE_AUTOUPDATE_URL . '&identified_name=' . urlencode($this->_identified_name) . '&based_identified_name=&edition=' . urlencode($this->_edition) . '&joomla_version=' . urlencode($this->_joomla_version) . '&username='******'customer_username']) . '&password='******'customer_password']) . '&upgrade=no';
     $objHTTPSocket = new JSNHTTPSocket($link, null, null, 'get');
     $result = $objHTTPSocket->socketDownload();
     if ($result) {
         $decodeToJSON = json_decode($result);
         if (is_null($decodeToJSON)) {
             $errorCode = strtolower((string) $result);
             switch ($errorCode) {
                 case 'err01':
                     $message = 'Invalid username or password. Please input JoomlaShine customer account you created when were purchasing the product';
                     break;
                 case 'err02':
                     $message = 'Installation is not authorized. We could not find the product in your order list. Seems like you did not purchase it yet..';
                     break;
                 case 'err03':
                     $message = 'Requested file is not found on server';
                     break;
                 default:
                     $message = '';
                     break;
             }
             JError::raiseWarning('SOME_ERROR_CODE', $message);
             return false;
         } else {
             return true;
         }
     }
     JError::raiseWarning('SOME_ERROR_CODE', 'Can not authorize your Customer account! Your server does not allow connection to Joomlashine server.');
     return false;
 }
示例#2
0
 /**
  * This function will authenticate the user as JoomlaShine customer and
  * return the array of versions of template that the user purchased
  * @return [type] [description]
  */
 function authenticateCustomerInfo()
 {
     $post = JRequest::get('post');
     $post['customer_password'] = JRequest::getString('customer_password', '', 'post', JREQUEST_ALLOWRAW);
     $link = JSN_TEMPLATE_AUTOUPDATE_URL . '&identified_name=' . urlencode($this->_identified_name) . '&joomla_version=' . urlencode($this->_joomla_version) . '&username='******'customer_username']) . '&password='******'customer_password']) . '&upgrade=no';
     $objHTTPSocket = new JSNHTTPSocket($link, null, null, 'get');
     $result = $objHTTPSocket->socketDownload();
     $errorCode = strtolower((string) $result);
     $hasError = true;
     $rel = new stdClass();
     if ($result) {
         switch ($errorCode) {
             case 'err00':
                 $message = 'Invalid Parameters! Cannot verify your product information.';
                 break;
             case 'err01':
                 $message = 'Invalid username or password. Please enter JoomlaShine customer account you created when you purchased the product.';
                 break;
             case 'err02':
                 $message = 'Installation is not authorized. We could not find the product in your order list. Seems like you did not purchase it yet.';
                 break;
             case 'err03':
                 $message = 'Requested file could not be found on server.';
                 break;
             default:
                 $hasError = false;
                 break;
         }
         if ($hasError === true) {
             $rel->error = true;
             $rel->message = $message;
         } else {
             /* Standardize the returned array */
             $result = json_decode($result, true);
             $editionArray = array();
             foreach ($result['editions'] as $value) {
                 if (!in_array($value, $editionArray)) {
                     $editionArray[] = $value;
                 }
             }
             $rel->error = false;
             $rel->editions = $editionArray;
             $rel->post['customer_username'] = $post['customer_username'];
             $rel->post['customer_password'] = $post['customer_password'];
         }
     } else {
         $rel->error = true;
         $rel->message = 'Can not authorize your Customer account! Your server does not allow connection to Joomlashine server.';
     }
     return $rel;
 }
示例#3
0
文件: jsn_ajax.php 项目: Rikisha/proj
 /**
  * This function is for installing extensions for sample data
  * This function DOES NOT actually install the extension, but acts as a
  * "proxy" to receive request from AJAX, then using HTTP Socket to send an
  * internal request to install the extension.
  * It is important to go this way because direct AJAX request to install
  * the extension might get interrupted because some extensions will perform
  * a 303 redirection after standard Joomla JInstaller process.
  */
 function requestInstallExtension()
 {
     $session = JFactory::getSession();
     $sdExtSesId = md5('exts_info_' . strtolower($this->_template_name));
     $sdExtInstallSesId = md5('exts_to_install_' . strtolower($this->_template_name));
     $sessionExtFailedId = md5('exts_failed_install_' . strtolower($this->_template_name));
     $sdFileSesId = md5('sample_data_file_' . strtolower($this->_template_name));
     $extInfoArray = $session->get($sdExtSesId, array(), 'jsntemplatesession');
     $flatInstallExts = $session->get($sdExtInstallSesId, array(), 'jsntemplatesession');
     $sdHelperInstance = new JSNSampleDataHelper();
     /* Get the submitted valirables */
     $extName = JRequest::getVar('ext_name');
     if (array_key_exists($extName, $extInfoArray)) {
         $extInfo = $extInfoArray[$extName];
         $installResult = true;
         $toContinue = true;
         $mes = '';
         $failedExts = $session->get($sessionExtFailedId, array(), 'jsntemplatesession');
         $sampleDataFile = '';
         /* Download latest version */
         require_once $this->_template_folder_path . DS . 'includes' . DS . 'lib' . DS . 'jsn_downloadtemplatepackage.php';
         $joomlaVersion = $this->_obj_utils->getJoomlaVersion(true);
         if ($extInfo->downloadUrl) {
             $link = $extInfo->downloadUrl;
         } else {
             $link = JSN_TEMPLATE_AUTOUPDATE_URL . '&identified_name=' . urlencode($extInfo->identifiedName) . '&joomla_version=' . $joomlaVersion . '&edition=free&upgrade=yes';
         }
         $tmpName = $extInfo->name . '-j' . $joomlaVersion . '.zip';
         $packageDownloaderInstance = new JSNDownloadTemplatePackage($link, $tmpName);
         $downloadResult = $packageDownloaderInstance->download();
         if (!$downloadResult || stripos($downloadResult, 'error0') !== false) {
             $installResult = false;
             $failedExts[$extInfo->name]['exist'] = $extInfo->exist;
             $mes = JText::_('JSN_SAMPLE_DATA_EXT_DOWNLOAD_FAILED');
             if ($extInfo->hasData === true) {
                 $failedExts[$extInfo->name]['message'] = JText::sprintf('JSN_SAMPLE_DATA_WARNING_EXT_INSTALL_FAILED', $extInfo->description);
             }
         } else {
             /* If download success, send HTTP Socket request to install */
             $url = JURI::root() . 'index.php?template=' . strtolower($this->_template_name) . '&tmpl=jsn_runajax&task=installExtension' . '&package=' . urlencode($downloadResult) . '&redirect=0';
             // The last argument NOFOLLOW = true means don't follow redirection
             $httpRequestInstance = new JSNHTTPSocket($url, null, null, 'get', true);
             $output = json_decode($httpRequestInstance->socketDownload());
             /* Assuming empty string (as redirection) returned means success */
             if (isset($output->result) && $output->result === false) {
                 $installResult = false;
                 if (isset($output->message) && $output->message != '') {
                     $mes = $output->message;
                 } else {
                     $mes = JText::_('JSN_SAMPLE_DATA_INSTALL_FAILED');
                 }
                 $failedExts[$extInfo->name]['exist'] = $extInfo->exist;
                 /* Only show warning for the extension which actually has sample data */
                 if ($extInfo->hasData === true) {
                     $failedExts[$extInfo->name]['message'] = JText::sprintf('JSN_SAMPLE_DATA_WARNING_EXT_INSTALL_FAILED', $extInfo->description);
                 }
             } else {
                 $installResult = true;
                 /**
                  * As ImageShow might not have completed the installation
                  * itself, so Joomla cannot remove the installation file.
                  * We need to delete installer package using an existing
                  * function of SampleData Helper.
                  */
                 $sdHelperInstance->deleteSampleDataFile($downloadResult);
                 /* Enable plugins as were not enabled by JInstaller */
                 $sdHelperInstance->enableInstalledPlugin($extInfo->name, $extInfo->type);
             }
         }
         /* Change to the next extension if available */
         if (array_key_exists($extName, $flatInstallExts)) {
             unset($flatInstallExts[$extName]);
             if (count($flatInstallExts) > 0) {
                 $arrayKeys = array_keys($flatInstallExts);
                 $nextExt = $arrayKeys[0];
                 $childOf = $flatInstallExts[$nextExt]['childOf'];
                 $isLastExt = $flatInstallExts[$nextExt]['isLastExt'];
             } else {
                 $nextExt = '';
                 $childOf = '';
                 $isLastExt = false;
             }
             $sampleDataFile = $session->get($sdFileSesId, '', 'jsntemplatesession');
             $session->set($sdExtInstallSesId, $flatInstallExts, 'jsntemplatesession');
             $session->set($sessionExtFailedId, $failedExts, 'jsntemplatesession');
             echo json_encode(array('installExt' => $installResult, 'extName' => $extName, 'message' => $mes, 'nextExt' => $nextExt, 'childOf' => $childOf, 'isLastExt' => $isLastExt, 'tocontinue' => $toContinue, 'sampleDataFile' => $sampleDataFile));
         }
     }
     exit;
 }
示例#4
0
 private function getLatestProductCatInfo($categoryName)
 {
     $httpRequestInstance = new JSNHTTPSocket(JSN_CAT_INFO_URL . $categoryName, null, null, 'get');
     return $httpRequestInstance->socketDownload();
 }
 function fsocketdownload()
 {
     $target = $this->_tmpFolder . $this->_tmpPackageName;
     $obj_http_request = new JSNHTTPSocket($this->_downloadURL, null, null, 'get');
     $contents = $obj_http_request->socketDownload();
     if ($contents == false) {
         return false;
     }
     if (!$this->_objArchive->checkZipData($contents)) {
         return $contents;
     }
     JFile::write($target, $contents);
     return basename($target);
 }
示例#6
0
 function socketDownload()
 {
     /**
      * When it come across this point from a JSNDownloadPackage instance,
      * the fsockopen will always be used, not cURL nor fOPEN
      */
     $objJSNUtil = JSNUtils::getInstance();
     if (!function_exists('fsockopen')) {
         if ($objJSNUtil->cURLCheckFunctions()) {
             return $this->cURLDownload();
         } elseif ($objJSNUtil->fOPENCheck()) {
             return $this->fOPENDownload();
         } else {
             return false;
         }
     }
     $crlf = "\r\n";
     $response = '';
     $data = '';
     if (is_array($this->_data) && count($this->_data) > 0) {
         $data = array();
         while (list($n, $v) = each($this->_data)) {
             $data[] = "{$n}={$v}";
         }
         $data = implode('&', $data);
         $contentType = "Content-type: application/x-www-form-urlencoded" . $crlf;
     } else {
         $data = $this->_data;
         $contentType = "Content-type: text/xml" . $crlf;
     }
     if (is_null($this->_referer)) {
         $referer = JURI::root();
     }
     $this->_fp = @fsockopen(($this->_protocol == 'https' ? 'ssl://' : '') . $this->_host, $this->_port, $errno, $errstr);
     if ($this->_fp === false) {
         return false;
     }
     if ($this->_method == 'post') {
         $req = 'POST ' . $this->_uri . ' HTTP/1.1' . $crlf . 'Host: ' . $this->_host . $crlf . 'Referer: ' . $referer . $crlf . $contentType . 'Content-length: ' . strlen($data) . $crlf . 'Connection: close' . $crlf . $crlf . $data;
     } elseif ($this->_method == 'get') {
         $req = 'GET ' . $this->_uri . $this->_query . ' HTTP/1.1' . $crlf . 'Host: ' . $this->_host . $crlf . 'Connection: close' . $crlf . $crlf;
         @fwrite($this->_fp, $req);
     }
     while (is_resource($this->_fp) && $this->_fp && !feof($this->_fp)) {
         $response .= fread($this->_fp, 1024);
     }
     @fclose($this->_fp);
     $pos = @strpos($response, $crlf . $crlf);
     if ($pos === false) {
         return $response;
     }
     $header = substr($response, 0, $pos);
     $body = substr($response, $pos + 2 * strlen($crlf));
     $headers = array();
     $lines = explode($crlf, $header);
     foreach ($lines as $line) {
         if (($pos = strpos($line, ':')) !== false) {
             $headers[strtolower(trim(substr($line, 0, $pos)))] = trim(substr($line, $pos + 1));
         }
     }
     /* Modify a bit for sample data extension installing */
     if (isset($headers['location']) && $this->_nofollow !== true) {
         $http = new JSNHTTPSocket($headers['location'], $this->_data, $this->_referer, $this->_method);
         return $http->socketDownload();
     } else {
         return $body;
     }
 }