function scan($url)
{
    global $scans;
    global $documentsToScan;
    $document = getPageContents($url);
    if (!DBdocumentExists($url)) {
        $keywords = EXTRACTkeywords($document);
        DBinsertKeywords($url, $keywords);
        $scans--;
    }
    if ($scans <= 0) {
        DBclose();
        exit;
    }
    $links = getLinks($document);
    $documentsToScan = array_merge($documentsToScan, $links);
    $nextScan = array_shift($documentsToScan);
    if ($nextScan != null) {
        scan($nextScan);
    }
}
Exemple #2
0
 function checkConnection()
 {
     global $DB;
     if (!$this->getConfig('check_fields_result')) {
         return false;
     }
     $DB['TYPE'] = $this->getConfig('DB_TYPE');
     if (is_null($DB['TYPE'])) {
         return false;
     }
     $DB['SERVER'] = $this->getConfig('DB_SERVER', 'localhost');
     $DB['PORT'] = $this->getConfig('DB_PORT', '0');
     $DB['DATABASE'] = $this->getConfig('DB_DATABASE', 'zabbix');
     $DB['USER'] = $this->getConfig('DB_USER', 'root');
     $DB['PASSWORD'] = $this->getConfig('DB_PASSWORD', '');
     $DB['SCHEMA'] = $this->getConfig('DB_SCHEMA', '');
     $error = '';
     // during setup set debug to false to avoid displaying unwanted PHP errors in messages
     if (!($result = DBconnect($error))) {
         error($error);
     } else {
         $result = true;
         if (!zbx_empty($DB['SCHEMA']) && $DB['TYPE'] == ZBX_DB_DB2) {
             $db_schema = DBselect('SELECT schemaname FROM syscat.schemata WHERE schemaname=\'' . db2_escape_string($DB['SCHEMA']) . '\'');
             $result = DBfetch($db_schema);
         }
         if ($result) {
             $result = DBexecute('CREATE TABLE zabbix_installation_test (test_row INTEGER)');
             $result &= DBexecute('DROP TABLE zabbix_installation_test');
         }
     }
     DBclose();
     $DB = null;
     return $result;
 }
Exemple #3
0
 function CheckConfigurationFile()
 {
     global $DB, $ZBX_SERVER, $ZBX_SERVER_PORT;
     if (!empty($DB)) {
         $old_DB = true;
         $old_DB_TYPE = $DB['TYPE'];
         $old_DB_SERVER = $DB['SERVER'];
         $old_DB_PORT = $DB['PORT'];
         $old_DB_DATABASE = $DB['DATABASE'];
         $old_DB_USER = $DB['USER'];
         $old_DB_PASSWORD = $DB['PASSWORD'];
         $old_ZBX_SERVER = $ZBX_SERVER;
         $old_ZBX_SERVER_PORT = $ZBX_SERVER_PORT;
     }
     $error = null;
     $error_msg = null;
     global $ZBX_CONFIGURATION_FILE;
     if (file_exists($ZBX_CONFIGURATION_FILE)) {
         include $ZBX_CONFIGURATION_FILE;
         if (isset($DB['TYPE']) && isset($DB['SERVER']) && isset($DB['DATABASE']) && isset($DB['USER']) && isset($DB['PASSWORD']) && isset($ZBX_SERVER) && isset($ZBX_SERVER_PORT) && isset($IMAGE_FORMAT_DEFAULT) && $DB['TYPE'] == $this->getConfig('DB_TYPE', null) && $DB['SERVER'] == $this->getConfig('DB_SERVER', null) && $DB['PORT'] == $this->getConfig('DB_PORT', null) && $DB['DATABASE'] == $this->getConfig('DB_DATABASE', null) && $DB['USER'] == $this->getConfig('DB_USER', null) && $DB['PASSWORD'] == $this->getConfig('DB_PASSWORD', null)) {
             if (!DBconnect($error_msg)) {
                 $error_msg = 'Can not connect to database';
             }
         } else {
             $error_msg = 'Incorrect configuration file[' . $ZBX_CONFIGURATION_FILE . ']';
         }
         DBclose();
     } else {
         $error = 'Missing configuration file[' . $ZBX_CONFIGURATION_FILE . ']';
     }
     if (isset($error_msg)) {
         error($error_msg);
     }
     /* restore connection */
     global $DB;
     if (isset($old_DB)) {
         $DB['TYPE'] = $old_DB_TYPE;
         $DB['SERVER'] = $old_DB_SERVER;
         $DB['PORT'] = $old_DB_PORT;
         $DB['DATABASE'] = $old_DB_DATABASE;
         $DB['USER'] = $old_DB_USER;
         $DB['PASSWORD'] = $old_DB_PASSWORD;
         $ZBX_SERVER = $old_ZBX_SERVER;
         $ZBX_SERVER_PORT = $old_ZBX_SERVER_PORT;
     }
     DBconnect($error2);
     return !isset($error) && !isset($error_msg);
 }
