Exemplo n.º 1
0
    }
} else {
    if (!defined('DEBUG')) {
        define('DEBUG', false);
    }
    // The configuration file does not exist.
    // Therefore we load the installer to create the configuration file and install a base database.
    $installer = new InstallHandler();
    $installer->begin_install();
}
/* Habari is installed and we established a connection with the database */
// Set the locale from database or default locale
if (Options::get('locale')) {
    HabariLocale::set(Options::get('locale'));
} else {
    HabariLocale::set('en-us');
}
if (Options::get('system_locale')) {
    HabariLocale::set_system_locale(Options::get('system_locale'));
}
// Verify if the database has to be upgraded.
if (Version::requires_upgrade()) {
    $installer = new InstallHandler();
    $installer->upgrade_db();
}
// If we're doing unit testing, stop here
if (defined('UNIT_TEST')) {
    return;
}
// if this is an asyncronous call, ignore abort.
if (isset($_GET['asyncronous']) && Utils::crypt(Options::get('guid'), $_GET['asyncronous'])) {
/**
 * 读取读取跳转代码 --boboit  2015.11.30
 */
include "checkParameter.php";
define('HABARI_PATH', dirname(__FILE__));
define("habari", dirname(__FILE__));
ob_start();
require dirname(__FILE__) . '/system/autoload.php';
spl_autoload_register('habari_autoload');
SuperGlobal::process_gps();
if (!defined('SUPPRESS_ERROR_HANDLER')) {
    Error::handle_errors();
}
$config = Site::get_dir('config_file');
require_once $config;
HabariLocale::set(Config::get('locale', 'en-us'));
if (!defined('DEBUG')) {
    define('DEBUG', false);
}
DB::connect();
$start_time = strtotime(date("Y-m-d 00:00:00", strtotime("-1 day")));
$end_time = strtotime(date("Y-m-d 23:59:59", strtotime("-1 day")));
if (isset($_GET['st']) && !empty($_GET['st'])) {
    $start_time = strtotime($_GET['st']);
}
if (isset($_GET['et']) && !empty($_GET['et'])) {
    $end_time = strtotime($_GET['et']);
}
$hbslf_visit = DB::get_results('SELECT distinct ip FROM `hbslf_visit` where date_add >=' . $start_time . ' AND  date_add <=' . $end_time);
$hbslf_redirect = DB::get_results('SELECT distinct ip FROM `hbslf_redirect`where date_add >=' . $start_time . ' AND  date_add <=' . $end_time);
echo $visit = count($hbslf_visit);
Exemplo n.º 3
0
 /**
  * Entry point for installation.  The reason there is a begin_install
  * method to handle is that conceivably, the user can stop installation
  * mid-install and need an alternate entry point action at a later time.
  */
 public function act_begin_install()
 {
     // Create a new theme to handle the display of the installer
     $this->theme = Themes::create('installer', 'RawPHPEngine', HABARI_PATH . '/system/installer/');
     /**
      * Set user selected Locale or default
      */
     $this->theme->locales = HabariLocale::list_all();
     if (isset($_POST['locale']) && $_POST['locale'] != null) {
         HabariLocale::set($_POST['locale']);
         $this->theme->locale = $_POST['locale'];
         $this->handler_vars['locale'] = $_POST['locale'];
     } else {
         HabariLocale::set('en-us');
         $this->theme->locale = 'en-us';
         $this->handler_vars['locale'] = 'en-us';
     }
     /*
      * Check .htaccess first because ajax doesn't work without it.
      */
     if (!$this->check_htaccess()) {
         $this->handler_vars['file_contents'] = htmlentities(implode("\n", $this->htaccess()));
         $this->display('htaccess');
     }
     // Dispatch AJAX requests.
     if (isset($_POST['ajax_action'])) {
         switch ($_POST['ajax_action']) {
             case 'check_mysql_credentials':
                 self::ajax_check_mysql_credentials();
                 exit;
                 break;
             case 'check_pgsql_credentials':
                 self::ajax_check_pgsql_credentials();
                 exit;
                 break;
             case 'check_sqlite_credentials':
                 self::ajax_check_sqlite_credentials();
                 exit;
                 break;
         }
     }
     // set the default values now, which will be overriden as we go
     $this->form_defaults();
     if (!$this->meets_all_requirements()) {
         $this->display('requirements');
     }
     /*
      * Add the AJAX hooks
      */
     Plugins::register(array('InstallHandler', 'ajax_check_mysql_credentials'), 'ajax_', 'check_mysql_credentials');
     Plugins::register(array('InstallHandler', 'ajax_check_pgsql_credentials'), 'ajax_', 'check_pgsql_credentials');
     /*
      * Let's check the config.php file if no POST data was submitted
      */
     if (!file_exists(Site::get_dir('config_file')) && !isset($_POST['admin_username'])) {
         // no config file, and no HTTP POST
         $this->display('db_setup');
     }
     // try to load any values that might be defined in config.php
     if (file_exists(Site::get_dir('config_file'))) {
         include Site::get_dir('config_file');
         // check for old style config (global variable, pre-dates registry based config
         if (!Config::exists('db_connection') && isset($db_connection)) {
             // found old style config...
             // set up registry:
             Config::set('db_connection', $db_connection);
             // assign handler vars (for config file write)
             $this->set_handler_vars_from_db_connection();
             // write new config file
             if ($this->write_config_file(true)) {
                 // successful, so redirect:
                 Utils::redirect(Site::get_url('habari'));
             }
         }
         if (Config::exists('db_connection')) {
             $this->set_handler_vars_from_db_connection();
         }
         // if a $blog_data array exists in config.php, use it
         // to pre-load values for the installer
         // ** this is completely optional **
         if (isset($blog_data)) {
             foreach ($blog_data as $blog_datum => $value) {
                 $this->handler_vars[$blog_datum] = $value;
             }
         }
     }
     // now merge in any HTTP POST values that might have been sent
     // these will override the defaults and the config.php values
     $this->handler_vars = $this->handler_vars->merge($_POST);
     // we need details for the admin user to install
     if ('' == $this->handler_vars['admin_username'] || '' == $this->handler_vars['admin_pass1'] || '' == $this->handler_vars['admin_pass2'] || '' == $this->handler_vars['admin_email']) {
         // if none of the above are set, display the form
         $this->display('db_setup');
     }
     $db_type = $this->handler_vars['db_type'];
     if ($db_type == 'mysql' || $db_type == 'pgsql') {
         $this->handler_vars['db_host'] = $_POST["{$db_type}_db_host"];
         $this->handler_vars['db_user'] = $_POST["{$db_type}_db_user"];
         $this->handler_vars['db_pass'] = $_POST["{$db_type}_db_pass"];
         $this->handler_vars['db_schema'] = $_POST["{$db_type}_db_schema"];
     }
     // we got here, so we have all the info we need to install
     // make sure the admin password is correct
     if ($this->handler_vars['admin_pass1'] !== $this->handler_vars['admin_pass2']) {
         $this->theme->assign('form_errors', array('password_mismatch' => _t('Password mis-match.')));
         $this->display('db_setup');
     }
     // check whether prefix is valid
     if (isset($this->handler_vars['table_prefix']) && preg_replace('/[^a-zA-Z_]/', '', $this->handler_vars['table_prefix']) !== $this->handler_vars['table_prefix']) {
         $this->theme->assign('form_errors', array('table_prefix' => _t('Allowed characters are A-Z, a-z and "_".')));
         $this->display('db_setup');
     }
     // Make sure we still have a valid connection
     if (!call_user_func(array($this, "check_{$db_type}"))) {
         $this->display('db_setup');
     }
     // try to write the config file
     if (!$this->write_config_file()) {
         $this->theme->assign('form_errors', array('write_file' => _t('Could not write config.php file...')));
         $this->display('db_setup');
     }
     // try to install the database
     if (!$this->install_db()) {
         // the installation failed for some reason.
         // re-display the form
         $this->display('db_setup');
     }
     // activate plugins on POST
     if (count($_POST) > 0) {
         $this->activate_plugins();
     }
     // Installation complete. Secure sqlite if it was chosen as the database type to use
     if ($db_type == 'sqlite') {
         if (!$this->secure_sqlite()) {
             $this->theme->sqlite_contents = implode("\n", $this->sqlite_contents());
             $this->display('sqlite');
         }
     }
     EventLog::log(_t('Habari successfully installed.'), 'info', 'default', 'habari');
     Utils::redirect(Site::get_url('habari'));
 }