php-general Digest 14 Jan 2006 16:55:33 -0000 Issue 3905

Topics (messages 228607 through 228618):

‚Í‚¢‚Í‚¢‚Í‚¢I
        228607 by: dioojula6

Re: mysqli bind_param and store_result don't work well together
        228608 by: Curt Zirzow

Re: most reliable way to test if using https
        228609 by: Curt Zirzow
        228610 by: Curt Zirzow

Re: Lions and tigers and slashes, oh my!
        228611 by: Curt Zirzow

Re: Parsing a large file
        228612 by: Curt Zirzow
        228613 by: Curt Zirzow

Re: Regex help
        228614 by: Curt Zirzow

Re: XML-Request
        228615 by: Björn Bartels

Re: Access Client IP address
        228616 by: PHP Superman

Help taking a string from a file
        228617 by: Lists

Using aliases to have an email trigger a php script
        228618 by: Sean Lerner

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:
        php-general@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
必見!極上ランキングサイト!
MVPサイト発表
http://zwya.com/hh1292/

問)
[EMAIL PROTECTED]
13:23:56

--- End Message ---
--- Begin Message ---
On Sat, Jan 14, 2006 at 03:18:55AM +0530, anirudh dutt wrote:
> On 1/5/06, Curt Zirzow <[EMAIL PROTECTED]> wrote:
> > On Wed, Jan 04, 2006 at 12:31:02AM +0530, anirudh dutt wrote:
> > > hi
> > > the subject is pretty much what the problem is.
> > >
> > > if i use
> > > $st1 = $sql->stmt_init(); // $sql is a mysqli obj/conn
> > > $st1->prepare("select `num` from `activity` where `id` = ?");
> > > $st1->bind_param('s', $myid);
> > > $myid = '3f6d017d3e728b057bcc082a7db75a57'; // forcing value to check
> > ...
> > >
> > > gives rows: 0, num: 0
> > ...
> > >
> > > also, if i use an sql var in the prepare/bind case as
> > > $st1->prepare("select @ck_num:=`num` from `activity` where `id` = ?");
> > > var_dump($rz) is NULL; otherwise it's int(7)
> >
> > What version of php and mysql do you have?
> >
> > Curt.
> 
> php 5.0.3

I would take in consideration that:

  - 5.0.3 was realease prior to March 31, 2005 
  - 5.0.4 was realease on March 31, 2005 
  - 5.0.5 was released on Sep 06, 2005.
  - 5.1.0 was release on Nov, 24, 2005
  - 5.1.1 was release on Nov, 28, 2005
  - 5.1.2 was release on Jan 12, 2006

And considering that any new release of any new version is prone to
serveral bugs; toward a more stable system as time passes.

The version you have is almost a year old. Not to mention the
stable releases are being issued on 5.1.x now.

wow, with that timetable, i just have to say.. happy new year to
everyone!! time goes by so fast.


Curt.
-- 
cat .signature: No such file or directory

--- End Message ---
--- Begin Message ---
On Fri, Jan 13, 2006 at 04:12:08PM -0700, Ray Hauge wrote:
> if( !preg_match("/HTTPS/", $_SERVER['SERVER_PROTOCOL']) ){
>       ....
> }
> 
> That's what I have been using.

Thats odd cause all my servers report this as SERVER_PROTOCOL via
https:

 $_SERVER["SERVER_PROTOCOL"] == HTTP/1.1

Thats odd cause all my servers report this as SERVER_PROTOCOL via
http:

 $_SERVER["SERVER_PROTOCOL"] == HTTP/1.1

Protocol doesn't have to do with how it is being transferred. The
protocol is based on the request being givin:

  GET / HTTP/1.1

Curt.
-- 
cat .signature: No such file or directory

--- End Message ---
--- Begin Message ---
On Sat, Jan 14, 2006 at 04:20:27AM +0000, Matt wrote:
> James Benson wrote:
> 
> >What is the most reliable way to test if a connection is already using 
> >the https protocol, is their a PHP constant or something builtin already?
> >
> >
> >
> >Thanks,
> >James
> >
> Something like?
> 
> if (isset($_SERVER["HTTPS"]) && 'on' == $_SERVER["HTTPS"])
> {// ssl
> } else {
> // non-ssl
> }

