This is the community forum. For a developer response use the Client Area.
Follow us on Facebook, Twitter and YouTube!

what is the way insert the code in a php file?
#1

Hi,
I'm really thankful for your script!
but my problem is i'm very new to php, and i don't noe where to add the integration script on the page?
cause i'm initially planning to host a photo hosting site, and i want the comments session on the image preview page!
Below is the current page code where i want the comment session to fit on!

//****************************************************

<?php

define('cfih', 'thumb');
include_once('./inc/cfih.php');

// find image id
if(isset($_GET['pt'])||isset($_GET['pm'])){
unset($_SESSION['upload']);
$_SESSION['upload'][0]['id'] = isset($_GET['pt'])?$_GET['pt']:$_GET['pm'];
}

// check to see if this page has been hidden (set in the admin panel), if so then send user to the index/home page
elseif(!isset($_SESSION['upload'])){
header('Location: index.php');
exit();
}

// check what thumb to show!
$showImage = isset($_GET['pt'])?1:0;

// count number of thumb's on page
$countThumb = 0;

// image loop
foreach($_SESSION['upload'] as $k=>$uploadimage){

if(isset($uploadimage['id'])){
$img_id =$uploadimage['id'];
}
if(isset($uploadimage['did'])){
$delete_id =$uploadimage['did'];
}
unset($_SESSION['upload'][$k]);

if(isset($img_id) && preg_replace("/[^0-9A-Za-z]/","",$img_id) == $img_id){
//see if image exists
if ($image = getImage($img_id)){

// hold thumbnail page html
if(!isset($thumbHtml))$thumbHtml = '';

//only count image if not on upload page
if(!isset($delete_id))db_imageCounterSave($image,4);

// Thumbnail page variables
$thumb_link = imageAddress(3,$image,'pt');
$thumb_url = imageAddress(3,$image,'dt');
$thumb_mid_link = imageAddress(2,$image,'pm');
$thumb_mid_url = imageAddress(2,$image,'dm');
$imgurl = imageAddress(1,$image,'di');
$alt = $image['alt'];
$shorturl = $image['shorturl'];
$bookmarking = bookmarking(($shorturl ==null?$thumb_mid_link:$shorturl),$alt);
$thumb_show = $showImage?$thumb_url:$thumb_mid_url;

// make image links
$links[$countThumb] = array(
'delete_url' => (isset($delete_id)?$settings['SET_SITEURL'].'/?d='.$delete_id:'')
);

// comments layout
$layout = ' full';

// AdSense
$thumb_Ad_html = '';
if(get_ad_code('thumb')){
if(!isset($countThumb) || $countThumb < 2){
$thumb_Ad_html = '<div class="thumb_Ad">'.get_ad_code('thumb').'</div>';
}
}

$thumbHtml .= '<div class="img_ad_box '.(isset($countThumb) && $countThumb > 0?' nextbox':'').'">
<div class="img_box'.(!empty($thumb_Ad_html)?' left':'').'"><a href="'.$imgurl.'" title="'.$alt.'" class="lightbox" ><img src="'.$thumb_show.'" alt="'.$alt.'" /><br/><span>'.$alt.'</span></a></div>
'.$thumb_Ad_html.'
<div style="clear: both;"></div>
</div>';

//image links
$thumbHtml .= '<div id="links" class="boxpanel'.$layout.'">
<h2 class="boxtitle">'._T("site_index_hide_link").'</h2>
<div class="code_box"><label id="toplabel">'._T("site_index_social_networks").':</label>'.$bookmarking.'</div>';
// Short URL
if ($shorturl != null && !empty($shorturl)) $thumbHtml .= '
<div class="code_box"><label for="shorturl">'._T("site_index_short_url_link").':</label> <input type="text" id="codehtml" value="'.$shorturl.'" onclick="javascript:this.focus();this.select();" readonly="true" class="text_input long" /></div>';

// Comment area for the users \\

if(isset($delete_id)){
$thumbHtml .= '
<h3>Delete Image</h3>
<div class="code_box"><label for="deletecode">'._T("site_index_delete_url").':</label> <input type="text" id="deletecode" value="'.$links[$countThumb]['delete_url'].'" onclick="javascript:this.focus();this.select();" readonly="true" class="text_input long" /></div>
<p class="teaser">'._T("site_index_delete_url_des").'</p>';
}
$thumbHtml .= '</div>';
$thumbHtml .= '<div style="clear: both;"></div>';
}else{
$Err['thumbs_page'] = _T("site_index_thumbs_page_err");
}
}
$countThumb++;
}// end uploaded loop

// unset upload array
unset($_SESSION['upload']);

////////////////////////////////////////////////////////////////////////////////////
// MAKE PAGE

// error send back to home page and show the error
if(!isset($thumbHtml)){
header('Location: index.php?err=404');
exit();
}

// set any header hooks
add_code_line('header','<link rel="stylesheet" type="text/css" href="'.$settings['SET_SITEURL'].'/lightbox/lightbox.css" media="screen" />
<script type= "text/javascript">
var homeUrl = "'.$settings['SET_SITEURL'].'";
</script>');

// set any footer hooks
add_code_line('footer','<script type="text/javascript" src="'.$settings['SET_SITEURL'].'/lightbox/lightbox.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$(".lightbox").lightbox({
fitToScreen: true,
imageClickClose: true,
displayDownloadLink: true
});
});
</script>');

// header page var
$pageSet['id'] = 'thumb';
$pageSet['title'] = ' - '.(isset($alt)?$alt:' No Image Found');
$pageSet['description'] = 'Thumb page for '.$alt.' image on '.$settings['SET_TITLE'];
$pageSet['keywords'] = 'Thumb image, gallery, images, photos, image gallery, photo gallery, image hosting';

// load header
include './header.php';

// print Thumbnail page
echo $thumbHtml;

// check for theme Settings
ImageWidget(!empty($themeSet['widgit_row'])?$themeSet['widgit_row']:$ROW_RANDIMG);

include './footer.php';
exit;
***************************************************//

Thank you very much in advance!
Reply
#2

Hi it depends how you want it to work. Are you wanting the comments to vary depending on the image or the same comments all the time?

If you want it to vary depending on the image, I'd suggest trying this:

PHP Code:
$cmtx_identifier $img_id;
$cmtx_reference  $image['alt'];
$cmtx_folder    '/upload/';
require(
$_SERVER['DOCUMENT_ROOT'] . $cmtx_folder 'frontend/index.php'); 

If you want the same comments all the time, just enter something descriptive like this:

PHP Code:
$cmtx_identifier 'image-preview';
$cmtx_reference  'Image Preview';
$cmtx_folder    '/upload/';
require(
$_SERVER['DOCUMENT_ROOT'] . $cmtx_folder 'frontend/index.php'); 

Also, remember to change the $cmtx_folder line to your Commentics folder.

Have you completed the interview?
Reply


Possibly Related Threads…
Thread / Author Replies Views Last Post
Last Post by Steven
25-Jul-2014, 06:23 PM
Last Post by jonoweb
09-Oct-2012, 03:11 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)