php-general Digest 20 Jul 2007 07:12:22 -0000 Issue 4913

Topics (messages 259186 through 259206):

Compiling/Building PHP 5.2.3 on Mac OS X 10.3.9
        259186 by: Rahul Sitaram Johari
        259188 by: Greg Donald

Re: Pirate PHP books online?
        259187 by: tedd
        259192 by: Chris Boget

Re: Creating a text file
        259189 by: tedd
        259205 by: Ryan Lao

about SQL authentication on PHP
        259190 by: Lic. Eduardo R. Hernández Osorio

Re: If  MySQL column/field values are in an PHP array
        259191 by: kvigor

Re: repetition of tedious references
        259193 by: tedd
        259194 by: Tijnema
        259196 by: Eric Butera
        259197 by: Instruct ICC
        259199 by: tedd
        259200 by: Chris
        259201 by: Arpad Ray

Re: session_decode from session handler
        259195 by: Tijnema
        259198 by: Ryan Graciano

Re: Save email as .eml file
        259202 by: bkozora
        259204 by: Handa Utsav

Re: converting extended chars to plain ascii
        259203 by: ahlist
        259206 by: Eddie Dunckley

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 ---
Ave,

I¹m running php 5.0.2 on Mac OS X 10.3.9 (Panther) which I had installed
using entropy.ch¹s installer.
Time to upgrade ­ but not sure which way to go. Apparently Entropy does not
support anything < 10.4 (Tiger).

I¹ve looked around macports & fink but can¹t get any clear direction. Tried
macports but it gave nothing but errors.

So at this point I¹m considering building/compiling php 5.2.3 on my mac. I¹m
no *nix expert and I¹ve never compiled anything (relatively critical)
before. Looking for the right direction to instructions or knowledge on how
to go about doing this.

Unless anyone has a better solution of getting php 5.2.3 on mac os x 10.3.9

Thanks.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Rahul Sitaram Johari
CEO, Twenty Four Seventy Nine Inc.

W: http://www.rahulsjohari.com
E: [EMAIL PROTECTED]

³I morti non sono piu soli ... The dead are no longer lonely²

--- End Message ---
--- Begin Message ---
On 7/19/07, Rahul Sitaram Johari <[EMAIL PROTECTED]> wrote:
Unless anyone has a better solution of getting php 5.2.3 on mac os x 10.3.9

http://destiney.com/blog/php-4-5-macos-x


--
Greg Donald

--- End Message ---
--- Begin Message ---
At 7:01 PM -0500 7/18/07, Larry Garfield wrote:
On Wednesday 18 July 2007, tedd wrote:
 > And,
 I've spent enough time in court to know the difference.

Apparently not.

And how much time have you spent in court? Rhetorical question and not germane to the topic, but I have spent a considerable amount of time in court.

 > I am always surprised as to how simple wrongful acts can be
 diminished with spin. We live in a world of political correctness, to
 which we all object, but whenever we can, we add our own spin to the
 layers of complexities around us.

And here is the crux of the point that I've been making.  Information is not
property.  Property cannot be duplicated ad infinitim.

Neither can digital information be duplicated ad infinitum. But what does that have to do with anything?

Are you saying that only tangible objects can be stolen? Intellectual property certainly can be stolen. Your digital persona can be stolen. Are these not things that can be stolen?


Information can, by
its very nature.  The concept of "theft" does not apply.  The concept of
restricting the flow of information is artificial (to answer someone else's
question from earlier), whereas the laws of physics provide a natural
restriction on the flow of goods.

I'm not talking about information. I'm talking about thought processes committed to digital. Algorithms, code, art, words, pictures, music, and other forms of creativity that should have protection from the "flow of information" by people who don't want to pay for it.

Also, you said: "Laws of Physics" provide a natural restriction on the flow of goods?

That got a laugh out of me. Would you be so kind as to tell me what specific "Laws of Physics" pertain to the real world and not to the digital one? Would it surprise you that life it's self is digital? But, we're traveling into another topic to debate and I don't want to go there -- it's far more complex than this topic.

