Re: [PHP] Reg.Photo Upload Tool

2007-09-07 Thread Ramesh.b
Thanks Jay,

I want a client side tool , something similar to Yahoo photos or flickr,
where it will shrink the size of the image and upload.

Thanks
Ramesh
""Jay Blanchard"" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
[snip]
Any opensource or PHP applicaiton is available for Photo upload tool?.
[/snip]

Easy to do yourself
http://us2.php.net/manual/en/features.file-upload.php

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



Re: [PHP] Converting PHP code to C#?

2007-09-07 Thread mike
On 9/7/07, Symbian <[EMAIL PROTECTED]> wrote:
>
> I'm unable to workout how to get the same IV as the one generated by the PHP
> script is random. The thing is that we cant change the PHP script as its
> readily being used now. Maybe I should look at the encryption routine and
> reverse that first?

just hard code the IV in both places.

to make it difficult you can do something like this (basically our
.NET guy took it from
http://www.codeproject.com/dotnet/DotNetCrypto.asp)

public static string Encrypt(string clearText, string Password)
{
// First we need to turn the input string into a byte array.
byte[] clearBytes =
  System.Text.Encoding.UTF8.GetBytes(clearText);

PasswordDeriveBytes pdb = new PasswordDeriveBytes(Password,
new byte[] {0x49, 0x76, 0x61, 0x6e, 0x20, 0x4d,
0x65, 0x64, 0x76, 0x65, 0x64, 0x65, 0x76});

 byte[] encryptedData = Encrypt(clearBytes,
 pdb.GetBytes(32), pdb.GetBytes(16));

   return Convert.ToBase64String(encryptedData);

}

(make sure to copy that first Encrypt method and set alg.Padding =
PaddingMode.Zeros)

and on PHP side (the IV/key numbers have been changed to protect the
innocent :))

i believe the numbers are the decimal values of the .NET 0x49 etc. you
need 32 of them for the key, and 16 for the IV (to match the
parameters above) - these numbers do not match right now i just
jumbled them up. i would first see if you can use my code to properly
encrypt in .NET and decrypt in PHP. then hopefully you can just
reverse it.

what i should do is actually publish an example with working
instructions + numbers. i'll keep this email around and publish an
article on my blog or something hopefully soon.

function decrypt($text, $key) {
$enc_key_array = Array(24,91,81,138,122,etc);
$chrs = "";
foreach(array_values($enc_key_array) as $chr) {
$chrs .= chr($chr);
}
$enc_key = $chrs;
$enc_iv_array = Array(35,56,103,81,77,etc);
$chrs = "";
foreach(array_values($enc_iv_array) as $chr) {
$chrs .= chr($chr);
}
$enc_iv = $chrs;
$text = base64_decode($text);
$decrypted = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $enc_key,
$text, "cbc", $enc_iv);
return $decrypted."\n";
}

remember to base64 encode/decode at the proper times. we use this to
encrypt information in a cookie so it needs to be encoded for transit.
it also helps when you are copy/pasting it back and forth to test
encrypt/decrypt :)

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



Re: [PHP] Php script for mail in a xhtml page

2007-09-07 Thread brian

Mauro Sacchetto wrote:

I've to implement a php script in a web page to send mail.
If I use a .html form and a separate .php script, all works fine.
In the contrary, if I try to put the script into the .html file,
I've some troubles... Here's the code:

...

When I try to open the page, I receive this error:

Parse error: syntax error, unexpected T_STRING 
in /var/www/netsons.org/samiel/form2.php on line 79


Do u see my error?


{Copies, pastes into editor that will number the lines ...}

Well, looking in the vicinity of line 79, i'd say the problem lies with 
your reversed PHP tags:


 echo $name. 

You've got another right below that:

?> echo $message;

Some other points:

- You can do without the "echo" by using, eg. 

- Because this is an XHTML page, you should be closing your input tags 
and properly quoting the attributes: value="" />


- That your script's purpose is to send mail has nothing to do with how 
it displays in a browser.


Anyway, that should do it. Be sure to validate the page.

brian

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



Re: [PHP] 'application' variables not available? Alternatives?

2007-09-07 Thread Vidyut Luther
Hi David,
 I'd say your best bet is to use memcached. This will allow the
variables you specified to stay in memory, and be accessible to all
other applications.

http://www.danga.com/memcached/

