We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 27305
    • 173 Posts
    Does anyone know if there is a reciprocal link add on for modx? I’m thinking of something that would or could check to see if someone has added a link and if they havent then their link gets removed from your directory?

    Anyone?

    cheers

    ss
      I made my first site with modx
      ------------------------
      Shopping blog
      Sky+ HD
      • 27376
      • 576 Posts
      Quote from: simonok at Mar 10, 2007, 09:41 AM

      I’m thinking of something that would or could check to see if someone has added a link and if they havent then their link gets removed from your directory?
      Added a link to what? Could you be more specific?
        • 28676
        • 136 Posts
        A plug in or module that would basically be a link directory. When someone requests a link in your directory they complete a form with all the information that they would like in your directory. They also have to add a link back to your website. some people remove the link that they added after a week or so, or forget to add it at all.

        It would be nice to automate this, so if a reciprocal link is missing it would tell you or just remove their link from your directory.

        you digg?
          I made my first site with modx
          ------------------------
          http://www.shop-bright.com | Uk shopping blog
          • 34127
          • 135 Posts
          This actually sounds pretty interesting and I was thinking about setting up such a directory for my own site. Couldn’t one just use cURL (or fopen) to grab the page, read it line by line and use a regular expression to match a link to your site? Perhaps something like this could work (sorry if it doesn’t it’s still early here but I need to find something to do tongue :

          <?php
          
          //change "your_link_database_table" to your actual table's name.
          $result = $modx->db->select( '*', 'your_link_database_table', '', '', '' ); 
          //your site's url - this is what you're checking for on each affiliate's page.
          $your_url = ''; 
          $output = '';
          
          
          while( $row = $modx->db->getRow( $result ) ) {
          	//this of course assumes that the field in your database is named "link"
          	if( link_checker( $your_url, $row['link'] ) ) {
          		$output .= '<span style="color:green">A link to your site appears on ' . $row['link'] . '.</span>';
          	}
          	else
          		$output .= '<span style="color:red">A link to your site does not appear on ' . $row['link'] . '.</span>';
          }
          
          function link_checker( $your_url, $check_url ) {
          	$match = false;
          	if( $handle = @fopen( $check_url, "r" ) ) {
          		while( !feof( $handle ) ) {
          			$line = fread( $handle, 1024 );
          			if( preg_match( '|<a\s+href\s*=\s*"'.$your_url.'[^>]+>(.*?)</a>|', $line ) ) {
          				$match = true;
          				break;
          			}
          		}
          		fclose( $handle );
          	}
          	return $match;
          }
          
          ?>


          Make a new snippet, paste that code in there and call it (uncached) on a modx document. It *should* work and do what you’d like. You of course need to create a database table for your affiliate links and populate it with data. I’ve added a couple comments to help you out with what needs to be changed. Also, this is very basic. If anyone’s even remotely interested in it I could expand on it to allow for users’ input on the URL to check, which sites to check for links on and stuff like that. smiley

          EDIT: Are you looking for an entire link exchange addon, or just the link checker? I came up with the link checker this morning and realized that you probably wanted a link exchange module too afterwards.
            • 1932
            • 137 Posts
            You might have luck using the FavoriteLinks snippet + module; the links in the database could then be accessed and checked using Eleventeen’s code above.

            .. Just a thought.