php-general Digest 3 Jan 2004 20:25:12 -0000 Issue 2510

Topics (messages 173674 through 173690):

Strange counter behavior
        173674 by: Cesar Aracena

Re: End slash, small problem.
        173675 by: Chris
        173676 by: Tom Rogers

php stub
        173677 by: Dan Mahoney

Re: A hint...
        173678 by: Burhan Khalid

Wondering If Upgrading Might Be in Order
        173679 by: stiano.optonline.net

encoding problem
        173680 by: Pedro Salgueiro

Problem with call_user_func_array and passing an array of objects
        173681 by: Jon Goodwin

Compare Array Elements
        173682 by: wknit
        173684 by: Geoffrey Thompson

Re: example of posting board or shoutbox
        173683 by: Richard Davey

PHP $_SESSION Expiring in IE
        173685 by: Tarrant Costelloe
        173686 by: Larry Brown
        173687 by: Tarrant Costelloe

Re: Production Websites (error loggin)
        173688 by: Marek Kilimajer

Re: Redirection to a named frame
        173689 by: Martin Helie

fsockopen to conect to ssl sites
        173690 by: Jorge Castaneda

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 ---
Hi all,

I know most of you doesn't have the time() for this kind of things, but I
have a problem with this beautifull counter script I found on hotscripts. I
read it over and over again but I can't find where the problem is. As the
code is way too long to write (several .php pages) I uploaded it to
http://www.icaam.com.ar/files/ep-dev-counter-3.41.zip. if anyone would be so
kind to download it and take a look at it... you may even find it usefull.
The problem is that the last counter showed displays a number one (1) after
it, so my total visitors show 11, 21, 31, 41... instead of just 1, 2, 3,
4...

This one's has no rush... Thanks in advanced.

Cesar Aracena

--- End Message ---
--- Begin Message ---
You forgot to double slash the windows slash like: '\\'

I would write that same functionality as follows:

$sep = (PHP_OS == 'Windows')? '\\':'/';
if(substr($template_path,-1) == $sep)) $template_path .= $sep;

-----Original Message-----
From: Tom Rogers [mailto:[EMAIL PROTECTED]
Sent: Friday, January 02, 2004 7:24 PM
To: Ryan A
Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: Re[2]: [PHP] End slash, small problem.


Hi,

Saturday, January 3, 2004, 11:23:00 AM, you wrote:
RA> Hi,
RA> Thanks for replying.

RA> Basically after that path I am adding a file "ryanFile.php" so I need
that
RA> ending slash to always be in the path

RA> My question was exactly that...how do I "grab" the last character?

RA> Thanks,
RA> -Ryan


I do it like this:

$sep = (PHP_OS == 'Windows')? '\':'/';
$template_path .= (substr($template_path,-1) == $sep)? '':$sep;



--
regards,
Tom

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

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

Saturday, January 3, 2004, 4:50:44 PM, you wrote:
C> You forgot to double slash the windows slash like: '\\'

C> I would write that same functionality as follows:

C> $sep = (PHP_OS == 'Windows')? '\\':'/';
C> if(substr($template_path,-1) == $sep)) $template_path .= $sep;


Not in single quotes I thought ..could be wrong though :)

-- 
regards,
Tom

--- End Message ---
--- Begin Message ---
So it's, at the time of this writing, 2:47 AM.  Keep this in mind.

I was looking at my webserver configuration.  I am in love with Suexec.
It's a gift from god for web hosts.  Not only does it secure your
directories, but as a bonus it forces your users to keep their stuff
secure (i.e. by not running scripts in 777 directories, et al).

Wonderful stuff.

So then I looked at suexec with php, which pretty much breaks embedded php
scripts, and requires that most freely available scripts be modified in a
now-unfamiliar and non-standard way, i.e. sticking a php shebang in the
scripts.  As a bonus, it's slower.

So then I found suPHP, and while it looked interesting at first, as it
comes with an apache module, and a suid program, I thought it was exactly
what I needed.

Nope, it still runs in CGI mode.  I think there's a couple benefits, but I
still think that if PHP had always been a CGI, it would have NEVER gained
the popularity it has.

So then I had a thought.  What about a stub program, similar to suexec,
that instead of running all the php scripts and the php CGI binary,
merely handles all the file operations that php would.  Ideally it would
speak to the httpd via pipes or something.