Keep in mind though, just because ASP does it in one way, you don't want
to do a bit for bit copy. You could also look into options like the
auto_prepend feature in php.ini, and the define() function.

http://us2.php.net/define

I personally don't like using the auto_prepend feature, but it's there
and you could use it if you like, I'm a fan of implicitly requiring
files if I need to.

If your associative array, is really that large that it's going to slow
things down, you may also want to consider whether all your scripts need
all of the data, and then possibly define things that are only necessary
for certain classes, in the file for that class.

You can also serialize your associative array, and store it in the
database.. but it's really all dependant on what you need, and what the
app needs.



david wrote:
> Hi
>
> I am looking at converting a large project from ASP to PHP, and have read 
> that there is no equivalent of global.asa in PHP. It is probably easiest if 
> I describe the problem starting with how the ASP does it:
>
> Project uses global.asa to load a lot of 'global' constants and variables 
> into memory. This includes translations for the web site in a number of 
> different languages. These are loaded from text files so that changing them 
> is easy. These items when loaded in global.asa are as if they are in an 
> associative array which is available to the whole application - it is not 
> destroyed when the page is destroyed!
>
> Any ideas how I could handle this in PHP? The ASP method seems sensible, as 
> the data is much too big to load for every page, and too common to load only 
> when required. Holding it in memory and it having application wide scope 
> like this is fast. Loading only parts required at execution from, say, a 
> database would surely be too costly in db calls?
>
> Anyone have any ideas about what I could do?
>
> Many thanks, David
>
>   

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



Re: [PHP] Converting PHP code to C#?

2007-09-07 Thread Symbian

Mike,

Thanks for the reply and your very useful notes.

I'm unable to workout how to get the same IV as the one generated by the PHP
script is random. The thing is that we cant change the PHP script as its
readily being used now. Maybe I should look at the encryption routine and
reverse that first?

Thanks,
Sym


mike-22 wrote:
> 
> I've done it in reverse - something encrypted in .NET and then decrypted
> in PHP
> 
> these were my notes...
> 
> 
> To get .NET and PHP to play friendly with two-way encryption, you need
> to make sure some things happen in both:
> In .NET:
> 1) You need to set the Padding to PaddingMode.Zeros, i.e.:
>  Rijndael alg = Rijndael.Create();
>  alg.Padding = PaddingMode.Zeros;
> 2) You also need to make sure to use System.Text.Encoding.ASCII or
> System.Text.Encoding.UTF8; System.Text.Encoding.Unicode will *not*
> work (perhaps in PHP6 this might be possible.)
> 3) Need to make sure the IV and key are the same as defined in PHP.
> 
> In PHP:
> 1) You need the mcrypt extension installed.
> 2) Need to make sure the IV and key are the same as defined in .NET.
> 3) You can issue this single line of code to decrypt:
>  mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, $encrypted_text, "cbc", $iv);
> 
> Notes:
> 1) By default .NET uses a 128-bit cipher in CBC mode when you
> initialize Rijndael. That might not be common knowledge.
> 2) If you're sending this data via a URL or cookie or something else,
> be sure to base64 encode on the .NET side, and base64_decode() the
> data on the PHP side.
> 
> 
> below i would say that:
> 
> a) you need to make sure the IV is the same. right now it looks like
> you are creating a random one in PHP and a different one in .NET. that
> would be my first thing to check.
> 
> b) not sure if ECB vs. CBC is any different; i know CBC will work though.
> 
> hope that helps some. it took some debugging for us, and it didn't
> help that our .NET guy created the IV using low and high ascii
> character codes that I had to reproduce in PHP for the IV and the
> key... I would get different sizes as well, but once the stars aligned
> it worked perfectly. Be sure that any base64 encoding/decoding or
> anything like that is done in the proper order (typically start out
> with no encoding, get it to work, then add on encoding and decoding on
> both ends properly, etc.)
> 
> good luck :)
> 

-- 
View this message in context: 
http://www.nabble.com/Converting-PHP-code-to-C---tf4397727.html#a12565713
Sent from the PHP - General mailing list archive at Nabble.com.

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



[PHP] Php script for mail in a xhtml page

2007-09-07 Thread Mauro Sacchetto
I've to implement a php script in a web page to send mail.
If I use a .html form and a separate .php script, all works fine.
In the contrary, if I try to put the script into the .html file,
I've some troubles... Here's the code:

==


