Modem-Help Forum Index Main Site
Modems
Downloads
Chips, Chipsets
Help [ Old Help ]
SearchAbuseAggregatorEFG
Modem-Help
Dedicated help on Modems
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Conteg :: Content Negotiation PHP Class :: v0.12.3 released
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Modem-Help Forum Index -> Site Info + Diary
View previous topic :: View next topic  
Author Message
Alex Kemp
Site Admin


Joined: 30 Jun 2004
Posts: 6088
Location: Nottingham, England

PostPosted: Wed Oct 04, 2006 11:13 am    Post subject: Conteg :: Content Negotiation PHP Class :: v0.12.3 released Reply with quote

Conteg.include v0.10 PHP Class : Documentation : Overview
Conteg :: Content Negotiation PHP Class :: v0.12.2 released
Conteg downloads

Thanks to Bob (CaveatLector) with the following message, we discovered an error within the code that sets 'Expiry', which keeps it at 1 hour, regardless of the parameter setting:
Quote:
Alex, thanks very much for making your Conteg class available. I was contemplating writing something similar myself, without fully understanding what would be involved, when I found a link to your code at WebmasterWorld.com. Wow, what a project! Not only did that require lots of coding, but also must have required lots of research into (or prior knowledge of) relevant standards. I am very impressed.

I was able to quickly implement Version 0.12.2 at a test site running under Apache 2 on a Windows 2000 Advanced Server. I watched resulting headers using Live HTTP Headers in Firefox as I experimented with various Constructor parameter array options. Everything worked as expected until I tried to change 'expiry'. Header 'expires' times default an hour into the future regardless of 'expiry' values passed to the class Constructor or the settings of other options.

For example, this:

$mdate = "Mon, 02 Oct 2006 05:33:00 GMT";
$param = array(
'use_etag' => TRUE,
'modified' => strtotime( $mdate ),
'expiry' => 900
);
$Encode = new Conteg( $param );
?>

Results in this header:

HTTP/1.x 200 OK
Via: 1.1 ARES
Connection: Keep-Alive
Proxy-Connection: Keep-Alive
Content-Length: 351
Expires: Tue, 03 Oct 2006 21:31:53 GMT
Date: Tue, 03 Oct 2006 20:31:53 GMT
Content-Type: text/html;charset=ISO-8859-1
Server: Apache
Last-Modified: Mon, 02 Oct 2006 05:33:00 GMT
Content-Language: en
Status: 200 OK
Content-Encoding: gzip
Vary: Accept-Encoding

Do you know what might be causing that?

Thanks again for making Conteg available.

-Bob

It was my bad. Here is part of my reply:
Quote:
An error on my part; look at lines 864->868:
864: // Expiry time - seconds (can be modified by Cache-Control, below)
865: if( !isset( $this->expires )) {
866: if( !isset( $param[ 'expires' ])) $param[ 'expiry' ] = 3600;
867: }
868: if( isset( $param[ 'expiry' ])) $this->expires = $this->now + $param[ 'expiry' ];

Line 866 s/b:
866: if( !isset( $param[ 'expiry' ])) $param[ 'expiry' ] = 3600;

That is now corrected in Conteg v0.12.3, and will be uploaded soon-ish.


It will be on the site shortly.

2009-04-16 Edited by AK
Edit Reason: Fixed URLs

_________________
Alex Kemp


Last edited by Alex Kemp on Thu Apr 16, 2009 2:17 am; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
CaveatLector



Joined: 04 Oct 2006
Posts: 2
Location: Salt Lake City, Utah, USA

PostPosted: Mon Oct 16, 2006 1:51 pm    Post subject: Conteg.include v0.12.3 Results Reply with quote

This is a note to let anyone interested in Alex’s Conteg,include class know that the fix in v0.12.3 corrected the header expiries problem I previously reported.

It also is to report a substantial benefit from using Conteg. Since implementing Conteg on a site with php-generated web pages about ten days ago my daily AdSense earnings have increased approximately 40 percent. Of course, AdSense earnings deviate daily for many reasons and it is rarely, if ever, possible know the causes with certainty. However, my daily earnings have become much more stable over the years as the number of unique visitors has grown from 100 per month at the outset of the AdSense program to the present 50,000 per month (as reported by awstats). The 40 percent earnings jump every day since Conteg implementation is unusual and convinces me of the importance of reporting meaningful (real) “Last Modified” dates in HTTP headers.

