Esempio n. 1
1
function gprobe_run($argv, $argc)
{
    global $a, $db;
    if (is_null($a)) {
        $a = new App();
    }
    if (is_null($db)) {
        @(include ".htconfig.php");
        require_once "dba.php";
        $db = new dba($db_host, $db_user, $db_pass, $db_data);
        unset($db_host, $db_user, $db_pass, $db_data);
    }
    require_once 'include/session.php';
    require_once 'include/datetime.php';
    load_config('config');
    load_config('system');
    $a->set_baseurl(get_config('system', 'url'));
    load_hooks();
    if ($argc != 2) {
        return;
    }
    $url = hex2bin($argv[1]);
    $r = q("select * from gcontact where nurl = '%s' limit 1", dbesc(normalise_link($url)));
    if (!count($r)) {
        $arr = probe_url($url);
        if (count($arr) && x($arr, 'network') && $arr['network'] === NETWORK_DFRN) {
            q("insert into `gcontact` (`name`,`url`,`nurl`,`photo`)\n\t\t\t\tvalues ( '%s', '%s', '%s', '%s') ", dbesc($arr['name']), dbesc($arr['url']), dbesc(normalise_link($arr['url'])), dbesc($arr['photo']));
        }
        $r = q("select * from gcontact where nurl = '%s' limit 1", dbesc(normalise_link($url)));
    }
    if (count($r)) {
        poco_load(0, 0, $r[0]['id'], str_replace('/profile/', '/poco/', $r[0]['url']));
    }
    return;
}
Esempio n. 2
1
function directory_run(&$argv, &$argc)
{
    global $a, $db;
    if (is_null($a)) {
        $a = new App();
    }
    if (is_null($db)) {
        @(include ".htconfig.php");
        require_once "include/dba.php";
        $db = new dba($db_host, $db_user, $db_pass, $db_data);
        unset($db_host, $db_user, $db_pass, $db_data);
    }
    load_config('config');
    load_config('system');
    if ($argc != 2) {
        return;
    }
    load_config('system');
    load_hooks();
    $a->set_baseurl(get_config('system', 'url'));
    $dir = get_config('system', 'directory_submit_url');
    if (!strlen($dir)) {
        return;
    }
    $arr = array('url' => $argv[1]);
    call_hooks('globaldir_update', $arr);
    logger('Updating directory: ' . $arr['url'], LOGGER_DEBUG);
    if (strlen($arr['url'])) {
        fetch_url($dir . '?url=' . bin2hex($arr['url']));
    }
    return;
}
Esempio n. 3
1
function directory_run($argv, $argc)
{
    global $a, $db;
    if (is_null($a)) {
        $a = new App();
    }
    if (is_null($db)) {
        @(include ".htconfig.php");
        require_once "dba.php";
        $db = new dba($db_host, $db_user, $db_pass, $db_data);
        unset($db_host, $db_user, $db_pass, $db_data);
    }
    load_config('config');
    load_config('system');
    if ($argc != 2) {
        return;
    }
    load_config('system');
    $a->set_baseurl(get_config('system', 'url'));
    $dir = get_config('system', 'directory_submit_url');
    if (!strlen($dir)) {
        return;
    }
    fetch_url($dir . '?url=' . bin2hex($argv[1]));
    return;
}
Esempio n. 4
1
function expire_run($argv, $argc)
{
    global $a, $db;
    if (is_null($a)) {
        $a = new App();
    }
    if (is_null($db)) {
        @(include ".htconfig.php");
        require_once "dba.php";
        $db = new dba($db_host, $db_user, $db_pass, $db_data);
        unset($db_host, $db_user, $db_pass, $db_data);
    }
    require_once 'include/session.php';
    require_once 'include/datetime.php';
    require_once 'library/simplepie/simplepie.inc';
    require_once 'include/items.php';
    require_once 'include/Contact.php';
    load_config('config');
    load_config('system');
    $a->set_baseurl(get_config('system', 'url'));
    logger('expire: start');
    $r = q("SELECT `uid`,`username`,`expire` FROM `user` WHERE `expire` != 0");
    if (count($r)) {
        foreach ($r as $rr) {
            logger('Expire: ' . $rr['username'] . ' interval: ' . $rr['expire'], LOGGER_DEBUG);
            item_expire($rr['uid'], $rr['expire']);
        }
    }
    return;
}
Esempio n. 5
1
function expire_run($argv, $argc)
{
    global $a, $db;
    if (is_null($a)) {
        $a = new App();
    }
    if (is_null($db)) {
        @(include ".htconfig.php");
        require_once "dba.php";
        $db = new dba($db_host, $db_user, $db_pass, $db_data);
        unset($db_host, $db_user, $db_pass, $db_data);
    }
    require_once 'include/session.php';
    require_once 'include/datetime.php';
    require_once 'library/simplepie/simplepie.inc';
    require_once 'include/items.php';
    require_once 'include/Contact.php';
    load_config('config');
    load_config('system');
    $a->set_baseurl(get_config('system', 'url'));
    // physically remove anything that has been deleted for more than two months
    $r = q("delete from item where deleted = 1 and changed < UTC_TIMESTAMP() - INTERVAL 60 DAY");
    q("optimize table item");
    logger('expire: start');
    $r = q("SELECT `uid`,`username`,`expire` FROM `user` WHERE `expire` != 0");
    if (count($r)) {
        foreach ($r as $rr) {
            logger('Expire: ' . $rr['username'] . ' interval: ' . $rr['expire'], LOGGER_DEBUG);
            item_expire($rr['uid'], $rr['expire']);
        }
    }
    return;
}
Esempio n. 6
0
 /**
  * 应用程序初始化
  */
 public static function start()
 {
     // 注册AUTOLOAD方法
     spl_autoload_register('Think\\Think::autoLoad');
     // 设定错误和异常处理
     register_shutdown_function('Think\\Think::fatalError');
     set_error_handler('Think\\Think::appError');
     set_exception_handler('Think\\Think::appException');
     // 初始化文件存储方式
     Storage::connect(STORAGE_TYPE);
     $runtimeFile = RUNTIME_PATH . APP_MODE . '~runtime.php';
     if (!APP_DEBUG && Storage::has($runtimeFile)) {
         Storage::load($runtimeFile);
     } else {
         $content = '';
         // 读取应用模式
         $mode = (include is_file(CONF_PATH . 'core.php') ? CONF_PATH . 'core.php' : MODE_PATH . APP_MODE . '.php');
         // 加载核心文件
         foreach ($mode['core'] as $file) {
             if (is_file($file)) {
                 include $file;
                 if (!APP_DEBUG) {
                     $content .= compile($file);
                 }
             }
         }
         // 加载应用模式配置文件
         foreach ($mode['config'] as $key => $file) {
             is_numeric($key) ? C(load_config($file)) : C($key, load_config($file));
         }
     }
 }