http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>http://www.w3.org/1999/xhtml";>




B#038;B #171;LA LOCANDA DI RE MANFREDI#187; - PALAZZO SAN
GERVASIO (PZ)







Home Page
Il nostro Bed#038;Breakfast
Il paese
La storia
Le tradizioni
Indirizzi utili


#200; possibile inviarci una comunicazione direttamente da questo
form
Riempire i campi richiesti e premere il pulsante "Invia"


Il messaggio non e' stato inviato
Si prega di compilare tutti i campi

Nome:


Indirizzo e-mail:


Oggetto:


Messaggio:



#160; #160; #160; #160; #160; #160;


Il messaggio non e' stato inviato
L'indirizzo e-mail indicato non e' valido";
?>

Nome:
 echo $name. 

Indirizzo e-mail:


Oggetto:
?> echo $message;

> #160; #160; #160; #160;
#160; #160;


");
echo "Il messaggio e' stato inviato correttamente
Risponderemo il piu' presto possibile
Grazie di averci scritto"; }

}
?>


==

When I try to open the page, I receive this error:

Parse error: syntax error, unexpected T_STRING 
in /var/www/netsons.org/samiel/form2.php on line 79

Do u see my error?
Thanx!
MS



-- 
linux user no.: 353546
public key at http://keyserver.linux.it

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



[PHP] Re: cant mail

2007-09-07 Thread Manuel Lemos
Hello,

on 09/06/2007 07:42 AM Diana Castillo said the following:
> 
> 
> when I try to send mail using this code:
> 
> mail("[EMAIL PROTECTED]","TEST MAIL","TESTING MAIL");
> 
> I get this error:
> 
> 
> Warning: mail() [function.mail]: SMTP server response: 554 
> <[EMAIL PROTECTED]>: Recipient address rejected: Access denied in 
> C:\Inetpub\wwwroot\intranet\test.php on line 4
> 
> my settings in php.ini are
> SMTP = "smtp.tsanalytics.com"
> smtp_port = 25 

That means you need to authenticate to relay messages through that SMTP
server.

PHP mail() function does not support SMTP authentication.

You can try using the smtp_mail() function from this package that
emulates the mail function and supports authentication. Take a look at
the test_smtp_mail.php script:

http://www.phpclasses.org/mimemessage

You also need these other classes to perform authentication through SMTP:

http://www.phpclasses.org/smtpclass

http://www.phpclasses.org/sasl

-- 

Regards,
Manuel Lemos

Metastorage - Data object relational mapping layer generator
http://www.metastorage.net/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

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



[PHP] 'application' variables not available? Alternatives?

2007-09-07 Thread david
Hi

I am looking at converting a large project from ASP to PHP, and have read 
that there is no equivalent of global.asa in PHP. It is probably easiest if 
I describe the problem starting with how the ASP does it:

Project uses global.asa to load a lot of 'global' constants and variables 
into memory. This includes translations for the web site in a number of 
different languages. These are loaded from text files so that changing them 
is easy. These items when loaded in global.asa are as if they are in an 
associative array which is available to the whole application - it is not 
destroyed when the page is destroyed!

Any ideas how I could handle this in PHP? The ASP method seems sensible, as 
the data is much too big to load for every page, and too common to load only 
when required. Holding it in memory and it having application wide scope 
like this is fast. Loading only parts required at execution from, say, a 
database would surely be too costly in db calls?

Anyone have any ideas about what I could do?

Many thanks, David

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



Re: [PHP] Reg.Photo Upload Tool

2007-09-07 Thread Kevin Waterson
This one time, at band camp, "Ramesh.b" <[EMAIL PROTECTED]> wrote:

> Hello,
> 
> Any opensource or PHP applicaiton is available for Photo upload tool?.

http://phpro.org/examples/Multiple-file-upload.html

Kevin


-- 
"Democracy is two wolves and a lamb voting on what to have for lunch. 
Liberty is a well-armed lamb contesting the vote."

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



Re: [PHP] Creating a File in Memory

2007-09-07 Thread Michael Preslar
Can't help with your main problem, however I find it easier to write
the likes of :

