April 25th, 2007phpld Image Uploader MOD

With this modification you can allow users to upload a profile image that will be placed in their details page.

1. Create a folder called uploads in the same folder as submit.php (root of the directory)
2. chmod 777 uploads
3. create a file image_upload.php in the same folder as submit.php, with the content below:

<?php 

$error=$_FILES["IMAGE"]["error"];
if ($error == UPLOAD_ERR_OK) {
 $parsed = parse_url($_POST["URL"]);
 $image_domain = $parsed['host'];
 $image_type=$_FILES['IMAGE']['type'];
 $image_loc="uploads/".$image_domain.".jpg";
 $tmp_name = $_FILES["IMAGE"]["tmp_name"];
  if ($image_type =="image/pjpeg" ||
      $image_type =="image/jpeg" ||
      $image_type=="image/gif"    ||
      $image_type=="image/png"){ 
    move_uploaded_file($tmp_name, $image_loc);
  }	
}

?>

4. in submit.php,
AFTER: require_once 'init.php';
ADD: require_once "image_upload.php";

5. in submit.tpl

FIND :

<form action="" method="post">

REPLACE BY:

<form action="" method="post"
          enctype="multipart/form-data">

FIND:

<td class="field">
      {* Load category selection *}
      {include file="category_select.tpl"}
   </td>
   </tr>

AFTER it, ADD:

<tr>
 <td class="label">Image</td>
 <td class="field">
  <input type="file" name="IMAGE" />
 </td>
</tr>

7. in detail.tpl, where you want the image to appear.
ADD:

{php}
$uploads_path="/path/to/uploads/";
$parsed = parse_url($this->_tpl_vars[URL]);
$image_domain = $parsed['host'];
$abs_image_loc = $uploads_path.$image_domain.".jpg";
$image_loc = "../uploads/".$image_domain.".jpg";
if (file_exists($abs_image_loc)) {
  echo "<img src=\"" . $image_loc . "\" />";
}
{/php}

EDIT : $uploads_path=”/path/to/uploads/”;
in the code above to something to the absolute path
to your uploads folder something like
“/home/domain/public_html/uploads/”

That’s it.
The mod can be improved by adding small test on the image size and dimensions.

Install the phpld deeplinks mod before applying the modification below.

To validate the additional deeplinks you will have to add the following:

First in submit.php
AFTER:

SmartyValidate :: register_validator('v_URL',
'URL','isURL', false, false, 'trim', 'submit_link');

ADD:

SmartyValidate :: register_validator('v_URL1',
 'URL1','isURL',true,false,'trim','submit_link');
SmartyValidate :: register_validator('v_URL1_ONLINE',
 'URL1','isURLOnline',true,false,null,'submit_link');

FINALLY in submit.tpl
AFTER:

<input type="text" name="URL1"
value="{$URL1|escape|trim}" size="40"
 maxlength="255" class="text"/>

ADD:

{validate form="submit_link" id="v_URL1"
 message=$smarty.capture.invalid_url}
{validate form="submit_link" id="v_URL1_ONLINE"
 message=$smarty.capture.url_not_online}

This will allow to validate the URL1 field when it is not empty. You should do the same for all URLs that you want to validate (straightforward).

Before applying this modification, please install first the deep links mod for phpld

This MOD is updating to allow the 5 deep links for featured listings, 3 deep links for regular and none for reciprocal. A question that has been asked many times.

First add the javascript code in header.tpl
RIGHT BEFORE </head>
ADD:

{literal}
<script language="JavaScript">
function setVisibility(id, visibility) {
document.getElementById(id).style.display = visibility;
style="display:none"
}
function featured(){
setVisibility('field1_title', '');
setVisibility('field1_url', '');
setVisibility('field2_title', '');
setVisibility('field2_url', '');
setVisibility('field3_title', '');
setVisibility('field3_url', '');
setVisibility('field4_title', '');
setVisibility('field4_url', '');
setVisibility('field5_title', '');
setVisibility('field5_url', '');
}
function regular(){
setVisibility('field1_title', '');
setVisibility('field1_url', '');
setVisibility('field2_title', '');
setVisibility('field2_url', '');
setVisibility('field3_title', '');
setVisibility('field3_url', '');
setVisibility('field4_title', 'none');
setVisibility('field4_url', 'none');
setVisibility('field5_title', 'none');
setVisibility('field5_url', 'none');
}
function reciprocal(){
setVisibility('field1_title', 'none');
setVisibility('field1_url', 'none');
setVisibility('field2_title', 'none');
setVisibility('field2_url', 'none');
setVisibility('field3_title', 'none');
setVisibility('field3_url', 'none');
setVisibility('field4_title', 'none');
setVisibility('field4_url', 'none');
setVisibility('field5_title', 'none');
setVisibility('field5_url', 'none');
}
</script>{/literal}

SECOND open submit.tpl
FIND:

<input type="radio" name="LINK_TYPE" value="featured"
 {if $LINK_TYPE eq 'featured'}checked="true"{/if}>

REPLACE BY:

<input type="radio" name="LINK_TYPE" value="featured"
 {if $LINK_TYPE eq 'featured'}checked="true"{/if}
  onclick="featured();"; >

FIND:

<input type="radio" name="LINK_TYPE" value="normal"
 {if $LINK_TYPE eq 'normal'}checked="true"{/if}>

REPLACE BY:

<input type="radio" name="LINK_TYPE" value="normal"
 {if $LINK_TYPE eq 'normal'}checked="true"{/if}
 onclick="regular();"; >

There are 2 Instances of this, for free and paid regular links.

FIND:

<input type="radio" name="LINK_TYPE" value="reciprocal"
 {if $LINK_TYPE eq 'reciprocal'}checked="true"{/if}>

REPLACE BY:

<input type="radio" name="LINK_TYPE" value="reciprocal"
 {if $LINK_TYPE eq 'reciprocal'}checked="true"{/if}
 onclick="reciprocal();"; >

Finally, in submit.tpl

FIND:

<tr>
    <td class="label">TITLE 1</td>
    <td class="field"><input type="text"
 name="TITLE1" value="{$TITLE1|escape|trim}"
 size="40" maxlength="255" class="text"/></td>
  </tr>
    <tr>
    <td class="label">URL 1</td>
    <td class="field"><input type="text"
 name="URL1" value="http://{$URL1|escape|trim}"
 size="40" maxlength="255" class="text"/></td>
  </tr>
  <tr>
    <td class="label">TITLE 2</td>
    <td class="field"><input type="text"
 name="TITLE2" value="{$TITLE2|escape|trim}"
 size="40" maxlength="255" class="text"/></td>
  </tr>
    <tr>
    <td class="label">URL 2</td>
    <td class="field"><input type="text"
 name="URL2" value="http://{$URL2|escape|trim}"
 size="40" maxlength="255" class="text"/></td>
  </tr>
  <tr>
    <td class="label">TITLE 3</td>
    <td class="field"><input type="text"
 name="TITLE3" value="{$TITLE3|escape|trim}"
 size="40" maxlength="255" class="text"/></td>
  </tr>
    <tr>
    <td class="label">URL 3</td>
    <td class="field"><input type="text"
 name="URL3" value="http://{$URL3|escape|trim}"
 size="40" maxlength="255" class="text"/></td>
  </tr>
  <tr>
    <td class="label">TITLE 4</td>
    <td class="field"><input type="text"
 name="TITLE4" value="{$TITLE4|escape|trim}"
 size="40" maxlength="255" class="text"/></td>
  </tr>
  <tr>
    <td class="label">URL 4</td>
    <td class="field"><input type="text"
 name="URL4" value="http://{$URL4|escape|trim}"
 size="40" maxlength="255" class="text"/></td>
  </tr>  
  <tr>
    <td class="label">TITLE 5</td>
    <td class="field"><input type="text"
 name="TITLE5" value="{$TITLE5|escape|trim}"
 size="40" maxlength="255" class="text"/></td>
  </tr>
    <tr>
    <td class="label">URL 5</td>
    <td class="field"><input type="text"
 name="URL5" value="http://{$URL5|escape|trim}"
 size="40" maxlength="255" class="text"/></td>
  </tr>

