php-general Digest 12 May 2004 07:24:51 -0000 Issue 2758

Topics (messages 185936 through 185955):

Re: php calender
        185936 by: Daniel Clark
        185937 by: Torsten Roehr

include (or require) doesn't seem to work
        185938 by: Daniel Barbar
        185939 by: Torsten Roehr
        185940 by: Torsten Roehr
        185941 by: Daniel Clark

Re: HTTP_RAW_POST_DATA
        185942 by: Chris Boget
        185943 by: John W. Holmes
        185944 by: Chris Shiflett
        185945 by: Travis Low

Automatically send auth info
        185946 by: motorpsychkill

Re: loading 250kb include files, performance degration?
        185947 by: Justin French

PHP Sessions on Windows
        185948 by: David Mitchell
        185950 by: Daniel Clark
        185955 by: rich

User/Group rights system?
        185949 by: david david
        185953 by: Burhan Khalid

Re: What is the GD library and what can I do with it ?
        185951 by: Pete
        185954 by: Burhan Khalid

Re: Save page
        185952 by: Nadim Attari

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 ---
It could be a HTML table with links on the properties to view more details.

> I am currently working on a site for a vacation rental company.   They
> want
> the ability to show users the availability of certain properties.  The
> availability will be held in a mysql db so I assume I will have to
> dynamically build a small javascript menu or something....I am just
> looking
> for some good suggestions and examples from other's who have done this.
>
> I am not a fan of generating javascript from php.
>
> Thanks,
> Eddie

--- End Message ---
--- Begin Message ---
"Edward Peloke" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I am currently working on a site for a vacation rental company.   They
want
> the ability to show users the availability of certain properties.  The
> availability will be held in a mysql db so I assume I will have to
> dynamically build a small javascript menu or something....I am just
looking
> for some good suggestions and examples from other's who have done this.
>
> I am not a fan of generating javascript from php.
>
> Thanks,
> Eddie

Hi Eddie,

there is a great calendar package in PEAR:
http://pear.php.net/package/Calendar

There is a good example of how to build an HTML calendar from it:
http://pear.php.net/manual/en/package.datetime.calendar.intro-inahurry.php
(scroll down to the middle of the page)

I don't know why you want to use javascript here. I would do it this way:

- select all dates of free vacation properties of the given/current month
- put the dates from the DB result into an array
- create the calendar with the example from above and check for every day if
there is an entry for the day in your array
- if so give the table cell a specific color and/or link to page containing
detailed information
- otherwise blank the cell out or whatever

Hope this helps!

Regards, Torsten

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

             I'm almost ashamed to ask this question as surely enough the
problem is something very basic but, nonetheless, I can't put my finger on
it. I'm trying to implement the concept of a library (library.php) on PHP
where I define (once) all auxiliary functions and then use them in a file
(for instance index.php) via the 'require' or 'include' constructs. Here's a
reduced version of what I'm doing:



index.php:

<?php
$lang = (isset($_REQUEST['lang']) ? $_REQUEST['lang'] : "es");
echo "index.php: include_path is " . (ini_get('include_path'))."<br>";
require("http://tristan/library.php?lang=$lang";);
my_function("en");
?>



library.php:

<?php
echo "library.php: Called with $_SERVER[HTTP_HOST]:/$_SERVER[REQUEST_URI]
<br>";
function my_function($lang = "es") {
    echo "my_function() says $lang";
}
echo "library.php: loaded<br>";
?>



When I load index.php I get the following:



index.php: include_path is .:/usr/local/php/4.3.6/lib/php
library.php: Called with tristan://library.php?lang=es
library.php: loaded



Fatal error: Call to undefined function: my_function() in
/www/htdocs/index.php on line 5



            It seems that the name space on index.php never gets updated
with the function definitions made on library.php. What am I doing wrong?
Thanks! Cheers,



Daniel

--- End Message ---
--- Begin Message ---
"Daniel Barbar" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hi,
>
>              I'm almost ashamed to ask this question as surely enough the
> problem is something very basic but, nonetheless, I can't put my finger on
> it. I'm trying to implement the concept of a library (library.php) on PHP
> where I define (once) all auxiliary functions and then use them in a file
> (for instance index.php) via the 'require' or 'include' constructs. Here's
a
> reduced version of what I'm doing:
>
>
>
> index.php:
>
> <?php
> $lang = (isset($_REQUEST['lang']) ? $_REQUEST['lang'] : "es");
> echo "index.php: include_path is " . (ini_get('include_path'))."<br>";
> require("http://tristan/library.php?lang=$lang";);
> my_function("en");
> ?>
>
>
>
> library.php:
>
> <?php
> echo "library.php: Called with $_SERVER[HTTP_HOST]:/$_SERVER[REQUEST_URI]
> <br>";
> function my_function($lang = "es") {
>     echo "my_function() says $lang";
> }
> echo "library.php: loaded<br>";
> ?>
>
>
>
> When I load index.php I get the following:
>
>
>
> index.php: include_path is .:/usr/local/php/4.3.6/lib/php
> library.php: Called with tristan://library.php?lang=es
> library.php: loaded
>
>
>
> Fatal error: Call to undefined function: my_function() in
> /www/htdocs/index.php on line 5
>
>
>
>             It seems that the name space on index.php never gets updated
> with the function definitions made on library.php. What am I doing wrong?
> Thanks! Cheers,
>
>
>
> Daniel

Hi Daniel,

take a look at this section of the manual about including remote files:

>>>
If "URL fopen wrappers" are enabled in PHP (which they are in the default
configuration), you can specify the file to be included using a URL (via
HTTP or other supported wrapper - see Appendix J for a list of protocols)
instead of a local pathname. If the target server interprets the target file
as PHP code, variables may be passed to the included file using a URL
request string as used with HTTP GET. This is not strictly speaking the same
thing as including the file and having it inherit the parent file's variable
scope; the script is actually being run on the remote server and the result
is then being included into the local script.
<<<

Try including it as a local file:
require_once library.php'; // if it is in the same directory as the file you
have this line in

Also you don't have to pass $lang via Get to the file as the included code
will have access to $lang as it is then in the scope of the script.

Regards, Torsten

--- End Message ---
--- Begin Message ---
> Try including it as a local file:
> require_once library.php'; // if it is in the same directory as the file
you

Forgot a quote here, sorry:
require_once 'library.php';

Torsten

--- End Message ---
--- Begin Message ---
Think you want something like this.

require("/tristan/library.php");

> Hi,
>
>              I'm almost ashamed to ask this question as surely enough the
> problem is something very basic but, nonetheless, I can't put my finger on
> it. I'm trying to implement the concept of a library (library.php) on PHP
> where I define (once) all auxiliary functions and then use them in a file
> (for instance index.php) via the 'require' or 'include' constructs. Here's
> a
> reduced version of what I'm doing:
>
>
>
> index.php:
>
> <?php
> $lang = (isset($_REQUEST['lang']) ? $_REQUEST['lang'] : "es");
> echo "index.php: include_path is " . (ini_get('include_path'))."<br>";
> require("http://tristan/library.php?lang=$lang";);
> my_function("en");
> ?>
>

--- End Message ---
--- Begin Message ---
> > same configuration.  Where would I look to discover why one
> > server would have data held in $HTTP_RAW_POST_DATA
> > whereas the other server would not?
> Check the value of "always_populate_raw_post_data" in php.ini 
> on both servers.

That was it.  Thank you so very much!!

Chris

--- End Message ---
--- Begin Message ---
From: "Curt Zirzow" <[EMAIL PROTECTED]>
> * Thus wrote John W. Holmes ([EMAIL PROTECTED]):
> > 
> > Check the value of "always_populate_raw_post_data" in php.ini on both
> > servers.
> 
> Thats such a funny name.

So is "Zirzow"

---John Holmes...

--- End Message ---
--- Begin Message ---
--- Curt Zirzow <[EMAIL PROTECTED]> wrote:
> > Check the value of "always_populate_raw_post_data" in php.ini on
> both servers.
> 
> Thats such a funny name.

Not to mention misleading, since it doesn't always populate
$HTTP_RAW_POST_DATA when enabled. Always should mean always.

Chris

=====
Chris Shiflett - http://shiflett.org/

PHP Security - O'Reilly
     Coming Fall 2004
HTTP Developer's Handbook - Sams
     http://httphandbook.org/
PHP Community Site
     http://phpcommunity.org/

--- End Message ---
--- Begin Message ---
Chris Shiflett wrote:
--- Curt Zirzow <[EMAIL PROTECTED]> wrote:

Check the value of "always_populate_raw_post_data" in php.ini on

both servers.


Thats such a funny name.

Not to mention misleading, since it doesn't always populate $HTTP_RAW_POST_DATA when enabled. Always should mean always.

No, no, that's crazy talk. :-)


cheers,

Travis


-- Travis Low <mailto:[EMAIL PROTECTED]> <http://www.dawnstar.com>

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

Some of my webpages are no longer working with the IE browser after MS
implemented some security patches which disable sending authentication info
through the URL:

http://user:[EMAIL PROTECTED]

This no longer works with IE, but is fine with most other browsers.  Does
anybody know of a workaround using PHP to send the user & pass "in the
background", i.e. without user interaction?

Thanks for your help!

-m

--- End Message ---
--- Begin Message --- Merlin,

All I can suggest is that you attempt to restructure the include files on the next version of the app, so that the functions and includes are broken in the most logical manner possible (by task or topic for example), so that you're only including the bare minimum of files for each request/screen of the app, rather than including a whole bunch of stuff that may not be needed on every request.

As an example, you might have an include file dedicated to file uploads, which might be 10 or 20k. It's pointless to include such a file on every request, since it's only required by a small module/section of the site. Same goes for your login functions (which are only required on login and logout), your form validation libraries (only required when there's a form to validate), etc etc.

You may also decide it's not worth the work... to bench mark, make a copy of all the code necessary to have a certain part of the site function, but without grabbing anything unnecessary. Run the site with the big includes (250k) and run the stripped down version a few times each (using microtime() for timing it), and compare the results.

If even that sounds like too much work, you may be able to fabricate a test case using dummy functions and code, which may give some accurate answers, or may not :)


On 12/05/2004, at 1:44 AM, Merlin wrote:


Hi there,

I am working on a complex webapp written in php. Recently I was reading about performance issues and after analysing the code I found that most of the files load 5 external php include files to run. All together those include files make about 250KB (there are 5 files).

Now I am wondering if loading 250KB on include files, each time a page = php script is called, is slowing down the webapplication a lot or not. Is this even
noticable while surfing the site. I am wondering about response times since I found them a bit slow (the time I click on the link until the page starts to display).


Thank you for any advice,

Merlin

PS: The system is a p4 2.4G with 1G RAM and about 500.000PI a month.


---
Justin French
http://indent.com.au

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

How does one get sessions working on Windows? I have modified my php.ini
file so that session.save_path = C:\Temp, restarted and Apache. Still I get
this error message:

Warning: session_start(): open(/tmp\sess_26310affee160329c9e50f27663f8971,
O_RDWR) failed: No such file or directory (2) in
c:\apache\htdocs\dbmdata\admin\61646d696e.php on line 2

This is the code that is triggering the error. It seems very straightforward
to me:

session_start();
        echo $_SESSION['user'];

Why is this so incredibly difficult?

Thanks,

Dave

--- End Message ---
--- Begin Message ---
Sounds right.

Do you have a C:\temp directory?

>>How does one get sessions working on Windows? I have modified my php.ini
>>file so that session.save_path = C:\Temp, restarted and Apache. Still I get
>>this error message:
>>
>>Warning: session_start(): open(/tmp\sess_26310affee160329c9e50f27663f8971,
>>O_RDWR) failed: No such file or directory (2) in
>>c:\apache\htdocs\dbmdata\admin\61646d696e.php on line 2
>>
>>This is the code that is triggering the error. It seems very straightforward
>>to me:
>>
>>session_start();
>>      echo $_SESSION['user'];
>>

--- End Message ---
--- Begin Message ---
> How does one get sessions working on Windows? I have modified my php.ini
> file so that session.save_path = C:\Temp, restarted and Apache.
> Still I get
> this error message:
>
> Warning: session_start(): open(/tmp\sess_26310affee160329c9e50f27663f8971,
> O_RDWR) failed: No such file or directory (2) in
> c:\apache\htdocs\dbmdata\admin\61646d696e.php on line 2
>

check you have edited the correct php.ini -- run <? phpinfo() ?> and check
where the ini file is to make sure you changed the correct one...

hth
rich

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

Does anyone know of an open source "user/group" based
permission system built with php/MySQL?

That is, the effective rights for any user on a
specific secured object are computed from various
permit/deny permissions assigned to the user or any of
the groups he/she belongs to.

PEAR::Auth seems only to support basic user
authentication.

Thanks,

David


        
                
__________________________________
Do you Yahoo!?
Yahoo! Movies - Buy advance tickets for 'Shrek 2'
http://movies.yahoo.com/showtimes/movie?mid=1808405861 

--- End Message ---
--- Begin Message --- david david wrote:
Hello,

Does anyone know of an open source "user/group" based
permission system built with php/MySQL?

That is, the effective rights for any user on a
specific secured object are computed from various
permit/deny permissions assigned to the user or any of
the groups he/she belongs to.

Drupal [ http://www.drupal.org ] has this functionality built in, but I don't know of a standalone script that does this.

--- End Message ---
--- Begin Message ---
Hello Rob,

> What is your local environment?  (OS, PHP version, etc.)
> If you're running windows, most likely all you will have to do is change
> your php.ini.

The OS used is Windows XP.

Thank you very much.
Webmaster


For all usenet/forum/mailinglist users:
http://www.netmeister.org/news/learn2quote.html

--- End Message ---
--- Begin Message --- Pete wrote:

Hello Rob,


What is your local environment?  (OS, PHP version, etc.)
If you're running windows, most likely all you will have to do is change
your php.ini.


The OS used is Windows XP.


Open your php.ini file, set your extension_dir variable to where the extensions directory is. If you installed php in c:\php, then the directory is c:\php\extensions.


The gd library is bundled with the .zip package for Windows. If you downloaded the .exe (binary installer), you may be missing some extensions. Download the .zip file for Windows, uncompress it, and then copy all the files from the extensions directory into your local php install folder.

Once you've done that, uncomment remove the ; from the line in php.ini that reads ;extension=gd.dll ( I think that's what its called, may also be gd2.dll ). Save php.ini, restart your web server, and then view the output from phpinfo();

Should see the gd extension enabled :)
--- End Message ---
--- Begin Message ---
"Brandon Holtsclaw" <[EMAIL PROTECTED]> a écrit dans le message de
news:[EMAIL PROTECTED]
> try something like
>
> $handle = fopen ("http://www.pagetoget.com/thispage.html";, "rb");
> $contents = "";
> do {
>     $data = fread($handle, 1024);
>     if (strlen($data) == 0) {
>         break;
>     }
>     $contents .= $data;
> } while(true);
> fclose ($handle);
>

>From the PHP manual:
// Another example, let's get a web page into a string.  See also
file_get_contents().
$html = implode ('', file ('http://www.example.com/'));

> then you have all text from the .html page in $contents and you can do a
> fwrite on it to a local file, echo it, str_rep etc etc etc
>
> Brandon Holtsclaw
> [EMAIL PROTECTED]
>
>
> ----- Original Message ----- 
> From: "Mike Mapsnac" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Monday, May 10, 2004 10:37 AM
> Subject: [PHP] Save page
>
>
> > Hello
> >
> > I' m writing php script that will request page and save it locally. The
> page
> > URL will be parameter (example: http://www.pagetoget.com/thispage.html).
> How
> > php can request such page and save it locally on the file?
> >
> > Thanks

--- End Message ---

Reply via email to