本文整理汇总了PHP中warn函数的典型用法代码示例。如果您正苦于以下问题:PHP warn函数的具体用法?PHP warn怎么用?PHP warn使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了warn函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ReadData
/**
* @param string $targetString The string from the config file
* @param the $map A reference to the map object (redundant)
* @param the $mapItem A reference to the object this target is attached to
* @return array invalue, outvalue, unix timestamp that the data was valid
*/
function ReadData($targetString, &$map, &$mapItem)
{
$data[IN] = null;
$data[OUT] = null;
$data_time = 0;
$matches = 0;
if (preg_match("/^time:(.*)\$/", $targetString, $matches)) {
$timezone = $matches[1];
$offset = "now";
if (preg_match("/^([^:]+):(.*)\$/", $timezone, $matches2)) {
$timezone = $matches2[1];
$offset = $matches2[2];
// test that the offset is valid
$timestamp = strtotime($offset);
if ($timestamp === false || $timestamp === -1) {
warn("Time ReadData: Offset String ({$offset}) is bogus - ignoring [WMTIME03]\n");
$offset = "now";
}
}
$timezone_l = strtolower($timezone);
if (array_key_exists($timezone_l, $this->timezones)) {
$tz = $this->timezones[$timezone_l];
wm_debug("Time ReadData: Timezone exists: {$tz}\n");
$dateTime = new DateTime($offset, new DateTimeZone($tz));
$mapItem->add_note("time_time12", $dateTime->format("h:i"));
$mapItem->add_note("time_time12ap", $dateTime->format("h:i A"));
$mapItem->add_note("time_time24", $dateTime->format("H:i"));
$mapItem->add_note("time_timet", $dateTime->format("U"));
$mapItem->add_note("time_timezone", $tz);
$data[IN] = $dateTime->format("H");
$data[OUT] = $dateTime->format("i");
$data_time = time();
$matches++;
}
if ($matches == 0) {
wm_warn("Time ReadData: Couldn't recognize {$timezone} as a valid timezone name [WMTIME02]\n");
}
} else {
// some error code to go in here
wm_warn("Time ReadData: Couldn't recognize {$targetString} \n");
}
wm_debug("Time ReadData: Returning (" . WMUtility::valueOrNull($data[IN]) . "," . WMUtility::valueOrNull($data[OUT]) . ",{$data_time})\n");
return array($data[IN], $data[OUT], $data_time);
}
示例2: ReadData
function ReadData($targetstring, &$map, &$item)
{
$data[IN] = NULL;
$data[OUT] = NULL;
$data_time = 0;
$itemname = $item->name;
$matches = 0;
if (preg_match("/^time:(.*)\$/", $targetstring, $matches)) {
$timezone = $matches[1];
$timezone_l = strtolower($timezone);
$timezone_identifiers = DateTimeZone::listIdentifiers();
foreach ($timezone_identifiers as $tz) {
if (strtolower($tz) == $timezone_l) {
debug("Time ReadData: Timezone exists: {$tz}\n");
$dateTime = new DateTime("now", new DateTimeZone($tz));
$item->add_note("time_time12", $dateTime->format("h:i"));
$item->add_note("time_time12ap", $dateTime->format("h:i A"));
$item->add_note("time_time24", $dateTime->format("H:i"));
$item->add_note("time_timezone", $tz);
$data[IN] = $dateTime->format("H");
$data_time = time();
$data[OUT] = $dateTime->format("i");
$matches++;
}
}
if ($matches == 0) {
warn("Time ReadData: Couldn't recognize {$timezone} as a valid timezone name [WMTIME02]\n");
}
} else {
// some error code to go in here
warn("Time ReadData: Couldn't recognize {$targetstring} \n");
}
debug("Time ReadData: Returning (" . ($data[IN] === NULL ? 'NULL' : $data[IN]) . "," . ($data[OUT] === NULL ? 'NULL' : $data[OUT]) . ",{$data_time})\n");
return array($data[IN], $data[OUT], $data_time);
}
示例3: preTestPost
function preTestPost(ISblamPost $p)
{
$text = preg_replace('/\\[:..:\\]\\s+/', ' ', $p->getRawContent());
if (strlen($text) < 40) {
$text .= $p->getAuthorURI();
}
if (strlen($text) < 40) {
$text .= $p->getAuthorEmail();
}
if (strlen($text) < 40) {
$text .= $p->getAuthorName();
}
if (strlen($text) < 20) {
$text .= $p->getAuthorIP();
}
if (strlen($text) < 10) {
$this->checksum = NULL;
return;
}
$text = preg_replace(array('/[.,\\s!:;()-]+/', '/([a-f0-9]{1,3}[a-f]{1,6}[0-9]{1,6})+/', '/\\d\\d{1,8}/'), array(' ', 'H', 'D'), strtolower($text));
d($text, 'normalized text');
$this->length = strlen($text);
$this->checksum = md5($text);
if (!$this->db->exec(sprintf("/*maxtime5*/INSERT INTO dupes (checksum,count,expires,ip) VALUES(UNHEX('%s'),1,%d,%u)\n\t\t\tON DUPLICATE KEY UPDATE count = 1 + IF(expires < %d,CEIL(count/10),count), expires = GREATEST(expires + 3600*6, %d)", $this->checksum, time() + 3600 * 18, ip2long($p->getAuthorIP()), time(), time() + 3600 * 18))) {
warn($this->db->errorInfo());
}
}
示例4: convertToArray
private function convertToArray($dat)
{
if (!function_exists('mb_convert_encoding') || !($conv = mb_convert_encoding($dat, "UTF-8", "UTF-8,ISO-8859-2,Windows-1252"))) {
$conv = @iconv("UTF-8", "UTF-8", $dat);
if ($conv === false || strlen($conv) < strlen($dat) * 0.9) {
$conv = @iconv("ISO-8859-2", "UTF-8//IGNORE", $dat);
if ($conv === false || strlen($conv) < strlen($dat)) {
warn($conv, "A total failure, not even ISO!");
$conv = utf8_encode($dat);
} else {
d($conv, "got iso converted");
}
} else {
d($conv, "got UTF-8 converted");
}
}
$dat = strtr($conv, array('ą' => 'ą', 'ę' => 'ę', 'ó' => 'ó', 'ż' => 'ż', 'ś' => 'ś', 'ć' => 'ć', 'ź' => 'ź', 'ń' => 'ń', 'Ą' => 'Ą', 'Ę' => 'Ę', 'Ó' => 'Ó', 'Ż' => 'Ż', 'Ś' => 'Ś', 'Ć' => 'Ć', 'Ź' => 'Ź', 'Ń' => 'Ń'));
$dat = explode("", $dat);
$cnt = count($dat);
$fields = array();
for ($i = 1; $i < $cnt; $i += 2) {
$fields[$dat[$i - 1]] = $dat[$i];
}
return $fields;
}
示例5: ReadData
function ReadData($targetstring, &$map, &$item)
{
$data[IN] = NULL;
$data[OUT] = NULL;
$data_time = 0;
if (preg_match("/^!(.*)\$/", $targetstring, $matches)) {
$command = $matches[1];
debug("ExternalScript ReadData: Running {$command}\n");
// run the command here
if (($pipe = popen($command, "r")) === false) {
warn("ExternalScript ReadData: Failed to run external script. [WMEXT01]\n");
} else {
$i = 0;
while ($i < 5 && !feof($pipe)) {
$lines[$i++] = fgets($pipe, 1024);
}
pclose($pipe);
if ($i == 5) {
$data[IN] = floatval($lines[0]);
$data[OUT] = floatval($lines[1]);
$item->add_hint("external_line1", $lines[0]);
$item->add_hint("external_line2", $lines[1]);
$item->add_hint("external_line3", $lines[2]);
$item->add_hint("external_line4", $lines[3]);
$data_time = time();
} else {
warn("ExternalScript ReadData: Not enough lines read from external script ({$i} read, 4 expected) [WMEXT02]\n");
}
}
}
debug("ExternalScript ReadData: Returning (" . ($data[IN] === NULL ? 'NULL' : $data[IN]) . "," . ($data[OUT] === NULL ? 'NULL' : $data[OUT]) . ",{$data_time})\n");
return array($data[IN], $data[OUT], $data_time);
}
示例6: ReadData
/**
* @param string $targetString The string from the config file
* @param the $map A reference to the map object (redundant)
* @param the $mapItem A reference to the object this target is attached to
* @return array invalue, outvalue, unix timestamp that the data was valid
*/
function ReadData($targetString, &$map, &$mapItem)
{
$data[IN] = null;
$data[OUT] = null;
$data_time = 0;
if (preg_match("/^time:(.*)\$/", $targetString, $matches)) {
$timezone = $matches[1];
$offset = "now";
if (preg_match("/^([^:]+):(.*)\$/", $timezone, $matches2)) {
$timezone = $matches2[1];
$offset = $matches2[2];
// test that the offset is valid
$timestamp = strtotime($offset);
if ($timestamp === false || $timestamp === -1) {
warn("Time ReadData: Offset String ({$offset}) is bogus - ignoring [WMTIME03]\n");
$offset = "now";
}
}
list($required_time, $timezone_name) = $this->getTimeForTimeZone($timezone, $offset);
$data = $this->populateTimeData($mapItem, $required_time, $timezone_name);
$data_time = time();
} else {
// some error code to go in here
wm_warn("Time ReadData: Couldn't recognize {$targetString} \n");
}
wm_debug("Time ReadData: Returning (" . WMUtility::valueOrNull($data[IN]) . "," . WMUtility::valueOrNull($data[OUT]) . ",{$data_time})\n");
return array($data[IN], $data[OUT], $data_time);
}
示例7: ReadData
function ReadData($targetstring, &$map, &$item)
{
$data[IN] = NULL;
$data[OUT] = NULL;
$data_time = 0;
if (preg_match("/^dbplug:([^:]+)\$/", $targetstring, $matches)) {
$database_user = $map->get_hint('dbplug_dbuser');
$database_pass = $map->get_hint('dbplug_dbpass');
$database_name = $map->get_hint('dbplug_dbname');
$database_host = $map->get_hint('dbplug_dbhost');
$key = mysql_real_escape_string($matches[1]);
$SQL = "select in,out from table where host={$key} LIMIT 1";
if (mysql_connect($database_host, $database_user, $database_pass)) {
if (mysql_select_db($database_name)) {
$result = mysql_query($SQL);
if (!$result) {
warn("dbsample ReadData: Invalid query: " . mysql_error() . "\n");
} else {
$row = mysql_fetch_assoc($result);
$data[IN] = $row['in'];
$data[OUT] = $row['out'];
}
} else {
warn("dbsample ReadData: failed to select database: " . mysql_error() . "\n");
}
} else {
warn("dbsample ReadData: failed to connect to database server: " . mysql_error() . "\n");
}
$data_time = now();
}
debug("RRD ReadData: Returning (" . ($data[IN] === NULL ? 'NULL' : $data[IN]) . "," . ($data[OUT] === NULL ? 'NULL' : $data[IN]) . ",{$data_time})\n");
return array($data[IN], $data[OUT], $data_time);
}
示例8: collectArtDirectories
private function collectArtDirectories($path)
{
global $config;
$this->directories[] = $path . '/';
if (count($this->directories) % 3 == 0) {
echo '.';
}
$dir = @opendir($path);
if (!$dir) {
if ($config['art.error.when.missing']) {
error("Unable to locate art directory: {$path}");
}
echo "\n";
warn("Unable to locate art directory: {$path}");
return;
}
$dirs = array();
while (false !== ($file = readdir($dir))) {
if ($file == '.' || $file == '..') {
continue;
}
if (!is_dir($path . '/' . $file)) {
continue;
}
$dirs[] = $path . '/' . $file;
}
closedir($dir);
foreach ($dirs as $path) {
$this->collectArtDirectories($path);
}
}
示例9: authenticate
function authenticate($params)
{
assert(isset($params['user']) && isset($params['pass']));
$contactId = $params['user'];
$token = $params['pass'];
$contact = DatabaseHelper::getInstance()->getContactByIdentifier($contactId, $identifier);
if ($contact) {
info(__METHOD__ . ': Contact ' . $contact['Id'] . ' succesfully authenticated');
return array('Id' => $contact['Id'], 'Role' => $contact['Role']);
} else {
warn(__METHOD__ . ': Authentication failed for contact "' . $contactId . '" and token "' . $identifier . '"');
return false;
}
}
示例10: readConfig
protected function readConfig(array $ini)
{
if (!empty($ini['tlds'])) {
SblamURI::init($ini['tlds'], $this->services->getDB());
} else {
warn('tlds not given!');
}
if (!empty($ini['dns'])) {
AsyncDNS::init(preg_split('![\\s,]+!', $ini['dns'], NULL, PREG_SPLIT_NO_EMPTY));
} else {
warn('dns not given!');
}
foreach ($ini as $name => $settings) {
if (!is_array($settings) || $name == 'db') {
continue;
}
if (!empty($settings['disabled']) || isset($settings['enabled']) && !$settings['enabled']) {
/*d($name,'disabled');*/
continue;
}
try {
include_once "tests/" . strtolower($name) . ".php";
$classname = "SblamTest" . ucfirst($name);
if (!class_exists($classname)) {
warn($name, "Problem loading test plugin");
}
$info = call_user_func(array($classname, 'info'));
if (!empty($info['remote']) && isset($ini['remote']) && !$ini['remote']) {
d($info, 'Its a remote service, remote disabled, skipping');
continue;
}
if (!empty($info['unsupported'])) {
d($info, 'unsupported in this configuration');
continue;
}
$test = new $classname($settings, $this->services);
if (!$test instanceof ISblamTest) {
warn($test, 'Not a test');
continue;
}
//d($classname,"instantiated");
$this->addTest($test, isset($settings['phase']) ? $settings['phase'] : 10);
} catch (Exception $e) {
warn($e, "Failed to initialize plugin {$name}");
}
}
return true;
}
示例11: initInternal
public function initInternal()
{
$this->_regions = DatabaseHelper::getInstance()->getRegions();
if (isset($_GET['regionSelector']) && array_key_exists($_GET['regionSelector'], $this->_regions)) {
$this->_currentRegion = $this->_regions[$_GET['regionSelector']];
// Set the cookie for 14 days
if (!setcookie('region', $_GET['regionSelector'], time() + TWO_WEEKS, getConfiguration('public.path') . '/')) {
warn(__METHOD__ . ': Could not set cookie for user! Output already exists.');
}
unset($_GET['region']);
} else {
if (isset($_COOKIE['region']) && array_key_exists($_COOKIE['region'], $this->_regions)) {
$this->_currentRegion = $this->_regions[$_COOKIE['region']];
// Update cookie expiry time
setcookie('region', $_COOKIE['region'], time() + TWO_WEEKS, getConfiguration('public.path') . '/');
} else {
$this->_currentRegion = $this->_regions[self::getDefaultRegion()];
}
}
info(__METHOD__ . ' region selected: ' . $this->_currentRegion['Id'] . ' (' . $this->_currentRegion['Name'] . ')');
}
示例12: severity
private function severity($ip)
{
$rev = SblamURI::gethostbyaddr($ip);
if (is_array($rev)) {
warn($rev, "gethostbyaddr returned array!?");
$rev = reset($rev);
}
if (!$rev) {
return 3;
}
if (preg_match('/(^|[.-])(vp[sn]|srv)[.\\d-]|(^|\\.)(colo|dedi?)[-.]|dedic|resell|serv(er|[.\\d-])|^ns\\d*\\.|^mail\\d*\\.|multicast|invalid|unknown/', $rev)) {
return 2;
}
if (preg_match('/internetdsl\\.|static/', $rev) || preg_match('/^[^\\d]+$/', $rev) || strlen($rev) < 10) {
return 1.5;
}
if (preg_match('/^nat[\\d.-]|cache|proxy|gprs[^a-z]|dynamic|\\.dhcp\\.|\\.sta\\.|ppp[\\d.-]|\\.dyn\\.|(^|[.-])adsl[.0-9-]/', $rev)) {
return 0.8;
}
return 1;
}
示例13: authenticate
function authenticate($params)
{
assert('isset($params["email"]) && isset($params["password"])');
// TODO: A primitive brute-force defense?
// We must call buildEmail as we may have explicitely added the
// domain suffix during registration
$email = Utils::buildEmail($params['email']);
$pass = $params['password'];
// Created a hashed hexadecimal string, use the salt if possible
$hashed = Utils::hashPassword($pass);
$contact = DatabaseHelper::getInstance()->getContactByEmail($email);
if ($contact !== false) {
if ($contact['Identifier'] === $hashed) {
info(__METHOD__ . ': Contact ' . $contact['Id'] . ' succesfully authenticated');
return array('Id' => $contact['Id'], 'Role' => $contact['Role']);
} else {
warn(__METHOD__ . ': Contact ' . $contact['Id'] . ' failed to authorize: wrong password');
}
}
return false;
}
示例14: addDecklist
public function addDecklist (Decklist $decklist) {
global $config;
if (!$this->decklistOnlyOutput) $this->addCards($decklist->cards);
if ($this->decklistOnlyOutput || $config['render.decklist']) {
$count = count($decklist->cards);
if ($count <= 75) {
// 75 or less and we assume this is a standard 60 card deck with upto a 15
// card sideboard.
$decklistRenderer = new DecklistRenderer();
$decklistRenderer->cards = $decklist->cards;
$decklistRenderer->writer = $this;
$decklistRenderer->outputDir = $config['output.directory'];
$decklistRenderer->outputName = 'Decklist - ' . $decklist->name;
$this->renderers[] = $decklistRenderer;
} else {
// Enough cards for a multi page list.
$cardsPerDeckpage = isset($config['output.decklist.cardsperpage']) ? $config['output.decklist.cardsperpage'] : 50;
echo "\n";
warn('Large/Highlander deck detected, going to ' . $cardsPerDeckpage . ' card per page lists.');
$cardsRendered = 0 ;
while ($cardsRendered < $count) {
// slice out each card block.
$cardPage = array_slice($decklist->cards, $cardsRendered, $cardsPerDeckpage);
$decklistRenderer = new DecklistRenderer();
$decklistRenderer->cards = $cardPage;
$decklistRenderer->wholeDeck = $decklist->cards;
$decklistRenderer->writer = $this;
$decklistRenderer->outputDir = $config['output.directory'];
$decklistRenderer->outputName = 'Decklist - ' . $decklist->name . ' page ' . (floor($cardsRendered / $cardsPerDeckpage) + 1);
$this->renderers[] = $decklistRenderer;
$cardsRendered += $cardsPerDeckpage;
}
}
}
}
示例15: index
function index()
{
$pdo = $this->services->getDB();
$sblam = $this->getSblam();
// inits urls
$table = 'plonker';
// FIXME: read config!
$accumulate = array();
$max = 10;
while ($max--) {
foreach ($pdo->query("SELECT ip,added from {$table} where flags=0 order by rand() limit 2000") as $r) {
try {
$ip = long2ip($r['ip']);
$rev = preg_replace('!(\\d+)\\.(\\d+)\\.(\\d+)\\.(\\d+)!', '\\4.\\3.\\2.\\1.dul.dnsbl.sorbs.net', $ip);
$r['rev1'] = $rev;
SblamURI::gethostbynameasync($rev);
$rev = preg_replace('!(\\d+)\\.(\\d+)\\.(\\d+)\\.(\\d+)!', '\\4.\\3.\\2.\\1.korea.services.net', $ip);
$r['rev2'] = $rev;
SblamURI::gethostbynameasync($rev);
$accumulate[] = $r;
usleep(50000);
if (count($accumulate) >= 20) {
foreach ($accumulate as $r) {
$res = SblamURI::gethostbyname($r['rev1']) ? 'dul' : 'nodul';
$res .= ',' . (SblamURI::gethostbyname($r['rev2']) ? 'wild' : 'nowild');
$q = "update {$table} set flags = '{$res}', added = added where ip = {$r['ip']}";
d($q);
if (!$pdo->query($q)) {
warn($pdo->errorInfo());
}
}
$accumulate = array();
}
} catch (Exception $e) {
}
}
}
return array('redirect' => '/admin/plonker');
}