View Single Post
  #1195  
Old 04-03-2004, 10:34 PM
killervette killervette is offline
 
Join Date: Nov 2003
Posts: 35
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Here is the gallery code I want to include at the bottom of the vbindex page. I want it centered like the centered latest threads page. I dont know much php. Can anyone help me and tell me where to put it please?

//++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++ +++++++++++++++++++

echo("<table bgcolor=\"#F7F7F7\" width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"3\"> ");
echo("<tr> ");
echo("<td valign=\"top\" bgcolor=\"CC0000\"><font face=\"verdana, arial, helvetica\" size=\"2\" class=\"nf\" color=\"#FFFFFF\"> <b>Latest ");
echo("Gallery Images - ");

$dbusername="";
$password="";
$database=""
mysql_connect(localhost,$dbusername,$password);
@mysql_select_db($database) or die( "Unable to select database");

$query = "SELECT * FROM photos WHERE approved='1'";
$result=mysql_query($query);
$numrows=mysql_num_rows($result);

echo ("$numrows Photos and Counting");


echo("</b></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td bgcolor=#F7F7F7><div align=center>");
echo("<p><font size=1 face=Geneva>");


////////////////////////////////////////////////////////////////////////////
// thumbincluder.php version 1.1
// A thumbnail includer for your non-photopost page
// Tested with Photopost PHP version 3.0.4
////////////////////////////////////////////////////////////////////////////
//1.0 first release
//1.1 included remote functions for standalone operation
// please note database hooks and paths are required in settings below.
////////////////////////////////////////////////////////////////////////////
// July 13, 2002 Here is a hacked-up version of photoinclude.php that has
// been merged with a hacked-up version of index.php and a hacked-up version of
// display_gallery by a guy on two quarts of caffeine at 3:40 AM, oh,
// and did I mention it was his first php programming experiment ever?
//
// If that didn't scare you enough: BACK UP YOUR DATABASE NOW!
//
// This file goes in your photopost php directory with all the other files
// Then configure Display Settings below as desired.
//
// NOTES:
// Please note that the prior typo "lastest" has been fixed, so the valid
// switches are random, most_views (plural) and latest (spelled correctly)
//
// If you liked this hack, email me a link to your photopost so I can learn
// something from your layout too!
//
// Live long and prosper - Matt Chroust (memobug@spamcop.net)
//
//////////////////////////// COPYRIGHT NOTICE //////////////////////////////
// This script is part of PhotoPost PHP, a software application by //
// All Enthusiast, Inc. Use of any kind of part or all of this //
// script or modification of this script requires a license from All //
// Enthusiast, Inc. Use or modification of this script without a license //
// constitutes Software Piracy and will result in legal action from All //
// Enthusiast, Inc. All rights reserved. //
// http://www.photopost.com legal@photopost.com //
// Contributing Developer: Michael Pierce (danasoft.com) //
// //
// PhotoPost Copyright 2002, All Enthusiast, Inc. //
////////////////////////////////////////////////////////////////////////////



// ************************************************** ***********************
// ************************************************** ***********************
//PhotoPost Setting
//You must change these values in order to run this script

$Url_Path = "http://www.ifitsfast.com/photogallery/"; //URL of your photo album, where the index.php is (with / at end)
$data_dir = "http://www.ifitsfast.com/photogallery/data/" ; //URL of your photo dir where those jpeg stored (with / at end)
$images_dir =$Url_Path."../images/"; //URL of your photopost images dir where default missing thumb image is stored (with / at end)
$rel_dir = "../photogallery/data/"; // path to the data directory where pictures reside RELATIVE
// to the location of THIS file (used for checking thumbs)
//Database Setting
//You must change these values in order to run this script
//These value are not visible in the output page source

$host = ""; //Server Name
$user= ""; //Username
$password= ""; //Password
$database=""; //Photopost database name or forum database name

//Display Setting (Changes to fit your page)
$q_switch = "latest"; // "random" or "most_views" or "latest"
$limit = 8; //number of image to show
$table_width = "65%"; //width of the table generated
$column = 4; //number of columns of the table generated
$photo_cell_align = "center"; //alignment of those cells

// CSS Setting (optional)
$class_link = ""; //css for link, leave blank if none
$class_table = ""; //css for table, leave blank if none
$class_mouseover = ""; //color when mouse over the photo cell, leave blank if to cancel

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

///////////don't edit below this line if you are too afraid to kill the code//////////////
// ---------------------- THESE FUNCS FROM pp-inc -----------------

function mysql_query_eval( $query, $database ) {
global $Globals;

$mysql_eval_error="";
$mysql_eval_result = mysql_query($query, $database) or $mysql_eval_error = mysql_error();
if ($mysql_eval_error) {
if ( $Globals{'debug'} == 1 ) {
$letter = "An error was encountered during execution of the query:\n\n";
$letter .= $query."\n\n";
$letter .="The query returned with an errorcode of: \n\n$mysql_eval_error\n\n";
$letter .= "If you need assistence or feel this is a 'bug'; please report it to our ";
$letter .= "support forums at: http://www.techimo.com/forum/f27/index.html\n\n";
$letter .= "To turn off these emails, set \$debug=0 in your config-inc.php file.";

$email = $Globals{'adminemail'};
$email_from = "From: ".$Globals{'adminemail'};

$subject="Subject: ".$Globals{'webname'}." MySQL Error Report";
$subject=trim($subject);

mail( $email, $subject, $letter, $email_from );
}
elseif ( $Globals{'debug'} == 2 ) {
dieWell( "MySQL error reported!<p>Query: $query<p>Result: $mysql_eval_error<p>Database handle: $database" );
exit;
}
return FALSE;
}
else {
return $mysql_eval_result;
}
}

