コード例 #1
0
 function get($oid)
 {
     $oidroot = $this->oidRoot();
     $oidroot = $oidroot[0];
     switch (preg_replace('/\\.0$/', '', $oid)) {
         case $oidroot . '1.1':
             if (in_array('ezfind', eZExtension::activeExtensions())) {
                 $ini = eZINI::instance('solr.ini');
                 $data = eZHTTPTool::getDataByURL($ini->variable('SolrBase', 'SearchServerURI') . "/admin/ping", false);
                 if (stripos($data, '<str name="status">OK</str>') !== false) {
                     $status = 1;
                 } else {
                     $status = 0;
                 }
             } else {
                 $status = -1;
             }
             return array('oid' => $oid, 'type' => eZSNMPd::TYPE_INTEGER, 'value' => $status);
         case $oidroot . '1.2':
             if (in_array('ezfind', eZExtension::activeExtensions())) {
                 $ini = eZINI::instance('solr.ini');
                 $data = eZHTTPTool::getDataByURL($ini->variable('SolrBase', 'SearchServerURI') . "/admin/stats.jsp", false);
                 if (preg_match('#<stat +name="numDocs" +>[ \\t\\r\\n]*(\\d+)[ \\t\\r\\n]*</stat>#', $data, $status)) {
                     $status = $status[1];
                 } else {
                     $status = -2;
                 }
             } else {
                 $status = -1;
             }
             return array('oid' => $oid, 'type' => eZSNMPd::TYPE_INTEGER, 'value' => $status);
     }
     return self::NO_SUCH_OID;
 }
コード例 #2
0
 static function gather()
 {
     $contentTypes = array('Objects (including users)' => array('table' => 'ezcontentobject'), 'Users' => array('table' => 'ezuser'), 'Nodes' => array('table' => 'ezcontentobject_tree'), 'Content Classes' => array('table' => 'ezcontentclass'), 'Information Collections' => array('table' => 'ezinfocollection'), 'Pending notification events' => array('table' => 'eznotificationevent', 'wherecondition' => 'status = 0'), 'Objects pending indexation' => array('table' => 'ezpending_actions', 'wherecondition' => "action = 'index_object'"), 'Binary files (content)' => array('table' => 'ezbinaryfile'), 'Image files (content)' => array('table' => 'ezimagefile'), 'Media files (content)' => array('table' => 'ezmedia'), 'Maximum children per node' => array('sql' => 'SELECT MAX(tot) AS NUM FROM ( SELECT count(*) AS tot FROM ezcontentobject_tree GROUP BY parent_node_id ) nodes'), 'Maximum nodes per object' => array('sql' => 'SELECT MAX(tot) AS NUM FROM ( SELECT count(*) AS tot FROM ezcontentobject_tree GROUP BY contentobject_id ) nodes'), 'Maximum incoming relations to an object' => array('sql' => 'SELECT MAX(tot) AS NUM FROM ( SELECT count(*) AS tot FROM ezcontentobject_link GROUP BY to_contentobject_id ) links', 'nvl' => 0), 'Maximum outgoing relations from an object' => array('sql' => 'SELECT MAX(tot) AS NUM FROM ( SELECT count(*) AS tot FROM ezcontentobject_link GROUP BY from_contentobject_id ) links', 'nvl' => 0));
     $db = eZDB::instance();
     $contentList = array();
     foreach ($contentTypes as $key => $desc) {
         if (isset($desc['table'])) {
             $sql = 'SELECT COUNT(*) AS NUM FROM ' . $desc['table'];
             if (@$desc['wherecondition']) {
                 $sql .= ' WHERE ' . $desc['wherecondition'];
             }
         } else {
             $sql = $desc['sql'];
         }
         $count = $db->arrayQuery($sql);
         $contentList[$key] = $count[0]['NUM'] === null ? $desc['nvl'] : $count[0]['NUM'];
     }
     if (in_array('ezfind', eZExtension::activeExtensions())) {
         $ini = eZINI::instance('solr.ini');
         $ezfindpingurl = $ini->variable('SolrBase', 'SearchServerURI') . "/admin/stats.jsp";
         $data = eZHTTPTool::getDataByURL($ezfindpingurl, false);
         //var_dump( $data );
         if (preg_match('#<stat +name="numDocs" ?>([^<]+)</stat>#', $data, $matches)) {
             $contentList['Documents in SOLR'] = trim($matches[1]);
         } else {
             $contentList['Documents in SOLR'] = 'Unknown';
         }
     }
     return $contentList;
 }
    /**
     * @return string
     */
    protected function acquireToken()
    {
        $response = eZHTTPTool::getDataByURL($this->tokenAcquireApiUrl);
        $xml = simplexml_load_string($response);

        return (string)$xml->data->string;
    }