I should add that sites with fewer visitors wouldn’t be apt to have the immediate earnings jump I experienced, because Google doesn’t fully index sites with low levels of activity as often. My site was fully indexed a few hours after Conteg was implemented which made it possible to have quick benefits.

-Bob
Back to top
Send private message
Alex Kemp
Site Admin


Joined: 30 Jun 2004
Posts: 6088
Location: Nottingham, England

PostPosted: Mon Oct 16, 2006 6:35 pm    Post subject: Wow! I'm lost for words (almost) Reply with quote

CaveatLector:
Quote:
Since implementing Conteg ... my daily AdSense earnings have increased approximately 40 percent.

I mean... wow!

I can see the advertisement strapline now...

Hmm. As an immediate benefit, my concentration has always been on the bandwidth reduction it affords. Current stats for October show an 80% reduction thanks to the use of compression (from AWStats, www.modem-help.com only; 4.51 GB reduced to 918.59 MB; 15 days, 32,468 visitors, 128,288 pages, 819,782 hits). Total reduction is far higher, of course, thanks to caching (proxy + browser), 304s, etc. etc.. Next was the warm, moral glow of doing The Right Thing on the web, and also of knowing that you were getting pages to site visitors just as quickly as it was humanly possible to do so (the positive side-effect of all that reduction in page-size and caching). It never, ever occurred to me that there would also be such a positive lift to the bottom line. Makes sense, though.

Gosh, what an interesting report. Thanks for the feedback, CaveatLector. My cheque is in the post (just kidding, OK?)

Added:
Bob, since you use AWStats, you may be interested in this early post on updating the robots.pm file and also obtaining an updated robots.pm file here.

The key to accurate reports with AWStats is an up-to-date listing of bots, to isolate human-hits from bot-hits. To under-score this point, currently in October there are 128,288 human-inspired pages from this site, and 101,213 "Not viewed traffic" pages. The Googlebot and Adsense-bot have recorded 49,094 pages all by themselves.

Since I installed AWStats in May 05 I have, in my usual obsessive er, er (damn this truth bug) erm, typically diligent fashion, been finding new bots each month and keeping AWStats updated with them. You can download the robots.pm and benefit from that diligence.
_________________
Alex Kemp
Back to top
View user's profile Send private message Visit poster's website
CaveatLector



Joined: 04 Oct 2006
Posts: 2
Location: Salt Lake City, Utah, USA

PostPosted: Tue Oct 17, 2006 1:35 am    Post subject: AWStats Reply with quote

Thanks Alex...

-Bob
Back to top
Send private message
Oracle



Joined: 18 Feb 2009
Posts: 5
Location: UK

PostPosted: Wed Feb 18, 2009 11:29 am    Post subject: HELP! Reply with quote

HI Alex, I saw this class on webmaster world and PHPClasses.

I was wondering how to use it?

I have an SQL database and have a last edited field. How do utilize this class to output a header to indicate when the item was last edited.

Would be very grateful for your help.
Back to top
Send private message
Alex Kemp
Site Admin


Joined: 30 Jun 2004
Posts: 6088
Location: Nottingham, England

PostPosted: Wed Feb 18, 2009 12:24 pm    Post subject: A mini HowTo... Reply with quote

Oracle wrote:
I have an SQL database and have a last edited field. How do utilize this class to output a header to indicate the item was last edited.

Hello Oracle, welcome to Modem-Help.

The brief answer is: "very easily".

For a slightly fuller answer, here is a mini-HowTo for you:

Quote:
Assumptions:
  1. Conteg declared (instantiated) early in program flow
  2. Conteg set NOT to output on declaration
  3. last_modified_date provided in UNIX timestamp format
  4. Conteg::show() used as last item in program
For a briefer example, where Conteg outputs immediately on declaration, see the first post.

