4images Forum & Community
4images Modifications / Modifikationen => Mods & Plugins (Releases & Support) => Topic started by: Vraxor on December 29, 2002, 01:02:55 PM
-
Hi all,
I did already forgot about this little modification I did. I was in fact the first little mod I did ever in PHP.
The idea is to show more statistics then the number of images and categories (which are shown by default).
This MOD will show:
- Number of Members
- Number of Image Votes
- Number of Image Hits
- Number of Image Comments
- Number of Image Downloads
All these are shown on totals, so it shows the total number of image hits over all images. You can see an example of it here: http://haunter.student.utwente.nl/Terrarevolution/galleries/index.php
// Ok, now lets get started
Creating the stats.php file
Make a new file called: stats.php
Save this empty file in the includes folder of 4images
Open stats.php with any code editor you like.
and copy past the following to your stats.php:
<?PHP
//-----------------------------------------------------
//--- Show number of Users ----------------------------
//-----------------------------------------------------
$sql = "SELECT COUNT(*) as users
FROM ".USERS_TABLE."
WHERE user_id <> ".GUEST;
$row = $site_db->query_firstrow($sql);
$total_users = "".$lang['users']."<B> ".$row['users']."</B>\n";
$site_template->register_vars("total_users", $total_users);
unset($total_users);
//-----------------------------------------------------
//--- Hits --------------------------------------------
//-----------------------------------------------------
$sql = "SELECT SUM(image_hits) AS sum
FROM ".IMAGES_TABLE;
$row = $site_db->query_firstrow($sql);
$sum = (isset($row['sum'])) ? $row['sum'] : 0;
$total_hits = "".$lang['total_hits']."<B> ".$row['sum']."</B>\n";
$site_template->register_vars("total_hits", $total_hits);
unset($total_hits);
//-----------------------------------------------------
//--- Votes -------------------------------------------
//-----------------------------------------------------
$sql = "SELECT SUM(image_votes) AS sum
FROM ".IMAGES_TABLE;
$row = $site_db->query_firstrow($sql);
$sum = (isset($row['sum'])) ? $row['sum'] : 0;
$total_votes = "".$lang['total_votes']."<B> ".$row['sum']."</B>\n";
$site_template->register_vars("total_votes", $total_votes);
unset($total_votes);
//-----------------------------------------------------
//--- Downloads ---------------------------------------
//-----------------------------------------------------
$sql = "SELECT SUM(image_downloads) AS sum
FROM ".IMAGES_TABLE;
$row = $site_db->query_firstrow($sql);
$sum = (isset($row['sum'])) ? $row['sum'] : 0;
$total_downloads = "".$lang['total_downloads']."<B> ".$row['sum']."</B>\n";
$site_template->register_vars("total_downloads", $total_downloads);
unset($total_downloads);
//-----------------------------------------------------
//--- Comments ----------------------------------------
//-----------------------------------------------------
$sql = "SELECT SUM(image_comments) AS sum
FROM ".IMAGES_TABLE;
$row = $site_db->query_firstrow($sql);
$sum = (isset($row['sum'])) ? $row['sum'] : 0;
$total_comments = "".$lang['total_comments']."<B> ".$row['sum']."</B>\n";
$site_template->register_vars("total_comments", $total_comments);
unset($total_comments);
?>
Now save the stats.php file.
ALWAYS BACKUP: any file you start editing as you might not be able to restore it when the mod doesn't work
Adding the statistics to the language files:
*NOTE* I only edited this in English, but you will have to copy this to any language you use and maybe translate the english.
Open the main.php file from the lang/[your language] folder of 4images.
Go all the way to the bottom of the file.
Find:
//-----------------------------------------------------
//--- Admin Links -------------------------------------
//-----------------------------------------------------
$lang['edit'] = "[Edit]";
$lang['delete'] = "[Delete]";
Add Before:
//-----------------------------------------------------
//--- Statistics --------------------------------------
//-----------------------------------------------------
$lang['users'] = "Total Members:";
$lang['total_hits'] = "Total Image Hits:";
$lang['total_votes'] = "Total Image Votes:";
$lang['total_downloads'] = "Total Image Downloads:";
$lang['total_comments'] = "Total Image Comments:";
Including the statistics in Index.php:
Open index.php in the root folder of 4images with any code editor you like.
Find:
require(ROOT_PATH.'includes/sessions.php');
Add after:
include(ROOT_PATH.'includes/stats.php');
Do the same for catergories.php, lightbox.php, top.php
(it might also work in memberlist.php, search.php, register.php etc. but I did not test them yet)
Now edit the template files that correspond with the php files you added the include to.
index.php = home.html
categories.php = categories.html
lightbox.php = lightbox.html
top.php = top.html
you can find the templates inside the templates/default folder of 4images.
In the templates you can now use the following tags:
{total_users} - This will show the total number of members
{total_votes} - This will show the total number of image votes
{total_comments} - This will show the total number of image comments
{total_hits} - This will show the total number of image hits
{total_downloads} - This will show the total number of image downloads
Uploading all the edited files:
Now upload all files you editted to the right folder at your webserver.
This is a list of files you need to upload:
./index.php
./categories.php
./lightbox.php
./top.php
./includes/stats.php
./lang/ (any language you editted) /main.php
./templates/ (any templates you editted) /home.html
./templates/ (any templates you editted) /categories.html
./templates/ (any templates you editted) /lightbox.html
./templates/ (any templates you editted) /top.html
of course if you editted any more files then the once I mentioned above, you will need to upload them too.
I think this is it. Please note that it could be that I made an error somewhere in the directions above. As soon as you notice any error, please let me know and I will correct it as soon as possible.
Enjoy this little mod!!!
Cheers,
Vraxor
-
Wow! works great, very nice!
just one little misspell I found
it supposed to be {total_users}
not{total_user}
and another thing, I think some host wont accept " <? " then need full tag " <?php "
P.S. do u have something else cool hided from us? :D :wink:
-
ok, fixed.
Good to hear you like it.
-
Cool mod Vraxor, thanks!
Just a quick note for those using the vBulletin integration mod, in stats.php find:
WHERE user_id <> ".GUEST;
and change to:
WHERE userid <> ".GUEST;
For it to work with vBulletin's users table rather than 4images.
-
This is real cool, and it works, no errors!
test here:
[link removed]
Greets.
-
Hallo !
Habe alle hier beschriebenen Schritte durchgeführt und erhalte nun folgende Fehlermeldung in home.html:
-------------------
Parse error: parse error in
/home/intuitiv/public_html/vision/includes/stats.php on line 5
-------------------
kann da jemand helfen ?
Die Site ist:
http://www.intuitivmedia.net/vision/index.php
thank you !
-
Hi intuitiv,
did you fix the error already as I do not see one?
Cheers,
Vraxor
-
Thank you, it was a problem related to my editor BBEdit 6.5. Everything is working fine.
-
Love the stats mod, great mod, thanks!!!!
-
i need help please here is link http://www.jtimberlake.net/gallery/index.php you can see whats problem :/
-
Creating the stats.php file
Make a new file called: stats.php
Save this empty file in the includes folder of 4images
Open stats.php with any code editor you like.
and copy past the following to your stats.php:
did u do exactly this part?
-
thank you soo much i forget to put stats.php in includes folder again thank you :oops:
-
haha! same thing happened to me jdk, lol
-
http://haunter.student.utwente.nl/Terrarevolution/galleries/index.php
I saw this image gallery! can u tell me how ca I add the section "Gallery News /Webmaster Comment" ?
thanksssssssssss
-
Just edit the home.html template
-
Thanks !!!! :D
Cristina
-
Hi @ all,
I just tried to implement this mod and I followed each and every step, but it does not work. Nothing is shown at all :cry:
Could it be possible, that the mod does not work with the script-version 1.7?
Has anybody managed it with this version?
I'm at a loss at this moment :!: :?:
Regards,
Biggi
-
Ha :D
forget it. Just written, then checked and changed the index.php again and it works.
Thanks to Vraxor for this excellent mod!
Biggi
-
this is an excellent MOD but however it would be great if the stats would be able to intergrate with the forum, in which users able to use tags such as {new_post} as well as {total_users} ; etc.
anyway would this MOD able to use while the intergration of database of phpbb and 4images are mixed?
Thanks
:roll:
-
Hi Sorestar,
I have intergrated my site with PHPBB and it works fine.
Cheers,
Vraxor
-
I like this mod, thanks for the hard work Vraxor!
Question though, is it me or does do the stats not get updated when an admin clicks, downloads, etc?
Meaning that the counters are updated fine when regular users click but when an admin to the site clicks they don't update.
-
I like this mod, thanks for the hard work Vraxor!
Question though, is it me or does do the stats not get updated when an admin clicks, downloads, etc?
Meaning that the counters are updated fine when regular users click but when an admin to the site clicks they don't update.
this is nothing to do with the mod. That how 4images works. Since admin probably spend alot of time on the site, why whould u like count him?
it's like to buy bread for dinner from your own bakery.... 8O :wink:
-
Thanks V@no.
-
Hi,
kann man den Mod auch noch so erweitern das angezeigt wird wieviele Besucher heute da waren??
-
Kann man auch die Anzahl Neuer Bilder in die Statistik mit aufnehmen???!!!
Was müsste man dafür ergänzen???
Habe das bei V@no auf seiner Seite gesehen.
Gruß
Markus
-
Hi,
kann man den Mod auch noch so erweitern das angezeigt wird wieviele Besucher heute da waren??
there is something simular:
http://4homepages.de/forum/viewtopic.php?t=4043
-
vraxor,
I suck at codeing so i'm not sure where to put {total_users} {total_votes}{total_comments}{total_hits}{total_downloads} in my code to have individual stats come up for the pictures. I'm not concearned about stats for the catagory as a whole, just the individual pictues in the category view (where 9 or 16 display at once). Can you help me out?
ndj5
-
vraxor,
I suck at codeing so i'm not sure where to put {total_users} {total_votes}{total_comments}{total_hits}{total_downloads} in my code to have individual stats come up for the pictures. I'm not concearned about stats for the catagory as a whole, just the individual pictues in the category view (where 9 or 16 display at once). Can you help me out?
ndj5
-
is it possible to showing this statistics at any page, not inside 4images?
-
is it possible to showing this statistics at any page, not inside 4images?
Easiest way to do so is create new stats.php with this code:
<?php
//-----------------------------------------------------
//--- Show number of Users ----------------------------
//-----------------------------------------------------
$sql = "SELECT COUNT(*) as users
FROM ".USERS_TABLE."
WHERE user_id <> ".GUEST;
$row = $site_db->query_firstrow($sql);
$total_users = "".$lang['users']."<B> ".$row['users']."</B>\n";
//-----------------------------------------------------
//--- Hits --------------------------------------------
//-----------------------------------------------------
$sql = "SELECT SUM(image_hits) AS sum
FROM ".IMAGES_TABLE;
$row = $site_db->query_firstrow($sql);
$sum = (isset($row['sum'])) ? $row['sum'] : 0;
$total_hits = "".$lang['total_hits']."<B> ".$row['sum']."</B>\n";
//-----------------------------------------------------
//--- Votes -------------------------------------------
//-----------------------------------------------------
$sql = "SELECT SUM(image_votes) AS sum
FROM ".IMAGES_TABLE;
$row = $site_db->query_firstrow($sql);
$sum = (isset($row['sum'])) ? $row['sum'] : 0;
$total_votes = "".$lang['total_votes']."<B> ".$row['sum']."</B>\n";
//-----------------------------------------------------
//--- Downloads ---------------------------------------
//-----------------------------------------------------
$sql = "SELECT SUM(image_downloads) AS sum
FROM ".IMAGES_TABLE;
$row = $site_db->query_firstrow($sql);
$sum = (isset($row['sum'])) ? $row['sum'] : 0;
$total_downloads = "".$lang['total_downloads']."<B> ".$row['sum']."</B>\n";
//-----------------------------------------------------
//--- Comments ----------------------------------------
//-----------------------------------------------------
$sql = "SELECT SUM(image_comments) AS sum
FROM ".IMAGES_TABLE;
$row = $site_db->query_firstrow($sql);
$sum = (isset($row['sum'])) ? $row['sum'] : 0;
$total_comments = "".$lang['total_comments']."<B> ".$row['sum']."</B>\n";
?>
upload it anywhere on your server, then insert this in the .php file u want it be displayed:
<?php
define('ROOT_PATH', './4images/');
include(ROOT_PATH.'global.php');
include('PATH_TO_NEW_STATS/stats.php');
?>
change PATH_TO_NEW_STATS to .... path to the new stats.php file :?
after that, u have 5 variables that content the stats:
$total_users
$total_hits
$total_votes
$total_downloads
$total_comments[/list:u]
u can use this:
echo $total_users;
or this:<?=$total_users?>
to print them on screen.
-
Thanks V@no :D
boti
-
To see total images rated, add this to stats.php
//-----------------------------------------------------
//--- Ratings------------------------------------------
//-----------------------------------------------------
$sql = "SELECT COUNT(image_rating) AS sum
FROM ".IMAGES_TABLE.
" WHERE image_rating > 0";
$row = $site_db->query_firstrow($sql);
$sum = (isset($row['sum'])) ? $row['sum'] : 0;
$total_rating = "".$lang['total_rating']."<B> ".$row['sum']."</B>\n";
$site_template->register_vars("total_rating", $total_rating);
unset($total_rating);
You will also have to add to main.php
$lang['total_rating'] = "Total Images Rated:";
You can now use {total_rating} in your templates. Here is an example of mine:
<table width="450" border="0" cellspacing="0" cellpadding="1">
<tr>
<td class="head1">
<table width="100%" border="0" cellspacing="0" cellpadding="3">
<tr>
<td valign="top" class="head1">Gallery Statistics</td>
</tr>
<tr>
<td valign="top" class="row2"> {total_users}<br>
{total_votes} <br>
{total_comments}<br>
{total_hits}<br>
{total_downloads}<br>
{total_rating} </td>
</tr>
</table>
</td>
</tr>
</table>
I tried to make this a template of its own, like whos_online, but couldn't get it to work. I created it as a separate template called stats.html and added it to the templates used in index.php. Nothing showed up, so I just hard-coded the html into my home and top templates. This works, but isn't as nice, so if anyone has it working a cleaner way, could you please let me know what to do.
-
hey thats coll, thanks jengwen :D
boti
-
@v@no: Can U explain me how to extend the gallery stats to
- New Images
- Sent postcards
- ...
like on your website.
Thanks a lot and cheers,
Markus
-
@v@no: Can U explain me how to extend the gallery stats
I did it in a "dirty" way, messing up the USERS_TABLE...but then, Jan suggested me this:Create a new table like this:
Code:
CREATE TABLE 4images_cat_stats (
user_id mediumint(8) unsigned NOT NULL default '0',
cat_id mediumint(8) unsigned NOT NULL default '0',
cat_hits int(10) unsigned NOT NULL default '0',
image_hits int(10) unsigned NOT NULL default '0',
downloads int(10) unsigned NOT NULL default '0',
postcards int(10) unsigned NOT NULL default '0',
KEY user_id (user_id),
KEY cat_id (cat_id)
) TYPE=MyISAM;
The fields user_id and cat_id are reference fields, the other fields contains the hit counts.
You can now store entries for each user_id depending on categories. User with ID 1 visits category with ID 1 the first time: The entry will be created and will be referenced on the user_id and cat_id. If the user visits category with ID 1 again, the entry will be updated depending on his user_id and the cat_id. If he visits category with ID 2, a new entry will be created with user_id = 1 and cat_id = 2. And so on...
You can pull infos about what you want. Relating on user_id's or cat_id's.
Examples:
Fetch 10 users most visited category with ID <cat_id>:
Code:
$sql = "SELECT u.user_id, u.user_name, cs.cat_hits, c.cat_name [...]
FROM ".USERS_TABLE." u, ".CATEGORIES_TABLE." c, 4images_cat_stats cs
WHERE cs.cat_id = <cat_id> AND u.user_id = c.user_id AND c.cat_id = cs.cat_id
ORDER BY cs.cat_hits DESC
LIMIT 10";
$site_db->query($sql);
Fetch 10 categories who are most visited by user with ID <user_id>:
Code:
$sql = "SELECT u.user_id, u.user_name, cs.cat_hits, c.cat_name [...]
FROM ".USERS_TABLE." u, ".CATEGORIES_TABLE." c, 4images_cat_stats cs
WHERE cs.user_id = <user_id> AND c.cat_id = cs.cat_id AND u.user_id = cs.user_id
ORDER BY cs.cat_hits DESC
LIMIT 10";
$site_db->query($sql);
Jan
I will try do this way somethimes soon, if I successed, I might post it as MOD here ;)
-
@v@no: Can U explain me how to extend the gallery stats
I did it in a "dirty" way, messing up the USERS_TABLE...but then, Jan suggested me this:Create a new table like this:
Code:
CREATE TABLE 4images_cat_stats (
user_id mediumint(8) unsigned NOT NULL default '0',
cat_id mediumint(8) unsigned NOT NULL default '0',
cat_hits int(10) unsigned NOT NULL default '0',
image_hits int(10) unsigned NOT NULL default '0',
downloads int(10) unsigned NOT NULL default '0',
postcards int(10) unsigned NOT NULL default '0',
KEY user_id (user_id),
KEY cat_id (cat_id)
) TYPE=MyISAM;
The fields user_id and cat_id are reference fields, the other fields contains the hit counts.
You can now store entries for each user_id depending on categories. User with ID 1 visits category with ID 1 the first time: The entry will be created and will be referenced on the user_id and cat_id. If the user visits category with ID 1 again, the entry will be updated depending on his user_id and the cat_id. If he visits category with ID 2, a new entry will be created with user_id = 1 and cat_id = 2. And so on...
You can pull infos about what you want. Relating on user_id's or cat_id's.
Examples:
Fetch 10 users most visited category with ID <cat_id>:
Code:
$sql = "SELECT u.user_id, u.user_name, cs.cat_hits, c.cat_name [...]
FROM ".USERS_TABLE." u, ".CATEGORIES_TABLE." c, 4images_cat_stats cs
WHERE cs.cat_id = <cat_id> AND u.user_id = c.user_id AND c.cat_id = cs.cat_id
ORDER BY cs.cat_hits DESC
LIMIT 10";
$site_db->query($sql);
Fetch 10 categories who are most visited by user with ID <user_id>:
Code:
$sql = "SELECT u.user_id, u.user_name, cs.cat_hits, c.cat_name [...]
FROM ".USERS_TABLE." u, ".CATEGORIES_TABLE." c, 4images_cat_stats cs
WHERE cs.user_id = <user_id> AND c.cat_id = cs.cat_id AND u.user_id = cs.user_id
ORDER BY cs.cat_hits DESC
LIMIT 10";
$site_db->query($sql);
Jan
I will try do this way somethimes soon, if I successed, I might post it as MOD here ;)
Short question! Do U have finished the mod???
Thanks!!!
Cheers,
Markus
-
Short question! Do U have finished the mod???
Sorry, no. After all I did to my database and 4images code itself I dont know what is what anymore. Maybe after major cleaning up or starting everything over, I will try finish with this one.
-
how can i have stats like this?
http://www.newman.d2g.com/index.php?template=sitestats
they look great!
-
Yes and no. Those stats are a combination of this mod and from a logging tool called pphlogger from www.phpee.com
-
hello
ive done everything correct i think, but im not sure where to add the tags or how to add them in the html files. When i add the tags, i guess i add them to the wrong place, because when i go to the site, it just gives some weird number, like "total downloads: 5738" or something. Can anyone please help?
-
Hello All,
This looks like a great mod, but I wanna include it on every page on my nav bar (click on link below, you will see the "Site Statistics" section where I want them).
Problem is the templating I'm using uses a file called 4gmenu.php, which is included on all pages and I am able to add things to that file and have them show up on every page (the "Navigation" and "Sponsors" sections are stored in this file).
Is there any way I can have the stats in this file too?
When I try to include stats.php in 4gmenu.php, I get this error:
Fatal error: Call to a member function on a non-object in /home/gob/public_html/new/gallery/includes/stats.php on line 9
Line 9 contains:
$row = $site_db->query_firstrow($sql);
Anybody have any ideas what the problem is?
Thanks!
-
try add this before your stats.php include:
define('ROOT_PATH', './');
@include(ROOT_PATH.'config.php');
include(ROOT_PATH.'includes/constants.php');
include(ROOT_PATH.'includes/db_'.strtolower($db_servertype).'.php');
$site_db = new Db($db_host, $db_user, $db_password, $db_name);
-
New Error:
Fatal error: Cannot redeclare class db in /home/gob/public_html/new/gallery/includes/db_mysql.php on line 28
-
I ment inside 4gmenu.php ....?
-
Yep, that's inside 4gmenu.php
-
ah, yes...sorry, my bad...
are u sure line 9 is $row = $site_db->query_firstrow($sql); ?
-
Yes, I am positive the error is occuring from that line.
-
Just to follow up, here's what I had to do to get site stats on every page (you can check them out by clicking on my link in my sig):
First I had to drop the stats.php include statement into every php files.
Then in all .html template files, I had to do:
<?php
$total_users2 = "{total_users}";
$total_votes2 = "{total_votes}";
$total_comments2 = "{total_comments}";
$total_hits2 = "{total_hits}";
$total_downloads2 = "{total_downloads}";
include("4gmenu.php");
?>
Then in my 4gmenu.php, I had:
<?php
print $total_users2."<br>";
print $total_votes2."<br>";
print $total_hits2."<br>";
print $total_comments2."<br>";
print $total_downloads2."<br>";
?>
I know, it's sort of an ugly hack, but since the template I have includes a php file for the menu system, I had to do this.
Just wanted to let ya'll know in case anybody else ran into a similar problem.[/code]
-
Then in all .html template files, I had to do:
if u already do that way, why dont u just use those tags and insert your stats directly into EACH template? why do u need include them into 4gmenu.php ??? it's just waste of time and perfomance.
-
<rant>Because I don't like how we have to edit XX files just to get something to appear in the menu bar. I am a fan of editing one file and having the changes appear on every page.</rant>
And the only way I could pass those {...} variables into my 4gmenu.php include file was to do the above.
-
yes, but u already have to edit all files....that's my point ;)
and still if in the feature u want to change something in those stats, u'll need edit all files again...
-
Yes, but I have set it up for minimal editing.
All I did was set some variables, so the only time I would need to go back through and change something is if I change a variable name, or add a new one.
If I want to change the look and feel of how they are displayed, I edit 1 file ;)
-
OK 4 all who want 2 display the last 5 resgisterd members.
//-----------------------------------------------------
//--- New Member --------------------------------------
//-----------------------------------------------------
$sql = "SELECT user_id, user_name FROM ".USERS_TABLE."
WHERE user_id > ".USER_AWAITING."
ORDER by user_joindate DESC
LIMIT 5";
$result = $site_db->query($sql);
while ($row = $site_db->fetch_array($result)) {
$user_new_member_list .= '<img border="0" src="templates/1/images/arrow_icon.gif"> <a href ="'.ROOT_PATH.'member.php?action=showprofile&user_id='.$row['user_id'].'"><b>'.$row['user_name'].'</b></a><br>';
}
$user_new_member_box = $site_template->parse_template("user_new_member_box");
$site_template->register_vars(array(
"user_new_member_box" => $user_new_member_box,
"user_new_member_list" => $user_new_member_list
));
unset($user_new_member_box);
unset($user_new_member_list);
create a new template called user_new_member_box.html and put {user_new_member_list} somewhere in.
-
Hi,
I´ve rewrote the stats.php for various reasons,in particular due to the non-standard db-tables. Plz look in this thread:http://www.4homepages.de/forum/viewtopic.php?t=6484 But there is my text in german, because i had not the time to translate it. Plz use google-tools! :wink: possibly I do later the translation...
Plz say me your opinion about the mod!
bye
-
ummm, was the variable $sum intended to be used in any instance?
for example;
$sum = (isset($row['sum'])) ? $row['sum'] : 0;
$total_hits = "".$lang['total_hits']."<B> ".$row['sum']."</B>\n";
should it not be;
$sum = (isset($row['sum'])) ? $row['sum'] : 0;
$total_hits = "".$lang['total_hits']."<B> ". $sum."</B>\n";
-
upload it anywhere on your server, then insert this in the .php file u want it be displayed:
<?php
define('ROOT_PATH', './4images/');
include(ROOT_PATH.'global.php');
include('PATH_TO_NEW_STATS/newstats.php');
?>
change PATH_TO_NEW_STATS to .... path to the new stats.php file
after that, u have 5 variables that content the stats:
$total_users
$total_hits
$total_votes
$total_downloads
$total_comments[/list:u]
u can use this:
Code:
echo $total_users;
or this:
Code:
<?=$total_users?>
to print them on screen.
Code:
have done the first part but haveing trouble printing the stats it says
"upload it anywhere on your server, then insert this in the .php file u want it be displayed:"
i want it to display on a html file but does not work
-
please use bbcode if u post a code and check the syntax of the code u've posted,
define('ROOT_PATH', './gallery/');
doesnt looks right.
-
my 4 images is inside a folder called gallery
so i insert this into my html file outside 4images
<?php
define('ROOT_PATH', './4images/');
include(ROOT_PATH.'global.php');
include('PATH_TO_NEW_STATS/newstats.php');
?>
then on the html page i want to show the stats i insert this
tag
<?=$total_users?>
is this correct thanks :D
-
no, the syntax is not correct, try it yourself ;) u'll get parse error.
-
sorry veno do not understand syntax , will try tomorrow after some sleep
-
hallo,
habe glaube ich alles so gemacht wie beschrieben, bekomme aber auf meiner seite fehlermeldungen www.netzpfosten.de und dann auf fotos.
was habe ich falsch gemacht ?
-
hmmm......habe es jetzt nochmal gemacht. jetzt sind die fehlermeldungen weg, aber man sieht die statistiken auch nicht ?!
-
thnx alooot its work wiz me 100% :D
-
Hi..I want to add some more statistics in my statistics details, please help me to do like this.
Total Votes: 2411
Total Members: 957
Total Hits: 2065645
Total Images: 16487
Total Categories: 246
Total Downloads: 111766
my code like this
{total_votes}<br>
{total_users}<br>
{total_hits}<br>
{total_images}br>
{total_categories}<br>
{total_downloads}
My statistics show's like this
Total Votes: 281
Total Members: 97
Total Hits: 10645
887
26
Total Downloads: 1856
Please help me to add Total Images and Total Categories.
Jamstave.
-
a good start would be if u showed us what is the code u use for {total_images} and {total_categories} tags
-
Hi..V@no thanks for the reply and i didn't edit any php code i just put this tag({total_images},{total_categories) in the home.html
I got that tag from main.php
$lang['site_stats'] = "<b>{total_images}</b> images in <b>{total_categories}</b> categories.";
Jamstave.
-
Okay, been trying to get this to work properly. And I am not having much luck. Does this mod work with 1.7.1? I have followed the instructions again and again. Thought maybe it was the 1.7.1 version that was causing the trouble. Thanks so much.
-
Does this work with 1.71 ? or do I have to change a different file?
-
Does this work with 1.71 ? or do I have to change a different file?
yes it does work with V1.71
-
This worked perfect for what I wanted. thanks
-
Everything seemed to work fine until I noticed the total image hits, it only gives me the hits for the top 5 categories not the entire site.
Heres my line if it will help.
http://www.757lab.com/Wallpapers
-
Plz can somebody help, cuz its only the total hits for the 5 top images and not all of the images. Plz help
-
Since the category votes is now developped :
http://www.4homepages.de/forum/index.php?topic=9297.0
and can be customized with this one - this is what you have to do for those who did installed it :
// Installation step :
In your stats.php file,
find :
//-----------------------------------------------------
//--- Votes -------------------------------------------
//-----------------------------------------------------
$sql = "SELECT SUM(image_votes) AS sum
FROM ".IMAGES_TABLE;
$row = $site_db->query_firstrow($sql);
$sum = (isset($row['sum'])) ? $row['sum'] : 0;
$total_votes = "".$lang['total_votes']."<B> ".$row['sum']."</B>\n";
$site_template->register_vars("total_votes", $total_votes);
unset($total_votes);
replace with :
//-----------------------------------------------------
//--- Image Votes -------------------------------------------
//-----------------------------------------------------
$sql = "SELECT SUM(image_votes) AS sum
FROM ".IMAGES_TABLE;
$row = $site_db->query_firstrow($sql);
$sum = (isset($row['sum'])) ? $row['sum'] : 0;
$total_votes = "".$lang['total_votes']."<B> ".$row['sum']."</B>\n";
$site_template->register_vars("total_votes", $total_votes);
unset($total_votes);
//-----------------------------------------------------
//--- Category Votes -------------------------------------------
//-----------------------------------------------------
$sql = "SELECT SUM(cat_votes) AS sum
FROM ".CATEGORIES_TABLE;
$row = $site_db->query_firstrow($sql);
$sum = (isset($row['sum'])) ? $row['sum'] : 0;
$total_cat_votes = "".$lang['total_votes']."<B> ".$row['sum']."</B>\n";
$site_template->register_vars("total_cat_votes", $total_cat_votes);
unset($total_cat_votes);
Then, in your template, simply add : {total_cat_votes} and you'll be able to see your total cat votes results. ;)
-
For users who installed this MOD :
http://www.4homepages.de/forum/index.php?topic=9567.0
Follow the steps below if you wish to combine it with the More Stats MOD.
In your includes/stats.php file,
find :
//-----------------------------------------------------
//--- Hits --------------------------------------------
//-----------------------------------------------------
$sql = "SELECT SUM(image_hits) AS sum
FROM ".IMAGES_TABLE;
$row = $site_db->query_firstrow($sql);
$sum = (isset($row['sum'])) ? $row['sum'] : 0;
$total_hits = "".$lang['total_hits']."<B> ".$row['sum']."</B>\n";
$site_template->register_vars("total_hits", $total_hits);
unset($total_hits);
add below :
//-----------------------------------------------------
//--- Profile Hits ------------------------------------
//-----------------------------------------------------
$sql = "SELECT SUM(profile_hits) AS sum
FROM ".USERS_TABLE;
$row = $site_db->query_firstrow($sql);
$sum = (isset($row['sum'])) ? $row['sum'] : 0;
$profile_hits = "".$lang['profile_hits']."<B> ".$row['sum']."</B>\n";
$site_template->register_vars("profile_hits1", $profile_hits);
unset($profile_hits);
Then, in your current template,
add this tag :
{profile_hits1}
as part of the others.
It should work. ;)
-
:arrow: How can I view the number of images and categories in this stats system :?: :oops: :mrgreen:
-
I posted this two threads above. :?
-
I posted this two postd above. :?
???
-
http://www.4homepages.de/forum/index.php?topic=3303.msg44129#msg44129
-
http://www.4homepages.de/forum/index.php?topic=3303.msg44129#msg44129
But in your post u put Category and Images Votes, I need the total of images and categories of my gallery
-
I thought this was already integrated in the MOD. I guess this is something I will have to look at. ;)
-
I thought this was already integrated in the MOD. I guess this is something I will have to look at. ;)
jejeje.. can u help me with the code but without votes?
-
I believe I already answered that question. :?
-
Hi
This Mod works perfect ... great !!!
Many thanks
coooool
Steffen
-
nice MOD .. working ..thanks
-
Hello.
I would like to change the number of images, my statistic display. Now it shows the "top 10" of each image/kategory/download whatsoever.
I would like to increase the number to 20 or so, but I cannot finde this 10 that i - suppose - need to change.
Thanks a lot in advance. Here my stats.php, but I think the number might be hidden elsewhere?
-
@ berlinfotos
... der Code deiner admin/stats.php hat absolut nichts mit diesem MOD zu tun ... :!:
... bitte entferne die Codezeilen aus deinem Post, um anderen Usern Irritationen zu ersparen ... :!:
Wenn du in deinem ACP auf der Startseite die Anzeige der Statistik von 5 (oder 10) auf 20 erhöhen willst, dann finde in admin/home.php folgende Codezeile gleich am Anfang :
$stats_limit = 5;
und ersetze sie durch :
$stats_limit = 20;
mawenzi
-
@ berlinfotos
... der Code deiner admin/stats.php hat absolut nichts mit diesem MOD zu tun ... :!:
... bitte entferne die Codezeilen aus deinem Post, um anderen Usern Irritationen zu ersparen ... :evil: :!:
Sorry, mawenzi,
wollte hier keinen ärgern, ich nahm als Laie nur an, dass ich für die Statistik was in der stats.php ändere.
Mit deinem Tipp hat das ganz einfach geklappt, danke.
Robert
-
... Mit deinem Tipp hat das ganz einfach geklappt, danke. ...
... na dann ist ja alles bestens ... :wink:
mawenzi
-
This is perfectly right mod that i want thanks alot:)
-
I'm using a MOD (Files List 1.3) by V@no , and i want know how can i added the number of files on STATS !?
Total Files : XX
:?:
-
I'm using a MOD (Files List 1.3) by V@no , and i want know how can i added the number of files on STATS !?
Total Files : XX
:?:
And make it only for Admin / Reg. Members :?
-
I have the guestbook mod and i have made a counter for the number of guestbook entries:
//-----------------------------------------------------
//--- Guestbook Signatures-----------------------------
//-----------------------------------------------------
$sql = "SELECT SUM(comment_id) AS sum
FROM ".GUESTBOOK_TABLE;
$row = $site_db->query_firstrow($sql);
$sum = (isset($row['sum'])) ? $row['sum'] : 0;
$total_signatures = "".$lang['total_signatures']."<B> ".$row['sum']."</B>\n";
$site_template->register_vars("total_signatures", $total_signatures);
unset($total_signatures);
With the corresponding language and calls etc. However, when it counts it counts deleted posts as there. I know because I made an entry, deleted it, made another entry. It now says there are 2 instead of 1. Is there a better variable to count than the "comment_id"?
-
//-----------------------------------------------------
//--- Guestbook Signatures-----------------------------
//-----------------------------------------------------
$sql = "SELECT COUNT(comment_id) AS sum
FROM ".GUESTBOOK_TABLE;
$row = $site_db->query_firstrow($sql);
$sum = (isset($row['sum'])) ? $row['sum'] : 0;
$total_signatures = "".$lang['total_signatures']."<B> ".$row['sum']."</B>\n";
$site_template->register_vars("total_signatures", $total_signatures);
unset($total_signatures);
you should use COUNT instead of SUM,
so the number of entries is outputed and not the sum of the comment_id.
-
Great, that works. Thanks.
-
Hi
Where abouts do I place the following below in the home.html, categories.html, lightbox.html & top.html, Thanks. :D
Gallery Statistics
{total_users}
{total_votes}
{total_comments}
{total_hits}
{total_downloads}
{total_rating}
-
toller MOD
klappt alles super. Danke
Gruüsse aus Hamburg
Steffen
-
To Vraxor
Please can you tell me how you edited your home.html etc so it shows the Site Statistics
like you have them.
Thanks
-
meybe someone could help me show number of registered users only for admin ?
-
is anyone put this code to show total images...I get the code total categories but still there is no code for total images...
-
Hi,
the mod works great.
The only thing is that the stats won't show up on the details, member and search sites.
Here's how i tried to implement it:
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="head1">
<table width="100%" border="0" cellspacing="0" cellpadding="3">
<tr>
<td class="head1" valign="top" background="{template_url}/images/top_bg.gif">Statistik</td>
</tr>
<tr>
<td class="row2" valign="top">
{total_users} <br />
{total_votes} <br />
{total_comments} <br />
{total_hits} <br />
{total_downloads} <br /></td>
</tr>
</table>
</td>
</tr>
</table>
The strange thing is that "Statistik" is displayed on every page just the stats themselves do not.
I'd appreciate any help.
regards
Charlie
-
@ CharlieF.
... you must insert the following in your details.php, member.php a.s.o ...
include(ROOT_PATH.'includes/stats.php');
-
Thanks mawenzi.
For some reason i just forgot that in these files.
Again, thanks alot :D
-
is anyone put this code to show total images...I get the code total categories but still there is no code for total images...
how can we see total images?
-
@ mstgokcen
... all total images on index ... :wink:
... in stats.php use this ...
//-----------------------------------------------------
// --- All total images -----
//-----------------------------------------------------
$sql = "SELECT COUNT(*) AS all_total_images
FROM ".IMAGES_TABLE."
WHERE image_active = 1";
$row = $site_db->query_firstrow($sql);
$all_total_images = $row['all_total_images'];
$lang_all_total_images = $lang['all_total_images'];
$site_template->register_vars("all_total_images", $all_total_images);
$site_template->register_vars("lang_all_total_images", $lang_all_total_images);
unset($all_total_images);
unset($lang_all_total_images);
//-----------------------------------------------------
... in /lang/<your_lang>/main.php use this ...
$lang['all_total_images'] = "Total Images :";
... now you can use in home.html this tags ...
{lang_all_total_images} {all_total_images}
-
tnx a lot it is ok
-
the demo doesn´t run.. where could i see a demo plz?
-
... e.g. here (http://klick.kl.funpic.de/index.php) ... :wink:
-
ok!thanks a lot
your gallery is too nice ^^
-
And how can we see total categories?
-
@ tansamalaja
... all total categories on index ... :wink:
... in stats.php use this ...
//-----------------------------------------------------
// --- All total categories -----
//-----------------------------------------------------
$sql = "SELECT COUNT(*) AS all_total_categories
FROM ".CATEGORIES_TABLE;
$row = $site_db->query_firstrow($sql);
$all_total_categories = $row['all_total_categories'];
$lang_all_total_categories = $lang['all_total_categories'];
$site_template->register_vars("all_total_categories", $all_total_categories);
$site_template->register_vars("lang_all_total_categories", $lang_all_total_categories);
unset($all_total_categories);
unset($lang_all_total_categories);
... in /lang/<your_lang>/main.php use this ...
$lang['all_total_categories'] = "All Categories :";
... now you can use in home.html this tags ...
{lang_all_total_categories} {all_total_categories}
-
@mawenzi(http://www.brianpeschke.de/pics/smilies/anbeten rechts.gif)
-
Ich hätte gerne die Anzahl in Fettdruck, ich bekomme das nicht so recht hin (Stichwort Fehlermeldung)
-
... try this simple solution ... :wink:
{lang_all_total_categories} <b>{all_total_categories}</b>
-
That's a way too..
I've tried it in the stats.php and had no success... :cry:
-
It's a nice MOD and work's fine.
Now I want to show how many times mi site is visited.
But I don't know how make it....
Help me please.
Thank's ron.
-
nice stats info. thx! :D last question: how can i display "media directory: xxx MB" and "thumbnail directory: xxx MB" in home.html? thanks for help!!
-
is it working on Version: 1.7.3 ?
-
People keep asking how and where to put the code into the HTML pages but NO one answers...How come? Why can't someone just say where to put the code?? :evil:
-
Worked for me...after a while because I am no coder
-
Parse error: parse error, unexpected T_STRING in /home2/vuong184/public_html/gallery/includes/stats.php on line 2
http://emtoi.org/gallery/
Help me
-
Poste doch mal die Zeilen 1-5 aus deiner stats.php, aber sow ie ich das sehe, hast du ein "/" zuviel in Zeile 2, vielleicht ist es ja aus Zeile 3 dort hinein gerutscht...
Send us lines 1-5 of your stats.php. I think you have an "/" too much in line 2, perhaps it belongs in line 3...
-
works fine.. thanks!!!! :wink: :wink: :wink: :wink: :wink: :wink: :P :P :P :P
Hi all,
I did already forgot about this little modification I did. I was in fact the first little mod I did ever in PHP.
The idea is to show more statistics then the number of images and categories (which are shown by default).
This MOD will show:
- Number of Members
- Number of Image Votes
- Number of Image Hits
- Number of Image Comments
- Number of Image Downloads
All these are shown on totals, so it shows the total number of image hits over all images. You can see an example of it here: http://haunter.student.utwente.nl/Terrarevolution/galleries/index.php
// Ok, now lets get started
Creating the stats.php file
Make a new file called: stats.php
Save this empty file in the includes folder of 4images
Open stats.php with any code editor you like.
and copy past the following to your stats.php:
<?PHP
//-----------------------------------------------------
//--- Show number of Users ----------------------------
//-----------------------------------------------------
$sql = "SELECT COUNT(*) as users
FROM ".USERS_TABLE."
WHERE user_id <> ".GUEST;
$row = $site_db->query_firstrow($sql);
$total_users = "".$lang['users']."<B> ".$row['users']."</B>\n";
$site_template->register_vars("total_users", $total_users);
unset($total_users);
//-----------------------------------------------------
//--- Hits --------------------------------------------
//-----------------------------------------------------
$sql = "SELECT SUM(image_hits) AS sum
FROM ".IMAGES_TABLE;
$row = $site_db->query_firstrow($sql);
$sum = (isset($row['sum'])) ? $row['sum'] : 0;
$total_hits = "".$lang['total_hits']."<B> ".$row['sum']."</B>\n";
$site_template->register_vars("total_hits", $total_hits);
unset($total_hits);
//-----------------------------------------------------
//--- Votes -------------------------------------------
//-----------------------------------------------------
$sql = "SELECT SUM(image_votes) AS sum
FROM ".IMAGES_TABLE;
$row = $site_db->query_firstrow($sql);
$sum = (isset($row['sum'])) ? $row['sum'] : 0;
$total_votes = "".$lang['total_votes']."<B> ".$row['sum']."</B>\n";
$site_template->register_vars("total_votes", $total_votes);
unset($total_votes);
//-----------------------------------------------------
//--- Downloads ---------------------------------------
//-----------------------------------------------------
$sql = "SELECT SUM(image_downloads) AS sum
FROM ".IMAGES_TABLE;
$row = $site_db->query_firstrow($sql);
$sum = (isset($row['sum'])) ? $row['sum'] : 0;
$total_downloads = "".$lang['total_downloads']."<B> ".$row['sum']."</B>\n";
$site_template->register_vars("total_downloads", $total_downloads);
unset($total_downloads);
//-----------------------------------------------------
//--- Comments ----------------------------------------
//-----------------------------------------------------
$sql = "SELECT SUM(image_comments) AS sum
FROM ".IMAGES_TABLE;
$row = $site_db->query_firstrow($sql);
$sum = (isset($row['sum'])) ? $row['sum'] : 0;
$total_comments = "".$lang['total_comments']."<B> ".$row['sum']."</B>\n";
$site_template->register_vars("total_comments", $total_comments);
unset($total_comments);
?>
Now save the stats.php file.
ALWAYS BACKUP: any file you start editing as you might not be able to restore it when the mod doesn't work
Adding the statistics to the language files:
*NOTE* I only edited this in English, but you will have to copy this to any language you use and maybe translate the english.
Open the main.php file from the lang/[your language] folder of 4images.
Go all the way to the bottom of the file.
Find:
//-----------------------------------------------------
//--- Admin Links -------------------------------------
//-----------------------------------------------------
$lang['edit'] = "[Edit]";
$lang['delete'] = "[Delete]";
Add Before:
//-----------------------------------------------------
//--- Statistics --------------------------------------
//-----------------------------------------------------
$lang['users'] = "Total Members:";
$lang['total_hits'] = "Total Image Hits:";
$lang['total_votes'] = "Total Image Votes:";
$lang['total_downloads'] = "Total Image Downloads:";
$lang['total_comments'] = "Total Image Comments:";
Including the statistics in Index.php:
Open index.php in the root folder of 4images with any code editor you like.
Find:
require(ROOT_PATH.'includes/sessions.php');
Add after:
include(ROOT_PATH.'includes/stats.php');
Do the same for catergories.php, lightbox.php, top.php
(it might also work in memberlist.php, search.php, register.php etc. but I did not test them yet)
Now edit the template files that correspond with the php files you added the include to.
index.php = home.html
categories.php = categories.html
lightbox.php = lightbox.html
top.php = top.html
you can find the templates inside the templates/default folder of 4images.
In the templates you can now use the following tags:
{total_users} - This will show the total number of members
{total_votes} - This will show the total number of image votes
{total_comments} - This will show the total number of image comments
{total_hits} - This will show the total number of image hits
{total_downloads} - This will show the total number of image downloads
Uploading all the edited files:
Now upload all files you editted to the right folder at your webserver.
This is a list of files you need to upload:
./index.php
./categories.php
./lightbox.php
./top.php
./includes/stats.php
./lang/ (any language you editted) /main.php
./templates/ (any templates you editted) /home.html
./templates/ (any templates you editted) /categories.html
./templates/ (any templates you editted) /lightbox.html
./templates/ (any templates you editted) /top.html
of course if you editted any more files then the once I mentioned above, you will need to upload them too.
I think this is it. Please note that it could be that I made an error somewhere in the directions above. As soon as you notice any error, please let me know and I will correct it as soon as possible.
Enjoy this little mod!!!
Cheers,
Vraxor
-
how do i show this on whos_online.html
-
how do i show this on whos_online.html
I myself have not done this mod, but what you are asking seems pretty easy to do.
Edit that template to your liking or just add the tags to the bottom of the template (under {user_online_list}).
Then you can use these tags to show what you want:
In the templates you can now use the following tags:
{total_users} - This will show the total number of members
{total_votes} - This will show the total number of image votes
{total_comments} - This will show the total number of image comments
{total_hits} - This will show the total number of image hits
{total_downloads} - This will show the total number of image downloads
-
But CeJAy bro
Now edit the template files that correspond with the php files you added the include to.
index.php = home.html
categories.php = categories.html
lightbox.php = lightbox.html
top.php = top.html
Just like this do u know which is the .php file for whos_online.html
-
But CeJAy bro
Now edit the template files that correspond with the php files you added the include to.
Sorry I did not read close enough and missed that :oops:
Just like this do u know which is the .php file for whos_online.html
I think it is the sessions.php in the includes directory.
Not sure if you can just add the include(ROOT_PATH.'includes/stats.php'); or not on that, or if it has to be added differently.
-
I love this mod, Vraxor. I only wanted to see members and downloads. It was easy to add to the bottom of my page, and works fanastically! Thank you! :thumbup:
http://www.simsfashionbarn.net/downloads/
-
Hallo!
Ich verstehe zwar Englisch soweit, dass ich den Mod einigermaßen installieren konnte, nur begreife ich nicht wie und womit ich diesen Schritt erledigen soll:
Now edit the template files that correspond with the php files you added the include to.
index.php = home.html
categories.php = categories.html
lightbox.php = lightbox.html
top.php = top.html
you can find the templates inside the templates/default folder of 4images.
In the templates you can now use the following tags:
{total_users} - This will show the total number of members
{total_votes} - This will show the total number of image votes
{total_comments} - This will show the total number of image comments
{total_hits} - This will show the total number of image hits
{total_downloads} - This will show the total number of image downloads
-
I am needing a Mod of equal statistics to this of the attached image. I am twirling version 1.7.4
Thank you
meujovem
Brazil
-
Hallo!
Ich habe das Mod installiert, doch tritt nach Hochladen der geänderten html/php - Datein folgender Fehler auf: Der Banner im Header ist nicht mehr da, ebenso erscheinen 2 Kreuze für ein nicht vorhandenes Bild über dem Rahmen der Kategorieübersicht.
Was muss ich da verändern, dass dieses Problem behoben ist?
Gruß
Markus
-
Kann denn keiner helfen? (siehe mein obiges Posting)
-
@Markus/TSC
... dann überprüfe die url des Banners / der Bilder und berichtige sie in den entsprechenden html- / php-Dateien ...
... mehr lässt sich ohne Link nicht sagen ...
-
@mawenzi: Ich habe es zwar inzwischen geschafft, die Statistik einzufügen, aber das angesprochene Problem mit den fehlenden Banner sowie 2 Rahmen o.Ä. ist nach wie vor da: http://www.storm-chasing.de/4images (http://www.storm-chasing.de/4images)
-
... wie sollen die Bilddateien auch angezeigt werden, wenn sie nicht da sind ...
... das z.B. ist die URL von deinem Banner entspr. deinem Websitecode ...
... http://www.storm-chasing.de/templates/default/images/header_logo.gif ...
... aber wenn du diesen Link aufrufst ... ist er nicht vorhanden ...
... also sorge dafür das deine Grafik-Bilder im Ordner "http://www.storm-chasing.de/templates/default/images/" liegen ...
-
Danke für den Hinweis, hab ich übersehen :roll: Kannst du mir eventuell noch hierbei helfen: http://www.4homepages.de/forum/index.php?topic=17193.new#new (http://www.4homepages.de/forum/index.php?topic=17193.new#new) Die Seite dazu findest du unter http://www.storm-chasing.de/galeriet.htm (http://www.storm-chasing.de/galeriet.htm)
-
Hello,
may you help me with a small problem (I think so).
I´m no PHP Guru !!!
Within the stats.php
I´ve tried to include a mathematic function.
Dividing {total_votes by {total_hits}.
So I would get the percentage of votes from visited images!
I´ve tried the following, but get parse errors:
//------------------------------------------------------
//----- Berechnung ---------------------------------
//--------------------------------------------------
bcdiv($total_votes, $total_hits, 3)
$bcdiv = "".$lang['bcdiv']."<B> ".$bcdiv."</B>\n";
$site_template->register_vars("bcdiv", $bcdiv);
unset($bcdiv);
I´m really no Guru, so someone may help please
regardes
Mario
-
Ok so where bcdiv come from ?
-
bcdiv I´ve found in a php manual:
it is the math function to divide two numbers
string bcdiv ( string left_operand, string right_operand [, int scale] )
<?php
echo bcdiv('105', '6.55957', 3); // 16.007
?>
that´s all I found
thanks mario
-
Better - use two SQL query for SELECT SUM . See example from admin/home.php file for see what is. ;)
-
Dear thunderstrike,
1) please may you tell me a bit more exact, what you mean?
2) I´ve got it (a bit)
//------------------------------------------------------
//----- Berechnung ---------------------------------
//--------------------------------------------------
echo bcdiv('total_votes', 'total_hits', 3);
but got the following (site is working anyway):
Warning: bcdiv(): Division by zero in /home/www/web386/html/4images/includes/stats.php on line 72
Why ???
thx
Mario
-
Change:
bcdiv($total_votes, $total_hits, 3);
$bcdiv = "".$lang['bcdiv']."<B> ".$bcdiv."</B>\n";
for:
$get_totals = $total_votes / $total_hits;
if ($get_totals > 0) {
$bcdiv = $lang['bcdiv']."<B> ".$get_totals."</B>\n";
} else {
$bcdiv = $lang['bcdiv']."<B> 0 </B>\n";
}
-
Dear Thunderstrike,
the same: division by zero!
//------------------------------------------------------
//----- Berechnung ---------------------------------
//--------------------------------------------------
$get_totals = $total_votes / $total_hits;
if ($get_totals > 0) {
$bcdiv = $lang['bcdiv']."<B> ".$get_totals."</B>\n";
} else {
$bcdiv = $lang['bcdiv']."<B> 0 </B>\n";
}
Maybe (I don´t know) because of this:
//-----------------------------------------------------
//--- Votes -------------------------------------------
//-----------------------------------------------------
$sql = "SELECT SUM(image_votes) AS sum
FROM ".IMAGES_TABLE;
$row = $site_db->query_firstrow($sql);
$sum = (isset($row['sum'])) ? $row['sum'] : 0;
$total_votes = "".$lang['total_votes']."<B> ".$row['sum']."</B>\n";
$site_template->register_vars("total_votes", $total_votes);
unset($total_votes);
last line!
//-----------------------------------------------------
//--- Hits --------------------------------------------
//-----------------------------------------------------
$sql = "SELECT SUM(image_hits) AS sum
FROM ".IMAGES_TABLE;
$row = $site_db->query_firstrow($sql);
$sum = (isset($row['sum'])) ? $row['sum'] : 0;
$total_hits = "".$lang['total_hits']."<B> ".$row['sum']."</B>\n";
$site_template->register_vars("total_hits", $total_hits);
unset($total_hits);
last line too
-
Ah ! ok so
find:
unset($total_votes);
move after this:
unset($total_hits);
(Keep same change of my post before)
-
just the same: division by zero!
Only an idea:
how to get "new" variables out of "total_hits" and "total_votes" - inside the functions?
mario
-
Why no use this MOD:
http://www.4homepages.de/forum/index.php?topic=12008.0
;)
-
I´ve got it to compute !
//-----------------------------------------------------
//--- Votes -------------------------------------------
//-----------------------------------------------------
$sql = "SELECT SUM(image_votes) AS sum
FROM ".IMAGES_TABLE;
$row = $site_db->query_firstrow($sql);
[b]$bewert = [/b]$sum = (isset($row['sum'])) ? $row['sum'] : 0;
$total_votes = "".$lang['total_votes']."<B> ".$row['sum']."</B>\n";
$site_template->register_vars("total_votes", $total_votes);
unset($total_votes);
and
$sql = "SELECT SUM(image_hits) AS sum
FROM ".IMAGES_TABLE;
$row = $site_db->query_firstrow($sql);
$treffer = $sum = (isset($row['sum'])) ? $row['sum'] : 0;
$total_hits = "".$lang['total_hits']."<B> ".$row['sum']."</B>\n";
$site_template->register_vars("total_hits", $total_hits);
unset($total_hits);
and
echo bcdiv ($bewert, $treffer, 4);
I can see the correct result on top of the screen.
But when I use this (thunderstrike) code, nothing happens!
$get_totals = bcdiv ($bewert, $treffer, 4);
if ($get_totals > 0) {
$bcdiv = $lang['bcdiv']."<B> ".$get_totals."</B>\n";
} else {
$bcdiv = $lang['bcdiv']."<B> 0 </B>\n";
}
$site_template->register_vars("get_totals", $get_totals);
I also have my "bcdiv" in the lang/main.php file
$lang['bcdiv'] = "Entspricht Prozent:";
What´s wrong in the last part of the script?
thx Mario
-
I´ve got it !
This was learning by doing!
And it is sooooo easy!- when you know it!
//------------------------------------------------------
//----- Berechnung ---------------------------------
//--------------------------------------------------
$get_totals = bcdiv ($bewert, $treffer, 4);
$ergebnis = $get_totals*100;
$site_template->register_vars("ergebnis", $ergebnis);
Result:
(http://vipersgarden.at/4images/test/Statistik_end.gif)
But anyway,
thanks for all help!!
Mario
-
Hello.
I've started a gallery. It is possible to increment registered users (of course not regiistering one, and another, and another...)? In others words, I don't want to appear 0 registered users. How can I make it appear 100 registered user per example?
Best regards
-
hmmm...
i didn't got this....
where should this be visible?
this one:
There are currently 2 registered user(s) (1 among them invisible) and 0 guest(s) online.
?
-
That was my fault... hard to explain.
No... here:
Registered Members: 0
-
where you see this?
-
On home page.
I've installed this MOD http://www.4homepages.de/forum/index.php?topic=3303.0
-
in that case you should ask this question as a reply to the mod's topic. You'll have more chances get the answer from people who know that mod.
-
instead of {total_users} in template, write down...
i do have 100 users..
it's simple :mrgreen:
-
Right... :lol:
-
merged :P
-
I have a tip:
Put this line in your includes/page_header.php, so you don't have to put it in each page :wink:
include(ROOT_PATH.'includes/stats.php');
-
I have a tip:
Put this line in your includes/page_header.php, so you don't have to put it in each page :wink:
include(ROOT_PATH.'includes/stats.php');
Sorry the question... but...
how can I put the {whos_online} on all the sections?
-
Hi!
I've read all pages but no one really wrote how to display total image votes. Can someone help?
Thank you! This mod is awesome! :)
-
thanks and i have another Problem When go to search page :oops:
http://nagmat.com/search.php :?
show codes 8O
Notice: Undefined index: perm_images in /home/nagmat/public_html/includes/stats.php on line 80
Notice: Undefined index: awaiting_validation in /home/nagmat/public_html/includes/stats.php on line 82
Notice: Undefined index: new_member_welcome in /home/nagmat/public_html/includes/stats.php on line 84
Notice: Undefined index: users in /home/nagmat/public_html/includes/stats.php on line 86
Notice: Undefined index: total_hits in /home/nagmat/public_html/includes/stats.php on line 88
Notice: Undefined index: total_votes in /home/nagmat/public_html/includes/stats.php on line 90
Notice: Undefined index: total_downloads in /home/nagmat/public_html/includes/stats.php on line 92
Notice: Undefined index: total_comments in /home/nagmat/public_html/includes/stats.php on line 94
Notice: Undefined index: total_postcards in /home/nagmat/public_html/includes/stats.php on line 96
Notice: Undefined variable: total_postcards in /home/nagmat/public_html/includes/stats.php on line 97
this is stats.php
http://www.mediafire.com/?zmmynmvj3on
-
The original stats.php files has only 60 lines of code, all these warning you showed started from line 80. The conclusion - the mistake is in your own modifications.
Without seeing the code, nobody could possible help you.
Did you add all these $lang['blah'] variables in your main.php language file?
[EDIT]ok, I must be blind...just found your stats.php :D[/EDIT]
-
The original stats.php files has only 60 lines of code, all these warning you showed started from line 80. The conclusion - the mistake is in your own modifications. Without seeing the code, nobody could possible help you.
Did you add all these $lang['blah'] variables in your main.php language file?
[EDIT]ok, I must be blind...just found your stats.php :D[/EDIT]
What files are you need ? :?
to solve the proplem
-
[1.7.4 - 1.7.7] search.php sets it's own error reporting (http://www.4homepages.de/forum/index.php?topic=26952.0)
This should do it.
-
@ VANO
Hello sir, god bless u
I just had query because i dont udnerstand something, i have done this MOD and it works perfect, so instead what i did is made it display for me on the left of the screen, i made a table and placed in inside userlogininfo.html,
Which the information is only displayed on the index page, as soon as i click on image for example, the statistics are not displayed, if click for example lightbox link , it is not displayed, but if i go back to my index.html the statistics are displayed, at first i thought it had something to do with include so i included - - -include(ROOT_PATH.'includes/stats.php'); into lightbox.php and details.php but it still did not work, so why is statistics viewable inside index but as soon as i navigate to another page the statistics are not viewable.
Thank u sir,
-
http://nagmat.com/rss.php?action=images
I have rss porplem
PLEASE REPLY ME About massege