コード例 #4
0
 public function getMediaRecent($pageID = false, $limit = 20)
 {
     $result = array('result' => array());
     $accumulator = $this->debugAccumulatorGroup . '_instagram_media_recent';
     eZDebug::accumulatorStart($accumulator, $this->debugAccumulatorGroup, 'media_recent');
     $cacheFileHandler = $this->getCacheFileHandler('_media_recent', array($pageID, $limit));
     try {
         if ($this->isCacheExpired($cacheFileHandler)) {
             eZDebug::writeDebug(array('page_id' => $pageID, 'limit' => $limit), self::$debugMessagesGroup);
             $items = array();
             $userData = eZHTTPTool::getDataByURL('https://api.instagram.com/v1/users/search?' . 'q=' . $pageID . '&' . 'client_id=' . $this->API['key']);
             $userID = false;
             if ($userData !== false) {
                 $userDataArray = json_decode($userData, true);
                 if (count($userDataArray['data'])) {
                     foreach ($userDataArray['data'] as $user) {
                         if ($user['username'] == $pageID) {
                             $userID = $user['id'];
                             break;
                         }
                     }
                 }
             }
             if ($userID !== false) {
                 $leftLimit = $limit;
                 $feedData = eZHTTPTool::getDataByURL('https://api.instagram.com/v1/users/' . $userID . '/media/recent/?' . 'access_token=' . $this->API['token']);
                 if ($feedData !== false) {
                     $feedDataArray = json_decode($feedData, true);
                     if (isset($feedDataArray['data'])) {
                         $items = array_merge($items, array_slice($feedDataArray['data'], 0, $leftLimit));
                         $leftLimit = $leftLimit - count($feedDataArray['data']);
                     }
                     $endlessLoopBreaker = 0;
                     while ($endlessLoopBreaker < 50 && $leftLimit > 0 && isset($feedDataArray['pagination']['next_url'])) {
                         $endlessLoopBreaker++;
                         $feedData = eZHTTPTool::getDataByURL($feedDataArray['pagination']['next_url']);
                         if ($feedData !== false) {
                             $feedDataArray = json_decode($feedData, true);
                             $items = array_merge($items, array_slice($feedDataArray['data'], 0, $leftLimit));
                         }
                         $leftLimit = $leftLimit - count($feedDataArray['data']);
                     }
                 }
             }
             $cacheFileHandler->fileStoreContents($cacheFileHandler->filePath, serialize($items));
         } else {
             $items = unserialize($cacheFileHandler->fetchContents());
         }
         eZDebug::accumulatorStop($accumulator);
         $result['result'] = $items;
         return $result;
     } catch (Exception $e) {
         eZDebug::accumulatorStop($accumulator);
         eZDebug::writeError($e->getMessage(), self::$debugMessagesGroup);
         return $result;
     }
 }
コード例 #5
0
 public static function getDataByURL($url, array $aCurlParams = array(), $justCheckURL = false, $userAgent = false)
 {
     if (in_array(CURLOPT_RETURNTRANSFER, $aCurlParams) && isset($aCurlParams[CURLOPT_RETURNTRANSFER]) && !$aCurlParams[CURLOPT_RETURNTRANSFER]) {
         $justCheckURL = true;
     } else {
         $aCurlParams[CURLOPT_RETURNTRANSFER] = true;
     }
     if (!extension_loaded('curl') || !count($aCurlParams)) {
         return eZHTTPTool::getDataByURL($url, $justCheckURL, $userAgent);
     }
     $ch = curl_init($url);
     if ($justCheckURL) {
         curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
         curl_setopt($ch, CURLOPT_TIMEOUT, 15);
         curl_setopt($ch, CURLOPT_FAILONERROR, 1);
         curl_setopt($ch, CURLOPT_NOBODY, 1);
     }
     if ($userAgent) {
         curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
     }
     $ini = eZINI::instance();
     $proxy = $ini->hasVariable('ProxySettings', 'ProxyServer') ? $ini->variable('ProxySettings', 'ProxyServer') : false;
     // If we should use proxy
     if ($proxy) {
         curl_setopt($ch, CURLOPT_PROXY, $proxy);
         $userName = $ini->hasVariable('ProxySettings', 'User') ? $ini->variable('ProxySettings', 'User') : false;
         $password = $ini->hasVariable('ProxySettings', 'Password') ? $ini->variable('ProxySettings', 'Password') : false;
         if ($userName) {
             curl_setopt($ch, CURLOPT_PROXYUSERPWD, "{$userName}:{$password}");
         }
     }
     foreach ($aCurlParams as $iCurlOption => $mCurlParam) {
         curl_setopt($ch, $iCurlOption, $mCurlParam);
     }
     // If we should check url without downloading data from it.
     if ($justCheckURL) {
         if (!curl_exec($ch)) {
             curl_close($ch);
             return false;
         }
         curl_close($ch);
         return true;
     }
     // Getting data
     // ob_start();
     $data = curl_exec($ch);
     $responseCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
     if ($responseCode != 200 || !$data) {
         curl_close($ch);
         //   ob_end_clean();
         return false;
     }
     curl_close($ch);
     // $data = ob_get_contents();
     // ob_end_clean();
     return $data;
 }
コード例 #6
0
 /**
  * @dataProvider providerTestGetDataByURL
  */
 public function testGetDataByURL($expectedDataResult, $url, $justCheckURL = false, $userAgent = false)
 {
     $this->assertEquals(eZHTTPTool::getDataByURL($url, $justCheckURL, $userAgent), $expectedDataResult);
     // There's no way to test the whole method without refactoring it.
     if (extension_loaded('curl')) {
         $this->markTestIncomplete('cURL behaviour tested, not fopen()');
     } else {
         $this->markTestIncomplete('fopen() behaviour tested, not cURL');
     }
 }
コード例 #7
0
 /**
  * (non-PHPdoc)
  * @see extension/sqliimport/classes/sourcehandlers/ISQLIImportHandler::initialize()
  */
 public function initialize()
 {
     $xmlUrl = $this->handlerConfArray['XMLStream'];
     $xmlString = eZHTTPTool::getDataByURL($xmlUrl);
     $xmlOptions = new SQLIXMLOptions(array('xml_string' => $xmlString, 'xml_parser' => 'simplexml'));
     $xmlParser = new SQLIXMLParser($xmlOptions);
     // On recherche tous les products dans la catégorie HardRock/Metal (HAR)
     $fullXML = $xmlParser->parse();
     $fullXML->registerXPathNamespace('x', $this->handlerConfArray['XMLNS']);
     $XPath = "//x:product[contains(./x:merchantCategory, '" . $this->handlerConfArray['MerchantCategory'] . "')]";
     $this->dataSource = $fullXML->xpath($XPath);
 }
コード例 #8
0
ファイル: php_version.php プロジェクト: gggeek/ggsysinfo
 function _retrieveCurrentValue()
 {
     $this->current_value = PHP_VERSION;
     $url = 'http://php.net/releases/?serialize=1&version=5';
     try {
         $latestVersion = eZHTTPTool::getDataByURL($url);
         $versionInfo = unserialize($latestVersion);
         $this->recommended_value = $versionInfo['version'];
     } catch (Exception $e) {
         $this->recommended_value = '';
     }
 }