Esempio n. 7
0
 /**
  * Get a forecasting configuration value
  * @param type $config_key const CONFIG_KEY_* of this class 
  * @return type
  */
 public static function getForecastingConfig($config_key)
 {
     if (is_null(self::$forecasting_config)) {
         self::$forecasting_config = load_config('forecasting');
     }
     return self::$forecasting_config[$config_key];
 }
Esempio n. 8
0
 /**
  * __construct method
  * @throws Error
  * */
 public function __construct()
 {
     $upload = load_config('upload');
     self::init($upload);
     if (is_null(self::$path)) {
         throw new Error('invalidUploadPath', array('invalidPath' => self::$path));
     }
 }
Esempio n. 9
0
 public function __construct()
 {
     $safeconfig = load_config('config', 'safe');
     if (isset($safeconfig['key']) && !empty($safeconfig['key'])) {
         $this->crypt_key = $safeconfig['key'];
     } else {
         $this->crypt_key = 'sunphp';
     }
 }
Esempio n. 10
0
 public function __construct(array $config = array())
 {
     global $app_dbo;
     $config = array_merge($config, load_config('auth'));
     $this->table_name = $config['auth_table_name'];
     $this->username_field = $config['auth_fields']['user'];
     $this->password_field = $config['auth_fields']['pass'];
     $this->remember = $config['remember'];
     $this->dbo =& $app_dbo;
 }
