Go Back   PHP Link Directory Forum > PHP Link Directory (phpLD) > Mods and contribution Discussion

Mods and contribution Discussion This forum is only for discussion of modding phpLD. For specific mod releases, please see the appropriate forum.

Closed Thread
 
Thread Tools Display Modes
Old 03-13-2006   #1
Boby
Supporter
Moderator
 
Boby's Avatar
 
Join Date: Dec 2005
Location: Cluj-Napoca/Sighisoara (Romania)
Posts: 4,468
Exclamation [MOD] Three Way Linking

There was a request for a three-way-linking mod.
Submitters will no more link to your directory, instead they will have to link to a third site. (Reciprocal)

This mod is for phpLD2, because the new phpLD 3.0.3 has this feature out-of-box.

Edit "admin/init.php" and find following code (lines 323-335):
Code:
 		array('ID' => 'VISUAL_CONFIRM',
			  'NAME' => _L('Visual confirmation'),
			  'DESCRIPTION' => _L('Display antispam visual confirmation code on link submit page.'),
			  'CONFIG_GROUP' => '3',
			  'TYPE' => 'LOG',
			  'REQUIRED' => '1'),
 		array('ID' => 'REQUIRE_RECIPROCAL',
			  'NAME' => _L('Require reciprocal link'),
			  'DESCRIPTION' => _L('Require reciprocal link on link submit page.'),
			  'CONFIG_GROUP' => '3',
			  'TYPE' => 'LOG',
			  'REQUIRED' => '1'),
Insert this right after:
Code:
      array('ID' => 'ENABLE_THREE_WAY',
           'NAME' => _L('Enable three-way-linking'),
           'DESCRIPTION' => _L('Submitters will have to link to a third site instead of this one.'),
           'CONFIG_GROUP' => '3',
           'TYPE' => 'LOG',
           'REQUIRED' => '0'),
      array('ID' => 'THREE_WAY_LINK_URL',
           'NAME' => _L('Three-way-link URL'),
           'DESCRIPTION' => _L('The URL of the site where submitters have to link.'),
           'CONFIG_GROUP' => '3',
           'TYPE' => 'STR',
           'REQUIRED' => '0'),
      array('ID' => 'THREE_WAY_LINK_TITLE',
           'NAME' => _L('Three-way-link Title'),
           'DESCRIPTION' => _L('The title of the site where submitters have to link.'),
           'CONFIG_GROUP' => '3',
           'TYPE' => 'STR',
           'REQUIRED' => '0'),
Now you have to edit "include/tables.php" and search for:
Code:
		# Pager Mod
		array('ID' => 'PAGER_LPP', 'VALUE' => '20'),
		# ID Mod
		array('ID' => 'ENABLE_ID', 'VALUE' => '1'),
		# Links open in blank window
		array('ID' => 'ENABLE_BLANK', 'VALUE' => '0'),
Put next code right above it:
Code:
      # Three way linking
      array('ID' => 'ENABLE_THREE_WAY', 'VALUE' => '0'),
      array('ID' => 'THREE_WAY_LINK_URL', 'VALUE' => 'http://www.third-site.com/'),
      array('ID' => 'THREE_WAY_LINK_TITLE', 'VALUE' => 'Third-Site'),
Edit "include/functions.php" and search for the for the first function:
Code:
function read_config($db) {
	global $tables, $tpl;
	$sql = "SELECT * FROM {$tables['config']['name']}";
	$db->SetFetchMode(ADODB_FETCH_ASSOC);
	$rs = $db->Execute($sql);
	while (!$rs->EOF) {
		define($rs->Fields('ID'), $rs->Fields('VALUE'));
		$rs->MoveNext();
	}
}
Replace it with this code:
Code:
function read_config($db) {
	global $tables, $tpl;
	$sql = "SELECT * FROM {$tables['config']['name']}";
	$db->SetFetchMode(ADODB_FETCH_ASSOC);
	$rs = $db->Execute($sql);
	while (!$rs->EOF) {
		define($rs->Fields('ID'), $rs->Fields('VALUE'));
		$rs->MoveNext();
	}
   set_default_recpr();
}

