ejecutarConsulta( ' select count(*) as n from sitiosip where sip_ip = \'' . $VIP . '\' and sip_sitio is not null and sip_ts > now() - INTERVAL ' . INTERVALO_IP . ' ' ); if ( $s[0]['n'] < SITIOSxDIA ) { $d = $conexion->ejecutarConsulta( ' select sit_id, sit_url, sit_prioridad from sitios left join ( select sip_sitio, count(*) as c from sitiosip where sip_ts > now() - INTERVAL ' . INTERVALO_LIM . ' group by sip_sitio ) ss1 on sip_sitio = sit_id where (sit_limite > c or c is null) and ( select count(*) from sitiosip where sip_ip = \'' . $VIP . '\' and sip_sitio = sit_id and sip_ts > now() - INTERVAL ' . INTERVALO_IP . ' ) = 0 ' ); if ( count($d) ) { $r = 0; foreach ($d as $iter) $r += $iter['sit_prioridad']; for($r = mt_rand(1, $r), $c = 0; $d[$c]['sit_prioridad'] < $r; $r -= $d[$c++]['sit_prioridad']); $sip = $d[$c]['sit_id']; } } if ( is_null($sip) ) { $sip = 'null'; if ( isset( $_POST['simu'] ) ) { echo 'NingĂșn sitio disponible'; } else { header('HTTP/1.1 204 No Content'); } } else { if ( isset( $_POST['simu'] ) ) { echo 'IFRAME : ' . $d[$c]['sit_url']; } else { echo ''; } } $conexion->ejecutarAccion( 'insert into sitiosip(sip_ip, sip_sitio, sip_ref) values(\'' . $VIP . '\', ' . $sip . ', \'' . $REF . '\')' ); require_once $INCPATH . '_includes/ender.php'; ?>