REPLACE BY:

<tr id="field1_title" style="display:none">
<td class="label">TITLE 1</td>
<td class="field"><input type="text"
name="TITLE1" value="{$TITLE1|escape|trim}"
size="40" maxlength="255" class="text"/></td>
</tr>
<tr id="field1_url" style="display:none">
<td class="label">URL 1</td>
<td class="field"><input type="text" 
name="URL1" value="{$URL1|escape|trim}"
size="40" maxlength="255" class="text"/>
</td>
</tr> 
<tr id="field2_title" style="display:none">
<td class="label">TITLE 2</td>
<td class="field"><input type="text"
name="TITLE2" value="{$TITLE2|escape|trim}"
size="40" maxlength="255" class="text"/></td>
</tr>
<tr id="field2_url" style="display:none">
<td class="label">URL 2</td>
<td class="field"><input type="text"
name="URL2" value="{$URL2|escape|trim}"
size="40" maxlength="255" class="text"/></td>
</tr> 
<tr id="field3_title" style="display:none">
<td class="label">TITLE 3</td>
<td class="field"><input type="text"
name="TITLE3" value="{$TITLE3|escape|trim}"
size="40" maxlength="255" class="text"/></td>
</tr>
<tr id="field3_url" style="display:none">
<td class="label">URL 3</td>
<td class="field"><input type="text"
name="URL3" value="{$URL3|escape|trim}"
size="40" maxlength="255" class="text"/></td>
</tr> 
<tr id="field4_title" style="display:none">
<td class="label">TITLE 4</td>
<td class="field"><input type="text"
name="TITLE4" value="{$TITLE4|escape|trim}"
size="40" maxlength="255" class="text"/></td>
</tr>
<tr id="field4_url" style="display:none">
<td class="label">URL 4</td>
<td class="field"><input type="text"
name="URL4" value="http://{$URL4|escape|trim}"
size="40" maxlength="255" class="text"/></td>
</tr> 
<tr id="field5_title" style="display:none">
<td class="label">TITLE 5</td>
<td class="field"><input type="text"
name="TITLE5" value="{$TITLE5|escape|trim}"
size="40" maxlength="255" class="text"/></td>
</tr>
<tr id="field5_url" style="display:none">
<td class="label">URL 5</td>
<td class="field"><input type="text"
name="URL5" value="http://{$URL5|escape|trim}"
size="40" maxlength="255" class="text"/></td>
</tr>

Please apply the phpld deeplinks mod before adding this feature.

This will give you the ability to show and edit the additional fields in the admin panel. 3 Files will be edited so I recommend that you back them up before applying the modifications.
Files to edit:
admin/dir_approve_links.php,
templates/Core/admin/link_details.tpl,
templates/Core/admin/dir_links_edit.tpl.

First in admin/dir_approve_links.php
FIND:

$columns = array ('TITLE' => _L('Title'),
'URL' => _L('URL'),
'DESCRIPTION' => _L('Description'),
'CATEGORY' => _L('Category'),
'RECPR_URL' => _L('Recpr. Link URL'),
'PAGERANK' => _L('Pagerank'),
'DATE_ADDED' => _L('Date Added'));

REPLACE BY:

$columns = array ('TITLE' => _L('Title') ,
'URL' => _L('URL'), 'TITLE1' => _L('Title1'),
'URL1' => _L('URL1') , 'TITLE2' => _L('Title2'),
'URL2' => _L('URL2') , 'TITLE3' => _L('Title3'),
'URL3' => _L('URL3') , 'TITLE4' => _L('Title4'),
'URL4' => _L('URL4') , 'TITLE5' => _L('Title5'),
'URL5' => _L('URL5'),
'DESCRIPTION' => _L('Description'),
'CATEGORY' => _L('Category'),
'RECPR_URL' => _L('Recpr. Link URL'),
'PAGERANK' => _L('Pagerank'),
'DATE_ADDED' => _L('Date Added'));

Second, in templates/admin/link_details.tpl
FIND:

<tr class="{cycle values="odd,even"}">
<td class="label">URL:</td>
<td class="smallDesc">{$linkInfo.URL|escape|trim}
</td>
</tr>

BELOW it, ADD:

<tr class="{cycle values="odd,even"}">
<td class="label">Title1:</td>
<td class="smallDesc">{$linkInfo.TITLE1|escape|trim}
</td>
</tr>

<tr class="{cycle values="odd,even"}">
<td class="label">URL1:</td>
<td class="smallDesc">{$linkInfo.URL1|escape|trim}
</td>
</tr>

<tr class="{cycle values="odd,even"}">
<td class="label">Title2:</td>
<td class="smallDesc">{$linkInfo.TITLE2|escape|trim}
</td>
</tr>

<tr class="{cycle values="odd,even"}">
<td class="label">URL2:</td>
<td class="smallDesc">{$linkInfo.URL2|escape|trim}
</td>
</tr>

<tr class="{cycle values="odd,even"}">
<td class="label">Title3:</td>
<td class="smallDesc">{$linkInfo.TITLE3|escape|trim}
</td>
</tr>

<tr class="{cycle values="odd,even"}">
<td class="label">URL3:</td>
<td class="smallDesc">{$linkInfo.URL3|escape|trim}
</td>
</tr>

<tr class="{cycle values="odd,even"}">
<td class="label">Title4:</td>
<td class="smallDesc">{$linkInfo.TITLE4|escape|trim}
</td>
</tr>

<tr class="{cycle values="odd,even"}">
<td class="label">URL4:</td>
<td class="smallDesc">{$linkInfo.URL4|escape|trim}
</td>
</tr>

<tr class="{cycle values="odd,even"}">
<td class="label">Title5:</td>
<td class="smallDesc">{$linkInfo.TITLE5|escape|trim}
</td>
</tr>

<tr class="{cycle values="odd,even"}">
<td class="label">URL5:</td>
<td class="smallDesc">{$linkInfo.URL5|escape|trim}
</td>
</tr>

FINALLY in templates/admin/dir_links_edit.tpl
FIND

<tr>
<td class="label required">
<label for="URL">URL:</label></td>
<td class="smallDesc">
<input type="text" id="URL" name="URL"
 value="{$URL|escape|trim}" class="text"/>
{validate form="dir_links_edit" id="v_URL"
 message=$smarty.capture.invalid_url}
{validate form="dir_links_edit" id="v_URL_U"
 message=$smarty.capture.url_not_unique}
</td>
</tr>

BELOW it , ADD

<tr>
<td class="label"><label for="TITLE1">
Title1:</label></td>
<td class="smallDesc">
<input type="text" id="TITLE1" name="TITLE1"
 value="{$TITLE1|escape|trim}" class="text" />           
</td>
</tr>
<tr>
<td class="label"><label for="URL1">
URL1:</label></td>
<td class="smallDesc">
<input type="text" id="URL1" name="URL1"
 value="{$URL1|escape|trim}" class="text"/>
</td>
</tr>
      
<tr>
<td class="label"><label for="TITLE2">
Title2:</label></td>
<td class="smallDesc">
<input type="text" id="TITLE2" name="TITLE2"
 value="{$TITLE2|escape|trim}" class="text" />           
</td>
</tr>
<tr>
<td class="label"><label for="URL2">
URL2:</label></td>
<td class="smallDesc">
<input type="text" id="URL2" name="URL2"
 value="{$URL2|escape|trim}" class="text"/>
