GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   need a PHP script coded (https://gfy.com/showthread.php?t=830270)

Mr Pheer 05-22-2008 08:55 PM

need a PHP script coded
 
should be simple

take a list of URLs I provide, check each one of them for a 404 response. If it gets that response, tell me which URL did it.

There are hundreds to check

paypal is ready to go

Juicy D. Links 05-22-2008 08:58 PM

show me your penis please

harvey 05-22-2008 09:20 PM

I already did it for you, please send $100 via paypal

Mr Pheer 05-22-2008 09:24 PM

Quote:

Originally Posted by harvey (Post 14226451)
I already did it for you, please send $100 via paypal

Its not checking for 404's on my sites, its on another site.

thats also not PHP

harvey 05-22-2008 09:32 PM

Quote:

Originally Posted by Mr Pheer (Post 14226456)
Its not checking for 404's on my sites, its on another site.

thats also not PHP

Xenu checks broken links in your site or off your site, no matter what. Not sure if I get what you mean. but you're right, is not PHP (although it's 10 times better than any php script out there and it's free). Anyway, if it's not what you need, there's nothing to discuss, however, a "thanx" or "thanx, but not what I was looking for" would have been enough :winkwink:

Steve Awesome 05-22-2008 09:35 PM

Didn't Xenu throw the Thetans into a volcano? That bastard!

Sly 05-22-2008 09:38 PM

Quote:

Originally Posted by harvey (Post 14226480)
Xenu checks broken links in your site or off your site, no matter what. Not sure if I get what you mean. but you're right, is not PHP (although it's 10 times better than any php script out there and it's free). Anyway, if it's not what you need, there's nothing to discuss, however, a "thanx" or "thanx, but not what I was looking for" would have been enough :winkwink:


He wants the program to feed in a list of addresses. Go to each address and see if the site/file exists. Create and output list of addresses that return a 404.

Bro Media - BANNED FOR LIFE 05-22-2008 09:50 PM

PHP Code:

<?php
if($_POST['submit'] == true)
{
    
$exp_url explode("\n"$_POST['url']);
    foreach(
$exp_url as $url)
    {
        
$response http_get($url, array("timeout" => 1), $info);
        if(
$info['response_code'] == "404")
        {
            echo 
"<b>404</b>&nbsp;" $url "<br />\n";
        }
    }
}else{
?>
<form method="post">
  <div align="center"><strong>Urls:</strong><br>
      <textarea name="url" id="url" cols="45" rows="5"></textarea>
    <br>  
    <input type="submit" name="submit" id="submit" value="Check Response">
  </div>
</form>
<?php
}
?>

don't have paypal, but if you got epass, i'll take a some, [email protected]

Bro Media - BANNED FOR LIFE 05-22-2008 09:53 PM

oh, i forgot you need the php_http extension installed on your server.

GrouchyAdmin 05-22-2008 10:12 PM

This is kind of simple. Do you just want it to report 404s? How do you want to 'feed' it?

ztik 05-22-2008 10:15 PM

script in my sig does that!

GrouchyAdmin 05-22-2008 10:17 PM

Quote:

Originally Posted by Jaysin (Post 14226538)
oh, i forgot you need the php_http extension installed on your server.

cURL is almost always safe to assume these days. :thumbsup

Zoose 05-22-2008 10:17 PM

Here's a version that uses curl:

Quote:

<?php

$list_of_urls = file( "urls.txt" );

while( list( $key, $value ) = each( $list_of_urls ) ){

$curl_handle = curl_init();

curl_setopt( $curl_handle, CURLOPT_URL, $list_of_urls[$key] );
curl_setopt( $curl_handle, CURLOPT_RETURNTRANSFER, true );

$response = curl_exec( $curl_handle );
$response_code = curl_getinfo( $curl_handle, CURLINFO_HTTP_CODE );

if( $response_code == '404' ){

echo $list_of_urls[$key]." appears to be 404<br>";

}

}

?>
Make a urls.txt file and put one url per line.

GrouchyAdmin 05-22-2008 10:29 PM

http://www.imagepup.com/up/FIxz_1211..._404thingy.jpg

This one's stupid, but it uses the common class.curl.php, and does a select based upon the error, so you can add different features/functions for 403s, 500s, etc.. Mostly, I'm just lazy and didn't figure it deserved OOP, even if I'm using an OOP class. Enjoy.

Code:

<html>
<head>
<Title>404 Test Thingy or whatever</title>
</head>
<body bgcolor="#ffffff" text="#000000" link="#0000ff">
<br>
<form method="post">
  <div align="center"><strong>Test URLs:</strong><br>
      <textarea name="urls" id="urls" cols="45" rows="5"><?=isset($_REQUEST['urls'])?$_REQUEST['urls']:"";?></textarea>
    <br>
    <input type="submit" name="submit" id="submit" value="Check Response">
  </div>
</form>
<?php
// This is hardly an example of good PHP.  Ugh.
@require_once("class.curl.php");
// trim() to get rid of errant enter keys.
$myurls = (isset($_REQUEST['urls'])?explode("\n", trim($_REQUEST['urls'])): array());
foreach ($myurls as $url) {
  // use our cURL class.
  $curlInit = new curl($url);
  // Make sure we don't follow redirects.
  $curlInit->setopt(CURLOPT_FOLLOWLOCATION, FALSE) ;
  // Do it.
  $curlInit->exec();
  // If we returned a connection error, say so.
  if ($myError = $curlInit->hasError()) {
    echo "ERR: $url ($myError)<br>\n";
  } else {
    // Reinit our array
    $status = array();
    // Seems to have worked, parse it.
    if (is_array($curlInit->m_status))
      $status = $curlInit->m_status;
    // Simple error checking.
    if (!empty($status)) {
      switch($status["http_code"]) {
        case "404":
          echo "<font color='red'>404</font>: <a href='$url' target='_new'>[link]</a> $url<br>\n";
          break;
        default:
          // Do nothing if not 404, I guess.
          break;
      }
    }
  }
  // We're done, close the socket.
  $curlInit->close();
} ?>
</body>
</html>


Zoose 05-22-2008 10:35 PM

rofl

Quote:

404 Test Thingy or whatever
Nicely done though for hacking it together in 5 mins. :p

GrouchyAdmin 05-22-2008 10:38 PM

Quote:

Originally Posted by Zoose (Post 14226651)
Nicely done though for hacking it together in 5 mins. :p

I dunno if I'd give it ratings that high. There's gonna be someone who needs urldecode, someone with a bizarre gpg setting, and.. oh god fuck PHP. :)