This would be similar to the way safe mode presently operates (as in, it
would do the same permissions checks on file reads for UID and GID, except
that it would, at least for file writes (and optionally, for reads), fork
a quick process that handled the file operations.  Also, it could possibly
do more than UID/GID checks, and actually check permissions, ala suexec.

Am I making no sense here?  Or is this actually doable?

I tend to think if it WAS feasible some other company would have done it
and would be selling it now, but in simple terms, I'd love to know why it
CAN'T be done.

I've thought about the fact that "you're still slowed down by the forking
of a separate process", but I'd much rather fork only on file writes,
while things like SQL-based message boards getting thousands of hits a day
still run at full-speed.

This would also solve the biggest bane of my existence, the fact that I
can't find a half-decent way of making it so that users can't read each
others' MySQL login info, usually sitting in the config.php of some
script.  This would solve that too.  (Safe mode would solve it, but safe
mode is known for breaking too much else.)

Am I insane?  If so, please tell me why.

How much would I have to donate to the apache foundation to get this
feature written if it is feasible? :)

-Dan Mahoney

--

"There is no right and wrong, there is only fun and boring."

-Fisher Stevens, "Hackers"

--------Dan Mahoney--------
Techie,  Sysadmin,  WebGeek
Gushi on efnet/undernet IRC
ICQ: 13735144   AIM: LarpGM
Site:  http://www.gushi.org
---------------------------

--- End Message ---
--- Begin Message ---