</td>
</tr>
      
<tr>
<td class="label"><label for="TITLE3">
Title3:</label></td>
<td class="smallDesc">
<input type="text" id="TITLE3" name="TITLE3"
 value="{$TITLE3|escape|trim}" class="text" />           
</td>
</tr>
<tr>
<td class="label"><label for="URL">
URL3:</label></td>
<td class="smallDesc">
<input type="text" id="URL3" name="URL3"
 value="{$URL3|escape|trim}" class="text"/>
</td>
</tr>
      
<tr>
<td class="label"><label for="TITLE4">
Title4:</label></td>
<td class="smallDesc">
<input type="text" id="TITLE4" name="TITLE4"
 value="{$TITLE4|escape|trim}" class="text" />           
</td>
</tr>
<tr>
<td class="label"><label for="URL4">
URL4:</label></td>
<td class="smallDesc">
<input type="text" id="URL4" name="URL4"
 value="{$URL4|escape|trim}" class="text"/>
</td>
</tr>
      
<tr>
<td class="label"><label for="TITLE5">
Title5:</label></td>
<td class="smallDesc">
<input type="text" id="TITLE5" name="TITLE5"
 value="{$TITLE5|escape|trim}" class="text" />           
</td>
</tr>
<tr>
<td class="label"><label for="URL5">
URL5:</label></td>
<td class="smallDesc">
<input type="text" id="URL5" name="URL5"
 value="{$URL5|escape|trim}" class="text"/>
</td>
</tr>

The second step will show the additional fields when hovering over the link title in admin panel when approving links or viewing links.

The third step will show them when editing the listing in the admin panel.

Many thanks to Bobby from the forums of phpld for all the help he gives to the members there.

April 23rd, 2007Phpld deeplinks mod

This modification allows to offer deeplinks in your directory. What are deeplinks you may ask? Well, information about this topic is certainly hard to find. Even blogs about various subjects may not contain such information. Read on and you may find something useful from this post. It is a safe modification but you are better off backing up the database and the following files:
include/tables.php
/detail.php
submit.tpl
detail.tpl
You might as well test it in your test directory first. I tested it on version 3.2 and it works great.

First: we have to add additional fields in the PLD_LINK table:

1. Open include/tables.php
FIND:

'RECPR_EXPIRED' => 'L NOTNULL DEFAULT 0'

REPLACE BY:

'RECPR_EXPIRED' => 'L NOTNULL DEFAULT 0' ,
'TITLE1' => 'C(255) NULL' ,
'URL1' => 'C(255) NULL' ,
'TITLE2' => 'C(255) NULL' ,
'URL2' => 'C(255) NULL' ,
'TITLE3' => 'C(255) NULL' ,
'URL3' => 'C(255) NULL' ,
'TITLE4' => 'C(255) NULL' ,
'URL4' => 'C(255) NULL' ,
'TITLE5' => 'C(255) NULL' ,
'URL5' => 'C(255) NULL'

2. NOW rerun the install script by pointing to install/index.php, this will update the table structure.

Second: Modify the submit form:

in submit.tpl
FIND:

<tr>
   <td class="label">Description:</td>

ABOVE it, ADD:

<tr>
    <td class="label">TITLE 1</td>
    <td class="field"><input type="text"
 name="TITLE1" value="{$TITLE1|escape|trim}"
 size="40" maxlength="255" class="text"/></td>
  </tr>
  <tr>
    <td class="label">URL 1</td>
    <td class="field"><input type="text"
 name="URL1" value="{$URL1|escape|trim}"
 size="40" maxlength="255" class="text"/></td>
  </tr>  
  <tr>
    <td class="label">TITLE 2</td>
    <td class="field"><input type="text"
 name="TITLE2" value="{$TITLE2|escape|trim}"
 size="40" maxlength="255" class="text"/></td>
  </tr>
  <tr>
    <td class="label">URL 2</td>
    <td class="field"><input type="text"
 name="URL2" value="{$URL2|escape|trim}"
 size="40" maxlength="255" class="text"/></td>
  </tr>  
  <tr>
    <td class="label">TITLE 3</td>
    <td class="field"><input type="text"
 name="TITLE3" value="{$TITLE3|escape|trim}"
 size="40" maxlength="255" class="text"/></td>
  </tr>
  <tr>
    <td class="label">URL 3</td>
    <td class="field"><input type="text"
 name="URL3" value="{$URL3|escape|trim}"
 size="40" maxlength="255" class="text"/></td>
  </tr>  
  <tr>
    <td class="label">TITLE 4</td>
    <td class="field"><input type="text"
 name="TITLE4" value="{$TITLE4|escape|trim}"
 size="40" maxlength="255" class="text"/></td>
  </tr>
  <tr>
    <td class="label">URL 4</td>
    <td class="field"><input type="text"
 name="URL4" value="{$URL4|escape|trim}"
 size="40" maxlength="255" class="text"/></td>
  </tr>  
  <tr>
    <td class="label">TITLE 5</td>
    <td class="field"><input type="text"
 name="TITLE5" value="{$TITLE5|escape|trim}"
 size="40" maxlength="255" class="text"/></td>
  </tr>
    <tr>
    <td class="label">URL 5</td>
    <td class="field"><input type="text"
 name="URL5" value="{$URL5|escape|trim}"
 size="40" maxlength="255" class="text"/></td>
  </tr>

Finally Show the additional links in the details page.
To do so, we have to modify detail.php and detail.tpl

1. in detail.tpl
FIND:

<tr>
<td class="label">Description:</td>
<td class="smallDesc" align="left">
{$DESCRIPTION|escape|trim}</td>
</tr>

BELOW, ADD:

<tr>
<td class="label">Products/Services:</td>
<td class="smallDesc" align="left">
<a href="{$URL1|escape|trim}">
{$TITLE1|escape|trim}</a>&nbsp;
<a href="{$URL2|escape|trim}">
{$TITLE2|escape|trim}</a>&nbsp;
<a href="{$URL3|escape|trim}">
{$TITLE3|escape|trim}</a>&nbsp;
<a href="{$URL4|escape|trim}">
{$TITLE4|escape|trim}</a>&nbsp;
<a href="{$URL5|escape|trim}">
{$TITLE5|escape|trim}</a>&nbsp;
</td>
</tr>

2. in detail.php
FIND:

$data['META_DESCRIPTION'] = $rdata['META_DESCRIPTION'];

BELOW it, ADD:

$data['TITLE1']    = $rdata['TITLE1']; 
$data['URL1']    = $rdata['URL1']; 
$data['TITLE2']    = $rdata['TITLE2']; 
$data['URL2']    = $rdata['URL2']; 
$data['TITLE3']    = $rdata['TITLE3']; 
$data['URL3']    = $rdata['URL3']; 
$data['TITLE4']    = $rdata['TITLE4']; 
$data['URL4']    = $rdata['URL4']; 
$data['TITLE5']    = $rdata['TITLE5']; 
$data['URL5']    = $rdata['URL5'];

 You are done, now all plans (regular and featured will have the optional 5 additional links.
To modify the number of additional links the code above should be modified accordingly (straightforward).

To allow a lower number of additional links for regular listings a simple javascript code can be added to the radio buttons of payment to hide some of the fields when “regular” is selected. Otherwise you can juste allow the same number of links for all plans.

Another additional feature could be to check if the deeplinks come from the same domain. Use your imagination.
I think this modification can be used for all versions of phpld but I only tested it on 3.2. These steps can be done everytime you upgrade the script, so you might bookmark this page or copy its content.
Feel free to improve this mod.


© 2007 rakCha resources | Powered by Wordpress | rakCha web directory