Esempio n. 11
0
 public function __construct()
 {
     $databaseConfig = load_config('database');
     if (!isset($this->database)) {
         $currentDBConfig = $databaseConfig['default'];
     } else {
         $currentDBConfig = $databaseConfig[$this->database];
     }
     $this->db = new DataBase($currentDBConfig);
 }
Esempio n. 12
0
 function testModelConnection()
 {
     $model = new Model();
     $config = load_config();
     $model->config = $config["database"];
     $model->load();
     global $test;
     echo "<br />";
     $test->show();
 }
Esempio n. 13
0
 public static function apiAuth($app)
 {
     load_config('apikey');
     if (empty($GLOBALS['config']['apikey'][$app])) {
         exit('key config error');
     }
     if (empty($_REQUEST['time']) || $_REQUEST['time'] + 120 <= time() || $_REQUEST['sign'] != md5($_REQUEST['_c'] . $GLOBALS['config']['apikey'][$app] . $_REQUEST['time'])) {
         echo "0";
         exit;
     }
 }
Esempio n. 14
0
 /**
  * 获得服务器的时区
  *
  * @return  integer
  */
 function server_timezone()
 {
     if (function_exists('load_config')) {
         $_CFG = load_config();
         return $_CFG['timezone'];
     }
     if (function_exists('date_default_timezone_get')) {
         return date_default_timezone_get();
     } else {
         return date('Z') / 3600;
     }
 }
Esempio n. 15
0
 /**
  * start method
  * @param string $url
  * @return array
  * */
 public static final function start($url)
 {
     self::$routArray = load_config('routing');
     self::$url = $url;
     if (self::$url === '/' || trim(self::$url) === '') {
         self::$url = '';
         self::defaultRout();
     } else {
         self::findCurrentValue();
     }
     return self::$router;
 }
Esempio n. 16
0
 /**
  * __construct method
  * @param array $config
  * */
 public function __construct($config = null)
 {
     foreach (load_config('database') as $item => $value) {
         $this->{$item} = $value;
     }
     if (!is_null($config)) {
         foreach ($config as $item => $value) {
             $this->{$item} = $value;
         }
     }
     $this->makeConnection();
 }
Esempio n. 17
0
 /**
  * 由email取得邮件服务商的信息
  * @param type $email 邮箱名
  * @return array ['name'] && ['url']
  */
 static function emailServer($email)
 {
     $emailServer = array("name" => "", "url" => "");
     load_config('emailServer');
     $emailDomain = substr($email, stripos($email, '@') + 1);
     if (isset($GLOBALS['config']['emailServer'][$emailDomain])) {
         $emailServer = $GLOBALS['config']['emailServer'][$emailDomain];
     } else {
         $emailServer['name'] = "邮箱";
         $emailServer['url'] = "http://www." . $email_domain;
     }
     return $emailServer;
 }
Esempio n. 18
0
 /**
  * 检测Cookie是否存在
  */
 public static function checkcookie($name)
 {
     $cookieconfig = load_config('config', 'cookie');
     $prefix = $cookieconfig['prefix'];
     $name = $prefix . $name;
     $name = base64_encode($name);
     $name = strtr($name, '=', 'S');
     if (isset($_COOKIE[$name])) {
         return true;
     } else {
         return false;
     }
 }
