public function getReport()
 {
     // quick and dirty: use same data as for the web
     $tpl = sysInfoTools::eZTemplateFactory();
     $tpl->setVariable('title', 'Content Classes Report');
     $htmlReport = $tpl->fetch("design:sysinfo/classesreport.tpl");
     return $htmlReport;
 }
Example #2
0
 public function getReport()
 {
     // quick and dirty: use same data as for the web
     $tpl = sysInfoTools::eZTemplateFactory();
     $tpl->setVariable('title', 'Roles & Policies Report');
     $tpl->setVariable('roles', self::getRoles());
     $htmlReport = $tpl->fetch("design:sysinfo/policiesreport.tpl");
     return $htmlReport;
 }
Example #3
0
 public function getReport()
 {
     // quick and dirty: use same data as for the web
     $tpl = sysInfoTools::eZTemplateFactory();
     $tpl->setVariable('title', 'Workflows Report');
     $workflows = eZWorkflow::fetchList();
     $triggers = eZTrigger::fetchList();
     $tpl->setVariable('workflows', $workflows);
     $tpl->setVariable('triggers', $triggers);
     $htmlReport = $tpl->fetch("design:sysinfo/workflowsreport.tpl");
     return $htmlReport;
 }
Example #4
0
 protected static function initialize($force = false)
 {
     if (self::$initialized && !$force) {
         return;
     }
     self::$originaltpls = array();
     $knowndirs = array('design');
     foreach ($knowndirs as $phpdir) {
         self::$originaltpls = array_merge(self::$originaltpls, self::scanDirFortpls($phpdir, true));
     }
     self::$extensiontpls = array();
     $extensionsdir = eZExtension::baseDirectory();
     $ini = eZINI::instance('design.ini');
     /// @todo take this from an ini too, to allow user to add more known php files dirs
     foreach ($ini->variable('ExtensionSettings', 'DesignExtensions') as $extdir) {
         self::$extensiontpls = array_merge(self::$extensiontpls, self::scanDirFortpls("{$extensionsdir}/{$extdir}/design", true));
     }
     self::$tpl = sysInfoTools::eZTemplateFactory();
     self::$initialized = true;
 }
Example #5
0
        eZDebug::writeWarning("Sysinfo view uses an unsupported response type: {$response_type}");
}
// fetch template to render results
$Result = array();
$Result['content'] = $tpl->fetch("design:sysinfo/{$view}.tpl");
// for requests which 'come from cluster', remove pagelayout, as they will be shown inside an iframe
if ($isClusterSlaveRequest) {
    /// @todo rewrite links
    // remove pagelayout
    $Result['pagelayout'] = 'design:clusterview_pagelayout.tpl';
    // shall we remove debug info as well?
} else {
    // build nav menu & left-hand menu
    $Result['left_menu'] = 'design:parts/sysinfo/menu.tpl';
    $url1stlevel = array(array('url' => 'sysinfo/index', 'text' => sysInfoTools::ezpI18ntr('SysInfo', 'System information')));
    if ($view == 'index') {
        $url1stlevel[0]['url'] = false;
        $url2ndlevel = array();
    } else {
        $url2ndlevel = array(array('url' => false, 'text' => sysInfoTools::ezpI18ntr('SysInfo', ezSysinfoModule::viewName($view))));
    }
    if ($extra_path != '') {
        if (ezSysinfoModule::viewActive($view)) {
            $url2ndlevel[0]['url'] = "sysinfo/{$view}";
        }
        $url3rdlevel = array(array('url' => false, 'text' => $extra_path));
    } else {
        $url3rdlevel = array();
    }
    $Result['path'] = array_merge($url1stlevel, $url2ndlevel, $url3rdlevel);
}
Example #6
0
 /**
  * @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;
 }
Example #7
0
            $cachedir = eZSys::siteDir() . '/' . $cacheItem['path'];
        } else {
            $cachedir = eZSys::cacheDirectory() . '/' . $cacheItem['path'];
        }
        $count = sysInfoTools::countFilesInDir($cachedir);
        $cacheFilesList[$cacheItem['name']]['count'] = $count;
        if ($count) {
            $cacheFilesList[$cacheItem['name']]['size'] = number_format(sysInfoTools::countFilesSizeInDir($cachedir));
        } else {
            $cacheFilesList[$cacheItem['name']]['size'] = "";
        }
    }
}
// q: are we 100% sure that the eZ5 cache is always at that location?
if (class_exists('Symfony\\Component\\HttpKernel\\Kernel') && is_dir($ezp5CacheDir = eZSys::siteDir() . '/../ezpublish/cache')) {
    foreach (glob($ezp5CacheDir . '/*', GLOB_ONLYDIR) as $envDir) {
        $env = basename($envDir);
        foreach (glob($envDir . '/*', GLOB_ONLYDIR) as $cacheDir) {
            $cache = basename($cacheDir);
            $cacheName = "Symfony/{$env}/{$cache}";
            $count = sysInfoTools::countFilesInDir($cacheDir);
            $cacheFilesList[$cacheName] = array('path' => "ezpublish/cache/{$env}/{$cache}", 'size' => $count ? number_format(sysInfoTools::countFilesSizeInDir($cacheDir)) : "", 'count' => $count);
        }
    }
}
if ($Params['viewmode'] == 'json') {
    $response_type = $Params['viewmode'];
    $response_data = $cacheFilesList;
    return;
}
$tpl->setVariable('filelist', $cacheFilesList);
Example #8
0
<?php

/**
 * @author G. Giunta
 * @copyright (C) G. Giunta 2014-2016
 * @license Licensed under GNU General Public License v2.0. See file license.txt
 */
