Author |
Message |
TheosEleos
Life Cycles Becoming CPU Cycles

Joined: Sep 18, 2003
Posts: 960
Location: Missouri
|
Posted:
Tue Mar 16, 2004 11:31 am |
|
It seems like the random photo block and your site info block don't get along. Are you interested in trouble shooting this with me? |
_________________ Only registered users can see links on this board! Get registered or login! |
|
 |
 |
Raven
Site Admin/Owner

Joined: Aug 27, 2002
Posts: 17088
|
Posted:
Tue Mar 16, 2004 11:36 am |
|
In a word, no (no time) - However, I can point you in the right direction. Chances are that both blocks are using the same variable name somewhere. When you find it/them, just rename all occurences. |
|
|
|
 |
TheosEleos

|
Posted:
Tue Mar 16, 2004 11:41 am |
|
lol
Thanks, will look in that direction. |
|
|
|
 |
TheosEleos

|
Posted:
Fri Mar 19, 2004 7:20 pm |
|
No luck so far. Will textpad search two files for matches?
Since I stink at php I am afraid I am missing a variable somewhere.  |
|
|
|
 |
TheosEleos

|
Posted:
Fri Mar 19, 2004 7:50 pm |
|
$10 bucks to fix this?
I can't take it anymore!
Code:<?php
// ------------------------------------------------------------------------- //
// Coppermine Photo Gallery 1.2.2a for CMS //
// ------------------------------------------------------------------------- //
// Copyright (C) 2002,2003 Grégory DEMAR <gdemar@wanadoo.fr> //
// http://www.chezgreg.net/coppermine/ //
// ------------------------------------------------------------------------- //
// Updated by the Coppermine Dev Team //
// (http://coppermine.sf.net/team/) //
// see /docs/credits.html for details //
// ------------------------------------------------------------------------- //
// New Port by GoldenTroll //
// http://coppermine.findhere.org/ //
// Based on coppermine 1.1d by Surf http://www.surf4all.net/ //
// ------------------------------------------------------------------------- //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation; either version 2 of the License, or //
// (at your option) any later version. //
// ------------------------------------------------------------------------- //
if (eregi("block-CPG-Random_pictures.php", $PHP_SELF)) {
Header("Location: index.php");
die();
}
define('NO_HEADER', true);
global $prefix, $db, $CONFIG, $Version_Num, $cpg_dir;
//global $ALBUM_SET;
$cpg_dir = "coppermine";
$cpg_block = false;
require("modules/".$cpg_dir."/include/load.inc.php");
$cpg_block = true;
//get_private_album_set();
$cpg_numberpic = $CONFIG['thumbcols']; //number of thumbs
$cpg_numberpic=1; //number of thumbs
$cpg_limit = $cpg_numberpic;
$content = '<p align="center">';
function truncate_string_randpic($str)
{
$cpg_maxlength = 15; // maximum lengtht of name in block
if (strlen($str) > $cpg_maxlength)
return substr($str, 0, $cpg_maxlength) . " ...";
else
return $str;
}
// modified by DJMaze
$cpg_result = $db->sql_query("SELECT COUNT(*) FROM ".$cpg_prefix."pictures INNER JOIN ".$cpg_prefix."albums AS a ON (p.aid = a.aid AND ".VIS_GROUPS.") WHERE approved='YES' GROUP BY pid");
//$cpg_result = $db->sql_query("SELECT COUNT(*) from " . $cpg_prefix . "pictures WHERE approved = 'YES' $ALBUM_SET");
$nbEnr = $db->sql_fetchrow($cpg_result);
$cpg_pic_count = $nbEnr[0];
// mysql_free_result($cpg_result);
// if we have more than 1000 pictures, we limit the number of picture returned
// by the SELECT statement as ORDER BY RAND() is time consuming
if ($cpg_pic_count > 1000) {
$cpg_result = $db->sql_query("SELECT COUNT(*) from " . $cpg_prefix . "pictures WHERE approved = 'YES'");
$nbEnr = mysql_fetch_row($cpg_result);
$cpg_total_count = $nbEnr[0];
// mysql_free_result($cpg_result);
$granularity = floor($cpg_total_count / 1000);
$cor_gran = ceil($total_count / $pic_count);
srand(time());
for ($i = 1; $i <= $cor_gran; $i++) $cpg_random_num_set = rand(0, $granularity) . ', ';
$cpg_random_num_set = substr($cpg_random_num_set, 0, -2);
// modified by DJMaze
$cpg_result = $db->sql_query("SELECT pid, filepath, filename, p.aid FROM ".$cpg_prefix."pictures AS p INNER JOIN ".$cpg_prefix."albums AS a ON (p.aid = a.aid AND ".VIS_GROUPS.") WHERE randpos IN ($cpg_random_num_set) AND approved='YES' GROUP BY pid ORDER BY RAND() DESC LIMIT $cpg_limit");
//$cpg_result = $db->sql_query("SELECT pid, aid, filepath, filename FROM " . $cpg_prefix . "pictures WHERE randpos IN ($cpg_random_num_set) AND approved = 'YES' $ALBUM_SET ORDER BY RAND() LIMIT $cpg_limit");
} else {
// modified by DJMaze
$cpg_result = $db->sql_query("SELECT pid, filepath, filename, p.aid FROM ".$cpg_prefix."pictures AS p INNER JOIN ".$cpg_prefix."albums AS a ON (p.aid = a.aid AND ".VIS_GROUPS.") WHERE approved='YES' GROUP BY pid ORDER BY RAND() DESC LIMIT $cpg_limit");
//$cpg_result = $db->sql_query("SELECT pid, aid, filepath, filename FROM " . $cpg_prefix . "pictures WHERE approved = 'YES' $ALBUM_SET ORDER BY RAND() LIMIT $cpg_limit");
}
$cpg_rowset = array();
while ($cpg_row = $db->sql_fetchrow($cpg_result)) {
if ($CONFIG['seo_alts'] == 0) {
$cpg_thumb_title = $cpg_row['filename'];
} else {
if ($cpg_row['title'] != '') {
$cpg_thumb_title = $cpg_row['title'];
} else {
$cpg_thumb_title = substr($cpg_row['filename'], 0, -4);
}
}
stripslashes($cpg_thumb_title);
$content .= '<a href="' . $CPG_M_URL . '&file=displayimage&pos=-' . $cpg_row["pid"] . '"><img src="' . $cpg_row["filepath"] . $CONFIG["thumb_pfx"] . $cpg_row["filename"] . '" border="0" alt="' . $thumb_title . '" title="' . $thumb_title . '"><br>' . truncate_string_randpic($thumb_title) . '</a><br>';
}
$content .= '<br /><a href="' . $CPG_M_URL . '">'.$lang_pagetitle_php["photogallery"].'</a></p>';
?>
|
|
|
|
|
 |