At least I can rely on trusty ol' cURL to almost always be there. fopen urls and http_get don't usually worked no more on crummy virtualhosts, but cURL? Most of the time. I almost turned headers on and NOBODY to use a HEAD to parse with less overhead, but the class is oddly lacking in the ability to handle that.

mrkris 05-22-2008 10:55 PM

Quote:

Originally Posted by GrouchyAdmin (Post 14226661)
I dunno if I'd give it ratings that high. There's gonna be someone who needs urldecode, someone with a bizarre gpg setting, and.. oh god fuck PHP. :)

At least I can rely on trusty ol' cURL to almost always be there. fopen urls and http_get don't usually worked no more on crummy virtualhosts, but cURL? Most of the time. I almost turned headers on and NOBODY to use a HEAD to parse with less overhead, but the class is oddly lacking in the ability to handle that.

I give you 2/5, mainly because I see you're lacking eval() calls.

pr0 05-22-2008 11:00 PM

how about the same script that looks for txt on the index, instead of a response code

like the text "this site does not exist"

how would ya do that in curl/php? That might be even more fool proof for him. Sometimes servers return bad codes even if the site isn't bad. This would foolproof it.

Mr Pheer 05-22-2008 11:05 PM

Quote:

Originally Posted by pr0 (Post 14226709)
how about the same script that looks for txt on the index, instead of a response code

like the text "this site does not exist"

how would ya do that in curl/php? That might be even more fool proof for him. Sometimes servers return bad codes even if the site isn't bad. This would foolproof it.