You are the one buying into the "spin" by claiming that information is as
permanently and inviolately restricted as atoms and molecules are.  That is
false.  That does not make breaking the law "right", but it is a necessary
fact of nature to understand if you want to understand the law and why the
law exists (in theory).

Well, you got me there! I'm clueless as to what the hell your talking about.

Of course, the media moguls have spent decades selling that spin precisely
because they want to confuse the issue.  If you convince people that
information is "property" in the same way that their house or car is, then
you undermine the purpose of copyright (promoting social good, not private
profit), undermine any attempts to reform the law, and undermine the basic
precepts of both open source software (the free flow of information creates
better expressive works through sharing) and Free software (restriction of
the free flow of information is immoral).

That's a mouthful, but totally wrong.

Why shouldn't the media moguls protect their investment, after all it's their investment?

You appear to expect everyone to provide you with information for free, is that it?

Is murder "theft"?  Of course not, but it's still illegal.
Is rape "theft"?  Of course not, but it's still illegal.
Is arson "theft"?  Of course not, but it's still illegal.
Is jaywalking "theft"?  Of course not, but it's still illegal.
Is speeding "theft"?  Of course not, but it's still illegal.
Is copyright infringement "theft"?  Of course not, but it's still illegal.

Duh!

Everyone of those example can be looked at as someone stealing something. Stealing life, stealing personal freedom, stealing use of processions, and so on. But, that's not at issue here.

You have made this issue into is one of what the definition of infringement is. It is clearly the act of breaking the law by having in your procession, or for your use, something that you are not entitled.

To me, that's stealing -- you call it what you want.

My grandkids have learned that they should never get into a "No, you did." exchange because I can carry it on forever. However, considering that this topic is tangent to php copyright infringement/theft issue, I shall refrain from posting to this subject to the list again. If you want to take the discussion off-list, you're welcome.

Larry, please understand that nothing that has been said in this exchange should be taken as a personal assault on you or your abilities -- you're simply expressing your opinion and I'm expressing mine. That's all.

Cheers,

tedd


--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message ---
> > The idea of even offering an electronic version should be to drive 
> > sales for the hard copy. Maybe offer a "Condensed Version" 
> > electronically, that has enough content that readers can get enough
of 
> > a feel for the product to drive a buying decision. Throughout, make 
> > reference to the full version having more complete content, complete

> > with an "order now" link.  This method worked well for Readers
Digest!
> Or watermark the .pdf with something that uniquely identifies each
copy
> - this could be done with a script at the time of the order.  Maybe
the name of the 
> original buyer, or the order number, etc.
> Doesn't prevent the piracy, but does give traceability should you wish
to pursue the 
> pirate.

Didn't/doesn't the PHP Architect magazine do this?  Or am I
mis-remembering?

thnx,
Chris

--- End Message ---
--- Begin Message ---
At 10:29 AM +0800 7/18/07, Ryan Lao wrote:
i made a simple PHP form that would ask for the users complete name, a
button that would browse to a file that the user wants to upload, a text
area for additional comments, and a submit button. This form works just
fine. what i want to achieve next is for my form to also create a text file
when it is submitted. The text file will contain the users complete name,
the filename that was being uploaded and the additional comments from the
user. Can anyone give me some ideas on how to do this?


If I was to do that, I would use MySQL. Store your data in a database -- much easier for me.

Cheers,

tedd
--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message ---
okay, i'll try that example you gave me... thanks!


""Daniel Brown"" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> On 7/17/07, Ryan Lao <[EMAIL PROTECTED]> wrote:
>> i made a simple PHP form that would ask for the users complete name, a
>> button that would browse to a file that the user wants to upload, a text
>> area for additional comments, and a submit button. This form works just
>> fine. what i want to achieve next is for my form to also create a text 
>> file
>> when it is submitted. The text file will contain the users complete name,
>> the filename that was being uploaded and the additional comments from the
>> user. Can anyone give me some ideas on how to do this?
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
>    Ryan,
>
>    Are you trying to create individual files for each form
> submission, or one file that will be appended with new data upon
> submission?
>
> -- 
> Daniel P. Brown
> [office] (570-) 587-7080 Ext. 272
> [mobile] (570-) 766-8107 

