Reply
Relevant for everyone : simplifying a daunting task.
Old 01-29-2005, 05:54 AM Relevant for everyone : simplifying a daunting task.
fambi's Avatar
Ultra Talker

Posts: 339
Hi everyone.

I am about to write a script that checks the validity of my link-partners links.

I recently went through a list of sites that i had swapped links with, but discovered that most of them had bad intentions and used me to obtain one way links.

For everyone's benefit, these are some of the unethical methods they used:

1. They used redirects.
2. They used redirects and used js to make the status bar show an anchor tag style url.
3. They used the rel="nofollow" tag.
4. They put the anchor tag properly, but commented it out so it still got seen by a page reader but not acknoledged by the search engines.
5. They didn't include the link at all.
6. They fed the search engines (using the SE's well-known IP addresses) one thing and fed us something else.

Well the only punishment i could think of was to remove their links altogether.

Nevertheless, i want to write a script that checks all of these things whenever i add a link and i also want to use a cronjob to run that script on a regular basis.

So what would i like from the masters at wemasters-talk:

a. Any suggestions with regards to detecting 1-6.
b. Enlightenment with regards to other sneaky methods that haven't been listed above.
c. Most importantly, a method of scrambling my ip address in php, because the script will be run as a cron and i don't want cheaters to realise that it is me and therefore us my ip to cheat me?
__________________
Sending sms from a website or application is easy!
Read this great tutorial that uses our bulk sms gateway.

Last edited by fambi : 01-29-2005 at 05:54 AM. Reason: improvement
fambi is offline
Reply With Quote
View Public Profile Visit fambi's homepage!
 
When You Register, These Ads Go Away!
     
Old 01-29-2005, 10:46 AM
Republikin's Avatar
Super Moderator

Posts: 3,191
I have created something similiar in the past using Snoopy. Perhaps that will be of some help to you.
Republikin is offline
Reply With Quote
View Public Profile
 
Old 01-29-2005, 10:51 AM
fambi's Avatar
Ultra Talker

Posts: 339
Your 'something similar' would be even more useful.

Just joking!!!

I have already downloaded snoopy but i don't know how to unzip the tar.gz file!

How do i go about that?

How about a-c???
__________________
Sending sms from a website or application is easy!
Read this great tutorial that uses our bulk sms gateway.
fambi is offline
Reply With Quote
View Public Profile Visit fambi's homepage!
 
Old 01-29-2005, 11:14 AM
Republikin's Avatar
Super Moderator

Posts: 3,191
Winzip will extract it.

I built it into osCommerce so there will be alot of unnecesary stuff in here but here ya go, you can sift through it.

Link display and sign up form.
PHP Code:
<?php
/*
  $Id: privacy.php,v 1.21 2003/02/13 04:23:23 hpdl Exp $

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2003 osCommerce

  Released under the GNU General Public License
*/

  
require('includes/application_top.php');

  require(
DIR_WS_LANGUAGES $language '/' 'links.php');

  
$breadcrumb->add(NAVBAR_TITLEtep_href_link('links.php'));
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <?php
// BOF: WebMakers.com Changed: Header Tag Controller v1.0
// Replaced by header_tags.php
if ( file_exists(DIR_WS_INCLUDES 'header_tags.php') ) {
  require(
DIR_WS_INCLUDES 'header_tags.php');
} else {
?>
  <title><?php echo TITLE ?></title>
<?php
}
// EOF: WebMakers.com Changed: Header Tag Controller v1.0
?>
    <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
    <base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER HTTP_SERVER) . DIR_WS_CATALOG?>">
    <link rel="stylesheet" href="skin/css.css" type="text/css" />
</head>
<body>
<?php require(DIR_WS_INCLUDES 'header.php'); ?>

<!-- 3COL|BGN -->
<table cellspacing="0" cellpadding="0" width="100%">
    <tr>
        <td width="177" height="26"><img src="skin/locate-left-curve.gif" width="177" height="26" border="0" alt="LightAudio" /></td>
        <td height="26" style="background-image: url(skin/locate-shadow.gif);"><img src="skin/pix.gif" width="1" height="1" border="0" alt="LightAudio" /></td>
        <td width="177" height="26"><img src="skin/locate-shadow-right.gif" width="177" height="26" border="0" alt="LightAudio" /></td>
    </tr>

    <tr>
        <td class="left" valign="top">
        <!-- NAV|BGN -->
             <?php require(DIR_WS_INCLUDES 'column_left.php'); ?>
        <!-- NAV|END -->
        </td>

        <!-- CONTENT|BGN -->
    <td width="100%" class="middle" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">
      <tr>
        <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
            <td><center><font size="4">The LightAudio.com Car Club Link Page</font><br />
            <a href="links.php#signup">Add your club to the list.</a></center></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif''100%''10'); ?></td>
      </tr>
      <tr>
        <td><br><table border="0" width="100%" cellspacing="0" cellpadding="2">
          <tr>
            <td class="main">
