php-general Digest 3 Jan 2005 15:06:47 -0000 Issue 3206

Topics (messages 205487 through 205520):

Re: critique this code please
        205487 by: Curt Zirzow
        205488 by: Nigel Jones
        205489 by: Curt Zirzow

Using SSL
        205490 by: Daniel Lahey
        205495 by: Jonel Rienton

unable to write a text file larger than 10Mb
        205491 by: Sagar C Nannapaneni
        205498 by: Burhan Khalid
        205502 by: Sagar C Nannapaneni

Re: function problem
        205492 by: Greg Beaver
        205493 by: Viktor Popov
        205494 by: Viktor Popov
        205499 by: Viktor Popov

or-die option - Opinions please...
        205496 by: gustav.varupiraten.se
        205497 by: Burhan Khalid

Calculate No Of Days
        205500 by: khuram noman
        205503 by: RaTT
        205506 by: tg-php.gryffyndevelopment.com

Register Globals=ON
        205501 by: HarryG
        205514 by: Greg Donald

Total Server Sessions
        205504 by: HarryG
        205517 by: Greg Donald

Re: Calendar Script
        205505 by: HarryG

migrating to PHP 5 + Apache 2 from PHP 4.3.8 + Apache 1.3.33.
        205507 by: symbulos partners
        205508 by: Rasmus Lerdorf
        205510 by: symbulos partners
        205512 by: symbulos partners
        205519 by: Rasmus Lerdorf

png.h not found, something's going wrong in my PHP installation
        205509 by: Aaron Paulley

Re: How to argue with ASP people...
        205511 by: John Sands

Re: php vs java....
        205513 by: Greg Donald

Re: Is there any way that PHP will issue a warning when using undeclared vars?
        205515 by: Greg Donald

newbie.. $_GET & $_POST
        205516 by: Pablo D Marotta
        205518 by: Pablo D Marotta
        205520 by: John Nichel

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [email protected]


----------------------------------------------------------------------
--- Begin Message ---
* Thus wrote Sebastian:
> i have this small function for a template system (if you want to call it
> that ;)
> 
> my idea was having something simple to separate html code from php and i
> think using something like smarty is too big for me and i really dont have
> time to learn to use it. so i have this code here:
> 
> http://www.cstrike-planet.com/function.phps
> 
> i call this function which reads .tpl files which contain html and some
> $vars, then in my pages use something like:
> 
> eval('echo("' . template('home_index') . '");');

I don't quite understand the purpose of this when either an
include() or readfile() will do the job, and not to mention much
faster and less memory intensive.


Curt
-- 
Quoth the Raven, "Nevermore."

--- End Message ---
--- Begin Message ---
I personally don't see anything wrong with it.  It's actually better
than any of my attempts to do templating.

BTW Curt: Check your clock/s, it seems to be a day out.


On Sun, 2 Jan 2005 02:46:40 +0000, Curt Zirzow
<[EMAIL PROTECTED]> wrote:
> * Thus wrote Sebastian:
> > i have this small function for a template system (if you want to call it
> > that ;)
> >
> > my idea was having something simple to separate html code from php and i
> > think using something like smarty is too big for me and i really dont have
> > time to learn to use it. so i have this code here:
> >
> > http://www.cstrike-planet.com/function.phps
> >
> > i call this function which reads .tpl files which contain html and some
> > $vars, then in my pages use something like:
> >
> > eval('echo("' . template('home_index') . '");');
> 
> I don't quite understand the purpose of this when either an
> include() or readfile() will do the job, and not to mention much
> faster and less memory intensive.
> 
> Curt
> --
> Quoth the Raven, "Nevermore."
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


-- 
N Jones
#newzealand @ irc.freenode.net
The future of IRC is coming,

--- End Message ---
--- Begin Message ---
* Thus wrote Nigel Jones:
> I personally don't see anything wrong with it.  It's actually better
> than any of my attempts to do templating.

There are a  lot of things with the system, imo, i just stopped at
the point where I read:

  eval('echo "'. template($foo) . '")');

all that evaluates to is a simple:

  include(template_filename($foo));

Without the overhead of:

  eval() - wich is know to be the slowest method to execute code
  echo() - instead of php  having to go and evaluate a string the
           contents of the files are read directly to the browser 
           on an include.
  template() - a function that goes out and builds a sting and pre
               processes it (side note, Hypertext Preparsing)


The function.phps file has already been evalutate so I'll just
point out some of the points for that file.

  - no need for the globals, use static for the $templatecache
    and pass a parameter to the function template to be verbose or
    not (aka $setting['debugtemplate'])

    * this will provide for a cleaner and more isolated function.

  - use isset($templatecache[$templatename]) instead
    
    * prevents unnescesary E_NOTICE errors

  - the use of file_get_contents is much prefered over opening a
    file handle, etc.  Althogh file_get_contents() requires >=
    4.3.0, php should be upgraded anyway.

    * file_get_contents is known to be much faster and efficient
      than the other alternatives


  - overuse of addslashes then stripping them down, using
    str_replace with the first two parameters as array's to
    specifiy what needs to get cleaned up.

    * just too much overhead.


