本文整理汇总了PHP中Core::RaiseWarning方法的典型用法代码示例。如果您正苦于以下问题:PHP Core::RaiseWarning方法的具体用法?PHP Core::RaiseWarning怎么用?PHP Core::RaiseWarning使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Core
的用法示例。
在下文中一共展示了Core::RaiseWarning方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: GetFileMimeType
public static function GetFileMimeType($path)
{
if (file_exists($path)) {
try {
if (class_exists("finfo")) {
// Probe magick database file
$magic_db_path = dirname(__FILE__) . "/magic";
if (!file_exists($magic_db_path)) {
$magic_db_path = "/usr/share/file/magic";
}
// Create fifo instance
$finfo = new finfo(FILEINFO_MIME, $magic_db_path);
if ($finfo) {
$retval = @$finfo->file($path);
} else {
Core::RaiseError("Cannot open FIFO database. Tried {$magic_db_path}", E_ERROR);
}
return $retval;
} elseif (function_exists("mime_content_type")) {
return mime_content_type($path);
} else {
Core::RaiseError("Cannot determine file mime type.", E_ERROR);
return "";
}
} catch (Exception $e) {
Core::RaiseError($e->getMessage(), E_ERROR);
}
} else {
Core::RaiseWarning("File not found.");
return "";
}
}
示例2: libwebta_error_handler
function libwebta_error_handler($errno, $errstr, $errfile, $errline)
{
$message = "Error {$errno} {$errstr}, in {$errfile}:{$errline}";
switch ($errno) {
case E_CORE_ERROR:
case E_ERROR:
case E_USER_ERROR:
Core::ThrowException($message, $errno);
break;
case E_USER_WARNING:
Core::ThrowException($message, E_USER_WARNING);
break;
case E_USER_NOTICE:
break;
default:
if (error_reporting() & $errno)
Core::RaiseWarning($message);
break;
}
}
示例3: GetFSBlockSize
/**
* Get filesystem block size
* @access public
* @param string $device Device
* @return int block size in bytes
*/
public function GetFSBlockSize($device)
{
$retval = $this->Shell->QueryRaw("/sbin/dumpe2fs {$device} 2>/dev/null | grep \"Block size\" | awk '{print \$3}'");
if (!is_int($retval)) {
Core::RaiseWarning(_("Cannot determine filesystem block size"));
$retval = false;
}
return $retval;
}
示例4: UploadFromURL
/**
* Upload file from URL
*
* @param string $url
* @return bool
* @todo Pass custom headers, like User-Agent
*/
public function UploadFromURL($url, $headers = array())
{
$urlinfo = parse_url($url);
$file = array("name" => $this->NormalizeFileName(basename($url)));
// Open socket connection
$sock = @fsockopen($urlinfo['host'], $urlinfo["port"] ? $urlinfo["port"] : 80, $errno, $errstr, 10);
@stream_set_blocking($sock, 1);
// If cannot open socket connection raise warning and return false
if (!$sock) {
$this->RaiseWarning(_("Failed to copy a file. Cannot connect to " . $urlinfo['host'] . "."), false);
return false;
} else {
if (substr($urlinfo['path'], 0, 1) != '/') {
$urlinfo['path'] = "/{$urlinfo['path']}";
}
// Define request
$request = "GET " . $urlinfo['path'] . ($urlinfo['query'] ? "?{$urlinfo['query']}" : "") . " HTTP/1.1\r\n";
if (count($headers) > 0 && is_array($headers)) {
$request .= implode("\r\n", $headers) . "\r\n";
}
$request .= "Host: {$urlinfo['host']}\r\n";
$request .= "Connection: Close\r\n\r\n";
// Send request
@fwrite($sock, $request);
$headers = "";
while ($str != "\r\n") {
$str = @fgets($sock, 2048);
$headers .= $str;
}
if (stristr($headers, "200 OK")) {
while (!feof($sock) && !$meta['eof']) {
@file_put_contents($this->Destination, @fgets($sock, 2048), FILE_APPEND);
$meta = stream_get_meta_data($sock);
}
// Generate real file info
$this->File = array("name" => basename($url), "type" => IOTool::GetFileMimeType($this->Destination), "size" => @filesize($this->Destination));
// Validate real file info
if ($this->Validate()) {
if (file_exists($this->Destination)) {
return true;
} else {
Core::RaiseError(_("Cannot write file."), E_ERROR);
}
}
@unlink($this->Destination);
return false;
} else {
$tmp = split("\n", $headers);
$error = trim($tmp[0]);
Core::RaiseWarning($error);
return false;
}
@fclose($sock);
}
}
示例5: ParseTimeToSeconds
/**
* Convert a BIND-style time(1D, 2H, 15M) to seconds.
*
* @param string $time Time to convert.
* @return int time in seconds on success, PEAR error on failure.
*/
function ParseTimeToSeconds($time)
{
if (is_numeric($time))
{
//Already a number. Return.
return $time;
}
else
{
// TODO: Add support for multiple \d\s
$split = preg_split("/([0-9]+)([a-zA-Z]+)/", $time, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
if (count($split) != 2)
Core::RaiseWarning(sprintf(_("Unable to parse time. %d"), $time));
list($num, $what) = $split;
switch (strtoupper($what))
{
case 'S': //Seconds
$times = 1;
break;
case 'M': //Minute
$times = 1 * 60;
break;
case 'H': //Hour
$times = 1 * 60 * 60;
break;
case 'D': //Day
$times = 1 * 60 * 60 * 24;
break;
case 'W': //Week
$times = 1 * 60 * 60 * 24 * 7;
break;
default:
Core::RaiseWarning(sprintf(_("Unable to parse time %s"), $time));
break;
}
$time = $num * $times;
return $time;
}
}
示例6: MXDNSRecord
case "MX":
$record = new MXDNSRecord($record["rkey"], $record["rvalue"], $record["ttl"], $record["rpriority"]);
$Zone->AddRecord($record);
break;
}
}
}
foreach ($Zone->Records as $record)
{
if (!($record instanceof CNAMEDNSRecord))
{
if (in_array($record->Name, $CNAMERecords))
{
Core::RaiseWarning(sprintf(_("CNAME RRs '%s' cannot have any other RRs with the same name."), $record->Name));
$error = true;
}
}
}
$zonecontent = $Zone->__toString();
if (Core::HasWarnings())
$error = true;
}
if ($error)
{
$db->RollbackTrans();
Log::Log(sprintf(_("Failed to generate DNS zone for '%s'"), $post_zonename), E_ERROR);
示例7: CreateObject
/**
* Create new object on S3 Bucket
*
* @param string $object_path
* @param string $bucket_name
* @param string $filename
* @param string $object_content_type
* @param string $object_permissions
* @return bool
*/
public function CreateObject($object_path, $bucket_name, $filename, $object_content_type, $object_permissions = "public-read")
{
if (!file_exists($filename))
{
Core::RaiseWarning("{$filename} - no such file.");
return false;
}
$HttpRequest = new HttpRequest();
$HttpRequest->setOptions(array( "redirect" => 10,
"useragent" => "LibWebta AWS Client (http://webta.net)"
)
);
$timestamp = $this->GetTimestamp(true);
$data_to_sign = array("PUT", "", $object_content_type, $timestamp, "x-amz-acl:{$object_permissions}","/{$bucket_name}/{$object_path}");
$signature = $this->GetRESTSignature($data_to_sign);
$HttpRequest->setUrl("http://{$bucket_name}.s3.amazonaws.com/{$object_path}");
$HttpRequest->setMethod(constant("HTTP_METH_PUT"));
$headers["Content-type"] = $object_content_type;
$headers["x-amz-acl"] = $object_permissions;
$headers["Date"] = $timestamp;
$headers["Authorization"] = "AWS {$this->AWSAccessKeyId}:{$signature}";
$HttpRequest->addHeaders($headers);
$HttpRequest->setPutFile($filename);
try
{
$HttpRequest->send();
$info = $HttpRequest->getResponseInfo();
if ($info['response_code'] == 200)
return true;
else
{
$xml = @simplexml_load_string($HttpRequest->getResponseBody());
return $xml->Message;
}
}
catch (HttpException $e)
{
Core::RaiseWarning($e->__toString(), E_ERROR);
return false;
}
}
示例8: ParseTimeToSeconds
/**
* Converts a BIND-style timeout(1D, 2H, 15M) to seconds.
*
* @param string $time Time to convert.
* @return int time in seconds on success, PEAR error on failure.
*/
function ParseTimeToSeconds($time)
{
if (is_numeric($time)) {
//Already a number. Return.
return $time;
} else {
$pattern = '/([0-9]+)([a-zA-Z]+)/';
$split = preg_split($pattern, $time, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
if (count($split) != 2) {
Core::RaiseWarning(sprintf(_("Unable to parse time. %d"), $time));
}
list($num, $what) = $split;
switch (strtoupper($what)) {
case 'S':
$times = 1;
//Seconds
break;
case 'M':
$times = 1 * 60;
//Minute
break;
case 'H':
$times = 1 * 60 * 60;
//Hour
break;
case 'D':
$times = 1 * 60 * 60 * 24;
//Day
break;
case 'W':
$times = 1 * 60 * 60 * 24 * 7;
//Week
break;
default:
Core::RaiseWarning(sprintf(_("Unable to parse time. %d"), $time));
break;
}
$time = $num * $times;
return $time;
}
}
示例9: AddClass
/**
* Add Class to REST
*
* @param string $classname
* @param string $namespace
* @return bool
*/
public function AddClass($classname, $args = array())
{
$namespace = "";
if (class_exists($classname)) {
$reflectionClass = new ReflectionClassEx($classname);
$methods = $reflectionClass->getPublicMethods();
foreach ($methods as $method) {
if ($namespace == "") {
$this->Methods[$method->getName()] = $method;
} else {
$this->Methods[$namespace][$method->getName()] = $method;
}
}
} else {
Core::RaiseWarning("Class '{$classname}' not found");
return false;
}
}
示例10: Fetch
public function Fetch($file, $notheme=false)
{
$this->HTMLResult = false;
try
{
$this->ExecRetry++;
$ch = curl_init();
if (!$notheme)
curl_setopt($ch, CURLOPT_URL, "https://{$this->Host}:2083/frontend/".$this->Theme."/{$file}");
else
curl_setopt($ch, CURLOPT_URL, "https://{$this->Host}:2083/{$file}");
curl_setopt($ch, CURLOPT_USERPWD, $this->User.":".$this->Password);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $this->ConnectTimeout);
curl_setopt($ch, CURLOPT_TIMEOUT, $this->ExecTimeout);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,0);
$res = curl_exec($ch);
$e = curl_error($ch);
// Try to Fetch again or raise warning.
if ($e)
{
if ($this->ExecRetry >= $this->ExecRetries)
Core::RaiseWarning($e);
else
{
@curl_close($ch);
$this->Fetch($file, $notheme);
}
}
@curl_close($ch);
}
catch(Exception $e)
{
Core::RaiseWarning("Failed to fetch CPanel page. ".$e->__toString());
return false;
}
if (!$res)
{
Core::RaiseWarning("Failed to fetch CPanel page. Make sure that theme name is correct.");
return false;
}
// Return
$this->HTMLResult = $res;
// Reset retries counter
$this->ExecRetry = 0;
return true;
}
示例11: ProceedToPayment
/**
* Send request to payment server
* @param float $amount
* @param integer $invoiceid
* @param string $description
* @param string $type 'single or subscription'
* @param array $extra
*
* @return bool
*/
public final function ProceedToPayment($amount, $invoiceid, $description, $type = 'single', $extra = array())
{
$merchant_reference = "REF ".implode("", explode(" ", microtime()));
$amount = $amount*100;
$request = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<JProxyPayLink>
<Message>
<Type>PreAuth</Type>
<Authentication>
<MerchantID>".CF_PAYMENTS_PROXYPAY3_MERCHANTID."</MerchantID>
<Password>".CF_PAYMENTS_PROXYPAY3_PASSWORD."</Password>
</Authentication>
<OrderInfo>
<Amount>{$amount}</Amount>
<MerchantRef>{$merchant_reference}</MerchantRef>
<MerchantDesc>".htmlspecialchars($description)."</MerchantDesc>
<Currency>{$this->CurrencySymbol}</Currency>
<CustomerEmail>{$extra["email"]}</CustomerEmail>
<Var1>InvoiceID: {$invoiceid}</Var1>
<Var2 />
<Var3 />
<Var4 />
<Var5 />
<Var6 />
<Var7 />
<Var8 />
<Var9 />
</OrderInfo>
<PaymentInfo>
<CCN>{$extra["ccn"]}</CCN>
<Expdate>{$extra["Expdate_m"]}{$extra["Expdate_Y"]}</Expdate>
<CVCCVV>{$extra["cvv"]}</CVCCVV>
<InstallmentOffset>0</InstallmentOffset>
<InstallmentPeriod>0</InstallmentPeriod>
</PaymentInfo>
</Message>
</JProxyPayLink>
";
$response = $this->SendRequest($request);
if(!$response)
return false;
$response = @simplexml_load_string($response);
if (intval($response->ERRORCODE) != 0)
{
Core::RaiseWarning(sprintf(_("Cannot proceed request. Error code: %s. Please contact Administrator."), $response->ERRORCODE));
return false;
}
else
return true;
}
示例12: __toString
/**
* Generate a text zone file
* @access public
* @return string Zone file content
*/
function __toString()
{
$this->Content = $this->Template;
if (count($this->Records) == 0)
{
Core::RaiseWarning(_("No records found"));
return "";
}
foreach ($this->RecordsSortMap as $RecordType)
{
foreach((array)$this->Records as $Record)
{
$classname = "{$RecordType}DNSRecord";
if ($Record instanceof $classname)
{
// Set TTL
if ($this->TTL && !$Record->TTL)
$Record->TTL = "";
elseif (!$Record->TTL && $RecordType != "SOA")
$Record->TTL = $Record->DefaultTTL;
// Raise Preference for MX record
if ($RecordType == "MX")
$Record->Pref = $this->RaiseMXPref($Record->Pref);
if ($RecordType == "SOA")
$soa = $Record;
$this->Content .= $Record->__toString()."\n";
}
}
}
$tags = array("{name}" => $soa->Name);
if ($this->TTL)
$tags["{ttl}"] = '$TTL '.$this->TTL;
else
$tags["{ttl}"] = "";
$this->Content = str_replace(
array_keys($tags),
array_values($tags),
$this->Content
);
return $this->Content;
}
示例13: ListZones
/**
* Return array with all zones
* @access public
* @return array $zones
*/
public function ListZones($ptr_zones = false)
{
// Delete multiline comments from named.conf
$this->Conf = preg_replace("/\\/\\*(.*?)\\*\\//ism", "", $this->Conf);
$lines = explode("\n", $this->Conf);
$retval = array();
foreach ($lines as $line) {
preg_match_all("/^[^\\/;#]*zone(.*?)['\"]+(.*?)['\"]+(.*?)\\{(.*?)\$/si", $line, $matches);
// filter local zones
if ($matches[2][0] != '' && $matches[2][0] != '.' && $matches[2][0] != 'localhost' && $matches[2][0] != 'localdomain' && !stristr($matches[2][0], "in-addr.arpa") && !stristr($matches[2][0], "ip6.arpa") && !$ptr_zones || (stristr($matches[2][0], "in-addr.arpa") || stristr($matches[2][0], "ip6.arpa")) && $ptr_zones) {
$in_zone = $matches[2][0];
}
if (preg_match("/^[^\\/;#]*}/", $line, $matches)) {
$in_zone = false;
}
if ($in_zone) {
preg_match_all("/^[^\\/;#]*file(.*?)['\"]+(.*?)['\"]+(.*?)\$/si", $line, $matches);
if ($matches[2][0]) {
$content = $this->GetZoneFileContent($matches[2][0]);
if ($content) {
$retval[$in_zone] = $content;
} else {
Core::RaiseWarning("Cannot get '{$matches[2][0]}'");
}
}
}
}
return $retval;
}
示例14: Start
/**
* Start virtualhost
*
* @return bool
*/
public function Start()
{
$res = $this->SSH2->Exec("{$this->VentriloPath}/vent.sh start {$this->Port}", "\004");
if ($res)
{
if (stristr($res, "Cannot find"))
{
Core::RaiseWarning(_("Cannot find virtualhost"));
return false;
}
elseif (stristr($res, "Cannot start server on"))
{
$lines = explode("\n", $res);
$error = $lines[count($lines)-5]."\n".$lines[count($lines)-4];
Core::RaiseWarning($error);
return false;
}
elseif (stristr($res, "Done."))
return true;
else
{
Core::RaiseWarning(_("Unknown error"));
return false;
}
}
else
return false;
}
示例15: FetchRecord
/**
* Whois request
*
* @param string $host
* @return string
*/
public function FetchRecord($host)
{
// Cut off www
if(substr($host, 0, 4) == 'www.')
$host = substr($host, 4);
// Extract TLD and find a suitable whois server
$pi = pathinfo($host);
$whoisinfo = $this->Servers[$pi["extension"]];
if (!$whoisinfo[0])
{
Core::RaiseWarning(sprintf(_("No custom whois server defined for %s. Using default one."), $host));
$hostparam = "";
}
else
$hostparam = " -h {$whoisinfo[0]}";
// Sanitize
$host = escapeshellcmd($host);
// Execute Shell command and Get result
$retval = $this->Shell->QueryRaw("{$this->WhoisBinPath} {$hostparam} {$host}");
// Check domain name existense and return false if domain NOT exists or Raw whois data about domain
if (stristr($retval, $whoisinfo[1]) ||
stristr($retval, "hostname nor servname provided") ||
preg_match("/((No entries found)|(No match)|(No Data Found)|(No match for)|(No data found))/si", $retval)
)
return false;
else
return $retval;
}