.



on-line?
? ?
Ru.Board » » Web- » PHP: ( )

: Cheery

   •
: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

     

SafeWay



Member
| | | ICQ | |
:

:
 
  function err_handler ($errno, $errstr, $errfile, $errline) {
    global $display_errors;
    if(($errno != E_NOTICE && $errno != E_WARNING) && $display_errors){
      echo '';
    }
  }
  $error_flags = E_ALL & ~E_NOTICE;
  @error_reporting($error_flags);
  @ini_set ('error_reporting', $error_flags);
  $old_error_handler = set_error_handler("err_handler");
 

 
, , .
 
: .



, !
, , !  
, . php - , , ,
 
ps: , .





:
: .
. Svarga.

: 365 | . 28-12-2003 | : 07:30 26-07-2004 | : Cheery, 16:57 25-03-2007
Cheery



.::.
| | | |
WEBerFAK

- ....

:
function gts ($dir)  
  {
      global $size;
       if (is_dir($dir)) {  
       if ($dh = opendir($dir)) {
        while (($file = readdir($dh)) !== false) {
               if (($file!='.') && ($file!='..')) {
                     $f=$_SERVER['DOCUMENT_ROOT']."/$dir/$file";
                     if (filetype($f)=='dir') { gts ("$dir/$file/"); }
                     if (filetype($f)!='dir') { $size=$size+filesize($f); }
               }
         }
       closedir($dh);
    }
 }
}


: 52737 | . 04-04-2002 | : 23:33 25-01-2006 | : Cheery, 23:34 25-01-2006
Cheery



.::.
| | | |
Ternik:

:
function myquery ($query)  
{  
$backtrace = debug_backtrace();  
 
$backtrace = "</b> in : <b>" . $backtrace[0]["file"] . "</b>, on line: <b>" . $backtrace[0]["line"] . "</b>";  
 
$result = mysql_query($query)  
or trigger_error(mysql_errno() . ": <b>" . mysql_error() . $backtrace . format_query($query) , E_USER_ERROR);  
 
return($result);  
}  
 
function format_query ($query)  
{  
return("<p><b>Query was:</b><br/><textarea cols='50' rows='10'>$query</textarea></p>");  
}

 
SQL , "or die", . MySQL, , SQL , , .

: 52737 | . 04-04-2002 | : 19:38 31-01-2006
Cheery



.::.
| | | |
Solovjev

:
/ ( ).  
 
