Exemple #1
0
 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;
 }
Exemple #2
0
 /**
  *	声明模板用法
  */
 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;
 }
 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);
 }
Exemple #4
0
 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);
             }
         }
     }
 }
Exemple #5
0
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;
}
		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>";
			
		}
 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;
 }
Exemple #8
0
/**
 * 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;
    }            
}
 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);
     }
 }
Exemple #10
0
 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);
     }
 }
Exemple #11
0
 function browserCapable()
 {
     //    return False;
     $ok = $this->forceModal || !ereg('MSIE 7', $_SERVER["HTTP_USER_AGENT"]);
     core_dbg(get_class($this), 'browserCapable', $ok ? 'YES' : 'NO', $this->debug);
     return $ok;
 }
Exemple #12
0
 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");
     }
 }
Exemple #13
0
 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']();
         }
     }
 }
Exemple #14
0
 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];
             }
         }
     }
 }
 /**
  * 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;
 }
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);
}
function hookpress_ajax_get_fields()
{
    global $wpdb, $hookpress_actions, $hookpress_filters;
    if ($_POST['type'] == 'action') {
        $args = $hookpress_actions[$_POST['hook']];
    }
    if ($_POST['type'] == 'filter') {
        $args = $hookpress_filters[$_POST['hook']];
    }
    $fields = array();
    foreach ($args as $arg) {
        if (ereg('[A-Z]+', $arg)) {
            $fields = array_merge($fields, hookpress_get_fields($arg));
        } else {
            $fields[] = $arg;
        }
    }
    header("Content-Type: text/html; charset=UTF-8");
    if ($_POST['type'] == 'filter') {
        $first = array_shift($fields);
        echo "<option value='{$first}' selected='selected' class='first'>{$first}</option>";
    }
    sort($fields);
    foreach ($fields as $field) {
        echo "<option value='{$field}'>{$field}</option>";
    }
    exit;
}
Exemple #18
0
 public function convertSystemValueToStamp($value)
 {
     if (ereg("P([0-9]{4})-([0-9]{2})", $value, $regs)) {
         return mktime(0, 0, 0, 1, ($regs[2] - 1) * 28, $regs[1] + 0);
     }
     return 0;
 }
function check_parameters()
{
    global $checked, $xml, $xsl, $xslSave, $xmlSave, $page, $lang;
    if (isset($_GET['xml']) && !ereg("^[a-z][a-z\\/]+.xml\$", $_GET['xml'])) {
        die("invalid parameter 1");
    } else {
        $checked['xml'] = $xml;
    }
    if (!ereg("^[a-z][a-zA-Z\\/\\_\\-]+.xsl\$", $xsl)) {
        die("invalid parameter 2");
    } else {
        $checked['xsl'] = $xsl;
    }
    if (isset($xmlSave) && !ereg(".xml\$", $xmlSave)) {
        die("invalid parameter 3: {$xmlSave}");
    } else {
        $checked['xmlSave'] = $xmlSave;
    }
    if (isset($xslSave) && !ereg(".xsl\$", $xslSave)) {
        die("invalid parameter 4");
    } else {
        $checked['xslSave'] = $xslSave;
    }
    if (isset($page) && !ereg("^[a-zA-Z\\_\\-]+\$", $page)) {
        die("invalid parameter 5");
    } else {
        $checked['page'] = $page;
    }
    if (!ereg("^(pt)|(es)|(en)\$", $lang)) {
        die("invalid lang parameter 6");
    } else {
        $checked['lang'] = $lang;
    }
}
Exemple #20
0
 function navigator_url($field, $title, $color = "white")
 {
     global $app;
     $url = url::complete_me();
     if (ereg('webadmin', $url)) {
         $path_ext = "webadmin/";
     }
     if (!ereg('\\?', $url)) {
         $url .= "?";
     }
     $url = preg_replace("|offset=.*?&|", "offset=0&", $url);
     $url = str_replace('&sort=asc', '', $url);
     $url = str_replace('&sort=desc', '', $url);
     $url = str_replace("&order={$field}", '', $url);
     $var = $_GET;
     if ($var['order'] == $field) {
         if ($var['sort'] == 'asc') {
             $out = "<a href='{$url}&order={$field}&sort=desc'><font color={$color}>{$title}</font></a> <img src='{$app['www']}/{$path_ext}img/arrow-asc.gif'>";
         } else {
             $out = "<a href='{$url}&order={$field}&sort=asc'><font color={$color}>{$title}</font></a> <img src='{$app['www']}/{$path_ext}img/arrow-desc.gif'>";
         }
     } else {
         $out = "<a href='{$url}&order={$field}&sort=asc'><font color={$color}>{$title}</font></a>";
     }
     return $out;
 }
	function check_email_address($email) {
	  // First, we check that there's one @ symbol, and that the lengths are right
	  if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $email)) {
	    // Email invalid because wrong number of characters in one section, or wrong number of @ symbols.
	    return false;
	  }
	  // Split it into sections to make life easier
	  $email_array = explode("@", $email);
	  $local_array = explode(".", $email_array[0]);
	  for ($i = 0; $i < sizeof($local_array); $i++) {
	     if (!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$", $local_array[$i])) {
	      return false;
	    }
	  }  
	  if (!ereg("^\[?[0-9\.]+\]?$", $email_array[1])) { // Check if domain is IP. If not, it should be valid domain name
	    $domain_array = explode(".", $email_array[1]);
	    if (sizeof($domain_array) < 2) {
	        return false; // Not enough parts to domain
	    }
	    for ($i = 0; $i < sizeof($domain_array); $i++) {
	      if (!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$", $domain_array[$i])) {
	        return false;
	      }
	    }
	  }
	  return true;
	}
Exemple #22
0
function SkontrolujEmail($email)
{
    // kontrola, ci obsahuje zavinac
    if (!ereg("^[^@]{1,64}@[^@]{1,255}\$", $email)) {
        // nespravny email - zly pocet znakov v jednej sekcii alebo zly pocet zavinacov
        return false;
    }
    // rozhodime to podla @ a podla .
    $email_array = explode("@", $email);
    $local_array = explode(".", $email_array[0]);
    for ($i = 0; $i < sizeof($local_array); $i++) {
        if (!ereg("^(([A-Za-z0-9!#\$%&'*+/=?^_`{|}~-][A-Za-z0-9!#\$%&'*+/=?^_`{|}~\\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))\$", $local_array[$i])) {
            return false;
        }
    }
    if (!ereg("^\\[?[0-9\\.]+\\]?\$", $email_array[1])) {
        // kontrola, ci domena je IP, ak nie, malo by to byt platne domenove meno
        $domain_array = explode(".", $email_array[1]);
        if (sizeof($domain_array) < 2) {
            return false;
            // nie je dost casti na domenu (min. 2)
        }
        for ($i = 0; $i < sizeof($domain_array); $i++) {
            if (!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))\$", $domain_array[$i])) {
                return false;
            }
        }
    }
    return true;
}
Exemple #23
0
function inject_form_variables(&$form_array, $arg1 = array(), $arg2 = array(), $arg3 = array(), $arg4 = array()) {
	$check_fields = array("value", "array", "friendly_name", "description", "sql", "sql_print", "form_id", "items");

	/* loop through each available field */
	while (list($field_name, $field_array) = each($form_array)) {
		/* loop through each sub-field that we are going to check for variables */
		foreach ($check_fields as $field_to_check) {
			if (isset($field_array[$field_to_check]) && (is_array($form_array[$field_name][$field_to_check]))) {
				/* if the field/sub-field combination is an array, resolve it recursively */
				$form_array[$field_name][$field_to_check] = inject_form_variables($form_array[$field_name][$field_to_check], $arg1);
			}elseif (isset($field_array[$field_to_check]) && (!is_array($field_array[$field_to_check])) && (ereg("\|(arg[123]):([a-zA-Z0-9_]*)\|", $field_array[$field_to_check], $matches))) {
				/* an empty field name in the variable means don't treat this as an array */
				if ($matches[2] == "") {
					if (is_array(${$matches[1]})) {
						/* the existing value is already an array, leave it alone */
						$form_array[$field_name][$field_to_check] = ${$matches[1]};
					}else{
						/* the existing value is probably a single variable */
						$form_array[$field_name][$field_to_check] = str_replace($matches[0], ${$matches[1]}, $field_array[$field_to_check]);
					}
				}else{
					/* copy the value down from the array/key specified in the variable */
					$form_array[$field_name][$field_to_check] = str_replace($matches[0], ((isset(${$matches[1]}{$matches[2]})) ? ${$matches[1]}{$matches[2]} : ""), $field_array[$field_to_check]);
				}
			}
		}
	}

	return $form_array;
}
Exemple #24
0
function zen_create_random_value($length, $type = 'mixed')
{
    if ($type != 'mixed' && $type != 'chars' && $type != 'digits') {
        return false;
    }
    $rand_value = '';
    while (strlen($rand_value) < $length) {
        if ($type == 'digits') {
            $char = zen_rand(0, 9);
        } else {
            $char = chr(zen_rand(0, 255));
        }
        if ($type == 'mixed') {
            if (eregi('^[a-z0-9]$', $char)) {
                $rand_value .= $char;
            }
        } elseif ($type == 'chars') {
            if (eregi('^[a-z]$', $char)) {
                $rand_value .= $char;
            }
        } elseif ($type == 'digits') {
            if (ereg('^[0-9]$', $char)) {
                $rand_value .= $char;
            }
        }
    }
    return $rand_value;
}
Exemple #25
0
 function Net_DNS_RR_SRV(&$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) {
             $a = unpack("@{$offset}/npreference/nweight/nport", $data);
             $offset += 6;
             list($target, $offset) = Net_DNS_Packet::dn_expand($data, $offset);
             $this->preference = $a['preference'];
             $this->weight = $a['weight'];
             $this->port = $a['port'];
             $this->target = $target;
         }
     } else {
         ereg("([0-9]+)[ \t]+([0-9]+)[ \t]+([0-9]+)[ \t]+(.+)[ \t]*\$", $data, $regs);
         $this->preference = $regs[1];
         $this->weight = $regs[2];
         $this->port = $regs[3];
         $this->target = ereg_replace('(.*)\\.$', '\\1', $regs[4]);
     }
 }
