| |||
$_server[http_host] Bueno estoy haciendo un sistema de links afiliados, es deciur de intercambio de enlaces, y todo va conectado a una misma base datos, como tengo a mi cargo como 150 WebSites distintos y para saber en cual se esta ejecutando el Script lo que hago asignar la variable $dominio = $HTTP_HOST, todos estan en nuestro server y hay 1 en especial que tiene distinta ip. Por alguna Razon $dominio = $HTTP_HOST no funciono en esta, asi que decidi usar $dominio = $_SERVER[HTTP_HOST], y este si me dio el dato, peroooo!!!! me dio un error al ejecutar el Script. para ser mas especifico, se comio toda la memoria ram de este.... realmente no se que fue lo que paso. alguien tiene alguna idea de que pudo haber pasado. DE ANTEMANO GRACIAS |
| |||
Respuesta: $_server[http_host]
Código:
<body> <? include('conex2.php'); // Conexion a la base de datos $link=conectarse(); //variable donde guardo la conexion. include('check_pr.php'); echo '<center>'; if (isset($ingreso[ingreso])) { echo '<table width="75%" border="1" cellspacing="0" cellpadding="0"><tr><td class="notificacion">'.$ingreso[ingreso].'</td></tr></table>'; } if (isset($error[primeros]) { echo '<table width="75%" border="1" cellspacing="0" cellpadding="0"><tr><td class="notificacion">'.$error[falta].'</td></tr></table>'; } echo '</center>'; ?> <table width="80%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="50%" valign="top" class="afiliados"> <?php $vacio=array(); $dominio='http://'.$HTTP_HOST; // ESTE PARAMETRO CAMBIE POR $_SERVER[HTTPE_HOST]; echo '<table><th title="Google PageRank">PR</th><th></th>'; $buscar=mysql_query("select * from afiliados where enlace_afi='$dominio'",$link); $site=mysql_fetch_object($buscar); $afi=mysql_query("SELECT * FROM afiliados",$link); $cont=0; while($row = mysql_fetch_array($afi)) { $cont=$cont+1; $pr = get_page_rank($row[enlace_afi]); if ($pr<0){ $pr=0; } echo '<tr><td> <img src="http://www.tppemarketing.com/opti_images/pr'.$pr.'.gif" title="Google PageRank: '.$pr.'/10" /> </td><td><b><a href="'.$row[enlace_afi].'" title="'.$p.'">'.$row[nombre_afi].' </a></b> - '.$row[enlace_afi].' <br />'.$row[descripcion_afi].'</td></tr>'; if($cont==1) { $p=$site->kw1_afi; } if($cont==2) { $p=$site->kw2_afi; } if($cont==3) { $p=$site->kw3_afi; $cont=0; } } $intercambio=mysql_query("SELECT * FROM intecambio where local_inter='$dominio' AND status_inter='activo'",$link); while($row2 = mysql_fetch_array($intercambio)) { $cont=$cont+1; $pr = get_page_rank($row2[remote_inter]); if ($pr<0){ $pr=0; } echo '<tr><td> <img src="http://www.tppemarketing.com/opti_images/pr'.$pr.'.gif" title="Google PageRank: '.$pr.'/10" /> </td><td><b><a href="'.$row2[remote_inter].'" title="'.$p.'">'.$row2[titulo_inter].' </a></b> - '.$row2[remote_inter].' <br />'.$row2[descrip_inter].'</td></tr>'; if($cont==1) { $p=$site->kw1_afi; } if($cont==2) { $p=$site->kw2_afi; } if($cont==3) { $p=$site->kw3_afi; $cont=0; } } echo '</table>'; ?></td> <td width="50%" valign="top" class="ingresa" id="stylized"><form action="interlink.php" method="post" name="intercambio" id="intercambio"> <fieldset> <legend><b>INGRESA TU ENLACE</b></legend> <p><b>1er PASO</b>: agrega un enlace de nuestra pagina en tu sitio. </p> <table border="0"> <tr> <td valign="top">Direccion URL:</td> <td valign="top"><a href="<?php echo $site->enlace_afi; ?>" target="_blank"><?php echo $site->enlace_afi; ?></a></td> </tr> <tr> <td valign="top">Titulo del enlace :</td> <td valign="top"><?php echo $site->nombre_afi; ?></td> </tr> <tr> <td valign="top">Descripcion:</td> <td valign="top"><?php echo $site->descripcion_afi; ?></td> </tr> </table> <p><br /> ó puedes copiar el texto de abajo y pegarlo en tu sitio web. <br /><br /> <textarea name="textarea" cols="30" rows="2" onfocus="this.select()"><a href="<?php echo $site->enlace_afi; ?>"><?php echo $site->nombre_afi; ?></a> - <?php echo $site->descripcion_afi; ?></textarea> <br /> <br /> <br /> </p> <b>2do PASO</b>: Ingresa los datos de tu enlace: <table border="0"> <tr> <td><strong>Tu nombre :</strong> <input type="text" name="nombre" size="40" maxlength="50" id="nombre" /></td> <td><? echo $error[nombre]; ?></td> </tr> <tr> <td><b>tu E-mail:</b><input type="text" name="email" size="40" maxlength="50" id="email"/></td> <td><? echo $error[email]; ?></td> </tr> <tr> <td><b>Titulo de tu sitio :</b> <input type="text" name="titulo" size="40" maxlength="50" id="titulo" /></td><td><? echo $error[titulo]; ?></td> </tr> <tr> <td><b>URL de tu enlace:</b> <input type="text" name="enlace" maxlength="100" value="http://" size="40" id="direccion" /></td><td><? echo $error[enlace]; ?></td> </tr> <tr> <td><b>URL donde esta el enlace: </b> <input type="text" name="renlace" maxlength="100" value="http://" size="40" /></td><td><? echo $error[renlace]; ?></td> </tr> <tr> <td><b>Descripcion del enlace: </b> <input name="descripcion" type="text" maxlength="200" size="60" id="descripcion"/></td><td><? echo $error[descripcion]; ?></td> </tr> </table> <br /> <center> Acepto <a href="http://www.tppemarketing.com/terminos.html">los terminos</a><br> <input name="terminos" type="checkbox" value="aceptado" id="aceptar"/> <? echo $error[terminos]; ?> <br /> <br /> Codigo de Verificacion: <br /> <? $valoraleatorio=rand(100000,999999) ; $_SESSION['rand']=$valoraleatorio; echo $valoraleatorio; ?><br /> <label for="valor">codigo:</label><br><input name="valor" type="text" maxlength="6" width="25" size="6" id="codigo"/><? echo $error[rando]; for($i=0;$i<=count($error);$i++) { $error[$i]=0; } $ingreso=$vacio; ?> <br /> <br /> <input type="submit" value="ingresar" id="aceptar" /> </center> <br /> </p> </fieldset> </form> </td> </tr> </table> <? mysql_free_result($afi); mysql_free_result($intercambio); mysql_free_result($buscar); ?> </body> </html> ACA ESTA EL CODIGO QUE SOLICISTASTE. ESPERO QUE ALGUIEN TENGA ALGUNA IDEA. |
| ||||
Respuesta: $_server[http_host] Pues en el código que expones no se ve donde pueda existir un memory leak excepto en el archivo include('check_pr.php');. Como te comento es muy dificil ver este tipo de errores sin hacer un debug en el server y ver viendo que es lo que pasa. Saludos. |
| |||
Respuesta: $_server[http_host] ESte es un carchivo que verifica el pageRank en Google
Código:
<?php define('GOOGLE_MAGIC', 0xE6359A60); function zeroFill($a, $b) { $z = hexdec(80000000); if ($z & $a) { $a = ($a>>1); $a &= (~$z); $a |= 0x40000000; $a = ($a>>($b-1)); }else{ $a = ($a>>$b); } return $a; } function toInt32(& $x){ $z = hexdec(80000000); $y = (int)$x; if($y==-$z&&$x<-$z){ $y = (int)((-1)*$x); $y = (-1)*$y; } $x = $y; } function mix($a,$b,$c) { $a -= $b; $a -= $c; toInt32($a); $a = (int)($a ^ (zeroFill($c,13))); $b -= $c; $b -= $a; toInt32($b); $b = (int)($b ^ ($a<<8)); $c -= $a; $c -= $b; toInt32($c); $c = (int)($c ^ (zeroFill($b,13))); $a -= $b; $a -= $c; toInt32($a); $a = (int)($a ^ (zeroFill($c,12))); $b -= $c; $b -= $a; toInt32($b); $b = (int)($b ^ ($a<<16)); $c -= $a; $c -= $b; toInt32($c); $c = (int)($c ^ (zeroFill($b,5))); $a -= $b; $a -= $c; toInt32($a); $a = (int)($a ^ (zeroFill($c,3))); $b -= $c; $b -= $a; toInt32($b); $b = (int)($b ^ ($a<<10)); $c -= $a; $c -= $b; toInt32($c); $c = (int)($c ^ (zeroFill($b,15))); return array($a,$b,$c); } function GoogleCH($url, $length=null, $init=GOOGLE_MAGIC) { if(is_null($length)) { $length = sizeof($url); } $a = $b = 0x9E3779B9; $c = $init; $k = 0; $len = $length; while($len>= 12) { $a += ($url[$k+0] +($url[$k+1]<<8) +($url[$k+2]<<16) +($url[$k+3]<<24)); $b += ($url[$k+4] +($url[$k+5]<<8) +($url[$k+6]<<16) +($url[$k+7]<<24)); $c += ($url[$k+8] +($url[$k+9]<<8) +($url[$k+10]<<16)+($url[$k+11]<<24)); $mix = mix($a,$b,$c); $a = $mix[0]; $b = $mix[1]; $c = $mix[2]; $k += 12; $len -= 12; } $c += $length; switch($len) /* all the case statements fall through */ { case 11: $c+=($url[$k+10]<<24); case 10: $c+=($url[$k+9]<<16); case 9 : $c+=($url[$k+8]<<8); /* the first byte of c is reserved for the length */ case 8 : $b+=($url[$k+7]<<24); case 7 : $b+=($url[$k+6]<<16); case 6 : $b+=($url[$k+5]<<8); case 5 : $b+=($url[$k+4]); case 4 : $a+=($url[$k+3]<<24); case 3 : $a+=($url[$k+2]<<16); case 2 : $a+=($url[$k+1]<<8); case 1 : $a+=($url[$k+0]); /* case 0: nothing left to add */ } $mix = mix($a,$b,$c); /*-------------------------------------------- report the result */ return $mix[2]; } //converts a string into an array of integers containing the numeric value of the char function strord($string) { for($i=0;$i<strlen($string);$i++) { $result[$i] = ord($string{$i}); } return $result; } function get_page_rank($url) { $url = preg_replace('/\?.*$/','?',$url); $reqgr = "info:".$url; $reqgre = "info:".urlencode($url); $gch = "6".GoogleCH(strord($reqgr)); $fsock = fsockopen('toolbarqueries.google.com', 80, $errno, $errstr); if ( !$fsock ){ echo 'Can not connect to server'; return -1; } $base_get = "/search?client=navclient-auto&ch=".$gch."&ie=UTF-8&oe=UTF-8&features=Rank:FVN&q=".$reqgre; fputs($fsock, "GET $base_get HTTP/1.1\r\n"); fputs($fsock, "HOST: toolbarqueries.google.com\r\n"); fputs($fsock, "User-Agent: Mozilla/4.0 (compatible; GoogleToolbar 2.0.114-big; Windows XP 5.1)\r\n"); fputs($fsock, "Connection: close\r\n\r\n"); while(!feof($fsock)){ $res['content'] .= fread($fsock, 1024); } fclose($fsock); if(preg_match('/Rank_.*?:.*?:(\d+)/i', $res['content'], $m)){ return $m[1]; }else{ return -1; } } ?> |
| ||||
Respuesta: $_server[http_host] Pues (a lo mejor) el error podria estar en estas lineas:
Código php:
Ver original Pero sin conocer como trabaja ni el porque ni viendo logs de errores es dificil saberlo. Saludos. |