<?php  
class lz_graf {  
public $im;//  
private $heigh;//  
private $width;//  
private $punkt_x;// ?  
private $punkt_y;// ?  
private $punkt_x_color;//  
private $punkt_y_color;//  
private $razd_x_color;//  
private $razd_y_color;//  
private $razd_size;//  
private $otstup_x;//  
private $otstup_y;//  
private $razd_x_text_size;//  
private $razd_y_text_size;//  
private $razd_x_text_color;// x  
private $razd_y_text_color;//  
private $razd_x_text_otstup;//  
private $razd_y_text_otstup;//  
private $diagram_or_gr;//0 - , 1-  
private $gr_color;// ( )  
private $y_name;//  
private $x_name;//  
private $pryamoug_color;// ( )  
private $pryamoug_gr;// ( )  
private $bgc;//  
//  
public function __construct($heigh=300, $width=502, $punkt_x=1, $punkt_y=1, $razd_size=3, $otstup_x=0.04,  
$otstup_y=0.09, $razd_x_text_size=3, $razd_y_text_size=3, $razd_x_text_otstup=0.2,  
$razd_y_text_otstup=1.015, $diagram_or_gr=0,  
$dannie=array('5','4','1','6','1','3','5','2','6','4','1','7', '5','6','4','2','3','6', '5','4','5','4','6','5','2', '3','6','4','1','5','7')) {  
$this->heigh=$heigh;  
$this->width=$width;  
$this->punkt_x=$punkt_x;  
$this->punkt_y=$punkt_y;  
$this->razd_size=$razd_size;  
$this->otstup_x=$otstup_x;  
$this->otstup_y=$otstup_y;  
$this->razd_x_text_size=$razd_x_text_size;  
$this->razd_y_text_size=$razd_y_text_size;  
$this->razd_x_text_otstup=$razd_x_text_otstup;  
$this->razd_y_text_otstup=$razd_y_text_otstup;  
$this->diagram_or_gr=$diagram_or_gr;  
$this->y_name=array('0', '1', '2','3', '4', '5', '6', '7', '8', '9', '10');  
$this->x_name=0;  
$this->dannie=$dannie;  
$this->im= ImageCreateTrueColor($this->width, $this->heigh);  
$this->razd_x_text_otstup=$razd_x_text_otstup;  
$this->razd_y_text_otstup=$razd_y_text_otstup;  
$this->diagram_or_gr=$diagram_or_gr;  
$this->dannie=$this->mashtab(); //  
}  
//  
public function __destruct() {  
ImageDestroy($this->im);  
}  
 
// ( )  
/* 10  
-- 10  
-- 10*/  
private function mashtab (){  
$flag=0;  
while ($flag == 0){  
$flag=1;  
for ($i=0; $i<count($this->dannie); $i++){  
if ($this->dannie[$i] > 10) {  
$flag=0;  
}  
}  
if ($flag == 0) {  
for ($k=0; $k<count($this->dannie); $k++){  
settype($this->dannie[$k],'double');  
$this->dannie[$k]=$this->dannie[$k]/10;  
settype($this->dannie[$k],'string');  
}  
for ($k=0; $k<count($this->y_name); $k++){  
settype($this->y_name[$k],'integer');  
$this->y_name[$k]=$this->y_name[$k]*10;  
settype($this->y_name[$k],'string');  
}  
// ,  
$this->otstup_x=$this->otstup_x*1.25;  
}  
}  
unset($this->x_name);  
for ($k=0; $k<count($this->dannie); $k++){  
$this->x_name[$k]=$k+1;  
}  
return $this->dannie;  
}  
 
 
 
//  
private function sep_y_ () {  
$n=count($this->y_name);  
$x0=$this->width*$this->otstup_x;  
$y0=$this->heigh*$this->otstup_y;  
$x1=$this->width*$this->otstup_x;  
$y1=$this->heigh-$this->heigh*$this->otstup_y;  
$w=$this->width-($this->width*$this->otstup_x);  
$length=($y1-$y0)/($n-1);  
for ($i=0; $i<$n; $i++){  
ImageLine($this->im, $x0, $y0, $x0+$this->razd_size, $y0, $this->razd_x_color);  
ImageLine($this->im, $x0, $y0, $x0-$this->razd_size, $y0, $this->razd_x_color);  
$style=array($this->punkt_x_color,IMG_COLOR_TRANSPARENT,IMG_COLOR_TRANSPARENT,IMG_COLOR_TRANSPARENT);  
imagesetstyle($this->im, $style);  
ImageLine($this->im, $x0, $y0, $w, $y0, IMG_COLOR_STYLED);  
$y0+=$length;  
}  
}  
 
//  
private function sep_y_lite_ () {  
$x0=$this->width*$this->otstup_x;  
$y0=$this->heigh*$this->otstup_y;  
$x1=$this->width*$this->otstup_x;  
$y1=$this->heigh-$this->heigh*$this->otstup_y;  
$n=count($this->y_name);  
$length=($y1-$y0)/($n-1);  
for ($i=0; $i<$n; $i++){  
ImageLine($this->im, $x0, $y0, $x0+$this->razd_size, $y0, $this->razd_x_color);  
ImageLine($this->im, $x0, $y0, $x0-$this->razd_size, $y0, $this->razd_x_color);  
$y0+=$length;  
}  
}  
 
//  
private function sep_x_ () {  
$x0=$this->width*$this->otstup_x;  
$y0=$this->heigh-$this->heigh*$this->otstup_y;  
$x1=$this->width-$this->width*$this->otstup_x;  
$y1=$this->heigh-$this->heigh*$this->otstup_y;  
$m=count($this->x_name);  
$h=$this->heigh*$this->otstup_y;  
$length=($x1-$x0)/$m;  
for ($i=0; $i<$m-1; $i++){  
$x0+=$length;  
ImageLine($this->im, $x0, $y0, $x0, $y0+$this->razd_size, $this->razd_y_color);  
ImageLine($this->im, $x0, $y0, $x0, $y0-$this->razd_size, $this->razd_y_color);  
$style=array($this->punkt_y_color,IMG_COLOR_TRANSPARENT,IMG_COLOR_TRANSPARENT,IMG_COLOR_TRANSPARENT);  
imagesetstyle($this->im,$style);  
ImageLine($this->im, $x0, $h, $x0, $y0, IMG_COLOR_STYLED);  
}  
}  
 
 
//  
private function sep_x_lite_ () {  
$x0=$this->width*$this->otstup_x;  
$y0=$this->heigh-$this->heigh*$this->otstup_y;  
$x1=$this->width-$this->width*$this->otstup_x;  
$y1=$this->heigh-$this->heigh*$this->otstup_y;  
$m=count($this->x_name);  
$length=($x1-$x0)/$m;  
for ($i=0; $i<$m-1; $i++){  
$x0+=$length;  
ImageLine($this->im, $x0, $y0, $x0, $y0+$this->razd_size, $this->razd_y_color);  
ImageLine($this->im, $x0, $y0, $x0, $y0-$this->razd_size, $this->razd_y_color);  
}  
}  
 
//  
private function sep_y_text_ (){  
$x0=$this->width*$this->otstup_x;  
$y0=$this->heigh*$this->otstup_y;  
$x1=$this->width*$this->otstup_x;  
$y1=$this->heigh-$this->heigh*$this->otstup_y;  
$n=$this->y_name;  
$length=($y1-$y0)/(count($n)-1);  
$n=array_reverse($n);  
$y0-=$length;  
for ($i=0; $i<count($n); $i++){  
$y0+=$length;  
ImageString($this->im, $this->razd_x_text_size, $x0*$this->razd_x_text_otstup, $y0-5, $n[$i], $this->razd_x_text_color);  
}  
}  
 
//  
private function sep_x_text_ (){  
$x0=$this->width*$this->otstup_x;  
$y0=$this->heigh-$this->heigh*$this->otstup_y;  
$x1=$this->width-$this->width*$this->otstup_x;  
$y1=$this->heigh-$this->heigh*$this->otstup_y;  
$m=$this->x_name;  
$length=(($x1-$x0)/count($m));  
$flag=1;  
for ($i=0; $i<count($m); $i++){  
$x0+=$length;  
if ($flag==1){  
$flag=-1;  
ImageString($this->im, $this->razd_y_text_size, $x0-13, $y0*$this->razd_y_text_otstup, $m[$i], $this->razd_y_text_color);  
} else $flag=1;  
}  
}  
 
//  
private function dlina ($m, $length,$y0){  
$p=(round($m)*$length)+(($m-round($m))*$length);  
$p=$y0-$p;  
 
return $p;  
}  
 
// ( )  
private function pryamoug () {  
$x0=$this->width*$this->otstup_x;  
$y0=$this->heigh-$this->heigh*$this->otstup_y;  
$x1=$this->width-$this->width*$this->otstup_x;  
$y1=$this->heigh*$this->otstup_y;  
$m=$this->dannie;  
$n=$this->x_name;  
$length=(($x1-$x0)/(count($n)));  
$length_y=(($y0-$y1)/(count($this->y_name)-1));  
$x0+=$length;  
imagesetthickness($this->im,1);  
for ($i=0; $i<count($m); $i++){  
imagefilledrectangle($this->im,$x0,$y0,$x0-$length,$this->dlina($m[$i], $length_y, $y0),$this->pryamoug_color);  
imagerectangle($this->im,$x0,$y0,$x0-$length,$this->dlina($m[$i], $length_y, $y0),$this->pryamoug_gr);  
$x0+=$length;  
}  
}  
 
//  
private function line (){  
$x0=$this->width*$this->otstup_x;  
$y0=$this->heigh-$this->heigh*$this->otstup_y;  
$x1=$this->width-$this->width*$this->otstup_x;  
$y1=$this->heigh*$this->otstup_y;  
$m=$this->dannie;  
$length=(($x1-$x0)/(count($this->x_name)));  
$yy0=$y0;  
$style=array($this->gr_color);  
imagesetstyle($this->im,$style);  
$length_y=(($y0-$y1)/(count($this->y_name)-1));  
$flag=1;  
for ($i=0; $i<count($m); $i++){  
if ($flag==0){  
imageline($this->im,$x0,$yy0,$x0+$length,$this->dlina($m[$i], $length_y, $y0),IMG_COLOR_STYLED); }  
else {$flag=0;}  
$yy0=$this->dlina($m[$i], $length_y, $y0);  
$x0+=$length;  
}  
}  
 
//  
public function set_color ($punkt_x_color, $punkt_y_color, $razd_x_color, $razd_y_color, $razd_x_text_color, $razd_y_text_color, $gr_color, $pryamoug_color, $pryamoug_gr, $bgc){  
$this->punkt_x_color=$punkt_x_color;  
$this->punkt_y_color=$punkt_y_color;  
$this->razd_x_color=$razd_x_color;  
$this->razd_y_color=$razd_y_color;  
$this->razd_x_text_color=$razd_x_text_color;  
$this->razd_y_text_color=$razd_y_text_color;  
$this->gr_color=$gr_color;  
$this->pryamoug_color=$pryamoug_color;  
$this->pryamoug_gr=$pryamoug_gr;  
$this->bgc=$bgc;  
}  
 
//  
public function show (){  
ImageFill($this->im, 0, 0, $this->bgc);  
imagesetthickness($this->im,2) ;  
ImageLine($this->im, $this->width*$this->otstup_x, $this->heigh-$this->heigh*$this->otstup_y, $this->width-$this->width*$this->otstup_x, $this->heigh-$this->heigh*$this->otstup_y, $this->razd_x_color);  
$otstup_xx=$this->otstup_x;  
if ($this->diagram_or_gr==0){  
$this->pryamoug ();  
} else {  
$this->line();  
}  
ImageLine($this->im, $this->width*$this->otstup_x, $this->heigh*$this->otstup_y, $this->width*$this->otstup_x, $this->heigh-$this->heigh*$this->otstup_y, $this->razd_y_color);  
if ($this->punkt_x==1) {  
$this->sep_y_();  
} else {  
$this->sep_y_lite_();  
}  
if ($this->punkt_y==1){  
$this->sep_x_();  
} else {  
$this->sep_x_lite_();  
}  
$this->sep_y_text_();  
$this->sep_x_text_();  
Header ('Content-type: image/png');  
ImagePng ($this->im);  
}  
}  
?>  
 
 
<?php  
// lz_graf  
require_once('lz_graf.php');  
$dannie=array('50','34','89','77','27','20','60','43','53','88','11','12','25','45');  
$a=new lz_graf(300, 502, 1, 1, 3, 0.04, 0.09, 3, 3, 0.2,1.015, 0,$dannie);  
/*  
:  
300 -  
502 -  
1 - x (1-, 0-)  
1 - x (1-, 0-)  
3 -  
0.04 -  
0.09 - y  
3 -  
3 - y  
0.2 -  
1.015 - y  
0 - ( ) (0-, 1-)  
$dannie -  
*/  
$white=ImageColorAllocate ($a->im, 255, 255, 255);  
$blue=ImageColorAllocate ($a->im, 0, 0, 64);  
$red=ImageColorAllocate ($a->im, 250, 43, 5);  
$blue1=ImageColorAllocate ($a->im, 0, 64, 128);  
$a->set_color($white,$white,$white,$white,$white,$white,$white,$blue1,$white, $blue);  
$a->show();  
?>  
 