Exemple #26
0
 function Tabler($table, $cols = array(), $filters = array(), $order = "")
 {
     $this->table($table);
     $this->pager = new Pager();
     if (count($cols) == 0) {
         $what = '*';
     } else {
         foreach ($cols as $title => $name) {
             if ($name != "") {
                 $this->addCol($name);
                 $this->col_option($name, 'title', $title);
             }
             $what .= $name . ',';
         }
         $what = substr($what, 0, strlen($what) - 1);
     }
     if (count($filters) > 0) {
         foreach ($filters as $add) {
             $filter = isset($filter) ? "{$filter} AND {$add}" : " WHERE {$add}";
         }
     }
     foreach ($_GET as $key => $value) {
         if (ereg('^filter_', $key)) {
             $name = substr($key, 7);
             if ($value != '') {
                 if ($_GET['f_' . $name . '_type'] == 'search') {
                     $filter = isset($filter) ? "{$filter} AND {$name} LIKE '%{$value}%'" : " WHERE {$name} LIKE '%{$value}%'";
                 } else {
                     $filter = isset($filter) ? "{$filter} AND {$name}='{$value}'" : " WHERE {$name}='{$value}'";
                 }
             }
         }
     }
     $query = "SELECT count(*) as max FROM {$table} {$filter}";
     $result = mysql_query($query) or die("MySQL Error: " . mysql_error());
     $row = mysql_fetch_array($result);
     $this->pager->max($row['max']);
     $query = "SELECT {$what} FROM {$table} {$filter}";
     $keys = array_keys($this->cols);
     $order = isset($_GET['orderby']) ? $_GET['orderby'] : ($order == "" ? $keys['0'] . ' DESC' : $order);
     $query .= " ORDER BY {$order}";
     $query .= " LIMIT " . $this->pager->from() . "," . $this->pager->incr();
     $result = mysql_query($query) or die("MySQL Error: " . mysql_error());
     while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
         $this->add($row);
     }
     $fields = mysql_num_fields($result);
     for ($x = 0; $x < $fields; $x++) {
         $colinfo = @mysql_field_flags($result, $x);
         $colinfo = explode(' ', $colinfo);
         $name = mysql_field_name($result, $x);
         $type = mysql_field_type($result, $x);
         if (array_search('auto_increment', $colinfo) !== false) {
             $this->col_option($name, 'filter', 'submit');
             $this->idcol = $name;
         } else {
             $this->col_option($name, 'filter', 'select');
         }
     }
 }
