Skip to content
WJunction - Webmaster Forum

Hosts Bot Chk DDL - BBcode

Status
Not open for further replies.
hi

this is the bot too chk for hosts:

the problem is it only chks live links, eg.

www.oron.com/myfile.txt <-- the bot can see this "live link" btw

[ c o d e ]www.oron.com/myfile.txt[ / c o d e ] <-- it cnt see it. why? beccos its got tags aaround...

how to make it chk inside tags to........?
 

10 comments

Well, the whole checking of code is:
PHP:
<?php

$hosts = array('test', 'www.oron.com');

foreach($hosts as $host) if(strpos('[code]www.oron.com/myfile.txt', $host)) echo 'Yeah, it contains ' . $host . ' link. <br />';

?>
You could add a statement to check whether it founds anything or not. Because strpos returns the position of the text you find. So if the string starts with the string to search, then it wont work

PHP:
<?php

$hosts = array('test', 'www.oron.com');

foreach($hosts as $host) if(strpos('www.oron.com/myfile.txt', $host) !== false) echo 'Yeah, it contains ' . $host . ' link. <br />';

?>
So it will work for this case too

Reposting since original post got deleted. Removed the original code since its some other user work this time though
 
so, forgive me if im asking dumb question btw wud this work:
PHP:
	foreach($hosts as $host)  
	if(strpos('[code]'.$host.'[/code]')) $keyword[] = $host; else if(strpos($file['content'],$host)) $keyword[] = $host;

it should work?
 
If you pulling the links from a forums database they may be encoded.
echo one to check.

replacing [ and ] With a space should work.
 
so, forgive me if im asking dumb question btw wud this work:
PHP:
    foreach($hosts as $host)  
    if(strpos('[code]'.$host.'[/code]')) $keyword[] = $host; else if(strpos($file['content'],$host)) $keyword[] = $host;
it should work?
Well, theres no need to check for string with codes

Try this:
PHP:
 foreach($hosts as $host) if(strpos($file['content'], $host) !== false) $keyword[] = $host;
 
use regex if you want more certainty
PHP:
$string = '[code]www.oron.com/myfile.txt'; //your string here
$host = 'oron.com'; //mind the format, host.com, no www.
$host = str_replace('.', '\.', $host); //escape dots
$pattern = '/(w{3}|)\.' . $host . '[a-zA-Z0-9_\\-.:#\/~}]/i'; //pattern to use
$found = preg_match($pattern, $string);

echo ($found ? 'found' : 'not found');
 
hi i think soft2050 is on the rite track... btw will it chk live links aswll as linkss in tags likee
Code:
 and <pre>
 
Well, it does work for
Code:
 and <pre> tags. because it does work for:

[php]<?php

$hosts = array('test', 'www.oron.com');

foreach($hosts as $host) if(strpos('[code]<pre>www.oron.com/myfile.txt</pre>
', $host) !== false) echo 'Yeah, it contains ' . $host . ' link. <br />';

?> [/php]

For the live links, no it wont check those. You need to get the links and check them then.

Also, the above method will check for the string in the page, it will add it if it found even the domain name in the page. so either you have to specify the full link starter (eg: filesonic.com/file) or use regex so that no one can spoof.
 
Show the source code of what you trying to get the links from, echo it and paste it to paste.to

Why dont you check for dead links on sites with no API, then if there site is down or your IP banned you wont get false reports of dead links :)
 
Status
Not open for further replies.

About the author

C
Banned · Joined
901
Messages
17
Reactions
18
Points
Grow your business

Advertise on WJunction

Connect with an established international community of webmasters, hosting providers, developers and online entrepreneurs.

  • Premium & Premium+ Sticky
  • Dedicated section banners
  • Site-wide banner advertising
Explore advertising options
Back
Top Bottom