本文整理汇总了PHP中log_fatal函数的典型用法代码示例。如果您正苦于以下问题:PHP log_fatal函数的具体用法?PHP log_fatal怎么用?PHP log_fatal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了log_fatal函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: csv_to_array
/**
* Convert a comma separated file into an associated array.
* The first row should contain the array keys.
*
* Example:
*
* @param string $filename Path to the CSV file
* @param string $delimiter The separator used in the file
* @return array
* @link http://gist.github.com/385876
* @author Jay Williams <http://myd3.com/>
* @copyright Copyright (c) 2010, Jay Williams
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
function csv_to_array($filename = '', $delimiter = ',', $enclosure = '"')
{
if (!file_exists($filename) || !is_readable($filename)) {
log_fatal("file {$filename} not found");
return FALSE;
}
$header = NULL;
$hcount = 0;
$lcount = 0;
$data = array();
if (($handle = fopen($filename, 'r')) !== FALSE) {
while (($row = fgetcsv($handle, 0, $delimiter, $enclosure)) !== FALSE) {
if (!$header) {
$header = $row;
$hcount = count($header);
} else {
if ($hcount != count($row)) {
echo implode(",", $row) . "\n{$filename}: array broken, header {$hcount} != row " . count($row) . "\n";
continue;
}
$data[] = array_combine($header, $row);
}
}
fclose($handle);
}
return $data;
}
示例2: cache_memcache_connect
function cache_memcache_connect()
{
if (!isset($GLOBALS['remote_cache_conns']['memcache'])) {
$host = $GLOBALS['cfg']['memcache_host'];
$port = $GLOBALS['cfg']['memcache_port'];
$start = microtime_ms();
$memcache = new Memcache();
if (!$memcache->connect($host, $port)) {
$memcache = null;
}
if (!$memcache) {
log_fatal("Connection to memcache {$host}:{$port} failed");
}
$end = microtime_ms();
$time = $end - $start;
log_notice("cache", "connect to memcache {$host}:{$port} ({$time}ms)");
$GLOBALS['remote_cache_conns']['memcache'] = $memcache;
$GLOBALS['timings']['memcache_conns_count']++;
$GLOBALS['timings']['memcache_conns_time'] += $time;
}
return $GLOBALS['remote_cache_conns']['memcache'];
}
示例3: onUnhandledException
/**
* Framework global exception handler
*
* @param Exception $e
*/
public static function onUnhandledException($e)
{
_catch($e);
log_fatal("system,error", "charcoal_global_exception_handler:" . $e->getMessage());
Charcoal_Framework::handleException($e);
}
示例4: system_instanciate_controller
/**
* Instanciates the previously chosen controller
*
* Checks what is requested: and object from the object-store, a controller via classname and loads/instaciates it.
* Will also die in AJAX requests when something weird is called or throw an exception if in normal mode.
* @param mixed $controller_id Whatever system_parse_request_path() returned
* @return ICallable Fresh Instance of whatever is needed
*/
function system_instanciate_controller($controller_id)
{
if (in_object_storage($controller_id)) {
$res = restore_object($controller_id);
} elseif (class_exists($controller_id)) {
$res = new $controller_id();
} else {
WdfException::Raise("ACCESS DENIED: Unknown controller '{$controller_id}'");
}
if (system_is_ajax_call()) {
if (!$res instanceof Renderable && !$res instanceof WdfResource) {
log_fatal("ACCESS DENIED: {$controller_id} is no Renderable");
die("__SESSION_TIMEOUT__");
}
} else {
if (!$res instanceof ICallable) {
WdfException::Raise("ACCESS DENIED: {$controller_id} is no ICallable");
}
}
return $res;
}
示例5: simpleid_start
/**
* Entry point for SimpleID.
*
* @see user_init()
*/
function simpleid_start()
{
global $xtpl, $GETPOST;
$xtpl = new XTemplate('html/template.xtpl');
$xtpl->assign('version', SIMPLEID_VERSION);
$xtpl->assign('base_path', get_base_path());
// Check if the configuration file has been defined
if (!defined('SIMPLEID_BASE_URL')) {
log_fatal('No configuration file found.');
indirect_fatal_error('No configuration file found. See the <a href="http://simpleid.koinic.net/documentation/getting-started">manual</a> for instructions on how to set up a configuration file.');
}
if (!is_dir(SIMPLEID_IDENTITIES_DIR)) {
log_fatal('Identities directory not found.');
indirect_fatal_error('Identities directory not found. See the <a href="http://simpleid.koinic.net/documentation/getting-started">manual</a> for instructions on how to set up SimpleID.');
}
if (!is_dir(SIMPLEID_CACHE_DIR) || !is_writeable(SIMPLEID_CACHE_DIR)) {
log_fatal('Cache directory not found or not writeable.');
indirect_fatal_error('Cache directory not found or not writeable. See the <a href="http://simpleid.koinic.net/documentation/getting-started">manual</a> for instructions on how to set up SimpleID.');
}
if (!is_dir(SIMPLEID_STORE_DIR) || !is_writeable(SIMPLEID_STORE_DIR)) {
log_fatal('Store directory not found or not writeable.');
indirect_fatal_error('Store directory not found or not writeable. See the <a href="http://simpleid.koinic.net/documentation/getting-started">manual</a> for instructions on how to set up SimpleID.');
}
if (@ini_get('register_globals') === 1 || @ini_get('register_globals') === '1' || strtolower(@ini_get('register_globals')) == 'on') {
log_fatal('register_globals is enabled in PHP configuration.');
indirect_fatal_error('register_globals is enabled in PHP configuration, which is not supported by SimpleID. See the <a href="http://simpleid.koinic.net/documentation/getting-started/system-requirements">manual</a> for further information.');
}
if (!bignum_loaded()) {
log_fatal('gmp/bcmath PHP extension not loaded.');
indirect_fatal_error('One or more required PHP extensions (gmp/bcmath) is not loaded. See the <a href="http://simpleid.koinic.net/documentation/getting-started/system-requirements">manual</a> for further information on system requirements.');
}
if (!function_exists('preg_match')) {
log_fatal('pcre PHP extension not loaded.');
indirect_fatal_error('One or more required PHP extensions (pcre) is not loaded. See the <a href="http://simpleid.koinic.net/documentation/getting-started/system-requirements">manual</a> for further information on system requirements.');
}
if (!function_exists('session_start')) {
log_fatal('session PHP extension not loaded.');
indirect_fatal_error('One or more required PHP extensions (session) is not loaded. See the <a href="http://simpleid.koinic.net/documentation/getting-started/system-requirements">manual</a> for further information on system requirements.');
}
if (@ini_get('suhosin.get.max_value_length') !== false && @ini_get('suhosin.get.max_value_length') < 1024) {
log_fatal('suhosin.get.max_value_length < 1024');
indirect_fatal_error('suhosin.get.max_value_length is less than 1024, which will lead to problems. See the <a href="http://simpleid.koinic.net/documentation/getting-started/system-requirements">manual</a> for further information on system requirements.');
}
openid_fix_request();
$GETPOST = array_merge($_GET, $_POST);
$q = isset($GETPOST['q']) ? $GETPOST['q'] : '';
extension_init();
user_init($q);
log_info('Session opened for "' . $q . '" [' . $_SERVER['REMOTE_ADDR'] . ', ' . gethostbyaddr($_SERVER['REMOTE_ADDR']) . ']');
// Clean stale assocations
cache_gc(SIMPLEID_ASSOC_EXPIRES_IN, 'association');
cache_gc(300, 'stateless');
simpleid_route($q);
}
示例6: error_reporting
<?php
include_once 'twitterclass1.php';
include_once 'askhost.php';
error_reporting(E_ALL);
ini_set('display_errors', 1);
$pg_host = "dbname=twitter user=capsidea password=31337 connect_timeout=30";
$dbconn = pg_connect($pg_host) or log_fatal('Could not connect to application database, please contact support.');
$tmp_dir = "/tmp/";
date_default_timezone_set("UTC");
$schemajson = "&fields=" . urlencode('[{Name: "ts", TypeName:"timestamp" },{Name: "location", TypeName:"string"}
,{Name: "userid", TypeName:"string"},{Name: "rtc", TypeName:"double" },{Name: "placecntry", TypeName:"string"},{Name: "placename", TypeName:"string"}]');
$capsidea_client_secret = "put-your-data-here";
$capsidea_permanent_access_token = "put-your-data-here";
$capsidea_appid = 3097;
function get_capsidea_data($capsidea_client_secret)
{
$ret = array();
$parsed_url = parse_url($_SERVER['HTTP_REFERER']);
$var = explode('&', $parsed_url['query']);
foreach ($var as $val) {
$x = explode('=', $val);
$arr[$x[0]] = $x[1];
}
unset($val, $x, $var, $qry, $parsed_url, $ref);
if (isset($arr["token"])) {
$token = $arr["token"];
} else {
die("cant find capsidea.com token");
}
if (36 != strlen($token)) {
示例7: extract_lzh
/**
* LZH 形式の圧縮ファイルを解凍する。
* LZH には、予めファイル名のわかっているファイルが1コだけ含まれる前提とする。
* 解凍したファイルのファイル名に大文字が含まれる場合は、小文字に変換する。
*/
function extract_lzh($lzh, $csv)
{
$cmd = LHA_COMMAND . PATH_TMP . "/" . $lzh;
$return_var = 0;
$output = array();
exec($cmd);
if ($return_var != 0) {
log_fatal("Failed to extract lzh: {$cmd}");
log_fatal($output);
exit(1);
}
$is_csv = false;
foreach (glob(PATH_TMP . "/*.{c,C}{s,S}{v,V}", GLOB_BRACE) as $file) {
$file = basename($file);
if (strtolower($file) != $csv) {
continue;
}
$is_csv = true;
log_info("Extracted: {$csv}");
if ($file == $csv) {
continue;
}
move_file(PATH_TMP . "/" . $file, PATH_TMP . "/" . $csv);
}
if ($is_csv) {
return true;
}
log_info("Faild to extract: {$csv}");
return false;
}
示例8: explode
/**
* Get a database connection.
*
* @param string $name The datasource alias.
* @return DataSource The database connection
*/
function &model_datasource($name)
{
global $MODEL_DATABASES;
if (strpos($name, "DataSource::") !== false) {
$name = explode("::", $name);
$name = $name[1];
}
if (!isset($MODEL_DATABASES[$name])) {
if (function_exists('model_on_unknown_datasource')) {
$res = model_on_unknown_datasource($name);
return $res;
}
log_fatal("Unknown datasource '{$name}'!");
$res = null;
return $res;
}
if (is_array($MODEL_DATABASES[$name])) {
list($dstype, $constr) = $MODEL_DATABASES[$name];
$dstype = fq_class_name($dstype);
$model_db = new $dstype($name, $constr);
if (!$model_db) {
WdfDbException::Raise("Unable to connect to database '{$name}'.");
}
$MODEL_DATABASES[$name] = $model_db;
}
return $MODEL_DATABASES[$name];
}
示例9: upgrade_start
/**
* Entry point for SimpleID upgrade script.
*
* @see user_init()
*/
function upgrade_start()
{
global $xtpl, $GETPOST;
$xtpl = new XTemplate('html/template.xtpl');
$xtpl->assign('version', SIMPLEID_VERSION);
$xtpl->assign('base_path', get_base_path());
$xtpl->assign('css', '@import url(' . get_base_path() . 'html/upgrade.css);');
// Check if the configuration file has been defined
if (!defined('SIMPLEID_BASE_URL')) {
indirect_fatal_error('No configuration file found. See the <a href="http://simpleid.koinic.net/documentation/getting-started">manual</a> for instructions on how to set up a configuration file.');
}
if (!is_dir(SIMPLEID_IDENTITIES_DIR)) {
indirect_fatal_error('Identities directory not found. See the <a href="http://simpleid.koinic.net/documentation/getting-started">manual</a> for instructions on how to set up SimpleID.');
}
if (!is_dir(SIMPLEID_CACHE_DIR) || !is_writeable(SIMPLEID_CACHE_DIR)) {
indirect_fatal_error('Cache directory not found or not writeable. See the <a href="http://simpleid.koinic.net/documentation/getting-started">manual</a> for instructions on how to set up SimpleID.');
}
if (!is_dir(SIMPLEID_STORE_DIR) || !is_writeable(SIMPLEID_STORE_DIR)) {
indirect_fatal_error('Store directory not found or not writeable. See the <a href="http://simpleid.koinic.net/documentation/getting-started">manual</a> for instructions on how to set up SimpleID.');
}
if (@ini_get('register_globals') === 1 || @ini_get('register_globals') === '1' || strtolower(@ini_get('register_globals')) == 'on') {
indirect_fatal_error('register_globals is enabled in PHP configuration, which is not supported by SimpleID. See the <a href="http://simpleid.koinic.net/documentation/getting-started/system-requirements">manual</a> for further information.');
}
if (!bignum_loaded()) {
log_fatal('gmp/bcmath PHP extension not loaded.');
indirect_fatal_error('One or more required PHP extensions (gmp/bcmath) is not loaded. See the <a href="http://simpleid.koinic.net/documentation/getting-started/system-requirements">manual</a> for further information on system requirements.');
}
if (!function_exists('preg_match')) {
log_fatal('pcre PHP extension not loaded.');
indirect_fatal_error('One or more required PHP extensions (pcre) is not loaded. See the <a href="http://simpleid.koinic.net/documentation/getting-started/system-requirements">manual</a> for further information on system requirements.');
}
if (!function_exists('session_start')) {
log_fatal('session PHP extension not loaded.');
indirect_fatal_error('One or more required PHP extensions (session) is not loaded. See the <a href="http://simpleid.koinic.net/documentation/getting-started/system-requirements">manual</a> for further information on system requirements.');
}
if (@ini_get('suhosin.get.max_value_length') !== false && @ini_get('suhosin.get.max_value_length') < 1024) {
log_fatal('suhosin.get.max_value_length < 1024');
indirect_fatal_error('suhosin.get.max_value_length is less than 1024, which will lead to problems. See the <a href="http://simpleid.koinic.net/documentation/getting-started/system-requirements">manual</a> for further information on system requirements.');
}
$q = isset($GETPOST['q']) ? $GETPOST['q'] : '';
$q = explode('/', $q);
extension_init();
user_init(NULL);
upgrade_user_init();
$routes = array('upgrade-selection' => 'upgrade_selection', 'upgrade-apply' => 'upgrade_apply', '.*' => 'upgrade_info');
simpleweb_run($routes, implode('/', $q));
}
示例10: pg_errormessage
if (false === $res) {
$qr = pg_errormessage($dbconn);
$line = implode(",", $this_item);
file_put_contents("{$my_data_dir}/loader.log", date(DATE_ATOM) . " (line: {$line}) client {$key} ERR {$qr} in query: {$qry} file: {$nfname}\n", FILE_APPEND);
log_fatal("ERR error in " . implode(",", array_keys($this_item)) . "values" . implode(",", $this_item));
}
if (false === stripos($this_item["case_type"], "NULL")) {
// @todo probably bug there
file_put_contents("{$my_data_dir}/paypal-m.log", serialize($this_item, true) . " \n", FILE_APPEND);
$qry = "insert into cases (cid, creason, cstatus, cmm, camount, mid, ifile ,ikey, filldate, ctype , clag) \n\t\t\tvalues ('" . pg_escape_string($this_item["mid"]) . "','" . pg_escape_string($this_item["creason"]) . "','" . pg_escape_string($this_item["cstatus"]) . "',\n\t\t\t\t\t'" . pg_escape_string($this_item["moneymove"]) . "'," . pg_escape_string($this_item["camount"]) . "," . pg_escape_string($this_item["mid"]) . ",\n\t0, {$key}, '{$case_filldate}', '" . pg_escape_string($this_item["case_type"]) . "',{$case_lag})";
$res = @pg_query($qry);
if (false === $res) {
$qr = pg_errormessage($dbconn);
$line = implode(",", $this_item);
file_put_contents("{$my_data_dir}/loader.log", date(DATE_ATOM) . " (line: {$line}) client {$key} ERR {$qr} in query: {$qry} file: {$nfname}\n", FILE_APPEND);
log_fatal("ERR error in " . implode(",", array_keys($this_item)) . "values" . implode(",", $this_item));
}
}
// case?
if ($i > 10000) {
// @pg_query("commit;");
echo ".";
ob_flush();
flush();
ob_flush();
flush();
//@pg_query("begin;");
$lines_processed = $lines_processed + $i;
$i = 0;
}
}
示例11: _db_connect
function _db_connect($cluster, $k=null){
$cluster_key = $k ? "{$cluster}-{$k}" : $cluster;
$host = $GLOBALS['cfg']["db_{$cluster}"]["host"];
$user = $GLOBALS['cfg']["db_{$cluster}"]["user"];
$pass = $GLOBALS['cfg']["db_{$cluster}"]["pass"];
$name = $GLOBALS['cfg']["db_{$cluster}"]["name"];
if ($k){
$host = $host[$k];
$name = $name[$k];
}
if (is_array($host)){
shuffle($host);
$host = $host[0];
}
if (!$host){
log_fatal("no such cluster: ".$cluster);
}
#
# try to connect
#
$start = microtime_ms();
$GLOBALS['db_conns'][$cluster_key] = @mysql_connect($host, $user, $pass, 1);
if ($GLOBALS['db_conns'][$cluster_key]){
@mysql_select_db($name, $GLOBALS['db_conns'][$cluster_key]);
@mysql_query("SET character_set_results='utf8', character_set_client='utf8', character_set_connection='utf8', character_set_database='utf8', character_set_server='utf8'", $GLOBALS['db_conns'][$cluster_key]);
}
$end = microtime_ms();
#
# log
#
log_notice('db', "DB-$cluster_key: Connect", $end-$start);
if (!$GLOBALS['db_conns'][$cluster_key] || (auth_has_role('staff') && $GLOBALS['cfg']['admin_flags_no_db'])){
log_fatal("Connection to database cluster '$cluster_key' failed");
}
$GLOBALS['timings']['db_conns_count']++;
$GLOBALS['timings']['db_conns_time'] += $end-$start;
#
# profiling?
#
if ($GLOBALS['cfg']['db_profiling']){
@mysql_query("SET profiling = 1;", $GLOBALS['db_conns'][$cluster_key]);
}
}
示例12: move_file
/**
* ファイルを移動する。
* 移動元がファイルで、移動先がディレクトリの場合は、そのディレクトリの下にファイルを移動する。
*/
function move_file($src, $trg)
{
if (!is_file($src) && !is_dir($src)) {
log_fatal("Faild to rename: {$src} => {$trg} -- missing {$src}");
exit(1);
}
if (is_file($src) && is_dir($trg)) {
$base_name = basename($src);
$trg .= "/{$base_name}";
}
if (is_dir($trg)) {
rmdirs(array($trg));
} elseif (is_file($trg)) {
unlink_files(array($trg));
}
if (!rename($src, $trg)) {
log_fatal("Faild to rename: {$src} => {$trg}");
exit(1);
}
}
示例13: pg_connect
$dbconn = pg_connect($pg_host) or die('Could not connect: ' . pg_last_error());
$key = (int) $_GET["key"];
//$_FILES["file"]["tmp_name"]
if (!check_credentials($_GET["key"], $_GET["hash"], $dbconn)) {
log_fatal("ERR hash incorrect for key={$key}, your hash: " . $_GET["hash"]);
}
//if ((123!=$key)||(123!=$_GET["hash"])) die("ERR hash incorrect for key=$key, your hash: ".$_GET["hash"]);
if (isset($_GET["truncate"])) {
// truncate all
@pg_query("delete from merchant where ikey={$key};");
@pg_query("commit;");
log_fatal("all customer merchant records deleted");
}
if (strtolower($_SERVER['REQUEST_METHOD']) != 'post' || empty($_FILES)) {
// file_put_contents($my_data_dir."/paypal-m.log", date(DATE_ATOM)."merchant $key no file attached\n", FILE_APPEND);
log_fatal("ERR no file attached");
}
// это тут, чтобы работал truncate
//$startdate=date("Y-m-d H:00:00O",strtotime($_GET["startdate"]));
//$enddate=date("Y-m-d H:00:00O",strtotime($_GET["enddate"]));
$d = "";
foreach ($_FILES as $this_item) {
$fname = $this_item["tmp_name"];
$rname = $this_item["name"];
$fsize = $this_item["size"];
if ($fsize > 20000000) {
// too big file
file_put_contents($my_data_dir . "/paypal-m.log", date(DATE_ATOM) . "merchant too big file {$key} {$rname} {$fsize}\n", FILE_APPEND);
die("ERR too large file, please use bz2 to compress it");
}
break;
示例14: log_fatal
} else {
log_fatal("no reports");
}
}
// of update dataset
if (FALSE === strpos($_GET["type"], "deleteSchema")) {
mylog("callback ERR. no method");
die("ERR unknown method");
}
// @todo check $capsidea_client_secret
$ikey = (int) $_GET["obj_key"];
if (0 == $ikey) {
mylog("delete ERR. ikey=0 ");
log_fatal("ERR user not found");
}
$dbconn = pg_connect($pg_host) or log_fatal('Could not connect to DB');
// . pg_last_error())
// remove if linked
$result = @pg_query("select * from client where ikey={$ikey} and iparent>0");
if (@pg_num_rows($result) > 0) {
// remove child
$row = pg_fetch_assoc($result);
$parent = (int) $row['iparent'];
@pg_free_result($result);
@pg_query("delete from client where ikey={$ikey}");
mylog("child removed: {$ikey} parent {$parent}");
//@pg_query("update client set active=1 where ikey=$ikey");
// is this parent disabled and dont have childs?
$ikey = $parent;
$result = @pg_query("select * from client where ikey={$ikey} and active=0");
if (0 == @pg_num_rows($result)) {
示例15:
<?
#
# $Id$
#
include('include/init.php');
#
# this is so we can test the logging output
#
if ($_GET['log_test']){
log_error("This is an error!");
log_fatal("Fatal error!");
}
#
# this is so we can test the HTTP library
#
if ($_GET['http_test']){
$ret = http_get("http://google.com");
}
#
# output
#