----------
Away/DND

: 52737 | . 04-04-2002 | : 23:29 14-05-2006
vworld



Silver Member
| | | |
 
 
, : , , ( , ).  
<?  
function pluralForm($n, $form1, $form2, $form5)  
{  
$n = abs($n) % 100;  
$n1 = $n % 10;  
if ($n > 10 && $n < 20) return $form5;  
if ($n1 > 1 && $n1 < 5) return $form2;  
if ($n1 == 1) return $form1;  
return $form5;  
}  
 
//  
echo " $n ".pluralForm($n, "", "", "");  
?>

: 2617 | . 13-02-2003 | : 07:32 20-10-2006
LusAvedus

Newbie
| | | |
. .
 

:
 
function input_check_numeric($input,$default_value=0) {
   ereg("([0-9]+[0-9]|[0-9]|(\-)[0-9]|(\-)[0-9]+[0-9])",$input,$match);
   return ((!$match) ? $default_value : $match[0]);
   }
 

 
.




?
- ? /Cheery/

: 2 | . 30-10-2006 | : 06:07 30-10-2006 | : Cheery, 07:17 30-10-2006
zerkms

Member
| | | ICQ | |
LusAvedus
- php.net/is_numeric
 
ps: 2.5 ?
pps: [0-9]+[0-9] [0-9]{2,}
ppps: (-)? 10