Pseudo-program script:
Code:
<?php
   require_once('Conteg.class');
   $_Encode = new Conteg( array('noprint' => TRUE ));
...
// rest of program
...
   $param = array(
      'modified' => $MDATE // last-edit date from SQL DB
   );
   $_Encode->setup( $param );
   $_Encode->show();
?>

_________________
Alex Kemp
Back to top
View user's profile Send private message Visit poster's website
Oracle



Joined: 18 Feb 2009
Posts: 5
Location: UK

PostPosted: Wed Feb 18, 2009 1:49 pm    Post subject: Reply with quote

Its returning this error when I add in the include_once

Fatal error: Cannot redeclare Conteg::$if_match in /var/www/Conteg.class on line 130

I've tried renaming to a php file with no success. Sorry for the noob problems... Embarassed
Back to top
Send private message
Alex Kemp
Site Admin


Joined: 30 Jun 2004
Posts: 6088
Location: Nottingham, England

PostPosted: Wed Feb 18, 2009 2:55 pm    Post subject: Reply with quote

Oracle wrote:
Fatal error: Cannot redeclare Conteg::$if_match in /var/www/Conteg.class on line 130

That error can only occur if you are using one of the following:
  • include()
  • require()
...more than once.

It can NOT occur if you exclusively use one of the following:
  • include_once()
  • require_once()]
...no matter how many times you have the statement in your script(s).

Check your coding, and particularly your include()-ed files. You are re-declaring the Class more than once within the flow of your program. It is designed to be declared just a single time - you can instantiate as many instances as you wish (although it does not make much sense to do that either).

Extra:
As a useful tip, I have a single script that is used site-wide, and thus use:
    require_once('site-wide-script.include')
...at the top of all my scripts. The 'site-wide-script.include' file declares & sets all global variables and also contains all user-functions that need to be available site-wide. Such global variables are identified in my scripts with a leading underscore. In addition, instances of Classes in my scripts always begin with a Capital Letter. Hence the use of `$_Encode' in the example in my previous post.

The reason for the practice outlined in the previous paragraph is the same reason for using Classes: encapsulation. Once thoroughly debugged the global-script can be forgotten, since it 'just works'.

Postscript:
PHP does not care what you call your files. The `.php' suffix is, mostly, derived from 16-bit Windows' practice.
_________________
Alex Kemp
Back to top
View user's profile Send private message Visit poster's website
Oracle



Joined: 18 Feb 2009
Posts: 5
Location: UK

PostPosted: Thu Feb 19, 2009 7:49 am    Post subject: Reply with quote

Its still reporting the same thing.

I tried require_once and include_once.

Fatal error: Cannot redeclare Conteg::$if_match in /var/www/Conteg.class on line 130

Just to confirm I tried it in a totally empty script with just the two following lines.

Code:
<?php

require_once('Conteg.class');
$_Encode = new Conteg( array('noprint' => TRUE ));

?>


Sorry for my lack of knowledge.
Back to top
Send private message
Alex Kemp
Site Admin


Joined: 30 Jun 2004
Posts: 6088
Location: Nottingham, England

PostPosted: Thu Feb 19, 2009 2:15 pm    Post subject: Reply with quote

Oracle wrote:
I tried it in a totally empty script with just the two following lines

Bum.

Which version of Conteg are you using, please? Also, can you confirm that you are using the Conteg script file as-supplied, with no changes whatsoever?

Tell us which one, and I'll test it out on my home server.
_________________
Alex Kemp
Back to top
View user's profile Send private message Visit poster's website
Alex Kemp
Site Admin


Joined: 30 Jun 2004
Posts: 6088
Location: Nottingham, England

PostPosted: Thu Feb 19, 2009 11:58 pm    Post subject: Cannot reproduce your error Reply with quote

Sorry, Oracle, but I cannot reproduce your error. These are the exact steps I took just now on my home server (file location obscured, otherwise reported from Bash history exactly as transpired):

Code:
# mkdir temp
# cd temp
# 7z e non-modem/PHP/Conteg/Conteg.0.13.6.7z
7-Zip 4.45 beta  Copyright (c) 1999-2007 Igor Pavlov  2007-04-17
p7zip Version 4.45 (locale=en_GB,Utf16=on,HugeFiles=on,4 CPUs)

