/**
  * Get the Post Data.
  *
  * @return array
  */
 protected function getPostDatas()
 {
     $rRawPost = Stream::getInput();
     $aRawPost = explode('&', $rRawPost);
     $aPostData = array();
     foreach ($aRawPost as $sKeyVal) {
         $aKeyVal = explode('=', $sKeyVal);
         if (count($aKeyVal) == 2) {
             $aPostData[$aKeyVal[0]] = Url::encode($aKeyVal[1]);
         }
         unset($aKeyVal);
     }
     unset($aRawPost);
     return $aPostData;
 }
 public function parseJs($sContent)
 {
     if ($this->_bJavaCompiler) {
         file_put_contents($this->_sTmpFilePath, $sContent);
         $sJsMinified = exec("java -jar {$this->_sYuiCompressorPath} {$this->_sTmpFilePath} --type js --charset utf-8");
         unlink($this->_sTmpFilePath);
     } else {
         // If we can open connection to Google Closure
         // Google Closure has a max limit of 200KB POST size, and will break JS with eval-command
         // URL-encoded file contents
         $sContentEncoded = \PH7\Framework\Url\Url::encode($sContent);
         // Closure Host
         $sHost = 'closure-compiler.appspot.com';
         if (strlen($sContentEncoded) < 200000 && preg_match('/[^a-z]eval\\(/ism', $sContent) == 0 && ($rSocket = @pfsockopen($sHost, 80))) {
             // Working vars
             $sJsMinified = '';
             $sServiceUri = '/compile';
             $sVars = 'js_code=' . $sContentEncoded . '&compilation_level=SIMPLE_OPTIMIZATIONS&output_format=text&output_info=compiled_code';
             // Compose HTTP request header
             $sHeader = "Host: {$sHost}\r\n";
             $sHeader .= "User-Agent: PHP Script\r\n";
             $sHeader .= "Content-Type: application/x-www-form-urlencoded\r\n";
             $sHeader .= "Content-Length: " . strlen($sVars) . "\r\n";
             $sHeader .= "Connection: close\r\n\r\n";
             fputs($rSocket, "POST {$sServiceUri}  HTTP/1.0\r\n");
             fputs($rSocket, $sHeader . $sVars);
             while (!feof($rSocket)) {
                 $sJsMinified .= fgets($rSocket);
             }
             fclose($rSocket);
             $sJsMinified = preg_replace('/^HTTP.+[\\r\\n]{2}/ims', '', $sJsMinified);
         } else {
             // remove comments
             //$sContent = preg_replace("/((?:\/\*(?:[^*]|(?:\*+[^*\/]))*\*+\/)|(?:\/\/.*))/", "", $sContent);
             // remove tabs, spaces, etc. */
             $sContent = str_replace(array("\r", "\t", '  ', '    ', '     '), '', $sContent);
             // remove other spaces before/after ) */
             $sContent = preg_replace(array('(( )+\\))', '(\\)( )+)'), ')', $sContent);
             /**
              * Inclusion of JSMin
              */
             $sJsMinified = Minify\Js::minify($sContent);
         }
     }
     return $sJsMinified;
 }
Beispiel #3
0
 /**
  * Create a link of to display a popup confirmation for an action CRUD (http://en.wikipedia.org/wiki/Create,_read,_update_and_delete).
  *
  * @param string $sLabel
  * @param string $sMod
  * @param string $sCtrl
  * @param string $sAct
  * @param mixed (integer | string) $mId
  * @param string $sClass Add a CSS class. Default NULL
  */
 public function popupLinkConfirm($sLabel, $sMod, $sCtrl, $sAct, $mId, $sClass = null)
 {
     $sClass = !empty($sClass) ? ' class="' . $sClass . '" ' : ' ';
     $aHttpParams = ['label' => Url::encode($sLabel), 'mod' => $sMod, 'ctrl' => $sCtrl, 'act' => $sAct, 'id' => Url::encode($mId)];
     echo '<a', $sClass, 'href="', PH7_URL_ROOT, 'asset/ajax/popup/confirm/?', Url::httpBuildQuery($aHttpParams), '" data-popup="classic">', $sLabel, '</a>';
 }
 /**
  * Get the URL of QR Code.
  *
  * @param integer $iSize Default 150
  * @param character $cECLevel Default L
  * @param integer $iMargin Default 1
  * @return string The API URL configure.
  */
 public function get($iSize = 150, $cECLevel = 'L', $iMargin = 1)
 {
     $this->_sData = Url::encode($this->_sData);
     return static::API_URL . $iSize . 'x' . $iSize . '&cht=qr&chld=' . $cECLevel . '|' . $iMargin . '&chl=' . $this->_sData;
 }
Beispiel #5
0
 /**
  * Get information on the software license.
  *
  * @access private
  * @return mixed (array | boolean) Returns license information in an array or FALSE if an error occurred.
  */
 private function _getLicInfo()
 {
     $oCache = (new Cache())->start('str/core', 'license', 3600 * 192);
     // Stored for 8 days
     if (!($mData = $oCache->get())) {
         $sFields = 'siteid=' . Url::encode($this->_sHostName) . '&hostip=' . Url::encode($this->_sHostIp);
         $rCh = curl_init();
         curl_setopt($rCh, CURLOPT_URL, self::CHECK_LICENSE_URL);
         curl_setopt($rCh, CURLOPT_POST, 1);
         curl_setopt($rCh, CURLOPT_POSTFIELDS, $sFields);
         curl_setopt($rCh, CURLOPT_RETURNTRANSFER, 1);
         curl_setopt($rCh, CURLOPT_FRESH_CONNECT, 1);
         $mResult = curl_exec($rCh);
         curl_close($rCh);
         unset($rCh);
         $oDom = new \DOMDocument();
         if (@(!$oDom->loadXML($mResult))) {
             return false;
         }
         foreach ($oDom->getElementsByTagName('license') as $oLic) {
             $sKey = $oLic->getElementsByTagName('key')->item(0)->nodeValue;
             $sKey2 = $oLic->getElementsByTagName('key2')->item(0)->nodeValue;
             $sCopyrightKey = $oLic->getElementsByTagName('copyright-key')->item(0)->nodeValue;
             $sMsg = $oLic->getElementsByTagName('message')->item(0)->nodeValue;
             $iExpire = $oLic->getElementsByTagName('expire')->item(0)->nodeValue;
             $iValid = $oLic->getElementsByTagName('status')->item(0)->nodeValue;
         }
         unset($oDom, $oLic);
         $mData = array('key' => $sKey, 'key2' => $sKey2, 'copyright_key' => $sCopyrightKey, 'message' => $sMsg, 'expire' => $iExpire, 'status' => $iValid);
         $oCache->put($mData);
     }
     unset($oCache);
     return $mData;
 }