To be safe about this is to ensure that the var HTTPS is compare in
a caseless manner like:

  'on' == strtolower($_SERVER["HTTPS"])

Most webservers report it in lower case but some say 'On' 

Curt.
-- 
cat .signature: No such file or directory

--- End Message ---
--- Begin Message ---
Bear (pun intened) with me on this one i havn't read the whole
thread, so you may get a repeat answer.

On Fri, Jan 13, 2006 at 10:55:00AM -0600, Jay Blanchard wrote:
> I am having a problem with a an ampersand sign. I have a list of things on a
> page, in which one category is 'Oil & Gas'. I store it in the database as
> 'Oil &amp; Gas'. When the category is clicked the query string shows just an
> ampersand, i.e.

The database should really hold text/plain, not text/html.

If you take the string 'Oil &amp; Gas' out side of the context of
html that &amp; is a rather strange sequence of characters.

> "Filter=Process&FilterKey=Oil%20&%20Gas&Order=Application&Direction=ASC&comm
> ents=" and therefore just shows as an '&' and the query only sees 'Oil'.

You forgot to urlencode() each value that is passed. And say you
did urlencode the data you would have:

Filter=Process&FilterKey=Oil+%26+Gas

Now the $_GET['FilterKey'] is 'Oil & Gas'

If you do a search on the db for this value with something like:

$cat = mysql_real_escape_string($_GET['FilterKey']);
$sql = "select * from table where cat = '$cat'";

You will come back with 0 results since you really have in that cat
field 'Oil &amp; Gas'.

> 
> I guess that I am too tired to deal with this or the answer would come to
> mind immediately. Can someone drop kick me in the right direction? Thanks!

Remember:

  characters only have meaning in the context they are used

If I want to use 'Oil & Gas' in:

  html: i need to html_entity_docode()/htmlentities() it
  sql:  i need to ensure it is escaped *_escape_string();
  url:  i need to urlencode() it.
  plain/text: just an echo/print
  store on a main frame: ASCII2EBCDIC() it


Curt.
-- 
cat .signature: No such file or directory

--- End Message ---
--- Begin Message ---
On Fri, Jan 13, 2006 at 04:21:10PM -0600, Richard Lynch wrote:
> 
> If you DO use grep, don't cat the whole file out to grep it...
> 
> grep __filename__ > __newfile__
 
oops, forgot the expression :)

 grep findthis __filename__ > __newfile__



-- 
cat .signature: No such file or directory

--- End Message ---
--- Begin Message ---
On Fri, Jan 13, 2006 at 04:47:11PM -0600, Jay Paulson wrote:
> > On Fri, January 13, 2006 3:33 pm, Jay Paulson wrote:
> >> $buf = "";
> > 
> > Probably better to initialize it to an empty array();...
> 
> Yep right.
>  
> >> while (!feof($fhandle)) {
> >>     $buf[] = fgets($fhandle);
> > 
> > ... since you are going to initialize it to an array here anyway.
> > 
> >>     if ($i++ % 10 == 0) {
> > 
> > Buffering 10 lines of text in PHP is probably not going to make a
> > significant difference...
> 
> This is true.  It's what I have written to start with.  Basically I'm just
> trying to make sure that I'm not hogging system memory with a huge file b/c
> there are other apps running at the same time that need system resources as
> well.  That's the main reason why I'm using a buffer to read the file in and
> parse it a little at a time.  By all means test it out on your hardware and
> see what that buffer needs to be.

I'd tend to go with Richard's suggestion. You say you are worried
about resources and memory? well when you load those 10 lines of
code where do they go? memory.

if resource and memory is an issue, there are a couple of options i
would suggest, being that the bottleneck is really disk I/O and cpu
usage.

  1) inside the loop (while reading one line at a time) do a
     usleep(), this will prevent heavy disk access and let the cpu
     catchup with processing

  2) 'nice' the application. run php under nice and give its cpu
     usage a lower priority of cpu processing time.

