403Webshell
Server IP : 103.48.194.25  /  Your IP : 216.73.216.33
Web Server : Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.4.33
System : Linux VMHostDefault 3.10.0-1160.42.2.el7.x86_64 #1 SMP Tue Sep 7 14:49:57 UTC 2021 x86_64
User : sieuthimay ( 1016)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /var/www/hocthongminh.net-bk/public_html/webadmin/components/robot/libraries/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/hocthongminh.net-bk/public_html/webadmin/components/robot/libraries/robot_library.php
<?php if (! defined('BASEPATH')) exit('No direct script access allowed');
	require_once "robot_html.php";
	require_once "download_image.php";
	define("RB_ERR_NOT_INIT_CURL","Can't init curl");

class robot_library
{
    var $my_base_url = '';
    var $base_url = '';
    var $date_format='';
    var $date_format_link='';
    var $temp_img_url = "";  
    private $err='';
    
    function configRobot($arr_config)
	{
        $this->base_url 		= isset($arr_config['base_url'])?$arr_config['base_url']:'';
        $this->my_base_url 		= isset($arr_config['my_base_url'])?$arr_config['my_base_url']:'';     
        $this->date_format		= isset($arr_config['date_format'])?$arr_config['date_format']:'';
        $this->date_format_link	= isset($arr_config['date_format_link'])?$arr_config['date_format_link']:'';
        $this->temp_img_url 	= isset($arr_config['temp_img_url'])?$arr_config['temp_img_url']:'';
    }
	
    /*function multiple_threads_request($nodes)
	{
        $mh = curl_multi_init();
        $curl_array = array();
        foreach($nodes as $i => $url)
        {
            $curl_array[$i] = curl_init($url);
            curl_setopt($curl_array[$i], CURLOPT_RETURNTRANSFER, true);			        
            curl_setopt($curl_array[$i], CURLOPT_BINARYTRANSFER, 1);
            curl_setopt($curl_array[$i], CURLOPT_FOLLOWLOCATION, 1);
            curl_setopt($curl_array[$i], CURLOPT_TIMEOUT,30);
            curl_multi_add_handle($mh, $curl_array[$i]);
        }
        $running = NULL;
        do {
            usleep(10000);
            curl_multi_exec($mh,$running);
        } while($running > 0);
       
        $res = array();
        foreach($nodes as $i => $url)
        {
            $res[$url] = curl_multi_getcontent($curl_array[$i]);
        }
       
        foreach($nodes as $i => $url){
            curl_multi_remove_handle($mh, $curl_array[$i]);
        }
        curl_multi_close($mh);       
        return $res;
    }*/
	
    function multi_get_news($nodes)
	{
        $mh = curl_multi_init();
        $curl_array = array();
        foreach($nodes as $i => $url)
        {
            $curl_array[$i] = curl_init($url['link']);
            curl_setopt($curl_array[$i], CURLOPT_RETURNTRANSFER, true);			        
            curl_setopt($curl_array[$i], CURLOPT_BINARYTRANSFER, 1);
            curl_setopt($curl_array[$i], CURLOPT_FOLLOWLOCATION, 1);
            curl_setopt($curl_array[$i], CURLOPT_FRESH_CONNECT, 1); 
            curl_setopt($curl_array[$i], CURLOPT_TIMEOUT,30);
            curl_multi_add_handle($mh, $curl_array[$i]);
        }
		
        $running = NULL;
        do {
            usleep(10000);
            curl_multi_exec($mh,$running);
        } while($running > 0);
		
       
        foreach($nodes as $i => $url)
        {
            $nodes[$i]['content'] = curl_multi_getcontent($curl_array[$i]);
        }
       
        foreach($nodes as $i => $url)
		{
            curl_multi_remove_handle($mh, $curl_array[$i]);
        }
        curl_multi_close($mh);     
		//trit($nodes);  
        return $nodes;
    }
	