--- End Message ---
--- Begin Message ---
Hello:
I'm trying to connect to a SQL Server database with PHP using windows auth. 
To do that I modified the PHP.ini file changing the line above:
...
; Use NT authentication when connecting to the server
mssql.secure_connection = Off
...
putting mssql.secure_connection = On 
...
instead but when I tried to connect to SQL Server the function
mssql_connect('myserver', '', '') doesn't work.

What am I doing bad?
need I to do something else?

Help me please, waiting for your help,
Richard
____________________________________

Eduardo Ricardo Hernández Osorio

Técnico Telecomunicaciones Aeronáuticas

U.T.B Servicios Aeronáuticos, ECASA s.a.

Aeropuerto Internacional "Frank País García"

Tel: (53) (24) 474569

 

email: [EMAIL PROTECTED]

 

"...de buenas intenciones está empedrado el camino al infierno..."

-----Mensaje original-----
De: Jeff Taylor [mailto:[EMAIL PROTECTED] 
Enviado el: Tuesday, March 20, 2007 4:43 AM
Para: [EMAIL PROTECTED]
Asunto: [PHP] working with class inheritance

Hey all, got a slight problem, where for some reasons my variables dont seem
to be getting stored in the child class:

e.g

class Parent
{
  $private type;

  public function __construct()
  {
  }

   public function GetType()
   {
      return $this->type;
  }
}

class Child implements Parent
{
    $public function __construct()


      $this->type= 'Child';
      }
}

$Child= new Child();
echo $Child->getType;

Can u see any reason why the type would return null?

Thanks,

Jeff


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

--- End Message ---
--- Begin Message ---
OK,

$cen_fields is an array of a store's Name, City, and State concatenated.

$cen_fields[0] echo'd looks like this: CHIEFS SUPERMARKET ST. MARYS OH 
$cen_fields[1] echo'd looks like this: CHIEFS SUPERMARKET CELINA OH

$in_list is the concatenated store's Name, City, and State but formatted w/ 
commas for MySQL.

i.e.
>From > $in_list = "'".join("','",$cen_chiefs)."'";

$in_list echo'd looks like this:

'CHIEFS SUPERMARKET ST. MARYS OH','CHIEFS SUPERMARKET CELINA OH','CHIEFS 
SUPERMARKET COLDWATER OH','CHIEFS SUPERMARKET DELPHOS OH','CHIEFS 
SUPERMARKET DEFIANCE OH','CHIEFS SUPERMARKET BRYAN OH','CHIEFS SUPERMARKET 
WAUSEON OH','CHIEFS SUPERMARKET PAULDING OH','CHIEFS SUPERMARKET NAPOLEON 
OH'


The central table looks like the following: (There's more columns but to be 
concise I added ones in question)

+--------------------------------+-----------------+----------+
| strName                                    | strCity                 | 
strState |
+--------------------------------+------------------+----------+
| VILLAGE STORE 14 FRESH | WEST PENESIO  | PA       |
| VILLAGE STORE 19 FRESH | WEST PENESIO  | PA       |
| CHIEFS SUPERMARKET      | ST. MARYS         | OH       |
+--------------------------------+-------------------+--------+

So user fills in form.  Table is populated with form data, and if the store 
name, city, and state matches exactly to $in_list value it'll store form 
data in this particular table.

With my current query, rows will be returned only if they match strName, 
strCity, strState exactly.

In addition to that I want the query to return the rows where strName 
matches partial $in_list array value

So if CHIEFS SUPERMARKET ST. MARYS OH is a value in $in_list If user only 
enters "CHIEFS" and not CHIEFS SUPERMARKET I want to be able to return that 
row also, even though it doesn't exactly match array value.

