Ver Mensaje Individual
  #11 (permalink)  
Antiguo 06/11/2005, 18:45
Avatar de kurorix
kurorix
 
Fecha de Ingreso: junio-2005
Ubicación: Maipu - Santiago - Chile
Mensajes: 54
Antigüedad: 18 años, 10 meses
Puntos: 0
Lo prometido es deuda. ...
Código PHP:
<?php 
ini_set
('display_errors'1); 
$host "dominio.com"// domain name 
$port 2082//cpanel port (always 2082) 
$path "/frontend/x/cron/editcron.html?mailto=xxx"// url del cron. 
// $DOCUMENT_ROOT;

//Vemos el registro del cron.
/*
Bueno, creamos un registro del cron ya que cuando se ingresaba un nuevo registro, se borraba el o los anteriores registros existentes, de esta forma ingresamos todos los registros que ya existian nuevamente.
*/
include('config.php');
$result mysql_db_query($db,"SELECT * FROM cron");
$entcont mysql_num_rows($result);
$i 1;
while(
$row mysql_fetch_array($result))
{
// $i-minute, $i-hour..., En mi caso, estas variables reciben los parametros necesario.
    
$path .= "&$i-minute=".$row['minute'];
    
$path .= "&$i-hour=".$row['hour'];
    
$path .= "&$i-day=".$row['day'];
    
$path .= "&$i-month=".$row['month'];
    
$path .= "&$i-weekday=".$row['weekday'];
    
$path .= "&$i-command=".$row['command'];
    
$i++;
}

//Agregamos el nuevo registro.
$command $_POST['command']; //Ej: $command = "GET%20http://www.$host/archivo.php%20>%20/dev/null";
//No olbidar %20 para los espacios.
if($_POST[command] <> ''){
    
$path .= "&entcount=$entcont";
    
$path .= "&0-minute=".$minute $_POST['minute'];
    
$path .= "&0-hour=".$hour $_POST['hour'];
    
$path .= "&0-day=".$day $_POST['day'];
    
$path .= "&0-month=".$month $_POST['month'];
    
$path .= "&0-weekday=".$weekday $_POST['weekday'];
    
$path .= "&0-command=".$command;

//Agregamos el nuevo registro.
    
mysql_db_query($db,"INSERT INTO cron(minute, hour, day, month, weekday, command) VALUES ('$minute', '$hour', '$day', '$month', '$weekday', '$command')");
    echo 
mysql_error();
}

// cpanel login info 
$cpaneluser "*****"
$cpanelpass "++++++"
$authstr "$cpaneluser:$cpanelpass"
//**************************** 

// Set auth str 
$pass base64_encode($authstr); 

$fp fsockopen($host$port$errno$errstr$timeout 30); 

if(!
$fp){ 
// error tell us 
echo "$errstr ($errno)\n"

}else{ 

// server request 

fputs($fp"POST $path HTTP/1.1\r\n"); 
fputs($fp"Host: $host\r\n"); 
fputs($fp"Authorization: Basic $pass \r\n"); 
fputs($fp"Content-type: application/x-www-form-urlencoded\r\n"); 
fputs($fp"Content-length: ".strlen($poststring)."\r\n");
fputs($fp"Connection: close\r\n\r\n"); 
fputs($fp$poststring "\r\n\r\n"); 

while(!
feof($fp)) { fgets($fp4096); } 
//close fp - we are done with it 
fclose($fp); 

print 
"Programacion Exitosa."
?>
Bueno eso seria todo, espero que les sirva...