This works perfectly fine for me, when I have the permissions to view the albums on EVERYBODY. But when I change it to LOGGED-IN it dissapears. Anyway to allow both LOGGED-IN and to view the top 20 views?
jackc4317
Joined: 2003-12-25
Posts: 11
Posted: Wed, 2003-12-31 09:40
nevermind it does it automatically. You just gotta wait
dackerman
Joined: 2003-02-19
Posts: 15
Posted: Thu, 2004-01-01 02:41
I have installed the most recent script and I get no errors...but all the tables are blank with no images?
It says the #1, #2, #3, etc, but there are no images there. I have placed this in my gallery folder...
FDFLocke
Joined: 2004-01-02
Posts: 10
Posted: Sun, 2004-01-04 01:14
Hi,
i´ve got exactly the same problem. No errors but also no thumbs or view stats...
what´s wrong?!
FDFLocke
Joined: 2004-01-02
Posts: 10
Posted: Tue, 2004-01-06 14:19
ok I solved this one: just change in your php.ini file the memory limit to 32M or higher
another problem with the caption text: the images won´t display correctly if have a line break (<br>) in your caption.
I´m still trying to ingegrate the topviews.php in php nuke, does anyone know how that works?
steffx
Joined: 2003-12-19
Posts: 2
Posted: Fri, 2004-01-09 21:13
Hello
the problem are not the <br> but the newlines and the returns.
All I want is to either have a random photo(major issues trying to get that to work) or my #1 most viewed photo. Can someone give me an answer on how best to do either(prefer the latter). Thanks,
D :D
Nicko!
Joined: 2003-12-05
Posts: 26
Posted: Thu, 2004-01-15 21:58
Hi there,
Love this script, I can get it working perfectly when I access is directly and it does seem to show the true top 20.
I'm a complete PHP virgin so I was wondering if someone could quickly tell me how to put a link on the front page of the gallery so that in the header there is a link to run the top 20 script.
This would be a great help as I can't seem to work it out for myself, don't even know which file to change.
As has been the case with most of my replys on here, it didnt help me out one bit. Glad you got it to work.
Nicko!
Joined: 2003-12-05
Posts: 26
Posted: Tue, 2004-01-20 16:25
Daryl.com - If you want to just have your most viewed photo appear, it may be possible to alter the view_top.php file to just find the most viewed by changing just one variable.
I don't have much PHP experience but was able to alter the code to show just the top ten, I assume it's possible to do it the same way for just the top 1.
I realized a modified version of top views / clicks to get it working with postnuke.
The modifications are almost insignificant :oops: and are based on Photofun's hack of version 0.6. Anyway, also modules/gallery/index.php needs to be modified.
Full and detailed installation instructions are included in the zip file you can download from here.
Sorry but I can't download it. What is the problem? Can you post the source you used?
Marco
mrcolj
Joined: 2004-01-06
Posts: 79
Posted: Tue, 2004-03-30 13:36
It was v8, straight from this site, exactly as is except for my counter script at the bottom. I renamed it viewtop from view_top. I just uploaded it into the folder, and the link on the main page quit working. It brings up a blank page with the gallery header at the top. (www.colinandbethany.com/gallery/viewtop.php)
motumboe
Joined: 2004-03-19
Posts: 17
Posted: Tue, 2004-03-30 14:32
looking at the html of the page you get, it seems that the php stops at some point after the
includeHtmlWrap("gallery.header");
call. My advice is to place a line like this one:
print "debug #001";
every few lines of code, especially after the includeHtmlWrap call, so you can understand where the problem is.
Good Luck!
Marco
mrcolj
Joined: 2004-01-06
Posts: 79
Posted: Tue, 2004-03-30 15:43
So I put in some debug lines, and going onto my site will show the results. My code right now, from the first to the last debug line, is:
global $displayNo;
global $maxStore;
global $gallery;
global $albumDB;
global $minSearch;
global $displayList;
global $sortBy;
global $timeSort;
global $time;
// max image links to store in cache file
$maxStore = 200;
// min amount of clicks that picture must have in order to be entered into array (or considered)
$minSearch = 2;
// sortBy tells the search function to only use last updated pics etc
// 0 = sort by clicks through whole gallery
// 1 = sort by last uploaded pics then clicks
// 2 = sort by last changed album then clicks
// depending whats entered at the url show for amount of time specified
switch ($time)
{
case "hour":
$timeSort = $hour;
break;
case "day":
$timeSort = $day;
break;
case "week":
$timeSort = $week;
break;
case "month":
$timeSort = $month;
break;
case "twomonths":
$timeSort = $twomonths;
break;
case "threemonths":
$timeSort = $threemonths;
break;
case "sixmonths":
$timeSort = $sixmonths;
break;
case "year":
$timeSort = $year;
break;
case "twoyears":
$timeSort = $twoyears;
break;
}
// set the default for timeSort here - if nothing specified in url
if(!$timeSort) {
$timeSort = $year;
$time = "year"; // currently set to past year
}
// number of images to display
// if nothing is specified in url (ie: www.site.com/gallery/view-top.php?display=100)
// then display the default - currently set at 20
if(!$display) { $displayNo = 20; }
else { $displayNo = $display; }
// owner to restrict by
// if nothing is specified in url (ie: www.site.com/gallery/view-top.php?owner=joe)
// then display the default - currently set at 20
if(!$owner) { $ownerinput = ""; }
else { $ownerinput = $owner; }
// whether to display top 10 etc as a list or not - default is to not show as list
if(!$list) { $displayList = 0; }
else { $displayList = 1; }
/* Read the album list */
$albumDB = new AlbumDB(FALSE);
$gallery->session->albumName = "";
/* Initializing the seed */
srand ((double) microtime() * 1000000);
// set the cache file name
define(CACHE_FILE, $gallery->app->albumDir . "/top-pics-$ownerinput.cache");
// here we rebuild the cache file every 12 hours (43200 seconds)
define(CACHE_EXPIRED, 3600);
// Check the cache file to see if it's up to date
$rebuild = 1;
if (fs_file_exists(CACHE_FILE)) {
$stat = fs_stat(CACHE_FILE);
$mtime = $stat[9];
if (time() - $mtime < CACHE_EXPIRED) {
$rebuild = 0;
}
}
// if the cache is not upto date, older than the time you've specified, then rebuild the cache file
if ($rebuild) {
scanAlbums();
saveCache();
readCache();
}
// else just read the cache file into arrays
else {
readCache();
}
// print the top 10/20/100 or whatever you specify
printTop();
print "debug #001a";
/*
* this function reads in the top 10/20/100 whatever you want from the cache file
* this information, that it reads in, will be as old as the cache file
*/
} // end if
} // checking owner
} // end else
} // end for NumPhotos
} // end if($album)
} // end recurseAlbums()
function scanAlbums() {
print "debug #006";
global $albumDB;
global $gallery;
global $minSearch;
global $arrayTopviewed;
global $position;
global $ownerinput;
$arrayTopviewed = array();
$position = 0;
$page = 1;
/* If there are albums in our list, display them in the table */
$numAlbums = $albumDB->numAlbums($gallery->user);
$numPhotos = $albumDB->getCachedNumPhotos($gallery->user);
} // end if
} // checking owner input
} // end else
} // end for NumPhotos
print "<tr>";
print "<!-- End Album Column Block -->";
} // end for
// sort the array of pics
arsort($arrayTopviewed);
// print contents of array - for debug purposes
//print_r($arrayTopviewed);
// save the cache to disk
saveCache();
} // end of scanAlbums()
function printTop() {
print "debug #007";
....
motumboe
Joined: 2004-03-19
Posts: 17
Posted: Tue, 2004-03-30 21:46
Ok, that's a good start 8)
The problem is in the scanAlbums function: you need to put more debug lines at the inside of that function.
I got a similar problem when the cache has to be rebuilt; so I found out that the cache can be generated only by a user with administrator privileges. May be it is the same problem... I will try and see if I can solve this problem and send an updated release to the original author.
Cya
Marco
mrcolj
Joined: 2004-01-06
Posts: 79
Posted: Thu, 2004-04-01 17:26
Here's my code, with multiple debugging notes inserted (quoted and bolded for legibility): Result page
The problem's somewhere in that 6bc section, but I don't know where else I can put debugging notes without messing something up...
Quote:
function scanAlbums() { print "debug #006--";
global $albumDB;
global $gallery;
global $minSearch;
global $arrayTopviewed;
global $position;
global $ownerinput;
$arrayTopviewed = array();
$position = 0;
$page = 1; print "debug #006a--";
/* If there are albums in our list, display them in the table */
$numAlbums = $albumDB->numAlbums($gallery->user);
$numPhotos = $albumDB->getCachedNumPhotos($gallery->user); print "debug #006b--";
// start of recurse code...
} // end if
} // checking owner input
} // end else
} // end for NumPhotos print "debug #006d--";
print "<tr>"; print "debug #006e--";
print "<!-- End Album Column Block -->";
motumboe
Joined: 2004-03-19
Posts: 17
Posted: Fri, 2004-04-02 12:35
Colin,
I'll try duplicating your problem in the next days. If I find something, I'll let you know.
cya,
Marco
mrcolj
Joined: 2004-01-06
Posts: 79
Posted: Tue, 2004-04-06 21:55
Any updates?
motumboe
Joined: 2004-03-19
Posts: 17
Posted: Tue, 2004-04-06 22:07
I'm sorry but I'm very busy in these days. As soon as I have news, I'll post them here
myriagon
Joined: 2004-01-22
Posts: 130
Posted: Tue, 2004-04-06 22:19
Colin - I've seen similar problems for a couple of users with my stats.php script which is similar to this script. I suspect the problem is caused by a resource limit. I would be interested if you could try stats.php - available from here - and see if that has the same issue.
i think its in gallery not in top view, i have it when i tweak columns and rows in any view page. but only when i use 1 as a colum or row. I bypassed the error by not using a 1 in colums or 1 in rows. this can be found in the properties area. I am noticing that a few of the mods on gallery are becoming a little out dated. and probably should be removed from the website. In perticular the ones that are no longer even supported by their original writers for which there is two.
Hope this helps.
KHSjr
kelvinfish
Joined: 2004-04-27
Posts: 2
Posted: Wed, 2004-04-28 16:45
Thanks. It works finally! And I have bypassed the code "isAlbumName...."
I've encountered the problem of "some of the thumbnails can be shown, and some don't......" I found that the problem caused by the "Caption" of the photo. If the caption (text) of the photo contains "<BR>" or you've hit "Return" for next line, the thumbnail cannot be shown.
...Fish
prwood
Joined: 2003-11-11
Posts: 57
Posted: Mon, 2004-05-10 17:51
I've found and corrected a few bugs in view-top.php version 0.8.0, and at jelwell's advice am informing you all of such. The changes are summarized as follows:
* Made view-top compatible with Gallery 1.4.3 by changing calls to isAlbumName to use getAlbumName instead. The need for this was noted in the Gallery ChangeLog with versions 1.4.3-cvs-b105 and 1.4.3-cvs-b106.
* Fixed bug where view-top was using editCaption() to grab photo captions. This caused weirdness in various situations. For example, when a user was logged in to gallery with edit rights for a photo, a call to editCaption() would return not only the caption itself, but also a link to edit the photo. This, obviously, isn't pretty when included in a context where no html tags are expected. Instead, view-top now uses $gallery->album->getCaption to get just the caption itself.
*Changed the default value of CACHE_EXPIRED to reflect the comment text above it (43200 seconds)
* A few self-serving HTML cleanups, for example making sure that html tag properties are quoted where possible.
These changes have all been tested on my Gallery 1.4.3-pl1 installation. The fix to make it work with Gallery 1.4.3 will probably cause it to break on earlier versions of Gallery, so please stick to an older view-top if that's your situation.
I have attached the new version of the file to this post.
Please let me know if you have any questions!
Thanks,
Peter
Zatte_Aap
Joined: 2003-10-26
Posts: 11
Posted: Tue, 2004-05-11 07:19
prwood, i still get an error
Quote:
Fatal error: Maximum execution time of 60 seconds exceeded in /home/virtual/site6/fst/var/www/html/gallery/classes/Album.php on line 161559812
Fatal error: Maximum execution time of 60 seconds exceeded in Unknown on line 0
prwood
Joined: 2003-11-11
Posts: 57
Posted: Tue, 2004-05-11 11:23
Zatte_Aap wrote:
prwood, i still get an error
Quote:
Fatal error: Maximum execution time of 60 seconds exceeded in /home/virtual/site6/fst/var/www/html/gallery/classes/Album.php on line 161559812
Fatal error: Maximum execution time of 60 seconds exceeded in Unknown on line 0
How many photos do you have in your gallery, total?
Shadow_Wolf
Joined: 2004-04-03
Posts: 181
Posted: Tue, 2004-05-11 13:05
I decided to try out the view-top.php and it works great. It is fairly useful and will come in handy with what I have in mind. The only small issue is that some of the most viewed images are from the Mature section.
Is there someplace I can do an exclude in the view-top so that certain albums get excluded from being counted?
Zatte_Aap
Joined: 2003-10-26
Posts: 11
Posted: Tue, 2004-05-11 16:34
prwood
i got about ~ 900 photo's on my site.
My site is [url]www.karbor.com/gallery[/url]
and the view-top file is located at [url]www.karbor.com/gallery/view_top.php[/url]
The old script (v .08 in combination with old gallery version) worked fine with my old gallery and back then I even had ~ 2000 photo's online!
btw, loading the url might take a while, so the error will be displayed in about 30 seconds...
prwood
Joined: 2003-11-11
Posts: 57
Posted: Tue, 2004-05-11 17:44
Zatte_Aap wrote:
prwood
i got about ~ 900 photo's on my site.
My site is [url]www.karbor.com/gallery[/url]
and the view-top file is located at [url]www.karbor.com/gallery/view_top.php[/url]
The old script (v .08 in combination with old gallery version) worked fine with my old gallery and back then I even had ~ 2000 photo's online!
btw, loading the url might take a while, so the error will be displayed in about 30 seconds...
I haven't been able to load the url at all. It has been several minutes and the page hasn't loaded. I doubt that any of the changes I have made would cause a timeout on your website.
I have written some debugging code into the script, so re-download the file here:
Download that and replace your current version with it. Then, remove your cache file (located in the top level of your album directory, probably named "top-pics-.cache" or something like that). Only after removing the cache file, re-run the view-top script, copy down the debugging information it prints out, and paste it in here. It will only print that all out the first time it runs, so be sure to cope and paste!
Thanks.
jackc4317
Joined: 2003-12-25
Posts: 11
Posted: Mon, 2004-05-24 20:00
Great job on the fix for 1.4.3pl version! I have one question. How do I edit the table to get rid of the borders? I tried chaning the border=0 and cellpadding=0 in the table in view_top.php, but it doesn't change. I also want to center it, but whatever I change to the php there is no change when i reload it. Am I doing something wrong?
prwood
Joined: 2003-11-11
Posts: 57
Posted: Mon, 2004-05-24 20:05
jackc4317 wrote:
Great job on the fix for 1.4.3pl version! I have one question. How do I edit the table to get rid of the borders? I tried chaning the border=0 and cellpadding=0 in the table in view_top.php, but it doesn't change. I also want to center it, but whatever I change to the php there is no change when i reload it. Am I doing something wrong?
Hm. You should only need to change line 453 in the printTop function:
In the original, border is set to "2", and I changed it to "0". You will need to save this change and make sure to re-upload the copy to your web server. You should also make sure to flush out your browser's cache of that page by holding shift and hitting the reload button.
Posts: 11
This works perfectly fine for me, when I have the permissions to view the albums on EVERYBODY. But when I change it to LOGGED-IN it dissapears. Anyway to allow both LOGGED-IN and to view the top 20 views?
Posts: 11
nevermind it does it automatically. You just gotta wait
Posts: 15
I have installed the most recent script and I get no errors...but all the tables are blank with no images?
It says the #1, #2, #3, etc, but there are no images there. I have placed this in my gallery folder...
Posts: 10
Hi,
i´ve got exactly the same problem. No errors but also no thumbs or view stats...
what´s wrong?!
Posts: 10
ok I solved this one: just change in your php.ini file the memory limit to 32M or higher
another problem with the caption text: the images won´t display correctly if have a line break (<br>) in your caption.
I´m still trying to ingegrate the topviews.php in php nuke, does anyone know how that works?
Posts: 2
Hello
the problem are not the <br> but the newlines and the returns.
try
$caption[$i] = preg_replace('/\n/', '<br>', $caption[$i]);
$caption[$i] = preg_replace('/\r/', '', $caption[$i]);
in function saveCache()
before the line
fwrite($fd, "$clicks[$i]|$url[$i]|$caption[$i]|$tag[$i]|$upload[$i]|$updated[$i]\n");
for me this works fine !
steffx
Posts: 43
All I want is to either have a random photo(major issues trying to get that to work) or my #1 most viewed photo. Can someone give me an answer on how best to do either(prefer the latter). Thanks,
D :D
Posts: 26
Hi there,
Love this script, I can get it working perfectly when I access is directly and it does seem to show the true top 20.
I'm a complete PHP virgin so I was wondering if someone could quickly tell me how to put a link on the front page of the gallery so that in the header there is a link to run the top 20 script.
This would be a great help as I can't seem to work it out for myself, don't even know which file to change.
View my gallery at: www.nickbrooke.co.uk/brumski/gallery
and to run the script: www.nickbrooke.co.uk/brumski/gallery/view_top.php
Cheers
Nick
Posts: 26
I've got it working now.
Cheers for the script- it's quality
http://www.nickbrooke.co.uk/brumski/gallery
Posts: 43
As has been the case with most of my replys on here, it didnt help me out one bit. Glad you got it to work.
Posts: 26
Daryl.com - If you want to just have your most viewed photo appear, it may be possible to alter the view_top.php file to just find the most viewed by changing just one variable.
I don't have much PHP experience but was able to alter the code to show just the top ten, I assume it's possible to do it the same way for just the top 1.
Hope you can get something sorted
Posts: 47
This is not working :S. the script doesn't generate any errors or warnings but pictures simply dont appear. the site is :
http://www.promoview.net/gallery/view_top_v6.php?sort=uploaded&time=month
please help me out
Posts: 17
I realized a modified version of top views / clicks to get it working with postnuke.
The modifications are almost insignificant :oops: and are based on Photofun's hack of version 0.6. Anyway, also modules/gallery/index.php needs to be modified.
Full and detailed installation instructions are included in the zip file you can download from here.
You can view a working demo here.
I would like to implement a fully standard-compliant postnuke module, if anyone want to help me, please leave a message
Posts: 79
Mine's just not working. Anyone want to look at it?
www.colinandbethany.com/gallery/viewtopic.php
Thank
Posts: 17
Sorry but I can't download it. What is the problem? Can you post the source you used?
Marco
Posts: 79
It was v8, straight from this site, exactly as is except for my counter script at the bottom. I renamed it viewtop from view_top. I just uploaded it into the folder, and the link on the main page quit working. It brings up a blank page with the gallery header at the top. (www.colinandbethany.com/gallery/viewtop.php)
Posts: 17
looking at the html of the page you get, it seems that the php stops at some point after the
includeHtmlWrap("gallery.header");
call. My advice is to place a line like this one:
print "debug #001";
every few lines of code, especially after the includeHtmlWrap call, so you can understand where the problem is.
Good Luck!
Marco
Posts: 79
So I put in some debug lines, and going onto my site will show the results. My code right now, from the first to the last debug line, is:
<?php
// Hack prevention.
if (!empty($HTTP_GET_VARS["GALLERY_BASEDIR"]) ||
!empty($HTTP_POST_VARS["GALLERY_BASEDIR"]) ||
!empty($HTTP_COOKIE_VARS["GALLERY_BASEDIR"])) {
print "Security violation\n";
exit;
}
require($GALLERY_BASEDIR . "init.php");
//
// global variables
//
global $displayNo;
global $maxStore;
global $gallery;
global $albumDB;
global $minSearch;
global $displayList;
global $sortBy;
global $timeSort;
global $time;
// max image links to store in cache file
$maxStore = 200;
// min amount of clicks that picture must have in order to be entered into array (or considered)
$minSearch = 2;
// sortBy tells the search function to only use last updated pics etc
// 0 = sort by clicks through whole gallery
// 1 = sort by last uploaded pics then clicks
// 2 = sort by last changed album then clicks
if($sort == "uploaded") { $sortBy = 1; }
elseif($sort == "updated") { $sortBy = 2; }
else { $sortBy = 0; } // default to just normal click sorting onn whole gallery
// timeSort tells search function how many seconds to go back by if sortBy equals 1 or 2
$hour = 3600; // 3600 seconds = 1 hour
$day = 86400; // 86400 seconds = 1 day
$week = 604800; // 604800seconds = 1 week
$month = 2419200; // 2419200 seconds = 1 month (4 weeks)
$twomonths = 4838400; // 4838400 seconds = 2 months (8 weeks)
$threemonths = 7862400; // 7862400 seconds = 3 months (13 weeks)
$sixmonths = 15724800; // 15724800 seconds = 6 months (26 weeks)
$year = 31449600; // 31449600 seconds = 12 months (52 weeks)
$twoyears = 62899200; // 62899200 seconds = 24 months (104 weeks)
// depending whats entered at the url show for amount of time specified
switch ($time)
{
case "hour":
$timeSort = $hour;
break;
case "day":
$timeSort = $day;
break;
case "week":
$timeSort = $week;
break;
case "month":
$timeSort = $month;
break;
case "twomonths":
$timeSort = $twomonths;
break;
case "threemonths":
$timeSort = $threemonths;
break;
case "sixmonths":
$timeSort = $sixmonths;
break;
case "year":
$timeSort = $year;
break;
case "twoyears":
$timeSort = $twoyears;
break;
}
// set the default for timeSort here - if nothing specified in url
if(!$timeSort) {
$timeSort = $year;
$time = "year"; // currently set to past year
}
// number of images to display
// if nothing is specified in url (ie: www.site.com/gallery/view-top.php?display=100)
// then display the default - currently set at 20
if(!$display) { $displayNo = 20; }
else { $displayNo = $display; }
// owner to restrict by
// if nothing is specified in url (ie: www.site.com/gallery/view-top.php?owner=joe)
// then display the default - currently set at 20
if(!$owner) { $ownerinput = ""; }
else { $ownerinput = $owner; }
// whether to display top 10 etc as a list or not - default is to not show as list
if(!$list) { $displayList = 0; }
else { $displayList = 1; }
/* Read the album list */
$albumDB = new AlbumDB(FALSE);
$gallery->session->albumName = "";
if (!$GALLERY_EMBEDDED_INSIDE) {
?>
<html>
<head>
<title><?php echo $gallery->app->galleryTitle ?></title>
<?php echo getStyleSheetLink() ?>
</head>
<body>
<?php
includeHtmlWrap("gallery.header");
print "debug #001";
/* Initializing the seed */
srand ((double) microtime() * 1000000);
// set the cache file name
define(CACHE_FILE, $gallery->app->albumDir . "/top-pics-$ownerinput.cache");
// here we rebuild the cache file every 12 hours (43200 seconds)
define(CACHE_EXPIRED, 3600);
// Check the cache file to see if it's up to date
$rebuild = 1;
if (fs_file_exists(CACHE_FILE)) {
$stat = fs_stat(CACHE_FILE);
$mtime = $stat[9];
if (time() - $mtime < CACHE_EXPIRED) {
$rebuild = 0;
}
}
// if the cache is not upto date, older than the time you've specified, then rebuild the cache file
if ($rebuild) {
scanAlbums();
saveCache();
readCache();
}
// else just read the cache file into arrays
else {
readCache();
}
// print the top 10/20/100 or whatever you specify
printTop();
print "debug #001a";
?>
</table>
<?php
includeHtmlWrap("gallery.footer");
print "debug #002";
} //end of GALLERY_EMBEDDED_INSIDE
if (!$GALLERY_EMBEDDED_INSIDE) { ?>
</body>
</html>
<?php }
/*
* --------------------------------------------------
* Support functions
* --------------------------------------------------
*/
function saveCache() {
print "debug #003";
/*
* this function saves the top 10/20/100 whatever you want to the cache file
* its reads the data straight from the topten array
*/
global $arrayTopviewed;
global $maxStore;
reset($arrayTopviewed);
if ($fd = fs_fopen(CACHE_FILE, "w")) {
for($i = 0; $i < $maxStore; $i++) {
$currentKey = key($arrayTopviewed);
$clicks[$i] = $arrayTopviewed[$currentKey][0];
$url[$i] = $arrayTopviewed[$currentKey][1];
$caption[$i] = $arrayTopviewed[$currentKey][2];
$tag[$i] = $arrayTopviewed[$currentKey][3];
$upload[$i] = $arrayTopviewed[$currentKey][4];
$updated[$i] = $arrayTopviewed[$currentKey][5];
fwrite($fd, "$clicks[$i]|$url[$i]|$caption[$i]|$tag[$i]|$upload[$i]|$updated[$i]\n");
$current = next($arrayTopviewed);
} // end for
fclose($fd);
} // end if
} // end saveCache()
function readCache() {
print "debug #004";
/*
* this function reads in the top 10/20/100 whatever you want from the cache file
* this information, that it reads in, will be as old as the cache file
*/
global $maxStore;
global $cacheTop;
$cacheTop = array();
if ($fd = fs_fopen(CACHE_FILE, "r")) {
for($i = 0; $i < $maxStore; $i++) {
$line = fgets($fd, 4096);
list($cacheTop[$i][0], $cacheTop[$i][1], $cacheTop[$i][2], $cacheTop[$i][3], $cacheTop[$i][4], $cacheTop[$i][5]) = explode("|", $line);
} // end for
fclose($fd);
} // end if
} //end readCache()
function recurseAlbums($album) {
print "debug #005";
/*
* this function resures the album that it is feed and adds picture clicks to
* the the array topten
*/
global $minSearch;
global $gallery;
global $position;
global $arrayTopviewed;
global $ownerinput;
if ($album) {
$numPhotos = $album->numPhotos(1);
for ($j = 1; $j <= $numPhotos; $j++) {
$id = $album->getPhotoId($j);
if($album->isAlbumName($j)) {
$myAlbumName = $album->isAlbumName($j);
$myAlbum = new Album();
$myAlbum->load($myAlbumName);
$localOwner = $myAlbum->getOwner();
$localOwner = $localOwner->getUsername();
if ($ownerinput == "" || $localOwner == $ownerinput)
recurseAlbums($myAlbum);
} // end if
else {
$localOwner = $album->getOwner();
$localOwner = $localOwner->getUsername();
if ($ownerinput == "" || $localOwner == $ownerinput)
{
$numClicks = $album->getItemClicks($j);
if ($numClicks > $minSearch) {
$index = $album->getPhotoIndex($id);
$arrayTopviewed[$position][0] = $numClicks;
$arrayTopviewed[$position][1] = makeAlbumUrl($album->fields[name], $id);
$arrayTopviewed[$position][2] = editCaption($album, $index, $edit);
$arrayTopviewed[$position][3] = $album->getThumbnailTag($j);
$arrayTopviewed[$position][4] = (time() - $album->getUploadDate($index));
$arrayTopviewed[$position][5] = (time() - strtotime ($album->getLastModificationDate()));
$position++;
} // end if
} // checking owner
} // end else
} // end for NumPhotos
} // end if($album)
} // end recurseAlbums()
function scanAlbums() {
print "debug #006";
global $albumDB;
global $gallery;
global $minSearch;
global $arrayTopviewed;
global $position;
global $ownerinput;
$arrayTopviewed = array();
$position = 0;
$page = 1;
/* If there are albums in our list, display them in the table */
$numAlbums = $albumDB->numAlbums($gallery->user);
$numPhotos = $albumDB->getCachedNumPhotos($gallery->user);
// start of recurse code...
for ($i = 1; $i <= $numAlbums; $i++) {
$gallery->album = $albumDB->getAlbum($gallery->user, $i);
$numPhotos = $gallery->album->numPhotos(1);
for ($j = 1; $j <= $numPhotos; $j++) {
$id = $gallery->album->getPhotoId($j);
if($gallery->album->isAlbumName($j)) {
$myAlbumName = $gallery->album->isAlbumName($j);
$myAlbum = new Album();
$myAlbum->load($myAlbumName);
$myAlbum->numPhotos(1);
$localOwner = $myAlbum->getOwner();
$localOwner = $localOwner->getUsername();
if ($ownerinput == "" || $localOwner == $ownerinput)
recurseAlbums($myAlbum);
} // end if
else {
$localOwner = $gallery->album->getOwner();
$localOwner = $localOwner->getUsername();
if ($ownerinput == "" || $localOwner == $ownerinput)
{
$numClicks = $gallery->album->getItemClicks($j);
if ($gallery->album->getItemClicks($j) > $minSearch) {
$index = $gallery->album->getPhotoIndex($id);
$arrayTopviewed[$position][0] = $numClicks;
$arrayTopviewed[$position][1] = makeAlbumUrl($gallery->album->fields[name], $id);
$arrayTopviewed[$position][2] = editCaption($gallery->album, $index, $edit);
$arrayTopviewed[$position][3] = $gallery->album->getThumbnailTag($j);
$arrayTopviewed[$position][4] = (time() - $gallery->album->getUploadDate($index));
$arrayTopviewed[$position][5] = (time() - strtotime ($gallery->album->getLastModificationDate()));
$position++;
} // end if
} // checking owner input
} // end else
} // end for NumPhotos
print "<tr>";
print "<!-- End Album Column Block -->";
} // end for
// sort the array of pics
arsort($arrayTopviewed);
// print contents of array - for debug purposes
//print_r($arrayTopviewed);
// save the cache to disk
saveCache();
} // end of scanAlbums()
function printTop() {
print "debug #007";
....
Posts: 17
Ok, that's a good start 8)
The problem is in the scanAlbums function: you need to put more debug lines at the inside of that function.
I got a similar problem when the cache has to be rebuilt; so I found out that the cache can be generated only by a user with administrator privileges. May be it is the same problem... I will try and see if I can solve this problem and send an updated release to the original author.
Cya
Marco
Posts: 79
Here's my code, with multiple debugging notes inserted (quoted and bolded for legibility):
Result page
The problem's somewhere in that 6bc section, but I don't know where else I can put debugging notes without messing something up...
Posts: 17
Colin,
I'll try duplicating your problem in the next days. If I find something, I'll let you know.
cya,
Marco
Posts: 79
Any updates?
Posts: 17
I'm sorry but I'm very busy in these days. As soon as I have news, I'll post them here
Posts: 130
Colin - I've seen similar problems for a couple of users with my stats.php script which is similar to this script. I suspect the problem is caused by a resource limit. I would be interested if you could try stats.php - available from here - and see if that has the same issue.
Cheers, J
www.tearoom.me.uk
Posts: 79
Actually the stats.php worked instantly. I used to run view_top, but it just quit working, probably when I upgraded to the new version.
But check out my stats.php: http://www.colinandbethany.com/gallery/stats.php?type=views
Posts: 79
I guess my earlier post didn't post...
Anyway, I put in stats.php and it works great. It's one column, which is an issue, but it's a great program.
http://www.colinandbethany.com/gallery/stats.php?type=views
Posts: 130
I keep hearing that people want multiple columns. It's do-able with probably not too much effort. Just need to get my head round all those tables!
Cheers, J
Posts: 11
I haven't been able to get view_top to work since I upgraded to v1.4.3 rc3. Please assist.
This is the error I get:
my script is located at: http://www.sodhi.org/gallery/view_top.php
Posts: 27300
Change isalbumname() to isalbum() and it should work.
Or try to incoperate this code from Stats.php
Dave
Posts: 271
I just installed view_top_v7.php.
The code seems to work however the page view is not displaying any pictures nor broken placeholders.
One difference I see in my use is that I have gallery stored in a subdomain folder. ie: the page address is http://gallery.verymisunderstood.com/view_top_v7.php
Any idea as to why I am not getting photos back ?
Posts: 2
I've got the problems of:
1. Division by zero in view-top.php on line 341, and
2. No thumbnail and viewed times, but only a table of 20 cells.
Can anyone kindly help please.
http://www.familyfish.com/gallery/view-top?display=20
I'm using Gallery 1.4.3, View-Top vesion 0.6
Thanks in advance.
... Fish
Posts: 271
i think its in gallery not in top view, i have it when i tweak columns and rows in any view page. but only when i use 1 as a colum or row. I bypassed the error by not using a 1 in colums or 1 in rows. this can be found in the properties area. I am noticing that a few of the mods on gallery are becoming a little out dated. and probably should be removed from the website. In perticular the ones that are no longer even supported by their original writers for which there is two.
Hope this helps.
KHSjr
Posts: 2
Thanks. It works finally! And I have bypassed the code "isAlbumName...."
I've encountered the problem of "some of the thumbnails can be shown, and some don't......" I found that the problem caused by the "Caption" of the photo. If the caption (text) of the photo contains "<BR>" or you've hit "Return" for next line, the thumbnail cannot be shown.
...Fish
Posts: 57
I've found and corrected a few bugs in view-top.php version 0.8.0, and at jelwell's advice am informing you all of such. The changes are summarized as follows:
* Made view-top compatible with Gallery 1.4.3 by changing calls to isAlbumName to use getAlbumName instead. The need for this was noted in the Gallery ChangeLog with versions 1.4.3-cvs-b105 and 1.4.3-cvs-b106.
* Fixed bug where view-top was using editCaption() to grab photo captions. This caused weirdness in various situations. For example, when a user was logged in to gallery with edit rights for a photo, a call to editCaption() would return not only the caption itself, but also a link to edit the photo. This, obviously, isn't pretty when included in a context where no html tags are expected. Instead, view-top now uses $gallery->album->getCaption to get just the caption itself.
*Changed the default value of CACHE_EXPIRED to reflect the comment text above it (43200 seconds)
* A few self-serving HTML cleanups, for example making sure that html tag properties are quoted where possible.
These changes have all been tested on my Gallery 1.4.3-pl1 installation. The fix to make it work with Gallery 1.4.3 will probably cause it to break on earlier versions of Gallery, so please stick to an older view-top if that's your situation.
I have attached the new version of the file to this post.
Please let me know if you have any questions!
Thanks,
Peter
Posts: 11
prwood, i still get an error
Posts: 57
How many photos do you have in your gallery, total?
Posts: 181
I decided to try out the view-top.php and it works great. It is fairly useful and will come in handy with what I have in mind. The only small issue is that some of the most viewed images are from the Mature section.
Is there someplace I can do an exclude in the view-top so that certain albums get excluded from being counted?
Posts: 11
prwood
i got about ~ 900 photo's on my site.
My site is [url]www.karbor.com/gallery[/url]
and the view-top file is located at [url]www.karbor.com/gallery/view_top.php[/url]
The old script (v .08 in combination with old gallery version) worked fine with my old gallery and back then I even had ~ 2000 photo's online!
btw, loading the url might take a while, so the error will be displayed in about 30 seconds...
Posts: 57
I haven't been able to load the url at all. It has been several minutes and the page hasn't loaded. I doubt that any of the changes I have made would cause a timeout on your website.
I have written some debugging code into the script, so re-download the file here:
http://prwdot.org/code/view-top.php.gz
Download that and replace your current version with it. Then, remove your cache file (located in the top level of your album directory, probably named "top-pics-.cache" or something like that). Only after removing the cache file, re-run the view-top script, copy down the debugging information it prints out, and paste it in here. It will only print that all out the first time it runs, so be sure to cope and paste!
Thanks.
Posts: 11
Great job on the fix for 1.4.3pl version! I have one question. How do I edit the table to get rid of the borders? I tried chaning the border=0 and cellpadding=0 in the table in view_top.php, but it doesn't change. I also want to center it, but whatever I change to the php there is no change when i reload it. Am I doing something wrong?
Posts: 57
Hm. You should only need to change line 453 in the printTop function:
change to
In the original, border is set to "2", and I changed it to "0". You will need to save this change and make sure to re-upload the copy to your web server. You should also make sure to flush out your browser's cache of that page by holding shift and hitting the reload button.
Posts: 30
Where is the Version 2 module ?
Thanks