<!-- BGN|LINK DISPLAY -->
<?php
/* BGN|INCLUDES */
include "link_mysql.php";
/* END|INCLUDES */

$list mysql_query("SELECT url,name,description,status FROM links",$link);

while(
$data mysql_fetch_assoc($list))
{
if (
$data["status"]==1)
{
echo 
"<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
echo 
"<tr>";
printf("<td align=\"left\" class=\"strip\"><a href=\"%s\" target=\"blank\">%s</a></td>",$data["url"],stripslashes($data["name"]));
echo   
"<td align=\"right\" class=\"strip\"><a href=\"contact_us.php\" target=\"blank\">Report Link</a></td>";
echo 
"</tr>";
echo 
"<tr>";
printf("<td colspan=\"2\" class=\"tanback\">%s</td>",stripslashes($data["description"]));
echo 
"</tr>";
echo 
"</table>";
echo 
"<hr>";
}
}
mysql_free_result($list);
?>
<!-- END|LINK DISPLAY -->
<br /><br />
<!-- BGN|SIGNUP FORM -->
<form name="form1" method="post" action="link_engine.php">
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td class="strip" colspan="2">Car Club Links Page Sign Up</td>
    </tr>
    <tr valign="top">
      <td class="tanback" width="23%"> <div align="right"><strong>Name of Club&nbsp;</strong></div></td>
      <td class="tanback" width="77%"> <input name="name" type="text" id="name" size="40"></td>
    </tr>
    <tr valign="top">
      <td class="tanback"><div align="right"><strong>Email&nbsp;</strong></div></td>
      <td class="tanback"><input name="email" type="text" id="email" size="40"></td>
    </tr>
    <tr valign="top">
      <td class="tanback"><div align="right"><strong>Notify&nbsp;</strong></div>
        <div align="right"></div></td>
      <td class="tanback"> <p>
          <input name="notify" type="checkbox" id="notify" value="yes" checked>
          <br>
          Do you want to be notified of the status of your link, like when it
          rolls off the list or if it becomes inactive due to a bad reciprocal
          link? (This is a good idea)</p></td>
    </tr>
    <tr valign="top">
      <td class="tanback"><div align="right"><strong>URL&nbsp;</strong></div></td>
      <td class="tanback"><input name="url" type="text" id="url" value="http://" size="40"></td>
    </tr>
    <tr valign="top">
      <td class="tanback"> <div align="right"><strong> Description&nbsp;</strong></div></td>
      <td class="tanback"> <textarea name="description" cols="35" rows="7" id="description"></textarea></td>
    </tr>
    <tr valign="top">
      <td class="tanback"><div align="right"><strong>Rules&nbsp;</strong></div></td>
      <td class="tanback"><p>1.) You may have only one link at a time on the list.<br>
          2.) You must reciprocate with a link on the page that you list.<br>
          3.) Descriptions may be no more than 60 words.<br><br>
        </p>
        </td>
    </tr>
    <tr valign="top">
      <td class="tanback">
        <div align="right"><strong>Info&nbsp;</strong></div></td>
      <td class="tanback">
<p>Links will roll off the list one month from the time
          they are listed. Also all links are subject to our approval before they
          show up on the list. &nbsp;</p>
        </p>
        <p>
          <input type="submit" name="Submit" value="Submit">
          <input type="reset" name="Submit2" value="Reset">
        </p>
        <p>&nbsp; </p></td>
    </tr>
  </table>
</form>
<!-- END|SIGNUP FORM -->
</td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td align="right" class="main"><br><?php/* echo '<a href="' . tep_href_link(FILENAME_DEFAULT) . '">' . tep_image_button('button_continue.gif', IMAGE_BUTTON_CONTINUE) . '</a>'; */?></td>
      </tr>
    </table></td>
        <!-- CONTENT|END -->

        <td class="left" valign="top">
        <!-- RIGHT|BGN -->
             <?php require(DIR_WS_INCLUDES 'column_right.php'); ?>
        <!-- RIGHT|END -->
        </td>
    </tr>