that was kind of exactly what I was looking for

Hillsborough on ICQ made exactly what I needed, not sure what his name is on GFY

mrkris 05-22-2008 11:05 PM

Quote:

Originally Posted by pr0 (Post 14226709)
how about the same script that looks for txt on the index, instead of a response code

like the text "this site does not exist"

how would ya do that in curl/php? That might be even more fool proof for him. Sometimes servers return bad codes even if the site isn't bad. This would foolproof it.

True, but that's not as common as you think. Many times people just use a customized 404.

GrouchyAdmin 05-22-2008 11:07 PM

Quote:

Originally Posted by mrkris (Post 14226696)
I give you 2/5, mainly because I see you're lacking eval() calls.

bich i cut u

Code:

<html>
<head>
<Title>404 Test Thingy from hell</title>
</head>
<body bgcolor="#ffffff" text="#000000" link="#0000ff">
<br>
<form method="post">
  <div align="center"><strong>Test URLs:</strong><br>
      <textarea name="urls" id="urls" cols="45" rows="5"><?=isset($_REQUEST['urls'])?$_REQUEST['urls']:"";?></textarea>
    <br>
    <input type="submit" name="submit" id="submit" value="Check Response">
  </div>
</form>
<?php
// BE SAFE: WRAP YOUR CRAP!
if (!function_exists('findCurlCli')) {
  function findCurlCli() {
    $curlClis=array(
                  '/usr/bin/curl', '/usr/local/bin/curl',
                  '/usr/bin/curl-cli', '/usr/local/bin/curl-cli',
                  '/usr/bin/curlcli', '/usr/local/bin/curlcli',
                  '/usr/bin/curl-cli', '/usr/local/bin/curl-cli',
                  // FOR SOME REASON THIS DOESNT WORK!!!!!
                  // '/usr/bin/wget', '/usr/local/bin/wget'
                  );

    foreach ($curlClis as $curlcli) {
      if (@is_file("$curlcli") && is_executable("$curlcli")) {
          return("$curlcli");
          break;
      } else {
        return FALSE;
      }
    }
  }
}
// lol
if ($foundCurl = findCurlCli()) {
  $myurls = (isset($_REQUEST['urls'])?explode("\n", trim($_REQUEST['urls'])): array());
  foreach ($myurls as $url) {
    // escapeshellcmd is for pussies and communists.
    $data = system("$foundCurl -I $url | grep -v '404'");
      if ($data = "1") {
        echo "<font color='red'>404</font>: <a href='$url' target='_new'>[link]</a> $url<br>\n";
      }
    }
  }
}
?>
</body>
</html>


GrouchyAdmin 05-22-2008 11:08 PM

Quote:

Originally Posted by mrkris (Post 14226720)
True, but that's not as common as you think. Many times people just use a customized 404.

One of these days, WordPress, shitty management tools, and RoR will support standard error codes.


That's in 2038, of course.

mrkris 05-22-2008 11:37 PM

Quote:

Originally Posted by GrouchyAdmin (Post 14226730)
One of these days, WordPress, shitty management tools, and RoR will support standard error codes. That's in 2038, of course.

and some day JESUS WILL SAVE YOU. ZING!

mrkris 05-22-2008 11:38 PM

Quote:

Originally Posted by GrouchyAdmin (Post 14226725)
bich i cut u

Code:

<html>
<head>
<Title>404 Test Thingy from hell</title>
</head>
<body bgcolor="#ffffff" text="#000000" link="#0000ff">
<br>
<form method="post">
  <div align="center"><strong>Test URLs:</strong><br>
      <textarea name="urls" id="urls" cols="45" rows="5"><?=isset($_REQUEST['urls'])?$_REQUEST['urls']:"";?></textarea>
    <br>
    <input type="submit" name="submit" id="submit" value="Check Response">
  </div>