    function getlinks($url,$rule_link)
	{ 
        $arr_link=array(); 
        $html = new simple_html_dom();
        //$html->load_file($url);
        
        //Begin connect
        $ch = curl_init($url);
        if (!$ch){
           //$this->setErr(RB_ERR_NOT_INIT_CURL);
           //$this->setErr($url);
           //return false;
        }
        // Chúng ta sẽ nhận trị trả về và nhận dưới dạng binary
        // Dó đó ta phải set 2 option như sau
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
        curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1); 
        curl_setopt($ch, CURLOPT_TIMEOUT,30);
        // Nếu không set như trên, bạn sẽ không nhận được gì
        // khi curl được thực thi, tức giá trị NULL
        // run curl and save value into data
        $content = curl_exec($ch);
        // close connect
        curl_close($ch);
        //End connect
        
        $html->load($content);
        //$a=$html;
        $arr_rule_link = explode("@",$rule_link);
        foreach ($arr_rule_link as $rule)
		{
            $aTemp=array();
            list($aTemp['rule_parent'], $aTemp['rule_image'], $aTemp['rule_link'],$aTemp['rule_time']) = explode('|', $rule); 
            
            if($aTemp['rule_parent']=='')
            {
                //echo $aTemp['rule_link'];
                 foreach ($html->find($aTemp['rule_link']) as $link)
				 {
                     if($aTemp['rule_time']!='')
					 {
                        $time = $link->find($aTemp['rule_time'],0);
                        if($time!=NULL)
						{
                            $str_time=$time->innertext;
                            //echo $str_time.'<br/>';
                            $time->outertext = '';
                            $getdate = $this->get_date($str_time,$this->date_format_link);
                            //print_r($getdate);
                            $compare=$this->compare_date($getdate);
                            //var_dump($getdate);
                            //only get news current day
                            if($compare)
							{
                                if ($link->href==NULL)  continue; 
                                if ($link->plaintext==NULL) continue; 
                                $text=str_replace(" "," ",$link->plaintext); 
                                $text=trim($text);         
                                if ($text=="") continue; 
                                if (substr($link->href,0,1)=="/") $link->href=$this->base_url. $link->href; 
                                if (in_array($link->href,$arr_link)==false){ 
                                    $arr_link[$text]['link']=$link->href;
                                    $arr_link[$text]['lb_title']=trim($link->plaintext);
                                    $arr_link[$text]['lb_small_image']=""; 
                                }
                            }
                        }
                    }
					else
					{
                        if ($link->href==NULL)  continue;
                        if ($link->plaintext==NULL) continue; 
                        $text=str_replace(" "," ",$link->plaintext); 
                        $text=trim($text);         
                        if ($text=="") continue; 
                        if (substr($link->href,0,1)=="/") $link->href=$this->base_url. $link->href; 
                        if (in_array($link->href,$arr_link)==false)
						{ 
                            $arr_link[$text]['link']=$link->href;
                            $arr_link[$text]['lb_title']=trim($link->plaintext);
                            $arr_link[$text]['lb_small_image']=""; 
                        }
                    }
                 }    
            }
			else
			{
                foreach ($html->find($aTemp['rule_parent']) as $parent)
				{
                    //echo $parent;
                    $link = $parent->find($aTemp['rule_link'],0);
                    if($link!=NULL)
					{
                        //echo $aTemp['rule_time'];
                        if($aTemp['rule_time']!='')
						{
                            $time = $parent->find($aTemp['rule_time'],0);
                            if($time!=NULL)
							{
                                $str_time=$time->innertext;
                                //echo $str_time.'<br/>';
                                $time->outertext = '';
                                $getdate = $this->get_date($str_time,$this->date_format_link);
                                //print_r($getdate);
                                $compare=$this->compare_date($getdate);
                                //var_dump($compare);
                                //only get news current day
                                if($compare)
								{
                                    if ($link->href==NULL)  continue; 
                                    if ($link->plaintext==NULL) continue; 
                                    $text = str_replace(" "," ",$link->plaintext); 
                                    $text = trim($text);         
                                    if ($text=="") continue; 
                                    if (substr($link->href,0,1)=="/") $link->href=$this->base_url. $link->href; 
                                    if (in_array($link->href,$arr_link)==false)
									{ 
                                        $arr_link[$text]['link']=$link->href; 
                                        $arr_link[$text]['lb_title']=trim($link->plaintext);
                                        $image  = $parent->find($aTemp['rule_image'],0);
                                        if($image!=NULL)
										{
                                            if (substr($image->src,0,1) == "/")  
                                                $image->src = $this->base_url.$image->src; 
                                            $arr_link[$text]['lb_small_image']=$image->src; 
                                        }
                                        else
										{
                                            //$lb_small_image ='';
                                            $arr_link[$text]['lb_small_image']=""; 
                                        } 
                                    }
                                }
                            }
                        }
						else
						{
                            if ($link->href==NULL)  continue; 
                            if ($link->plaintext==NULL) continue; 
                            $text=str_replace(" "," ",$link->plaintext); 
                            $text=trim($text);         
                            if ($text=="") continue; 
                            if (substr($link->href,0,1)=="/") $link->href=$this->base_url. $link->href; 
                            if (in_array($link->href,$arr_link)==false)
							{ 
                                $arr_link[$text]['link']=$link->href; 
                                $arr_link[$text]['lb_title']=trim($link->plaintext);
                                $image  = $parent->find($aTemp['rule_image'],0);
                                if($image!=NULL)
								{
                                    if (substr($image->src,0,1) == "/")  
                                        $image->src = $this->base_url.$image->src; 
                                    $arr_link[$text]['lb_small_image']=$image->src; 
                                }
                                else{
                                    //$lb_small_image ='';
                                    $arr_link[$text]['lb_small_image']=""; 
                                } 
                            }
                        }
                    }
					else
					{
                        //$this->setErr("Can't find tag link");
                        //$this->setErr($url);
                        //return false;
                    }
                }
            }
        } 
		//trit($arr_link);
        $html->clear(); 
        unset($html); 
        return $arr_link; 
    }
	
    /*Get all images from content to my host*/
    function cron_get_content_news($content){
        $news = array();
        $arr_image = array();

        $html = new simple_html_dom();
        $html->load($content);
        
        //Remove attribute
        $this->remove_attr($html);
        
        $arr_obj_img = array();
        
        foreach( $html->find('img') as $img){  
            if($img!=NULL)
            {    
                $img->src=trim($img->src);
                if($img->src!='')
                {
                    array_push($arr_obj_img,$img);
                }
            }
        }
        //get images in news to my host
        $download_img = new download_image($this->temp_img_url,"","");
        $download_img->multi_get_img($arr_obj_img);

        foreach($arr_obj_img as $obj_img){
            $img_title= ($obj_img->alt!=NULL)?$obj_img->alt:''; 
            $info = $obj_img->arr_img_info;
            $info['title']=$img_title;

            array_push($arr_image, $info);
            $new_url_picture=$this->my_base_url."uploads/temp/".$info['name'];
            $obj_img->src = $new_url_picture;
        }
        //$this->remove_attr($html);

        $news['content'] = $html->innertext; 
        $news['arr_image']=$arr_image;
        
        $html->clear(); 
        unset($html); 
        return $news; 
    }
	
    function cron_get_once_news($arr_link,$rule_detail)
	{
        $news = array();
        $arr_rule = array();
        $arr_image = array();
		
        if($arr_link['link']!='')
		{  
            $html = new simple_html_dom();
            //$html->load_file($url);
            /*Begin open curl*/
            /*End open curl*/
             $html->load($arr_link['content']);
        
            list($arr_rule['rule_parent'], $arr_rule['rule_title'], $arr_rule['rule_des'],$arr_rule['rule_relate_news'],$arr_rule['rule_content'],$arr_rule['rule_delete'],$arr_rule['rule_time']) = explode('|', $rule_detail);

            $parent = $html->find($arr_rule['rule_parent'],0);
            //echo $parent->innertext;
            if($parent!=NULL)
			{
                $time = $html->find($arr_rule['rule_time'],0);
                if($time!=NULL)
				{
                    $str_time=$time->innertext;
                    //echo $str_time.'<br/>';
                    $time->outertext = '';
                    $getdate = $this->get_date($str_time,$this->date_format);
                    //print_r($getdate);
                    $compare=$this->compare_date($getdate);
                    //var_dump($compare);
                    //only get news current day
                    if($compare)
					{
                        $seo_keyword = $html->find('meta[name=keywords]',0);
                        if($seo_keyword!=NULL)
                        {
                            $news['seo_keyword']=$seo_keyword->content;
                        }else{
                            $news['seo_keyword']='';
                        }
                        $title = $parent->find($arr_rule['rule_title'],0); 
                        if($title!=NULL)
						{
                            //$news['title']=$title->innertext; 
                            $news['title']=$title->plaintext; 
                            $title->outertext='';
                        }
						else
						{
                            $this->setErr("Can't find tag title");
                            $this->setErr($arr_link['link']);
                            //return false;
                        }
                        if($arr_rule['rule_des']!='')
                        {
                            $des = $parent->find($arr_rule['rule_des'],0); 
                            if($des!=NULL){
                                $this->remove_attr($des);
                                $news['des']=$des->plaintext; 
                                $des->outertext = '';
                            }else{
                                $news['des']=""; 
                            }
                        }else{
                            $news['des']="";
                        }
                        $content = $html->find($arr_rule['rule_content'],0);
                        
                        if($content!=NULL)
                        {    
                            $arr_obj_img = array();
                            foreach( $content->find('img') as $img){  
                                if($img!=NULL)
                                {    
                                    $img->src=trim($img->src);
                                    if($img->src!='')
                                    {    if (substr($img->src,0,1) == "/"){  
                                            $img->src = $this->base_url.$img->src;
                                            /*BEgin End code file name to get imagesize for case url invalid*/
                                            $filename_encode = $this->get_url_filename($img->src);
                                            $img->src = str_replace ($filename_encode,urlencode($filename_encode),$img->src);
                                            /*End End code*/
                                         }
                                        array_push($arr_obj_img,$img);
                                    }
                                }
                            }
                            //get images in news to my host
                            $download_img = new download_image($this->temp_img_url,"","");
                            $download_img->multi_get_img($arr_obj_img);
                            
                            foreach($arr_obj_img as $obj_img){
                                $img_title= ($obj_img->alt!=NULL)?$obj_img->alt:''; 
                                   
                                $info = $obj_img->arr_img_info;
                                //print_r($info);
                                //if(count($info)<=0)echo $img->src;
                                $info['title']=$img_title;
                                
                                array_push($arr_image, $info);
                                $new_url_picture=$this->my_base_url."uploads/temp/".$info['name'];
                                $obj_img->src = $new_url_picture;
                            }
                            $this->remove_attr($content);
                            
                            $news['content'] = $content->innertext; 
                        }else {
                            $this->setErr("Can't find tag content detail");
                            $this->setErr($arr_link['link']);
                            
                            return array();
                        }
                        $news['time']=$getdate;
                        $news['arr_image']=$arr_image;
                    }  
                }else{
                    $this->setErr("Can't find tag time detail");
                    $this->setErr($arr_link['link']);
                    //return false;
                }
            }else{
                $this->setErr("Can't find div content detail");
                $this->setErr($arr_link['link']);
                //return false;
            }   
            $html->clear(); 
            unset($html); 
        }
        return $news; 
    }
	 
    function get_once_news($url,$rule_detail)
	{
        
        $news = array();
        $arr_rule = array();
        $arr_image = array();
        if($url!=''){  
            $html = new simple_html_dom();
            //$html->load_file($url);
            /*Begin open curl*/
            $ch = curl_init($url);
            if (! $ch) {
                $this->setErr(RB_ERR_NOT_INIT_CURL);
                $this->setErr($url);
                //return false;
            }
            // Chúng ta sẽ nhận trị trả về và nhận dưới dạng binary
            // Dó đó ta phải set 2 option như sau
            /*curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
            curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
            curl_setopt($ch, CURLOPT_TIMEOUT,30);*/
            
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
            curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
            curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1); 
            curl_setopt($ch, CURLOPT_TIMEOUT,30);
            // Nếu không set như trên, bạn sẽ không nhận được gì
            // khi curl được thực thi, tức giá trị NULL
            // run curl and save value into data
            $content = curl_exec($ch);
            //echo $content;
            // close connect
            curl_close($ch);
            /*End open curl*/
            $html->load($content);
        
            list($arr_rule['rule_parent'], $arr_rule['rule_title'], $arr_rule['rule_des'],$arr_rule['rule_relate_news'],$arr_rule['rule_content'],$arr_rule['rule_delete'],$arr_rule['rule_time']) = explode('|', $rule_detail);

            $parent = $html->find($arr_rule['rule_parent'],0);
            //echo $parent->innertext;
            if($parent!=NULL){
               
                $time = $html->find($arr_rule['rule_time'],0);
                
                if($time!=NULL){
                    $str_time=$time->innertext;
                    //echo $str_time.'<br/>';
                    $time->outertext = '';
                    $getdate = $this->get_date($str_time,$this->date_format);
                    //print_r($getdate);
                    //$compare=$this->compare_date($getdate);
                    //echo $compare;
                    //only get news current day
                    //if($compare){
                        $seo_keyword = $html->find('meta[name=keywords]',0);
                        if($seo_keyword!=NULL)
                        {
                            $news['seo_keyword']=$seo_keyword->content;
                        }else{
                            $news['seo_keyword']='';
                        }
                        $title = $parent->find($arr_rule['rule_title'],0); 
                        if($title!=NULL){
                            //$news['title']=$title->innertext; 
                            $news['title']=trim($title->plaintext); 
                            $title->outertext='';
                        }else{
                            $this->setErr("Can't find tag title");
                            $this->setErr($url);
                            //return false;
                        }
                        if($arr_rule['rule_des']!='')
                        {
                            $des = $parent->find($arr_rule['rule_des'],0); 
                            if($des!=NULL){
                                $this->remove_attr($des);
                                $news['des']=trim($des->plaintext); 
                                $des->outertext = '';
                            }else{
                                $news['des']=""; 
                            }
                        }else{
                            $news['des']="";
                        }
                        $content = $html->find($arr_rule['rule_content'],0);
                        
                        if($content!=NULL)
                        {   
                            /*foreach( $content->find('img') as $img){         
                                $img->src=trim($img->src);
                                if (substr($img->src,0,1) == "/")  
                                    $img->src = $this->base_url.$img->src;
                                $img_title= ($img->alt!=NULL)?$img->alt:''; 
                                    
                                //get images in news to my host
                                $download_img = new download_image($this->temp_img_url,"","");        
                                $info = $download_img->get_img($img->src);
                                //print_r($info);
                                //if(count($info)<=0)echo $img->src;
                                $info['title']=$img_title;
                                
                                array_push($arr_image, $info);
                                $new_url_picture=$this->my_base_url."uploads/temp/".$info['name'];
                                $img->src = $new_url_picture;
                            }*/
                            $arr_obj_img = array();
                            foreach( $content->find('img') as $img){  
                                if($img!=NULL)
                                {    
                                    $img->src=trim($img->src);
                                    if($img->src!='')
                                    {    
                                        if (substr($img->src,0,1) == "/"){  
                                            $img->src = $this->base_url.$img->src;
                                            /*BEgin End code file name to get imagesize for case url invalid*/
                                            $filename_encode = $this->get_url_filename($img->src);
                                            $img->src = str_replace ($filename_encode,urlencode($filename_encode),$img->src);
                                            /*End End code*/
                                         }
                                        array_push($arr_obj_img,$img);
                                    }
                                }
                                
                            }
                            //get images in news to my host
                            $download_img = new download_image($this->temp_img_url,"","");
                            $download_img->multi_get_img($arr_obj_img);
                            
                            foreach($arr_obj_img as $obj_img){
                                $img_title= ($obj_img->alt!=NULL)?$obj_img->alt:''; 
                                   
                                $info = $obj_img->arr_img_info;
                                //print_r($info);
                                //if(count($info)<=0)echo $img->src;
                                $info['title']=$img_title;
                                
                                array_push($arr_image, $info);
                                $new_url_picture=$this->my_base_url."uploads/temp/".$info['name'];
                                $obj_img->src = $new_url_picture;
                                
                            }
                            $this->remove_attr($content);
                            //echo $content->innertext;exit();
                            $news['content'] = $content->innertext; 
                        }else {
                            $this->setErr("Can't find tag content detail");
                            $this->setErr($url);
                            return array();
                            //return false;
                        }
                        $news['time']=$getdate;
                        $news['arr_image']=$arr_image;
                    //}  
                }else{
                    $this->setErr("Can't find tag time detail");
                    $this->setErr($url);
                    //return false;
                }
            }else{
                $this->setErr("Can't find div content detail");
                $this->setErr($url);
                //return false;
            }   
            $html->clear(); 
            unset($html); 
        }
        //print_r($news);
        return $news; 
    } 
	
    function remove_attr(&$obj)
    {
        //Replace short link by full link
        foreach($obj->find('a') as $a){         
            $a->href=trim($a->href);
            if (substr($a->href,0,1) == "/")  
                $a->href = $this->base_url.$a->href;
        }
        //Begin remove class,style,script
        foreach ($obj->find("*[class]") as $class){
            $class->class="";
        }
        foreach ($obj->find("*[id]") as $class){
            $class->id="";
        }
        foreach ($obj->find("*[style]") as $style){
            $style->style="";
        }
        foreach ($obj->find("script") as $script){
            $script->outertext="";
        }
    }
	
    function get_date($str_date,$format)
	{
        date_default_timezone_set('Asia/Ho_Chi_Minh');
        $date=array();
        $matched=array(0,0,0,0,0,0,0);
        switch ($format){
            case "d/m/y":
                preg_match('/(\d{0,2})[-|:\/](\d{0,2})[-|:\/](\d{0,4})[^\d]*(\d{0,2})?:?(\d{0,2}):?(\d{0,2})?/',$str_date, $matched);
                //echo "Nam {$matched[1]}, Thang {$matched[2]}, Ngay {$matched[3]},Gio {$matched[4]}, Phut  {$matched[5]}, Giay {$matched[6]} ";
                $date['year']=(strlen($matched[3])==2)?'20'.$matched[3]:$matched[3];
                $date['mon']=$matched[2];
                $date['mday']=$matched[1];
                $date['hours'] =$matched[4];
                $date['minutes'] =$matched[5];
                $date['seconds'] =$matched[6];
                break;
            case "y/m/d":
                preg_match('/(\d{0,4})[-|:\/](\d{0,2})[-|:\/](\d{0,2})[^\d]*(\d{0,2}):(\d{0,2}):?(\d{0,2})?/',$str_date, $matched);
                $date['year']=$matched[1];
                $date['mon']=$matched[2];
                $date['mday']=$matched[3];
                $date['hours'] =$matched[4];
                $date['minutes'] =$matched[5];
                $date['seconds'] =$matched[6];
                break;
            case "h:m d/m/y":
                preg_match('/(\d{0,2}):(\d{0,2}):?(\d{0,2})?[^\d]*(\d{0,2})[-|:\/](\d{0,2})[-|:\/](\d{0,4})/',$str_date, $matched);
                $date['year']=$matched[6];
                $date['mon']=$matched[5];
                $date['mday']=$matched[4];
                $date['hours'] =$matched[1];
                $date['minutes'] =$matched[2];
                $date['seconds'] =$matched[3];
                break;
            case "d/m/y h:m":
                //echo $str_date;
                preg_match('/(\d{0,2})[-|:\/](\d{0,2})[-|:\/](\d{0,4}) (\d{0,2}):(\d{0,2})/',$str_date, $matched);
                //print_r($matched);exit();
                $date['year']=$matched[3];
                $date['mon']=$matched[2];
                $date['mday']=$matched[1];
                $date['hours'] =$matched[4];
                $date['minutes'] =$matched[5];
                $date['seconds'] =isset($matched[6])?$matched[6]:0;
                break; 
            case "giophuttruoc":
                if(preg_match('/(\d{0,2}) giờ (\d{0,2}) phút trước/',$str_date, $matched))
                {   //gio phut
                    $dt = new DateTime();
                    $modify = '-'.$matched[1].'hour -'.$matched[2].' minute';
                    $dt->modify($modify);
                    
                    $date['year']=$dt->format('Y');
                    $date['mon']=$dt->format('m');
                    $date['mday']=$dt->format('d');
                    $date['hours'] =$dt->format('G');
                    $date['minutes'] =$dt->format('i');
                    $date['seconds'] =$dt->format('s');
                }else if(preg_match('/(\d{0,2}) giờ trước/',$str_date, $matched)){
                    //gio
                    $dt = new DateTime();
                    $modify = '-'.$matched[1].' hour';
                    $dt->modify($modify);
                    
                    $date['year']=$dt->format('Y');
                    $date['mon']=$dt->format('m');
                    $date['mday']=$dt->format('d');
                    $date['hours'] =$dt->format('G');
                    $date['minutes'] =$dt->format('i');
                    $date['seconds'] =$dt->format('s');
                }else if(preg_match('/(\d{0,2}) phút trước/',$str_date, $matched)){
                    //phut
                    $dt = new DateTime();
                    $modify = '-'.$matched[1].' minute';
                    $dt->modify($modify);

                    $date['year']=$dt->format('Y');
                    $date['mon']=$dt->format('m');
                    $date['mday']=$dt->format('d');
                    $date['hours'] =$dt->format('G');
                    $date['minutes'] =$dt->format('i');
                    $date['seconds'] =$dt->format('s');
                }
                else if(preg_match('/(\d{0,2})[-|:\/](\d{0,2})[-|:\/](\d{0,4})[^\d]*(\d{0,2}):(\d{0,2}):?(\d{0,2})?/',$str_date, $matched))
                {
                    $date['year']=(strlen($matched[3])==2)?'20'.$matched[3]:$matched[3];
                    $date['mon']=$matched[2];
                    $date['mday']=$matched[1];
                    $date['hours'] =$matched[4];
                    $date['minutes'] =$matched[5];
                    $date['seconds'] =$matched[6];
                }
                break;
        }
        return $date;
    }
	
    function compare_date($date)
	{
        if($date['year']!=''&&$date['mon']!=''&&$date['mday']!='')
        {    
            date_default_timezone_set('Asia/Ho_Chi_Minh');
            $now =  date('Y-m-d');
            $str_date=$date['year'].'-'.$date['mon'].'-'.$date['mday'];
            $date1 = date_create($now);
            $date2 = date_create($str_date);
            if($date1 == $date2)
            {
                return true;
            }else{
                return false;
            }
        }else{
            return false;
        }
    }
	
    public function setErr($err){
        $this->err .=$err.'<br/>';
    }
    public function getErr(){
       return $this->err;
    }
    function get_url_filename($url)
    {
        $arr = explode("/",$url);
        $filename = array_pop($arr);
        $ext = substr($filename,strpos($filename,"."));
        if (substr($ext,4))
        {
            if (substr($ext,4,1)=="?"){
                $ext = substr($ext,0,4);
            }else{
                $ext = substr($ext,0,5);
            }
        }
        $filename = substr($filename,0,strpos($filename,"."));

        return $filename . $ext;
    }
    function copy_images_editor($base_url='',$url_copy='',$src_html=''){
        $html = str_get_html($src_html);
            if($html){
                foreach($html->find('img') as $element){
                    $pos = strpos($element->src, 'uploads/images/');
                    if($pos === false){

                    }else{
                        $img_src  = substr($element->src,$pos);
                        $img_des = $url_copy.date("dmYHis").end(explode('/',$element->src));
                        copy('../'.$img_src,'../'.$img_des);
                        $element->src = $base_url.$img_des;
                    }
                }
            }
        return $html;
    }
}
?>

Youez - 2016 - github.com/yon3zu
LinuXploit