コード例 #9
0
 /**
  * @param int $repositoryID
  *
  * @return OCRepositoryClientInterface|OCClassSearchTemplate
  * @throws Exception
  */
 public static function instanceRepository($repositoryID)
 {
     $definition = self::isAvailableRepository($repositoryID);
     if (!$definition) {
         throw new Exception("Non trovo il repository {$repositoryID}");
     }
     $serverInfoUrl = rtrim($definition['Url'], '/') . self::SERVER_BASE_PATH . $repositoryID;
     $definition['ServerBaseUrl'] = $serverInfoUrl;
     $definition['ClientBasePath'] = self::CLIENT_BASE_PATH . $repositoryID;
     if (!eZHTTPTool::getDataByURL($serverInfoUrl, true)) {
         throw new Exception("Repository {$repositoryID} ({$serverInfoUrl}) non raggiungibile");
     }
     $serverInfo = json_decode(eZHTTPTool::getDataByURL($serverInfoUrl), true);
     if (!$serverInfo) {
         throw new Exception("Il repository {$repositoryID} non ha risposto correttamente alla richiesta di informazioni");
     }
     if (isset($serverInfo['error'])) {
         throw new Exception("Errore del server remoto: \" {$serverInfo['error']} \" ");
     }
     if ($serverInfo['type']) {
         if (isset($definition['Handler'])) {
             $clientHandlerName = $definition['Handler'];
         } else {
             $clientHandlerName = 'OCRepository' . $serverInfo['type'] . 'Client';
         }
         if (class_exists($clientHandlerName)) {
             $clientHandler = new $clientHandlerName();
             if (!$clientHandler instanceof OCRepositoryClientInterface) {
                 throw new Exception("La libreria {$clientHandlerName} non estende l'interfaccia corretta");
             }
             $parameters = array();
             if ($serverInfo['parameters']) {
                 $parameters = $serverInfo['parameters'];
             }
             $parameters['definition'] = $definition;
             $clientHandler->init($parameters);
             return $clientHandler;
         }
     }
     throw new Exception("Errore");
 }
 protected static function gmapStaticImageGetData($args)
 {
     extract($args);
     $markers = array();
     $query = array();
     foreach ($parameters as $key => $value) {
         if (is_array($value)) {
             foreach ($value as $markerProperties) {
                 $latLngArray = array();
                 $markerQuery = array();
                 $markerPositions = array();
                 foreach ($markerProperties as $markerPropertyKey => $markerPropertyValue) {
                     if ($markerPropertyKey == '_positions') {
                         foreach ($markerPropertyValue as $position) {
                             if ($position['lat'] > 0 && $position['lng'] > 0) {
                                 $markerPositions[] = "{$position['lat']},{$position['lng']}";
                             }
                         }
                     } else {
                         $markerQuery[] = "{$markerPropertyKey}:{$markerPropertyValue}";
                     }
                 }
                 if (empty($markerPositions)) {
                     throw new Exception("Positions not found in parameters " . var_export($parameters, 1));
                 } else {
                     //markers=color:blue|46.067618,11.117315
                     $query[] = "markers=" . implode('|', $markerQuery) . '|' . implode('|', $markerPositions);
                 }
             }
         } else {
             //zoom=13 size=600x300 maptype=roadmap
             $query[] = "{$key}={$value}";
         }
     }
     $stringQuery = implode('&', $query);
     $baseUrl = 'http://maps.googleapis.com/maps/api/staticmap';
     $url = "{$baseUrl}?{$stringQuery}";
     $data = eZHTTPTool::getDataByURL($url);
     eZDebug::writeNotice("Generate static map for attribute {$attribute->attribute('id')}: {$url}", __METHOD__);
     return 'data:image/PNG;base64,' . base64_encode($data);
 }
コード例 #11
0
/**
 * Submits an HTTP POST to a reCAPTCHA server
 * @param string $host
 * @param string $path
 * @param array $data
 * @param int port
 * @return array response
 */
function _recaptcha_http_post($host, $path, $data, $port = 80)
{
    $req = _recaptcha_qsencode($data);
    $response = eZHTTPTool::getDataByURL($host . $path . '?' . $req, false, 'reCAPTCHA/PHP');
    return $response;
}
コード例 #12
0
 static function getRSSVersion($url)
 {
     $xmlData = eZHTTPTool::getDataByURL($url);
     if ($xmlData === false) {
         return false;
     }
     // Create DomDocument from http data
     $domDocument = new DOMDocument('1.0', 'utf-8');
     $success = $domDocument->loadXML($xmlData);
     if (!$success) {
         return false;
     }
     $root = $domDocument->documentElement;
     switch ($root->getAttribute('version')) {
         default:
         case '1.0':
             return '1.0';
             break;
         case '0.91':
         case '0.92':
         case '2.0':
             return $root->getAttribute('version');
             break;
     }
 }