Raven

|
Posted:
Fri Mar 19, 2004 8:19 pm |
|
We have had company since Wednesday. I am not ignoring you . I will look at this as soon as I can. |
|
|
|
 |
TheosEleos

|
Posted:
Fri Mar 19, 2004 8:33 pm |
|
What!
I am the most important thing in your life! Wake up!
lol, I thought you were really serious about not having the time...ever.
Thanks man. |
|
|
|
 |
Raven

|
Posted:
Fri Mar 19, 2004 8:45 pm |
|
My guess will be something in this file: require("modules/".$cpg_dir."/include/load.inc.php");
The author breaks a cardinal rule from FB's instructions on coding modules:
Quote: | but remember to not use reserved variables names like "name" and/or "file" ... |
He is using $name as a variable. Let's start with that as that may be the source. In load.inc.php rename ALL $name to $xxxname and see if that fixes it. I always start with obvious potentials and work into harder stuff. Let me know. |
|
|
|
 |
TheosEleos

|
Posted:
Fri Mar 19, 2004 11:07 pm |
|
I made those changes and no luck.
Here is the load.inc.php for your review.
Code:<?php
// PHPNuke POSTNuke
if (!eregi("modules.php", $_SERVER['PHP_SELF']) && !defined("LOADED_AS_MODULE") &&
!$cpg_block && !defined('INSTALL_PHP')) {
die ("You can't access this file directly...");
}
//define('SILLY_SAFE_MODE', 1);
$CPG_VERSION = '1.2.2b';
if (!$cpg_block) require_once("mainfile.php");
if (!defined('IN_COPPERMINE')) define('IN_COPPERMINE', true);
if (!isset($cpg_name)) $cpg_name = $GLOBALS['name']; // postnuke
if (!isset($cpg_dir)) $cpg_dir = $cpg_name;
$CPG_M_DIR = "modules/" . $cpg_dir;
$CPG_URL = "modules.php?name=" . $cpg_dir;
$CPG_M_URL = $CPG_URL;
$CPG_PROFILE_URL = "forum-userprofile-.html";
global $CONFIG, $CURRENT_ALBUM_DATA, $CPG_URL, $cookie;
// language variables not declared global else where
global $lang_user_admin_menu, $lang_gallery_admin_menu, $lang_cat_list,
$lang_get_pic_data, $lang_pagetitle_php, $lang_charset,
$lang_text_dir, $lang_byte_units, $lang_day_of_week,
$lang_month, $lang_yes, $lang_no,
$lang_back, $lang_continue, $lang_info,
$lang_error, $album_date_fmt, $lastcom_date_fmt,
$lastup_date_fmt, $lasthit_date_fmt, $comment_date_fmt,
$lang_picinfo, $lang_album_admin_menu;
global $template_tab_display, $template_user_list_info_box, $template_album_admin_menu; // index.php
global $template_img_navbar, $template_display_picture, $template_image_rating,
$template_image_comments, $template_add_your_comment; // displayimage.php
global $template_cpg_die, $template_msg_box; // functions.inc.php
global $template_ecard; // displayecard.php
global $template_edit_one_pic; // editDesc.inc.php
global $field_user_id, $field_user_pass, $field_user_name, $field_user_email;
global $first_install_M_DIR,$CPG_PROFILE_URL,$meta_link;
// load postnuke specific part
if (!isset($Version_Num)) {
$CPG_URL = "modules.php?op=modload&name=" . $cpg_dir;
$CPG_M_URL = $CPG_URL."&file=index";
$CPG_PROFILE_URL = "user.php?op=userinfo&uname=";
if (!defined('IN_POSTNUKE')) {
require_once($CPG_M_DIR . "/include/postnuke.php");
}
} else {
if (!defined('LOGOUT_URL')) {
define('LOGOUT_URL', "modules.php?name=Your_Account&op=logout");
define('LOGIN_URL', "modules.php?name=Your_Account"); //&redirect=$cpg_name
define('NEWUSER_URL', "account-new_user.html");
define('ADDUSER_URL', "admin.php?op=mod_users");
// define('ADDUSER_URL', "modules.php?name=Your_Account&file=admin&op=addUser");
define('USERPROF_URL', "modules.php?name=Your_Account&op=edituser");
}
$module_name = $cpg_name;
$field_user_regdate = "user_regdate";
$field_user_avatar = "user_avatar";
// get_lang($module_name);
// load phpnuke 5.5-6.0 specific part
if ($Version_Num[0] < 6 || $Version_Num == "6.0") {
global $dbi;
if (!defined('IN_OLDNUKE')) {
require_once($CPG_M_DIR . "/include/oldnuke.php");
}
}
// load phpnuke 6.5+ specific part
else {
$field_user_id = "user_id";
$field_user_name = "username";
$field_user_pass = "user_password";
$field_user_email = "user_email";
}
}
if (!defined('INSTALL_PHP')) {
// load required settings for this install
$result = $db->sql_fetchrow($db->sql_query("SELECT prefix, dirname FROM cpg_installs WHERE dirname='$cpg_dir'"));
if (!$result || $result[1] != $cpg_dir) {
$error = "The coppermine module \"$cpg_dir\" isn't installed/upgraded yet. <br>Go to ";
if (defined('IN_POSTNUKE')) $error .= "modules.php?op=modload&name=$cpg_dir&file=install to proceed.";
else $error .= "modules.php?name=$cpg_dir&file=install to proceed.";
die ($error);
}
$cpg_prefix = $result[0];
// $first_install_M_DIR gets the first installs module directory is used for language detection
// can be used for other file that are not required to be different between installs
$result = $db->sql_fetchrow($db->sql_query("SELECT dirname FROM cpg_installs WHERE cpg_id=1"));
$first_install_M_DIR = "modules/" .$result[0];
require($CPG_M_DIR . '/include/init.inc.php');
if (!defined('NO_HEADER') && !defined('IN_POSTNUKE')) {
// Set nice page title
$pagetitle = "> ".$CONFIG['gallery_name'];
$sql = "SELECT value FROM " . $cpg_prefix . "config WHERE name='nice_titles'";
$value = $db->sql_fetchrow($db->sql_query($sql));
if ($value[0]) {
$breadcrumb = array();
if (is_numeric($album) && $album > 0) {
$result = db_query("SELECT aid AS id, title, category AS parent FROM {$CONFIG['TABLE_ALBUMS']} WHERE aid = ".$album);
if (mysql_num_rows($result) > 0) {
$breadcrumb[] = mysql_fetch_array($result);
mysql_free_result($result);
}
}
else if (is_numeric($cat) && $cat > 0) {
if ($cat > FIRST_USER_CAT) {
$result = db_query("SELECT $field_user_name AS title FROM {$CONFIG['TABLE_USERS']} WHERE $field_user_id = " . ($cat - FIRST_USER_CAT));
if (mysql_num_rows($result) != 0) {
$row = mysql_fetch_array($result);
$row['id'] = $cat;
$row['parent'] = 1;
$breadcrumb[] = $row;
mysql_free_result($result);
}
}
else {
$result = db_query("SELECT cid as id, parent, catname AS title FROM {$CONFIG['TABLE_CATEGORIES']} WHERE cid='$cat'");
if (mysql_num_rows($result) > 0) {
$breadcrumb[] = mysql_fetch_array($result);
mysql_free_result($result);
}
}
}
get_breadcrumb($breadcrumb);
foreach($breadcrumb as $crumb) {
$pagetitle .= " > ".$crumb['title'];
}
if (!is_numeric($album)) switch ($album) {
case 'lastup':
case 'lastcom':
case 'topn':
case 'toprated':
case 'search':
case 'random':
$pagetitle .= " > ".$lang_meta_album_names[$album];
break;
}else {
//sorted by code
}
if ($pagetitle == "") $pagetitle = "> ".$CONFIG['gallery_name'];
}
else $pagetitle = "> ".$CONFIG['gallery_name'];
}
}
?>
|
|
|
|
|
 |