Exemple #4
0
 /**
  * Initializes the application.
  */
 public function run($mode = self::EXEC_MODE_DEFAULT)
 {
     $this->init();
     $this->setMaintenanceMode();
     $this->setErrorHandler();
     switch ($mode) {
         case self::EXEC_MODE_DEFAULT:
             $this->loadConfigFile();
             $this->initDB();
             $this->initNodes();
             $this->authenticateUser();
             // init nodes after user is authenticated
             init_nodes();
             $this->initLocales();
             break;
         case self::EXEC_MODE_API:
             $this->loadConfigFile();
             $this->initDB();
             $this->initNodes();
             $this->initLocales();
             break;
         case self::EXEC_MODE_SETUP:
             try {
                 // try to load config file, if it exists we need to init db and authenticate user to check permissions
                 $this->loadConfigFile();
                 $this->initDB();
                 $this->initNodes();
                 $this->authenticateUser();
                 // init nodes after user is authenticated
                 init_nodes();
                 $this->initLocales();
                 DBclose();
             } catch (ConfigFileException $e) {
             }
             break;
     }
 }
 function CheckConnection()
 {
     global $DB;
     //			global $ZBX_MESSAGES;
     $DB['TYPE'] = $this->getConfig('DB_TYPE');
     if (is_null($DB['TYPE'])) {
         return false;
     }
     $DB['SERVER'] = $this->getConfig('DB_SERVER', 'localhost');
     $DB['PORT'] = $this->getConfig('DB_PORT', '0');
     $DB['DATABASE'] = $this->getConfig('DB_DATABASE', 'zabbix');
     $DB['USER'] = $this->getConfig('DB_USER', 'root');
     $DB['PASSWORD'] = $this->getConfig('DB_PASSWORD', '');
     $DB['SCHEMA'] = $this->getConfig('DB_SCHEMA', '');
     $error = '';
     if (!($result = DBconnect($error))) {
         //				if(!is_null($ZBX_MESSAGES)) array_pop($ZBX_MESSAGES);
         error($error);
     } else {
         $result = true;
         if (!zbx_empty($DB['SCHEMA']) && $DB['TYPE'] == 'IBM_DB2') {
             $db_schema = DBselect("SELECT schemaname FROM syscat.schemata WHERE schemaname='" . db2_escape_string($DB['SCHEMA']) . "'");
             $result = DBfetch($db_schema);
         }
         if ($result) {
             $result = DBexecute('CREATE table zabbix_installation_test ( test_row integer )');
             $result &= DBexecute('DROP table zabbix_installation_test');
         }
     }
     DBclose();
     if ($DB['TYPE'] == 'SQLITE3' && !zbx_is_callable(array('sem_get', 'sem_acquire', 'sem_release', 'sem_remove'))) {
         error('SQLite3 requires IPC functions');
         $result = false;
     }
     $DB = null;
     return $result;
 }
 function CheckConnection()
 {
     global $DB;
     $DB['TYPE'] = $this->getConfig('DB_TYPE');
     if (is_null($DB['TYPE'])) {
         return false;
     }
     $DB['SERVER'] = $this->getConfig('DB_SERVER', 'localhost');
     $DB['PORT'] = $this->getConfig('DB_PORT', '0');
     $DB['DATABASE'] = $this->getConfig('DB_DATABASE', 'zabbix');
     $DB['USER'] = $this->getConfig('DB_USER', 'root');
     $DB['PASSWORD'] = $this->getConfig('DB_PASSWORD', '');
     $DB['SCHEMA'] = $this->getConfig('DB_SCHEMA', '');
     $error = '';
     if (!($result = DBconnect($error))) {
         error($error);
     } else {
         $result = true;
         if (!zbx_empty($DB['SCHEMA']) && $DB['TYPE'] == ZBX_DB_DB2) {
             $db_schema = DBselect('SELECT schemaname FROM syscat.schemata WHERE schemaname=\'' . db2_escape_string($DB['SCHEMA']) . '\'');
             $result = DBfetch($db_schema);
         }
         if ($result) {
             $result = DBexecute('CREATE TABLE zabbix_installation_test (test_row INTEGER)');
             $result &= DBexecute('DROP TABLE zabbix_installation_test');
         }
     }
     DBclose();
     if ($DB['TYPE'] == ZBX_DB_SQLITE3 && !zbx_is_callable(array('ftok', 'sem_get', 'sem_acquire', 'sem_release', 'sem_remove'))) {
         error('Support of SQLite3 requires PHP IPC functions');
         $result = false;
     }
     $DB = null;
     return $result;
 }
Exemple #7
0
// if a guest or a non-super admin user is logged in
if (CWebUser::$data && CWebUser::getType() < USER_TYPE_SUPER_ADMIN) {
    // on the last step of the setup we always have a guest user logged in;
    // when he presses the "Finish" button he must be redirected to the login screen
    if (CWebUser::isGuest() && CSession::getValue('step') == 5 && hasRequest('finish')) {
        CSession::clear();
        redirect('index.php');
    } elseif (!(CWebUser::isGuest() && CSession::getValue('step') == 5)) {
        access_deny(ACCESS_DENY_PAGE);
    }
} elseif (hasRequest('cancel') || hasRequest('finish')) {
    CSession::clear();
    redirect('index.php');
}
$theme = CWebUser::$data ? getUserTheme(CWebUser::$data) : ZBX_DEFAULT_THEME;
DBclose();
/*
 * Setup wizard
 */
$ZBX_SETUP_WIZARD = new CSetupWizard();
// if init fails due to missing configuration, set user as guest with default en_GB language
if (!CWebUser::$data) {
    CWebUser::setDefault();
}
// page title
(new CPageHeader(_('Installation')))->addCssFile('styles/' . CHtml::encode($theme) . '.css')->addJsFile('js/browsers.js')->addJsFile('jsLoader.php?ver=' . ZABBIX_VERSION . '&amp;lang=' . CWebUser::$data['lang'])->display();
/*
 * Displaying
 */
$link = (new CLink('GPL v2', 'http://www.zabbix.com/license.php'))->setTarget('_blank')->addClass(ZBX_STYLE_GREY)->addClass(ZBX_STYLE_LINK_ALT);
$sub_footer = (new CDiv(['Licensed under ', $link]))->addClass(ZBX_STYLE_SIGNIN_LINKS);