コード例 #13
0
 $deleteParams = array();
 $markInvalidParams = array();
 $fileContentCache = array();
 $rows = $db->arrayQuery("SELECT DISTINCT param FROM ezpending_actions WHERE action = 'static_store'", array('limit' => $limit, 'offset' => $offset));
 if (!$rows || empty($rows)) {
     break;
 }
 foreach ($rows as $row) {
     $param = $row['param'];
     $paramList = explode(',', $param);
     $source = $paramList[1];
     $destination = $paramList[0];
     $invalid = isset($paramList[2]) ? $paramList[2] : null;
     if (!isset($fileContentCache[$source])) {
         $cli->output("Fetching URL: {$source}");
         $fileContentCache[$source] = eZHTTPTool::getDataByURL($source, false, eZStaticCache::USER_AGENT);
     }
     if ($fileContentCache[$source] === false) {
         $cli->error("Could not grab content from \"{$source}\", is the hostname correct and Apache running?");
         if ($invalid !== null) {
             $deleteParams[] = $param;
             continue;
         }
         $markInvalidParams[] = $param;
     } else {
         eZStaticCache::storeCachedFile($destination, $fileContentCache[$source]);
         $deleteParams[] = $param;
     }
 }
 if (!empty($markInvalidParams)) {
     $db->begin();
コード例 #14
0
    /**
     * This function goes over the list of recorded actions and excecutes them.
     */
    static function executeActions()
    {
        if ( empty( self::$actionList ) )
        {
            return;
        }

        $fileContentCache = array();
        $doneDestList = array();

        $ini = eZINI::instance( 'staticcache.ini');
        $clearByCronjob = ( $ini->variable( 'CacheSettings', 'CronjobCacheClear' ) == 'enabled' );

        if ( $clearByCronjob )
        {
            $db = eZDB::instance();
        }

        foreach ( self::$actionList as $action )
        {
            list( $action, $parameters ) = $action;

            switch( $action ) {
                case 'store':
                    list( $destination, $source ) = $parameters;

                    if ( isset( $doneDestList[$destination] ) )
                        continue 2;

                    if ( $clearByCronjob )
                    {
                        $param = $db->escapeString( $destination . ',' . $source );
                        $db->query( 'INSERT INTO ezpending_actions( action, param ) VALUES ( \'static_store\', \''. $param . '\' )' );
                        $doneDestList[$destination] = 1;
                    }
                    else
                    {
                        if ( !isset( $fileContentCache[$source] ) )
                        {
                            if ( eZHTTPTool::getDataByURL( $source, true, eZStaticCache::USER_AGENT ) )
                                $fileContentCache[$source] = eZHTTPTool::getDataByURL( $source, false, eZStaticCache::USER_AGENT );
                            else
                                $fileContentCache[$source] = false;
                        }
                        if ( $fileContentCache[$source] === false )
                        {
                            eZDebug::writeError( "Could not grab content (from $source), is the hostname correct and Apache running?", 'Static Cache' );
                        }
                        else
                        {
                            eZStaticCache::storeCachedFile( $destination, $fileContentCache[$source] );
                            $doneDestList[$destination] = 1;
                        }
                    }
                    break;
            }
        }
        self::$actionList = array();
    }
コード例 #15
0
            foreach ($xmlData as $doc) {
                if (is_object($doc)) {
                    if (is_object($doc->Doc)) {
                        $doc->Doc->formatOutput = true;
                        $xml[] = $doc->Doc->saveXML($doc->RootElement);
                    } else {
                        $dom = new DOMDocument();
                        $dom->preserveWhiteSpace = FALSE;
                        $dom->loadXML($doc->docToXML());
                        $dom->formatOutput = TRUE;
                        $xml[] = $dom->saveXML($dom->documentElement);
                    }
                }
            }
            $solrBase = new eZSolrBase();
            $version = json_decode(eZHTTPTool::getDataByURL($solrBase->SearchServerURI . '/admin/system/?wt=json'), true);
            $solr = array('ping' => trim(print_r($solrBase->ping(), 1)), 'version' => trim(print_r($version, 1)));
        } else {
            $error = "Current user can not read object {$objectID}";
        }
    } else {
        $error = "Object {$objectID} not found";
    }
}
$tpl->setVariable('error', $error);
$tpl->setVariable('info', $info);
$tpl->setVariable('detail', $detail);
$tpl->setVariable('xml', $xml);
$tpl->setVariable('solr', $solr);
echo $tpl->fetch('design:index/object.tpl');
eZDisplayDebug();
コード例 #16
0
 /**
  * Executes the PHP function for the operator cleanup and modifies $operatorValue.
  * 
  * @param eZTemplate $tpl
  * @param string $operatorName
  * @param array $operatorParameters
  * @param string $rootNamespace
  * @param string $currentNamespace
  * @param mixed $operatorValue
  * @param array $namedParameters
  */
 public function modify($tpl, $operatorName, $operatorParameters, $rootNamespace, $currentNamespace, &$operatorValue, $namedParameters)
 {
     switch ($operatorName) {
         case 'feedreader':
             $source = isset($namedParameters['source']) ? $namedParameters['source'] : '';
             $limit = isset($namedParameters['limit']) ? $namedParameters['limit'] : 0;
             $offset = isset($namedParameters['offset']) ? $namedParameters['offset'] : 0;
             $res = array();
             $sourceXML = eZHTTPTool::getDataByURL($namedParameters['source']);
             try {
                 $feed = ezcFeed::parseContent($sourceXML);
             } catch (Exception $e) {
                 $res['error'] = $e->getMessage();
                 $operatorValue = $res;
                 return;
             }
             $res['title'] = isset($feed->title) ? $feed->title->__toString() : null;
             $res['links'] = self::buildLinksArray(isset($feed->link) ? $feed->link : array());
             $items = isset($feed->item) ? $feed->item : array();
             $counter = 0;
             foreach ($items as $item) {
                 $counter++;
                 if ($counter <= $offset) {
                     continue;
                 }
                 $title = isset($item->title) ? $item->title->__toString() : null;
                 $description = isset($item->description) ? $item->description->__toString() : null;
                 $content = isset($item->content) ? $item->content->__toString() : null;
                 $published = isset($item->published) ? $item->published->date->format('U') : null;
                 $links = self::buildLinksArray(isset($item->link) ? $item->link : array());
                 $res['items'][] = array('title' => $title, 'links' => $links, 'description' => $description, 'content' => $content, 'published' => $published);
                 if ($counter == $limit + $offset) {
                     break;
                 }
             }
             $operatorValue = $res;
             break;
     }
 }
コード例 #17
0
             $dnsCheck = checkdnsrr($host, "MX");
             if (!$dnsCheck) {
                 if ($isValid) {
                     eZURL::setIsValid($linkID, false);
                 }
                 $cli->output($cli->stylize('warning', "invalid"));
             } else {
                 if (!$isValid) {
                     eZURL::setIsValid($linkID, true);
                 }
                 $cli->output($cli->stylize('success', "valid"));
             }
         }
     } else {
         if (preg_match("/^(http:)/i", $url) or preg_match("/^(file:)/i", $url) or preg_match("/^(ftp:)/i", $url)) {
             if (!eZHTTPTool::getDataByURL($url, true, 'eZ Publish Link Validator')) {
                 if ($isValid) {
                     eZURL::setIsValid($linkID, false);
                 }
                 $cli->output($cli->stylize('warning', "invalid"));
             } else {
                 if (!$isValid) {
                     eZURL::setIsValid($linkID, true);
                 }
                 $cli->output($cli->stylize('success', "valid"));
             }
         } else {
             $cli->output("Couldn't check https protocol");
         }
     }
 } else {
コード例 #18
0
 /**
  * @param $identifier
  *
  * @return stdClass
  * @throws Exception
  */
 protected static function fetchRemoteByIdentifier($identifier)
 {
     if (is_object(self::$remoteUrl)) {
         $original = self::$remoteUrl;
     } elseif (file_exists(self::$remoteUrl)) {
         $data = file_get_contents(self::$remoteUrl);
         $original = json_decode($data);
     } else {
         $currentUrl = eZINI::instance()->variable('SiteSettings', 'SiteURL');
         $originalRepositoryUrl = self::$remoteUrl . $identifier;
         if (stripos($originalRepositoryUrl, $currentUrl) === false) {
             $original = json_decode(eZHTTPTool::getDataByURL($originalRepositoryUrl));
         } else {
             throw new Exception("Server e client non possono coincidere");
         }
     }
     if (!is_object($original)) {
         throw new Exception("Classe remota non trovata");
     }
     if (isset($original->error)) {
         throw new Exception($original->error);
     }
     return $original;
 }
コード例 #19
0
 /**
  * @todo we should return an error if the scalar values are queried without a .0 appendeded...
  */
 function get($oid)
 {
     // warm up list of existing oids, if not yet done
     $this->oidList();
     $internaloid = preg_replace('/\\.0$/', '', $oid);
     if (array_key_exists($internaloid, self::$simplequeries)) {
         $count = -1;
         if (strpos($internaloid, '2.1.4.') === 0) {
             // session-related queries: return -1 if not using db-based storage
             $ini = eZINI::instance();
             $sessionHandler = $ini->variable('Session', 'Handler');
             if ($sessionHandler != 'ezpSessionHandlerDB') {
                 return array('oid' => $oid, 'type' => eZSNMPd::TYPE_INTEGER, 'value' => $count);
             }
         }
         if (strpos($internaloid, '2.1.6.') === 0) {
             // async-publication-related queries: return -1 if not using it
             $ini = eZINI::instance('content.ini');
             if ($ini->variable('PublishingSettings', 'AsynchronousPublishing') != 'enabled') {
                 return array('oid' => $oid, 'type' => eZSNMPd::TYPE_INTEGER, 'value' => $count);
             }
         }
         $db = self::eZDBinstance();
         if ($db) {
             $results = $db->arrayQuery(str_replace('/*anonymousId*/', eZUser::anonymousId(), self::$simplequeries[$internaloid]));
             $db->close();
             if (is_array($results) && count($results)) {
                 $count = $results[0]['count'];
             }
         }
         return array('oid' => $oid, 'type' => eZSNMPd::TYPE_INTEGER, 'value' => $count);
     }
     if (array_key_exists($internaloid, self::$orderstatuslist)) {
         $oids = explode('.', $internaloid);
         switch ($oids[5]) {
             case '1':
                 return array('oid' => $oid, 'type' => eZSNMPd::TYPE_INTEGER, 'value' => self::$orderstatuslist[$internaloid]);
             case '2':
                 return array('oid' => $oid, 'type' => eZSNMPd::TYPE_STRING, 'value' => self::$orderstatuslist[$internaloid]);
             case '3':
             case '4':
                 $count = -1;
                 $db = self::eZDBinstance();
                 if ($db) {
                     $status = $db->arrayQuery('select count(*) as num from ezorder where is_temporary=0 and is_archived=' . ($oids[5] + 1) % 2 . ' and status_id=' . self::$orderstatuslist[$internaloid], array('column' => 'num'));
                     $db->close();
                     if (is_array($status) && count($status)) {
                         $count = $status[0];
                     }
                 }
                 return array('oid' => $oid, 'type' => eZSNMPd::TYPE_INTEGER, 'value' => $count);
         }
     }
     if (array_key_exists($internaloid, self::$cachelist)) {
         $cacheinfo = eZCache::fetchByID(self::$cachelist[$internaloid]);
         $oids = explode('.', $internaloid);
         switch ($oids[3]) {
             case '1':
                 return array('oid' => $oid, 'type' => eZSNMPd::TYPE_STRING, 'value' => $cacheinfo['name']);
             case '2':
                 return array('oid' => $oid, 'type' => eZSNMPd::TYPE_INTEGER, 'value' => (int) $cacheinfo['enabled']);
             case '3':
             case '4':
                 $fileINI = eZINI::instance('file.ini');
                 $handlerName = $fileINI->variable('ClusteringSettings', 'FileHandler');
                 switch ($handlerName) {
                     case 'ezfs':
                     case 'eZFSFileHandler':
                     case 'eZFS2FileHandler':
                         break;
                     default:
                         // the db-based filehandlers + dfs one not yet supported
                         return array('oid' => $oid, 'type' => eZSNMPd::TYPE_INTEGER, 'value' => -1);
                 }
                 // take care: this is hardcoded from knowledge of cache structure...
                 if (strpos($cacheinfo['path'], 'var/cache/') === 0) {
                     $cachedir = $cacheinfo['path'];
                 } else {
                     $cachedir = eZSys::cacheDirectory() . '/' . $cacheinfo['path'];
                 }
                 if ($oids[3] == '3') {
                     $out = (int) eZsnmpdTools::countFilesInDir($cachedir);
                 } else {
                     $out = (int) eZsnmpdTools::countFilesSizeInDir($cachedir);
                 }
                 return array('oid' => $oid, 'type' => eZSNMPd::TYPE_INTEGER, 'value' => $out);
         }
     }
     if (array_key_exists($internaloid, self::$storagedirlist)) {
         $oids = explode('.', $internaloid);
         switch ($oids[3]) {
             case '1':
                 return array('oid' => $oid, 'type' => eZSNMPd::TYPE_STRING, 'value' => self::$storagedirlist[$internaloid]);
             case '2':
             case '3':
                 $fileINI = eZINI::instance('file.ini');
                 $handlerName = $fileINI->variable('ClusteringSettings', 'FileHandler');
                 switch ($handlerName) {
                     case 'ezfs':
                     case 'eZFSFileHandler':
                     case 'eZFS2FileHandler':
                         break;
                     default:
                         // the db-based filehandlers + dfs one not yet supported
                         return array('oid' => $oid, 'type' => eZSNMPd::TYPE_INTEGER, 'value' => -1);
                 }
                 if ($oids[3] == '2') {
                     $out = (int) eZsnmpdTools::countFilesInDir(self::$storagedirlist[$internaloid]);
                 } else {
                     $out = (int) eZsnmpdTools::countFilesSizeInDir(self::$storagedirlist[$internaloid]);
                 }
                 return array('oid' => $oid, 'type' => eZSNMPd::TYPE_INTEGER, 'value' => $out);
         }
     }
     switch ($internaloid) {
         case '2.1.1':
             // verify if db can be connected to
             $ok = 1;
             $db = self::eZDBinstance();
             if (!$db) {
                 $ok = 0;
             } else {
                 $db->close();
             }
             return array('oid' => $oid, 'type' => eZSNMPd::TYPE_INTEGER, 'value' => $ok);
             /*case '2.2.1': // cache-blocks
                             /// @todo ...
                             $handlerName = $fileINI->variable( 'ClusteringSettings', 'FileHandler' );
                             switch( $handlerName )
                             {
                                 case 'ezfs':
                                     break;
                                 case 'ezdb':
                                     break;
                                 default:
                             }
             
                         case '2.2.2': // view-cache
                             /// @todo ...
                             $handlerName = $fileINI->variable( 'ClusteringSettings', 'FileHandler' );
                             switch( $handlerName )
                             {
                                 case 'ezfs':
                                     break;
                                 case 'ezdb':
                                     break;
                                 default:
                             }*/
         /*case '2.2.1': // cache-blocks
                         /// @todo ...
                         $handlerName = $fileINI->variable( 'ClusteringSettings', 'FileHandler' );
                         switch( $handlerName )
                         {
                             case 'ezfs':
                                 break;
                             case 'ezdb':
                                 break;
                             default:
                         }
         
                     case '2.2.2': // view-cache
                         /// @todo ...
                         $handlerName = $fileINI->variable( 'ClusteringSettings', 'FileHandler' );
                         switch( $handlerName )
                         {
                             case 'ezfs':
                                 break;
                             case 'ezdb':
                                 break;
                             default:
                         }*/
         case '2.4.1':
             // ldap connection
             $ini = eZINI::instance('ldap.ini');
             if ($ini->variable('LDAPSettings', 'LDAPEnabled') == 'true' && $ini->variable('LDAPSettings', 'LDAPServer') != '') {
                 $ok = 0;
                 // code copied over from ezldapuser class...
                 $LDAPVersion = $ini->variable('LDAPSettings', 'LDAPVersion');
                 $LDAPServer = $ini->variable('LDAPSettings', 'LDAPServer');
                 $LDAPPort = $ini->variable('LDAPSettings', 'LDAPPort');
                 $LDAPBindUser = $ini->variable('LDAPSettings', 'LDAPBindUser');
                 $LDAPBindPassword = $ini->variable('LDAPSettings', 'LDAPBindPassword');
                 $ds = ldap_connect($LDAPServer, $LDAPPort);
                 if ($ds) {
                     ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, $LDAPVersion);
                     if ($LDAPBindUser == '') {
                         $r = ldap_bind($ds);
                     } else {
                         $r = ldap_bind($ds, $LDAPBindUser, $LDAPBindPassword);
                     }
                     if ($r) {
                         $ok = 1;
                     }
                     // added: release resources, be ready for next test
                     ldap_close($ds);
                 }
             } else {
                 $ok = -1;
             }
             return array('oid' => $oid, 'type' => eZSNMPd::TYPE_INTEGER, 'value' => $ok);
         case '2.4.2':
             // web connection
             $ini = eZINI::instance('snmpd.ini');
             $websites = $ini->variable('StatusHandler', 'WebBeacons');
             $ok = 0;
             if (is_string($websites)) {
                 $websites = array($websites);
             }
             foreach ($websites as $key => $site) {
                 if (trim($site) == '') {
                     unset($websites[$key]);
                 }
             }
             if (count($websites)) {
                 foreach ($websites as $site) {
                     // current eZ code is broken if no curl is installed, as it does not check for 404 or such.
                     // besides, it does not even support proxies...
                     if (extension_loaded('curl')) {
                         if (eZHTTPTool::getDataByURL($site, true)) {
                             $ok = 1;
                             break;
                         }
                     } else {
                         $data = eZHTTPTool::getDataByURL($site, false);
                         if ($data !== false && sysInfoTools::isHTTP200($data)) {
                             $ok = 1;
                             break;
                         }
                     }
                 }
             } else {
                 $ok = -1;
             }
             return array('oid' => $oid, 'type' => eZSNMPd::TYPE_INTEGER, 'value' => $ok);
         case '2.4.3':
             // email connection
             $ini = eZINI::instance('snmpd.ini');
             $recipient = $ini->variable('StatusHandler', 'MailReceiver');
             $ok = 0;
             $mail = new eZMail();
             if (trim($recipient) != '' && $mail->validate($recipient)) {
                 $mail->setReceiver($recipient);
                 $ini = eZINI::instance();
                 $sender = $ini->variable('MailSettings', 'EmailSender');
                 $mail->setSender($sender);
                 $mail->setSubject("Test email");
                 $mail->setBody("This email was automatically sent while testing eZ Publish connectivity to the mail server. Please do not reply.");
                 $mailResult = eZMailTransport::send($mail);
                 if ($mailResult) {
                     $ok = 1;
                 }
             } else {
                 $ok = -1;
             }
             return array('oid' => $oid, 'type' => eZSNMPd::TYPE_INTEGER, 'value' => $ok);
         case '2.5.1':
             $fileINI = eZINI::instance('file.ini');
             $clusterhandler = $fileINI->variable('ClusteringSettings', 'FileHandler');
             if ($clusterhandler == 'ezdb' || $clusterhandler == 'eZDBFileHandler') {
                 $ok = 0;
                 $dbFileHandler = eZClusterFileHandler::instance();
                 if ($dbFileHandler instanceof eZDBFileHandler) {
                     // warning - we dig into the private parts of the cluster file handler,
                     // as no real API are provided for it (yet)
                     if (is_resource($dbFileHandler->backend->db)) {
                         $ok = 1;
                     }
                 }
             } else {
                 if ($clusterhandler == 'eZDFSFileHandler') {
                     // This is even worse: we have no right to know if db connection is ok.
                     // So we replicate some code here...
                     $dbbackend = eZExtension::getHandlerClass(new ezpExtensionOptions(array('iniFile' => 'file.ini', 'iniSection' => 'eZDFSClusteringSettings', 'iniVariable' => 'DBBackend')));
                     try {
                         $dbbackend->_connect();
                         $ok = 1;
                     } catch (exception $e) {
                         $ok = 0;
                     }
                 } else {
                     $ok = -1;
                 }
             }
             return array('oid' => $oid, 'type' => eZSNMPd::TYPE_INTEGER, 'value' => $ok);
     }
     return self::NO_SUCH_OID;
     // oid not managed
 }