One major point that should be noted is that php *is* a templating
system already, so re-creating somthing like this is not really
necessary.

If caching is a desired thing, for starters the filesystem will
already do caching on recently accessed files, so OS level
optimizations can be done.  Also you can use things like APC
(http://pecl.php.net/package/APC).

  
> 
> BTW Curt: Check your clock/s, it seems to be a day out.

Thanks for the heads up on this.

 

Curt
-- 
Quoth the Raven, "Nevermore."

--- End Message ---
--- Begin Message --- I've posted about this before, and I guess I'm just thick, but I'm just not getting it.

I need to implement secure transactions for a client, but I just can't figure out how to open a page with an https prefix. The server has mod-ssl and OpenSSL compiled into it:

Apache/1.3.33 (Unix) mod_auth_passthrough/1.8 mod_log_bytes/1.2 mod_bwlimited/1.4 PHP/4.3.9 FrontPage/5.0.2.2635 mod_ssl/2.8.22 OpenSSL/0.9.7a PHP-CGI/0.1b

Here's the PHP config:

'./configure' '--with-apxs=/usr/local/apache/bin/apxs' '--with-xml' '--enable-bcmath' '--enable-calendar' '--with-curl' '--with-dom' '--with-dom-xslt' '--with-dom-exslt' '--enable-exif' '--enable-ftp' '--with-gd' '--with-jpeg-dir=/usr/local' '--with-png-dir=/usr' '--with-xpm-dir=/usr/X11R6' '--with-gettext' '--with-imap' '--with-imap-ssl' '--with-kerberos' '--enable-mbstring' '--enable-mbstr-enc-trans' '--enable-mbregex' '--with-mcrypt' '--with-mhash' '--with-ming=../ming-0.2a' '--enable-magic-quotes' '--with-mysql' '--with-openssl' '--enable-discard-path' '--with-pear' '--with-pspell' '--enable-sockets' '--enable-track-vars' '--with-ttf' '--with-freetype-dir=/usr' '--enable-gd-native-ttf' '--enable-versioning' '--enable-wddx' '--with-xmlrpc' '--with-zlib'

I'm unable to open any pages with an https prefix, .html or .php. I get the message:

The requested URL /index.html was not found on this server.

(or whatever page I try to open other than index.html) This is in Firefox.

If I try it locally, I get "Connection refused when attempting to contact localhost". This is in Firefox. If I try to open a page on the server in Safari, I get redirected to http://www.netidentity.com/ Huh? If I try it locally in Safari, I get 'Safari can't connect to the server. Safari can't open the page "https://localhost/ because it cannot connect to the server "localhost".' (I get the standard Apache default page as http://localhost/).

From everything I've read and been told, all that should be necessary is to compile ssl into the server and PHP and add the https prefix. Aargh.

Should I be consulting an Apache mail list? Try to get a gig bagging groceries? Any advice as to where to find information about using SSL would be HUGELY appreciated. TIA
--- End Message ---
--- Begin Message --- Consulting the Apache documentation is better, seems like you just missed configuring the conf file of Apache. Have you created the certificate for your domain? SSL will not be loaded unless you configure it in the conf file(httpd.conf/apache2.conf)

regards,

http://jonel.road14.com
--
I not know English well, but I know 7 computer languages.
                                                                ----anonymous


On Jan 2, 2005, at 11:41 PM, Daniel Lahey wrote:

I've posted about this before, and I guess I'm just thick, but I'm just not getting it.

I need to implement secure transactions for a client, but I just can't figure out how to open a page with an https prefix. The server has mod-ssl and OpenSSL compiled into it:

Apache/1.3.33 (Unix) mod_auth_passthrough/1.8 mod_log_bytes/1.2 mod_bwlimited/1.4 PHP/4.3.9 FrontPage/5.0.2.2635 mod_ssl/2.8.22 OpenSSL/0.9.7a PHP-CGI/0.1b

Here's the PHP config:

'./configure' '--with-apxs=/usr/local/apache/bin/apxs' '--with-xml' '--enable-bcmath' '--enable-calendar' '--with-curl' '--with-dom' '--with-dom-xslt' '--with-dom-exslt' '--enable-exif' '--enable-ftp' '--with-gd' '--with-jpeg-dir=/usr/local' '--with-png-dir=/usr' '--with-xpm-dir=/usr/X11R6' '--with-gettext' '--with-imap' '--with-imap-ssl' '--with-kerberos' '--enable-mbstring' '--enable-mbstr-enc-trans' '--enable-mbregex' '--with-mcrypt' '--with-mhash' '--with-ming=../ming-0.2a' '--enable-magic-quotes' '--with-mysql' '--with-openssl' '--enable-discard-path' '--with-pear' '--with-pspell' '--enable-sockets' '--enable-track-vars' '--with-ttf' '--with-freetype-dir=/usr' '--enable-gd-native-ttf' '--enable-versioning' '--enable-wddx' '--with-xmlrpc' '--with-zlib'

I'm unable to open any pages with an https prefix, .html or .php. I get the message:

The requested URL /index.html was not found on this server.

(or whatever page I try to open other than index.html) This is in Firefox.

If I try it locally, I get "Connection refused when attempting to contact localhost". This is in Firefox. If I try to open a page on the server in Safari, I get redirected to http://www.netidentity.com/ Huh? If I try it locally in Safari, I get 'Safari can't connect to the server. Safari can't open the page "https://localhost/ because it cannot connect to the server "localhost".' (I get the standard Apache default page as http://localhost/).

From everything I've read and been told, all that should be necessary is to compile ssl into the server and PHP and add the https prefix. Aargh.

Should I be consulting an Apache mail list? Try to get a gig bagging groceries? Any advice as to where to find information about using SSL would be HUGELY appreciated. TIA

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



--- End Message ---
--- Begin Message ---
Hello All,

This is very imp and urgent for me. I've a very large db on my remote website. 
I want to get a backup of that db. phpmyadmin is installed on the server..but 
if failed to create the backup (may b coz of the time outs). so i wrote my own 
class to get the backup. Its working fine except that PHP is not able to write 
a file larger than 10Mb. I've tried to export the data to Excel...The same 
problem repeated again. Is there any parameters to change in php to make it 
write larger files...???


/sagar

--- End Message ---
--- Begin Message --- Sagar C Nannapaneni wrote:
Hello All,

This is very imp and urgent for me. I've a very large db on my remote website. I want to get a backup of that db. phpmyadmin is installed on the server..but if failed to create the backup (may b coz of the time outs). so i wrote my own class to get the backup. Its working fine except that PHP is not able to write a file larger than 10Mb. I've tried to export the data to Excel...The same problem repeated again. Is there any parameters to change in php to make it write larger files...???

Are you sure your script isn't timing out?

--- End Message ---
--- Begin Message ---
yes,,

I'm sure that my script is not timing out...

Also i set mysql connection timeout to max.

/sagar
----- Original Message -----
From: "Burhan Khalid" <[EMAIL PROTECTED]>
To: "Sagar C Nannapaneni" <[EMAIL PROTECTED]>
Cc: <[email protected]>
Sent: Monday, January 03, 2005 3:37 PM
Subject: Re: [PHP] unable to write a text file larger than 10Mb


> Sagar C Nannapaneni wrote:
> > Hello All,
> >
> > This is very imp and urgent for me. I've a very large db on my remote
website. I want to get a backup of that db. phpmyadmin is installed on the
server..but if failed to create the backup (may b coz of the time outs). so
i wrote my own class to get the backup. Its working fine except that PHP is
not able to write a file larger than 10Mb. I've tried to export the data to
Excel...The same problem repeated again. Is there any parameters to change
in php to make it write larger files...???
>
> Are you sure your script isn't timing out?
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>


--- End Message ---
--- Begin Message ---
Hi Viktor,

Viktor Popov wrote:
Hi,

I'm trying to do the following but I don't have any success. Could you help
me here...
I have this code in mu page:

<?php
include "script/functions.php";
require 'script/common.inc';
$valid = TRUE;

if (isset ($_POST['submit'])) {
    foreach($_POST as $key=>$value) {
      $$key = $value;
    }

This is a huge security hole, far better is to do this:

if (isset ($_POST['submit'])) {
    foreach (array('field1', 'field2', 'field3') as $allowedfield) {
        if (isset($_POST[$allowedfield])) {
            $$allowedfield = $_POST[$allowedfield];
        }
    }
}

In addition, you really need to use mysql_escape_string() to avoid serious potential problems with sql injection attacks.

[NOTE: mysql_db_query() is deprecated, use mysql_query()/mysql_select_db()]

mysql_select_db($DB);
mysql_query('INSERT INTO blahbalhblahblah VALUES("' . mysql_escape_string($field1) . '" ....');


Regards,
Greg

--- End Message ---
--- Begin Message ---
Hi!
Thank you for the reply!
I have change the function:

function doReg($fname1="",$family1="",$company1="", $MOL1="", $dannum1="",

$bulstat1="", $phone1="", $email1="", $username1="", $password1="",
$payment1="",

$maillist1="", $Addr1="", $City1="", $zipcode1="", $Country1="",
$shippingName1="",

$shippingFamily1="", $shippingphone1="", $shippingAddr1="",
$shippingcity1="",

$shippingzipcode1="", $shippingCountry1="")
{

  if(!($link = mysql_pconnect ($DB_SERVER, $DB_LOGIN, $DB_PASSWORD)))
 {
   echo "the connection failed";
   exit();
 }


  if(!($newresult = mysql_db_query($DB, "insert into
users(name,family,company, MOL,

taxnum, bulstat, phone, email, username, password, payment, maillist, Addr,
City,

zipcode, Country, shippingName, shippingFamily, shippingphone, shippingAddr,

shippingcity, shippingzipcode, shippingCountry)
values('$fname1','$family1','$company1', '$MOL1', '$dannum1', '$bulstat1',
'$phone1',

'$email1', '$username1', '$password1', '$payment1', '$maillist1', '$Addr1',
'$City1',

'$zipcode1', '$Country1','$shippingName1','$shippingFamily1',

'$shippingphone1','$shippingAddr1', '$shippingcity1', '$shippingzipcode1',

'$shippingCountry1')")))
 {
   echo "the insertiont cannot be done";
   exit();
 }
    header("Location:http://$HTTP_HOST/$DOCROOT/allright.html";);
 exit();
}

When i try to insert ->  the problem is in the insertion. The message  "the
insertiont cannot be done"; appears. Do you know what could be the mistake?

Thank you!

Viktor

--- End Message ---
--- Begin Message ---
Hi, thank you for your reply! I'll consider carefully this holes. Thank you!

--- End Message ---
--- Begin Message ---
Hi,

Thank you for your reply!

I have changed the function like this:

function doReg($fname1="",$family1="",$company1="", $MOL1="", $dannum1="",
$bulstat1="", $phone1="", $email1="", $username1="", $password1="",
$payment1="", $maillist1="", $Addr1="", $City1="", $zipcode1="",
$Country1="", $shippingName1="", $shippingFamily1="", $shippingphone1="",
$shippingAddr1="", $shippingcity1="", $shippingzipcode1="",
$shippingCountry1="")
{

  mysql_pconnect ($DB_SERVER, $DB_LOGIN, $DB_PASSWORD) or
die(mysql_error());



 mysql_select_db($DB) or die(mysql_error());
  mysql_query( "insert into users(name,family,company, MOL, taxnum, bulstat,
phone, email, username, password, payment, maillist, Addr, City, zipcode,
Country, shippingName, shippingFamily, shippingphone, shippingAddr,
shippingcity, shippingzipcode, shippingCountry)
values('$fname1','$family1','$company1', '$MOL1', '$dannum1', '$bulstat1',
'$phone1', '$email1', '$username1', '$password1', '$payment1', '$maillist1',
'$Addr1', '$City1', '$zipcode1',
'$Country1','$shippingName1','$shippingFamily1',
'$shippingphone1','$shippingAddr1', '$shippingcity1', '$shippingzipcode1',
'$shippingCountry1')") or die (mysql_error());


}

I think that the problem is not in the insertion string because when write
the function body :
 mysql_pconnect(.....);
mysql_select_db($DB) or die(mysql_error());
mysql_query("insert into ....");

instead doReg() in register.php, everything works. I have inserted some data
in this way.
The problem is that A DATABASE is  NOT SELECTED. This is the message when I
use doReg().

The register.php   is   in the DOCROOT->emagazine.  In the subdirectory
script are "common.inc"  and  "functions.php". In common.inc is this:

<?php
 $DB_SERVER="localhost";
 $DB_LOGIN="admin";
 $DB_PASSWORD="******";
 $DB="emagazine";
 $HTTP_HOST="localhost:3000";
 $DOCROOT="emagazine";

?>

Is it all right? I think that $DB="emagazine"  should work. Here I select
the $DB, which name is "emagazine".

I don't understand what's going on:)



Thank you!

Viktor

--- End Message ---
--- Begin Message ---
Hi there all!

I'm thinking of the "or die" suffix (or option or whatever it is called)...

I can use or die together with opening a db.

open_mysqldb("bla.bla.") or die("couldn't connect to db");

But this is just useful when developing?

I don't want my users to see that a specific table can't be opened?
Or do I want that? What's your opinion?

/G
@varupiraten.se

--- End Message ---
--- Begin Message --- [EMAIL PROTECTED] wrote:
Hi there all!

I'm thinking of the "or die" suffix (or option or whatever it is called)...

I can use or die together with opening a db.

open_mysqldb("bla.bla.") or die("couldn't connect to db");

But this is just useful when developing?

I don't want my users to see that a specific table can't be opened?
Or do I want that? What's your opinion?

For production sites, turn of error reporting and turn on error logging, or write your own error handler functions.


--Burhan
--- End Message ---
--- Begin Message ---
Hi 

Is there any function avialable in PHP to calculate
the no of days by passing 2 dates like 1 argument is
1/1/2005 and the second one is 1/2/2005 then it
returns the no of days or how can i do that if there
is no builtin function .

Regards
Khuram Noman

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

--- End Message ---
--- Begin Message ---
Hi Khuram 

I use this function 

function daysLeft($startDate,$endDate=false){
                // convert to timestamps

                $start_stamp = strtotime($startDate);
                $end_stamp   = ($endDate)?strtotime($endDate):time();

                if($start_stamp > $end_stamp){
                        // start date is passed end date
                        return "0";
                }
                $difference = $end_stamp - $start_stamp;
                return floor($difference/(24*60*60));
}

echo  daysleft("today", "01/05/2005");

Note, remeber to use the correct dat format otherwise you will see
some unexpected results.

Jarratt 


On Mon, 3 Jan 2005 02:33:58 -0800 (PST), khuram noman
<[EMAIL PROTECTED]> wrote:
> Hi
> 
> Is there any function avialable in PHP to calculate
> the no of days by passing 2 dates like 1 argument is
> 1/1/2005 and the second one is 1/2/2005 then it
> returns the no of days or how can i do that if there
> is no builtin function .
> 
> Regards
> Khuram Noman
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
>

--- End Message ---
--- Begin Message ---
Greetings!

I've posted this before, but there are always new readers so here's my script 
solution.  One of these days I'll make it a function or something, but this 
should give you a good general idea of how to do such a thing in case you need 
it again in the future.

btw: This also calculates hours, minutes, seconds, etc between two dates.  I 
start with date/times in string format just for ease of reading but you really 
only need them in serial date/time format ($stimestamp and $etimestamp):

<?php
# Standard format dates and times
$startdate = "10/30/02";
$starttime = "13:05:01";

$enddate = "12/30/03";
$endtime = "14:06:02";

# Break apart dates and times for mktime
list($smonth,$sday,$syear) = explode("/",$startdate);
list($emonth,$eday,$eyear) = explode("/",$enddate);
list($shour,$sminute,$ssecond) = explode(":",$starttime);
list($ehour,$eminute,$esecond) = explode(":",$endtime);

# Number of seconds in each timeframe, 1 month = 30 days
$secondsequiv = array("Years"=>31536000,
                               "Months"=>2592000,
                               "Days"=>86400,
                               "Hours"=>3600,
                               "Minutes"=>60);

# How many seconds between two dates/times
$stimestamp = mktime($shour,$sminute,$ssecond,$smonth,$sday,$syear);
$etimestamp = mktime($ehour,$eminute,$esecond,$emonth,$eday,$eyear);
$daydiff = $etimestamp - $stimestamp;

# Just to make sure I didn't use $remainder somewhere else in my script and 
forgot
if (isset($remainder)) unset($remainder);

# Cycle through timeframes checking to see if number is large enough to be a 
full year/month/day/etc
# If so, find out how many and store remainder for further processing
# If not, set to zero and continue processing
foreach ($secondsequiv as $timeframe=>$seconds) {
  if (isset($remainder)) { $checkvalue = $remainder; } else { $checkvalue = 
$daydiff; }
  if ($checkvalue >= $seconds) {
   $daydiffarr[$timeframe] = floor($checkvalue/$seconds);
   $remainder = $daydiff % $seconds;
  } else {
   $daydiffarr[$timeframe] = 0;
  }
}

# If $reminder is never used, then we're dealing with less than a minute's 
worth of time diff
if (isset($remainder)) {
  $daydiffarr["Seconds"] = $remainder;
} else {
  $daydiffarr["Seconds"] = $daydiff;
}

# Display results
foreach ($daydiffarr as $timeframe=>$count) {
  echo "$timeframe = $count<br>\n";
}
?>

= = = Original message = = =

Hi 

Is there any function avialable in PHP to calculate
the no of days by passing 2 dates like 1 argument is
1/1/2005 and the second one is 1/2/2005 then it
returns the no of days or how can i do that if there
is no builtin function .

Regards
Khuram Noman

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


___________________________________________________________
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

--- End Message ---
--- Begin Message ---
Which process is better to use in PHP?

Having register_globals=on and referring to variables as if($name){} or
using $_GET & $_POST statements like if(isset($_GET['name']))?

What is the main advantage/disadvantage in both cases.

Thanks
HarryG

--- End Message ---
--- Begin Message ---
On Mon, 3 Jan 2005 22:21:48 +1100, HarryG <[EMAIL PROTECTED]> wrote:
> Which process is better to use in PHP?
> 
> Having register_globals=on and referring to variables as if($name){} or
> using $_GET & $_POST statements like if(isset($_GET['name']))?
> 
> What is the main advantage/disadvantage in both cases.

It's all right there in the fine manual:

http://us2.php.net/register_globals


-- 
Greg Donald
Zend Certified Engineer
http://destiney.com/

--- End Message ---
--- Begin Message ---
Is there an easier way to count the total number of sessions running on a
PHP webserver? something like session_count();

I've seen some php site where it tells you how many people are currently
online, which I guess is being done by keeping a count of total sessions
running on the server

Thanks
HarryG

--- End Message ---
--- Begin Message ---
On Mon, 3 Jan 2005 23:02:19 +1100, HarryG <[EMAIL PROTECTED]> wrote:
> Is there an easier way to count the total number of sessions running on a
> PHP webserver? something like session_count();
> 
> I've seen some php site where it tells you how many people are currently
> online, which I guess is being done by keeping a count of total sessions
> running on the server

It's a piece of cake if you use database driven PHP sessions.

http://destiney.com/pub/Destiney_db_sessions_0.1.0.tar.bz2

Once you get your PHP sessions running inside a database counting the
sessions is just a select count(*) from sessions query.  You can even
force garbage collection before the count to get a realtime count.


-- 
Greg Donald
Zend Certified Engineer
http://destiney.com/

--- End Message ---
--- Begin Message ---
Cool.. just tried your script. I might try to convert it to Smarty template 
compatible code, in my spare time. Have you used Smarty Templates??
  "Joe Harman" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
  Hello,

  I just finished writing a basic calendar script... I wanted to pass it out to 
everyone here... maybe someone could use it... or, even better optimize it.. 
.and maybe share that with me.

  <?php

  function Cal_Month()
   {
    // Get Today's Date
     $todays_date = getdate();
    
    // Determine what month to display
     if(isset($_GET['month']))
      {
       $resolve_time = "1 ".$_GET['month']." ".$_GET['year'];
       $resolve_first_day_of_month = strtotime($resolve_time);
       $resolved_date = getdate($resolve_first_day_of_month);
      }
      else
      { $resolved_date = $todays_date; }
    
    // if this is the current month - say it's okay to mark today on the 
calendar
     if($todays_date['year'] == $resolved_date['year'] && $todays_date['month'] 
== $resolved_date['month'])
      {  $mark_today_on_calendar = TRUE; }

    // HOW MANY DAYS ARE IN THIS MONTH
     $days_in_current_month = cal_days_in_month(CAL_GREGORIAN, 
$resolved_date['mon'], $resolved_date['year']);
    
    // STRING TO START THE CALENDAR ON THE FIRST DAY OF THE MONTH
     $show_month = $resolved_date['month'];
     $show_year = $resolved_date['year'];
    
    // Get Info for Current Displayed Month 
     $string_time = "1 ".$show_month." ".$show_year;
     $first_day_of_month = strtotime($string_time);
     $first_day = getdate($first_day_of_month); //**************************
     $the_first_day_of_the_month = getdate($first_day_of_month); // Starts from 
the 1st
     
     $num_days_week = 7;
     $num_days_in_month = cal_days_in_month(CAL_GREGORIAN, 
$resolved_date['mon'], $resolved_date['year']);
    
    // Get info for NEXT month 
     $show_next = strtotime("+1 Month", $first_day_of_month); 
     $show_next_month_first_day = getdate($show_next);
     
    // Get info for PREV month 
     $show_prev = strtotime("-1 Month", $first_day_of_month); 
     $show_prev_month_first_day = getdate($show_prev);
     
     $next_month = $show_next_month_first_day['month'];
     $next_year = $show_next_month_first_day['year'];
     $prev_month = $show_prev_month_first_day['month'];
     $prev_year = $show_prev_month_first_day['year']; 
     
     $link_next_month = "<a 
href=\"?month=".$next_month."&year=".$next_year."\">Next Month </a>";
     $link_prev_month = "<a 
href=\"?month=".$prev_month."&year=".$prev_year."\">Prev Month </a>";
    
    // Table Size Variables... will be moved to CSS eventually
     $table_align = "center";
     $table_width = 500;
     $table_height = 50;
     $cell_width = $table_width/7;   
    // Start HTML for Building Calendar
    
      $cal_generated .= "<center>".$link_prev_month." 
".$link_next_month."</center>";
      $cal_generated .= "<table width=\"".$table_width."\" border=\"1\" 
align=\"".$table_align."\">";
      $cal_generated .=  "<tr><td 
colspan=\"7\"><center>".$the_first_day_of_the_month['month']." 
".$the_first_day_of_the_month['year']."</center></td></tr>";
      $cal_generated .= "<tr><td width=\"".$cell_width."\">Sun</td><td 
width=\"".$cell_width."\">Mon</td>";
      $cal_generated .= "<td width=\"".$cell_width."\">Tue</td><td 
width=\"".$cell_width."\">Wed</td><td width=\"".$cell_width."\">Thu</td>";
      $cal_generated .= "<td width=\"".$cell_width."\">Fri</td><td 
width=\"".$cell_width."\">Sat</td></tr>";
      
    // Initial Calendar Buildin Variables
      $first_week_marked = FALSE;
      $month_day_count = 1;
      $week_day_count = 0;

    // Start The Calendar Loop
      do {
        if($mark_today_on_calendar == TRUE && $todays_date['mday'] == 
$month_day_count)
         { 
          $highlight_today_open = "<font color=\"#990000\">"; 
          $highlight_today_close = "</font>";
         }
        else
         { 
          $highlight_today_open = "<font color=\"#000000\">"; 
          $highlight_today_close = "</font>";
         }
      
       // If it is the first day of the week open a ROW
        if($week_day_count == 0)
          { 
           $cal_generated .= "<tr>"; 
          }
        
         if ($first_week_marked == FALSE)
          {
           $blank_cell = 0;
            do {
             if($the_first_day_of_the_month['wday'] <> $blank_cell)
              {
               $cal_generated .= "<td height=\"".$table_height."\" 
valign=\"top\"></td>";
               $blank_cell++;
              }
             else
              { 
               
               
               $cal_generated .= "<td height=\"".$table_height."\" 
valign=\"top\">".$highlight_today_open 
."".$month_day_count."".$highlight_today_close."</td>";
               $first_week_marked = TRUE;
              }
              
            $week_day_count = $the_first_day_of_the_month['wday'];
             
           } while ($first_week_marked == FALSE);
            
          }
         else
          {
           $cal_generated .= "<td height=\"".$table_height."\" 
valign=\"top\">".$highlight_today_open 
."".$month_day_count."".$highlight_today_close."</td>";
          }
        
        $month_day_count++;
        
        // If it is the last day of the week close ROW
         if($week_day_count == 6)
          { 
           $cal_generated .= "</tr>"; 
          }
          
        $week_day_count++;
       
        // Countings 
         if($week_day_count == 7)
          {$week_day_count=0;}
          
      } while ($month_day_count <= $num_days_in_month);
   // End Calendar Loop
      
   $cal_generated .= "</table>";   
   return $cal_generated;
     
   }

  echo Cal_Month();
  ?>

  Joe Harman

--- End Message ---
--- Begin Message ---
Dear friends,

we would like to migrate a server where we host several websites (in virtual
hosting) to PHP 5 with Apache 2.

Technical support at the hosting provider told us there are still problems
about safety of threads on php 5 + Apache 2 (management of memory). They
would propose to migrate Apache to the pre-fork version in order to avoid
these problems (but we would be unable to use all the features of Apache
2). 

Is that right?

Has anybody switched to that combination already?

Any suggestion about recommended php, Apache versions?
-- 
symbulos partners
-.-
symbulos - ethical services for your organisation
http://www.symbulos.com

--- End Message ---
--- Begin Message --- symbulos partners wrote:
Dear friends,

we would like to migrate a server where we host several websites (in virtual
hosting) to PHP 5 with Apache 2.

Technical support at the hosting provider told us there are still problems
about safety of threads on php 5 + Apache 2 (management of memory). They
would propose to migrate Apache to the pre-fork version in order to avoid
these problems (but we would be unable to use all the features of Apache
2).


Is that right?

Has anybody switched to that combination already?

Any suggestion about recommended php, Apache versions?

You want to stay away from the threaded MPM's in Apache2.

Which specific Apache2 features are you looking for?

-Rasmus
--- End Message ---
--- Begin Message ---
Rasmus Lerdorf wrote:
> You want to stay away from the threaded MPM's in Apache2.

Why?

-- 
symbulos partners
-.-
symbulos - ethical services for your organisation
http://www.symbulos.com

--- End Message ---
--- Begin Message ---
Symbulos Partners wrote:

> Rasmus Lerdorf wrote:
>> You want to stay away from the threaded MPM's in Apache2.
> 
> Why?
> 

Which versions would be recommended then? We would like to be able to use
the new PHP object model, and at the same time use features like the
possibility of running scriping languages using a lower rights users, as in
apache 2.
-- 
symbulos partners
-.-
symbulos - ethical services for your organisation
http://www.symbulos.com

--- End Message ---
--- Begin Message --- symbulos partners wrote:
Symbulos Partners wrote:


Rasmus Lerdorf wrote:

You want to stay away from the threaded MPM's in Apache2.

Why?



Which versions would be recommended then? We would like to be able to use
the new PHP object model, and at the same time use features like the
possibility of running scriping languages using a lower rights users, as in
apache 2.

How does Apache2 let you do that?

As far as threading goes, it is simply not a good idea for a large complex system. There are too many moving parts to ensure that everything will be threadsafe. Most of the parts are actually threadsafe, but the huge problem is that we don't have a clear picture of which libraries out there aren't, and it is nearly impossible to debug a thread-related race condition. These race conditions tend to only happen under heavy load and only in certain conditions so they aren't reproducable which makes our job of tracking them down that much harder. People have reported success with PHP under Apache2 with a threaded MPM so you can give it a try and see how it goes. It may work perfectly, or it may work perfectly for weeks and then suddenly fall over. Unless you really know what you are doing we are not going to be able to help you with any occasional crashes.

I am a big believer in keeping the base infrastructure as simple as possible. You are going to layer a lot of complexity on top of Apache and PHP in the form of your web applications. You want to make sure that your building blocks are rock solid so if you see a problem you can be confident that it is something you did wrong. If your base is shaky everything you build on top of it is going to be that much more unstable.

-Rasmus
--- End Message ---
--- Begin Message ---
I found a thread a couple of weeks ago where someone had to create
symbolic links in order to get their install of PHP to work because
PHP wasn't able to find png.h.

I am having the same problem. I made no changes to the installation of
libpng, installed it in its default location and PHP cannot find
png.h, no matter what I set the dir= flag to.

Here is my ./configure:

./configure --with-mysql --with-apxs=/www/bin/apxs --with-xml
--enable-ftp --with-gd --enable-magic-quotes --with-jpeg-dir=/usr
--with-mcrypt --with-png-dir=/usr --enable-sockets --enable-track-vars
--enable-versioning --with-zlib --enable-bcmath --enable-calendar
--with-xpm-dir=/usr/X11R6 --enable-memory-limit

png.h on my system is located in /usr/lib

--- End Message ---
--- Begin Message ---
I was happy as an ASP developer - you can use MSXSL for XML
processing, ADO for database, and the file scripting object for file
processing. The weakness shows up when you want to do something that
Microsoft has not built into ASP or JavaScript or the COM objects I
just listed. You're stuck writing your own COM object in VB or C++. I
was in a C++ shop and writing C++ COM components for use in ASP is
just horrible. PHP has a much larger library.

Try to find something you need to do that will require you to write a
COM component if you use ASP, and it's built into PHP.


On Thu, 30 Dec 2004 08:38:18 -0800, Tony Di Croce <[EMAIL PROTECTED]> wrote:
> I am fairly new to PHP, but I am loving it... I have recently gotten
> involved in a business venture and I have been using PHP so far...
> Recently I have taken on a partner, and he is a big ASP guy...
> 
> I am not totally against ASP, but it would have to be pretty good to
> get me to switch at this point (PHP seems to do everything I need)...
> But I will need to convince him of this...
> 
> What points can I bring up in PHP's favor? In what areas does PHP trounce ASP?
> 
> --
> 
>     td
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
>

--- End Message ---
--- Begin Message ---
On Sun, 2 Jan 2005 21:48:01 -0500, GH <[EMAIL PROTECTED]> wrote:
> Can you please explain Threads to me?

Multiple isolated tasks executing at the same time.


-- 
Greg Donald
Zend Certified Engineer
http://destiney.com/

--- End Message ---
--- Begin Message ---
On Sun, 2 Jan 2005 16:23:34 -0800, Dan Eloff <[EMAIL PROTECTED]> wrote:
> My single biggest beef with PHP is the fact that it silently fails
> when I use a variable that has never been declared. Like if($sumbit)
> will always be false because the variable was really named $submit. My
> only clue that this is happening is whe the program fails to work as
> intended and I waste lots of time trying to find out why the block
> never executes.
> 
> Or if you forget to use $this->var and you just use $var. I just had
> that happen to me too. Wasted another 30 min.
> 
> Is there any way at all to control this? I went into my PHP.ini file,
> but my errors are set to E_ALL & E_STRICT which seems to be the
> highest level I can set.
> 
> If not I think we should seriously push for E_STRICT warnings if a
> variable is used without every being assigned to.

I usally do something like this when I start a project, so I can
easily turn it back off later when my code goes production:
 
if( $debug )
{
    error_reporting( E_ALL );
    ini_set( 'display_errors', 1 );
    ini_set( 'log_errors', 1 );
}
else
{
    error_reporting( E_ERROR | E_WARNING | E_PARSE );
    ini_set( 'display_errors', 0 );
}


-- 
Greg Donald
Zend Certified Engineer
http://destiney.com/

--- End Message ---
--- Begin Message ---
Hi there..
I need to pass variables to a page through an html link.
I do it like this:

<A href="Extra/excelListing3.php?buildQuery=<?php echo $buildQuery
?>">Export</A>

where 'buildQuery' is the variable I�m passing.

In the destination page, I capture it with $_GET and that�s it.

I want to know if there is any way of doing it without showing the variables in
the direction bar.

Thanks!

Pablo



American Express made the following
 annotations on 01/03/05 06:43:25
------------------------------------------------------------------------------
******************************************************************************

     "This message and any attachments are solely for the intended recipient 
and may contain confidential or privileged information. If you are not the 
intended recipient, any disclosure, copying, use, or distribution of the 
information included in this message and any attachments is prohibited.  If you 
have received this communication in error, please notify us by reply e-mail and 
immediately and permanently delete this message and any attachments.  Thank 
you."

******************************************************************************

==============================================================================

--- End Message ---
--- Begin Message ---
Hi there..
I need to pass variables to a page through an html link.
I do it like this:

<A href="Extra/excelListing3.php?buildQuery=<?php echo $buildQuery
?>">Export</A>

where 'buildQuery' is the variable I�m passing.

In the destination page, I capture it with $_GET and that�s it.

I want to know if there is any way of doing it without showing the variables in
the direction bar.

Thanks!

Pablo



American Express made the following
 annotations on 01/03/05 06:54:38
------------------------------------------------------------------------------
******************************************************************************

     "This message and any attachments are solely for the intended recipient 
and may contain confidential or privileged information. If you are not the 
intended recipient, any disclosure, copying, use, or distribution of the 
information included in this message and any attachments is prohibited.  If you 
have received this communication in error, please notify us by reply e-mail and 
immediately and permanently delete this message and any attachments.  Thank 
you."

******************************************************************************

==============================================================================

--- End Message ---
--- Begin Message --- Pablo D Marotta wrote:
Hi there..
I need to pass variables to a page through an html link.
I do it like this:

<A href="Extra/excelListing3.php?buildQuery=<?php echo $buildQuery
?>">Export</A>

where 'buildQuery' is the variable I�m passing.

In the destination page, I capture it with $_GET and that�s it.

I want to know if there is any way of doing it without showing the variables in
the direction bar.

Turn it into a form, and post it.

<form name="whatever" action="Extra/excelListing3.php" method="post">
<input type="hidden" name="buildQuery" value="<?php echo ( $buildQuery ); ?>" />
<a href="JavaScript:document.whatever.submit()">Export</a>
</form>


--
John C. Nichel
�berGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

--- End Message ---

Reply via email to