ACC SHELL

Path : /srv/www/vhosts/profias/admin/
File Upload :
Current File : /srv/www/vhosts/profias/admin/fulltext.php

<?php



  function starttag($parser, $name, $attrs)
  {
    global $a;
    global $div;
    global $h1;
    global $data; 
    global $flag; 
    
    $name=strtolower($name);
     if ('left'==$attrs['ID'])
     {
      
      $flag='';
     }
    
    if (TRUE==in_array($name, array('h1')) || ('content'==$attrs['ID']))
    {
      $flag='content';
      $data[$name]='';
    }
    else if ( ('a'==$name) && (FALSE==strpos($attrs['HREF'], '.')) && (FALSE==strpos($attrs['HREF'], '/files/')) ) 
    {
//      echo $attrs['HREF'].' - '.strpos('c', $attrs['HREF']).'<br />';
      $data['a'].=$attrs['HREF'];
    }
    
  } 


  function endtag($parser, $name)
  {
    global $a;
    global $div;
    global $h1;
    global $data; 
    global $flag;
  
    $name=strtolower($name);
//    echo $name.' - '.$flag.'<br />';
    
    if ( ('div'==$name) && (TRUE==$data[$name]) )
    {
      if ('content'==$flag)
      {
        $div=$data[$name];
      }
    }
    else if (TRUE==$data[$name])
    {
      $GLOBALS[$name][]=str_replace('<?=$this->httpRoot?>', '/', $data[$name]);
      $data[$name]='';
    }
    
  }



  function data($parser, $text)
  {
    global $data; 
  
    $keys=@array_keys($data);
    for ($i=0; $i<count($keys); $i++)
    {
      if ('a'!=$keys[$i])
      {
        $data[$keys[$i]].=$text;
      }
    }
  } 
  
  


  function crawl($path, $parent=0)
  {
    global $a;
    global $div;
    global $h1;


    if ( (TRUE==in_array($path, $GLOBALS['all_a'])) || ('//'==substr($path, 0, 2)) || (TRUE==strpos($path, 'files')) || (TRUE==strpos($path, '??')) || (TRUE==strpos($path, 'ke-stazeni')) )
    {
      return FALSE;
    }

    $path=str_replace('//', '/', $path);

    if ('/cz'!=substr($path, 0, 3))
    {
      $path='/cz'.$path;
    }

    if ( (TRUE==in_array($path, $GLOBALS['all_a'])) || ('//'==substr($path, 0, 2)) || (TRUE==strpos($path, 'files')) || (TRUE==strpos($path, '??')) || (TRUE==strpos($path, 'ke-stazeni')) )
    {
      return FALSE;
    }
    
    $GLOBALS['all_a'][]=$path;


    if ( (TRUE==strpos($path, '..')) || (TRUE==strpos($path, 'katalog/katalog')) )
    {
      return FALSE;
    }


    
    $a=array();
    $h1=array();
    $div=array();
    
    
    if ('/cz'==substr($path, 0, 3))
    {
      $prefix='http://ppobaly.cz';
    }
    else
    {
      $prefix='http://ppobaly.cz/cz';
    }
    
    
    ob_start();
    include_once($prefix.$path);
    $html=ob_get_contents();
    ob_end_clean();
    
//    echo $html;

    $xml_parser=xml_parser_create();
    xml_set_character_data_handler($xml_parser, 'data');      
    xml_set_element_handler($xml_parser, 'starttag', 'endtag');
    xml_parse($xml_parser, $html);
    
    for ($i=0; $i<count($a); $i++)
    {
      if ('?'==$a[$i][0])
      {
        $a[$i]=str_replace('?', $path.'?', $a[$i]);
      }
      if ('../'==substr($a[$i], 0, 3)) 
      {
        $tmp=explode('/', $path);
        array_pop($tmp);
        $a[$i]=@implode('/', $tmp).str_replace('../', '/', $a[$i]);
      }
      if ( ('/'!==$a[$i][0]) && ('?'!==$a[$i][0]) )
      {
        $a[$i]=$path.$a[$i];
      }
    }

    $local_a=$a;
//    die(print_r($local_a));

      $div=strip_tags($div);
//print_r($local_a);    


    echo $path_prefix.$path.'<br />';

    
    $parent2=get_auto_increment('sys_fulltext');    
    $GLOBALS['db']->insert('sys_fulltext', array('path'=>$path, 'page_name'=>addslashes($h1[0]), 'content'=>addslashes($div), 'id_language'=>'1', 'id_parent'=>(int)$parent));

    
    for ($i=0; $i<count($local_a); $i++)
    {
      crawl($local_a[$i], $parent2);
    } 
    
  }















  include_once('../inc/config.php');
  include_once('../inc/fce.php');
  include_once('../inc/db.php');

  $db=new Db();

  $GLOBALS['all_a']=array();

  $GLOBALS['path_prefix']='http://ppobaly.cz/cz';

//  $pages=$db->select('pl.path', 'sys_pages_languages AS pl LEFT JOIN sys_pages AS p ON (p.id=pl.id_page)', 'p.active=\'Y\' AND pl.id_language=1');
  
  $db->queryN('TRUNCATE TABLE sys_fulltext');
  

  crawl($http_root);  

  
  $pages=$db->select('path', 'sys_pages AS p LEFT JOIN sys_pages_languages AS pl ON (pl.id_page=p.id)', 'pl.id_language=1 AND p.in_menu=\'Y\'');
  for ($i=0; $i<count($pages); $i++)
  {
    crawl($http_root.$pages[$i]['path']);
  }

  
  
  $page='';
  

  echo 'Done.';

  
  
?>

ACC SHELL 2018