$warnings = tplChecker::checkFileContents();
$ezgeshi_available = sysInfoTools::ezgeshiAvailable();
if ($Params['viewmode'] == 'json') {
    $response_type = $Params['viewmode'];
    $response_data = $warnings;
    return;
}
$tpl->setVariable('warnings', $warnings);
$tpl->setVariable('ezgeshi_available', $ezgeshi_available);
Example #9
0
    $logdate = $logdate2 = 0;
    if (file_exists($logfile)) {
        $logdate = filemtime($logfile);
    }
    if (file_exists($logfile2)) {
        $logdate2 = filemtime($logfile2);
    }
    $cachedate = $clusterfile->mtime();
    if ($cachedate >= $logdate && $cachedate >= $logdate2) {
        $cachefound = true;
        $clusterfile->fetch();
    }
}
if (!$cachefound) {
    $scale = 60;
    $scalenames = array(60 => 'minute', 60 * 60 => 'hour', 60 * 60 * 24 => 'day');
    // *** Parse storage.log files ***
    $data = ezLogsGrapher::asum(ezLogsGrapher::parseLog($logfile, $scale), ezLogsGrapher::parseLog($logfile2, $scale));
    ksort($data);
    // *** build graph and store it ***
    $graphname = sysInfoTools::ezpI18ntr('SysInfo', 'files per ' . $scalenames[$scale]);
    $graph = ezLogsGrapher::graph($data, $graphname, $scale);
    if ($graph != false) {
        $clusterfile->fileStoreContents($cachefile, $graph);
    } else {
        $errormsg = ezLogsGrapher::lastError();
    }
}
// *** output ***
$tpl->setVariable('graphsource', $cachefile);
$tpl->setVariable('errormsg', $errormsg);
Example #10
0
 /**
  * Return array of all php classes registered for autoload.
  * Class ezpAutoloader does not help us here...
  */
 static function autoloadClasses()
 {
     if (!is_array(self::$ezpClasses)) {
         self::$ezpClasses = (include 'autoload/ezp_kernel.php');
         if (file_exists('var/autoload/ezp_extension.php')) {
             self::$ezpClasses = array_merge(self::$ezpClasses, include 'var/autoload/ezp_extension.php');
         }
         if (defined('EZP_AUTOLOAD_ALLOW_KERNEL_OVERRIDE') and EZP_AUTOLOAD_ALLOW_KERNEL_OVERRIDE) {
             if ($ezpKernelOverrideClasses = (include 'var/autoload/ezp_override.php')) {
                 self::$ezpClasses = array_merge(self::$ezpClasses, $ezpKernelOverrideClasses);
             }
         }
     }
     return self::$ezpClasses;
 }