I hope this is more clear.  I tried the MySQL forums but they are kinda slow 
responding.

//============================================================================
""M. Sokolewicz"" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> kvigor wrote:
>> I created an array using the following:
>>
>> $in_list = "'".join("','",$cen_chiefs)."'"; //$cen_chiefs is an array
>>
>> $query_cen_chiefs = "SELECT * FROM central WHERE CONCAT(strName,' 
>> ',strCity,' ',strState) IN({$in_list})";
>>
>> How would I go about adding an AND clause to the above query to return 
>> all rows where strName column values are in $in_list array
>>
>> I acutally did the above w/ "SELECT * FROM central WHERE CONCAT(strName,' 
>> ',strCity,' ',strState)
>> IN({$in_list}) AND (strName) IN({$in_list}) ORDER BY conName"; // This 
>> return zero rows.
>>
>> I think I Should I be using strName as a pattern, because strName would 
>> be a partial value of $in_list array values?
>>
>> Something like: REGEXP '^.....$'
>>
>> "SELECT * FROM central WHERE CONCAT(strName,' ',strCity,' ',strState) 
>> IN({$in_list}) AND (REGEXP '^strName$') IN({$in_list}) ORDER BY conName"; 
>> //This query doesn't work by the way.  This is where I'm stuck.
>
> First of all, let's start by saying that this question is very OT on a 
> php-list. It would be a lot more appropriate on a mysql list. But, I'll 
> try to help you anyway. First of all, I have no clue what you're trying to 
> do. Give some values (ie. what's in $cen_chiefs, what does the central 
> table look like, and what does strName look like.
>
> The whole problem here, afaics, is that you don't have a clear idea of 
> what you want. Tell us what you _want_ to do (not HOW, but what the result 
> should be) and we might be able to help.
>
> Now,
> SELECT * FROM central WHERE CONCAT(strName,' ',strCity,' ',strState) 
> IN({$in_list}) AND (REGEXP '^strName$') IN({$in_list}) ORDER BY conName
> won't work simply because you're saying (php-style): if($foo == $a.' '.$b 
> && $foo == $a), which obviously will _never_ work :) 

--- End Message ---
--- Begin Message ---
At 2:24 PM +0200 7/18/07, Olav Mørkrid wrote:
consider the following statement:

$language =
isset($_SERVER["HTTP_ACCEPT_LANGUAGE"]) &&
$_SERVER["HTTP_ACCEPT_LANGUAGE"] != "" ?
$_SERVER["HTTP_ACCEPT_LANGUAGE"] : "*";

when using strings in arrays that may be non-existing or empty, you
have to repeat the reference  *three* times, which gets excessive and
unreadable.

is there any way to only have to write
$_SERVER["HTTP_ACCEPT_LANGUAGE"] only once?

i know it's possible to supress "is not set" with @, but that just
seems wrong in case there really is an error in the statement.

i love php, but this is one of my pet peeves.

Olav:

Mine too.

But, Rasmus gave me this:

 $action = isset($_GET['action']) ? $_GET['action'] : null;

Which could be translated to:

$language = isset ($_SERVER["HTTP_ACCEPT_LANGUAGE"]) ? ($_SERVER["HTTP_ACCEPT_LANGUAGE"]) : "*";

I think that might help.

Anyone see a problem with it?

Cheers,

tedd
--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message ---
On 7/19/07, tedd <[EMAIL PROTECTED]> wrote:
At 2:24 PM +0200 7/18/07, Olav Mørkrid wrote:
>consider the following statement:
>
>$language =
>isset($_SERVER["HTTP_ACCEPT_LANGUAGE"]) &&
>$_SERVER["HTTP_ACCEPT_LANGUAGE"] != "" ?
>$_SERVER["HTTP_ACCEPT_LANGUAGE"] : "*";
>
>when using strings in arrays that may be non-existing or empty, you
>have to repeat the reference  *three* times, which gets excessive and
>unreadable.
>
>is there any way to only have to write
>$_SERVER["HTTP_ACCEPT_LANGUAGE"] only once?
>
>i know it's possible to supress "is not set" with @, but that just
>seems wrong in case there really is an error in the statement.
>
>i love php, but this is one of my pet peeves.