</table>
<!-- 3COL|END -->
<?php require(DIR_WS_INCLUDES 'footer.php'); ?>
<?php 
require(DIR_WS_INCLUDES 'application_bottom.php'); ?>
Submit form processing.
PHP Code:
<?php
/* BGN|INCLUDES */
include "Snoopy.class.php";
/* END|INCLUDES */

/* BGN|VARS */
$redirect  "links.php";
$name htmlspecialchars(addslashes($_POST['name']));
$url htmlspecialchars(addslashes($_POST['url']));
$desc htmlspecialchars(addslashes($_POST['description']));
$email htmlspecialchars(addslashes($_POST['email']));
$notify $_POST['notify'];
$ip $_SERVER['REMOTE_ADDR'];
$datetime date("Y-m-d H:i:s");
/* END|VARS */

/* BGN|DESC CHECK */
if (str_word_count($desc) >= 61)
{
echo 
"Your description is greater than 60 words. Please fix and resubmit.";
exit;
}
/* END|DESC CHECK */

/* BGN|REQ LINK CHECK */
$link = new Snoopy;
$link->fetchlinks($_POST['url']);

    if (!
in_array("http://www.lightaudio.com",$link->results))
        {
            echo 
"You must put a link to http://www.lightaudio.com in the page that you want to list. Please go back and read the directions carefully
                  <a href=\"links.php\">Go Back</a>"
;
            exit;
        }else{
/* END|REQ LINK CHECK */

/* BGN|MYSQL CONN */
$link mysql_connect('localhost','root','') or die(mysql_error());
mysql_select_db('toplist',$link) or die(mysql_error());
/* END|MYSQL CONN */

/* BGN|QUERY AND CHECK */
$url_query mysql_query("SELECT * FROM links WHERE url='$url'");
$check_url mysql_num_rows($url_query);
if (
$url_query==FALSE)
{
exit;
}
if (
$check_url>=1)
{
echo 
"Hey, NO CHEATERS. That website is already listed.<br />";
echo 
"<a href=\"http://www.lightaudio.com/links.php\">Click here to go back to the links page.</a>";
}else{
if (
$notify)
{
$notify "yes";
}else{
$notify "no";
}
/* END|QUERY AND CHECK */

/* BGN|INSERT RECORDS */
$insert "INSERT INTO links (name,url,email,notify,description,ip,datetime) VALUES ('$name','$url','$email','$notify','$desc','$ip','$datetime')";
mysql_query($insert,$link) or die(mysql_error());
/* END|INSERT RECORDS */

/* REDIRECT */
header("Location: $redirect");

/* END|LAST ELSE STATEMENT */
}
}
?>
This is what I used to validate email addresses.
PHP Code:
<?php

include "link_mysql.php";
include 
"Snoopy.class.php";
$req_id $_GET['id'];
$req_email $_GET['e'];
$req_url $_GET['u'];


    
$sql "SELECT * FROM links WHERE id='$req_id'";
    
$query mysql_query($sql);
    
$query_arr mysql_fetch_assoc($query);
    
$num_rows mysql_num_rows($query);

    if (
$num_rows 1)
        {
            
header("Location: links.php");
            exit;
        }else{
                if (
$query_arr['email'] == $req_email || $query_arr['url'] == $req_url || $query_arr['id'] == $req_id)
                    {
            
$url $query_arr['url'];
            
$s = new Snoopy;
            
$s->fetchlinks($url);

                if (!
in_array("http://www.lightaudio.com",$s->results))
                    {
                    print 
"Try putting the link on your page first. Then come back here and try again.";
                    exit;
                }else{
                    
$sql2 "UPDATE links SET status = 1 LIMIT 1";
                    
mysql_query($sql2);
                    
header("Location: links.php");
                    }
                    }

        }
mysql_free_result($sql);
mysql_free_result($sql2);
?>
This is my link pruning script that I would run with a cron job.
PHP Code:
<?php

$date_message 
"<html><body>This notice has been automatically generated to inform you that your link on <a href=\"http://www.lightaudio.com/links.php\">LightAudio.com</a> has passed the expiration date.<br /><br />
                 Expiration dates are set for your benefit. This allows you to go back and put your link at the top of the list.
                 To add your link to the list again simply goto <a href=\"http://www.lightaudio.com/links.php\">The LightAudio.com Car Club Link Page</a>.<br /><br />
                 Signed,<br />
                 Tim Smith<br />
                 tim@lightaudio.com<br /><br /><br /><br />
                 You are recieving this message because you opted to be notified when your link rolled off the list. To not be included in future mailings make sure not to check the option box when you add your club to the list.
                 If you do not plan on adding your club to the list again then do nothing and you will hear from us no more.</body></html>"