Processing archive: non-modem/PHP/Conteg/Conteg.0.13.6.7z

Extracting  basic-howto.0.13.txt
Extracting  Conteg.0.13.6.txt
Extracting  custom-error-howto.0.13.txt
Extracting  intro.0.13.txt
Extracting  php-with-html-plus-Apache-Notes-howto.0.13.txt

Everything is Ok
# mv Conteg.0.13.6.txt Conteg.class
# joe test.php # this is the exact replica of your test script above
# /usr/bin/php-cgi test.php
PHP Notice:  Conteg::Conteg: output buffering switched ON; any output before this point will trigger errors when headers are sent. in /root/temp/Conteg.class on line 2203
Content-type: text/html

The PHP Notice is to warn that output buffering is NOT switched on at instantiation, and that the Conteg constructor has just done so.

There is something else on your system that is causing your error. You will need to report your version of PHP in addition to the version of Conteg that you are testing.
_________________
Alex Kemp
Back to top
View user's profile Send private message Visit poster's website
oriceon



Joined: 15 Apr 2009
Posts: 2

PostPosted: Wed Apr 15, 2009 8:45 am    Post subject: Huh.. Reply with quote

First of all, hello people :)

I have same fatal error: Fatal error: Cannot redeclare Conteg::$if_match in ..

Why ? :|

Anyone resolved that?

Thanks

Last edit:

I found another solution to open CPU AVG... So you must change your function _loadAvg .. with another one .. _loadAvgUnix ..

here is example how to get load $load=@exec('uptime')

See that: http://www.vbseo.com/blogs/danny-bembibre/plugin-restrict-search-when-server-load-high-49/
Back to top
Send private message
Alex Kemp
Site Admin


Joined: 30 Jun 2004
Posts: 6088
Location: Nottingham, England

PostPosted: Wed Apr 15, 2009 4:21 pm    Post subject: Version of Conteg? PHP? Reply with quote

Hello oriceon, welcome to Modem-Help.

Thanks for the link to how to get load average for Unix. I'll add that to the next version of Conteg, with a credit for yourself.

If you will now give a little info on your problem, maybe I can also add a fix for your issue to the new version:

Version of Conteg?
Version of PHP?
OS?
etc, etc...
_________________
Alex Kemp
Back to top
View user's profile Send private message Visit poster's website
oriceon



Joined: 15 Apr 2009
Posts: 2

PostPosted: Wed Apr 15, 2009 4:31 pm    Post subject: Hy there :) Reply with quote

Thanks for reply.

I use: Conteg 0.13 downloaded from phpclasses.
PHP Version 5.2.6
Apache 2
OS: Linux

The first problem was that i receive an error about redeclare of $if_match.
I take a look in class and found 2 $if_match. One in line 130 and other in 133 and are same. I added // to line 133 so i escape that Fatal error.

Then, i receive another error about that cannot open /proc/loadavg because base_opendir is not allowed (on some server is disabled as you know..).

So, i look for some fix and i found that we can acces cpu avarange with unix command...

Now seems that he take cpu avg and all error / notice disapear.

Now, i must read again what about this class to see how realy work and what realy do because i didn`t understand all because i didn`t have time ..


Sorry my bad english...
Back to top
Send private message
Alex Kemp
Site Admin


Joined: 30 Jun 2004
Posts: 6088
Location: Nottingham, England

PostPosted: Thu Apr 16, 2009 4:36 am    Post subject: Fixed in v0.13.3 Reply with quote

Your English is fine, oriceon.

Thank goodness someone has finally told me which version they are using. The issue was fixed 2 years ago in v0.13.3. Nevertheless, it's my bad...

The version previously up at PHP Classes was v0.13. I had a look this evening, and found a 'Replace' link, so have uplifted v0.13.7 to replace it (current version, exactly as used on this site).

Your useful changes will be incorporated tomorrow (thanks again).
_________________
Alex Kemp
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Modem-Help Forum Index -> Site Info + Diary All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2007 phpBB Group