Olav:

Mine too.

But, Rasmus gave me this:

 $action = isset($_GET['action']) ? $_GET['action'] : null;

Which could be translated to:

 $language = isset
($_SERVER["HTTP_ACCEPT_LANGUAGE"]) ?
($_SERVER["HTTP_ACCEPT_LANGUAGE"]) : "*";

I think that might help.

Anyone see a problem with it?

Cheers,

tedd
--

Yes,what if the key does exists, but is empty?
Then it should fallback to the default value, which is exactly what
the OP script did, and what yours does too when you add != ""
statement, or empty().

Tijnema
--
Vote for PHP Color Coding in Gmail! -> http://gpcc.tijnema.info

--- End Message ---
--- Begin Message ---
On 7/19/07, tedd <[EMAIL PROTECTED]> wrote:
At 2:24 PM +0200 7/18/07, Olav Mørkrid wrote:
>consider the following statement:
>
>$language =
>isset($_SERVER["HTTP_ACCEPT_LANGUAGE"]) &&
>$_SERVER["HTTP_ACCEPT_LANGUAGE"] != "" ?
>$_SERVER["HTTP_ACCEPT_LANGUAGE"] : "*";
>
>when using strings in arrays that may be non-existing or empty, you
>have to repeat the reference  *three* times, which gets excessive and
>unreadable.
>
>is there any way to only have to write
>$_SERVER["HTTP_ACCEPT_LANGUAGE"] only once?
>
>i know it's possible to supress "is not set" with @, but that just
>seems wrong in case there really is an error in the statement.
>
>i love php, but this is one of my pet peeves.

Olav:

Mine too.

But, Rasmus gave me this:

  $action = isset($_GET['action']) ? $_GET['action'] : null;

Which could be translated to:

  $language = isset
($_SERVER["HTTP_ACCEPT_LANGUAGE"]) ?
($_SERVER["HTTP_ACCEPT_LANGUAGE"]) : "*";

I think that might help.

Anyone see a problem with it?

Cheers,

tedd
--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Since you're responding to someone else asking about such things where
there is the chance someone can just copy & paste...  There really
should be a whitelist against your actions.  This has the benefits of
making sure you know that your program is going to work as expected
whether or not a user is trying to be malicious or they copied the URL
incorrectly, etc.

This:
$action = isset($_GET['action']) ? $_GET['action'] : null;

Becomes:
$actions = array('one','two');
$action = (!empty($_GET['action']) AND in_array($_GET['action'], $actions))
   ? $_GET['action'] : null;

--- End Message ---
--- Begin Message ---
From: tedd <[EMAIL PROTECTED]>
Olav:

Mine too.

But, Rasmus gave me this:

 $action = isset($_GET['action']) ? $_GET['action'] : null;

Which could be translated to:

$language = isset ($_SERVER["HTTP_ACCEPT_LANGUAGE"]) ? ($_SERVER["HTTP_ACCEPT_LANGUAGE"]) : "*";

I think that might help.

Anyone see a problem with it?

Cheers,

tedd

I see a problem. If it is set and == "", you let it stay "" instead of being assigned "*". Only when it is not "" should it be allowed to stay the same.

_________________________________________________________________
Local listings, incredible imagery, and driving directions - all in one place! http://maps.live.com/?wip=69&FORM=MGAC01
--- End Message ---
--- Begin Message ---
At 5:41 PM -0400 7/19/07, Eric Butera wrote:
On 7/19/07, tedd <[EMAIL PROTECTED]> wrote:
But, Rasmus gave me this:

  $action = isset($_GET['action']) ? $_GET['action'] : null;

Since you're responding to someone else asking about such things where
there is the chance someone can just copy & paste...  There really
should be a whitelist against your actions.  This has the benefits of
making sure you know that your program is going to work as expected
whether or not a user is trying to be malicious or they copied the URL
incorrectly, etc.

