Ver Mensaje Individual
  #3 (permalink)  
Antiguo 08/06/2011, 09:09
Suskos
 
Fecha de Ingreso: agosto-2009
Mensajes: 52
Antigüedad: 15 años, 4 meses
Puntos: 4
Respuesta: Página carga 1 vez, comando de actualización se ejecuta dos veces.

Buenas.
No se trata de un include que se incluye varias veces.
No he puesto el código porque estoy casi segura que el problema no está en el código que se ejecuta del lado del servidor.

Código PHP:


define
("THIS_PAGE",'watch_premium_video');

define("PARENT_PAGE",'videos');

require 
'includes/config.inc.php';

$userquery->perm_check('view_video',true);

$pages->page_redir();




$vkey = @$_GET['data'];
$from substr($_SERVER['HTTP_REFERER'],0,28);
/*$from = "httpreferer: ".$_SERVER['HTTP_REFERER'].'<br/>';
$from .= "server: ".$_SERVER['SERVER_NAME'].'<br/>';
$from .= "document root: ".$_SERVER['DOCUMENT_ROOT'].'<br/>';*/
assign('from',$from);

if(
video_playable($vkey))

{

    
$vdo $cbvid->get_video($vkey);

    

    
//Checking for playlist

    
$pid $_GET['play_list'];

    if(!empty(
$pid))

    {

        
$plist $cbvid->action->get_playlist($pid,userid());

        if(
$plist)

            
$_SESSION['cur_playlist'] = $pid;

    }

    

    if(
post('send_content'))

    {

        
//Sending Video

        
$cbvid->set_share_email($vdo);

        
$cbvid->action->share_content($vdo['videoid']);

    }

    

    
//Calling Functions When Video Is going to play
    
call_watch_video_function($vdo);
    
    
//antiguamente esta llamada se realizaba dentro de call_watch_video_function
    //se ha separado para incrementar los contadores premium solo cuando el vídeo es premium    
    //casos en los que se incrementa el contador de videos premium
    //1. cuando es la primera vez que se accede al video
    //   (no existe la cookie con el id del vídeo) o (la cookie con el id de transacción asociada al video es distinta del id de transacción recibido por get)
    
if(!isset($_COOKIE['video_'.$vdo['videoid']])or($_COOKIE['trxid_video_'.$vdo['videoid']]!=$_GET["trxid_video"])){
        
increment_premium_views($vdo['videoid']);
    }
    
assign('cookie',$_COOKIE['trxid_video_'.$vdo['videoid']]);
    
assign('trxid',$_GET['trxid']);
    

    
//adding Comment
    
    
if(isset($_POST['add_comment']))

    {

        
$cbvideo->add_comment($_POST['comment'],$vdo['videoid']);

        
$vdo['comments_count'] = $cbvid->count_video_comments;

    }

    

    
//Adding Video To Favorites
    
    
if(isset($_REQUEST['favorite']))

    {

        
$cbvideo->action->add_to_fav($vdo['videoid']);

    }

    

    
assign('vdo',$vdo);

    
assign('user',$userquery->get_user_details($vdo['userid']));
    
    
subtitle($vdo['title']);



}else

    
$Cbucket->show_page false;



//Return category id without '#'
$v_cat $vdo['category'];
if(
$v_cat[2] =='#') {
$video_cat $v_cat[1];
}else{
$video_cat $v_cat[1].$v_cat[2];}
$vid_cat str_replace('%#%','',$video_cat);


assign('vid_cat',$vid_cat);


$log_this date('Y-m-d H:i:s') . '|' microtime();
foreach(
$_SERVER as $key => $value){
    
$log_this .= "[$key]=$value";
}
$log_this .= "<br />\n";
error_log($log_this,3,'log_file.txt');


//Displaying The Template
template_files('watch_premium_video.html');
display_it(); 
La función increment_premium_views es la que lanza el update que te comentaba.
A base de amargarme sin saber porqué se ejecuta dos veces el código, se me medio ocurrió crear un log para registrar las "requests" a las que atiende esta página.

