MyBB Community Forums

Full Version: Developer, Do you think you can solve this?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I modify my code MyCode lines in class_parser.php to include link checking. And It does work..well, at least for 1 link.

If I put a single link in code tag, I will get this:
http://filehost.com/file.zip - (file found!)


But if I put several links in code tag, I will get this:
http://filehost.com/file.zip
http://filehost.com/file.zip
http://filehost.com/file.zip
http://filehost.com/file.zip
http://filehost.com/file.zip
http://filehost.com/file.zip - (file found!)

Which is only the last file get checked.


So, how to make it check each link and print "(file found)" at the end of the links?


For reference, here is my code MyCode in class_parser.php
	/**
	* Parses code MyCode.
	*
	* @param string The message to be parsed
	* @param boolean Are we formatting as text?
	* @return string The parsed message.
	*/
	function mycode_parse_code($code, $text_only=false)
	{
		global $lang;

		if($text_only == true)
		{
			return "\n{$lang->code}\n--\n{$code}\n--\n";
		}

		// Clean the string before parsing.
		$code = preg_replace('#^(\t*)(\n|\r|\0|\x0B| )*#', '\\1', $code);
		$code = rtrim($code);
		$original = preg_replace('#^\t*#', '', $code);

		if(empty($original))
		{
			return;
		}

		$code = str_replace('$', '$', $code);
		$code = preg_replace('#\$([0-9])#', '\\\$\\1', $code);
		$code = str_replace('\\', '\', $code);
		$code = str_replace("\t", '    ', $code);
		$code = str_replace("  ", '  ', $code);
		
			//Link Checking Addon
		if(strstr($original,"rapidshare.com")){
        $var = file_get_contents($original);
        $checked = $checked + 1;
        if(strpos($var,"FILE DOWNLOAD")){
        $status =  " <font color=\"green\">(file found!)<br></font>";
        $working = $working + 1;
        }
        if(strpos($var,"The file could not be found")){
        $status =  " <font color=\"red\">(file not found!)<br></font>";  
        }      
        if(strpos($var," deleted.")){
        $status =  "  <font color=\"red\">(file deleted!)<br></font>";
        }


    } elseif (strstr($original,"megaupload.com")){
        $var1 = file_get_contents($original);
        $checked = $checked +1;
        if(strpos($var1,"Please enter")){
            $status =  " <font color =\"green\">(file found!)<br></font>";
            $working = $working + 1;
        }
        if(strpos($var1,"Unfortunately, the link you have clicked is not available.")){
            $status =  " <font color =\"red\">(file not found!)<br></font>";    
        }
        
    } elseif (strstr($original,"megashares.com")){
        $var2 = file_get_contents($original);
        $checked = $checked +1;
        if(strpos($var2,"Filename:")){
            $status =  " <font color =\"green\">(file found!)<br></font>";
            $working = $working + 1;
        }
        if(strpos($var2,"Welcome to Megashares")){
            $status =  " <font color =\"red\">(file not found!)<br></font>";    
        }
        if(strpos($var2,"have the correct URL")){
            $status =  " <font color =\"red\">(file not found!)<br></font>";    
        }
        
    } elseif (strstr($original,"sendspace.com")){
        $var3 = file_get_contents($original);
        $checked = $checked +1;
        if(strpos($var3,"404 Page Not Found")){
            $status =  " <font color =\"red\">(file not found!)<br></font>";    
        
        } elseif(strpos($var3,"Sorry, the file you requested is not available.")){
            $status =  " <font color =\"red\">(file not found!)<br></font>";    
        } else {
            $status =  " <font color =\"green\">(file found!)<br></font>";
            $working = $working + 1;
            }
    } elseif(strstr($original,"rapidshare.de")){
        $var5 = file_get_contents($original);
        $checked = $checked + 1;
        if(strpos($var,"You want to download the file ")){
        $status =  " <font color=\"green\">(file found!)<br></font>";
        $working = $working + 1;
        }
        if(strpos($var,"File not found.")){
        $status =  " <font color=\"red\">(file not found!)<br></font>";  
        }      
        if(strpos($var," deleted.")){
        $status =  " <font color=\"red\">(file deleted!)<br></font>";
        }
        
    } elseif (strstr($original,"mediafire.com")){
        $var4 = file_get_contents($original);
        $checked = $checked +1;
        if(strpos($var4,"Sharing")){
            $status =  " <font color =\"green\">(file found!)<br></font>";    
            $working = $working + 1;
        }
        if(strpos($var4,"Invalid Quickkey.")){
            $status =  " <font color =\"red\">(file not found!)<br></font>";    
        }
        if(strpos($var4,"I want to upload")){
            $status =  " <font color =\"red\">(file not found!)<br></font>";    
        }
    } else {
        $status =  "";    
    }

		return "<div class=\"codeblock\">\n<div class=\"title\">".$lang->code."\n</div><div class=\"body\" dir=\"ltr\"><code>".$code." - ".$status."</code></div></div>\n";
	}