Exemple #27
0
function exploreDir($dirname, $keyword)
{
    $allowedExt = ".php.pdf.chm";
    $dh = opendir($dirname);
    while ($file = readdir($dh)) {
        if (is_dir("{$dirname}/{$file}")) {
            if ($file != '.' and $file != '..') {
                exploreDir("{$dirname}/{$file}", $keyword);
            }
        } else {
            if ($file == 'index.php') {
                $file = basename($dirname);
                if (ereg($keyword, $file)) {
                    echo '<a href="', $dirname, '">', $file, '</a><br>';
                }
            } else {
                if (ereg($keyword, $file)) {
                    $ext = pathinfo($file, PATHINFO_EXTENSION);
                    $ext = ".{$ext}";
                    if (ereg($ext, $allowedExt)) {
                        echo '<a href="', $dirname, '/', $file, '">', basename($file, $ext), '</a><br>';
                    }
                }
            }
        }
    }
    closedir($dh);
}
Exemple #28
0
function build_search_terms($search, $match)
{
    $terms = array();
    // if this is an exact phrase match
    if ($match == 3) {
        $terms[] = $search;
    } else {
        if (strstr($search, '"')) {
            //first pull out all the double quoted strings
            if (strstr($search, "\"")) {
                $search_string = $search;
                while (ereg('-*"[^"]*"', $search_string, $match)) {
                    $terms[] = trim(str_replace("\"", "", $match[0]));
                    $search_string = substr(strstr($search_string, $match[0]), strlen($match[0]));
                }
            }
            $search = ereg_replace('-*"[^"]*"', '', $search);
        }
        //pull out the rest words in the string
        $regular_terms = explode(" ", $search);
        //merge them all together and return
        while (list($key, $val) = each($regular_terms)) {
            if ($val != "") {
                $terms[] = trim($val);
            }
        }
    }
    return $terms;
}
Exemple #29
0
 function Net_DNS_RR_TXT(&$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) {
             $maxoffset = $this->rdlength + $offset;
             while ($maxoffset > $offset) {
                 list($text, $offset) = Net_DNS_Packet::label_extract($data, $offset);
                 $this->text[] = $text;
             }
         }
     } else {
         $data = str_replace('\\\\', chr(1) . chr(1), $data);
         /* disguise escaped backslash */
         $data = str_replace('\\"', chr(2) . chr(2), $data);
         /* disguise \" */
         ereg('("[^"]*"|[^ \\t]*)[ \\t]*$', $data, $regs);
         $regs[1] = str_replace(chr(2) . chr(2), '\\"', $regs[1]);
         $regs[1] = str_replace(chr(1) . chr(1), '\\\\', $regs[1]);
         $regs[1] = stripslashes($regs[1]);
         $this->text = $regs[1];
     }
 }
Exemple #30
0
 function WriteHTML($html)
 {
     //Parseur HTML
     $html = str_replace("\n", ' ', $html);
     $a = preg_split('/<(.*)>/U', $html, -1, PREG_SPLIT_DELIM_CAPTURE);
     foreach ($a as $i => $e) {
         if ($i % 2 == 0) {
             //Texte
             if ($this->HREF) {
                 $this->PutLink($this->HREF, $e);
             } else {
                 $this->Write(5, $e);
             }
         } else {
             //Balise
             if ($e[0] == '/') {
                 $this->CloseTag(strtoupper(substr($e, 1)));
             } else {
                 //Extraction des attributs
                 $a2 = explode(' ', $e);
                 $tag = strtoupper(array_shift($a2));
                 $attr = array();
                 foreach ($a2 as $v) {
                     if (ereg('^([^=]*)=["\']?([^"\']*)["\']?$', $v, $a3)) {
                         $attr[strtoupper($a3[1])] = $a3[2];
                     }
                 }
                 $this->OpenTag($tag, $attr);
             }
         }
     }
 }