Esempio n. 19
0
function cronhooks_run(&$argv, &$argc)
{
    global $a, $db;
    if (is_null($a)) {
        $a = new App();
    }
    if (is_null($db)) {
        @(include ".htconfig.php");
        require_once "include/dba.php";
        $db = new dba($db_host, $db_user, $db_pass, $db_data);
        unset($db_host, $db_user, $db_pass, $db_data);
    }
    require_once 'include/session.php';
    require_once 'include/datetime.php';
    require_once 'include/pidfile.php';
    load_config('config');
    load_config('system');
    $maxsysload = intval(get_config('system', 'maxloadavg'));
    if ($maxsysload < 1) {
        $maxsysload = 50;
    }
    if (function_exists('sys_getloadavg')) {
        $load = sys_getloadavg();
        if (intval($load[0]) > $maxsysload) {
            logger('system: load ' . $load . ' too high. Poller deferred to next scheduled run.');
            return;
        }
    }
    $lockpath = get_lockpath();
    if ($lockpath != '') {
        $pidfile = new pidfile($lockpath, 'cronhooks');
        if ($pidfile->is_already_running()) {
            logger("cronhooks: Already running");
            if ($pidfile->running_time() > 19 * 60) {
                $pidfile->kill();
                logger("cronhooks: killed stale process");
                // Calling a new instance
                proc_run('php', 'include/cronhooks.php');
            }
            exit;
        }
    }
    $a->set_baseurl(get_config('system', 'url'));
    load_hooks();
    logger('cronhooks: start');
    $d = datetime_convert();
    call_hooks('cron', $d);
    logger('cronhooks: end');
    return;
}
Esempio n. 20
0
/**
 * @brief Get a particular config variable given the category name ($family)
 * and a key.
 *
 * Get a particular config variable from the given category ($family) and the
 * $key from a cached storage in $a->config[$family]. If a key is found in the
 * DB but does not exist in local config cache, pull it into the cache so we
 * do not have to hit the DB again for this item.
 * 
 * Returns false if not set.
 *
 * @param string $family
 *  The category of the configuration value
 * @param string $key
 *  The configuration key to query
 * @return mixed Return value or false on error or if not set
 */