El resultado del log es:
Código:
2011-06-08 18:56:35|0.88989100 1307544995[DOCUMENT_ROOT]=/home/radicals/public_html[GATEWAY_INTERFACE]=CGI/1.1[HTTP_ACCEPT]=text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8[HTTP_ACCEPT_ENCODING]=gzip, deflate[HTTP_CONNECTION]=keep-alive[HTTP_COOKIE]=video_70=watched; trxid_video_70=f70aba30-8aac-4ea8-b5dc-0d763d6180e8; video_71=watched; trxid_video_71=0030bfe0-299d-49fd-aa83-da5850897d94; video_68=watched; trxid_video_68=1686e89f-23ee-4519-924f-6335ba427ea3; PHPSESSID=d7d7fafb9556c9590c9ff1890cdc1a9d; pageredir=http%3A%2F%2Fwww.radicalswinger.tv%2Fupload%2Fwatch_premium_video.php%3FDATAS%3D71%26data%3D71%26codes%3D1234%26code%3D1234%26trxid%3D0030bfe0-299d-49fd-aa83-da5850897d94%26transaction_id%3D0030bfe0-299d-49fd-aa83-da5850897d94[HTTP_HOST]=www.radicalswinger.tv[HTTP_KEEP_ALIVE]=115[HTTP_REFERER]=http://payment.allopass.com/acte/scripts/iframe/right.apu?ids=255654&%20idd=1014134&%20lang=es&data=71[HTTP_USER_AGENT]=Mozilla/5.0 (Windows NT 6.0; rv:2.0.1) Gecko/20100101 Firefox/4.0.1[PATH]=/bin:/usr/bin[QUERY_STRING]=DATAS=71&data=71&codes=1234&code=1234&trxid=8a8bde7a-c0d9-4178-a464-fca9385e80b8&transaction_id=8a8bde7a-c0d9-4178-a464-fca9385e80b8[REDIRECT_STATUS]=200[REMOTE_ADDR]=88.3.224.19[REMOTE_PORT]=61285[REQUEST_METHOD]=GET[REQUEST_URI]=/upload/watch_premium_video.php?DATAS=71&data=71&codes=1234&code=1234&trxid=8a8bde7a-c0d9-4178-a464-fca9385e80b8&transaction_id=8a8bde7a-c0d9-4178-a464-fca9385e80b8[SCRIPT_FILENAME]=/home/radicals/public_html/upload/watch_premium_video.php[SCRIPT_NAME]=/upload/watch_premium_video.php[SERVER_ADDR]=109.205.137.195[SERVER_ADMIN][email protected][SERVER_NAME]=www.radicalswinger.tv[SERVER_PORT]=80[SERVER_PROTOCOL]=HTTP/1.1[SERVER_SIGNATURE]=<address>Apache/2.0.63 (Unix) mod_ssl/2.0.63 OpenSSL/0.9.8e-fips-rhel5 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 Server at www.radicalswinger.tv Port 80</address>
[SERVER_SOFTWARE]=Apache/2.0.63 (Unix) mod_ssl/2.0.63 OpenSSL/0.9.8e-fips-rhel5 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635[PHP_SELF]=/upload/watch_premium_video.php[REQUEST_TIME]=1307544995[argv]=Array[argc]=1<br />

2011-06-08 18:56:36|0.57464300 1307544996[DOCUMENT_ROOT]=/home/radicals/public_html[GATEWAY_INTERFACE]=CGI/1.1[HTTP_ACCEPT]=text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8[HTTP_ACCEPT_ENCODING]=gzip, deflate[HTTP_CONNECTION]=keep-alive[HTTP_COOKIE]=quick_list_box=show; video_70=watched; trxid_video_70=f70aba30-8aac-4ea8-b5dc-0d763d6180e8; video_71=watched; trxid_video_71=0030bfe0-299d-49fd-aa83-da5850897d94; video_68=watched; trxid_video_68=1686e89f-23ee-4519-924f-6335ba427ea3; PHPSESSID=69c0ef2b81af8273be977ee78aa10036; pageredir=http%3A%2F%2Fradicalswinger.tv%2Fupload%2Fpay_per_video.php%3Fv%3D69B329XXMO9S; WibiyaLoads=67; WibiyaProfile=%7B%22toolbar%22%3A%7B%22stat%22%3A%22Max%22%7D%2C%22apps%22%3A%7B%22openApps%22%3A%7B%7D%7D%2C%22connectUserNetworks%22%3A%5Bnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%5D%7D; WibiyaNotification248688=248688[HTTP_HOST]=radicalswinger.tv[HTTP_KEEP_ALIVE]=115[HTTP_REFERER]=http://payment.allopass.com/acte/scripts/iframe/right.apu?ids=255654&%20idd=1014134&%20lang=es&data=71[HTTP_USER_AGENT]=Mozilla/5.0 (Windows NT 6.0; rv:2.0.1) Gecko/20100101 Firefox/4.0.1[PATH]=/bin:/usr/bin[QUERY_STRING]=DATAS=71&data=71&codes=1234&code=1234&trxid=8a8bde7a-c0d9-4178-a464-fca9385e80b8&transaction_id=8a8bde7a-c0d9-4178-a464-fca9385e80b8[REDIRECT_STATUS]=200[REMOTE_ADDR]=88.3.224.19[REMOTE_PORT]=61239[REQUEST_METHOD]=GET[REQUEST_URI]=/upload/watch_premium_video.php?DATAS=71&data=71&codes=1234&code=1234&trxid=8a8bde7a-c0d9-4178-a464-fca9385e80b8&transaction_id=8a8bde7a-c0d9-4178-a464-fca9385e80b8[SCRIPT_FILENAME]=/home/radicals/public_html/upload/watch_premium_video.php[SCRIPT_NAME]=/upload/watch_premium_video.php[SERVER_ADDR]=109.205.137.195[SERVER_ADMIN][email protected][SERVER_NAME]=radicalswinger.tv[SERVER_PORT]=80[SERVER_PROTOCOL]=HTTP/1.1[SERVER_SIGNATURE]=<address>Apache/2.0.63 (Unix) mod_ssl/2.0.63 OpenSSL/0.9.8e-fips-rhel5 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 Server at radicalswinger.tv Port 80</address>
[SERVER_SOFTWARE]=Apache/2.0.63 (Unix) mod_ssl/2.0.63 OpenSSL/0.9.8e-fips-rhel5 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635[PHP_SELF]=/upload/watch_premium_video.php[REQUEST_TIME]=1307544996[argv]=Array[argc]=1<br />
O sea, que realmente se está cargando 2 veces la página. Pero sigo sin saber cuál es la causa de esto, y mientras no lo averigue la actualización se lanzará 2 veces.

Si alguien entiende este log y puede ayudarme se lo agradeceré muchísimo.