本文整理汇总了PHP中ereg函数的典型用法代码示例。如果您正苦于以下问题:PHP ereg函数的具体用法?PHP ereg怎么用?PHP ereg使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ereg函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: mysql_import_file
function mysql_import_file($filename, &$errmsg)
{
/* Read the file */
$lines = file($filename);
if (!$lines) {
$errmsg = "cannot open file {$filename}";
return false;
}
$scriptfile = false;
/* Get rid of the comments and form one jumbo line */
foreach ($lines as $line) {
$line = trim($line);
if (!ereg('^--', $line)) {
$scriptfile .= " " . $line;
}
}
if (!$scriptfile) {
$errmsg = "no text found in {$filename}";
return false;
}
/* Split the jumbo line into smaller lines */
$queries = explode(';', $scriptfile);
/* Run each line as a query */
foreach ($queries as $query) {
$query = trim($query);
if ($query == "") {
continue;
}
if (!mysql_query($query . ';')) {
$errmsg = "query " . $query . " failed";
return false;
}
}
return true;
}
示例2: ETCoreStart
/**
* 声明模板用法
*/
function ETCoreStart($set = array('ID' => '1', 'TplType' => 'htm', 'CacheDir' => 'cache', 'TemplateDir' => 'template', 'AutoImage' => 'on', 'LangDir' => 'language', 'Language' => 'default', 'Copyright' => 'off', 'MemCache' => ''))
{
$this->TplID = (defined('TemplateID') ? TemplateID : ((int) @$set['ID'] <= 1 ? 1 : (int) $set['ID'])) . '_';
$this->CacheDir = (defined('NewCache') ? NewCache : (trim($set['CacheDir']) != '' ? $set['CacheDir'] : 'cache')) . '/';
$this->TemplateDir = (defined('NewTemplate') ? NewTemplate : (trim($set['TemplateDir']) != '' ? $set['TemplateDir'] : 'template')) . '/';
$this->Ext = @$set['TplType'] != '' ? $set['TplType'] : 'htm';
$this->AutoImage = @$set['AutoImage'] == 'off' ? 0 : 1;
$this->Copyright = @$set['Copyright'] == 'off' ? 0 : 1;
$this->Server = is_array($GLOBALS['_SERVER']) ? $GLOBALS['_SERVER'] : $_SERVER;
$this->version = trim($_GET['EaseTemplateVer']) ? die('Ease Templae E3!') : '';
//载入语言文件
$this->LangDir = (defined('LangDir') ? LangDir : (@$set['LangDir'] != 'language' && @$set['LangDir'] ? $set['LangDir'] : 'language')) . '/';
if (is_dir($this->LangDir)) {
$this->Language = defined('Language') ? Language : ($set['Language'] != 'default' && $set['Language'] ? $set['Language'] : 'default');
if (@is_file($this->LangDir . $this->Language . '.php')) {
$lang = array();
@(include_once $this->LangDir . $this->Language . '.php');
$this->LangData = $lang;
}
} else {
$this->Language = 'default';
}
//缓存目录检测以及运行模式
if (@ereg(':', $set['MemCache'])) {
$this->RunType = 'MemCache';
$memset = explode(":", $set['MemCache']);
$this->Emc = memcache_connect($memset[0], $memset[1]) or die("Could not connect!");
} else {
$this->RunType = @substr(@sprintf('%o', @fileperms($this->CacheDir)), -3) == 777 && is_dir($this->CacheDir) ? 'Cache' : 'Replace';
}
$CompileBasic = array('/(\\{\\s*|<!--\\s*)inc_php:([a-zA-Z0-9_\\[\\]\\.\\,\\/\\?\\=\\#\\:\\;\\-\\|\\^]{5,200})(\\s*\\}|\\s*-->)/eis', '/<!--\\s*DEL\\s*-->/is', '/<!--\\s*IF(\\[|\\()(.+?)(\\]|\\))\\s*-->/is', '/<!--\\s*ELSEIF(\\[|\\()(.+?)(\\]|\\))\\s*-->/is', '/<!--\\s*ELSE\\s*-->/is', '/<!--\\s*END\\s*-->/is', '/<!--\\s*([a-zA-Z0-9_\\$\\[\\]\'\\"]{2,60})\\s*(AS|as)\\s*(.+?)\\s*-->/', '/<!--\\s*while\\:\\s*(.+?)\\s*-->/is', '/(\\{\\s*|<!--\\s*)lang\\:(.+?)(\\s*\\}|\\s*-->)/eis', '/(\\{\\s*|<!--\\s*)row\\:(.+?)(\\s*\\}|\\s*-->)/eis', '/(\\{\\s*|<!--\\s*)color\\:\\s*([\\#0-9A-Za-z]+\\,[\\#0-9A-Za-z]+)(\\s*\\}|\\s*-->)/eis', '/(\\{\\s*|<!--\\s*)dir\\:([^\\{\\}]{1,100})(\\s*\\}|\\s*-->)/eis', '/(\\{\\s*|<!--\\s*)run\\:(\\}|\\s*-->)\\s*(.+?)\\s*(\\{|<!--\\s*)\\/run(\\s*\\}|\\s*-->)/is', '/(\\{\\s*|<!--\\s*)run\\:(.+?)(\\s*\\}|\\s*-->)/is', '/\\{([a-zA-Z0-9_\'\\"\\[\\]\\$]{1,100})\\}/');
$this->Compile = is_array($this->Compile) ? array_merge($this->Compile, $CompileBasic) : $CompileBasic;
$AnalysisBasic = array('$this->inc_php("\\2")', '";if($ET_Del==true){echo"', '";if(\\2){echo"', '";}elseif(\\2){echo"', '";}else{echo"', '";}echo"', '";\\$_i=0;foreach((array)\\1 AS \\3){\\$_i++;echo"', '";\\$_i=0;while(\\1){\\$_i++;echo"', '$this->lang("\\2")', '$this->Row("\\2")', '$this->Color("\\2")', '$this->Dirs("\\2")', '";\\3;echo"', '";\\2;echo"', '";echo \\$\\1;echo"');
$this->Analysis = is_array($this->Analysis) ? array_merge($this->Analysis, $AnalysisBasic) : $AnalysisBasic;
}
示例3: process
function process()
{
if (ereg('.free.fr/', Request::getCurrentCompleteUrl())) {
print "<h2>Attention ! Les utilisateurs de Free.fr doivent faire une opération très particulière pour faire fonctionner phpMyVisites, du fait des limitations techniques imposées par Free.fr.</h2>\n\t\t\t<p> Vous devez donc <u>OBLIGATOIREMENT</u> :</p>\n\t\t\t<ul><li>Créer un répertoire /include/ à la racine de votre site free</li>\n\t\t\t<li>Uploader dans ce nouveau répertoire vide <u>le contenu du répertoire /libs/ de phpmyvisites</u>, une fois phpmyvisites dézippé sur votre ordinateur</li>\n\t\t\t<li>Vous ne devez donc pas changer votre phpmyvisites que vous avez normalement déjà uploadé sur le serveur. Vous devez seulement réuploader les fichiers et répertoires contenus dans le répertoire /libs/ de phpmyvisites. Ces fichiers sont : PEAR.php, Cache/, QuickForm/, HTML/, XML/ (les autres sont facultatifs).</li>\n\t\t\t<li>A la fin de l'opération, vous devez donc avoir à la racine de votre site Free : <br>/include/PEAR.php<br> /include/XML/<br> /include/HTML/<br> etc.\n\t\t\t</ul>\n\t\t\t\n\t\t\t<p> En cas de problèmes consultez les forums de phpMyVisites mais surtout suivez scrupuleusement ces indications et tout se passera très bien !</p>\n\t\t\t\n\t\t\t\n\t\t\t<p><b>If you need these explanations in english, please ask in phpmyvisites forums</b></p>";
}
$this->tpl->assign("show_next_step", true);
}
示例4: WriteHTML
function WriteHTML($html)
{
//HTML parser
$html = str_replace("\n", ' ', $html);
$a = preg_split('/<(.*)>/U', $html, -1, PREG_SPLIT_DELIM_CAPTURE);
foreach ($a as $i => $e) {
if ($i % 2 == 0) {
//Text
if ($this->HREF) {
$this->PutLink($this->HREF, $e);
} else {
$this->Write(5, $e);
}
} else {
//Tag
if ($e[0] == '/') {
$this->CloseTag(strtoupper(substr($e, 1)));
} else {
//Extract properties
$a2 = split(' ', $e);
$tag = strtoupper(array_shift($a2));
$prop = array();
foreach ($a2 as $v) {
if (ereg('^([^=]*)=["\']?([^"\']*)["\']?$', $v, $a3)) {
$prop[strtoupper($a3[1])] = $a3[2];
}
}
$this->OpenTag($tag, $prop);
}
}
}
}
示例5: jyxo_bot
function jyxo_bot($q = "", $d = "mm", $ereg = ".", $notereg = "", $cnt = 10000000000000, $page = 1, $pmax = 2, $o = "nocls")
{
$i = 0;
$results = "";
$results[$i] = "";
//$q = str_replace(" ", "+", $q);
$q = urlencode($q);
for (; $page <= $pmax; $page++) {
$request = "http://jyxo.cz/s?q={$q}&d={$d}&o={$o}&cnt={$cnt}&page={$page}";
$fp = fopen($request, "r") or die(" !!! Cannot connect !!!");
while (!feof($fp)) {
$line = fgets($fp);
if (eregi("<div class='r'>", $line) && ereg(" class=ri", $line)) {
$line = explode("<!--m--><div class='r'><A HREF=\"", $line);
$line = $line[1];
$line = explode("\" class=ri", $line);
$line = trim($line[0]);
$line = urldecode($line);
if (@eregi($ereg, $line) && !@eregi($notereg, $line) && !in_array($line, $results)) {
echo "{$line}\n";
//Output
//echo("$i:$line\n"); //Indexed Output
//echo("<a href=\"$line\">$line</a><br />\n"); //XHTML Output
$results[$i] = $line;
$i++;
}
}
}
fclose($fp);
}
echo "\nTotal: {$i}\n";
//Sumary Output
return $results;
}
示例6: save
function save($db_object,$common,$_POST,$default)
{
$yes= array();
$no = array();
while(list($key,$value)=each($_POST))
{
$$key = $value;
if($value=='YES')
{
if(ereg("^check_",$key))
{
$yes[]=substr($key,6);
}
}
if($value=='NO')
{
if(ereg("^check_",$key))
{
$no[]=substr($key,6);
}
}
}
$yes_id = implode("','",$yes);
$no_id = implode("','",$no);
$fields = $common->prefix_table(name_fields);
$qry1 = "update $fields set status='YES' where name_id in ('$yes_id')";
//echo "$qry1<br>";
$res = $db_object->insert($qry1);
$qry2 = "update $fields set status='NO' where name_id in ('$no_id')";
$res = $db_object->insert($qry2);
//echo "$qry2<br>";
}
示例7: scan
function scan($page_content)
{
$i = 0;
if (ereg("<style( *[\n]*.*)>\n*(.\n*)*<\\/style>", $page_content)) {
if (preg_match_all("/(@\\s*import\\s* (url((\"|')?)?((\"|')?)|(\"|'){1}).+(\"|')?\\)?)/", $page_content, $ext_stylesheets)) {
foreach ($ext_stylesheets[0] as $stylesheet) {
$css_content[$i] = preg_replace("/(@\\s*import\\s*)|(url\\(?((\"|')?))|(\"|'){1}|\\)?(\"|')?;|(\\s)/", "", $stylesheet);
$i++;
}
$array = 1;
}
$inline_notused = $this->check_file($page_content, $page_content);
} else {
die("No page styles, sorry!" . $this->helptext);
}
$unused = array('internal' => array(), 'external' => array());
if (isset($array) && $array == 1) {
foreach ($css_content as $css_file) {
$css = file_get_contents($css_file);
if (!empty($css)) {
$not_used = $this->check_file($css, $page_content);
array_push($unused['external'], array('css_file' => $css_file, 'external' => $not_used));
}
}
}
if ($inline_notused != false) {
$unused['internal'] = $inline_notused;
}
return $unused;
}
示例8: Image_Graph_gd_version
/**
* Check which version of GD is installed
* @return int 0 if GD isn't installed, 1 if GD 1.x is installed and 2 if GD 2.x is installed
*/
function Image_Graph_gd_version()
{
if (function_exists("gd_info")) {
$info = gd_info();
$version = $info['GD Version'];
} else {
ob_start();
phpinfo(8);
$php_info = ob_get_contents();
ob_end_clean();
if (ereg("<td[^>]*>GD Version *<\/td><td[^>]*>([^<]*)<\/td>", $php_info, $result)) {
$version = $result[1];
}
}
if ($version) {
//define("GD_VERSION", $version);
}
if (ereg("1\.[0-9]{1,2}", $version)) {
return 1;
}
elseif (ereg("2\.[0-9]{1,2}", $version)) {
return 2;
} else {
return 0;
}
}
示例9: save_data
function save_data($db_object, $common, $fLang_id, $_POST, $default)
{
$id = array();
while (list($key, $value) = each($_POST)) {
${$key} = $value;
if (ereg("^lang_", $key)) {
$id[] = substr($key, 5);
}
if (ereg("^charset_", $key)) {
$ids = split("_", $key);
$id1 = $ids[1];
$char[$id1] = $value;
}
}
$charset_table = $common->prefix_table("language_charset");
while (list($kk, $vv) = @each($char)) {
$upqry = "update {$charset_table} set charset='{$vv}' where language_id='{$kk}'";
$upqry = "replace into {$charset_table} set language_id='{$kk}',charset='{$vv}'";
$db_object->insert($upqry);
}
$lang_table = $common->prefix_table("language");
$lang = "lang_" . $fLang_id;
for ($i = 0; $i < count($id); $i++) {
$lan = "lang_" . $id[$i];
$lan = ${$lan};
$mysql = "update {$lang_table} set {$lang}='{$lan}' where lang_id='{$id[$i]}'";
$db_object->insert($mysql);
}
}
示例10: Connect
private function Connect($servers)
{
if ($this->IsConnected()) {
throw new Exception('Already connected');
}
if (!is_array($servers) || count($servers) == 0) {
throw new Exception('No servers');
}
foreach ($servers as $s) {
if (!ereg("[^:]+:[0-9]+", $s)) {
throw new Exception($s . ' is not a valid server');
}
}
srand((double) microtime() * 1000000);
shuffle($servers);
foreach ($servers as $s) {
list($server, $port) = explode(":", $s);
$server = gethostbyname($server);
$this->socket = fsockopen($server, $port, $errno, $err);
if ($this->IsConnected()) {
break;
}
}
if ($this->IsConnected()) {
return true;
} else {
throw new Exception($errno . ' - ' . $err);
}
}
示例11: piclens_gallery
function piclens_gallery()
{
$item_id = EClassApi::getParam('item_id');
$entry = '';
if ($item_id) {
$sql = 'select id, original_image_url, title, position from item_image where item_id = ' . intval($item_id) . ' ORDER BY position ';
DB::query($sql);
if (DB::num_rows()) {
$entry = '';
while ($rows = DB::fetch_row()) {
$rows['title'] = $rows['title'] ? $rows['title'] : "Image {$rows['position']}";
$rows['title'] = trim(XMLLib::_xml_encode_attribute($rows['title']));
if (ereg('/', $rows['original_image_url'])) {
$url = trim(XMLLib::_xml_encode_attribute("http://" . IMAGE_PATH . "{$rows['original_image_url']}"));
} else {
$url = trim(XMLLib::_xml_encode_attribute("http://" . IMAGE_PATH . "uploaded/items/{$rows['original_image_url']}"));
}
$entry .= "\n\t\t \t \t<item>\n\t\t \t \t\t\t<title>" . stripslashes($rows['title']) . "</title>\n\t\t\t\t\t\t<link>{$url}</link>\n\t\t\t\t\t\t<guid>Image {$rows['position']}</guid>\n\t\t\t\t\t\t<media:thumbnail url=\"{$url}\" />\n\t\t\t\t\t\t<media:content url=\"{$url}\" />\n\t\t\t\t</item>\n\t\t \t \t";
}
@header("Content-type: text/xml");
echo "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n\t\t\t <rss version=\"2.0\" xmlns:media=\"http://search.yahoo.com/mrss\">\n\t\t\t <channel>\t\t\t\n\t\t\t <title>Enbac.com</title>\n\t\t\t <link>http://www.chonmon.vn/</link>\n\t\t\t <description>Enbac.com - </description>\n\t\t\t <logo url=\"style/images/logo.piclens.png\" />\n\t\t\t";
echo $entry;
echo "\n\t\t \t </channel>\n\t\t\t </rss>\n\t\t\t";
} else {
die("no_info");
}
} else {
die("no_info");
}
}
示例12: shipping
function shipping($module = '')
{
global $language, $PHP_SELF, $customer_id;
$customer_group = new customer_group($customer_id);
if (ereg('all', $customer_group->getshipment())) {
$this->modules = explode(';', MODULE_SHIPPING_INSTALLED);
} else {
$this->modules = explode(';', $customer_group->getshipment());
}
if (defined('MODULE_SHIPPING_INSTALLED') && tep_not_null(MODULE_SHIPPING_INSTALLED)) {
$include_modules = array();
if (tep_not_null($module) && in_array(substr($module['id'], 0, strpos($module['id'], '_')) . '.' . substr($PHP_SELF, strrpos($PHP_SELF, '.') + 1), $this->modules)) {
$include_modules[] = array('class' => substr($module['id'], 0, strpos($module['id'], '_')), 'file' => substr($module['id'], 0, strpos($module['id'], '_')) . '.' . substr($PHP_SELF, strrpos($PHP_SELF, '.') + 1));
} else {
reset($this->modules);
while (list(, $value) = each($this->modules)) {
$class = substr($value, 0, strrpos($value, '.'));
$include_modules[] = array('class' => $class, 'file' => $value);
}
}
for ($i = 0, $n = sizeof($include_modules); $i < $n; $i++) {
include DIR_WS_LANGUAGES . $language . '/modules/shipping/' . $include_modules[$i]['file'];
include DIR_WS_MODULES . 'shipping/' . $include_modules[$i]['file'];
$GLOBALS[$include_modules[$i]['class']] = new $include_modules[$i]['class']();
}
}
}
示例13: Net_DNS_RR_A
function Net_DNS_RR_A(&$rro, $data, $offset = '')
{
$this->name = $rro->name;
$this->type = $rro->type;
$this->class = $rro->class;
$this->ttl = $rro->ttl;
$this->rdlength = $rro->rdlength;
$this->rdata = $rro->rdata;
if ($offset) {
if ($this->rdlength > 0) {
/*
* We don't have inet_ntoa in PHP?
*/
$aparts = unpack('C4b', $this->rdata);
$addr = $aparts['b1'] . '.' . $aparts['b2'] . '.' . $aparts['b3'] . '.' . $aparts['b4'];
$this->address = $addr;
}
} else {
if (strlen($data) && ereg("([0-9]+)\\.([0-9]+)\\.([0-9]+)\\.([0-9]+)[ \t]*\$", $data, $regs)) {
if ($regs[1] >= 0 && $regs[1] <= 255 && ($regs[2] >= 0 && $regs[2] <= 255) && ($regs[3] >= 0 && $regs[3] <= 255) && ($regs[4] >= 0 && $regs[4] <= 255)) {
$this->address = $regs[1] . '.' . $regs[2] . '.' . $regs[3] . '.' . $regs[4];
}
}
}
}
示例14: validateObjectAttributeHTTPInput
/**
* Validates the input from the object edit form concerning this attribute.
*
* @param mixed $http Class eZHTTPTool.
* @param string $base Seems to be always 'ContentObjectAttribute'.
* @param mixed $contentObjectAttribute Class eZContentObjectAttribute.
*
* @return int eZInputValidator::STATE_INVALID/STATE_ACCEPTED
*/
public function validateObjectAttributeHTTPInput($http, $base, $contentObjectAttribute)
{
if ($http->hasPostVariable($base . "_data_domain_" . $contentObjectAttribute->attribute("id"))) {
$data = $http->postVariable($base . "_data_domain_" . $contentObjectAttribute->attribute("id"));
$data = str_replace(" ", "", $data);
if (!$contentObjectAttribute->validateIsRequired() && $data == "") {
return eZInputValidator::STATE_ACCEPTED;
}
$withSubdomain = $contentObjectAttribute->contentClassAttribute()->attribute(self::SUBDOMAIN_FIELD);
if ($withSubdomain == 1) {
if (!ereg('^' . self::SUBDOMAIN_REGEXP . '$', $data)) {
$contentObjectAttribute->setValidationError(ezi18n('kernel/classes/datatypes', 'No valid domain'));
return eZInputValidator::STATE_INVALID;
}
} else {
if (!ereg('^' . self::DOMAIN_REGEXP . '$', $data)) {
$contentObjectAttribute->setValidationError(ezi18n('kernel/classes/datatypes', 'No valid domain'));
return eZInputValidator::STATE_INVALID;
}
}
return eZInputValidator::STATE_ACCEPTED;
} else {
return eZInputValidator::STATE_ACCEPTED;
}
return eZInputValidator::STATE_INVALID;
}
示例15: get_parser_characters
function get_parser_characters($format)
{
if ($format == 'tab') {
$middle = ' ';
$end_tr = '<BR>';
} elseif ($format == 'html' || $format == '') {
$begin_table = '<TABLE>';
$end_table = '</TABLE>';
$tr = '<TR>';
$end_tr = '</TR>';
$td = '<TD>';
$end_td = '</TD>';
$middle = $end_td . $td;
} elseif (ereg('html:', $format)) {
list($style, $choice) = explode(':', $format);
$begin_table = '<TABLE class = "$choice">';
$end_table = '</TABLE>';
$tr = '<TR>';
$end_tr = '</TR>';
$td = '<TD>';
$end_td = '</TD>';
$middle = $end_td . $td;
}
return $parser_char = array('middle' => $middle, 'begin_table' => $begin_table, 'tr' => $tr, 'end_tr' => $end_tr, 'td' => $td, 'end_td' => $end_td, 'middle' => $middle, 'end_table' => $end_table);
}