TheosEleos

|
Posted:
Sat Mar 20, 2004 7:34 am |
|
Come to find out coppermine had so much trouble with user info blocks not working they had to make their own user block.
Too bad they didn't look at the way they made their block and module first.
I would change to their user info block if it didn't stink and yours wasn't the best user info block ever.  |
|
|
|
 |
Raven

|
Posted:
Sat Mar 20, 2004 8:55 am |
|
I still bet it's the variable name duplicity - somewhere. The problem is trying to trace all the INCLUDES. Just as a test, try reversing the ORDER they load in. |
|
|
|
 |
TheosEleos

|
Posted:
Sat Mar 20, 2004 10:55 am |
|
I don't know how to do that.
 |
|
|
|
 |
Raven

|
Posted:
Sat Mar 20, 2004 10:57 am |
|
In your blocks admin adjust the Weight column to reverse the position order. |
|
|
|
 |
TheosEleos

|
Posted:
Sat Mar 20, 2004 11:13 am |
|
I would try to do that but now when I go to my admin page I get this.
Quote: | You can't access this file directly... |
I don't know what I could have done to cause that. The only thing I am working on is this one issue. |
|
|
|
 |
Raven

|
Posted:
Sat Mar 20, 2004 11:45 am |
|
Try this. Use phpmyadmin and edit the nuke_blocks table. Find the coppermine block and set the Active column to 0 (zero). Can you access the admin now? |
|
|
|
 |