-----Original Message-----
From: Jeremy Russell [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, December 30, 2003 11:17 PM
To: [EMAIL PROTECTED]
Subject: [PHP] A hint...

Hello list..

I was needing  a small hint on how to make a sort of status page...

What I have is a function that takes a few minutes to complete...

It send an snmp signal out then waits a bit and then gets the status via
snmp.   

I would like to have some sort of graphic or page for the status, e.g.
Percent done, a flashing waiting or something.

You could try something like http://pear.php.net/package/HTML_Progress
--
PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
http://www.php.net/unsub.php

--- End Message ---
--- Begin Message ---
I don't know, but maybe part of the trouble I have making canned code to
learn PHP/MySQL is that I'm using older versions? I'm on a Macintosh G3
PowerBook with OS 10.2.1. PHP is version 4.3.0; MySQL, 3.23.53; and
phpmyAdmin, 2.4.0.

What are the latest available post-beta, stable, fully-baked versions? Is
upgrading as big a project as deleting old versions and then reinstalling
newer? Or are there instructs for upgrading over the old?

Thank you.

Stephen Tiano

--------------------------------------------------------------------
mail2web - Check your email from the web at
http://mail2web.com/ .

--- End Message ---
--- Begin Message ---
Hi.

I have made a script in php that calls a java program.
This java program will make a connection to a
PostgreSQL db and do some operations. That java
program works just fine if I run it on a console, but
when it is php to runing it, it gives some errors
related to the charset encoding.
The error that apears in "error.log" of Apache is the
following:

Java.sql.SQLException: ERROR:  Could not convert UTF-8
to ISO8859-1

I think that the problem is than Apache or PHP is
runing the java program with UTF-8 encoding, while it
should be running with iso8859-1.

Does anyone knows how to solve this problem?

Thanks.
Pedro Salgueiro.

__________________________________
Do you Yahoo!?
Find out what made the Top Yahoo! Searches of 2003
http://search.yahoo.com/top2003

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

I wish to call function f($params) using call_user_func_array() and pass to
f() an array of two objects as a parameter.

When I call f() directly, it works as expected. Function f() recognises that
2 objects are in the array and I can access their member variables.

When I call the same function via call_user_func_array(), function f()
recognises only the first object. Also, the same code that I used to access
the objects when f() was called directly does not work when f() is called
via call_user_func_array().

I have included some sample code below to illustrate the problem.

I am running PHP version 4.2.2 on Windows NT 5.0 and Apache 2.0.39.
I also have the same problem when I run PHP 4.3.0 on Linux and Apache 1.3.27

Thanks in advance for your help.

<?
class tst
{
  var $v1;
  var $v2;

  function tst($a, $b)
  {
    $this->v1 = $a;
    $this->v2 = $b;
  }
}

$tst1 = new tst("a", "b");
$tst2 = new tst("d", "e");

$arr = array($tst1, $tst2);

echo("<B>Call function f() as regular function</B><BR>");
f($arr);

echo("<B>Calling function f() via call_user_func_array()</B><BR>");
call_user_func_array(f, $arr);

function f($params)
{
  var_dump($params);
  echo("Count=" . count($params). "<BR>");
  echo("Param[0]->v1=" . $params[0]->v1 . " Param[0]->v2=" . $params[0]->v2
. "<BR>");
  echo("Param[1]->v1=" . $params[1]->v1 . " Param[1]->v2=" . $params[1]->v2
. "<BR>");
  echo("<P>");
}

?>

OUTPUT >>>>>

Call function f() as regular function
array(2) { [0]=> object(tst)(2) { ["v1"]=> string(1) "a" ["v2"]=> string(1)
"b" } [1]=> object(tst)(2) { ["v1"]=> string(1) "d" ["v2"]=> string(1)
"e" } } Count=2
Param[0]->v1=a Param[0]->v2=b
Param[1]->v1=d Param[1]->v2=e

Calling function f() via call_user_func_array()
object(tst)(2) { ["v1"]=> string(1) "a" ["v2"]=> string(1) "b" } Count=1
Param[0]->v1= Param[0]->v2=
Param[1]->v1= Param[1]->v2=

--- End Message ---
--- Begin Message ---
I am a novice, I am sure this is pretty simple...

I have two arrays of integers, equal length.
The arrays elements consists of the integers 0 through 9.
The order of the numbers in the arrays should always be different.

Example 1: Is ok
xArray: 2 9 6 0 1 3 4 5 8 7
yArray: 3 7 1 9 0 8 6 2 4 5

Example 2: Is not ok - the element "7" is in the same position in both
arrays.
xArray: 2 9 6 0 7 3 4 5 8 1
yArray: 3 5 1 9 7 8 6 2 4 0

I need a snippet that will compare the value of each element in each
position and call a function to create a new array if the compare evaluates
to true.  I assume that a foreach is the way to go, but I can't seem to find
the right syntax for it.

-------
if foreach (xArray as $x) == (yArray as $y) {
new_yArray ();
}
------

I know this isn't correct, but in idiot terms, it is what I want to do... a
test/compare.  Of course the compare should stop and call the function the
moment it evaluates to true at any given position.

Maybe I should be using a "for" loop? (again, not a clue)

Thanks anyone!

--- End Message ---
--- Begin Message ---
One approach:

for ($i=0; $i < sizeof($xArray); $i++) {
    if ($xArray[$i] == $yArray[$i]) {
        new_yArray();
        break;
    }
}

"Wknit" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I am a novice, I am sure this is pretty simple...
>
> I have two arrays of integers, equal length.
> The arrays elements consists of the integers 0 through 9.
> The order of the numbers in the arrays should always be different.
>
> Example 1: Is ok
> xArray: 2 9 6 0 1 3 4 5 8 7
> yArray: 3 7 1 9 0 8 6 2 4 5
>
> Example 2: Is not ok - the element "7" is in the same position in both
> arrays.
> xArray: 2 9 6 0 7 3 4 5 8 1
> yArray: 3 5 1 9 7 8 6 2 4 0
>
> I need a snippet that will compare the value of each element in each
> position and call a function to create a new array if the compare
evaluates
> to true.  I assume that a foreach is the way to go, but I can't seem to
find
> the right syntax for it.
>
> -------
> if foreach (xArray as $x) == (yArray as $y) {
> new_yArray ();
> }
> ------
>
> I know this isn't correct, but in idiot terms, it is what I want to do...
a
> test/compare.  Of course the compare should stop and call the function the
> moment it evaluates to true at any given position.
>
> Maybe I should be using a "for" loop? (again, not a clue)
>
> Thanks anyone!

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

Saturday, January 3, 2004, 1:29:14 AM, you wrote:

A> how do i make something where some1 enters text, a name, and email 
A> address, etc. and can post it onto a textarea or something, in a format of

http://www.hotscripts.com/cgi-bin/search.cgi?bool=AND&query=shoutbox&catid=2

-- 
Best regards,
 Richard                            mailto:[EMAIL PROTECTED]

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

I have recently launched the new Planet-Tolkien.com, one would think
that writing a message board from scratch and a dynamic weather system,
a simple session login would be the least of my problems right? Wrong.

It would appear that for Mozilla and Opera keep a $_SESSION is not an
issue and the $_SESSION is continued until the member logs out. However
when members are using Internet Explorer browser (most versions it
seems), they can go around the site for varied amounts of time, usually
less than five minutes and then their $_SESSION will expire!!??

I cannot for the life of me figure out why a server side $_SESSION would
expire on IE but not for MOZ or Opera but it is, and I need to figure
out why and how can I fix this.

REF. All login information is saved as such:

session_save_path("$path/sessions"); 
session_start(); $_SESSION['session_memberID']=$session_memberID;
$_SESSION['session_username']=$session_username;
$_SESSION['session_groupID']=$membergroup;

In Fellowship,
Tarrant 

--- End Message ---
--- Begin Message ---
I use sessions with IE all the time without such a problem.  Are there any
points in the program that redirect the user off site and back or something
with that affect that IE might be handling in a wierd way?  Do you have
pages that detect the browser and feed alternate content based on the
browser?  If so do you always run the session_start before these checks?

-----Original Message-----
From: Tarrant Costelloe [mailto:[EMAIL PROTECTED]
Sent: Saturday, January 03, 2004 10:27 AM
To: [EMAIL PROTECTED]
Subject: [PHP] PHP $_SESSION Expiring in IE


Hello,

I have recently launched the new Planet-Tolkien.com, one would think
that writing a message board from scratch and a dynamic weather system,
a simple session login would be the least of my problems right? Wrong.

It would appear that for Mozilla and Opera keep a $_SESSION is not an
issue and the $_SESSION is continued until the member logs out. However
when members are using Internet Explorer browser (most versions it
seems), they can go around the site for varied amounts of time, usually
less than five minutes and then their $_SESSION will expire!!??

I cannot for the life of me figure out why a server side $_SESSION would
expire on IE but not for MOZ or Opera but it is, and I need to figure
out why and how can I fix this.

REF. All login information is saved as such:

session_save_path("$path/sessions");
session_start(); $_SESSION['session_memberID']=$session_memberID;
$_SESSION['session_username']=$session_username;
$_SESSION['session_groupID']=$membergroup;

In Fellowship,
Tarrant

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

--- End Message ---
--- Begin Message ---
"Are there any points in the program that redirect the user off site and
back or something with that affect that IE might be handling in a weird
way?"

Nope

"Do you have pages that detect the browser and feed alternate content
based on the browser?"

Nope

"do you always run the session_start before these checks?"

Yes.

The only other thing I guess it could be is the .htaccess mod_rewrite
maybe? It's just weird that Internet Explorer is the only browser that
seemingly looses the members $_SESSION where as Mozilla is not effected
whatsoever.

In Fellowship,
Tarrant 

-----Original Message-----
From: Larry Brown [mailto:[EMAIL PROTECTED] 
Sent: 03 January 2004 16:34
To: Tarrant Costelloe; PHP List
Subject: RE: [PHP] PHP $_SESSION Expiring in IE


I use sessions with IE all the time without such a problem.  Are there
any points in the program that redirect the user off site and back or
something with that affect that IE might be handling in a wierd way?  Do
you have pages that detect the browser and feed alternate content based
on the browser?  If so do you always run the session_start before these
checks?

-----Original Message-----
From: Tarrant Costelloe [mailto:[EMAIL PROTECTED]
Sent: Saturday, January 03, 2004 10:27 AM
To: [EMAIL PROTECTED]
Subject: [PHP] PHP $_SESSION Expiring in IE


Hello,

I have recently launched the new Planet-Tolkien.com, one would think
that writing a message board from scratch and a dynamic weather system,
a simple session login would be the least of my problems right? Wrong.

It would appear that for Mozilla and Opera keep a $_SESSION is not an
issue and the $_SESSION is continued until the member logs out. However
when members are using Internet Explorer browser (most versions it
seems), they can go around the site for varied amounts of time, usually
less than five minutes and then their $_SESSION will expire!!??

I cannot for the life of me figure out why a server side $_SESSION would
expire on IE but not for MOZ or Opera but it is, and I need to figure
out why and how can I fix this.

REF. All login information is saved as such:

session_save_path("$path/sessions");
session_start(); $_SESSION['session_memberID']=$session_memberID;
$_SESSION['session_username']=$session_username;
$_SESSION['session_groupID']=$membergroup;

In Fellowship,
Tarrant

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

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

--- End Message ---
--- Begin Message --- Does apache have permissions to write to the file and directory?

Aidan Lister wrote:
If anyone has successfully got php error logging working on a production
website, could you please reply with the steps taken?

I'm using RH7.3, Apache1.3x, PHP4.3x

My php.ini has:

log_errors = On
error_log = /var/log/httpd/php/error_log

However the errorlog is never created.

Thanks for any help.


--- End Message ---
--- Begin Message ---
How about simply:

echo "
<SCRIPT>
    window.top.main.location= 'http://localhost/phase1/report.php'';
</SCRIPT>";

?

"Geoffrey Thompson" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I was only able to find one reference to targeting a named frame on a
> redirection, in the "MySQL Cookbook" by O'Reilly.  According to the book,
> this should work:
>
>  header('Window-target: main');
>  header('Location: http://localhost/phase1/report.php');
>
> But, alas, it seems to only load up the current frame (which is not main).
>
> I also tried:
>
>  header('Window-target: _top');
>  header('Location: http://localhost/phase1/report.php');
>
> to see if I could get it to wipe out the frameset and get back to the full
> window, but it still loaded up in the current frame.
>
> Any help would be appreciated!
>
> Thanks,
>
> Geoff

--- End Message ---
--- Begin Message ---
WHERE IS THE ERROR?
 
The  username  and  the  password  are the correct and the name of the
variables  (login  and  pass)  also  match. I tried to get data from a
secure  site but I always receive the next message instead of the page
I request:
 
We are connected with somesecuredomain.com
 
HTTP/1.1  302  Found  Date:  Fri,  02  Jan  2004  19:21:20 GMT Server:
Apache/1.3.27 (Unix) FrontPage/5.0.2.2623 PHP/4.3.2 mod_gzip/1.3.19.1a
mod_accounting/1.0   mod_fastcgi/2.4.0  mod_ssl/2.8.14  OpenSSL/0.9.7b
rus/PL30.17         X-Powered-By:         PHP/4.3.2        Set-Cookie:
biz=8a204f6cf271a7a81d3de70c0b250921; path=/ Expires: Thu, 01 Jan 1970
00:00:01   GMT  Cache-Control:  no-store,  no-cache,  must-revalidate,
post-check=0,      pre-check=0      Pragma:     no-cache     Location:
/?error=Auth+error%2C+wrong+login+or+password.&login=myusername
Connection:   close   Content-Type:   text/html;  charset=windows-1251
Last-Modified: Fri, 02 Jan 2004 19:21:20 GMT
 
 
 
The script I used:
__________________________________________
 
<?php
 
$host= "somesecuredomain.com"; $page= "/account/login.php";
 
 
$formdata = array (login=>"myusername" , pass=>"mypassword"); 
 
foreach($formdata AS $key => $val)
{ 
    $poststring .= urlencode($key)."=".urlencode($val)."&"; 
} 
 
$poststring = substr($poststring, 0, -1); 
 
$request= "POST $page HTTP/1.0\x0D\x0A";
$request .= "HOST: $host\x0D\x0A";
$request .= "Content-Type: application/x-www-form-urlencoded\x0D\x0A";
$request .= "User-Agent: test client\x0D\x0A";
$request .= "Accept: */*\x0D\x0A";
$request .= "Content-Length: ".strlen($poststring)."\x0D\x0A";
$request .= "Connection: close\x0D\x0A\x0D\x0A"; 
$request .= $poststring ."\x0D\x0A\x0D\x0A"; 
 
$fp = fsockopen("ssl://".$host, 443, &$errorno, &$errordesc);
 
if ($fp) {print "We are connected with $host";}
else
{die ("I can not connect with $host: \nError: $errorno \nDescription: $errordesc");}
 
print "<br>";
 
fputs($fp, $request);
 
while (!feof($fp))
 print  fgets($fp, 1024);
fclose($fp);
?> 
 

___________________________________________________________________________________

Thank you in advance for any help.

Best regards,
 Jorge                          mailto:[EMAIL PROTECTED]

--- End Message ---

Reply via email to