i have phpnuke 7.0 and have installed the hot or not module from nukecops downloads page. i get this error..
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/videonob/public_html/main/includes/sql_layer.php on line 238
There are images in the database
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/videonob/public_html/main/includes/sql_layer.php on line 238
There are images inactive
can someone redirect me or tell me how to fix this in newb language...i have already done an extensive search for this here to no avail. thanks in advance to anyone who can help.
dant1259 Captain
Joined: Jan 16, 2004
Posts: 336
Posted:
Thu Jun 02, 2005 10:51 am
I did actually get a version to open in the admin panel of phpnuke 7.6
In the admin/modules/hotornot.php you must fix all the sql_fetch_row lines. then you have to fix the top of the script which authorizes the admin.
This will let in open in the admin panel but it does not yet solve all the problems
It will write data to the mysql database but it is not reading the data back. So that is where I'm currently at.
Here is the admin/modules/hotornot.php file, if you care to see what is happening
-------------------------------------------------------------------------------------
Code:
<?php
# ******************************************************************************
# PHPnuke Hot or Not v1.0
#
# for PHPnuke 5.5
#
# Download at: http://www.trashbin.tk
#
# Copyright (C) 2002 by WebStyle http://www.trashbin.tk
#
# 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.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# ******************************************************************************
if(is_admin($admin)) {
if(!is_array($admin)) {
$adm = base64_decode($admin);
$adm = explode(":", $adm);
$aname = "$adm[0]";
} else {
$aname = "$admin[0]";
}
list($radminsuper) = $db->sql_fetchrow($db->sql_query("select radminsuper from ".$prefix."_authors where aid='$aname'"));
$radminuser = 0;
if ($Version_Num >= 7.5) {
$row = $db->sql_fetchrow($db->sql_query("SELECT title, admins FROM ".$prefix."_modules WHERE title='Your_Account'"));
$row2 = $db->sql_fetchrow($db->sql_query("SELECT name, radminsuper FROM ".$prefix."_authors WHERE aid='$aname'"));
$admins = explode(",", $row['admins']);
for ($i=0; $i < sizeof($admins); $i++) {
if ($row2['name'] == "$admins[$i]" AND $row['admins'] != "") {
$radminuser = 1;
}
}
} else {
list($radminuser) = $db->sql_fetchrow($db->sql_query("select radminuser from ".$prefix."_authors where aid='$aname'"));
}
}
//upload image to server
OpenTable();
global $img_path, $img_upload_maxsize;
echo "<form ENCTYPE=\"multipart/form-data\" method=\"post\" action=\"admin.php\">"
."<font class=\"option\"><b>"._HOTORNOTUPLOAD."</b></font><br><br>";
if ($uploadmsg != "") {
echo "<font color=\"#cc0000\"><b>$uploadmsg</b></font><br><br>";
}
echo "<input type=\"hidden\" name=\"op\" value=\"hotornotimageupload\">"
."<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"$img_upload_maxsize\">"
.""._HOTORNOTUPLOADFILE.": <input type=\"file\" name=\"userfile\" size=\"50\"><br><br>"
.""._HOTORNOTUPLOADDIR.": <select name=\"img_updir\">";
//get directories from img path
if ($handle = @opendir("$img_path")) {
while (false !== ($dir = readdir($handle))) {
if ($dir != "." && $dir != "..") {
//assume that there are no file in the directory!!!
echo "<option value=\"$dir\">$dir</option>";
}
}
}
echo "</select>";
echo " <input type=\"submit\" value=\""._HOTORNOTUPLOAD."\">"
."</form>";
CloseTable();
echo "<br>";
include ("footer.php");
}
//Add category to database
function addcategory($cat_title, $cat_desc, $cat_par_id = 0) {
global $prefix, $dbi;
$error = _ERRORTHECATEGORY;
//Check if category with same name already exists
$result = sql_query("select cat_id from ".$prefix."_hotornot_cat where cat_title='$cat_title' and cat_par_id = $cat_par_id", $dbi);
$numrows = sql_num_rows($result, $dbi);
if ($numrows>0) {
//Display error msg
include("header.php");
GraphicAdmin();
OpenTable();
echo "<br><center><font class=\"option\">"
."<b>$error $title "._ALREADYEXIST."</b><br><br>"
.""._GOBACK."<br><br>";
CloseTable();
include("footer.php");
} else {
//Insert category into database. By default it is inactive and not show in block!
sql_query("insert into ".$prefix."_hotornot_cat values (NULL, '$cat_title', '$cat_desc', $cat_par_id, 1, 1, 0, 1)", $dbi);
Header("Location: admin.php?op=hotornot");
}
}
//Add image to database
function addimage($vote_dir, $vote_file, $vote_link, $vote_cat_id, $redirect = true) {
global $prefix, $dbi, $nukeurl, $img_path;
//check if mandatory fields are filled.
if ($vote_dir != "" && $vote_file != "") {
//check if image already exists
$result = sql_query("select vote_id from ".$prefix."_hotornot_votes where vote_dir = '$vote_dir' and vote_file = '$vote_file'", $dbi);
if (sql_num_rows($result, $dbi) == 0) {
//check if vote_link is given, otherwise default to same url on $nukeurl
if (is_null($vote_link) || $vote_link == "") {
$vote_link = "$nukeurl/$img_path/$vote_dir/$vote_file";
}
//get image fullsize size to store in database
$img_size = getimagesize($vote_link);
$vote_imgwidth = $img_size[0];
$vote_imgheight = $img_size[1];
//insert image into database!
sql_query("insert into ".$prefix."_hotornot_votes (vote_cat_id, vote_dir, vote_file, vote_link, vote_imgwidth, vote_imgheight) values ($vote_cat_id, '$vote_dir', '$vote_file', '$vote_link', $vote_imgwidth, $vote_imgheight)", $dbi);
$return = true;
} else {
$return = false;
}
}
if ($redirect) {
//go to content page of category
editcontent($vote_cat_id);
}
return $return;
}
//save image changes to database
function saveimage($vote_id, $vote_dir, $vote_file, $vote_link, $vote_active, $cat_id) {
global $prefix, $dbi;
//check mandatory fields
if ($vote_id != "" && $vote_dir != "" && $vote_file != "") {
sql_query("update ".$prefix."_hotornot_votes set vote_dir = '$vote_dir', vote_file = '$vote_file', vote_link = '$vote_link', vote_active = $vote_active where vote_id = $vote_id", $dbi);
}
editcontent($cat_id);
}
function deleteimage($vote_id, $cat_id) {
global $prefix, $dbi;
if (isset($vote_id) && $vote_id > 0) {
//delete all its comments
sql_query("delete from ".$prefix."_hotornot_comments where c_vote_id = $vote_id", $dbi);
//delete image from database by id
sql_query("delete from ".$prefix."_hotornot_votes where vote_id = $vote_id", $dbi);
}
editcontent($cat_id);
}
//Get content of directory!
function getDirC($dir, $preview, $cat_id, $vote_link = "") {
global $prefix, $dbi, $img_path, $img_type;
include ("header.php");
GraphicAdmin();
OpenTable();
//get category title
$result=sql_query("select cat_title from ".$prefix."_hotornot_cat where cat_id = $cat_id", $dbi);
list($cat_title) = $db->sql_fetchrow($db->sql_query($result, $dbi));
echo "<center><font class=\"title\"><b>"._HOTORNOTADDDIRECTORY." - $img_path/$dir</b></font></center><br>";
if ($dir != "") {
//get files from given directory
$path = array();
$files = array();
if ($handle = @opendir("$img_path/$dir")) {
while (false !== ($file = readdir($handle))) {
$bpush = false;
if ($file != "." && $file != "..") {
//check if file type is allowed!
foreach ($img_type as $type) {
if (substr($file, strlen($file) - strlen($type)) == $type) {
$bpush = true;
}
}
//if image allowed, put in array
if ($bpush) {
//check if image does not already exists
$result = sql_query("select vote_id from ".$prefix."_hotornot_votes where vote_dir = '$dir' and vote_file = '$file'", $dbi);
if (sql_num_rows($result, $dbi) == 0) {
array_push($files, $file);
$file = "$dir/$file";
array_push($path, $file);
}
}
}
}
closedir($handle);
}
echo "<p><table border=\"1\" width=\"85%\"><tr><th>Image Path</th><th>File Size</th></tr>";
if (count($path) == 0) {
echo "<tr><td colspan=\"2\" align=\"center\">No new images found in $img_path/$dir</td></tr>";
} else {
global $nukeurl;
foreach ($path as $pfile) {
//add link to preview image!
echo "<tr><td><a href=\"$nukeurl/$img_path/$pfile\" target=\"preview\">$img_path/$pfile</a></td>";
echo "<td>".(filesize("$img_path/$pfile")/1000)." kb</td></tr>";
}
}
echo "</table></p>";
}
if ($preview == "") $preview = 1;
if ($preview == 1) {
//build form to add to database
//default link to fullsize image!
$vote_link = "$nukeurl/$img_path/$dir/fullsize";
echo "<table border=\"0\"><tr><td valign=\"top\"><form action=\"admin.php\" method=\"post\">"
."<input type=\"hidden\" name=\"op\" value=\"hotornotdirc\">"
."<input type=\"hidden\" name=\"preview\" value=\"1\">"
."<input type=\"hidden\" name=\"vote_cat_id\" value=\"$cat_id\">"
.""._HOTORNOTPATH.": $img_path/<input type=\"text\" size=\"21\" name=\"dir\" value=\"$dir\">"
." <input type=\"submit\" value=\""._HOTORNOTPREVIEW."\"></form></td></tr>"
."<tr><td valign=\"bottom\" align=\"left\">"
."<form action=\"admin.php\" method=\"post\">"
."<input type=\"hidden\" name=\"op\" value=\"hotornotdirc\">"
."<input type=\"hidden\" name=\"preview\" value=\"0\">"
."<input type=\"hidden\" name=\"dir\" value=\"$dir\">"
."<input type=\"hidden\" name=\"vote_cat_id\" value=\"$cat_id\">"
.""._HOTORNOTFULLPATH.":<br><input type=\"text\" size=\"100\" maxlength=\"255\" name=\"vote_link\" value=\"$vote_link\"></tr>"
."<tr><td valign=\"bottom\" align=\"center\">"
."<input type=\"submit\" value=\""._HOTORNOTADDTODB."\"></form></td></tr></table>";
}
if ($preview == 0) {
//add images to database!!!
if (count($files) != 0) {
foreach ($files as $file) {
if ($vote_link != "") $hot_link = $vote_link."/$file";
if (addimage($dir, $file, $hot_link, $cat_id, false)) {
echo "added: $dir/$file in $cat_title<br>";
} else {
echo "$dir/$file already in database!<br>";
}
}
}
echo "<p><a href=\"admin.php?op=hotornoteditcat&cat_id=$cat_id\">"._HOTORNOTBACKTO." $cat_title.</a></p>";
}
CloseTable();
include("footer.php");
}
function fiximagesizes() {
include ("header.php");
OpenTable();
global $dbi, $prefix;
$i = 1;
echo "<table>";
$result = sql_query("select vote_id, vote_link from ".$prefix."_hotornot_votes", $dbi);
while(list($vote_id, $vote_link) = $db->sql_fetchrow($db->sql_query($result, $dbi))) {
$img_size = getimagesize($vote_link);
echo "<tr><td>$i</td><td>$vote_link</td><td>".$img_size[0]."</td><td>".$img_size[1]."</td></tr>";
sql_query("update ".$prefix."_hotornot_votes set vote_imgwidth = ".$img_size[0].", vote_imgheight = ".$img_size[1]." where vote_id = $vote_id", $dbi);
$i++;
}
echo "</table>";
CloseTable();
include ("footer.php");
}
switch ($op) {
case "hotornot":
hotornot($uploadmsg);
break;
case "hotornotaddcat";
addcategory($cat_title, $cat_desc);
break;
case "hotornotmodcat":
modifycategory($cat_id);
break;
case "hotornotsavecat":
savecategory($cat_id, $cat_title, $cat_desc, $cat_active, $cat_block, $cat_view, $cat_userupload);
break;
case "hotornotdelcat":
deletecategory($cat_id, $del_ok);
break;
case "hotornoteditcat":
editcontent($cat_id);
break;
case "hotornotadd":
addimage($vote_dir, $vote_file, $vote_link, $vote_cat_id);
break;
case "hotornotdel":
deleteimage($vote_id, $cat_id);
break;
case "hotornotedit":
editimage($vote_id, $cat_id);
break;
case "hotornotsave":
saveimage($vote_id, $vote_dir, $vote_file, $vote_link, $vote_active, $cat_id);
break;
case "hotornotdelc":
editimage($vote_id, $cat_id, $cid);
break;
case "hotornotdirc":
getDirC($dir, $preview, $vote_cat_id, $vote_link);
break;
case "hotornotaddvotelink":
addvotelink($cat_id);
break;
case "hotornotfix":
fiximagesizes();
default:
hotornot($uploadmsg);
}
} else {
//show message if user is not admin.
echo "Access Denied";
}
?>
dant1259 Captain
Joined: Jan 16, 2004
Posts: 336
Posted:
Thu Jun 02, 2005 5:39 pm
Ok, I have got it running successfully in 7.6 The solution was less complex than I origianlly thought.
Go ahead and do the install per the readme file in hotornot
in the admin/modules/hotornot.php file replace the top few lines for the admin authorization with the following:
Code:
if(is_admin($admin)) {
if(!is_array($admin)) {
$adm = base64_decode($admin);
$adm = explode(":", $adm);
$aname = "$adm[0]";
} else {
$aname = "$admin[0]";
}
list($radminsuper) = $db->sql_fetchrow($db->sql_query("select radminsuper from ".$prefix."_authors where aid='$aname'"));
$radminuser = 0;
if ($Version_Num >= 7.5) {
$row = $db->sql_fetchrow($db->sql_query("SELECT title, admins FROM ".$prefix."_modules WHERE title='Your_Account'"));
$row2 = $db->sql_fetchrow($db->sql_query("SELECT name, radminsuper FROM ".$prefix."_authors WHERE aid='$aname'"));
$admins = explode(",", $row['admins']);
for ($i=0; $i < sizeof($admins); $i++) {
if ($row2['name'] == "$admins[$i]" AND $row['admins'] != "") {
$radminuser = 1;
}
}
} else {
list($radminuser) = $db->sql_fetchrow($db->sql_query("select radminuser from ".$prefix."_authors where aid='$aname'"));
}
}
if ($radminsuper == 1 || $radminuser == 1) {
The module ran perfectly with this small fix.
If you have problems finding the module just pm me and I'll be happy to email it to you.
womble Guest
Posted:
Tue Jun 07, 2005 1:42 am
Thanks dant1259, that fixes most of my module.. but when I try to upload an image i get this warning...
Warning: strstr(): Empty delimiter. in /home/me/public_html/cms/admin/modules/hotornot_upload.php on line 67
and it doesnt upload the file..
womble Guest
Posted:
Tue Jun 07, 2005 1:47 am
..also when I paste the code
Code:
###################################################
# Code for Hot or Not module by ::Trashbin:: 2002 #
###################################################
require_once("modules/Hot_Or_Not/rate.php");
###################################################
into my mainfile.php it breaks my site..
dant1259 Captain
Joined: Jan 16, 2004
Posts: 336
Posted:
Tue Jun 07, 2005 3:28 am
I'll have to go thru and look but make sure you have your files/folders chmod to the right permission. I'll take a look at my code later today and let you know. -- off to work
womble Guest
Posted:
Tue Jun 07, 2005 1:00 pm
The readme didnt say anything about CHMODing so I dont think I changed the permisions on any of the files.....
Ok that would be great!! Thanks!!
dant1259 Captain
Joined: Jan 16, 2004
Posts: 336
Posted:
Tue Jun 07, 2005 3:17 pm
which version of hot or not do you have. This is the one I'm running
Hot or Not Version ChicagoBase.com 1
This is the only one I found that worked. If you don't have it pm your email and I'll send it to you.
here is the file to set the permissions on
Please make sure that you have set the permissions of "Hot_Or_Not" and "users" directories to 777 or writeable by everyone.
womble Guest
Posted:
Tue Jun 07, 2005 8:54 pm
The only version ive been able to find is Hot or Not v2.0 beta 1,
And I CHMOD the 2 directories but still not working.
womble Nuke Cadet
Joined: Jun 08, 2005
Posts: 1
Posted:
Wed Jun 08, 2005 1:37 am
WooHoo, I fixed it
What I was doing wrong was not putting the correct 'sever' path in the rate.php file I was using my http path... so now the mainfile with the code added to it is working now
Thanks for all your help
guest555 Guest
Posted:
Wed Jun 15, 2005 11:31 am
help im using version Hot or Not v2.0 beta 1 and i cant upload a file it says "access denied"