$kml_string = << wrote:
> Hello All,
>
> I am trying to zip data in a PHP program using the following code.  The
> resulting file (ndfdViaPipe.kmz) is zip'ed but the data in the archive
> lacks a file name.  So when a program like Google Earth tries to process
> the file, it fails.  When I bring ndfdViaPipe.kmz into WinZip, the file
> has no name but can otherwise be extracted just fine.  Once extracted,
> Google Earth can process the file.  Does anyone know how I might add the
> "file name" information to the ndfdViaPipe.kmz?  The reason I'm trying
> to use pipes is to avoid creating a file with the dynamically created
> data in $kml_string.  The plan is to send $kmz_content out in a SOAP
> service message with the payload as base64 encoded file.  If there is a
> better way to accomplish this I am certainly open to suggestions.
>
> In advance, thanks for any help you care to offer.
>
> John
>
> 
> $kml_string = "";
> $kml_string = $kml_string . " xmlns=\"http://earth.google.com/kml/2.1\";>";
> $kml_string = $kml_string . "";
> $kml_string = $kml_string . "   National Digital Forecast Database
> Data";
> $kml_string = $kml_string . "   1";
> $kml_string = $kml_string . "   name=\"NdfdData\">";
> $kml_string = $kml_string . " name=\"UOM\">";
> $kml_string = $kml_string . " name=\"ValidTime\">";
> $kml_string = $kml_string . " name=\"MaxTemp\">";
> $kml_string = $kml_string . "  ";
> $kml_string = $kml_string . "  ";
> $kml_string = $kml_string . "Maximum Temperature";
> $kml_string = $kml_string . "90F valid at
> 2007-06-26T00:00:00-04:00";
> $kml_string = $kml_string . "";
> $kml_string = $kml_string . "  -77.37,37.82";
> $kml_string = $kml_string . "";
> $kml_string = $kml_string . "F";
> $kml_string = $kml_string . "
> 2007-06-26T00:00:00-04:00";
> $kml_string = $kml_string . "95";
> $kml_string = $kml_string . "  ";
> $kml_string = $kml_string . "  ";
> $kml_string = $kml_string . "Maximum Temperature";
> $kml_string = $kml_string . "89F valid at
> 2007-06-26T00:00:00-04:00";
> $kml_string = $kml_string . "";
> $kml_string = $kml_string . "  -77.5,38.00";
> $kml_string = $kml_string . "";
> $kml_string = $kml_string . "F";
> $kml_string = $kml_string . "
> 2007-06-26T00:00:00-04:00";
> $kml_string = $kml_string . "89";
> $kml_string = $kml_string . "  ";
> $kml_string = $kml_string . "";
> $kml_string = $kml_string . "";
>
> $descriptorAssignments = array(
>0 => array("pipe", "r"),  // stdin is a pipe that the child will read
> from
>1 => array("pipe", "w"),  // stdout is a pipe that the child will
> write to
>2 => array("file", "/tmp/error-output.txt", "a") // stderr is a file
> to write to
> );
>
> $kmz_process = proc_open('zip',$descriptorAssignments,$pipes);
>
> if (is_resource($kmz_process))
> {
>fwrite($pipes[0],$kml_string);
>fclose($pipes[0]);
>
>$kmz_content = stream_get_contents($pipes[1]);
>
>fclose($pipes[1]);
>
>$return_value = proc_close($kmz_process);
>
>//  Only outputting data to ensure it is a properly formatted zip file
>//  Normally, a SOAP service will sent the data as a base64 encoded
> payload
>$output_file = fopen('ndfdViaPipe.kmz','w');
>fwrite($output_file,$kmz_content);
>fclose($output_file);
> }
>
> ?>
>
> --
> 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



Re: [PHP] Creating a File in Memory

2007-09-07 Thread Graham Cossey
Can't help with your main problem, however I find it easier to write
the likes of :

$kml_string = $kml_string . "";

as:

 $kml_string .= "";

;-)