This:
$action = isset($_GET['action']) ? $_GET['action'] : null;

Becomes:
$actions = array('one','two');
$action = (!empty($_GET['action']) AND in_array($_GET['action'], $actions))
   ? $_GET['action'] : null;

Eric:

Point well taken about asking a question in a question -- I'll try not to next time.

So, did Rasmus provide a problematic solution?

tedd


--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message ---
tedd wrote:
At 5:41 PM -0400 7/19/07, Eric Butera wrote:
On 7/19/07, tedd <[EMAIL PROTECTED]> wrote:
But, Rasmus gave me this:

  $action = isset($_GET['action']) ? $_GET['action'] : null;

Since you're responding to someone else asking about such things where
there is the chance someone can just copy & paste...  There really
should be a whitelist against your actions.  This has the benefits of
making sure you know that your program is going to work as expected
whether or not a user is trying to be malicious or they copied the URL
incorrectly, etc.

This:
$action = isset($_GET['action']) ? $_GET['action'] : null;

Becomes:
$actions = array('one','two');
$action = (!empty($_GET['action']) AND in_array($_GET['action'], $actions))
   ? $_GET['action'] : null;

Eric:

Point well taken about asking a question in a question -- I'll try not to next time.

So, did Rasmus provide a problematic solution?

Yeh that works fine (with the additional checks that Eric suggested).

But you're missing the point from the OP.

He wanted to AVOID having to do something to the effect of:

$var = null;
if (isset($really_long_var_name_here)) {
  $var = $really_long_var_name_here;
} else {
  $var = 'default_value';
}

Where $really_long_var_name_here is listed multiple times.

The function here: http://marc.info/?l=php-general&m=118476858504463&w=2 should do the trick but test for yourself.

--
Postgresql & php tutorials
http://www.designmagick.com/

--- End Message ---
--- Begin Message ---
Olav Mørkrid wrote:
i didn't know about empty. thanks!

do you have a link to this new php 6 ? : convention?

I haven't seen any documentation yet but it currently operates like:
($a ?: $b) === (empty($a) ? $b : $a)
with the exception that if $a is unset then an E_NOTICE error is raised.

It remains to be seen in the final version whether that notice is raised or that this operator exists at all

Arpad
it would be great if php 6 could have a solution for this. php is
sweet when it's compact!

On 18/07/07, Arpad Ray <[EMAIL PROTECTED]> wrote:

You can use empty() to take one of them out, since "0" is presumably
also not a desired input:

$language = empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])
    ? "*"
    : $_SERVER['HTTP_ACCEPT_LANGUAGE'];

There's a new ?: operator in PHP 6 which will make that even shorter,
however unlike empty(), it currently throws a notice with unset operands.


--- End Message ---
--- Begin Message ---
On 7/19/07, Ryan Graciano <[EMAIL PROTECTED]> wrote:

I'm having an issue getting session_decode to work from my session handler in 
PHP 5.2.3.  Here's a short code snippet that demonstrates what I'm trying to do 
(from my read handler) -

public function read($id) {
....
var_dump($data);  // prints out the serialized session correctly
$retval = session_decode($data);
var_dump($_SESSION);  // prints out "array(0) {}"
echo $retval;  // prints false
return $data;
}

In my calling function, $_SESSION is updated with everything that was held in 
$data, which means that $data was not corrupt - it worked when I returned it, 
but it did not work when I used session_decode.  This is a problem because I 
want to change my read($id) function so that it decodes $data, adds something 
extra to the $_SESSION, then re-encodes $data and returns it.

Thanks,
- Ryan

How did you get $data?

If it's just serialized data, you can simply call unserialize instead
of session_decode.

Tijnema

--
Vote for PHP Color Coding in Gmail! -> http://gpcc.tijnema.info

--- End Message ---
--- Begin Message ---
PHP passed $data to my write($id) function, and then I wrote it to the 
database.  In the code below, I have retrieved it from the database.  I presume 
that it used encode_session to generate $data.

