php-general Digest 13 Jan 2012 01:16:59 -0000 Issue 7647
Topics (messages 316271 through 316278):
Re: http_referer. what's wrong with that?
316271 by: Jonesy
316272 by: Stuart Dallas
srand questions
316273 by: Matthew D. Pagel
316276 by: Jim Giner
Re: passing variables to php script
316274 by: David Savage
316275 by: Matijn Woudt
316277 by: Tim Streater
advise on simplfying session usage
316278 by: Haluk Karamete
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 ---
On Thu, 12 Jan 2012 17:11:25 +1100, Ross McKay wrote:
> On Wed, 11 Jan 2012 21:27:58 -0800, Haluk Karamete wrote:
>
>>[...]
>>Notice: Undefined index: HTTP_REFERER in
>>D:\Hosting\5291100\html\blueprint\bp_library.php on line 16
>>die;
>>[...]
>>But I'm still curious, what configuration am I missing so that
>>http_referer is treated like that?
>
> You only get an HTTP_REFERER when you link to a page from another page.
> If you go directly to the page, e.g. by typing / pasting the URL into
> the location bar, ...
> ... or linking from an email, then there is no HTTP_REFERER.
Not so. It depends. A number of email programs of the
HTML-email-abomination ilk send referrers. I just completed
some log scans to verify an 'issue' with AOL sessions, and their
email contraption _does_ send a referrer. I've seen others, as well.
"74.93.226.126" - - [14/Oct/2011:21:08:50 +0000] "GET /UBSC/ HTTP/1.1"
200 4502 "http://mail.aol.com/34188-111/aol-6/en-us/Suite.aspx"
"Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; ........
Jonesy
--
Marvin L Jones | jonz | W3DHJ | linux
38.24N 104.55W | @ config.com | Jonesy | OS/2
* Killfiling google & XXXXbanter.com: jonz.net/ng.htm
--- End Message ---
--- Begin Message ---
On 12 Jan 2012, at 14:10, Jonesy wrote:
> On Thu, 12 Jan 2012 17:11:25 +1100, Ross McKay wrote:
>> On Wed, 11 Jan 2012 21:27:58 -0800, Haluk Karamete wrote:
>>
>>> [...]
>>> Notice: Undefined index: HTTP_REFERER in
>>> D:\Hosting\5291100\html\blueprint\bp_library.php on line 16
>>> die;
>>> [...]
>>> But I'm still curious, what configuration am I missing so that
>>> http_referer is treated like that?
>>
>> You only get an HTTP_REFERER when you link to a page from another page.
>> If you go directly to the page, e.g. by typing / pasting the URL into
>> the location bar, ...
>
>> ... or linking from an email, then there is no HTTP_REFERER.
>
> Not so. It depends. A number of email programs of the
> HTML-email-abomination ilk send referrers. I just completed
> some log scans to verify an 'issue' with AOL sessions, and their
> email contraption _does_ send a referrer. I've seen others, as well.
>
> "74.93.226.126" - - [14/Oct/2011:21:08:50 +0000] "GET /UBSC/ HTTP/1.1"
> 200 4502 "http://mail.aol.com/34188-111/aol-6/en-us/Suite.aspx"
> "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; ........
One point of clarity... the browser sends the referrer header, not the page
that contains the link, whether it's a simple website or an application.
Websites have absolutely no control over it.
-Stuart
--
Stuart Dallas
3ft9 Ltd
http://3ft9.com/
--- End Message ---
--- Begin Message ---
Hi all,
I have a few questions about the srand (or mt_) function for directed
seeding.
I'm assuming if I do a targeting seeding with a particular value, I'll
get the same sequence of values no matter how many times I run the page
(assuming it's on the same OS and php version). Of course, if this is
incorrect, please let me know. But I have a few questions.
1) What is the persistence of the random seed?
a) If I run another script on the same server subdomain that does NOT
seed the random number generator, will it re-seed from a "random value"
(as the manual puts it) or will it run off the sequence from the seed
initialized in my targetted script? On another subdomain hosted on the
same computer (same user account, etc)? Does it make a difference if
the page has the same URL (I replace one version of the page with
another that removes the seed line or use the seed function in an
include file used by both scripts)?
b) If I seed in two separate pages with the same seed number and draw 10
random values, I'd expect to get the same sequence if the two scripts
are run sequentially. But what if I seeded one, put in a 20 second
delay (but did not grab any values yet), ran the other script (without
the delay), and then allowed the first script to finish by grabbing 10
values. Would the draw from one page affect the other?
c) If each file/script does not inherit the random seed, locally what is
the heritability? In other words, does the sequence persist outside of
the function in which the random number is seeded? Or does a different
function re-seed itself automatically?
d) Would php's random number generator be influenced by other programs
running on the system (assuming they're not tampering with the memory
allocated to the running script)?
2) What is the cycle period?
a) Is a seeded random value expected to repeat its generated sequence in
fewer than getrandmax for a seeded random number? An unseeded one?
b) Is there built-in cycle detection and auto-reseeding?
c) If I draw the same number (e.g. 12345) as before, would I expect the
next value to be the same as the previous time I saw 12345 (assuming my
range is from 0 to getrandmax)? Or is there a secondary number stored
somewhere which is what the next random number is calculated in
conjunction with?
d) Has anyone ever looked into the distribution of cycle times (if it
does indeed cycle). If so, what's the mean, median, variance/stdev and
is it a near-gaussian distribution?
e) Are any seed values known to be intrinsically poor at avoiding a
cycle? Are there any (known) seed values that bias draws high/low or
even/odd, or can I assume given enough calls I'll get ABOUT half and
half (gaussian-like distribution)?
3) To simulate the basal behavior of the unseeded rand call (but want to
repeat with that same seed value later), do I just get the microtime,
store it somewhere (e.g. mtvar), and then call srand($mtvar)? Or is the
autogenerated "random seed" not based on the current clock or via a hash
of the clock?
If any of these answers are significantly different for mt_srand vs
srand, I'd appreciate knowing about both. However, I'll take whatever
information you do know. So, even if you only know the answer to one
part of one of these questions, I'd still appreciate your response.
--Matt
--- End Message ---
--- Begin Message ---
The manual notes some of your concerns - especially the lack of a need to do
a 'seeding' and (since 5.2.1) the presence of a new algorithm that generates
a unique sequence regardless if the 'seed' is repeated. Furthermore, since
there is no need to do a seed, I would guess that each call to the function
mt_rand utilizes a new 'seed' internally, which the developer need not worry
about.
Just my $.02.
--- End Message ---
--- Begin Message ---
Installed apache onto a win2K server, and have the html file & php file in the
same folder (Q:\ASTERISK\) on the Q: drive (which is just another drive in this
same server). I opened the html file using IE 6.0. What I'm thinking is
there may be an issue with some setting on the web server. The php statements
I posted were the first few statements in the script, so apparently the script
didn't see the variables, so I'll have to review the httpd.conf and php.ini
files to find whatever settings is preventing the acctnum, year, and month from
being passed to the php script.
Thanks to all of you who posted comments for this problem ! I believe it will
eventually come together.
David
________________________________
From: Ellis Antaya [mailto:[email protected]]
Sent: Tue 1/10/2012 4:46 PM
To: Marco Behnke
Cc: [email protected]
Subject: Re: [PHP] passing variables to php script
"it can't work as long as long as there is Q:\ ins his form action"
+1
David, which web server are you running (apache, iis, ...)?
What is your document_root?
And last question, where are your html file and your php file(the full file
path)?
---
Ellis
(Sent from my iPod)
On 2012-01-10, at 16:25, Marco Behnke <[email protected]> wrote:
> Am 10.01.12 21:57, schrieb Ashley Sheridan:
>>
>>
>>> o simply "callrecs.php" and see if that works.
>>> > Q: would be referencing a filesystem path, rather a web address
>>> > interpreted by a PHP processor. Make sure your .php target is within a
>>> > PHP supported web space.
>>> If a default application is set within windows for php, the script
>>> submitting to Q will be executed.
>>>
>>>
>>
>> But wouldn't Windows attempt to execute the PHP script as if it were a CLI
>> script, not as if it were within a web server context? That would make
>> posting a form pretty pointless.
> Indeed. But isn't that the point? We are trying to figure out why his posting
> the form does not work. I say, it can't work as long as long as there is Q:\
> ins his form action, no way it will do, because you leave your webserver
> context anyways.
>
> He must change it to a valid web url.
>
> --
> Marco Behnke
> Dipl. Informatiker (FH), SAE Audio Engineer Diploma
> Zend Certified Engineer PHP 5.3
>
> Tel.: 0174 / 9722336
> e-Mail: [email protected]
>
> Softwaretechnik Behnke
> Heinrich-Heine-Str. 7D
> 21218 Seevetal
>
> http://www.behnke.biz <http://www.behnke.biz/>
--- End Message ---
--- Begin Message ---
On Thu, Jan 12, 2012 at 7:51 PM, David Savage <[email protected]> wrote:
> Installed apache onto a win2K server, and have the html file & php file in
> the same folder (Q:\ASTERISK\) on the Q: drive (which is just another drive
> in this same server). I opened the html file using IE 6.0. What I'm
> thinking is there may be an issue with some setting on the web server. The
> php statements I posted were the first few statements in the script, so
> apparently the script didn't see the variables, so I'll have to review the
> httpd.conf and php.ini files to find whatever settings is preventing the
> acctnum, year, and month from being passed to the php script.
No, Don't open the html file from the drive! If you have installed
apache, you can open IE and go to http://localhost, this will show
your web site running. If you put the files from Q:\ASTERISK in the
folder where the website is, or you set this correctly in httpd.conf
then it will show up fine. Now, if you update the form, and replace
Q:\ASTERISK\callrecs.php with /callrecs.php, then it'll probably work
fine.
Matijn
--- End Message ---
--- Begin Message ---
On 12 Jan 2012 at 18:51, David Savage <[email protected]> wrote:
> Installed apache onto a win2K server, and have the html file & php file in the
> same folder (Q:\ASTERISK\) on the Q: drive (which is just another drive in
> this same server). I opened the html file using IE 6.0. What I'm thinking
> is there may be an issue with some setting on the web server. The php
> statements I posted were the first few statements in the script, so apparently
> the script didn't see the variables, so I'll have to review the httpd.conf and
> php.ini files to find whatever settings is preventing the acctnum, year, and
> month from being passed to the php script.
You say:
I opened the html file using IE 6.0
I don't like the sound of that. Do you mean you double-clicked the file and it
opened in IE or do you mean you put Q:\... into the IE address bar or what?
What you should be doing is putting http://localhost/your-file.html in the IE
address bar.
What is your document-root? Is the Q:\thingy part of it?
--
Cheers -- Tim
--- End Message ---
--- Begin Message ---
Again, coming from ASP background, I'm trying to minimize the typing
for most needed functionalities..
in asp, to set a session var, you go <%session("age")=90%> and to
output it, you just go <%=session("age")%>
in php, you've got to _SESSION['age']=90. that's a lot of keyboarding,
lots of double key strokes and the entire word session has to be
uppercase.
of course, if you use an IDE and you get fast at it, this may not be
an issue but I wanted to simplify it anyway.
so the plan is this
<?php
_s("age",43) //set the session var age to 43
echo _s("age") //outputs the value
?>
To achieve this; I wrote this preliminary function;
function _s($var,$val = "r4r53d323,9e809023890j832e@14fdsffdd")
{
if ($val == "r4r53d323,9e809023890j832e@14fdsffdd")
{return $_SESSION[$var];}
else
{$_SESSION[$var] = $val;}
}
Now, what's that number you ask!... it's just a value which I figured
I would never end up in a real app.
It's just a way for me to use default argument of the function so I
can call _s function with 1 or 2 arguments.
Can this be done a better way? How do you use _s function with 1 or 2
arguments so in 1 arg mode, you can use it as a set, and in 2 arg
mode, you use it as a way to return val.
Is func_get_args route the only way? performance wise which one would better?
--- End Message ---