If you want to test how usleep and the 'nice' thing works here are
some sample scripts to benchmark with:

// cpu usage try with and without nice
  while (1) {}
vs.
  while(1) { usleep(500); }

//diskio, try with and without nice
  $fp = fopen('/var/log/messages', 'r') or die('boo');
  while(1) {
    $line = fgets($fp);
    fseek($fp, 0, SEEK_SET);
  }
vs.
  $fp = fopen('/var/log/messages', 'r') or die('boo');
  while(1) {
    $line = fgets($fp);
    fseek($fp, 0, SEEK_SET);
    usleep(500);
  }

Like Richard said, there are much easier ways to make the app less
resource intensive instead of trying to battle io between memory
and cpu, within php.

Curt.
-- 
cat .signature: No such file or directory

--- End Message ---
--- Begin Message ---
On Fri, Jan 13, 2006 at 08:25:57AM -0500, Mike Smith wrote:
> I'm trying to save myself some time by extracting certain variables
> from a string:
> 
> 102-90 E 42 X 42 X 70 3/8
> 
> I've been testing with: http://www.quanetic.com/regex.php
> and have been somewhat successful. Using this pattern:
> /[0-9]{2,}( X| x|x )/

The biggest problem with trying to match a string with regex is you
have to know the definition of what the string can be, for example
can the data be:
  
   102-90 E 42  X 42 X 70 3/8
   102-90 E 42 X  42 X 70 3/8
   102-90 E 42X42X70 3/8
   102-90 E 42\tX\t  42 \t X\n 70\r\n 3/8

> 
> I have:
> 102-90 E [!MATCH!] [!MATCH!] 70 3/8

If you want to just match those two numbers then:

  /\s+(\d{1,2})\s+(X|x)\s+(\d{1,2})\s+(X|x)\s+/

> 
> 
> Ideally what I want to do is update the db table that holds these records.
> ID: 1
> Unit: 102-90 E 42 X 42 X 70 3/8
> Panel: 42
> Width: 42
> Height: 70 3/8

If this is the case, where does the 102-90 E come from? This sounds
more like a data normalization issue than anything.
 
Curt.
-- 
cat .signature: No such file or directory

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

try this as your first output line:
$this_output = "<?xml version=\"1.0\"
encoding=\"".$_XMLCONFIG["enc-type"]."\"?".">";


hope that helps...

cheers

björn

>Hi, I gotta send an XML request to a server. In the doc it's defined as
>follows:
>[request]
><xs:request xmlns:xs='urn:pinXpressSchema' version='1.5' langCode='en'>
>
><DEALERinfo aspName=‘XXX’
>
>dealerName=''
>
>posName='1234'
>
>posPassword='1234'
>
>userName=''
>
>userPassword='1234' />
>
><purchasePINs transID='1234567890' ticket='true' ticketWidth='32' />
>
></xs:request>
>[/request]
>and I tried to realize it that way:
>[Code]
><?php
>$n = "

