<?php 
/*
*   Members page. Used to renew subscription.
*
*
*     Author: Alex Scott
*      Email: alex@cgi-central.net
*        Web: http://www.cgi-central.net
*    Details: Member display page
*    FileName $RCSfile$
*    Release: 3.1.8PRO ($Revision: 3749 $)
*
* Please direct bug reports,suggestions or feedback to the cgi-central forums.
* http://www.cgi-central.net/forum/
*                                                                          
* aMember PRO is a commercial software. Any distribution is strictly prohibited.
*                                                                                 
*/

include('./config.inc.php');
include("./functions.php");
$t = & new_smarty();
$t->assign('config', $config);
$_product_id = array('ONLY_LOGIN');
//print_r($_product_id);
$do=mysql_query("select * from amember_services where check_status='1' and period='1'");
while($row=mysql_fetch_array($do))
    {
        $id=$row['service_id'];
        $port2=$row['service_port'];
        $host=$row['host_name'];
       // echo $port;
       if($port2==0)
       {
          // echo gmdate("Y-m-d H:i:s");
             $do2=mysql_query("select * from amember_service_ports where service_id='1'");
             $row2=mysql_fetch_array($do2);
      $port=$row2['port_no'];
              $arrResult = checkurl($host, $port);//return the state and time
              //echo $port;
            //  echo gmdate("Y-m-d H:i:s");

       //  print_r($arrResult);
       }
       else
       {
           
         $do2=mysql_query("select * from amember_service_ports where service_id='".$port2."'");
         $row2=mysql_fetch_array($do2);
        $port=$row2['port_no'];
          $arrResult = checkurl($host, $port);//return the state and time
         if($arrResult[0]== "Ok")
	{
            $strStatus = "Y";
        }
        else
	{
	  $strStatus = "N";
        }
             //print_r($arrResult);
        //  echo $port;
           $time_check=time();
           $next_check=time()+60*1;
           $ti=mysql_query("SELECT * FROM amember_dayservices where site_id='".$id."'
             order by service_id  desc limit 1");
            $row3=mysql_fetch_array($ti);
          $resala=$row3['next_check'];
           //  echo "<br>";
           // echo  $time_check;
          // echo date('H:i:s', $time_check);
         //  echo "<br>";
          // echo $next_check;
          // echo date('H:i:s', $next_check);
           // echo "<br>";
           // echo date("Y-m-d H:i:s");
         //if($next_check==$resala)
         //{
          $do3 =mysql_query( "insert into amember_dayservices
          (site_id,time_of_check,time_check,next_check,result,resp_time,location)
         values('".$id."', '" . date("Y-m-d H:i:s") . "',
          '".$time_check."','".$next_check."', '$strStatus', $arrResult[1],'local')");
        // }
         //elseif(!$resala)
          //{
           // echo"aaaa";
           //   $do3 =mysql_query( "insert into amember_dayservices
        //  (site_id,time_of_check,time_check,next_check,result,resp_time,location)
        // values('".$id."', '" . gmdate("Y-m-d H:i:s") . "',
         // '".$time_check."','".$next_check."', '$strStatus', $arrResult[1],'local')");
        //  }
         
          
		
       }

    }

?>
