本文整理汇总了PHP中ereg_replace函数的典型用法代码示例。如果您正苦于以下问题:PHP ereg_replace函数的具体用法?PHP ereg_replace怎么用?PHP ereg_replace使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ereg_replace函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ImageManipulation
/**
* Contructor method. Will create a new image from the target file.
* Accepts an image filename as a string. Method also works out how
* big the image is and stores this in the $image array.
*
* @param string $imgFile The image filename.
*/
public function ImageManipulation($imgfile)
{
//detect image format
$this->image["format"] = ereg_replace(".*\\.(.*)\$", "\\1", $imgfile);
$this->image["format"] = strtoupper($this->image["format"]);
// convert image into usable format.
if ($this->image["format"] == "JPG" || $this->image["format"] == "JPEG") {
//JPEG
$this->image["format"] = "JPEG";
$this->image["src"] = ImageCreateFromJPEG($imgfile);
} elseif ($this->image["format"] == "PNG") {
//PNG
$this->image["format"] = "PNG";
$this->image["src"] = imagecreatefrompng($imgfile);
} elseif ($this->image["format"] == "GIF") {
//GIF
$this->image["format"] = "GIF";
$this->image["src"] = ImageCreateFromGif($imgfile);
} elseif ($this->image["format"] == "WBMP") {
//WBMP
$this->image["format"] = "WBMP";
$this->image["src"] = ImageCreateFromWBMP($imgfile);
} else {
//DEFAULT
return false;
}
// Image is ok
$this->imageok = true;
// Work out image size
$this->image["sizex"] = imagesx($this->image["src"]);
$this->image["sizey"] = imagesy($this->image["src"]);
}
示例2: clear_tmpfiles
function clear_tmpfiles($cachetime = 1800)
{
global $GB_TMP;
$delfiles = 0;
$filelist = '';
if (is_dir("{$this->include_path}/{$GB_TMP}")) {
chdir("{$this->include_path}/{$GB_TMP}");
$hnd = opendir(".");
while ($file = readdir($hnd)) {
if (is_file($file)) {
$filelist[] = $file;
}
}
closedir($hnd);
}
if (is_array($filelist)) {
while (list($key, $file) = each($filelist)) {
$tmpfile = explode(".", $file);
$tmpfile[0] = ereg_replace("img-", "", $tmpfile[0]);
if ($tmpfile[0] < time() - $cachetime) {
if (unlink($file)) {
$delfiles++;
}
}
}
}
return $delfiles;
}
示例3: build_query_url
/**
* 拼接URL
* @param $uri 可以传入Controller名称
* @param string $type
* @param array $params
* @param bool $toLower 是否需要将uri换成小写
* @return string
*/
public static function build_query_url($uri, $params = array(), $toLower = true, $type = "")
{
$class_name = ereg_replace('Controller$', '', $uri);
$arr = explode("_", $class_name);
if ($toLower) {
$uri = strtolower(implode("/", $arr));
} else {
$uri = implode("/", $arr);
}
if (empty($type) && BASE_URI_PRI) {
$resUri = "/" . BASE_URI_PRI . "/" . ltrim($uri, "/");
} elseif (empty($type)) {
$resUri = "/" . ltrim($uri, "/");
} else {
$url_type = APF::get_instance()->get_config("domain_type");
if ($url_type[$type]) {
$resUri = "/" . $url_type[$type] . "/" . ltrim($uri, "/");
} else {
$resUri = "/" . ltrim($uri, "/");
}
}
if (!empty($params) && is_array($params)) {
$resUri .= "?" . http_build_query($params);
}
$base_domain = APF::get_instance()->get_config('base_domain');
return self::get_protocol_name() . "://" . $base_domain . $resUri;
}
示例4: encodeHTML
function encodeHTML($sHTML)
{
$sHTML = ereg_replace("&", "&", $sHTML);
$sHTML = ereg_replace("<", "<", $sHTML);
$sHTML = ereg_replace(">", ">", $sHTML);
return $sHTML;
}
示例5: formatPH
function formatPH($ph)
{
$ph = ereg_replace('[^0-9]+', '', $ph);
// ##### Strip all Non-Numeric Characters
$phlen = strlen($ph);
switch (TRUE) {
case $phlen < 7:
$ext = $ph;
break;
case $phlen == 7:
sscanf($ph, "%3s%4s", $pfx, $exc);
break;
case $phlen > 7 and $phlen < 10:
sscanf($ph, "%3s%4s%s", $pfx, $exc, $ext);
break;
case $phlen == 10:
sscanf($ph, "%3s%3s%4s", $area, $pfx, $exc);
break;
case $phlen == 11:
sscanf($ph, "%1s%3s%3s%4s", $cty, $area, $pfx, $exc);
break;
case $phlen > 11:
sscanf($ph, "%1s%3s%3s%4s%s", $cty, $area, $pfx, $exc, $ext);
break;
}
$out = '';
$out .= isset($cty) ? $cty . ' ' : '';
$out .= isset($area) ? '(' . $area . ') ' : '';
$out .= isset($pfx) ? $pfx . ' - ' : '';
$out .= isset($exc) ? $exc . ' ' : '';
$out .= isset($ext) ? 'x' . $ext : '';
return $out;
}
示例6: lang_load
function lang_load($p_lang)
{
global $g_lang_strings, $g_active_language;
$g_active_language = $p_lang;
if (isset($g_lang_strings[$p_lang])) {
return;
}
if (!lang_language_exists($p_lang)) {
return;
}
$t_lang_dir = dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'lang' . DIRECTORY_SEPARATOR;
require_once $t_lang_dir . 'strings_' . $p_lang . '.txt';
# Allow overriding strings declared in the language file.
# custom_strings_inc.php can use $g_active_language
$t_custom_strings = dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'custom_strings_inc.php';
if (file_exists($t_custom_strings)) {
require $t_custom_strings;
# this may be loaded multiple times, once per language
}
$t_vars = get_defined_vars();
foreach (array_keys($t_vars) as $t_var) {
$t_lang_var = ereg_replace('^s_', '', $t_var);
if ($t_lang_var != $t_var || 'MANTIS_ERROR' == $t_var) {
$g_lang_strings[$p_lang][$t_lang_var] = ${$t_var};
}
}
}
示例7: encode_blast_email
function encode_blast_email($htmlmessage = NULL, $textmessage = NULL, $message_ID, $fields = NULL)
{
if ($this->type != 'Email-Admin') {
if ($htmlmessage) {
$htmlmessage = eregi_replace("\\[USERID\\]", $message_ID, $htmlmessage);
if ($fields) {
$htmlmessage = merge_fields_email($htmlmessage, $message_ID, $fields);
}
$htmlmessage .= '<img src="' . $Web_Site . 'http://localhost/amp/ut.php?m=' . $message_ID . '" width="1" height="1" border="0">';
$htmlmessage .= '<br><p align="center"> To unsubscribe please click <a href="' . $Web_Site . 'http://localhost/amp/unsubscribe.php?m=' . $message_ID . '">here</a></p>';
$htmlmessage = ereg_replace("\\[[A-Z\\. ]+\\]", "", $htmlmessage);
}
if ($textmessage) {
//$textmessage = eregi_replace("\[USERID\]",$message_ID,$textmessage,$fields=NULL);
if ($fields) {
$textmessage = $this->merge_fields_email($textmessage, $message_ID, $fields);
}
$textmessage .= '\\n_____________________________________________________\\n To unsubscribe go to:\\n ' . $Web_Site . '/unsubscribe.php?m=' . $message_ID;
$textmessage = ereg_replace("\\[[A-Z\\. ]+\\]", "", $textmessage);
}
} else {
if ($htmlmessage) {
if ($fields) {
$htmlmessage = merge_fields_email($htmlmessage, $message_ID, $fields);
}
$htmlmessage .= '<img src="' . AMP_SITE_URL . '/ut.php?m=' . $message_ID . '" width="1" height="1" border="0">';
$htmlmessage = ereg_replace("\\[[A-Z\\. ]+\\]", "", $htmlmessage);
}
}
$message = array('html' => $htmlmessage, 'text' => $textmessage);
return $message;
}
示例8: tep_date_short_add
function tep_date_short_add($raw_date, $typ, $add)
{
if ($raw_date == '0000-00-00 00:00:00' || $raw_date == '') {
return false;
}
if ($typ == 'year') {
$year = substr($raw_date, 0, 4);
$year = $year + (int) $add;
} else {
$year = substr($raw_date, 0, 4);
}
if ($typ == 'month') {
$month = (int) substr($raw_date, 5, 2);
$month = $month + (int) add;
} else {
$month = (int) substr($raw_date, 5, 2);
}
if ($typ == 'day') {
$day = (int) substr($raw_date, 8, 2);
$day = $day + (int) $add;
} else {
$day = (int) substr($raw_date, 8, 2);
}
$hour = (int) substr($raw_date, 11, 2);
$minute = (int) substr($raw_date, 14, 2);
$second = (int) substr($raw_date, 17, 2);
if (@date('Y', mktime($hour, $minute, $second, $month, $day, $year)) == $year) {
return date(DATE_FORMAT, mktime($hour, $minute, $second, $month, $day, $year));
} else {
return ereg_replace('2037' . '$', $year, date(DATE_FORMAT, mktime($hour, $minute, $second, $month, $day, 2037)));
}
}
示例9: index
function index()
{
if (isset($_GET['key'])) {
$frontlinesms_key = $_GET['key'];
}
if (isset($_GET['s'])) {
$message_from = $_GET['s'];
// Remove non-numeric characters from string
$message_from = ereg_replace("[^0-9]", "", $message_from);
}
if (isset($_GET['m'])) {
$message_description = $_GET['m'];
}
if (!empty($frontlinesms_key) && !empty($message_from) && !empty($message_description)) {
// Is this a valid FrontlineSMS Key?
$keycheck = ORM::factory('settings', 1)->where('frontlinesms_key', $frontlinesms_key)->find();
if ($keycheck->loaded == true) {
$services = new Service_Model();
$service = $services->where('service_name', 'SMS')->find();
if (!$service) {
return;
}
$reporter_check = ORM::factory('reporter')->where('service_id', $service->id)->where('service_account', $message_from)->find();
if ($reporter_check->loaded == true) {
$reporter_id = $reporter_check->id;
} else {
// get default reporter level (Untrusted)
$levels = new Level_Model();
$default_level = $levels->where('level_weight', 0)->find();
$reporter = new Reporter_Model();
$reporter->service_id = $service->id;
$reporter->service_userid = null;
$reporter->service_account = $message_from;
$reporter->reporter_level = $default_level;
$reporter->reporter_first = null;
$reporter->reporter_last = null;
$reporter->reporter_email = null;
$reporter->reporter_phone = null;
$reporter->reporter_ip = null;
$reporter->reporter_date = date('Y-m-d');
$reporter->save();
$reporter_id = $reporter->id;
}
// Save Message
$message = new Message_Model();
$message->parent_id = 0;
$message->incident_id = 0;
$message->user_id = 0;
$message->reporter_id = $reporter_id;
$message->message_from = $message_from;
$message->message_to = null;
$message->message = $message_description;
$message->message_type = 1;
// Inbox
$message->message_date = date("Y-m-d H:i:s", time());
$message->service_messageid = null;
$message->save();
}
}
}
示例10: plugin_ls_convert
function plugin_ls_convert()
{
// global $vars;
$with_title = FALSE;
if (func_num_args()) {
$args = func_get_args();
$with_title = in_array('title', $args);
}
$prefix = $this->cont['PageForRef'] . '/';
$pages = array();
foreach ($this->func->get_existpages(FALSE, $prefix) as $page) {
//if (strpos($page,$prefix) === 0)
//{
$pages[] = $page;
//}
}
//natcasesort($pages);
$this->func->pagesort($pages);
$ls = array();
foreach ($pages as $page) {
$comment = '';
if ($with_title) {
list($comment) = $this->func->get_source($page);
// 見出しの固有ID部を削除
$comment = preg_replace('/^(\\*{1,5}.*)\\[#[A-Za-z][_0-9a-zA-Z-]+\\](.*)$/', '$1$2', $comment);
$comment = '- ' . ereg_replace('^[-*]+', '', $comment);
}
$ls[] = "-[[{$page}]] {$comment}";
}
return $this->func->convert_html($ls);
}
示例11: convertir_caracteres_especiales
function convertir_caracteres_especiales($cadena)
{
$cadena = htmlentities($cadena);
$cadena = ereg_replace("á", "�", $cadena);
$cadena = ereg_replace("é", "�", $cadena);
$cadena = ereg_replace("í", "�", $cadena);
$cadena = ereg_replace("&ocute;", "�", $cadena);
$cadena = ereg_replace("ú", "�", $cadena);
$cadena = ereg_replace("Á", "�", $cadena);
$cadena = ereg_replace("É", "�", $cadena);
$cadena = ereg_replace("Í", "�", $cadena);
$cadena = ereg_replace("Ó", "�", $cadena);
$cadena = ereg_replace("Ú", "�", $cadena);
$cadena = ereg_replace("ñ", "�", $cadena);
$cadena = ereg_replace("Ñ", "�", $cadena);
$cadena = ereg_replace("°", "�", $cadena);
$cadena = ereg_replace("º", "�", $cadena);
$cadena = ereg_replace("ª", "�", $cadena);
$cadena = ereg_replace(""", "\"", $cadena);
$cadena = str_replace("\\'", "'", $cadena);
$cadena = str_replace('\\"', "''", $cadena);
$cadena = str_replace("'", "'", $cadena);
$cadena = str_replace('"', "''", $cadena);
$cadena = str_replace('&', "Y", $cadena);
return trim($cadena);
}
示例12: plugin_ls_convert
function plugin_ls_convert()
{
global $vars;
$with_title = FALSE;
if (func_num_args()) {
$args = func_get_args();
$with_title = in_array('title', $args);
}
$prefix = $vars['page'] . '/';
$pages = array();
foreach (get_existpages() as $page) {
if (strpos($page, $prefix) === 0) {
$pages[] = $page;
}
}
natcasesort($pages);
$ls = array();
foreach ($pages as $page) {
$comment = '';
if ($with_title) {
list($comment) = get_source($page);
// 見出しの固有ID部を削除
$comment = preg_replace('/^(\\*{1,3}.*)\\[#[A-Za-z][\\w-]+\\](.*)$/', '$1$2', $comment);
$comment = '- ' . ereg_replace('^[-*]+', '', $comment);
}
$ls[] = "-[[{$page}]] {$comment}";
}
return convert_html($ls);
}
示例13: validaCPF
function validaCPF($cpf = null)
{
// Verifica se um número foi informado
if (empty($cpf)) {
return false;
}
// Elimina possivel mascara
$cpf = ereg_replace('[^0-9]', '', $cpf);
$cpf = str_pad($cpf, 11, '0', STR_PAD_LEFT);
// Verifica se o numero de digitos informados é igual a 11
if (strlen($cpf) != 11) {
return false;
} else {
if ($cpf == '00000000000' || $cpf == '11111111111' || $cpf == '22222222222' || $cpf == '33333333333' || $cpf == '44444444444' || $cpf == '55555555555' || $cpf == '66666666666' || $cpf == '77777777777' || $cpf == '88888888888' || $cpf == '99999999999') {
return false;
// Calcula os digitos verificadores para verificar se o
// CPF é válido
} else {
for ($t = 9; $t < 11; $t++) {
for ($d = 0, $c = 0; $c < $t; $c++) {
$d += $cpf[$c] * ($t + 1 - $c);
}
$d = 10 * $d % 11 % 10;
if ($cpf[$c] != $d) {
return false;
}
}
return true;
}
}
}
示例14: oiSnmptrapHandle
function oiSnmptrapHandle($trap_arr)
{
$_ret = '';
// snmpTrapOID
if (isset($trap_arr['.1.3.6.1.6.3.18.1.3.0'])) {
$trap_version = "SNMPv1";
} else {
$trap_version = "SNMPv2";
}
$trap_address = ereg_replace("UDP:\\[(.*)\\].*", "\\1", $trap_arr['UDP:']);
$trap_enterprise = $trap_arr['.1.3.6.1.6.3.1.1.4.3.0'];
$trap_oid = $trap_arr['.1.3.6.1.6.3.1.1.4.1.0'];
$trap_details = '';
// seperate snmptrap by device oid
switch ($trap_oid) {
case $trap_oid:
if (isset($trap_arr[$trap_oid])) {
$trap_details = $trap_arr[$trap_oid];
$_ret['detail'] = ereg_replace('"', '', $trap_details);
}
break;
default:
$_ret['detail'] = '';
break;
}
$_ret['key'] = $trap_oid;
$_ret['address'] = $trap_address;
$_ret['version'] = $trap_version;
// return
return $_ret;
}
示例15: datadump
function datadump($table)
{
// <--- thx to mrwebmaster for function
# Creo la variabile $result
$result .= "# Dump of {$table} \n";
$result .= "# Dump DATE : " . date("d-M-Y") . "\n\n";
# Conto i campi presenti nella tabella
$query = mysql_query("select * from {$table}");
$num_fields = @mysql_num_fields($query);
# Conto il numero di righe presenti nella tabella
$numrow = mysql_num_rows($query);
# Passo con un ciclo for tutte le righe della tabella
for ($i = 0; $i < $numrow; $i++) {
$row = mysql_fetch_row($query);
# Ricreo la tipica sintassi di un comune Dump
$result .= "INSERT INTO " . $table . " VALUES(";
# Con un secondo ciclo for stampo i valori di tutti i campi
# trovati in ogni riga
for ($j = 0; $j < $num_fields; $j++) {
$row[$j] = addslashes($row[$j]);
$row[$j] = ereg_replace("\n", "\\n", $row[$j]);
if (isset($row[$j])) {
$result .= "\"{$row[$j]}\"";
} else {
$result .= "\"\"";
}
if ($j < $num_fields - 1) {
$result .= ",";
}
}
# Chiudo l'istruzione INSERT
$result .= ");\n";
}
return $result . "\n\n\n";
}