You are here: Re: opening a page with the sole purpose of running an sql statement « PHP Programming Language « IT news, forums, messages
Re: opening a page with the sole purpose of running an sql statement

Posted by petersprc on 10/09/06 04:09

If replication, or a federated table (MySQL), or a remote mysql
connection isn't possible, the remote URL would work. Another option
would be to use a tracking image (1x1 transparent gif) that pointed to
server A. A would then have access to the page being viewed through
HTTP_REFERER. This method allows keep-alive to be used.

For collecting site/page stats, you might be interested in Google
Analytics (google.com/analytics) which is free, or a service like
DeepMetrix.

Depending on the app, you might take a performance hit if you open a
remote URL with each request. To optimize this, you could continue
storing the stats locally on B (say in some new tables that don't get
overwritten), and then occasionally post a dump of those tables to
server A using cURL. Batching the updates instead of sending each
insertion.

As a basic precaution, you would probably want to check the remote IP
($_SERVER['REMOTE_ADDR']) before evaluating any code. There are
additional measures you could take security-wise.

On Oct 8, 8:39 pm, "windandwaves" <nfranc...@gmail.com> wrote:
> Hi Folk
>
> I am running a site (A) that has a US mirror (B). This means that all
> the data from A is copied daily to B.
>
> On the site, I keep some statistics of the pages people visit, tracking
> them with a session and noting their searches, etc... for statistical
> purposes.
>
> The problem I have is that if someone visits site B then at the end of
> the day, their statistical data is going to be overriden by the update
> from A.
>
> To counter this, I envisaged a system where the stats dont just run an
> sql statement to update my MySql database, but instead, the statements
> "include" a URL on A that runs the statement.
>
> For example:
>
> ---
> Old procedure:
> function add_user_page() {
> mysql_query("INSERT INTO USER (PAGEID, USERID) VALUES (1,2);");
>
> }---
> New procedure:
> function add_user_page() {
> if(site B) {
>
> include_once("http://A.com/runstats.php?function=add_user_pageB&table=USER&V1=8&V2=9");
> }
> mysql_query("INSERT INTO USER (PAGEID, USERID) VALUES (8,9);");
>
> }---
> I would then create a file runstats.php with the following code:
>
> <?php
> call_user_function($_GET["function"], $_GET);
> function add_user_pageB ($name, $v1, $v2) {
> mysql_query("INSERT INTO USER (PAGEID, USERID) VALUES
> ('.$v1.','.$v2.');");}?>
>
> This is obviously super simplified and not tested.
>
> The questions I have are
>
> 1. is this a good method?
> 2. can I / should I use "include_once" or is there a better way to run
> (call) the runstats.php page?
>
> NOTE: my ISP does not allow me to connect directly from B to the
> database on A.
>
> Thanks in advance for any comments
>
> Nicolaas

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация