php-general Digest 1 Jul 2001 15:11:50 -0000 Issue 729

Topics (messages 55704 through 55729):

GMT Time and Setting Cookies in PHP
        55704 by: Gonyou, Austin

Re: (slightly OT) the bad and the good (hosting recommentations)
        55705 by: Jack Sasportas
        55710 by: Justin French

Cookie ?
        55706 by: Jack Sasportas
        55708 by: Jon Yaggie

Re: Capturing output of shell script.
        55707 by: Brad Hubbard

Re: Time out Errors?
        55709 by: Aral Balkan

Fatal Execution Error
        55711 by: Chris Cameron
        55717 by: Aral Balkan

Page not found for MSIE in SSL mode
        55712 by: Fikko Adhipranta

一个域名6个网站(域名注册大优惠)
        55713 by: 网络时代 Today'Network

accessing files not in www root directory.
        55714 by: Sterling Anderson
        55715 by: Chris Anderson
        55716 by: Sterling Anderson

Re: how to determine size of gz-handler output
        55718 by: Christian Reiniger

Re: new break tags
        55719 by: Christian Reiniger

Re: Stopping stolen / spoofed / linked sessions
        55720 by: Christian Reiniger

Re: Printing a string issue
        55721 by: Christian Reiniger

shtml includes
        55722 by: Jamie Saunders
        55726 by: Justin French
        55728 by: Gyozo Papp

Re: Pricing Advice Needed
        55723 by: Brad Hubbard

Re: emalloc / erealloc problem (was: help with custom session handler)
        55724 by: Delbono

Re: Uploading files
        55725 by: Gyozo Papp

safe_mode behavior modification request
        55727 by: Olivier PRENANT

Time Help
        55729 by: KPortsmout.aol.com

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]


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


What's a good method for setting time in GMT? as in the expiration date for
cookies? I saw two functions to do this with, but I haven't been able to get
them to output anything properly. 

-- 
Austin Gonyou
Systems Architect, CCNA
Coremetrics, Inc.
Phone: 512-796-9023
email: [EMAIL PROTECTED] 




It sounds like price is more important to you then quality of service etc.


John Monfort wrote:

>   www.pepiedesigns.com
>
>   PHP 4
>   Perl 5
>   MySQL
>   ASP
>   Apache
>   Web Access Panel
>   SSH
>   and a whole lot more...
>
> __________John Monfort_________________
> _+-----------------------------------+_
>      P E P I E  D E S I G N S
>        www.pepiedesigns.com
> "The world is waiting, are you ready?"
> -+___________________________________+-
>
> On Fri, 29 Jun 2001, Justin French wrote:
>
> > hi all,
> >
> > i'm about to change ISPs, and i'll probably be moving to a US based
> > server, on Unix, with Apache, PHP4, CGI, Perl 5, MySQL, etc etc.
> >
> > so far the best I can find (price/service level/features) is
> > experthost.com.au.  Has anyone got a bad experience with these guys, or
> > a good experience with annother ISP that they can recommend?
> >
> >
> > for what it's worth they offer a reseller package with 2-4 domains for
> > US$10/month each, all the way down to 25+ for US$4.99 each / month.
> > this is with 50 meg space, MySQL DB, 20 POPs, and much more.
> >
> >
> > i don't require dial up access, just hosting.
> >
> >
> > i'd be interested to hear of competitors to this ISP, or of any good /
> > bad experiences.  I'm ony interested in Australian, US, Canada or UK ISPs.
> >
> >
> >
> > many thanks
> >
> > jsutin french
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > To contact the list administrators, e-mail: [EMAIL PROTECTED]
> >
> >
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]

--
___________________________________________________________
Jack Sasportas
Innovative Internet Solutions
Phone 305.665.2500
Fax 305.665.2551
www.innovativeinternet.com
www.web56.net






Jack Sasportas wrote:
> 
> It sounds like price is more important to you then quality of service etc.


Not at all.  That's why I asked if any one had experience with
experthost.com, bad or good.  I do want to know about the service before
signing up.

So far almost everyone that has responded has been promoting their own
hosting service though, so I still don't know for sure what sort of
service levels they have.


Sure, price is a key factor (why pay double or tripple for a simular
service?), but end of the day, if it doesn't work, it's a waste of money.


Justin French




I wanted to do something like set the cookie for 5 minutes, then as the
user uses the system each page would refresh so to speak the timeout
always setting it back to 5 minutes as long as he was using it.
I beleive this is not really working.
Any Ideas on how I can accomplish this ??

Thanks
Here is the function I was using to set the cookies...


function f_put_cookie($user_name,$user_email,$account_type) {

        global $HTTP_COOKIE_VARS;

        if(isset($c_user_name)) {

setcookie("c_uas_time","GREEN",(time()+400),'/','website.com',0);
        } else {

setcookie("c_user_name",$user_name,(time()+400*30*12),'/','.website.com',0);


setcookie("c_user_email",$user_email,(time()+400*30*12),'/','.website.com',0);


setcookie("c_account_type",$account_type,(time()+400*30*12),'/','.website.com',0);

                setcookie("c_uas_time",
"GREEN",(time()+400),'/','.website.com',0);
        }
}
___________________________________________________________
Jack Sasportas
Innovative Internet Solutions
Phone 305.665.2500
Fax 305.665.2551
www.innovativeinternet.com
www.web56.net






i had this problem a while back.  the problem with this is cookies work by
the users time not the servers time.  so if the server is in america and my
computer is on japanese time even a cookie set for time()+18000 will be
valid because my computer is actually +50400 for a server in EST.   i have
have worked with two alternatives here.  one set another cookie that holds a
timestamp of the time you want the other cookie to expire and then compare
server time and the expiration cookie.  or do the same thing basically b ut
use a variable set in a session.



Thank You,

Jon Yaggie
www.design-monster.com

And they were singing . . .

'100 little bugs in the code
100 bugs in the code
fix one bug, compile it again
101 little bugs in the code

101 little bugs in the code . . .'

And it continued until they reached 0


----- Original Message -----
From: "Jack Sasportas" <[EMAIL PROTECTED]>
To: "php" <[EMAIL PROTECTED]>
Sent: Sunday, July 01, 2001 9:44 AM
Subject: [PHP] Cookie ?


> I wanted to do something like set the cookie for 5 minutes, then as the
> user uses the system each page would refresh so to speak the timeout
> always setting it back to 5 minutes as long as he was using it.
> I beleive this is not really working.
> Any Ideas on how I can accomplish this ??
>
> Thanks
> Here is the function I was using to set the cookies...
>
>
> function f_put_cookie($user_name,$user_email,$account_type) {
>
>         global $HTTP_COOKIE_VARS;
>
>         if(isset($c_user_name)) {
>
> setcookie("c_uas_time","GREEN",(time()+400),'/','website.com',0);
>         } else {
>
>
setcookie("c_user_name",$user_name,(time()+400*30*12),'/','.website.com',0);
>
>
>
setcookie("c_user_email",$user_email,(time()+400*30*12),'/','.website.com',0
);
>
>
>
setcookie("c_account_type",$account_type,(time()+400*30*12),'/','.website.co
m',0);
>
>                 setcookie("c_uas_time",
> "GREEN",(time()+400),'/','.website.com',0);
>         }
> }
> ___________________________________________________________
> Jack Sasportas
> Innovative Internet Solutions
> Phone 305.665.2500
> Fax 305.665.2551
> www.innovativeinternet.com
> www.web56.net
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]





On Sat, 30 Jun 2001 06:36, Charles Williams wrote:
> Hello all,
>
> I have an .sh shell script being executed from a php4 call.  I need to
> capture the string return and work with that in the php script.  The only
> problem is that the call works but I cannot get the returned string.  I've
> tried using exec, passthru, ``, system, and escapeshellcommand.  Nothing
> seems to work.  any ideas?

$capture = `script.sh 2>&1`; // redirect standard error to standard output


Cheers,
Brad
-- 
Brad Hubbard
Congo Systems
12 Northgate Drive,
Thomastown, Victoria, Australia 3074
Email: [EMAIL PROTECTED]
Ph: +61-3-94645981
Fax: +61-3-94645982
Mob: +61-419107559




I've been having the same problem with Apache 1.3.19 / PHP 4.0.5 running on
WinMe -- and not just with my scripts either: phpMyAdmin does it sometimes
too. So, I reckon that the problem is with the configuration.

Has anyone experienced this on Win2000? (I'm in the process of moving my
files to a Win2000 box so I'll you know when I do if the problem repeats.)

Aral :)

______________________________
([EMAIL PROTECTED])
    New Media Producer, Kismia, Inc.
([EMAIL PROTECTED])
    Adj. Prof., American University







I'm getting quite the whacked out error when trying to run this one php
file.

FATAL:  erealloc():  Unable to allocate 15728640 bytes

When trying to load it as a webpage I get:

Alert!: Unexpected network read error; connection aborted.

from lynx. When running the file from the command line with php, I get the
first error.

Any ideas? At all?

Thanks,
Chris

--
"If you don't find it in the index, look very carefully through the entire catalogue."
        - Sears, Roebuck, and Co., Consumer's Guide, 1897





Are you doing a database query by chance or anything with sessions? I'm
getting the same errors logged in the Apache logs for something I'm working
on (see my previous posts for details.)

Aral :)
______________________________
([EMAIL PROTECTED])
    New Media Producer, Kismia, Inc.
([EMAIL PROTECTED])
    Adj. Prof., American University







I am using MSIE 5.5, with web-hosting apache. When
do the secure connection SSL, sometime, it displays:
Page Not Found. I find out it happens because MSIE
doesn't kill the secured connection. (I refer to the
documentation:
http://www.modssl.org/docs/2.6/ssl_faq.html#ToC48

The web-hosting refushed to change the directive in
apache.

Can I do it in PHP level?


Thanks in advance.

 
Fikko



__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/





尊敬的客户:您好!
    
    凡在6月23号到7月23号之间在Today's 
Network完成国内、国际、新域名注册,就可以一个域名就能同时建立六个网站,也就是说次级域名数由原来的3个变为6个!再加上VDNS特有的三种指向功能,要建设自己的未来网易和搜狐,就要从现在开始!
  
   互联网上每两秒种就会消失一个域名!投资自己的网络资源,您的收获将大大超出您的想象!
    
   Today’s 
Network(http://www.now.net.cn)创先开发的VDNS域名服务器,能实现URL转发、主机A记录、MX邮件记录、IP指向控制等操作,更可以随心所欲地增加自己的次级域名,
 
帮助您建立多个网站,你可以让她指向任何空间,也可以申请一次空间就建六个网站,也可以不申请空间而用原来的空间,甚至用免费空间,
 更利于您优化使用空间资源。
 
和您共同推动互联网发展,我们现推出“注册域名暑期大优惠活动”,
 
除此之外,我们还为您送上我们特有的网站管理工具WEB-ADMIN,它是集上传,下载 网页编辑 
文件移动 删除 拷贝等功能于一体网站管理工具,与传统FTP合用,更有效,更方便地管理您的网站。
 
本次活动截止于7月23号,请抓住您的机遇,开拓您的网上商机,赶快注册您梦想的域名!请点击http://www.now.net.cn/register/
 
我们一直以专业、优质、领先为宗旨,热诚为您服务!
 
欢迎致信 Today's Network [EMAIL PROTECTED]
欢迎你访问 我们的网站 http://www.now.net.cn




Hi,
I am trying to write a page that will perform a select on a DB and get the 
path and file name of an image. Then display the image.
The DB part if fine but I am having difficulty figuring out how to get the 
images to display. For example:

result from select:
$file_path = "/home/pics/friends/"
$file_name = "bob.jpg"

Now, say my web root directory is "/etc/http/wwwroot"

How do I create a link to my file "/home/pics/friends/bob.jpg"?
I tried symlink() but the link created appears to hang around after it is no 
longer needed.

By the way, this is a Linux server running Apache.

Any ideas?

Thanks,

Sterling Anderson
[EMAIL PROTECTED]





you may want to send this as a NON-reply, because many people view mail by
grouped threads, and thus would miss your question

Original Message -----
From: "Sterling Anderson" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, July 01, 2001 12:05 AM
Subject: [PHP] accessing files not in www root directory.


> Hi,
> I am trying to write a page that will perform a select on a DB and get the
> path and file name of an image. Then display the image.
> The DB part if fine but I am having difficulty figuring out how to get the
> images to display. For example:
>
> result from select:
> $file_path = "/home/pics/friends/"
> $file_name = "bob.jpg"
>
> Now, say my web root directory is "/etc/http/wwwroot"
>
> How do I create a link to my file "/home/pics/friends/bob.jpg"?
> I tried symlink() but the link created appears to hang around after it is
no
> longer needed.
>
> By the way, this is a Linux server running Apache.
>
> Any ideas?
>
> Thanks,
>
> Sterling Anderson
> [EMAIL PROTECTED]
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>





Hi,
I am trying to write a page that will perform a select on a DB and get the
path and file name of an image. Then display the image.
The DB part if fine but I am having difficulty figuring out how to get the
images to display. For example:

result from select:
$file_path = "/home/pics/friends/"
$file_name = "bob.jpg"

Now, say my web root directory is "/etc/http/wwwroot"

How do I create a link to my file "/home/pics/friends/bob.jpg"?
I tried symlink() but the link created appears to hang around after it is no
longer needed.

By the way, this is a Linux server running Apache.

Any ideas?

Thanks,

Sterling Anderson
[EMAIL PROTECTED]




On Saturday 30 June 2001 04:31, Richard Lynch wrote:

> >I'd like to know how small my content gets when i use
> >ob_gzhandler.

> Does gz-handler not provide any facility for measuring its performance
> or anything?...  You'd think it would...

Using gzencode () should perform identical (compression ratio - wise) to 
ob_gzhandler. So a

$PageZ = gzencode ($Page);
$PL = strlen ($Page);
$PLZ = strlen ($PageZ);

echo "Uncompressed : $PL<br>";
echo "Compressed: $PLZ<br>";
echo "Ratio: " . ($PLZ / $PL) . "<br>";

should do the job at the cost of a little overhead (page is compressed 
twice).

-- 
Christian Reiniger
LGDC Webmaster (http://lgdc.sunsite.dk/)

void sleep(){for(long int sheep=0;!asleep();sheep++);}




On Friday 29 June 2001 17:27, bill wrote:

> $breaks=preg_match_all("/<br>\s+<br>/i", "$text", $parts)
>
> and this
>
> preg_replace("/<br>\s+<br>/i","</P><P class=\"doserif\">",$text)
>
>
> Now that PHP 4.0.5 has changed the nl2br() function, it no longer
> replaces new lines with:
>
> <br>
>
> but instead with the new XHTML compliant break tags:
>
> <br />
>
> I tried just substituting the new tag into the above regular
> expressions to no avail.  Any ideas?

Lemme guess, you tried

$breaks=preg_match_all("/<br/>\s+<br/>/i", "$text", $parts)

right? As "/" is the pattern delimiter this of course won't work. 
Solution: Escape it:
$breaks=preg_match_all("/<br\/>\s+<br\/>/i", "$text", $parts)
Improved Solution: Make it more flexible:
$breaks=preg_match_all("/<br\s*\/?>\s+<br\s*\/?>/i", "$text", $parts)
That should do the job

-- 
Christian Reiniger
LGDC Webmaster (http://lgdc.sunsite.dk/)

void sleep(){for(long int sheep=0;!asleep();sheep++);}




On Saturday 30 June 2001 18:17, adam (dahamsta) wrote:

> making it too awkward - in a forms- and sessions- based situation. What
> I have difficulty with is understanding how the thousands of websites I
> mentioned manage it without being overly concerned about security. Or
> is that the problem - they're not concerned enough, and we should all
> be using PKI's? For regular websites though, I think that might be
> overkill, especially when a huge majority of people don't understand
> even the fundamentals of security and encryption. (I tried to explain
> it to my Dad last night, it was painful but productive. :)

Little idea in between - What if you not only give the suer (via cookies 
or URL) a (normal, random) session ID but also a (small) random string 
that changes on every request (non-predictably)?
That would mean that if someone *did* snoop the transmitted SessionID 
stuff, he would have to use it *before* the real user clicks on another 
link (because than the ID would be changed again).

Still has some holes, but should catch most attacks.

-- 
Christian Reiniger
LGDC Webmaster (http://lgdc.sunsite.dk/)

void sleep(){for(long int sheep=0;!asleep();sheep++);}




On Friday 29 June 2001 23:09, Craig Simon wrote:

> from html it would look like this
>
> "<p><a href="wtai://wp/mc;1-555-555-1212"">Asst</a></p>"
>
> So I am trying to figure out how to write this.  I have a statement
> like this:
>
> print ("<p><a
> href=\"wtai://wp/mc;"$row["officenum"]"\">Office</a></p>");
>
> Although I can't get this to parse!

Use the string concatenation operator '.' :
print ("<p><a
 href=\"wtai://wp/mc;" . $row["officenum"] . "\">Office</a></p>");

-- 
Christian Reiniger
LGDC Webmaster (http://lgdc.sunsite.dk/)

void sleep(){for(long int sheep=0;!asleep();sheep++);}




Hi,

In my site  I use shtml extensively.  Therefore I have quite a number of
text files that serve as shtml includes.  Often these text files contain
more shtml includes.  I'm creating PHP pages and wish to use these text
files within the pages, I know how to do this easily enough by using:
include("textfile.txt");  The problem is that because a lot of these text
files contain more includes the PHP pages are passing them over, as it
cannot deal with the shtml <!-- include --> tag.  Here's a brief example:

script.php:
<?
include("text1.txt");
?>

text1.txt:
<html>
<!-- include file="text2.txt" -->
</html>

What I would like to happen is for the PHP script to be able to look for the
<!-- include --> tags within the text files and parse them as PHP
include(""); tags.  Is there any way of achieving this?

Thanks.

Jamie Saunders






Jamie Saunders wrote:

> What I would like to happen is for the PHP script to be able to look for the
> <!-- include --> tags within the text files and parse them as PHP
> include(""); tags.  Is there any way of achieving this?

It can be done with regular expressions (but i'll leave that to someone
who is GOOD at them :)
The problem is that for a php program to parse a file (so stuff) it has
to be named with a .php extension (or whatever your server is set up to
do),  so nested includes will fall over.


I'd just like to point out however that if you do this, you'll put a
long term burden and performance issue into your site.

If you grab a decent text editor, and do a search and replace accross
the whole site (decent text editors can do search and replace on a whole
directory or disk), you'll have a once-off chore, rather than giving the
server a constant chore.


example

Search and Replace
  <!-- include file="

with
  <?php include('

the search and replace
  .txt" -->

with
  .php'); ?>


so <!-- include file="stuff.txt" -->
becomes <?php include('stuff.php'); ?>

easy.  the bad bit is that you've got to then go and rename each
extension .php instead of .txt, but you are going to have this problem
with either method, due to the nested natur of your inlcude files.


how many files in total are we talking about (the includes and nested
includes, not the parent pages)?


Justin French
Creative Director
Indent.com.au




Hello,

you may try Smarty, a very skillful PHP template processor.
AFAIR, Smarty can handle includes in that way you want.

http://www.phpinsider.com/php/code/Smarty/
Papp Gyozo 
- [EMAIL PROTECTED]
----- Original Message ----- 
From: "Jamie Saunders" <[EMAIL PROTECTED]>
To: "PHP General" <[EMAIL PROTECTED]>
Sent: 2001. j鷏ius 1. 12:05
Subject: [PHP] shtml includes


> Hi,
> 
> In my site  I use shtml extensively.  Therefore I have quite a number of
> text files that serve as shtml includes.  Often these text files contain
> more shtml includes.  I'm creating PHP pages and wish to use these text
> files within the pages, I know how to do this easily enough by using:
> include("textfile.txt");  The problem is that because a lot of these text
> files contain more includes the PHP pages are passing them over, as it
> cannot deal with the shtml <!-- include --> tag.  Here's a brief example:
> 
> script.php:
> <?
> include("text1.txt");
> ?>
> 
> text1.txt:
> <html>
> <!-- include file="text2.txt" -->
> </html>
> 
> What I would like to happen is for the PHP script to be able to look for the
> <!-- include --> tags within the text files and parse them as PHP
> include(""); tags.  Is there any way of achieving this?
> 
> Thanks.
> 
> Jamie Saunders
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
> 





On Sun,  1 Jul 2001 03:43, [EMAIL PROTECTED] wrote:

> to make you feel better, lemme tell you that after more than 3ys w/ PHP
> I earn somewhere arround 3 ( I mean 3!) $/h in Romania
> so let me tell you more about geographic disadvantages :)

Hi Teo,

Point taken. The grass is always greener though heh?

Cheers,
Brad






I had the same problem whenever retrieving data from MSSQL using ODBC from a
NULL field.


To "solve" the problem I had to add a character asd default to that field.

I added a dot.

descr nvarchar  default '.'  .

(the sql sintax here is not the correct one.)




----- Original Message -----
From: "Aral Balkan" <[EMAIL PROTECTED]>
To: "Rasmus Lerdorf" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Sunday, July 01, 2001 1:52 AM
Subject: Re: [PHP] emalloc / erealloc problem (was: help with custom session
handler)


> Well finally I am 99.9% sure that the problem is with Metabase. I've
managed
> to bring the code down to the absolute minimum to simplify things and I
can
> now state the bug clearly:
>
> On Pentium III 500Mhz running WinMe, Apache 1.3.19 and PHP 4.0.5, use of
> Metabase calls in custom session handler to update a MySQL database
randomly
> crash Apache with (again, randomly) errors in either PHP4TS.DLL or
> MSVCRT.DLL.
>
> When Apache does not crash, the code does work (I tested this with a
simple
> variable increment).
>
> When the Metabase session handler is replaced with one using MySQL calls,
> the problem goes away.
>
> Entries noticed in Apache's error.log that may be related are:
> FATAL:  emalloc():  Unable to allocate 1701082243 bytes
> FATAL:  erealloc():  Unable to allocate 369098752 bytes
>
> I've already written to Manuel about this and I'm sure he'll have the
> problem figured out in no time but in the meanwhile, I'm posting my code
> here so that this post may benefit others trying to do this in the future
> (and with the hope that maybe someone can discover something that *I'm*
> doing wrong that could be causing all this!)
>
> <?php
> /*
>  metabase sesssions library
>
>  error: makes Apache crash randomly with errors in PHP4TS.DLL and
MSVCRT.DLL
>  running on WinMe with Apache 1.3.19 and PHP 4.0.5
>
>  based on the code of Sterling Hughes (PHP Developer's Cookbook,
>  pgs. 222 - 224) and Ying Zhang (PHPBuilder, "Custom Session
>  Handlers in PHP4,
> http://www.phpbuilder.com/columns/ying20000602.php3?page=1)
>
>  metabase by Manuel Lemos ([EMAIL PROTECTED],
>          http://www.phpclasses.upperdesign.com/)
>
>  copyright (c) 2001, aral balkan ([EMAIL PROTECTED])
>       http://www.aralbalkan.com
> */
>
> // metabase database abstraction layer
> require_once "metabase/metabase_parser.php";
> require_once "metabase/metabase_manager.php";
> require_once "metabase/metabase_database.php";
> require_once "metabase/metabase_interface.php";
>
> $SESS_LIFE = get_cfg_var('session.gc_maxlifetime');
>
> // default life of session to an hour
> if ($SESS_LIFE == '') { $SESS_LIFE = 3600; }
>
> function on_session_start ($save_path, $session_name)
> {
>  global $database;
>
>  /*  db_init.php holds the values for
>   $db_type, $db_user, $db_pass, $db_host
>  */
>  require_once('db_init.php');
>
>  $metabase_init = array(
>  "Type"=>$db_type,
>  "User"=>$db_user,
>  "Password"=>$db_pass,
>  "Host"=>$db_host,
>  "IncludePath"=>"metabase/",
>  "Persistent"=>TRUE
>  );
>
>  $metabase_error = MetabaseSetupDatabase(&$metabase_init, &$database);
>
>  if ($metabase_error != '') {
>   die('Database setup error: '.$metabase_error);
>   return false; // failure
>  }
>
>  // select database
>  $previous_database_name = MetabaseSetDatabase($database, $db_name);
>  return true;
> }
>
> function on_session_end()
> {
>  // Nothing needs to be done in this function
>  // since we used a persistent connection
>  return true;
> }
>
> function on_session_read ($key)
> {
>  global $database;
>
>  $key = MetabaseGetTextFieldValue($database, $key);
>
>  $stmt = "SELECT sessionData FROM sessions";
>  $stmt .= " WHERE sessionID = $key";
>  $stmt .= " AND sessionExpire > ". time();
>
>  if (!($result = MetabaseQuery($database, $stmt))) {
>    // query failed
>    echo '> Main query (sql) failed.'.$e;
>    echo '> Error: '.MetabaseError($database).$e;
>    die();
>  }
>
>  $stmt_rows = MetabaseNumberOfRows($database, $result);
>
>  if ($stmt_rows) {
>   $sessionData = MetabaseFetchResult($database, $result, 0,
'sessionData');;
>   return($sessionData);
>  } else {
>   return false;
>  }
> }
>
> function on_session_write ($key, $val)
> {
>  global $session_db, $SESS_LIFE;
>  global $database;
>
>  // convert the text value to a format suitable for use in current
database
>  $expiry = time() + $SESS_LIFE;
>  $key = MetabaseGetTextFieldValue($database, $key);
>  $val = MetabaseGetTextFieldValue($database, $val);
>
>  $replace_stmt = "REPLACE INTO sessions (sessionID, sessionData,
> sessionExpire)"
>      ." values($key, $val, $expiry)";
>
>  $success = MetabaseQuery($database, $replace_stmt);
>
>  return $success;
> }
>
> function on_session_destroy ($key)
> {
>  global $database;
>
>  $key = MetabaseGetTextFieldValue($database, $key);
>  $stmt = "DELETE FROM sessions WHERE sessionID = $key";
>  $success = MetabaseQuery($database, $stmt);
>  return $success;
> }
>
> function on_session_gc ($max_lifetime)
> {
>  global $database;
>
>  $stmt = "delete from sessions where sessionExpire < " . time();
>  $success = MetabaseQuery($database, $stmt);
>  return $success;
> }
>
> // Set the save handlers
> session_set_save_handler("on_session_start", "on_session_end",
>        "on_session_read", "on_session_write",
>        "on_session_destroy", "on_session_gc");
>
> ?>
>
> Thanks,
> Aral :)
>
> ______________________________
> ([EMAIL PROTECTED])
>     New Media Producer, Kismia, Inc.
> ([EMAIL PROTECTED])
>     Adj. Prof., American University
> 
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>





> I'm using a form to upload a number of  files named $input_form_$i where $i
> is from 0 to 5 and the following is my code:
> 
> for ($i = 0; $i<=5; $i++){
> 
>     $l = "input_form_$i";
>     $location = $$l;
> 
>     move_uploaded_file($location, "$upload_path/$location_name");
                                                  ^^^^^^^^^^^^^^
Well,first, you're messed up with $location and $location_name, or would it be 
${location}_name?
And maybe, you might check what name were given to the form variables.

> 
> }
>  with that, I get the following warnings:
> 
> Warning: Unable to create '/': Invalid argument in [php file running
> program] on line 64
> 
> Warning: Unable to move '/var/tmp//php9Uai9S' to '/' in [php file running
> program] on line 64
> /var/tmp//php9Uai9S not loadable
          ^^
These double slashes make no sense in a filepath, beware of it if you move on.

> 
> Funny thing is another page that doesn't use the $$l method to dynamically
> grab variable names (just uses a static variable name) works totally fine
> with essentially the same code.

I think it is obvious that your dynamic variable-name handling breaks the code.






Hi list,

I'd like to submit the problem I have and the idea to circonvent it.

I host web site. Those sites belong to different peapole (login)

Putting safe_mode on breaks the loading of any file in include_path
variable because there's no chances that they could belong to the script
owner. Therefore it breaks any common library anyone could you (like
phplib).

OTOH, setting safe_mode to Off is a real lack of security.

Suggestion:
Keep safe_mode the way it works EXCEPT for files in include_path and
tmp_path (for uploading...)

Now I don't know php 4 code so much that I can do it alone.

Does it sound a ood idea? Does it break something else ? Did I miss
something ??

Can you give me some pointers to do it??

TIA

-- 
Olivier PRENANT                 Tel:    +33-5-61-50-97-00 (Work)
Quartier d'Harraud Turrou           +33-5-61-50-97-01 (Fax)
31190 AUTERIVE                      +33-6-07-63-80-64 (GSM)
FRANCE                      Email: [EMAIL PROTECTED]
------------------------------------------------------------------------------
Make your life a dream, make your dream a reality. (St Exupery)






Hi,

I`m trying to get the difference between two date/times and then state how 
many days, hours and minutes there are between them. 

So I take my date and convert it into unix time. Then get the current time, 
and then subtract the two to get the current difference in unix seconds. What 
I`m having trouble doing is working out how many days hours and minutes are 
left over.

For example if I have the date/time: 2001-07-01 01:10:00
And the current date/time was: 2001-07-02 00:00:00
Then I would like to display 1 Day 1 Hour 10 Minutes.

Any one have any suggestions, this is my code so far.

$date1_formated = "$DateEnd $TimeEnd";
$date1 = strtotime($date1_formated); //converts to a UNIX timestamp
$date2 = time(); //returns current UNIX timestamp
$seconds_between = $date1 - $date2;

TIA
Ade


Reply via email to