Example #11
0
                                    $view = array_merge( array( 'params' => array(), 'functions' => array(), 'unordered_params' => array(), 'single_post_actions' => array(), 'post_actions' => array(), 'post_action_parameters' => array() ), $view );
                                    $operationList[$viewname . '_' . $modulename] = $view;
                                    $operationList[$viewname . '_' . $modulename]['name'] = $viewname;
                                    $operationList[$viewname . '_' . $modulename]['module'] = $modulename;
                                    $operationList[$viewname . '_' . $modulename]['extension'] = $extension;
                                    // merge all post parameters stuff
                                    $post_params = array_merge( $view['post_actions'], array_keys( $view['single_post_actions'] ) );
                                    foreach( $view['post_action_parameters'] as $key => $params )
                                    {
                                        $post_params = array_merge( $post_params, array_keys( $params ) );
                                    }
                                    sort( $post_params );
                                    $operationList[$viewname . '_' . $modulename]['post_params'] = array_unique( $post_params );
                                }*/
            }
        }
    }
    ksort($operationList);
}
$title = 'List of available operations';
if ($Params['modulename'] != '') {
    $title .= ' in module "' . $Params['modulename'] . '"';
    $extra_path = $Params['modulename'];
}
$ezgeshi_available = sysInfoTools::ezgeshiAvailable();
$tpl->setVariable('title', $title);
$tpl->setVariable('operationlist', $operationList);
$tpl->setVariable('sdkversion', eZPublishSDK::version());
$tpl->setVariable('ezgeshi_available', $ezgeshi_available);
$tpl->setVariable('source_available', sysInfoTools::sourceCodeAvailable(eZPublishSDK::version()));
Example #12
0
<?php

/**
 *
 * @author G. Giunta
 * @copyright (C) G. Giunta 2008-2016
 * @license Licensed under GNU General Public License v2.0. See file license.txt
 *
 * @todo add more details, such as dates of first/last files
 * @todo add support for db-clustered configs - hard currently, since there is no recursive search in api...
 * @todo in edfs mode allow user to only show clustered data
 */
$storageFilesList = array();
$storageDir = eZSys::storageDirectory();
$files = @scandir($storageDir);
foreach ($files as $file) {
    if ($file != '.' && $file != '..' && is_dir($storageDir . '/' . $file)) {
        $storageFilesList[$file] = array('path' => $storageDir . '/' . $file, 'count' => number_format(sysInfoTools::countFilesInDir($storageDir . '/' . $file)), 'size' => number_format(sysInfoTools::countFilesSizeInDir($storageDir . '/' . $file)));
    }
}
if ($Params['viewmode'] == 'json') {
    $response_type = $Params['viewmode'];
    $response_data = $storageFilesList;
    return;
}
$tpl->setVariable('filelist', $storageFilesList);
Example #13
0
foreach ($cacheList as $cacheItem) {
    if ($cacheItem['path'] != false && $cacheItem['enabled']) {
        $cacheDirsList[$cacheItem['id']] = $cacheItem['path'];
        $cacheDirsList2[$cacheItem['id']] = false;
    }
}
if ($http->hasPostVariable('SearchText') && $http->hasPostVariable('SearchCaches')) {
    $ini = eZINI::instance();
    $cachedir = eZSys::cacheDirectory();
    //$cachedir .= "/" .$ini->variable( 'ContentSettings', 'CacheDir' );
    $searchtext = $http->postVariable('SearchText');
    $is_regexp = $http->hasPostVariable('SearchType') && $http->postVariable('SearchType') == 'Regexp';
    foreach ($http->postVariable('SearchCaches') as $cache) {
        if (array_key_exists($cache, $cacheDirsList)) {
            // take care: this is hardcoded from knowledge of cache structure...
            if ($cacheDirsList[$cache] == 'var/cache/ini') {
                $filelist = array_merge($filelist, sysInfoTools::searchInFiles($searchtext, eZSys::siteDir() . '/' . $cacheDirsList[$cache], $is_regexp));
            } else {
                $filelist = array_merge($filelist, sysInfoTools::searchInFiles($searchtext, $cachedir . '/' . $cacheDirsList[$cache], $is_regexp));
            }
            $cacheDirsList2[$cache] = true;
        }
    }
    //print_r($filelist);
}
$tpl->setVariable('filelist', $filelist);
$tpl->setVariable('list_count', count($filelist));
$tpl->setVariable('searchtext', $searchtext);
$tpl->setVariable('cachelist', $cacheDirsList2);
$tpl->setVariable('deletedfiles', $deletedfiles);
$tpl->setVariable('is_regexp', $is_regexp);
Example #14
0
$clusterStorageDir = ezSysinfoClusterManager::clusterFileStorageDir();
if ($clusterStorageDir != '') {
    $storageDir = $clusterStorageDir;
    foreach ($cacheList as $cacheItem) {
        if ($cacheItem['path'] != false && $cacheItem['enabled']) {
            $cacheName = 'DFS://' . $cacheItem['name'];
            // take care: this is hardcoded from knowledge of cache structure...
            if ($cacheItem['path'] == 'var/cache/ini') {
                //$cachedir = $storageDir . '/' . eZSys::siteDir() . '/' . $cacheItem['path'];
                // no var/cache/ini in dfs nfs storage
                continue;
            } else {
                $cachedir = $storageDir . '/' . eZSys::cacheDirectory() . '/' . $cacheItem['path'];
            }
            $cacheFilesList[$cacheName] = array('path' => $cachedir);
            $count = sysInfoTools::countFilesInDir($cachedir);
            $cacheFilesList[$cacheName]['count'] = $count;
            if ($count) {
                $cacheFilesList[$cacheName]['size'] = number_format(sysInfoTools::countFilesSizeInDir($cachedir));
            } else {
                $cacheFilesList[$cacheName]['size'] = "";
            }
        }
    }
}
if ($Params['viewmode'] == 'json') {
    $response_type = $Params['viewmode'];
    $response_data = $cacheFilesList;
    return;
}
$tpl->setVariable('filelist', $cacheFilesList);
Example #15
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
 }