I tried calling unserialize() on it for good measure, but it wasn't able to 
parse the data.  When I return $data from my method, though, PHP is able to 
turn it into a $_SESSION.

Thanks,
- Ryan

----- Original Message ----
From: Tijnema <[EMAIL PROTECTED]>
To: Ryan Graciano <[EMAIL PROTECTED]>
Cc: [EMAIL PROTECTED]
Sent: Thursday, July 19, 2007 5:28:32 PM
Subject: Re: [PHP] session_decode from session handler

On 7/19/07, Ryan Graciano <[EMAIL PROTECTED]> wrote:
>
> I'm having an issue getting session_decode to work from my session handler in 
> PHP 5.2.3.  Here's a short code snippet that demonstrates what I'm trying to 
> do (from my read handler) -
>
> public function read($id) {
> ....
> var_dump($data);  // prints out the serialized session correctly
> $retval = session_decode($data);
> var_dump($_SESSION);  // prints out "array(0) {}"
> echo $retval;  // prints false
> return $data;
> }
>
> In my calling function, $_SESSION is updated with everything that was held in 
> $data, which means that $data was not corrupt - it worked when I returned it, 
> but it did not work when I used session_decode.  This is a problem because I 
> want to change my read($id) function so that it decodes $data, adds something 
> extra to the $_SESSION, then re-encodes $data and returns it.
>
> Thanks,
> - Ryan

How did you get $data?

If it's just serialized data, you can simply call unserialize instead
of session_decode.

Tijnema

-- 
Vote for PHP Color Coding in Gmail! -> http://gpcc.tijnema.info







       
____________________________________________________________________________________
Pinpoint customers who are looking for what you sell. 
http://searchmarketing.yahoo.com/

--- End Message ---
--- Begin Message ---
I've been struggling with the same issue, does anyone have a link to or know
of a way to automatically create eml files using PHP? The links that Google
search returned were mostly specific to email clients, I need to create the
eml files on the server. Thanks
-- 
View this message in context: 
http://www.nabble.com/Save-email-as-.eml-file-tf4103444.html#a11701195
Sent from the PHP - General mailing list archive at Nabble.com.

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

Well it can be easily done. Just input your mail (make 'procmail' fwd
it) to your script & script would save it as .eml .

Try to use the following code for script :

######## CODE #####################

<?php 

$email = "";
## Read
E-mail                                                                          
                       
$fd = fopen("php://stdin", "r");
while (!feof($fd)) {
$email .= fread($fd, 1024);
}
fclose($fd);

# Save email
$handle = fopen("$path/$file_name.eml","a+");
 if (!$handle) {
   fwrite($log_handle," Failed ");
 }
 else {
   fwrite($handle,"$email");
   fclose($handle);
 }


?>

Hope this helps you out.


Greetings
Utsav Handa

--- End Message ---
--- Begin Message ---
On 7/19/07, ahlist <[EMAIL PROTECTED]> wrote:
Hello,

A libarary I'm using (the cybersource api if it helps any) is dying
when I pass it "extended" chars - such as bjorn (two dots over the o -
not sure of the actual name of this char -sorry).

For some reason, the newest version of cybersourc's api aborts on this input.

Can anyone recommend a quick way to strip/convert those chars out
before I pass it to cybersources lib?

I store the data as a varchar in mysql and pull it out in a query.

Thanks for ANY advice. I need to get some sort of fix for this asap.

I should add that I'm not using mbyte extension.

Is there any transformation or regex that could replace anything
outside of a-zA-z with another char. I don't need this to be exact.
The db will still hold the original, correct chars. I just need to
feed something to the cybersource lib that is all a-zA-Z

Thanks in advance.

--- End Message ---
--- Begin Message ---
On Fri 20 Jul 07 04:21, ahlist wrote:
> On 7/19/07, ahlist <[EMAIL PROTECTED]> wrote:
> > A libarary I'm using (the cybersource api if it helps any) is dying
> > when I pass it "extended" chars - such as bjorn (two dots over the
> > o - not sure of the actual name of this char -sorry).
> >
> > For some reason, the newest version of cybersourc's api aborts on
> > this input.
> >
> > Can anyone recommend a quick way to strip/convert those chars out
> > before I pass it to cybersources lib?
> >
> > I store the data as a varchar in mysql and pull it out in a query.
> >
> > Thanks for ANY advice. I need to get some sort of fix for this
> > asap.
>
> I should add that I'm not using mbyte extension.
>
> Is there any transformation or regex that could replace anything
> outside of a-zA-z with another char. I don't need this to be exact.
> The db will still hold the original, correct chars. I just need to
> feed something to the cybersource lib that is all a-zA-Z
>
> Thanks in advance.

do a $somestring = cleanconvertaccents($somestring);
then pass it over to your function. was trying to do the same and found 
nice examples in php.net and other places on the web.

// i got this function from the web.. converts accents into their lower 
ascii base chars. converted it a bit to handle more characters

// credits to opensource! got this from  the strtr docs on php.net
// thank you -sven (www.bitcetera.com)
// It does accents and umlauts, but also ligatures and runes known to 
ISO-8859-1

function cleanconvertaccents($str,$escapeapostrophes=false) {
    $str = cleanutfstrtranslate($str,$escapeapostrophes);
    $str = htmlentities($str);
    
    //$newstr = preg_replace("/&([a-z])[a-z\d]+;/i","$1",$str);
    $newstr = preg_replace("/(&#\d\d\d;)/i","$1",$str);
    $newstr = preg_replace("/:/","",$newstr);
    return $newstr;
}

function cleanutfstrtranslate($str,$escapeapostrophes=false) {
    $badwordchars=array(
                    "\xe2\x80\x98", // left single quote
                    "\xe2\x80\x99", // right single quote
                    "\xe2\x80\x9c", // left double quote
                    "\xe2\x80\x9d", // right double quote
                    "\xe2\x80\x94", // em dash
                    "\xe2\x80\xa6" // elipses
                    );
    if ($escapeapostrophes) { 
$fixedwordchars=array( "\\'", "\\'", '\\"', '\\"', '-', 'o'); }
    else { $fixedwordchars=array( "'", "'", '\"', '\"', '-', 'o'); }
    $str=str_replace($badwordchars,$fixedwordchars,$str);

    if ($escapeapostrophes) {
        $str= strtr($str, array("\x92"=>"\\'"));
    }
    $str = 
strtr($str, 
"\x91\x92\x93\x94\x96\xA1\xAA\xBA\xBF\xC0\xC1\xC2\xC3\xC5\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1"
                    
."\xD2\xD3\xD4\xD5\xD8\xD9\xDA\xDB\xDD\xE0\xE1\xE2\xE3\xE5\xE7\xE8\xE9\xEA\xEB\xEC"
                    
."\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF8\xF9\xFA\xFB\xFD\xFF",
                    
"\"'\"\"-!ao?AAAAACEEEEIIIIDNOOOOOUUUYaaaaaceeeeiiiidnooooouuuyy");
    $str= strtr($str, 
array("\xC4"=>"Ae", "\xC6"=>"AE", "\xD6"=>"Oe", "\xDC"=>"Ue", "\xDE"=>"TH", 
"\xDF"=>"ss",
                            "\xE4"=>"ae", "\xE6"=>"ae", "\xF6"=>"oe", 
"\xFC"=>"ue", "\xFE"=>"th","\x85"=>"..."));
    return($str);
}

-- 
Eddie Dunckley - [EMAIL PROTECTED] - Realtime Travel Connections 
IBE Development, www.rttc.co.za, cell 083-379-6891, fax 086-617-7831
Where 33deg53'37.23"S 18deg37'57.87"E Cape Town Bellville Oakdale ZA
         random quote: "Courage is grace under pressure."

--- End Message ---

Reply via email to