----------
tvfdor - rutracker |

: 387 | . 07-05-2004 | : 12:53 30-10-2006 | : zerkms, 12:57 30-10-2006
sTa1kEr



Member
| | | |
PHP . .. html , IB , mirc . PHP >5 !!! - . , ( - )
...

: 279 | . 28-07-2005 | : 18:43 20-11-2006
hire

Newbie
| | | |
dump :
 
dump (- - ):

:
 
/**
* Function for dump variables
*  
* @access public
* @global $_DEBUG
*/
function dump()
{
require_once 'dBug.class.php';

$id = rand();

$init = debug_backtrace();

$msg = "";
$lvl = count($init);
if ($lvl >= 1) {
// $msg .= "&nbsp;&nbsp;was called from :<BR>";
for ($k = $lvl-1; $k >= 0; $k--) {
$msg .= "&nbsp;[#".$k."] ";

if (isset($init[$k]["class"]))
$msg .= @$init[$k]["class"]."::";

if (isset($init[$k]["function"]))
$msg .= @$init[$k]["function"]."() called at ";

$msg .= "[/".basename(@$init[$k]["file"]).":".@$init[$k]["line"]."]<BR>";
}

}
 
global $_DEBUG;

if (!$_DEBUG) {
$_DEBUG = 1;
echo
"<script language='JavaScript'>\n".
" show_item=function(evt) { var obj=document.getElementById(evt); if(obj.className == \"\") { obj.className += \" over\"; }else{ obj.className = \"\"; } }\n".
"</script>\n";
echo "<style>\n";
echo "#debug {background-color:#ffffff; margin: 0;}".
"#debug ul {list-style-type: none; padding: 0 2 0 2; margin: 0;}".
"#debug li a{text-decoration: none; color: #003366; margin: 0; font-size: 12px;}".
"#debug li a:HOVER{color: #FF3300;}".
"#debug li ul{ display: none; padding: 2 2 2 2;}".
"#debug li ul li {background-color:#ddffdd; padding: 2 2 2 2; margin: 2;}".
"#debug li.over ul{display: block;}".
"#debug li.over a{color: #000000;;}";
echo "</style>\n";

echo"<script language='JavaScript'>
/* code modified from ColdFusion's cfdump code */
function dBug_toggleRow(source) {
target=(document.all) ? source.parentElement.cells[1] : source.parentNode.lastChild
dBug_toggleTarget(target,dBug_toggleSource(source));
}

function dBug_toggleSource(source) {
if (source.style.fontStyle=='italic') {
source.style.fontStyle='normal';
source.title='click to collapse';
return 'open';
} else {
source.style.fontStyle='italic';
source.title='click to expand';
return 'closed';
}
}

function dBug_toggleTarget(target,switchToState) {
target.style.display=(switchToState=='open') ? '' : 'none';
}

function dBug_toggleTable(source) {
var switchToState=dBug_toggleSource(source);
if(document.all) {
var table=source.parentElement.parentElement;
for(var i=1;i<table.rows.length;i++) {
target=table.rows[i];
dBug_toggleTarget(target,switchToState);
}
}
else {
var table=source.parentNode.parentNode;
for (var i=1;i<table.childNodes.length;i++) {
target=table.childNodes[i];
if(target.style) {
dBug_toggleTarget(target,switchToState);
}
}
}
}
</script>

<style type='text/css'>
table.dBug_array,table.dBug_object,table.dBug_resource,table.dBug_resourceC,table.dBug_xml {
font-family:Verdana, Arial, Helvetica, sans-serif; color:#000000; font-size:12px;
}

.dBug_arrayHeader,
.dBug_objectHeader,
.dBug_resourceHeader,
.dBug_resourceCHeader,
.dBug_xmlHeader  
{ font-weight:bold; color:#FFFFFF; }

/* array */
table.dBug_array { background-color:#006600; }
table.dBug_array td { background-color:#FFFFFF; }
table.dBug_array td.dBug_arrayHeader { background-color:#009900; }
table.dBug_array td.dBug_arrayKey { background-color:#CCFFCC; }

/* object */
table.dBug_object { background-color:#0000CC; }
table.dBug_object td { background-color:#FFFFFF; }
table.dBug_object td.dBug_objectHeader { background-color:#4444CC; }
table.dBug_object td.dBug_objectKey { background-color:#CCDDFF; }

/* resource */
table.dBug_resourceC { background-color:#884488; }
table.dBug_resourceC td { background-color:#FFFFFF; }
table.dBug_resourceC td.dBug_resourceCHeader { background-color:#AA66AA; }
table.dBug_resourceC td.dBug_resourceCKey { background-color:#FFDDFF; }

/* resource */
table.dBug_resource { background-color:#884488; }
table.dBug_resource td { background-color:#FFFFFF; }
table.dBug_resource td.dBug_resourceHeader { background-color:#AA66AA; }
table.dBug_resource td.dBug_resourceKey { background-color:#FFDDFF; }

/* xml */
table.dBug_xml { background-color:#888888; }
table.dBug_xml td { background-color:#FFFFFF; }
table.dBug_xml td.dBug_xmlHeader { background-color:#AAAAAA; }
table.dBug_xml td.dBug_xmlKey { background-color:#DDDDDD; }
</style>";
}  

echo"<div id=debug>
<ul>
<li id=\"".$id."\"><a name=\"".$id."\"></a><a onClick=\"javascript: show_item(".$id.");\" href=\"#".$id."\">".
"<b>Dump was called: </b><br>".
$msg.
"<b>Variables:<br></b></a>".
"<ul>\n";

foreach (func_get_args() as $var)
{
echo "<li>";

//if (is_string($var)) echo "string (".strlen($var)."): ";
new dBug($var);

echo "</li>\n";
}
echo"</ul></li></ul></div><HR>";
}
 

 
:

:
 
dump($_GET, $classRequest);
 

 
 
dBug (author Kwaku Otchere; modified)
..

: 20 | . 21-08-2006 | : 09:58 25-11-2006 | : hire, 10:11 25-11-2006
dacuan

Full Member
| | | |
hire

 
dBug
 
:

:
 
<?php
require_once("dBug.php");
 
$a = "123";
$b = "456";
 
//
dBug::dump($a, $b);
 
//
dBug::stop($a, $b);
 
?>
 

 
.

: 545 | . 23-10-2003 | : 10:43 25-11-2006
andymc

Newbie
| | | |

$length -
$dig    - ( - )
$lchar  - ( - )
$rchar  -
$symb   -
 

:
 
function generate_password($length,$dig=1,$lchar=1,$rchar=0,$symb=''){
    $dig=array(0,1,2,3,4,5,6,7,8,9);
    $rus=array(
    "","","","","","","","","","",
    "","","","","","","","","","",
    "","","","","","","","","","",
    "","","");
    $for=array(
    "a","b","c","d","e","f","g","h","j","k",
    "l","m","n","o","p","q","r","s","t","u",
    "v","w","x","y","z");
    $main=array();
    $dig?$main=array_merge($main,$dig):true;
    $rchar?$main=array_merge($main,$rus):true;
    $lchar?$main=array_merge($main,$for):true;
    !empty($symb)?$main=array_merge($main,explode(' ',$symb)):true;
    shuffle($main);
    return $pass=substr(implode('',$main),0,$length);
}
 



:
 
function optimize_html($s){
    $s=str_replace("\n"," ",$s);
    $s=str_replace("\r"," ",$s);    
    //$s=str_replace("href=\"http://".$_SERVER['HTTP_HOST']."/","/",$s);
    while(strchr($s,"  ")){
        $s=str_replace("  "," ",$s);
    }
    while(strchr($s,"    ")){
        $s=str_replace("    "," ",$s);
    }    
    while(strchr($s,"  ")){
        $s=str_replace("  "," ",$s);
    }    
    return $s;
}
 

 


:
 
function fw_($file,$str){
    $fo=fopen($file,'w+') or die(" ");
    if(fwrite($fo,$str)){
        fclose($fo);
        return true;
    }else{
        fclose($fo);
        return false;
    };
}
 

 


:
 
function fa_($file,$str){
    $fo=fopen($file,'a+') or die(" ");
    if(fwrite($fo,$str)){
        fclose($fo);
        return true;
    }else{
        fclose($fo);
        return false;
    };    
}
 

: 18 | . 21-09-2006 | : 23:41 09-12-2006 | : andymc, 09:08 10-12-2006
LusAvedus

Newbie
| | | |

:
LusAvedus
- php.net/is_numeric
 
ps: 2.5 ?
pps: [0-9]+[0-9] [0-9]{2,}
ppps: (-)? 10

 
1. is_numeric . .
2. .
3. ,   .

: 2 | . 30-10-2006 | : 16:03 10-12-2006
andymc

Newbie
| | | |
LusAvedus
" ", eregi_replace("[0-9]*",$input).
,
 
 
:

( )
( )

:
 
function startTimer(){
    global $starttime;
    $starttime = microtime();
    return $starttime;
}
function endTimer(){
    global $starttime;
    $pageendtime = microtime();
    $starttime2 = explode(" ",$starttime);
    $endtime = explode(" ",$pageendtime);
    $totaltime = $endtime[0]-$starttime2[0]+$endtime[1]-$starttime2[1];
    $totaltime = round($totaltime, 3);
    return $totaltime;
}
 

:

:
 
$start_time=startTimer();
$timer=array();
$timer['start']=endTimer();
 

$timer['']=endTimer();

:
 
$timer['modules']=endTimer();
...
$timer['content']=endTimer();
 

$timer

:
 
echo "<pre style='font-size:10px'>";
print_r($timer);
echo "</pre>";
 

 
:
,
, ,

:
 
$root_base=str_replace('/'.basename($_SERVER['PHP_SELF']),'',$_SERVER['PHP_SELF']);
$root_dir=str_replace('/','',$root_base);
// $root_dir -
 

 
, ( , )

:
 
$is_robot=(strchr($_SERVER['HTTP_USER_AGENT'],'StackRambler') || stristr($_SERVER['HTTP_USER_AGENT'],'Yandex') || strchr($_SERVER['HTTP_USER_AGENT'],'Googlebot') || strchr($_SERVER['HTTP_USER_AGENT'],'Yahoo! Slurp')|| strchr($_SERVER['HTTP_USER_AGENT'],'Mail.ru'));
 



, PHP .

:
 
....
a:link,  a{text-decoration: none; color: <?php echo $linkColor ?>;}
....
 



:
 
<html><head><style><?php include($dir_images.'/style2.css');?></style>...
 

,
 
:


$_SERVER['HTTP_HOST']=str_replace("www.","",$_SERVER['HTTP_HOST']);
if ($QUERY_STRING!=''){
   $current_url="http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."?".$QUERY_STRING;
} else {
   $current_url="http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
}
 


function extract_site($url){
    $part=substr($url,8);
    $end=strchr($part,"/");
    $site=str_replace($end,'',$url)."/";    
    $site=str_replace('www.','',$site);    
    return $site;        
}
 

$s $e
function extract_str($str,$s,$e){
    if (!strchr($str,$s)) return $str;
    $start=strpos($str,$s);
    $end=strpos($str,$e,$start);
    return substr($str,$start,$end-$start);
}
 


// $string - ( $QUERY_STRING)
// $name -
function get_query_value($string,$name){
    if (strchr($string,"$name=")){
        $string=substr(strchr($string,"$name="),1+strlen($name));
        if (strchr($string,'&')){
            $string=str_replace(strchr($string,'&'),'',$string);    
        }
        return $string;        
    } else {
        return false;        
    }
}

: 18 | . 21-09-2006 | : 19:45 10-12-2006 | : andymc, 21:38 10-12-2006
Cheery



.::.
| | | |
andymc
, ?

:
if ($QUERY_STRING!=''){

register_globals=off.. $_SERVER

:

www.php.net/parse_url

:

www.php.net/parse_url  + www.php.net/parse_str
 
 
ps: .

----------
Away/DND

: 52737 | . 04-04-2002 | : 07:07 12-12-2006
chs52ncm

Newbie
| | | |
HTTP PHP. . .
 
 
 
 





? . /Cheery/

: 4 | . 01-09-2006 | : 14:45 15-12-2006 | : Cheery, 15:22 15-12-2006
andymc

Newbie
| | | |
( )
, .css . .
$styles
$a[' ']['']=

:
 
//$s=file_get_contents('style.css');
$s=file_get_contents("index.htm");
$styles=array();
if (strchr($s,'<style>')){
    $start=strpos($s,'<style>')+7;
    $end=strpos($s,'</style>');
    $s=substr($s,$start,$end-$start);
}
$start=0;
if (substr_count($s,'{')>0&&substr_count($s,'}')>0){    
    while (strchr($s,'{')){
         
        $st0=strpos($s,'{');
        $st1=strpos($s,'}');
        $style_name=trim(substr($s,$start,$st0));
        $style_body=trim(substr($s,$st0+1,$st1-$st0-1));
        $styles[$style_name]=array();        
         
        while (strchr($style_body,':')){            
            $dv=strpos($style_body,':');
            $tz=strpos($style_body,';');
            $name=trim(substr($style_body,0,$dv));
            $value=trim(substr($style_body,$dv+1,$tz-$dv-1));
            $style_body=substr($style_body,$tz+1);
            $styles[$style_name][$name]=$value;
        }
         
        $s=substr($s,$st1+1);
    }
}
print_br($styles);
 

// html  
// , PHP ( )

: 18 | . 21-09-2006 | : 13:25 18-12-2006 | : andymc, 13:26 18-12-2006
drew2006

BANNED
| | | |
translate.ru
.
 
function translate ($src) {
 
$ch = curl_init();
 
curl_setopt($ch, CURLOPT_URL, 'http://www.translate.ru/text.asp');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, 'status=translate&direction=re&transliterate=ON&source='.urlencode($src));
 
$html = curl_exec($ch);
curl_close($ch);
 
preg_match('|<span id="r_text" name="r_text">(.*?)</span>|s', $html, $rst);
$rst = strtolower(preg_replace('|[\s]+|', '_', trim($rst[1])));
 
return $rst;
 
}

: 12 | . 28-01-2006 | : 21:38 28-12-2006 | : drew2006, 21:39 28-12-2006
mctaddy



Newbie
| | | |





. ? /Cheery/
ps: PHP

: 28 | . 20-04-2006 | : 00:03 18-01-2007 | : Cheery, 00:04 18-01-2007
Jokerjar



BANNED
| | | |
, "?" (.. )?
 
,




.. ! /Cheery/

: 591 | . 22-03-2006 | : 19:51 21-01-2007 | : Cheery, 21:22 21-01-2007
G_Drey_V

Junior Member
| | | |
$GLOBALS['HTTP_RAW_GET_DATA'] - $GLOBALS['HTTP_RAW_POST_DATA'], , - ... , -, - header- .. print_r($_SERVER)

: 158 | . 20-12-2003 | : 21:20 21-01-2007
Cheery



.::.
| | | |
G_Drey_V
.. phpinfo();
 
$_SERVER["QUERY_STRING"]
 
 
 
ps: , ,

----------
Away/DND

: 52737 | . 04-04-2002 | : 21:24 21-01-2007
     

: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

Ru.Board » » Web- » PHP: ( )


Ru.Board.

Powered by Ikonboard "v2.1.7b" © 2000 Ikonboard.com
Modified by Ru.Board
© Ru.Board 2000-2020

BitCoin: 1NGG1chHtUvrtEqjeerQCKDMUi6S6CG4iC

.ru