TheosEleos

|
Posted:
Sat Mar 20, 2004 11:46 am |
|
I had to go to my databse and turn off the coppermine block.
I bet the user changes I made to that include file did it to me. |
|
|
|
 |
TheosEleos

|
Posted:
Sat Mar 20, 2004 11:46 am |
|
That was cute. We posted together. |
|
|
|
 |
Raven

|
Posted:
Sat Mar 20, 2004 11:47 am |
|
TheosEleos wrote: | I had to go to my databse and turn off the coppermine block.
I bet the user changes I made to that include file did it to me. | Probably. Just restore it. |
|
|
|
 |
TheosEleos

|
Posted:
Sat Mar 20, 2004 11:56 am |
|
I had to restore the coppermine block.
This may not be worth our time. It's not your fault coppermine has poor block programing. |
|
|
|
 |
TheosEleos

|
Posted:
Sat Mar 20, 2004 12:01 pm |
|
I changed the $name to $cpg_name variable in that include file and I can now access the admin page.
I will mess with the blocks weight but if you want to bail on this I understand. |
|
|
|
 |
Raven

|
Posted:
Sat Mar 20, 2004 12:01 pm |
|
Well, it's a conflict between 2 blocks where there is no standard for programming blocks. My info block is simply an enhancement/expansion to the standard userInfo block that comes with nuke. I can't spend anymore time on this right now though. |
|
|
|
 |
TheosEleos

|
Posted:
Sat Mar 20, 2004 12:05 pm |
|
I completely understand. I don't want to either. lol |
|
|
|
 |
TheosEleos

|
Posted:
Tue Mar 23, 2004 4:50 pm |
|
Guess what? It was the load order. I had to move the block to the right and put it below your block. Is there a way to get the blocks on the right to load before the block on the left in block admin? |
|
|
|
 |
Raven

|
Posted:
Tue Mar 23, 2004 5:01 pm |
|
Raven wrote: | I still bet it's the variable name duplicity - somewhere. The problem is trying to trace all the INCLUDES. Just as a test, try reversing the ORDER they load in. | Well, my post from the 20th was pretty close, eh? |
|
|
|
 |
TheosEleos

|
Posted:
Tue Mar 23, 2004 5:16 pm |
|
|
|
 |
|