";
>$aspName="XXX";
>$dealerName="paykiosks";
>$posName="998745";
>$posPasswords="998745";
>$userName="";
>$userPassword="";
>
>$inputdata = '<xs:request xmlns:xs='urn:pinXpressSchema' version='1.5'
>langCode='en'>'.$n.'
><DEALERinfo aspName='.$aspName.'
>dealerName='.$dealerName.'
>posName='.$posName.'
>posPassword='.$posPassword.'
>userName='.$userName.'
>userPassword='.$userPassword.'/>
><purchasePINs transID=1234567890 ticket=true ticketWidth=32 />
></xs:request>';
>$x = curl_init("https://xml.pinsprepaid.com/xml/xmlPinXpress.asp";);
>curl_setopt($x, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
>curl_setopt($x, CURLOPT_HEADER, 0);
>curl_setopt($x, CURLOPT_POST, 1);
>curl_setopt($x, CURLOPT_POSTFIELDS, $inputdata);
>curl_setopt($x, CURLOPT_FOLLOWLOCATION, 0);
>curl_setopt($x, CURLOPT_REFERER, "http://localhost/test.php";);
>curl_setopt($x, CURLOPT_RETURNTRANSFER, 1);
>$data = curl_exec($x);
>curl_close($x);
>echo $data;
>?>
>[Code]
>but I only got the Answer:
>"invalid xml"
>
>Why, what's going wrong? Thank you for your help!
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Björn Bartels
-Development/IT-Services-

----------------------------------------------
dbusiness.de gmbh
digital business & printing gmbh

Greifswalder Str. 152
D-10409 Berlin

Fon: [0.30] 4.21.19.95
Fax: [0.30] 4.21.19.74

www.dbusiness.de
[EMAIL PROTECTED]
ftp://dbusiness.dyndns.org

--- End Message ---
--- Begin Message ---
$_SERVER['REMOTE_ADDR'] will give you the proxy ip if they have one, and the
browser sends the info, the user might change it to blahblahblah for all we
know...

On 1/4/06, Jay Blanchard <[EMAIL PROTECTED]> wrote:
>
> [snip]
>     Is there any way to client's IP address inside a php document. I am
> trying to generate a code that depends on the IP address of the client.
> [/snip]
>
>
> http://us3.php.net/manual/en/reserved.variables.php#reserved.variables.serve
> r
>
> $_SERVER['REMOTE_ADDR']
>
> but it may not always be reliable
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


--
Hi Everyone, I am running PHP 5 on Windosws XP SP2 with MySQL5, Bye Now!

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

I made something work, but probably in the most crappy way possible.

My goal is to take just the HTML for the image and link from the Flickr badge js script.

This is what I did, please help me do in a better way. I'd appreciate good sources to read to learn to strip stuff away and just get specific parts as well. I never know which of the str functions to use.

<?
// allow retrieval of external web source
ini_set('allow_url_fopen',1);

// get flickr js file
$photo = file_get_contents("http://www.flickr.com/badge_code_v2.gne? count=1&display=latest&size=m&layout=h&source=user&user=91667218% 40N00");

//get rid of all the crap except for the image tags
$photo = strstr($photo, '<a');
list($image, $trash) = explode("'", $photo);
$image = ereg_replace("</td>","", $image);
?>

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

I'd like an email received to [EMAIL PROTECTED] to trigger a
php script.

I've configured the following:

in /etc/aliases
toronto: |/var/www/wq/email_toronto.php

in /etc/exim/exim.conf
system_aliases:
 driver = aliasfile
 file_transport = address_file
 pipe_transport = address_pipe
 file = /etc/aliases
 search_type = lsearch
 user = mail

in /var/www/wq/email_toronto.php
#!/usr/bin/php -q
<?
 $var_toronto_file = fopen("toronto.txt", "a");
 fwrite($var_toronto_file, "Email Received!\n");
 fclose($var_toronto_file);
?>

I then send an email to [EMAIL PROTECTED] and check the file
toronto.txt but it does not say Email Received!

The exim log shows:
2006-01-13 13:38:12 1ExToS-0007Ni-00 <= [EMAIL PROTECTED] H=mailout2.igs.net
[216.58.97.88] P=esmtp S=758 [EMAIL PROTECTED]
2006-01-13 13:38:12 1ExToS-0007Ni-00 => |/var/www/wq/email_toronto.php
<[EMAIL PROTECTED]> D=system_aliases T=address_pipe
2006-01-13 13:38:12 1ExToS-0007Ni-00 Completed

There's nothing in the panic log or syslog.

A few things I've tried:
* changed the permissions to 777 in toronto.txt and email_toronto.php to rule out a permissions issue
* changed in systems_aliases user=root
* put the script in /etc/smrsh (even though I don't think I'm running smrsh on my server)

Any idea as to why my script isn't being triggered by the email? Any further logs I can check?

Thanks,

Sean

--- End Message ---

Reply via email to