コード例 #20
0
ファイル: rssimport.php プロジェクト: nfrp/ezpublish
 *
 * @copyright Copyright (C) 1999-2013 eZ Systems AS. All rights reserved.
 * @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2
 * @version //autogentag//
 * @package kernel
 */
//For ezUser, we would make this the ezUser class id but otherwise just pick and choose.
//fetch this class
$rssImportArray = eZRSSImport::fetchActiveList();
// Loop through all configured and active rss imports. If something goes wrong while processing them, continue to next import
foreach ($rssImportArray as $rssImport) {
    // Get RSSImport object
    $rssSource = $rssImport->attribute('url');
    $addCount = 0;
    $cli->output('RSSImport ' . $rssImport->attribute('name') . ': Starting.');
    $xmlData = eZHTTPTool::getDataByURL($rssSource, false, 'eZ Publish RSS Import');
    if ($xmlData === false) {
        $cli->output('RSSImport ' . $rssImport->attribute('name') . ': Failed to open RSS feed file: ' . $rssSource);
        continue;
    }
    // Create DomDocument from http data
    $domDocument = new DOMDocument('1.0', 'utf-8');
    $success = $domDocument->loadXML($xmlData);
    if (!$success) {
        $cli->output('RSSImport ' . $rssImport->attribute('name') . ': Invalid RSS document.');
        continue;
    }
    $root = $domDocument->documentElement;
    switch ($root->getAttribute('version')) {
        default:
        case '1.0':
コード例 #21
0
    /**
     * @param string $type
     * @param string $uumpId
     * @param bool|string $email
     * @param bool|string $url
     * @throws Exception
     */
    protected function callLyris($type, $uumpId, $email = false, $url = false)
    {
        $serviceUrl = self::buildUrl($type, $uumpId, $url);

        eZLog::write("Email for URL: {$email}", 'resetpass.log');
        eZLog::write("Service URL: {$url}", 'resetpass.log');

        $response = eZHTTPTool::getDataByURL($serviceUrl);

        eZLog::write("EMAILSERVICE URL: {$serviceUrl}", 'esb_uump.log');
        eZLog::write("EMAILSERVICE RESPONSE:\n" . $response, 'esb_uump.log');
        eZLog::write("EMAILSERVICE URL: {$serviceUrl}", 'resetpass.log');
        eZLog::write("EMAILSERVICE RESPONSE:\n" . $response, 'resetpass.log');
    }
コード例 #22
0
 /**
  * @param string $action
  * @param array $parameters
  * @param bool $responseAsArray
  *
  * @return mixed
  * @throws Exception
  */
 protected function call($action, $parameters, $responseAsArray)
 {
     $serverBaseUrl = $this->attributes['definition']['ServerBaseUrl'];
     if (!eZHTTPTool::getDataByURL($serverBaseUrl, true)) {
         throw new Exception("Url {$serverBaseUrl} non raggiungibile");
     }
     $query = $this->buildQueryString($action, $parameters);
     eZDebug::writeNotice($query, __METHOD__ . ' ' . $action);
     return json_decode(eZHTTPTool::getDataByURL($serverBaseUrl . '?' . $query), $responseAsArray);
 }
コード例 #23
0
ファイル: sysinfotests.php プロジェクト: gggeek/ggsysinfo
 /**
  * @todo set up soap and webdav tests
  */
 public static function runTests()
 {
     $status_tests = array('db' => '0', 'cluster db' => '0', 'ldap server' => '0', 'web access' => '0', 'ezfind' => '0', 'mail' => '0');
     $db = eZDB::instance();
     if ($db->isConnected() === true) {
         $status_tests['db'] = '1';
     }
     $clusterDBHandler = ezSysinfoClusterManager::clusterDBHandler();
     if ($clusterDBHandler instanceof eZDBFileHandler) {
         // warning - we dig into the private parts of the cluster file handler,
         // as no real API are provided for it (yet)
         if (is_resource($clusterDBHandler->backend->db)) {
             $status_tests['cluster db'] = '1';
         }
     } else {
         if (is_object($clusterDBHandler)) {
             // This is even worse: we have no right to know if db connection is ok.
             // So we replicate some code here...
             try {
                 $clusterDBHandler->_connect();
                 $status_tests['cluster db'] = '1';
             } catch (exception $e) {
             }
         } else {
             $status_tests['cluster db'] = 'X';
         }
     }
     if (in_array('ezfind', eZExtension::activeExtensions())) {
         $ini = eZINI::instance('solr.ini');
         $ezfinpingurl = $ini->variable('SolrBase', 'SearchServerURI') . "/admin/ping";
         $data = eZHTTPTool::getDataByURL($ezfinpingurl, false);
         $pos2 = stripos($data, '<str name="status">OK</str>');
         if ($pos2 !== false) {
             $status_tests['ezfind'] = '1';
         } else {
             $status_tests['ezfind'] = '0';
         }
     } else {
         $status_tests['ezfind'] = 'X';
     }
     $ini = eZINI::instance('ldap.ini');
     if ($ini->variable('LDAPSettings', 'LDAPEnabled') == 'true' && $ini->variable('LDAPSettings', 'LDAPServer') != '') {
         if (function_exists('ldap_connect')) {
             // code copied over ezldapuser class...
             $LDAPVersion = $ini->variable('LDAPSettings', 'LDAPVersion');
             $LDAPServer = $ini->variable('LDAPSettings', 'LDAPServer');
             $LDAPPort = $ini->variable('LDAPSettings', 'LDAPPort');
             $LDAPBindUser = $ini->variable('LDAPSettings', 'LDAPBindUser');
             $LDAPBindPassword = $ini->variable('LDAPSettings', 'LDAPBindPassword');
             $ds = ldap_connect($LDAPServer, $LDAPPort);
             if ($ds) {
                 ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, $LDAPVersion);
                 if ($LDAPBindUser == '') {
                     $r = ldap_bind($ds);
                 } else {
                     $r = ldap_bind($ds, $LDAPBindUser, $LDAPBindPassword);
                 }
                 if ($r) {
                     $status_tests['ldap server'] = '1';
                 }
             }
         }
     } else {
         $status_tests['ldap server'] = 'X';
     }
     $ini = eZINI::instance('sysinfo.ini');
     $websites = $ini->variable('SystemStatus', 'WebBeacons');
     if (is_string($websites)) {
         $websites = array($websites);
     }
     foreach ($websites as $key => $site) {
         if (trim($site) == '') {
             unset($websites[$key]);
         }
     }
     if (count($websites)) {
         foreach ($websites as $site) {
             // current eZ code is broken if no curl is installed, as it does not check for 404 or such.
             // besides, it does not even support proxies...
             if (extension_loaded('curl')) {
                 if (eZHTTPTool::getDataByURL($site, true)) {
                     $status_tests['web access'] = '1';
                     break;
                 }
             } else {
                 $data = eZHTTPTool::getDataByURL($site, false);
                 if ($data !== false && sysInfoTools::isHTTP200($data)) {
                     $status_tests['web access'] = '1';
                     break;
                 }
             }
         }
     } else {
         $status_tests['web access'] = 'X';
     }
     $ini = eZINI::instance('sysinfo.ini');
     $recipient = $ini->variable('SystemStatus', 'MailReceiver');
     $mail = new eZMail();
     if (trim($recipient) != '' && $mail->validate($recipient)) {
         $mail->setReceiver($recipient);
         $ini = eZINI::instance();
         $sender = $ini->variable('MailSettings', 'EmailSender');
         $mail->setSender($sender);
         $mail->setSubject("Test email");
         $mail->setBody("This email was automatically sent while testing eZ Publish connectivity to the mail server. Please do not reply.");
         $mailResult = eZMailTransport::send($mail);
         if ($mailResult) {
             $status_tests['mail'] = '1';
         }
     } else {
         $status_tests['mail'] = 'X';
     }
     /*
     $ini = eZINI::instance( 'soap.ini' );
     if ( $ini->variable( 'GeneralSettings', 'EnableSOAP' ) == 'true' )
     {
         /// @todo...
     }
     else
     {
         $status_tests['ez soap'] = 'X';
     }
     
     $ini = eZINI::instance( 'webdav.ini' );
     if ( $ini->variable( 'GeneralSettings', 'EnableWebDAV' ) == 'true' )
     {
         /// @todo...
     }
     else
     {
         $status_tests['ez webdav'] = 'X';
     }
     */
     return $status_tests;
 }
コード例 #24
0
$id = $Params['ID'];
$http = eZHTTPTool::instance();
$tpl = eZTemplate::factory();
$format = 'ez';
$action = false;
if ($http->hasVariable('format')) {
    $format = $http->variable('format');
}
$remoteRequest = false;
$remoteRequestUrl = null;
$remoteRequestSuffix = false;
if ($http->hasVariable('remote')) {
    $remoteRequest = $http->variable('remote');
    if (file_exists($remoteRequest)) {
        $remoteRequestUrl = $remoteRequest;
    } elseif (eZHTTPTool::getDataByURL($remoteRequest)) {
        $remoteRequestUrl = rtrim($remoteRequest, '/') . '/classtools/definition/';
    }
    if ($remoteRequestUrl) {
        $remoteRequestSuffix = '?remote=' . $remoteRequest;
    }
}
$remote = null;
try {
    if ($module->isCurrentAction('Install')) {
        $tools = new OCClassTools($id, true, array(), $remoteRequestUrl);
        $tools->sync();
        return $module->redirectTo('/classtools/compare/' . $id . $remoteRequestSuffix);
    }
    $tools = new OCClassTools($id, false, array(), $remoteRequestUrl);
    $remote = $tools->getRemote();