function get_config($family, $key)
{
    global $a;
    if (!array_key_exists($family, $a->config) || !array_key_exists('config_loaded', $a->config[$family])) {
        load_config($family);
    }
    if (array_key_exists('config_loaded', $a->config[$family])) {
        if (!array_key_exists($key, $a->config[$family])) {
            return false;
        }
        return !is_array($a->config[$family][$key]) && preg_match('|^a:[0-9]+:{.*}$|s', $a->config[$family][$key]) ? unserialize($a->config[$family][$key]) : $a->config[$family][$key];
    }
    return false;
}
Esempio n. 21
0
function gprobe_run(&$argv, &$argc)
{
    global $a, $db;
    if (is_null($a)) {
        $a = new App();
    }
    if (is_null($db)) {
        @(include ".htconfig.php");
        require_once "include/dba.php";
        $db = new dba($db_host, $db_user, $db_pass, $db_data);
        unset($db_host, $db_user, $db_pass, $db_data);
    }
    require_once 'include/session.php';
    require_once 'include/datetime.php';
    load_config('config');
    load_config('system');
    $a->set_baseurl(get_config('system', 'url'));
    load_hooks();
    if ($argc != 2) {
        return;
    }
    $url = hex2bin($argv[1]);
    $r = q("select * from gcontact where nurl = '%s' limit 1", dbesc(normalise_link($url)));
    logger("gprobe start for " . normalise_link($url), LOGGER_DEBUG);
    if (!count($r)) {
        // Is it a DDoS attempt?
        $urlparts = parse_url($url);
        $result = Cache::get("gprobe:" . $urlparts["host"]);
        if (!is_null($result)) {
            $result = unserialize($result);
            if ($result["network"] == NETWORK_FEED) {
                logger("DDoS attempt detected for " . $urlparts["host"] . " by " . $_SERVER["REMOTE_ADDR"] . ". server data: " . print_r($_SERVER, true), LOGGER_DEBUG);
                return;
            }
        }
        $arr = probe_url($url);
        if (is_null($result)) {
            Cache::set("gprobe:" . $urlparts["host"], serialize($arr));
        }
        if (count($arr) && x($arr, 'network') && $arr['network'] === NETWORK_DFRN) {
            q("insert into `gcontact` (`name`,`url`,`nurl`,`photo`)\n\t\t\t\tvalues ( '%s', '%s', '%s', '%s') ", dbesc($arr['name']), dbesc($arr['url']), dbesc(normalise_link($arr['url'])), dbesc($arr['photo']));
        }
        $r = q("select * from gcontact where nurl = '%s' limit 1", dbesc(normalise_link($url)));
    }
    if (count($r)) {
        poco_load(0, 0, $r[0]['id'], str_replace('/profile/', '/poco/', $r[0]['url']));
    }
    logger("gprobe end for " . normalise_link($url), LOGGER_DEBUG);
    return;
}
Esempio n. 22
0
function load_view($page, $data = null)
{
    $file = load_config("app.view_folder") . $page . ".php";
    if (file_exists($file)) {
        ob_start();
        if ($data != null) {
            extract($data);
        }
        require $file;
        return ob_get_clean();
    } else {
        echo "404 Not Found!";
    }
}
Esempio n. 23
0
 /**
  * __construct
  * @var array $args (default value null)
  **/
 public function __construct($args = null)
 {
     $session = load_config('session');
     $config = $args != null ? $args : $session;
     if (strlen($config['encryption_key']) < 32) {
         exit('To use session you must set encryption key at less 32 symbols');
     }
     session_start();
     if (!isset($_SESSION['session_id'])) {
         $this->register($config['expire_time'], $config['encryption_key']);
     }
     if (!$this->isRegistered() || $this->isExpired()) {
         $this->end();
     }
 }
Esempio n. 24
0
function dbupdate_run(&$argv, &$argc)
{
    global $a, $db;
    if (is_null($a)) {
        $a = new App();
    }
    if (is_null($db)) {
        @(include ".htconfig.php");
        require_once "include/dba.php";
        $db = new dba($db_host, $db_user, $db_pass, $db_data);
        unset($db_host, $db_user, $db_pass, $db_data);
    }
    load_config('config');
    load_config('system');
    update_db($a);
}
Esempio n. 25
0
 /**
  * $isCustomPath 值为0时使用默认路径,值为1时使用$filename指定路径
  */
 public function __construct($filename, $isCustomPath = 0)
 {
     $logconfig = load_config('config', 'log');
     if ($isCustomPath == 0) {
         if (isset($logconfig['path']) && !empty($logconfig['path'])) {
             $this->log_path = $logconfig['path'] . $filename;
         } else {
             $this->log_path = APP_PATH . 'log/' . $filename;
         }
     } else {
         $this->log_path = $filename;
     }
     if (!file_exists($dirname = dirname($this->log_path))) {
         mkdir($dirname, 0777, true);
     }
 }
Esempio n. 26
0
 private function load_tree($file)
 {
     $config = load_config();
     if (isset($config["development"]["gen_routing_tree"])) {
         $this->load_routes($file);
         return true;
     }
     if (file_exists(SITE_PATH . "config/{$file}.tmp.php")) {
         include_once SITE_PATH . "config/{$file}.tmp.php";
         $this->routing_tree =& $root;
     } else {
         if (empty($root)) {
             $this->load_routes($file);
         }
     }
 }