function set_default_recpr() {
   $default_recpr_link_url   = (ENABLE_THREE_WAY == 1 ? THREE_WAY_LINK_URL   : SITE_URL);
   $default_recpr_link_title = (ENABLE_THREE_WAY == 1 ? THREE_WAY_LINK_TITLE : SITE_NAME);
   define('DEFAULT_RECPR_URL',   $default_recpr_link_url);
   define('DEFAULT_RECPR_TITLE', $default_recpr_link_title);
}
Same file (include/functions.php), search for:
Code:
function validate_recpr_link($value, $empty, & $params, & $form) {
	global $tpl;
	if ($empty && empty ($value))
		return 1;
	$ret = check_recpr_link($form);
	if ($ret == -1) {
		$tpl->assign('RECPR_ERROR', _L("The URL could not be validated. Either the page does not exist or the server could not be contacted."));
		return 0;
	}
	if ($ret == 0) {
		$tmp = _L("A link to #SITE_URL# could not be found at the specified URL.");
		$tmp = str_replace('#SITE_URL#', SITE_URL, $tmp);
		$tpl->assign('RECPR_ERROR', $tmp);
		return 0;
	}
	return 1;
}

function check_recpr_link($data) {
	if (!trim($data['RECPR_URL']))
		return -1;
	$ret = get_url($data['RECPR_URL'], URL_CONTENT);
	if (!$ret['status']) {
		return -1;
	}
	if (empty ($data['RECPR_ID'])) { //Old validation method (until RC3)
		return (preg_match("`<a.*href=(\"|')?".SITE_URL."/?(\"|')?.*>`Ui", $ret['content']) && !preg_match("`<a.*href=(\"|')?".SITE_URL."/?(\"|')?.*rel\s*=\s*(\"|')nofollow(\"|').*>`Ui", $ret['content'])) == 0 ? 0 : 1;
	} else { //New validation method
		$valid = 0;
		$rid = sprintf('R%X', $data['RECPR_ID']);
		if (preg_match("`<a(.*href=(\"|')".SITE_URL."/?(\"|').*)>(.*)</a>`Ui", $ret['content'], $m)) {
			error_log(sprint_r($m));
			if (preg_match("`id=(\"|')".$rid."(\"|')`i", $m[1]) && !preg_match("`rel\s*=\s*(\"|')?\s*nofollow\s*(\"|')?`i", $m[1])) {
				$valid = 1;
			}
		}
		return $valid;
	}
}
Replace with:
Code:
function validate_recpr_link($value, $empty, & $params, & $form) {
	global $tpl;
	if ($empty && empty ($value))
		return 1;
	$ret = check_recpr_link($form);
	if ($ret == -1) {
		$tpl->assign('RECPR_ERROR', _L("The URL could not be validated. Either the page does not exist or the server could not be contacted."));
		return 0;
	}
	if ($ret == 0) {
		$tmp = _L("A link to #SITE_URL# could not be found at the specified URL.");
		$tmp = str_replace('#SITE_URL#', DEFAULT_RECPR_URL, $tmp);
		$tpl->assign('RECPR_ERROR', $tmp);
		return 0;
	}
	return 1;
}