On 9/7/07, John Schattel <[EMAIL PROTECTED]> wrote:
> Hello All,
>
> I am trying to zip data in a PHP program using the following code.  The
> resulting file (ndfdViaPipe.kmz) is zip'ed but the data in the archive
> lacks a file name.  So when a program like Google Earth tries to process
> the file, it fails.  When I bring ndfdViaPipe.kmz into WinZip, the file
> has no name but can otherwise be extracted just fine.  Once extracted,
> Google Earth can process the file.  Does anyone know how I might add the
> "file name" information to the ndfdViaPipe.kmz?  The reason I'm trying
> to use pipes is to avoid creating a file with the dynamically created
> data in $kml_string.  The plan is to send $kmz_content out in a SOAP
> service message with the payload as base64 encoded file.  If there is a
> better way to accomplish this I am certainly open to suggestions.
>
> In advance, thanks for any help you care to offer.
>
> John
>
> 
> $kml_string = "";
> $kml_string = $kml_string . " xmlns=\"http://earth.google.com/kml/2.1\";>";
> $kml_string = $kml_string . "";
> $kml_string = $kml_string . "   National Digital Forecast Database
> Data";
> $kml_string = $kml_string . "   1";
> $kml_string = $kml_string . "   name=\"NdfdData\">";
> $kml_string = $kml_string . " name=\"UOM\">";
> $kml_string = $kml_string . " name=\"ValidTime\">";
> $kml_string = $kml_string . " name=\"MaxTemp\">";
> $kml_string = $kml_string . "  ";
> $kml_string = $kml_string . "  ";
> $kml_string = $kml_string . "Maximum Temperature";
> $kml_string = $kml_string . "90F valid at
> 2007-06-26T00:00:00-04:00";
> $kml_string = $kml_string . "";
> $kml_string = $kml_string . "  -77.37,37.82";
> $kml_string = $kml_string . "";
> $kml_string = $kml_string . "F";
> $kml_string = $kml_string . "
> 2007-06-26T00:00:00-04:00";
> $kml_string = $kml_string . "95";
> $kml_string = $kml_string . "  ";
> $kml_string = $kml_string . "  ";
> $kml_string = $kml_string . "Maximum Temperature";
> $kml_string = $kml_string . "89F valid at
> 2007-06-26T00:00:00-04:00";
> $kml_string = $kml_string . "";
> $kml_string = $kml_string . "  -77.5,38.00";
> $kml_string = $kml_string . "";
> $kml_string = $kml_string . "F";
> $kml_string = $kml_string . "
> 2007-06-26T00:00:00-04:00";
> $kml_string = $kml_string . "89";
> $kml_string = $kml_string . "  ";
> $kml_string = $kml_string . "";
> $kml_string = $kml_string . "";
>
> $descriptorAssignments = array(
>0 => array("pipe", "r"),  // stdin is a pipe that the child will read
> from
>1 => array("pipe", "w"),  // stdout is a pipe that the child will
> write to
>2 => array("file", "/tmp/error-output.txt", "a") // stderr is a file
> to write to
> );
>
> $kmz_process = proc_open('zip',$descriptorAssignments,$pipes);
>
> if (is_resource($kmz_process))
> {
>fwrite($pipes[0],$kml_string);
>fclose($pipes[0]);
>
>$kmz_content = stream_get_contents($pipes[1]);
>
>fclose($pipes[1]);
>
>$return_value = proc_close($kmz_process);
>
>//  Only outputting data to ensure it is a properly formatted zip file
>//  Normally, a SOAP service will sent the data as a base64 encoded
> payload
>$output_file = fopen('ndfdViaPipe.kmz','w');
>fwrite($output_file,$kmz_content);
>fclose($output_file);
> }
>
> ?>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Graham

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



[PHP] html2png

2007-09-07 Thread timothy johnson
I was wondering if anyone knew of some php code that I could use to create
thumbnails of webpages.


[PHP] Creating a File in Memory

2007-09-07 Thread John Schattel

Hello All,

I am trying to zip data in a PHP program using the following code.  The 
resulting file (ndfdViaPipe.kmz) is zip'ed but the data in the archive 
lacks a file name.  So when a program like Google Earth tries to process 
the file, it fails.  When I bring ndfdViaPipe.kmz into WinZip, the file 
has no name but can otherwise be extracted just fine.  Once extracted, 
Google Earth can process the file.  Does anyone know how I might add the 
"file name" information to the ndfdViaPipe.kmz?  The reason I'm trying 
to use pipes is to avoid creating a file with the dynamically created 
data in $kml_string.  The plan is to send $kmz_content out in a SOAP 
service message with the payload as base64 encoded file.  If there is a 
better way to accomplish this I am certainly open to suggestions.


In advance, thanks for any help you care to offer.

John

";
$kml_string = $kml_string . "xmlns=\"http://earth.google.com/kml/2.1\";>";

$kml_string = $kml_string . "";
$kml_string = $kml_string . "   National Digital Forecast Database 
Data";

$kml_string = $kml_string . "   1";
$kml_string = $kml_string . "  name=\"NdfdData\">";
$kml_string = $kml_string . "name=\"UOM\">";
$kml_string = $kml_string . "name=\"ValidTime\">";
$kml_string = $kml_string . "name=\"MaxTemp\">";

$kml_string = $kml_string . "  ";
$kml_string = $kml_string . "  ";
$kml_string = $kml_string . "Maximum Temperature";
$kml_string = $kml_string . "90F valid at 
2007-06-26T00:00:00-04:00";

$kml_string = $kml_string . "";
$kml_string = $kml_string . "  -77.37,37.82";
$kml_string = $kml_string . "";
$kml_string = $kml_string . "F";
$kml_string = $kml_string . "
2007-06-26T00:00:00-04:00";

$kml_string = $kml_string . "95";
$kml_string = $kml_string . "  ";
$kml_string = $kml_string . "  ";
$kml_string = $kml_string . "Maximum Temperature";
$kml_string = $kml_string . "89F valid at 
2007-06-26T00:00:00-04:00";

$kml_string = $kml_string . "";
$kml_string = $kml_string . "  -77.5,38.00";
$kml_string = $kml_string . "";
$kml_string = $kml_string . "F";
$kml_string = $kml_string . "
2007-06-26T00:00:00-04:00";

$kml_string = $kml_string . "89";
$kml_string = $kml_string . "  ";
$kml_string = $kml_string . "";
$kml_string = $kml_string . "";

$descriptorAssignments = array(
  0 => array("pipe", "r"),  // stdin is a pipe that the child will read 
from
  1 => array("pipe", "w"),  // stdout is a pipe that the child will 
write to
  2 => array("file", "/tmp/error-output.txt", "a") // stderr is a file 
to write to

);

$kmz_process = proc_open('zip',$descriptorAssignments,$pipes);

if (is_resource($kmz_process))
{
  fwrite($pipes[0],$kml_string);
  fclose($pipes[0]);

  $kmz_content = stream_get_contents($pipes[1]);

  fclose($pipes[1]);

  $return_value = proc_close($kmz_process);

  //  Only outputting data to ensure it is a properly formatted zip file
  //  Normally, a SOAP service will sent the data as a base64 encoded 
payload

  $output_file = fopen('ndfdViaPipe.kmz','w');
  fwrite($output_file,$kmz_content);
  fclose($output_file);
}

?>

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



RE: [PHP] Opening a file

2007-09-07 Thread Sanjeev N


Here there may be 2 cases.
1st either file() is not returning any values, that is why array empty and
wrong datatype error, are you able to read the file.

2nd try to use implode function to consider each word as different value in
an array
$lines = implode('', file("fruits.txt"));

Warm Regards,
Sanjeev
http://www.sanchanworld.com/
http://webdirectory.sanchanworld.com - Submit your website URL
http://webhosting.sanchanworld.com - Choose your best web hosting plan

-Original Message-
From: Dan Shirah [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, September 05, 2007 7:55 PM
To: php-general
Subject: [PHP] Opening a file

Good Morning!

Opening this file is proving to be a pain. I have a folder that contains a
PHP page and a text file. I am trying to open the contents of the txt file
using file() but it keeps erroring out. Below is the code I'm using to try
and open it:



So, I'm setting my variable, opening my file as an array in $lines, then
checking to see if my variable is in the array, and if it is, assign a value
ot a new variable.  However, I am getting the following error:

PHP Warning: in_array()
[function.in-array]:
Wrong datatype for second argument

Any ideas?

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



Re: [PHP] looking for the right mcrypt ciphers

2007-09-07 Thread Samuel Vogel

I solved the problem using bin2hex()!

Regards,
Samy

Samuel Vogel schrieb:

Hey guys,

I'm wondering which mcrypt cipher will provide me with an encryted 
string, that can afterwards be encrypted again and is transverable 
without problems through an link in an e-mail.
I would like to encrypt some piece of information (up to 25 
characters) and send it to the user in an e-mail via a link like 
kilu.de?enc=... ! This doesn't work with |MCRYPT_XTEA or 
|MCRYPT_TWOFISH256, since they create pretty special ASCII characters, 
that are not interpreted right!


What cipher would you suggest? Or would you suggest a whole different 
method?


Regards,
Samy



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



[PHP] looking for the right mcrypt ciphers

2007-09-07 Thread Samuel Vogel

Hey guys,

I'm wondering which mcrypt cipher will provide me with an encryted 
string, that can afterwards be encrypted again and is transverable 
without problems through an link in an e-mail.
I would like to encrypt some piece of information (up to 25 characters) 
and send it to the user in an e-mail via a link like kilu.de?enc=... ! 
This doesn't work with |MCRYPT_XTEA or |MCRYPT_TWOFISH256, since they 
create pretty special ASCII characters, that are not interpreted right!


What cipher would you suggest? Or would you suggest a whole different 
method?


Regards,
Samy

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



RE: [PHP] Reg.Photo Upload Tool

2007-09-07 Thread Jay Blanchard
[snip]
Any opensource or PHP applicaiton is available for Photo upload tool?.
[/snip]

Easy to do yourself
http://us2.php.net/manual/en/features.file-upload.php

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



[PHP] Reg.Photo Upload Tool

2007-09-07 Thread Ramesh.b
Hello,

Any opensource or PHP applicaiton is available for Photo upload tool?.

Thanks
Ramesh 

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



Re: [PHP] php5: capital "I" letters in func/class method names do not work with turkish locale in php5

2007-09-07 Thread Roman

On Thu, 06 Sep 2007 15:57:57 +0300, Tijnema <[EMAIL PROTECTED]> wrote:


On 9/6/07, Roman Neumüller <[EMAIL PROTECTED]> wrote:

I'm a german web-designer living in Turkey.
Sometimes I use opensource software like gallery2 or WP to have  
customers

have some
nice web albums or blog. The turkish translation files of such  
opensource

software
usually use gettext and .po files for i18n and are always a bit behind  
the

translation
status of other european languages.

I decided to work a bit on some of those tr.po files on my local linux  
box

(opensuse 10.2 with apache 2.x mysql 5.x and php 5.2.0). But when I
started the
test phase in turkish I couldn't test because of strange errors.
I contacted the forum of gallery2 and after investigating the problem I
stumbled over an answer of bug #35050 at bugs.php.net:

  http://bugs.php.net/bug.php?id=35050

and its status: WONT FIX

Now that's really great. It means that turkish hosting providers cannot
use php5 at all!
And as of the news on php.net php4 will not be supported or developed  
any

further
after the end of 2007! Will Turks really have now to wait for a php6?
When will that come out?
That's seems to me to be a sort of discrimination of turkish language in
php5.
Is it technical so difficult to develop a patch for this bug?

Sincerely



Well, only 1 hour later than your email, there has been posted a patch
on the bug page that fixes it.

Tijnema




I had a look at the patch under http://www.topolis.lt/php/#35050 and saw it
did not work for my system (php5.2.0) I wrote to the author of the patch  
and

got this answer:


Patch is written for PHP 5.2.5-dev. It should work in 6.0-dev and PHP
5.2.1 or later version. Any version later than 2006-12-05.


But he also said:


If you need workaround, just set LC_CTYPE locale to C. It also deals with
programming mistakes in PHP scripts.setlocale(LC_ALL,'tr_TR.UTF-8');
setlocale(LC_CTYPE, 'C');


and that seems to work - at least in case of my gallery2 under php5.2.0.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Converting PHP code to C#?

2007-09-07 Thread mike
On 9/7/07, Symbian <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> I'm not sure if this is the right place to post this, I have some decryption
> routines that use mcrypt that I need to decrypt in .NET, does anyone know
> how why I cant get this to work?


I've done it in reverse - something encrypted in .NET and then decrypted in PHP

these were my notes...


To get .NET and PHP to play friendly with two-way encryption, you need
to make sure some things happen in both:
In .NET:
1) You need to set the Padding to PaddingMode.Zeros, i.e.:
 Rijndael alg = Rijndael.Create();
 alg.Padding = PaddingMode.Zeros;
2) You also need to make sure to use System.Text.Encoding.ASCII or
System.Text.Encoding.UTF8; System.Text.Encoding.Unicode will *not*
work (perhaps in PHP6 this might be possible.)
3) Need to make sure the IV and key are the same as defined in PHP.

In PHP:
1) You need the mcrypt extension installed.
2) Need to make sure the IV and key are the same as defined in .NET.
3) You can issue this single line of code to decrypt:
 mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, $encrypted_text, "cbc", $iv);

