Exemplo n.º 1
0
 function installphpexcell()
 {
     require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'loader.php';
     $data = OPCloader::fetchUrl('http://www.rupostel.com/gpl/phpexcell.zip');
     if (!empty($data)) {
         $zip = JPATH_ROOT . DS . 'libraries' . DS . 'PHPExcel' . DS . 'phpexcel.zip';
         $dest = JPATH_ROOT . DS . 'libraries' . DS . 'PHPExcel';
         jimport('joomla.filesystem.file');
         jimport('joomla.filesystem.folder');
         jimport('joomla.filesystem.archive');
         jimport('joomla.archive.archive');
         if (JFolder::create($dest) !== false) {
             if (JFile::write($zip, $data) !== false) {
                 if (JArchive::extract($zip, $dest . DS) !== false) {
                     $msg = JText::_('COM_ONEPAGE_OK');
                 }
             }
         }
     }
     if (empty($msg)) {
         $msg = 'Error';
     }
     $data = JRequest::get('post');
     if (isset($data['limitstart'])) {
         $limitstart = $data['limitstart'];
     } else {
         $limitstart = JRequest::getVar('limitstart', 0, '', 'int');
     }
     $mainframe = JFactory::getApplication();
     if (isset($data['limit'])) {
         $limit = $data['limit'];
     }
     if (empty($limit)) {
         $limit = $mainframe->getUserStateFromRequest("{$option}.limit", 'limit', 50, 'int');
     }
     $link = 'index.php?option=com_onepage&view=orders&limitstart=' . $limitstart . '&limit=' . $limit;
     $this->setRedirect($link, $msg);
 }
Exemplo n.º 2
0
 /**
  * Creates HTTP request and returns response body
  * 
  * @param string $url URL
  * @return string Response body
  */
 private function sendRequest($url)
 {
     if (!function_exists('fsockopen')) {
         if (class_exists('OPCloader')) {
             return OPCloader::fetchUrl($url);
         }
         return false;
     }
     $parsed = parse_url($url);
     $fp = fsockopen($parsed['host'], 80, $errno, $errstr, 5);
     if (!$fp) {
         //throw new OPCHeurekaOverenoException($errstr . ' (' . $errno . ')');
         return false;
     } else {
         $return = '';
         $out = "GET " . $parsed['path'] . "?" . $parsed['query'] . " HTTP/1.1\r\n" . "Host: " . $parsed['host'] . "\r\n" . "Connection: Close\r\n\r\n";
         //stAn - protect agains slow server:
         $start = microtime(true);
         fputs($fp, $out);
         while (!feof($fp)) {
             $return .= fgets($fp, 128);
             $now = microtime(true);
             if ($now - $start > 10) {
                 break;
             }
         }
         fclose($fp);
         $returnParsed = explode("\r\n\r\n", $return);
         return empty($returnParsed[1]) ? '' : trim($returnParsed[1]);
     }
 }
Exemplo n.º 3
0
            $now = time();
            if ($now - $time > 24 * 60 * 60) {
                $refresh = true;
            }
        } else {
            $refresh = true;
        }
    } else {
        $refresh = true;
    }
} else {
    $refresh = true;
}
if (!empty($refresh) || empty($json)) {
    $url = 'http://partner.pickpackpont.hu/stores/validboltlista.xml';
    $data = OPCloader::fetchUrl($url);
    $json = simplexml_load_string($data);
    if (!empty($json)) {
        $json->OPCtime = time();
        foreach ($json as $key => $val) {
            if (empty($json->{$key})) {
                $json->{$key} = '';
            }
        }
        $json_data = json_encode($json);
        JFile::write($file, $json_data);
        $xmlfile = JPATH_CACHE . DS . 'validboltlista.xml';
        $_SESSION['vm_ppp_xml'] = $xmlfile;
        JFile::write($xmlfile, $data);
    }
}
Exemplo n.º 4
0
 function xmlexportData()
 {
     $entity = JRequest::getVar('entity', '');
     $ref_id = JRequest::getVar('asset', 'virtuemart_category_id');
     jimport('joomla.filesystem.file');
     jimport('joomla.filesystem.folder');
     $entity = JFile::makeSafe($entity);
     $cache_dir = JPATH_CACHE . DS . 'com_onepage' . DS;
     $cache_file = $cache_dir . 'xmlcache_' . $entity . '.php';
     if (!file_exists($cache_dir)) {
         JFolder::create($cache_dir);
     }
     if (file_exists($cache_file)) {
         include $cache_file;
         if (isset($return)) {
             return $return;
         }
     }
     require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'controllers' . DS . 'xmlexport.php';
     $xc = new VirtueMartControllerXmlexport();
     $class = $xc->createXml($entity);
     if (empty($class)) {
         return;
     }
     if (method_exists($class, 'getPairingUrl')) {
         $url = $class->getPairingUrl();
     } else {
         if (isset($class->xml->category_pairing_url)) {
             $url = (string) $class->xml->category_pairing_url;
         } else {
             return;
         }
     }
     if (method_exists($class, 'getPairingName')) {
         $name = $class->getPairingName();
     } else {
         if (isset($class->xml->category_pairing_name)) {
             $name = (string) $class->xml->category_pairing_name;
         } else {
             $name = $entity;
         }
     }
     require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'loader.php';
     $res = OPCloader::fetchUrl($url);
     if (empty($res)) {
         return;
     }
     $converted = array();
     if (method_exists($class, 'processPairingData')) {
         $data = $class->processPairingData($res, $converted);
     } else {
         return;
     }
     if (empty($converted)) {
         foreach ($data->children as $topcat) {
             $converted[$topcat->id] = $topcat->txt;
             if (!empty($topcat->children)) {
                 $this->recurseCat($topcat->children, $converted[$topcat->id], $converted);
             }
         }
     }
     $data = '<?php defined( \'_JEXEC\' ) or die( \'Restricted access\' );' . "\n";
     $data .= ' $return = ' . var_export($converted, true);
     $data .= '; ' . "\n";
     JFile::write($cache_file, $data);
     return $converted;
 }