Example #16
0
                  }*/
                /*$last = end( array_keys( $data ) );
                  $data[$last + $scale] = 0;*/
                $graphname = sysInfoTools::ezpI18ntr('SysInfo', 'messages per ' . $scalenames[$scale]);
                $graph = ezLogsGrapher::graph($data, $graphname, $scale);
                if ($graph != false) {
                    $clusterfile->fileStoreContents($cachefile, $graph);
                    $cachefiles[$logname] = $cachefile;
                } else {
                    $errormsg = ezLogsGrapher::lastError();
                }
            } else {
                eZDebug::writedebug("No valid date labels in log {$logfile}", __METHOD__);
            }
        }
    }
}
if ($Params['viewmode'] == 'json') {
    $response_type = $Params['viewmode'];
    $response_data = $cachefiles;
    return;
}
// *** output ***
$tpl->setVariable('graphsources', $cachefiles);
$tpl->setVariable('errormsg', $errormsg);
$Result = array();
$Result['content'] = $tpl->fetch("design:sysinfo/logchurn.tpl");
//var_dump($cacheFilesList);
$Result['left_menu'] = 'design:parts/sysinfo/menu.tpl';
$Result['path'] = array(array('url' => false, 'text' => sysInfoTools::ezpI18ntr('SysInfo', 'Log churn')));
Example #17
0
<?php

/**
 * Tests status of eZ Publish install in more detail than ezinfo/isalive
 * For every test, 1 = OK, 0 = KO and X = NA. ? = test not yet implemented
 * NB: some tests are enabled/disabled depending upon config in sysinfo.ini
 *
 * @author G. Giunta
 * @copyright (C) G. Giunta 2008-2016
 * @license Licensed under GNU General Public License v2.0. See file license.txt
 */
// backwards compatibility
if (!isset($Params['viewmode'])) {
    if (isset($Params['output_format'])) {
        $Params['viewmode'] = $Params['output_format'];
    }
}
$testsList = sysInfoTools::runTests();
$ezsnmpd_available = false;
if (in_array('ezsnmpd', eZExtension::activeExtensions())) {
    $ezsnmpd_available = true;
}
if ($Params['viewmode'] == 'plaintext' || $Params['viewmode'] == 'json') {
    $response_type = $Params['viewmode'];
    $response_data = $testsList;
    return;
}
$tpl->setVariable('testslist', $testsList);
$tpl->setVariable('ezsnmpd_available', $ezsnmpd_available);