</form>
<?php
// BE SAFE: WRAP YOUR CRAP!
if (!function_exists('findCurlCli')) {
  function findCurlCli() {
    $curlClis=array(
                  '/usr/bin/curl', '/usr/local/bin/curl',
                  '/usr/bin/curl-cli', '/usr/local/bin/curl-cli',
                  '/usr/bin/curlcli', '/usr/local/bin/curlcli',
                  '/usr/bin/curl-cli', '/usr/local/bin/curl-cli',
                  // FOR SOME REASON THIS DOESNT WORK!!!!!
                  // '/usr/bin/wget', '/usr/local/bin/wget'
                  );

    foreach ($curlClis as $curlcli) {
      if (@is_file("$curlcli") && is_executable("$curlcli")) {
          return("$curlcli");
          break;
      } else {
        return FALSE;
      }
    }
  }
}
// lol
if ($foundCurl = findCurlCli()) {
  $myurls = (isset($_REQUEST['urls'])?explode("\n", trim($_REQUEST['urls'])): array());
  foreach ($myurls as $url) {
    // escapeshellcmd is for pussies and communists.
    $data = system("$foundCurl -I $url | grep -v '404'");
      if ($data = "1") {
        echo "<font color='red'>404</font>: <a href='$url' target='_new'>[link]</a> $url<br>\n";
      }
    }
  }
}
?>
</body>
</html>


I now give you 4/5 -- only because you have now mixed view with logic. :)

pr0 05-22-2008 11:40 PM

Quote:

Originally Posted by GrouchyAdmin (Post 14226725)
bich i cut u

Code:

<html>
<head>
<Title>404 Test Thingy from hell</title>
</head>
<body bgcolor="#ffffff" text="#000000" link="#0000ff">
<br>
<form method="post">
  <div align="center"><strong>Test URLs:</strong><br>
      <textarea name="urls" id="urls" cols="45" rows="5"><?=isset($_REQUEST['urls'])?$_REQUEST['urls']:"";?></textarea>
    <br>
    <input type="submit" name="submit" id="submit" value="Check Response">
  </div>
</form>
<?php
// BE SAFE: WRAP YOUR CRAP!
if (!function_exists('findCurlCli')) {
  function findCurlCli() {
    $curlClis=array(
                  '/usr/bin/curl', '/usr/local/bin/curl',
                  '/usr/bin/curl-cli', '/usr/local/bin/curl-cli',
                  '/usr/bin/curlcli', '/usr/local/bin/curlcli',
                  '/usr/bin/curl-cli', '/usr/local/bin/curl-cli',
                  // FOR SOME REASON THIS DOESNT WORK!!!!!
                  // '/usr/bin/wget', '/usr/local/bin/wget'
                  );

    foreach ($curlClis as $curlcli) {
      if (@is_file("$curlcli") && is_executable("$curlcli")) {
          return("$curlcli");
          break;
      } else {
        return FALSE;
      }
    }
  }
}
// lol
if ($foundCurl = findCurlCli()) {
  $myurls = (isset($_REQUEST['urls'])?explode("\n", trim($_REQUEST['urls'])): array());
  foreach ($myurls as $url) {
    // escapeshellcmd is for pussies and communists.
    $data = system("$foundCurl -I $url | grep -v '404'");
      if ($data = "1") {
        echo "<font color='red'>404</font>: <a href='$url' target='_new'>[link]</a> $url<br>\n";
      }
    }
  }
}
?>
</body>
</html>


wait is this thing checking it the way i suggested for a certain text area?

GrouchyAdmin 05-22-2008 11:57 PM

Quote:

Originally Posted by pr0 (Post 14226788)
wait is this thing checking it the way i suggested for a certain text area?

Sure doesn't, but it can.. Just change the grep statement and remove the -I. That version was made as a (bigger) joke, though.

GrouchyAdmin 05-23-2008 12:13 AM

Code:

<html>
<head>
<Title>404 Test Thingy or whatever</title>
</head>
<body bgcolor="#ffffff" text="#000000" link="#0000ff">
<br>
<form method="post">
  <div align="center"><strong>Test URLs:</strong><br>
      <textarea name="urls" id="urls" cols="45" rows="5"><?=isset($_REQUEST['urls'])?$_REQUEST['urls']:"";?></textarea>
    <br>
    <input type="submit" name="submit" id="submit" value="Check Response">
  </div>
