Gossamer Forum
Home : Products : Gossamer Links : PHP Front End :

[Plugin] Count_Impressions PHP Version...

Quote Reply
[Plugin] Count_Impressions PHP Version...
Here is a PHP version of my Count_Impressions plugin. Its not actually a pluing, but more of a 'mod'. Heres what you need to do;

1) Upload count.php to where-ever you hold your PHP scripts (usually along with add.cgi, modify.cgi etc). SEE ATTACHED FILE!

2) Add a new field called 'Impressions' to your Links def's. (Database > Links (drop down) > Properties (drop down)...)..make sure it is set to an INT!

3) Add the following to whatever template areas you want to track (i.e category.html, search_results.html etc).

--------------------------------
<?

$i = 0;
foreach ($links_loop as $thing => $val) {

$i++;
$new_array = $links_loop[$thing];
$add[$i] = $new_array[ID];

}

require("/home/dumps/public_html/templates/count.php");

impressions($add[0],$add[1],$add[2],$add[3],$add[4],$add[5],$add[6],$add[7],$add[8],$add[9],$add[10],$add[11],$add[12],$add[13],$add[14],$add[15],$add[16],$add[17],$add[18],$add[19],$add[20],$add[21],$add[22],$add[23],$add[24],$add[25],$add[26],$add[27],$add[28],$add[29],$add[30]);

?>
-------------------

4) replace /home/dumps/public_html/templates/count.php with the location to the script on your server.

That should be it. Obviously this will only work in dynamic mode (page.php)...Wink

Enjoy Smile

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] [Plugin] Count_Impressions PHP Version... In reply to
Yikes...you should really change that long ugly query to use WHERE ID IN(x,y,z) ...build it with php code rather than writing out a huge long list.

I'm not even sure what the code is doing but anyway...

Last edited by:

Paul: Jul 5, 2002, 6:54 AM
Quote Reply
Re: [Paul] [Plugin] Count_Impressions PHP Version... In reply to
Yeah, great one Paul! Maybe you should stick to Perl. There is nothing I can get rid of there...its down to a minimum of code as it is! I need that there to track all the ID numbers that are being sent to me!

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] [Plugin] Count_Impressions PHP Version... In reply to
So erm you are telling me that this query can't be shortened?

Code:
UPDATE ${PREFIX}Category SET Impressions = Impressions + 1 WHERE ID = $in_1 OR ID = $in_2 OR ID = $in_3 OR ID = $in_4 OR ID = $in_5 OR ID = $in_6 OR ID = $in_7 OR ID = $in_8 OR ID = $in_9 OR ID = $in_10 OR ID = $in_11 OR ID = $in_12 OR ID = $in_13 OR ID = $in_14 OR ID = $in_15 OR ID = $in_16 OR ID = $in_17 OR ID = $in_18 OR ID = $in_19 OR ID = $in_20 OR ID = $in_21 OR ID = $in_22 OR ID = $in_23 OR ID = $in_24 OR ID = $in_25 OR ID = $in_26 OR ID = $in_27 OR ID = $in_28 OR ID = $in_29 OR ID = $in_30

...hmm ok Andy :)

>>Yeah, great one Paul! Maybe you should stick to Perl.<<

Hmm its actually neither perl or php, it's SQL Tongue
Quote Reply
Re: [Paul] [Plugin] Count_Impressions PHP Version... In reply to
Yeah Paul..but that requires a re-write of the whoel script, as well as the code to put in category.html! I may look into it...but I don't know if its worth it, as not many people will probably use this script!

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] [Plugin] Count_Impressions PHP Version... In reply to
If you are passing 30 arguments from one subroutine to another or doing an SQL query with 30 OR's its time for a logic re-think.

Last edited by:

Paul: Jul 5, 2002, 8:56 AM
Quote Reply
Re: [Paul] [Plugin] Count_Impressions PHP Version... In reply to
Ok..I've edited it now, so that it creates the array of IDs, and then creates a query like;

sql_Category SET Impressions = Impressions + 1 WHERE ID NO(1,3,2)

However, this just gives an error;

There was a problem. It was: You have an error in your SQL syntax near 'NO(1,3,2)' at line 1. It seems to be the NO() function that isn't being liked Unsure

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] [Plugin] Count_Impressions PHP Version... In reply to
That's because I said use IN() not NO() Tongue
Quote Reply
Re: [Paul] [Plugin] Count_Impressions PHP Version... In reply to
Ok...here is the updated codes etc.

1) Replace count.php with the attached file.

2) Use the following code in templates such as category.html etc.

------------------------------------
<?

$i = 0;
$in_stuff = array();

foreach ($links_loop as $thing => $val) {

$i++;
$new_array = $links_loop[$thing];
$in_stuff[] = $new_array[ID];

}

require("/home/dumps/public_html/templates/count.php");

impressions($in_stuff);

?>

------------------------------------

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] [Plugin] Count_Impressions PHP Version... In reply to
Now how much better does that look...agree?
Quote Reply
Re: [Paul] [Plugin] Count_Impressions PHP Version... In reply to
Yes..it does...but it took longer to program!

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] [Plugin] Count_Impressions PHP Version... In reply to
Here's a global'ed version of Andy's code:
Code:
'count_impressions' => 'create_function("", \'
global $TAGS, $DB, $PREFIX;
if ($TAGS["links_loop"]) {
$link_id = array();
foreach ($TAGS["links_loop"] as $link) {
$link_id[] = $link["ID"]; }
$query = "UPDATE ${PREFIX}Category SET Impressions = Impressions + 1 WHERE ID IN(" . join(",", $link_id) . ")";
$sth = $DB->query($query); }
\');',
and if you want to just paste it right into the global editor:
Code:
create_function("", '
global $TAGS, $DB, $PREFIX;
if ($TAGS["links_loop"]) {
$link_id = array();
foreach ($TAGS["links_loop"] as $link) {
$link_id[] = $link["ID"]; }
$query = "UPDATE ${PREFIX}Category SET Impressions = Impressions + 1 WHERE ID IN(" . join(",", $link_id) . ")";
$sth = $DB->query($query); }
\');
And to use it just put:
Code:
<?$count_impressions()?>
in category.html, search_results.html, etc.

Remember, you'll also add the column like Andy said.

I forgot to mention that you will need to make a change to Links.inc.php as discussed here: http://www.gossamer-threads.com/...?post=203346;#203346

Adrian

Last edited by:

brewt: Jul 5, 2002, 12:54 PM