salto de linea nl2br – php
#saltos de linea desde la plantilla de symfony <?php echo nl2br($package[‘politics’])?>
#saltos de linea desde la plantilla de symfony <?php echo nl2br($package[‘politics’])?>
function randomPass($longitud) { $pattern = “1234567890abcdefghijklmnopqrstuvwxyz”; for($i=0;$i<$longitud;$i++) { $key .= $pattern{rand(0,35)}; } … Read More »Generar un password automatico
<?php $file = “ip_data.dat”; $duration = 30*60; //30 minutes $lines = file($file); foreach($lines as $line) { list($ip, $time) = explode(“µ”, $line); if($time > time()–$duration) { $ips[$ip] = trim($time); } } $ip = $_SERVER[‘REMOTE_ADDR’]; if(@array_key_exists($ip, $ips)) { if($ips[$ip] > time()–$duration) { // TRUE $ips[$ip] = time(); $was_here = TRUE; } } else { $ips[$ip] = time(); $was_here = FALSE; } $fp = fopen($file, “w”); foreach($ips as $ip=>$time) { fputs($fp, $ip.“µ”.$time.“\n“);… Read More »filebased ip lock
//MenuCardTable.class public function getMenuCardForCombo(){ $q = Doctrine_Query::create() ->select(‘m.*’) ->from(‘MenuCard m’); … Read More »colocar un item por defecto a un combo relacionado
Note Necesario para eliminar el cache del explorador cuando se utiliza ajax para mostrar resultados en un contenedor div <? header(“Expires: Tue, 01 Jul… Read More »Eliminar Cache del explorador
// Call a class method outside the class call_user_func(array($myclass, $mymethod), $args); // Call a class method inside the class call_user_func(array($this, $mymethod), $args); //or $this->{$mymethod}($args);
<?php $url = “http://www.url.net/file.zip”; $file = “file.zip”; $esc = escapeshellarg($url); exec(“wget “ . $esc); //use ur extension… Read More »wget, unzip and delete a File per Shell via PHP
if (isset($_SERVER[‘REMOTE_ADDR’])) die(‘Permission denied.’); Note it’s also possibl with a .htaccess file and “deny from all ” in that file
<?php if ( !strpos($_SERVER[‘HTTP_USER_AGENT’], ‘Gecko’) ) { ?> <!– Firefox dışında ki tarayıcılarda göstermek istediğiniz kodları buraya yerleştirin –> <?php } ?> Note mesela adsense’nin… Read More »Firefox tarayıcısı dışında bir tarayıcıda istediğini gösterme
$start = microtime(TRUE); // Code PHP à bencher for ($i = 0; $i < 10000; $i++) { isset($array[‘id’]); } echo number_format(microtime(TRUE) – $start,… Read More »Calculer le temps d’exécution d’un code PHP