function get_ext( $filename ) {
$photolen = strlen($filename);
$RetVal = substr( $filename, $photolen-3, $photolen);

return $RetVal;
}

function get_filename($filename) {
// strip off the last 4
$len = strlen( $filename )-4;
$RetVal = substr( $filename, 0, $len);
return $RetVal;
}


// ---------------------- THESE FUNCS FROM pp-inc -----------------
// Connecting, selecting database
$link = mysql_connect ("$host", "$user", "$password") or die ('I cannot connect to the database.');
mysql_select_db ("$database")or die("Could not select database");

// Here is the hacked up display_gallery($q_switch)

$catquery="";

if ( IsSet($cat) ) {
$querya="SELECT catname FROM categories WHERE id=$cat";
$catq = mysql_query_eval($querya,$link);
$catr = mysql_fetch_array($catq);
$catname = $catr['catname'];
mysql_free_result($catq);


$queryb = "SELECT id FROM categories WHERE parent='$cat' ORDER BY catorder ASC";
$boards = mysql_query_eval($queryb,$link);
$cnt=0;
while ( $row = mysql_fetch_array($boards, MYSQL_ASSOC)) {
$catqid = $row['id'];
if ( $cnt == 0 ) {
$cnt=1;
$catquery .= "$catqid";
}
else {
$catquery .= ",$catqid";
}
}
mysql_free_result($boards);
}



// Connecting, selecting database

// Selecting method and Perform SQL query


switch ($q_switch) {
case "most_views":
if ( !IsSet($cat) ) {
$group_title = "Most Popular Images - All Categories";
$query = "SELECT id,user,userid,cat,title,bigimage,views FROM photos WHERE bigimage!='' AND approved='1' $exclude_cat ORDER BY views DESC LIMIT $limit";
}
else {
$query = "SELECT id,user,userid,cat,title,bigimage,views FROM photos WHERE bigimage!='' AND approved='1' $exclude_cat AND cat in ($catquery) ORDER BY views DESC LIMIT $limit";
$group_title = "Most Popular Images - $catname";
}
break;
case "latest":
if ( !IsSet($cat) ) {
$group_title = "Most Recent Images - All Categories";
$query = "SELECT id,user,userid,cat,title,bigimage,views FROM photos WHERE bigimage!='' AND approved='1' $exclude_cat ORDER BY date DESC LIMIT $limit";
break;
}
else {
$group_title = "Most Recent Images - $catname";
$query = "SELECT id,user,userid,cat,title,bigimage,views FROM photos WHERE bigimage!='' AND approved='1' $exclude_cat AND cat in ($catquery) ORDER BY date DESC LIMIT $limit";
break;
}
break;
default:
if ( !IsSet($cat) ) {
$group_title = "Random Images - All Categories";
$query = "SELECT id,user,userid,cat,title,bigimage,views FROM photos WHERE bigimage!='' AND approved='1' $exclude_cat ORDER BY RAND() DESC LIMIT $limit";
break;
}
else {
$group_title = "Random Images - $catname";
$query = "SELECT id,user,userid,cat,title,bigimage,views FROM photos WHERE bigimage!='' AND approved='1' $exclude_cat AND cat in ($catquery) ORDER BY RAND() DESC LIMIT $limit";
break;
}
break;
}


$i = 1;
$e = 2;
$col_val = $column;
$result = mysql_query_eval($query,$link) or die("Query failed");
print "<table class=\"".$class_table."\" width=\"".$table_width."\"><tr>";
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
$photo_name = get_filename( $line['bigimage'] );
print "<td onmouseover=this.style.background='".$class_mouseo ver."' onmouseout=this.style.background='' align=\"center\">";
$theext = get_ext( $line['bigimage'] );
$thecat = $line['cat'];
$temp_user = ($line["userid"]);
$filepath = "$data_dir"."$thecat/$temp_user$photo_name-thumb.$theext";
$rel_path = "$rel_dir"."$thecat/$temp_user$photo_name-thumb.$theext";
print "<A class=\"$class_link\" href=\"$Url_Path"."showphoto.php?photo=".$line['id']. "\">";
if ( file_exists( $rel_path ) )
print "<img border=\"0\" src='$filepath'>";
else
print "<img border=\"0\" src='".$images_dir."nothumb.gif' alt='$filepath'>";
print "<Font size=\"1\"color=\"".$Globals{'maintext'}."\" face=\"verdana,arial\">\n";
if ($q_switch == "most_views") {
print "<br>".$line["title"]."<br>".$line["views"]." views";
print "</a><br></font></div><br>";
} else {
print "<br>".$line["title"];
print "</a><Br>by ".$line["user"]."</font></div><br>";
}
if ($i == "$column") {
print "</td></tr><tr>";
$column = $col_val*$e;
$e++;
} else {print "</td>";}
$i++;
}

print "</tr></table>";

// Closing connection
mysql_close($link);
// mysql_close($db_link);


echo("</font></p>");
echo("</div></td>");
echo("</tr>");
echo("</table>");

//++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++ +++++++++++++++++++
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01202 seconds
  • Memory Usage 1,823KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete