Guest User

test

a guest
Jul 8th, 2017
432
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 38.82 KB | None | 0 0
  1. <?php
  2. /**
  3.  * Website: http://www.siteguarding.com/
  4.  * Email: support@siteguarding.com
  5.  *
  6.  * @author John Coggins
  7.  * @version 1.2.2
  8.  * @date 18 Oct 2016
  9.  * @package SiteGuarding Antivirus Scanner module
  10.  */
  11.  
  12. // Init
  13. error_reporting( 0 );
  14. ignore_user_abort(true);
  15. set_time_limit ( 600 );
  16.  
  17. define ('DEBUG_FLAG', false);
  18.  
  19. if (DEBUG_FLAG) echo 'DEBUG MODE'."\n";
  20.  
  21.  
  22. $result = Antivirus::Init();
  23.  
  24. if ($result !== true)
  25. {
  26.     Antivirus::TemplateHeader(true);
  27.     $result = $result."<br><br>"."If you have Windows server or problems with the permissions.<br>We advice to download full package (<a target=\"_blank\" href=\"https://www.siteguarding.com/en/download-service/website-antivirus-standalone-package\">Download</a>)<br><br>and<br><br>Make sure that your server can communicate with other servers and outgoing traffic is not blocked by hoster (ask your hoster support)";
  28.     Antivirus::PrintPage_Message($result, 'error');
  29.     Antivirus::TemplateFooter();
  30.     exit;
  31. }
  32.  
  33.     /**
  34.      * Start
  35.      */
  36.     $task = trim($_REQUEST['task']);
  37.    
  38.     Antivirus::TemplateHeader();
  39.    
  40.     // Check is antivirus_installer.php is loaded
  41.     if (file_exists(Antivirus::GetPath().Antivirus::$antivirus_work_folder.'antivirus_installer.php') && $task == '')
  42.     {
  43.         Antivirus::PrintPage_Installation();
  44.     }
  45.     else {
  46.         /**
  47.          * Tasks
  48.          */
  49.         switch ($task)
  50.         {
  51.             case 'Installation':
  52.                 $result = Antivirus::Installation();
  53.                 if ($result !== true) Antivirus::PrintPage_Message($result, 'error');
  54.                 else Antivirus::PrintPage_Dashboard();
  55.                 break;
  56.                
  57.             case 'StartScanner':
  58.                 Antivirus::StartScanner();
  59.                 break;
  60.                
  61.            
  62.            
  63.            
  64.             default:
  65.                 Antivirus::PrintPage_Dashboard();
  66.            
  67.         }
  68.        
  69.     }
  70.    
  71.     Antivirus::TemplateFooter();
  72.  
  73.  
  74.  
  75.  
  76.  
  77. class Antivirus {
  78.    
  79.     public static $SITEGUARDING_SERVER = 'http://www.siteguarding.com/ext/antivirus/index.php';
  80.     public static $SITEGUARDING_SERVER_HTTPS = 'https://www.siteguarding.com/ext/antivirus/index.php';
  81.     public static $antivirus_work_folder = '/webanalyze/';
  82.     public static $antivirus_assets_folder = '/webanalyze/assets/';
  83.    
  84.     static function Init()
  85.     {
  86.         // Remove .htaccess
  87.         if (file_exists(self::GetPath().self::$antivirus_work_folder.'.htaccess')) unlink(self::GetPath().self::$antivirus_work_folder.'.htaccess');
  88.        
  89.         // Create folder /webanalyze/
  90.         if (!file_exists(self::GetPath().self::$antivirus_work_folder))
  91.         {
  92.             if ( !mkdir(self::GetPath().self::$antivirus_work_folder) ) return "Can't create folder ".self::$antivirus_work_folder;
  93.         }
  94.        
  95.         // Create folder /webanalyze/assets/
  96.         if (!file_exists(self::GetPath().self::$antivirus_assets_folder))
  97.         {
  98.             if ( !mkdir(self::GetPath().self::$antivirus_assets_folder) ) return "Can't create folder ".self::$antivirus_assets_folder;
  99.         }
  100.        
  101.         $assets_files = array(
  102.             'semantic.min.css',
  103.             'jquery.min.js',
  104.             'semantic.min.js',
  105.             'icons.ttf',
  106.             'icons.woff',
  107.             'icons.woff2',
  108.             'wpAntivirusSiteProtection-logo.png',
  109.             'canvasloader-min.js',
  110.             'logo_siteguarding.png'
  111.         );
  112.         foreach ($assets_files as $file)
  113.         {
  114.             $url = 'http://www.siteguarding.com/_get_file.php?file=antivirus_'.$file.'&time='.time();
  115.             $url_https = 'https://www.siteguarding.com/_get_file.php?file=antivirus_'.$file.'&time='.time();
  116.             $destination = self::GetPath().self::$antivirus_assets_folder.$file;
  117.            
  118.             if (!file_exists($destination) || filesize($destination) == 0)
  119.             {
  120.                 if(DEBUG_FLAG) echo 'Download '.$file.' [cURL]'."\n";
  121.                 $status = self::CreateRemote_file_contents($url, $destination);
  122.                 if ($status === false)
  123.                 {
  124.                     $status = self::CreateRemote_file_contents($url_https, $destination);
  125.                     if ($status === false)
  126.                     {
  127.                         if(DEBUG_FLAG) echo 'Download '.$file.' [cURL] - failed'."\n";
  128.                         if(DEBUG_FLAG) echo 'Download '.$file.' [HTTPClient]'."\n";
  129.                         $status = self::CreateRemote_file_contents_HTTPClient($url, $destination);
  130.                         if ($status === false)
  131.                         {
  132.                             $status = self::CreateRemote_file_contents_HTTPClient($url_https, $destination);
  133.                             if ($status === false)
  134.                             {
  135.                                 if(DEBUG_FLAG) echo 'Download '.$file.' [HTTPClient] - failed'."\n";
  136.                                 return "Can't get asset file: ".self::$antivirus_assets_folder.$file.'<br>(Err: '.$GLOBALS['debug_latest_error'].')';
  137.                             }
  138.                         }
  139.                     }
  140.                 }
  141.             }
  142.         }
  143.        
  144.         $file = 'antivirus_installer.php';
  145.         if (!file_exists(self::GetPath().self::$antivirus_work_folder.'antivirus.php') /*|| !file_exists(self::GetPath().self::$antivirus_work_folder.'antivirus_config.php')*/)
  146.         {
  147.             $destination = self::GetPath().self::$antivirus_work_folder.'antivirus_installer.php';
  148.             $url = 'http://www.siteguarding.com/_get_file.php?file=antivirus_antivirus_installer.php&time='.time();
  149.             $url_https = 'https://www.siteguarding.com/_get_file.php?file=antivirus_antivirus_installer.php&time='.time();
  150.            
  151.             $status = self::CreateRemote_file_contents($url, $destination);
  152.             if ($status === false)
  153.             {
  154.                 $status = self::CreateRemote_file_contents($url_https, $destination);
  155.                 if ($status === false)
  156.                 {
  157.                     if(DEBUG_FLAG) echo 'Download antivirus_installer.php [cURL] - failed'."\n";
  158.                     if(DEBUG_FLAG) echo 'Download antivirus_installer.php [HTTPClient]'."\n";
  159.                     $status = self::CreateRemote_file_contents_HTTPClient($url, $destination);
  160.                     if ($status === false)
  161.                     {
  162.                         $status = self::CreateRemote_file_contents_HTTPClient($url, $destination);
  163.                         if ($status === false)
  164.                         {
  165.                             if(DEBUG_FLAG) echo 'Download antivirus_installer.php [HTTPClient] - failed'."\n";
  166.                             return "Can't get file: antivirus_installer.php<br>(Err: ".$GLOBALS['debug_latest_error'].')';
  167.                         }
  168.                     }
  169.                 }
  170.             }
  171.         }
  172.        
  173.         return true;
  174.     }
  175.    
  176.  
  177.    
  178.     static function GetWebsiteURL()
  179.     {
  180.        $this_filename = pathinfo(__FILE__, PATHINFO_BASENAME);
  181.        return 'http://'.$_SERVER['HTTP_HOST'].str_replace($this_filename, "", $_SERVER['SCRIPT_NAME']);
  182.     }
  183.  
  184.  
  185.    
  186.     static function Get_Access_Key()
  187.     {
  188.         include_once(self::GetPath().self::$antivirus_work_folder.'antivirus_config.php');
  189.        
  190.         return ACCESS_KEY;
  191.     }
  192.    
  193.  
  194.    
  195.     static function Get_License_info()
  196.     {
  197.         $domain = self::GetDomain();
  198.         $access_key = self::Get_Access_Key();
  199.        
  200.        
  201.         $link = self::$SITEGUARDING_SERVER.'?action=licenseinfo&type=json&data=';
  202.         $link_https = self::$SITEGUARDING_SERVER_HTTPS.'?action=licenseinfo&type=json&data=';
  203.        
  204.         $data = array(
  205.             'domain' => $domain,
  206.             'access_key' => $access_key,
  207.             'product_type' => 'any'
  208.         );
  209.        
  210.         $link .= base64_encode(json_encode($data));
  211.         $link_https .= base64_encode(json_encode($data));
  212.        
  213.         $a = self::GetRemote_file_contents($link, true);
  214.         if ($a === false) $a = self::GetRemote_file_contents($link_https, true);
  215.         if ($a === false) $a = self::GetRemote_file_contents_HTTPClient($link, true);
  216.         if ($a === false) $a = self::GetRemote_file_contents_HTTPClient($link_https, true);
  217.        
  218.         return $a;
  219.      
  220.     }
  221.    
  222.  
  223.    
  224.     static function GetDomain()
  225.     {
  226.         $host_info = parse_url(self::GetWebsiteURL());
  227.         if ($host_info == NULL) return false;
  228.         $domain = $host_info['host'];
  229.         if ($domain[0] == "w" && $domain[1] == "w" && $domain[2] == "w" && $domain[3] == ".") $domain = str_replace("www.", "", $domain);
  230.         //$domain = str_replace("www.", "", $domain);
  231.        
  232.         return $domain;
  233.     }
  234.  
  235.  
  236.    
  237.     static function GetPath()
  238.     {
  239.        return dirname(__FILE__);
  240.     }
  241.  
  242.    
  243.    
  244.     static function Installation()
  245.     {
  246.         // Send data
  247.         $link = self::$SITEGUARDING_SERVER.'?action=register&type=json&data=';
  248.         $link_https = self::$SITEGUARDING_SERVER_HTTPS.'?action=register&type=json&data=';
  249.        
  250.         $domain = self::GetWebsiteURL();
  251.         $email = trim($_REQUEST['email']);
  252.         $access_key = md5(time().$domain.rand(1, 20000).$email);
  253.        
  254.         $data = array(
  255.             'domain' => $domain,
  256.             'email' => $email,
  257.             'access_key' => $access_key,
  258.             'errors' => '',
  259.             'call_back' => 1
  260.         );
  261.         $link .= base64_encode(json_encode($data));
  262.         $link_https .= base64_encode(json_encode($data));
  263.        
  264.         $a = trim(self::GetRemote_file_contents($link));
  265.        
  266.         if ($a == 'installation_ok') return true;
  267.         else {
  268.             $a = trim(self::GetRemote_file_contents($link_https));
  269.             if ($a == 'installation_ok') return true;
  270.             else {
  271.                 $a = self::GetRemote_file_contents_HTTPClient($link);
  272.                 if ($a == 'installation_ok') return true;
  273.                 else {
  274.                     $a = self::GetRemote_file_contents_HTTPClient($link_https);
  275.                     if ($a == 'installation_ok') return true;
  276.                     else {
  277.                         return $a." (Err: ".$GLOBALS['debug_latest_error'].')';
  278.                     }
  279.                 }
  280.             }
  281.         }
  282.     }
  283.    
  284.    
  285.     static function TemplateHeader($remote_assets = false)
  286.     {
  287.         ?>
  288. <!DOCTYPE html>
  289. <html>
  290. <head>
  291.   <meta charset="utf-8" />
  292.   <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
  293.   <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
  294.   <title>Website Antivirus Scanner by SiteGuarding.com</title>
  295.  
  296. <?php
  297.         if ($remote_assets)
  298.         {
  299.             ?>
  300.                 <link rel="stylesheet" type="text/css" href="https://www.siteguarding.com/ext/antivirus/assets/semantic.min.css">
  301.                 <script src="https://www.siteguarding.com/ext/antivirus/assets/jquery.min.js"></script>
  302.                 <script src="https://www.siteguarding.com/ext/antivirus/assets/semantic.min.js"></script>
  303.             <?php
  304.         }
  305.         else {
  306.             ?>
  307.                 <link rel="stylesheet" type="text/css" href="webanalyze/assets/semantic.min.css">
  308.                 <script src="webanalyze/assets/jquery.min.js"></script>
  309.                 <script src="webanalyze/assets/semantic.min.js"></script>
  310.             <?php
  311.            
  312.         }
  313. ?>
  314.  
  315.  
  316.  
  317.  
  318.   <style type="text/css">
  319.     body {
  320.       background-color: #DADADA;
  321.     }
  322.     body > .grid {
  323.       height: 100%;
  324.     }
  325.     .image {
  326.       margin-top: -100px;
  327.     }
  328.     .column {
  329.       max-width: 450px;
  330.     }
  331.   </style>
  332. </head>
  333. <body>
  334. <?php
  335.     }
  336.    
  337.    
  338.     static function TemplateFooter()
  339.     {
  340.         ?>
  341. </body>
  342. </html>
  343.         <?php
  344.     }
  345.    
  346.    
  347.     static function PrintPage_Message($txt = '', $type = 'error')
  348.     {
  349.         switch ($type)
  350.         {
  351.             case 'error': $type = 'red'; break;
  352.             case 'ok': $type = 'green'; break;
  353.             case 'alert': $type = 'yellow '; break;
  354.             default: $type = '';
  355.         }
  356.         ?>
  357.             <div class="ui middle aligned center aligned grid">
  358.                 <div class="column">
  359.                     <div class="ui <?php echo $type; ?> message"><?php echo $txt; ?></div>
  360.                 </div>
  361.             </div>
  362.         <?php
  363.     }
  364.    
  365.    
  366.    
  367.     static function PrintPage_Installation()
  368.     {
  369.         ?>
  370.         <script>
  371.         $(document)
  372.         .ready(function() {
  373.           $('.ui.form')
  374.             .form({
  375.               fields: {
  376.                 email: {
  377.                   identifier  : 'email',
  378.                   rules: [
  379.                     {
  380.                       type   : 'empty',
  381.                       prompt : 'Please enter your e-mail'
  382.                     },
  383.                     {
  384.                       type   : 'email',
  385.                       prompt : 'Please enter a valid e-mail'
  386.                     }
  387.                   ]
  388.                 }
  389.               }
  390.             })
  391.           ;
  392.         })
  393.         ;
  394.         </script>
  395.        
  396.         <div class="ui middle aligned center aligned grid">
  397.           <div class="column left aligned">
  398.  
  399.             <form method="post" class="ui large form left aligned">
  400.               <div class="ui stacked segment">
  401.              
  402.                 <h2 class="ui image header">
  403.                   <img src="<?php echo Antivirus::GetWebsiteURL().Antivirus::$antivirus_assets_folder; ?>wpAntivirusSiteProtection-logo.png" class="image">
  404.                   <div class="content">
  405.                     Antivirus Installation
  406.                   </div>
  407.                 </h2>
  408.                
  409.                 <div class="field">
  410.                   <label>Website URL</label>
  411.                     <input disabled="disabled" type="text" name="website_url" value="<?php echo Antivirus::GetWebsiteURL(); ?>" placeholder="Please enter your Website URL">
  412.                 </div>
  413.  
  414.                 <div class="field">
  415.                   <label>Email</label>
  416.                     <input type="text" name="email" placeholder="Please enter your Email">
  417.                 </div>
  418.                
  419.                 <div class="ui fluid large green submit button">Install Antivirus</div>
  420.               </div>
  421.        
  422.               <div class="ui error message"></div>
  423.              
  424.               <input type="hidden" name="task" value="Installation">
  425.        
  426.             </form>
  427.        
  428.           </div>
  429.         </div>
  430.         <?php
  431.     }
  432.    
  433.    
  434.     static function PrintBlock_LogoMenu()
  435.     {
  436.         ?>
  437.           <style type="text/css">
  438.           .main.container {
  439.             margin-top: 7em;
  440.           }
  441.           img.logo{width:250px!important;}
  442.           </style>
  443.                 <div class="ui borderless  fixed menu">
  444.                     <div class="ui container">
  445.                       <div class="header item">
  446.                         <a href="https://www.siteguarding.com">
  447.                             <img class="logo" src="<?php echo Antivirus::GetWebsiteURL().Antivirus::$antivirus_assets_folder; ?>logo_siteguarding.png">
  448.                         </a>
  449.                       </div>
  450.        
  451.                           <a href="#" class="item">&nbsp;</a>
  452.                           <a href="https://www.siteguarding.com/en/buy-service/website-antivirus-protection" class="ui right floated dropdown item">Get PRO</a>
  453.                           <a href="https://www.siteguarding.com/en/protect-your-website" class="ui right floated dropdown item">Protect Your Website</a>
  454.                           <a href="https://www.siteguarding.com/en/services/malware-removal-service" class="ui right floated dropdown item">Malware Removal Service</a>
  455.                           <a href="https://www.siteguarding.com/en/contacts" class="ui right floated dropdown item">Contact Us</a>
  456.                          
  457.        
  458.                     </div>
  459.                   </div>
  460.        
  461.         <?php
  462.     }
  463.    
  464.     static function PrintPage_Dashboard()
  465.     {
  466.         $license_info = self::Get_License_info();
  467.         //print_r($license_info);
  468.        
  469.         self::PrintBlock_LogoMenu();
  470.         ?>
  471.  
  472.         <div class="ui middle aligned center aligned grid">
  473.             <div class="ui main text container">
  474.  
  475.  
  476.  
  477.  
  478. <h2 class="ui dividing header">Antivirus Scanner</h2>
  479.  
  480.  
  481.  
  482.     <div class="ui list">
  483.         <?php
  484.         $txt = $license_info['membership'];
  485.         if ($txt != 'pro') $txt = ucwords($txt);
  486.         else $txt = '<span class="ui green label">'.ucwords($txt).'<span>';
  487.         ?>
  488.         <p class="item">Your subscription: <b><?php echo $txt; ?></b> valid till: <?php echo $license_info['exp_date']."&nbsp;&nbsp;";
  489.         if ($license_info['exp_date'] < date("Y-m-d")) echo '<span class="ui red label">'.'Expired'.'</span> [<a href="https://www.siteguarding.com/en/buy-service/antivirus-site-protection?domain='.urlencode( self::GetWebsiteURL() ).'&email='.urlencode($license_info['email']).'" target="_blank">Upgrade</a>]';
  490.         else if ($license_info['exp_date'] < date("Y-m-d", mktime(0, 0, 0, date("m")  , date("d")-7, date("Y")))) echo '<span class="msg_box msg_warning">'.'Will Expire Soon'.'</span>';
  491.         ?></p>
  492.  
  493.     </div>
  494.    
  495.     <div class="ui list">
  496.         <p class="item">Google Blacklist Status: <?php if ($license_info['blacklist']['google'] != 'ok') echo '<span class="ui red label">Blacklisted ['.$license_info['blacklist']['google'].']</span> [<a href="https://www.siteguarding.com/en/services/malware-removal-service" target="_blank">Remove From Blacklist</a>]'; else echo '<span class="ui green label">Not blacklisted</span>'; ?></p>
  497.         <p class="item">File Change Monitoring: <?php if ($license_info['filemonitoring']['status'] == 0) echo '<span class="ui red label">Disabled</span> [<a href="https://www.siteguarding.com/en/protect-your-website" target="_blank">Subscribe</a>]'; else echo '<b>'.$license_info['filemonitoring']['plan'].'</b> ['.$license_info['filemonitoring']['exp_date'].']'; ?></p>
  498.         <?php
  499.         if (count($license_info['reports']) > 0)
  500.         {
  501.             if ($license_info['last_scan_files_counters']['main'] == 0 && $license_info['last_scan_files_counters']['heuristic'] == 0) echo '<p class="item">Website Status: <span class="ui green label">Clean</span></p>';
  502.             if ($license_info['last_scan_files_counters']['main'] > 0) echo '<p class="item">Website Status: <span class="ui red label">Infected</span> [<a href="https://www.siteguarding.com/en/services/malware-removal-service" target="_blank">Clean My Website</a>]</p>';
  503.             else if ($license_info['last_scan_files_counters']['heuristic'] > 0)  echo '<p class="item">Website Status: <span class="ui red label">Review is required</span> [<a href="https://www.siteguarding.com/en/services/malware-removal-service" target="_blank">Review My Website</a>]</p>';
  504.         }
  505.         else {
  506.             echo '<p class="item">Website Status: <span class="ui red label">Never Analyzed</span></p>';
  507.         }
  508.         ?>
  509.     </div>
  510.  
  511.  
  512.  
  513. <div style="clear:both"></div>
  514.  
  515.  
  516.  
  517.  
  518. <div class="mod-box">      
  519. <p>To start the scan process click "Start Scanner" button.</p>
  520. <p>Scanner will automatically collect and analyze the files of your website. The scanning process can take up to 10 mins (it depends of speed of your server and amount of the files to analyze).</p>
  521. <p>After full analyze you will get the report. The copy of the report we will send by email for your records.</p>
  522.  
  523.            
  524.         <form method="post">
  525.        
  526.        
  527.         <div class="startscanner">
  528.             <p style="text-align: center;">
  529.               <input type="submit" name="submit" id="submit" class="huge ui green button" value="Start Scanner">
  530.           </p>
  531.         </div>
  532.        
  533.         <input type="hidden" name="task" value="StartScanner"/>
  534.        
  535.         </form>
  536.        
  537.         <div class="ui ignored warning message">
  538.         <p>Don't forget to remove antivirus script from the server when analyze is finished. </p>
  539.         </div>
  540.  
  541. <?php
  542.  
  543. if (count($license_info['reports']))
  544. { ?>       
  545.     <h3 class="ui dividing header">Latest Reports</h3>
  546.  
  547. <?php
  548.  
  549.     foreach ($license_info['reports'] as $report_info)
  550.     {
  551.         ?><a href="<?php echo $report_info['report_link']."&showtrial=1"; ?>" target="_blank">Click to view report for <?php echo $report_info['domain']; ?>. Date: <?php echo $report_info['date']; ?></a><br /><?php
  552.     }
  553. }
  554.  
  555. ?>
  556.  
  557. <h3 class="ui dividing header">Extra Options</h3>
  558.  
  559. <h2 class="ui center aligned header">Do you need clean and protected website? Please learn how it works.</h2>
  560. <p class="ui center aligned"><center>Our security packages cover all your needs. Focus on your business and leave security to us.</center></p>
  561.  
  562. <iframe src="https://player.vimeo.com/video/140200465" width="100%" height="378" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
  563.  
  564. <form style="padding: 40px 0 100px 0;" class="ui middle aligned center aligned grid" method="post" action="https://www.siteguarding.com/en/protect-your-website">
  565.  
  566.           <input type="submit" name="submit" class="big ui green button center aligned" value="Protect My Website">
  567.  
  568.     </form>
  569.  
  570.  
  571.  
  572.         </div>
  573.        
  574.        
  575.         <div class="center aligned row">
  576.         <div style="text-align:center">
  577.             <p>
  578.             For more information and details about Antivirus Site Protection please <a target="_blank" href="https://www.siteguarding.com/en/antivirus-site-protection">click here</a>.<br /><br />
  579.             <a href="http://www.siteguarding.com/livechat/index.html" target="_blank">
  580.                 <img src="https://www.siteguarding.com/images/livechat.png"/>
  581.             </a><br />
  582.             For any questions and support please use LiveChat or this <a href="https://www.siteguarding.com/en/contacts" rel="nofollow" target="_blank" title="SiteGuarding.com - Website Security. Professional security services against hacker activity. Daily website file scanning and file changes monitoring. Malware detecting and removal.">contact form</a>.<br>
  583.             <br>
  584.             Copyright &copy; 2008 - <?php echo date("Y"); ?> <a href="https://www.siteguarding.com/" target="_blank">SiteGuarding.com</a></br>Website Security. Professional security services against hacker activity.<br />
  585.             </p>
  586.         </div>
  587.         </div>
  588.  
  589.  
  590.         <?php
  591.     }
  592.    
  593.    
  594.    
  595.    
  596.    
  597.     static function StartScanner()
  598.     {
  599.         self::PrintBlock_LogoMenu();
  600.        
  601.         $session_report_key = md5(self::GetWebsiteURL().rand(1, 10000).time());
  602.         $license_info = self::Get_License_info();
  603.        
  604.        
  605.         ?>
  606.          
  607.         <script src="<?php echo Antivirus::GetWebsiteURL().Antivirus::$antivirus_assets_folder; ?>canvasloader-min.js" type="text/javascript"></script>
  608.        
  609.         <div class="ui middle aligned center aligned grid">
  610.             <div class="ui main text container">
  611.            
  612.            
  613.         <div class="ui middle aligned center aligned grid">
  614.             <div class="ui main text container">
  615.            
  616.             <div class="ui middle aligned center aligned grid">
  617.                 <div class="container">
  618.                     <div class="ui yellow message" style="text-align: center;">If the scanning process takes too long. Get the results using the link<br /><a href="https://www.siteguarding.com/antivirus/viewreport?report_id=<?php echo $session_report_key; ?>&showtrial=1" target="_blank">https://www.siteguarding.com/antivirus/viewreport?report_id=<?php echo $session_report_key; ?></a></div>
  619.                 </div>
  620.             </div>
  621.                 <h2 class="ui header aligned center aligned">Please wait. It can take up to 5 - 10 minutes to get the results.</h2>
  622.                 <p style="text-align: center;" id="progress_bar_txt"></p>
  623.                
  624.                 <div id="canvasloader-container" style="position:absolute;top:65%;left:50%;"></div>
  625.            
  626.             </div>
  627.         </div>
  628.        
  629.        
  630.             </div>
  631.         </div>
  632.            
  633.            
  634.             <script type="text/javascript">
  635.                 var cl = new CanvasLoader('canvasloader-container');
  636.                 cl.setColor('#4b9307'); // default is '#000000'
  637.                 cl.setShape('spiral'); // default is 'oval'
  638.                 cl.setDiameter(118); // default is 40
  639.                 cl.setDensity(26); // default is 40
  640.                 cl.setSpeed(1); // default is 2
  641.                 cl.show(); // Hidden by default
  642.                
  643.                 // This bit is only for positioning - not necessary
  644.                   var loaderObj = document.getElementById("canvasLoader");
  645.                 loaderObj.style.position = "absolute";
  646.                 loaderObj.style["top"] = cl.getDiameter() * -0.5 + "px";
  647.                 loaderObj.style["left"] = cl.getDiameter() * -0.5 + "px";
  648.                
  649.  
  650.             $(document).ready(function(){
  651.                
  652.                 var refreshIntervalId;
  653.                
  654.                 <?php
  655.                 $ajax_url = self::GetWebsiteURL().'/webanalyze/antivirus.php?task=scan&access_key='.$license_info['access_key'].'&session_report_key='.$session_report_key.'&email='.$license_info['email'].'&cache='.time();
  656.                 ?>
  657.                 var link = "<?php echo $ajax_url; ?>";
  658.  
  659.                 $.post(link, {
  660.                         no_html: "1"
  661.                     },
  662.                     function(data){
  663.                         /*if (data != '') alert(data);*/
  664.                     }
  665.                 );
  666.                
  667.                
  668.                
  669.                 function GetProgress()
  670.                 {
  671.                     <?php
  672.                     $ajax_url = self::GetWebsiteURL().'/webanalyze/antivirus.php?task=scan_status&access_key='.$license_info['access_key'].'&cache='.time();
  673.                     ?>
  674.                     var link = "<?php echo $ajax_url; ?>";
  675.    
  676.                     $.post(link, {
  677.                             no_html: "1"
  678.                         },
  679.                         function(data){
  680.                             if (data == 'report_redirect')
  681.                             {
  682.                                 document.location.href = 'https://www.siteguarding.com/antivirus/viewreport?report_id=<?php echo $session_report_key; ?>&showtrial=1';
  683.                                 return;
  684.                             }
  685.                             var tmp_data = data.split('|');
  686.                             $("#progress_bar_txt").html(tmp_data[0]+'% - '+tmp_data[1]);
  687.                            
  688.                             if (parseInt(tmp_data[0]) >= 100) $("#adminForm").submit();
  689.                         }
  690.                     ); 
  691.                 }
  692.                
  693.                 refreshIntervalId =  setInterval(GetProgress, 3000);
  694.                
  695.             });
  696.            
  697.                        
  698.             </script>
  699.            
  700.            
  701.             <form action="<?php echo JRoute::_('index.php?option=com_securapp&task=AntivirusViewReport&showtrial=1'); ?>" method="get" enctype="multipart/form-data" name="adminForm" id="adminForm" >
  702.                     <input type="hidden" name="report_id" value="<?php echo $session_report_key; ?>" />
  703.             </form>
  704.        
  705.        
  706.         <?php
  707.     }
  708.    
  709.    
  710.  
  711.     static function CreateRemote_file_contents_HTTPClient($url, $destination)
  712.     {
  713.         if (class_exists('HTTPClient'))
  714.         {
  715.             $client = new HTTPClient();
  716.             $client->timeout = 600;
  717.             $client->agent = 'Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; Acoo Browser 1.98.744; .NET CLR 3.5.30729)';
  718.             if (DEBUG_FLAG) $client->debug = true;
  719.            
  720.             $content = $client->get($url);
  721.            
  722.             if (DEBUG_FLAG && $content === false) echo 'HTTPClient $content = false'."\n";
  723.             if (DEBUG_FLAG && trim($content) == '' && $content !== false) echo 'HTTPClient $content is empty'."\n";
  724.             if (DEBUG_FLAG) echo $client->error."\n";
  725.            
  726.             if ($content === false || trim($content) == '')
  727.             {
  728.                 $GLOBALS['debug_latest_error'] = $client->error;
  729.                 return false;
  730.             }
  731.  
  732.            
  733.             $fp = fopen($dst, 'w');
  734.             if ($fp === false) return false;
  735.             $a = fwrite($fp, $content);
  736.             if ($a === false) return false;
  737.             fclose($fp);
  738.            
  739.             return true;
  740.         }
  741.         else return false;
  742.     }
  743.    
  744.    
  745.     static function CreateRemote_file_contents($url, $dst)
  746.     {
  747.         if (extension_loaded('curl'))
  748.         {
  749.             $dst = fopen($dst, 'w');
  750.            
  751.             $ch = curl_init();
  752.            
  753.             curl_setopt($ch, CURLOPT_URL, $url );
  754.             curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
  755.             curl_setopt($ch, CURLOPT_TIMEOUT, 3600);
  756.             curl_setopt($ch, CURLOPT_TIMEOUT_MS, 3600000);
  757.             curl_setopt($ch, CURLOPT_FILE, $dst);
  758.             curl_setopt($ch, CURLOPT_FAILONERROR, true);
  759.             curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); // 10 sec
  760.             curl_setopt($ch, CURLOPT_CONNECTTIMEOUT_MS, 10000); // 10 sec
  761.             curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
  762.             curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  763.            
  764.             $a = curl_exec($ch);
  765.             if ($a === false)  return false;
  766.            
  767.             $info = curl_getinfo($ch);
  768.            
  769.             curl_close($ch);
  770.             fflush($dst);
  771.             fclose($dst);
  772.            
  773.             return $info['size_download'];
  774.         }
  775.         else return false;
  776.     }
  777.    
  778.    
  779.     static function GetRemote_file_contents_HTTPClient($url, $parse = false)
  780.     {
  781.         if (class_exists('HTTPClient'))
  782.         {
  783.             $client = new HTTPClient();
  784.             $client->timeout = 600;
  785.             $client->agent = 'Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; Acoo Browser 1.98.744; .NET CLR 3.5.30729)';
  786.            
  787.             $content = $client->get($url);
  788.            
  789.             $output = trim(curl_exec($ch));
  790.             curl_close($ch);
  791.            
  792.             if ($content === false || trim($content) == '')
  793.             {
  794.                 $GLOBALS['debug_latest_error'] = $client->error;
  795.                 return false;
  796.             }
  797.            
  798.             if ($parse === true) $output = (array)json_decode($output, true);
  799.            
  800.             return $output;
  801.         }
  802.         else return false;
  803.     }
  804.    
  805.    
  806.     static function GetRemote_file_contents($url, $parse = false)
  807.     {
  808.         if (extension_loaded('curl'))
  809.         {
  810.             $ch = curl_init();
  811.            
  812.             curl_setopt($ch, CURLOPT_URL, $url );
  813.             curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
  814.             curl_setopt($ch, CURLOPT_TIMEOUT, 3600);
  815.             curl_setopt($ch, CURLOPT_TIMEOUT_MS, 3600000);
  816.             curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  817.  
  818.             curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); // 10 sec
  819.             curl_setopt($ch, CURLOPT_CONNECTTIMEOUT_MS, 10000); // 10 sec
  820.             curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
  821.             curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  822.            
  823.             $output = trim(curl_exec($ch));
  824.             curl_close($ch);
  825.            
  826.             if ($output === false || trim($output) == '')  return false;
  827.            
  828.             if ($parse === true) $output = (array)json_decode($output, true);
  829.            
  830.             return $output;
  831.         }
  832.         else return false;
  833.     }
  834.    
  835.  
  836. }
  837.  
  838. define('HTTP_NL',"\r\n"); class DokuHTTPClient extends HTTPClient { function DokuHTTPClient(){ global $conf; $this->HTTPClient(); $this->proxy_host = $conf['proxy']['host']; $this->proxy_port = $conf['proxy']['port']; $this->proxy_user = $conf['proxy']['user']; $this->proxy_pass = $conf['proxy']['pass']; $this->proxy_ssl = $conf['proxy']['ssl']; } } class HTTPClient { var $agent; var $http; var $timeout; var $cookies; var $referer; var $max_redirect; var $max_bodysize; var $header_regexp; var $headers; var $debug; var $start = 0; var $error; var $redirect_count; var $resp_status; var $resp_body; var $resp_headers; var $user; var $pass; var $proxy_host; var $proxy_port; var $proxy_user; var $proxy_pass; var $proxy_ssl; function HTTPClient(){ $this->agent = 'Mozilla/4.0 (compatible; DokuWiki HTTP Client; '.PHP_OS.')'; $this->timeout = 15; $this->cookies = array(); $this->referer = ''; $this->max_redirect = 3; $this->redirect_count = 0; $this->status = 0; $this->headers = array(); $this->http = '1.0'; $this->debug = false; $this->max_bodysize = 0; $this->header_regexp= ''; if(extension_loaded('zlib')) $this->headers['Accept-encoding'] = 'gzip'; $this->headers['Accept'] = 'text/xml,application/xml,application/xhtml+xml,'. 'text/html,text/plain,image/png,image/jpeg,image/gif,*/*'; $this->headers['Accept-Language'] = 'en-us'; } function get($url,$sloppy304=false){ if(!$this->sendRequest($url)) return false; if($this->status == 304 && $sloppy304) return $this->resp_body; if($this->status != 200) return false; return $this->resp_body; } function post($url,$data){ if(!$this->sendRequest($url,$data,'POST')) return false; if($this->status != 200) return false; return $this->resp_body; } function sendRequest($url,$data='',$method='GET'){ $this->start = $this->_time(); $this->error = ''; $this->status = 0; $uri = parse_url($url); $server = $uri['host']; $path = $uri['path']; if(empty($path)) $path = '/'; if(!empty($uri['query'])) $path .= '?'.$uri['query']; $port = $uri['port']; if($uri['user']) $this->user = $uri['user']; if($uri['pass']) $this->pass = $uri['pass']; if($this->proxy_host){ $request_url = $url; $server = $this->proxy_host; $port = $this->proxy_port; if (empty($port)) $port = 8080; }else{ $request_url = $path; $server = $server; if (empty($port)) $port = ($uri['scheme'] == 'https') ? 443 : 80; } if($port == 443 || $this->proxy_ssl) $server = 'ssl://'.$server; $headers = $this->headers; $headers['Host'] = $uri['host']; $headers['User-Agent'] = $this->agent; $headers['Referer'] = $this->referer; $headers['Connection'] = 'Close'; if($method == 'POST'){ if(is_array($data)){ $headers['Content-Type'] = 'application/x-www-form-urlencoded'; $data = $this->_postEncode($data); } $headers['Content-Length'] = strlen($data); $rmethod = 'POST'; }elseif($method == 'GET'){ $data = ''; } if($this->user) { $headers['Authorization'] = 'Basic '.base64_encode($this->user.':'.$this->pass); } if($this->proxy_user) { $headers['Proxy-Authorization'] = 'Basic '.base64_encode($this->proxy_user.':'.$this->proxy_pass); } $start = time(); $socket = @fsockopen($server,$port,$errno, $errstr, $this->timeout); if (!$socket){ $resp->status = '-100'; $this->error = "Could not connect to $server:$port\n$errstr ($errno)"; return false; } stream_set_blocking($socket,0); $request = "$method $request_url HTTP/".$this->http.HTTP_NL; $request .= $this->_buildHeaders($headers); $request .= $this->_getCookies(); $request .= HTTP_NL; $request .= $data; $this->_debug('request',$request); fputs($socket, $request); $r_headers = ''; do{ if(time()-$start > $this->timeout){ $this->status = -100; $this->error = sprintf('Timeout while reading headers (%.3fs)',$this->_time() - $this->start); return false; } if(feof($socket)){ $this->error = 'Premature End of File (socket)'; return false; } $r_headers .= fgets($socket,1024); }while(!preg_match('/\r?\n\r?\n$/',$r_headers)); $this->_debug('response headers',$r_headers); if($this->max_bodysize && preg_match('/\r?\nContent-Length:\s*(\d+)\r?\n/i',$r_headers,$match)){ if($match[1] > $this->max_bodysize){ $this->error = 'Reported content length exceeds allowed response size'; return false; } } if (!preg_match('/^HTTP\/(\d\.\d)\s*(\d+).*?\n/', $r_headers, $m)) { $this->error = 'Server returned bad answer'; return false; } $this->status = $m[2]; $this->resp_headers = $this->_parseHeaders($r_headers); if(isset($this->resp_headers['set-cookie'])){ foreach ((array) $this->resp_headers['set-cookie'] as $c){ list($key, $value, $foo) = explode('=', $cookie); $this->cookies[$key] = $value; } } $this->_debug('Object headers',$this->resp_headers); if($this->status == 301 || $this->status == 302 ){ if (empty($this->resp_headers['location'])){ $this->error = 'Redirect but no Location Header found'; return false; }elseif($this->redirect_count == $this->max_redirect){ $this->error = 'Maximum number of redirects exceeded'; return false; }else{ $this->redirect_count++; $this->referer = $url; if (!preg_match('/^http/i', $this->resp_headers['location'])){ $this->resp_headers['location'] = $uri['scheme'].'://'.$uri['host']. $this->resp_headers['location']; } return $this->sendRequest($this->resp_headers['location'],array(),'GET'); } } if($this->header_regexp && !preg_match($this->header_regexp,$r_headers)){ $this->error = 'The received headers did not match the given regexp'; return false; } $r_body = ''; if(preg_match('/transfer\-(en)?coding:\s*chunked\r\n/i',$r_header)){ do { unset($chunk_size); do { if(feof($socket)){ $this->error = 'Premature End of File (socket)'; return false; } if(time()-$start > $this->timeout){ $this->status = -100; $this->error = sprintf('Timeout while reading chunk (%.3fs)',$this->_time() - $this->start); return false; } $byte = fread($socket,1); $chunk_size .= $byte; } while (preg_match('/[a-zA-Z0-9]/',$byte)); $byte = fread($socket,1); $chunk_size = hexdec($chunk_size); $this_chunk = fread($socket,$chunk_size); $r_body .= $this_chunk; if ($chunk_size) $byte = fread($socket,2); if($this->max_bodysize && strlen($r_body) > $this->max_bodysize){ $this->error = 'Allowed response size exceeded'; return false; } } while ($chunk_size); }else{ while (!feof($socket)) { if(time()-$start > $this->timeout){ $this->status = -100; $this->error = sprintf('Timeout while reading response (%.3fs)',$this->_time() - $this->start); return false; } $r_body .= fread($socket,4096); $r_size = strlen($r_body); if($this->max_bodysize && $r_size > $this->max_bodysize){ $this->error = 'Allowed response size exceeded'; return false; } if($this->resp_headers['content-length'] && !$this->resp_headers['transfer-encoding'] && $this->resp_headers['content-length'] == $r_size){ break; } } } $status = socket_get_status($socket); fclose($socket); if($this->resp_headers['content-encoding'] == 'gzip'){ $this->resp_body = gzinflate(substr($r_body, 10)); }else{ $this->resp_body = $r_body; } $this->_debug('response body',$this->resp_body); $this->redirect_count = 0; return true; } function _debug($info,$var=null){ if(!$this->debug) return; print '<b>'.$info.'</b> '.($this->_time() - $this->start).'s<br />'; if(!is_null($var)){ ob_start(); print_r($var); $content = htmlspecialchars(ob_get_contents()); ob_end_clean(); print '<pre>'.$content.'</pre>'; } } function _time(){ list($usec, $sec) = explode(" ", microtime()); return ((float)$usec + (float)$sec); } function _parseHeaders($string){ $headers = array(); $lines = explode("\n",$string); foreach($lines as $line){ list($key,$val) = explode(':',$line,2); $key = strtolower(trim($key)); $val = trim($val); if(empty($val)) continue; if(isset($headers[$key])){ if(is_array($headers[$key])){ $headers[$key][] = $val; }else{ $headers[$key] = array($headers[$key],$val); } }else{ $headers[$key] = $val; } } return $headers; } function _buildHeaders($headers){ $string = ''; foreach($headers as $key => $value){ if(empty($value)) continue; $string .= $key.': '.$value.HTTP_NL; } return $string; } function _getCookies(){ foreach ($this->cookies as $key => $val){ if ($headers) $headers .= '; '; $headers .= $key.'='.$val; } if ($headers) $headers = "Cookie: $headers".HTTP_NL; return $headers; } function _postEncode($data){ foreach($data as $key => $val){ if($url) $url .= '&'; $url .= $key.'='.urlencode($val); } return $url; } }
  839.  
  840. ?>
Add Comment
Please, Sign In to add comment