Esempio n. 27
0
function get_conf($server_cfg, $game_name)
{
    $common_config = $server_cfg["common_config_file"];
    $hostgroup_config = sprintf($server_cfg["hostgroups_config"], $game_name);
    #print $common_config." ".$hostgroup_config;
    //        $f_common_config = fopen($common_config,"r");
    //      $f_hostgroup_config = fopen($hostgroup_config,"r");
    //    $content_common = fread($f_common_config,filesize($common_config));
    //  $content_hostgroup = fread($f_hostgroup_config,filesize($hostgroup_config));
    //$content_config = $content_common.$content_hostgroup;
    //$cfg = load_config($content_config);
    $f_common_config = file_get_contents($common_config);
    $f_hostgroup_config = file_get_contents($hostgroup_config);
    $content_config = $f_hostgroup_config . $f_hostgroup_config;
    $cfg = load_config($content_config);
    return $cfg;
}
Esempio n. 28
0
function cli_startup()
{
    global $a, $db;
    if (is_null($a)) {
        $a = new App();
    }
    if (is_null($db)) {
        @(include ".htconfig.php");
        require_once 'include/dba/dba_driver.php';
        $db = dba_factory($db_host, $db_port, $db_user, $db_pass, $db_data);
        unset($db_host, $db_port, $db_user, $db_pass, $db_data);
    }
    require_once 'include/session.php';
    load_config('system');
    $a->set_baseurl(get_config('system', 'baseurl'));
    load_hooks();
}
function load_user_config()
{
    $config = load_config(settings('user_config_filename'));
    $settings = settings();
    $hqt_settings = $settings['hqt_settings'];
    // parse user config
    foreach ($settings['user_config_items'] as $item => $var) {
        if (is_string($var) && strpos($var, ':') !== false) {
            list($subvar, $var) = explode(':', $var);
            if ($subvar == 'hqt_settings') {
                $hqt_settings[$var] = isset($config[$item]) ? $config[$item] : '';
            } else {
                if (!isset($settings[$subvar])) {
                    $settings[$subvar] = array();
                }
                $settings[$subvar][$var] = isset($config[$item]) ? $config[$item] : '';
            }
        } elseif (is_string($var)) {
            $settings[$var] = isset($config[$item]) ? $config[$item] : '';
        }
    }
    // store all
    settings($settings);
    settings('user_config', $config);
    settings('hqt_settings', $hqt_settings);
    // special content header
    if (isset($settings['pre_content_closure']) && is_callable($settings['pre_content_closure'])) {
        settings('pre_content', callback($settings['pre_content_closure']));
    }
    // special treatment for the menu
    $menu = $config['pages'];
    foreach ($menu as $page => $item) {
        if (!isset($item['url'])) {
            $menu[$page]['url'] = get_demo_url($page);
        }
        if (isset($item['items']) && !empty($item['items'])) {
            foreach ($item['items'] as $i => $subitem) {
                if (!isset($subitem['url']) && isset($subitem['hash'])) {
                    $menu[$page]['items'][$i]['url'] = get_demo_url($page, $subitem['hash']);
                }
            }
        }
    }
    settings('menu', $menu);
}
Esempio n. 30
0
 private function __construct($appkey = null, $secretKey = null)
 {
     ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . LIB_PATH . "Com" . DIRECTORY_SEPARATOR . "taobao" . DIRECTORY_SEPARATOR . 'standard' . DIRECTORY_SEPARATOR);
     require_once 'RequestCheckUtil.php';
     require_once 'TopClient.php';
     $cfg = load_config();
     $this->_topClient = new TopClient();
     if ($appkey !== null && $secretKey !== null) {
         $this->_topClient->appkey = $appkey;
         $this->_topClient->secretKey = $secretKey;
     } else {
         $this->_topClient->appkey = $cfg['taobao_appkey0'];
         $this->_topClient->secretKey = $cfg['taobao_appsecret0'];
     }
     $this->_taobao_nick = $cfg['taobao_nick'];
     $pid = explode('_', $cfg['taobao_ali_pid']);
     $this->_taobao_pid = $pid[1];
 }