;

include 
"link_header.php";
$link_months 1// How long the link will remain in the database in months.
$link_days 0// How long the link will remain in the database in days.
$link_min 0// For testing this function only.
$link_hour 0// For testing this function only.
$minus mktime(date("H")-$link_hour,date("i")-$link_min,date("s"),date("m")-$link_months,date("d")-$link_days,date("Y"));
$timestamp date("Y-m-d H:i:s"$minus);

$sql "SELECT * FROM links WHERE datetime <= '$timestamp'";
$date_check mysql_query($sql,$link) or die("Query Error on Update<br />" mysql_error());
while (
$data mysql_fetch_assoc($date_check))
{
    if (
$data['status'] == 1)
    {
    
$id $data['id'];
        
mysql_query("DELETE FROM links Where id = '$id' LIMIT 1");

/* echo "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"3\">";
echo  "<tr>";
echo    "<td width=\"16%\" bgcolor=\"#000099\"><div align=\"right\"><strong><font color=\"#FFFFFF\">Name</font></strong></div></td>";
printf ("<td width=\"84\" bgcolor=\"#000000\"><font color=\"#FFFFFF\"><a href=\"%s\">%s</a></font></td>",$data['url'],$data['name']);
echo  "</tr>";
echo  "<tr>";
echo    "<td bgcolor=\"#000099\"><div align=\"right\"><strong><font color=\"#FFFFFF\">Email</font></strong></div></td>";
printf ("<td bgcolor=\"#000000\"><font color=\"#FFFFFF\"><a href=\"mailto:%s\">%s</a></font></td>",$data['email'],$data['email']);
echo  "</tr>";
echo  "<tr>";
echo    "<td bgcolor=\"#000099\"><div align=\"right\"><strong><font color=\"#FFFFFF\">Status</font></strong></div></td>";
printf ("<td bgcolor=\"#000000\"><font color=\"#FFFFFF\">%s</font></td>",$data['status']);
echo  "</tr>";
echo "</table>"; */

    
if ($data['notify'] == "yes")
        {
            
$email $data['email'];
            
$name stripslashes($data['name']);
            
mail("$email""Link to $name Expired on LightAudio.com"$date_message,
             
"MIME-Version: 1.0\r\n"
            
."Content-type: text/html; charset=iso-8859-1\r\n"
            
."From: admin@lightaudio.com\r\n"
               
."Reply-To: admin@lightaudio.com\r\n"
               
."X-Mailer: PHP/" phpversion());
        }

    }
}
?>

I left out some things, like the link admin section wich was really just about approving, editing or deleting links. As you can see as well this was not very efficient or good coding. It was one of my first projects while learning php.

Have fun breaking that apart though.
Republikin is offline
Reply With Quote
View Public Profile
 
Old 01-29-2005, 12:52 PM
fambi's Avatar
Ultra Talker

Posts: 339
Thanks for the help. But my winzip won't unzip snoopy.
__________________
Sending sms from a website or application is easy!
Read this great tutorial that uses our bulk sms gateway.
fambi is offline
Reply With Quote
View Public Profile Visit fambi's homepage!
 
Old 01-29-2005, 12:55 PM
foobar's Avatar
Extreme Talker

Posts: 225
Try using WinRAR. WinRAR rules.
foobar is offline
Reply With Quote
View Public Profile Visit foobar's homepage!
 
Old 01-29-2005, 12:56 PM
fambi's Avatar
Ultra Talker

Posts: 339
How do i go about that? WHere can i find it?
__________________
Sending sms from a website or application is easy!
Read this great tutorial that uses our bulk sms gateway.
fambi is offline
Reply With Quote
View Public Profile Visit fambi's homepage!
 
Old 01-29-2005, 01:27 PM
Christopher's Avatar
Iced Cap

Latest Blog Post:
PHP and Unicode with UTF-8
Posts: 3,108
Location: Toronto, Ontario
http://www.rarlabs.com/
Christopher is offline
Reply With Quote
View Public Profile Visit Christopher's homepage!
 
Old 01-29-2005, 03:41 PM
Republikin's Avatar
Super Moderator

Posts: 3,191
Yeah, that was going to be my next suggestion.
Republikin is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Relevant for everyone : simplifying a daunting task.