function check_recpr_link($data) {
	if (!trim($data['RECPR_URL']))
		return -1;
	$ret = get_url($data['RECPR_URL'], URL_CONTENT);
	if (!$ret['status']) {
		return -1;
	}
	if (empty ($data['RECPR_ID'])) { //Old validation method (until RC3)
		return (preg_match("`<a.*href=(\"|')?".DEFAULT_RECPR_URL."/?(\"|')?.*>`Ui", $ret['content']) && !preg_match("`<a.*href=(\"|')?".DEFAULT_RECPR_URL."/?(\"|')?.*rel\s*=\s*(\"|')nofollow(\"|').*>`Ui", $ret['content'])) == 0 ? 0 : 1;
	} else { //New validation method
		$valid = 0;
		$rid = sprintf('R%X', $data['RECPR_ID']);
		if (preg_match("`<a(.*href=(\"|')".DEFAULT_RECPR_URL."/?(\"|').*)>(.*)</a>`Ui", $ret['content'], $m)) {
			error_log(sprint_r($m));
			if (preg_match("`id=(\"|')".$rid."(\"|')`i", $m[1]) && !preg_match("`rel\s*=\s*(\"|')?\s*nofollow\s*(\"|')?`i", $m[1])) {
				$valid = 1;
			}
		}
		return $valid;
	}
}
And now the last file to change, "tamplates/submit.tpl", search for:
Code:
<textarea name="RECPR_TEXT" rows="2" readonly="readonly" cols="37" class="text">&lt;a href="{$smarty.const.DEFAULT_RECPR_URL}"{if $smarty.const.ENABLE_ID} id="R{$recpr_id|string_format:"%X"}"{/if}&gt;{$smarty.const.DEFAULT_RECPR_TITLE}&lt;/a&gt;</textarea>
Replace with:
Code:
<textarea name="RECPR_TEXT" rows="2" readonly="true" cols="37" class="text">&lt;a href="{$smarty.const.DEFAULT_RECPR_URL}"{if $smarty.const.ENABLE_ID} id="R{$recpr_id|string_format:"%X"}"{/if}&gt;{$smarty.const.DEFAULT_RECPR_TITLE}&lt;/a&gt;</textarea>
If you don't want to go through the update script, you can run a SQL query in phpMyAdmin or something else to insert 3 configuration rows to your database.
This is the needed SQL query:
Code:
INSERT INTO `PLD_CONFIG` (`ID`, `VALUE`) VALUES ('ENABLE_THREE_WAY', '0');
INSERT INTO `PLD_CONFIG` (`ID`, `VALUE`) VALUES ('THREE_WAY_LINK_URL', 'http://www.third-site.com/');
INSERT INTO `PLD_CONFIG` (`ID`, `VALUE`) VALUES ('THREE_WAY_LINK_TITLE', 'Third-Site');
PLD_CONFIG is the default configuration table, if you are using other prefix than "PLD_" please change it in your query.


That's all, you can enable now this feature and change settings in your admin panel by going:
System >> Edit Settings >> Link Submit

Good Luck!
Boby

Later Edit:
I have also uploaded an archive with the files and needed changes and put also a sql file with the query. You can download it from attachment.
__________________
wanna say thank you?
  • My phpLD Mods
  • I am *not* a phpLD staff member, so please do *not* ask me to grant permissions, sales stuff, for access to the private supporter forums or phpLD 3.0+ download area.
  • Before you report your problems, make sure it happens with the *default* package and not your highly modified code. Don't forget to use the search feature and do not *bump* threads to soon (allow at least 24h).
Boby is offline  
Old 03-13-2006   #2
insidedesign
Supporter
 
Join Date: Dec 2005
Location: Asheville, NC
Posts: 112
Default

Your welcome everyone

Thanks for your work Boby
insidedesign is offline  
Old 03-13-2006   #3
anon
Supporter
 
anon's Avatar
 
Join Date: Feb 2006
Location: As far from you as humanly possible!
Posts: 2,893
Send a message via Yahoo to anon
Default

insidedesign

thank you

you too boby
anon is offline  
Old 11-15-2006   #4
euwebdirectory
Supporter
 
Join Date: Mar 2006
Location: Spain
Posts: 75
Default backlink to same category

Hi.

I want to make the backlink, no to a third party site, i want to make it to the same category that somebody submit your site.

It´s possible? and the best, what´s the code .. :P

Thx a lot.
euwebdirectory is offline  
Old 12-22-2006   #5
sofie77
 
Join Date: Jul 2005
Posts: 77
Default

Hi boby

is it possible to rewrite this mod, that its possible to add more Linking URLs instead of only 1? i would like to have the option to offer the customer more Reciprocal URLs of my project.

I am for sure willing to pay. please tell me your price!

tx for help!
sofie77 is offline  
Old 05-14-2007   #6
webguide
 
Join Date: Apr 2007
Posts: 16
Default Dont work

It doesnt work, the recirpocal isnt updated in the submit.php script.
The db have the rigth information.

Is there an easy way to ad different reciprocals to different submits?

Last edited by David; 08-18-2009 at 12:03 AM. Reason: Spelling
webguide is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Change reciprocal html link to test on linking parter's site kcook Support (Version 2) 0 05-19-2006 12:57 AM
Buttons for Linking to phpLD vegabond Design 4 03-20-2006 10:07 PM
Buttons for Linking to phpLD here ing Design 1 03-19-2006 02:19 AM
Linking from one page to the link submit page of a category 5websearch Design 9 12-04-2005 07:53 AM


All times are GMT +1. The time now is 02:56 PM.


Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.