</form>
<?php
// This is hardly an example of good PHP.  Ugh.
@require_once("class.curl.php");
// trim() to get rid of errant enter keys.
$myurls = (isset($_REQUEST['urls'])?explode("\n", trim($_REQUEST['urls'])): array());
foreach ($myurls as $url) {
  // lame
  $search="";
  $breakshit = @explode("|", $url);
  if (!empty($breakshit["1"])) {
    $url = $breakshit["0"];
    $search = $breakshit["1"];
  }
  // use our cURL class.
  $curlInit = new curl($url);
  // Make sure we don't follow redirects.
  $curlInit->setopt(CURLOPT_FOLLOWLOCATION, FALSE) ;
  $curlInit->setopt(CURLOPT_RETURNTRANSFER, TRUE) ;
  // Do it.
  $return = $curlInit->exec();
  // If we returned a connection error, say so.
  if ($myError = $curlInit->hasError()) {
    echo "ERR: $url ($myError)<br>\n";
  } else {
    // Reinit our array
    if (!eregi($search, $return)) {
          echo "<font color='red'>Did not find &quot;".$search."&quot;</font>: <a href='$url' target='_new'>[link]</a> $url<br>\n";
    }
  }
  // We're done, close the socket.
  $curlInit->close();
}
?>
</body>
</html>

This one lets you search for a specific word in the full text of the html. It uses eregi rather than preg, because I hate perl's regex.

Format:
http://site.com/|searchterm

If searchterm is empty, it doesn't fall back to 404. I don't feel like actually turning this pile of shit code into something worthwhile. I'm not bored anymore. :)

Mr Pheer 05-23-2008 12:40 AM

next time I think I'll just make a thread called, spam me with your PHP code...

:)

pr0 05-23-2008 12:46 AM

Quote:

Originally Posted by Mr Pheer (Post 14226895)
next time I think I'll just make a thread called, spam me with your PHP code...

:)

na that only works at 4am when programmers are still up & trying anything they can to get sleepy...like right now

k0nr4d 05-23-2008 12:51 AM

i dont feel like reading through all this, but are we having another one of those contests to see who can do this more inefficiently again?

Iron Fist 05-23-2008 12:59 AM

Quote:

Originally Posted by k0nr4d (Post 14226915)
i dont feel like reading through all this, but are we having another one of those contests to see who can do this more inefficiently again?

:1orglaugh:1orglaugh:1orglaugh

GrouchyAdmin 05-23-2008 01:26 AM

Quote:

Originally Posted by k0nr4d (Post 14226915)
i dont feel like reading through all this, but are we having another one of those contests to see who can do this more inefficiently again?

That bitch Kris didn't play along so I gave up.

mrkris 05-23-2008 07:39 AM

Quote:

Originally Posted by GrouchyAdmin (Post 14226979)
That bitch Kris didn't play along so I gave up.

sorry, I fell asleep haha

gornyhuy 05-23-2008 07:52 AM

Quote:

Originally Posted by Mr Pheer (Post 14226895)
next time I think I'll just make a thread called, spam me with your PHP code...

:)

This is super rare for a tech or biz thread to be not only answered but hit with multiple versions of working code and even upgrades by request. Crazy shit.:thumbsup

Bro Media - BANNED FOR LIFE 05-23-2008 03:11 PM

damn shush grouchy i just did it in a 5 mins i was tired, it worked on my dev server

GrouchyAdmin 05-23-2008 03:39 PM

Quote:

Originally Posted by mrkris (Post 14227559)
sorry, I fell asleep haha

It's no fun playing in the kiddy pool. Bitch.

mrkris 05-23-2008 04:02 PM

Quote:

Originally Posted by GrouchyAdmin (Post 14229824)
It's no fun playing in the kiddy pool. Bitch.

:1orglaugh:1orglaugh:1orglaugh

pornpf69 05-23-2008 05:40 PM

some interesting scripts around here...


All times are GMT -7. The time now is 12:32 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123