Notes:
1) By default .NET uses a 128-bit cipher in CBC mode when you
initialize Rijndael. That might not be common knowledge.
2) If you're sending this data via a URL or cookie or something else,
be sure to base64 encode on the .NET side, and base64_decode() the
data on the PHP side.


below i would say that:

a) you need to make sure the IV is the same. right now it looks like
you are creating a random one in PHP and a different one in .NET. that
would be my first thing to check.

b) not sure if ECB vs. CBC is any different; i know CBC will work though.

hope that helps some. it took some debugging for us, and it didn't
help that our .NET guy created the IV using low and high ascii
character codes that I had to reproduce in PHP for the IV and the
key... I would get different sizes as well, but once the stars aligned
it worked perfectly. Be sure that any base64 encoding/decoding or
anything like that is done in the proper order (typically start out
with no encoding, get it to work, then add on encoding and decoding on
both ends properly, etc.)

good luck :)


>  PHP
> $mcryptSize = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_ECB);
> $mcryptIV = mcrypt_create_iv($mcryptSize, MCRYPT_RAND);
> $mcryptData = pack("H*", $data);
> $decryptData =
> mcrypt_decrypt(MCRYPT_RIJNDAEL_128,$key,$mcryptData,MCRYPT_MODE_ECB,$mcryptIV);
> -
>
> $decryptData should be 2048 in size. Here's my C# converted bits:
> - C#
>
> RijndaelManaged rj = new RijndaelManaged();
> rj.Mode = CipherMode.ECB;
> rj.Key = ASCIIEncoding.ASCII.GetBytes(KEY);
> rj.KeySize = 128;
> rj.GenerateIV();
> rj.Padding = PaddingMode.Zeros;
> ICryptoTransform trans = rj.CreateDecryptor(rj.Key, rj.IV);
> byte[] Buffer = Convert.FromBase64String(DATA);
> string dataD =
> ASCIIEncoding.ASCII.GetString(trans.TransformFinalBlock(Buffer,0,
> Buffer.Length));
> -
>
> However the length is 3017

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



[PHP] Converting PHP code to C#?

2007-09-07 Thread Symbian

Hi,

I'm not sure if this is the right place to post this, I have some decryption
routines that use mcrypt that I need to decrypt in .NET, does anyone know
how why I cant get this to work?

 PHP
$mcryptSize = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_ECB);
$mcryptIV = mcrypt_create_iv($mcryptSize, MCRYPT_RAND);
$mcryptData = pack("H*", $data);
$decryptData = 
mcrypt_decrypt(MCRYPT_RIJNDAEL_128,$key,$mcryptData,MCRYPT_MODE_ECB,$mcryptIV);
-

$decryptData should be 2048 in size. Here's my C# converted bits:
- C#

RijndaelManaged rj = new RijndaelManaged();
rj.Mode = CipherMode.ECB;
rj.Key = ASCIIEncoding.ASCII.GetBytes(KEY);
rj.KeySize = 128;
rj.GenerateIV();
rj.Padding = PaddingMode.Zeros;
ICryptoTransform trans = rj.CreateDecryptor(rj.Key, rj.IV);
byte[] Buffer = Convert.FromBase64String(DATA);
string dataD = 
ASCIIEncoding.ASCII.GetString(trans.TransformFinalBlock(Buffer,0, 
Buffer.Length));
-

However the length is 3017

Any ideas?

Thanks,
Sym 

-- 
View this message in context: 
http://www.nabble.com/Converting-PHP-code-to-C---tf4397727.html#a12541304
Sent from the PHP - General mailing list archive at Nabble.com.

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



[PHP] Is it possible to create a php.so

2007-09-07 Thread Khai
I have several background processes written in PHP.  In our design, we 
have the parent process which check if there is work to process, and if 
so launch a child process via exec() to do actual work.  By design, we 
want the child process to do just what it was told to do and gracefully 
terminate.  We don't want the child process to live longer than 10 
minutes.


My coworker looked at ZendPlatform, and APC, but he found that these 
does not do anything for PHP program that are run from command line.  I 
know at this point ZendPlatform does not support command line.  Is this 
true with APC?  Is there any other caching implementation that we can use?


Is it possible to compile PHP so that the core of it is in a dynamically 
 linked library (I am running in a Linux/Unix environment)?


Can I turn my PHP code into a dynamic link library ?

Thanks
Khai

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