OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
php-general Digest 1 Feb 2005 10:08:43 -0000 Issue 3261

php-general-digest-helplists.php.net
Date: Tue Feb 01 2005 - 04:08:43 CST


php-general Digest 1 Feb 2005 10:08:43 -0000 Issue 3261

Topics (messages 207806 through 207825):

Re: PHP Security Consortium
        207806 by: Chris W. Parker

Re: file upload error
        207807 by: Marek Kilimajer

Uploaded File by Form is mysteriously away.
        207808 by: Mirco Blitz
        207809 by: Marek Kilimajer
        207810 by: Mirco Blitz

simple question
        207811 by: Pagongski
        207812 by: Robby Russell
        207813 by: Jason Wong
        207814 by: Pagongski
        207818 by: John Holmes
        207819 by: Robert Cummings

Displaying a html line as html
        207815 by: Todd Cary
        207816 by: Justin French
        207817 by: Jeffery Fernandez

best flow for this project
        207820 by: Dustin Krysak

Re: SSH system command problem
        207821 by: Curt Zirzow

Re: Autoflush
        207822 by: Wudi

Re: upload file size limit
        207823 by: badlya badlu

inserting utf8 from PHP to MySQL makes text unreadable
        207824 by: Dave
        207825 by: Marek Kilimajer

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscribelists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscribelists.php.net

To post to the list, e-mail:
        php-generallists.php.net

----------------------------------------------------------------------

attached mail follows:


Chris Shiflett <mailto:shiflettphp.net>
    on Sunday, January 30, 2005 10:19 PM said:

> The PHP Security Consortium has officially launched. The following is
> the press release:

Oooh cool! This looks to be a great resource. Keep up the good work
Chris.

Another,
Chris.

attached mail follows:


Tom wrote:
> Hi
>
> I have a very simple file upload form and script to handle it (copied
> verbatim from the php manual, except for the file target location and
> the script name).
> However, it always fails, with an error code in the _FILE array or 6.
> Does anyone know what this error is or what I am likely to have set
> wrong? All that I can find in the docs are errors from 0 to 4 :-(

It's there:
http://sk.php.net/manual/en/features.file-upload.errors.php

UPLOAD_ERR_NO_TMP_DIR

     Value: 6; Missing a temporary folder. Introduced in PHP 4.3.10 and
PHP 5.0.3.

     Note: These became PHP constants in PHP 4.3.0.

Set the correct upload_tmp_dir in php.ini and restart webserver

attached mail follows:


Hi,

I'm trying to upload a pic file by form (Using QuickForm, but this here also
happens in manually generates Forms).

Everything seems to work fine.

The $_FILES["formfile"] shows everything about the file what is needed to
know.

For example: Array ( [formfile] => Array ( [name] => lindworm.jpg [type] =>
image/pjpeg [tmp_name] => /srv/www/htdocs/tmp/phpTLREuE [error] => 0 [size]
=> 15101 ) )

 

With this information I now try to make
move_uploaded_file($_FILE["formfile"],
"/srv/www/htdocs/img/".$_FILE["formfile"]["name"]) .

This also seem to work, because it gives no error back.

 

Both directories are writeable by php. I also use this dirs on other Sites
to generate file inside.

 

But and that's the problem. The File does not appear in TMP-DIR and not at
Destination dir. It is just nowhere.

 

I am Using php-4.3.4 and Apache 2 on SuSE9.1.

Fileupload is active in php.ini and phpinfo(); tells me the same.

 

Has anybody an Idea please what also could be wrong.

 

Greetings

Mirco Blitz

attached mail follows:


Mirco Blitz wrote:
> Hi,
>
> I'm trying to upload a pic file by form (Using QuickForm, but this here also
> happens in manually generates Forms).
>
> Everything seems to work fine.
>
> The $_FILES["formfile"] shows everything about the file what is needed to
> know.
>
> For example: Array ( [formfile] => Array ( [name] => lindworm.jpg [type] =>
> image/pjpeg [tmp_name] => /srv/www/htdocs/tmp/phpTLREuE [error] => 0 [size]
> => 15101 ) )
>
>
>
> With this information I now try to make
> move_uploaded_file($_FILE["formfile"],
> "/srv/www/htdocs/img/".$_FILE["formfile"]["name"]) .

move_uploaded_file($_FILE["formfile"]['tmp_name'], ...

>
>

attached mail follows:


Oh sorry, that move_uploaded_file is surely used with
FILE["formfile"]['tmp_name']
That was an error in Mail Typing.

Problem still exists.

Mirco Blitz

-----Ursprüngliche Nachricht-----
Von: Marek Kilimajer [mailto:listskilimajer.net]
Gesendet: Dienstag, 1. Februar 2005 00:12
An: Mirco Blitz
Cc: php-generallists.php.net
Betreff: Re: [PHP] Uploaded File by Form is mysteriously away.

Mirco Blitz wrote:
> Hi,
>
> I'm trying to upload a pic file by form (Using QuickForm, but this here
also
> happens in manually generates Forms).
>
> Everything seems to work fine.
>
> The $_FILES["formfile"] shows everything about the file what is needed to
> know.
>
> For example: Array ( [formfile] => Array ( [name] => lindworm.jpg [type]
=>
> image/pjpeg [tmp_name] => /srv/www/htdocs/tmp/phpTLREuE [error] => 0
[size]
> => 15101 ) )
>
>
>
> With this information I now try to make
> move_uploaded_file($_FILE["formfile"],
> "/srv/www/htdocs/img/".$_FILE["formfile"]["name"]) .

move_uploaded_file($_FILE["formfile"]['tmp_name'], ..

>
>

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

attached mail follows:


I have this function:

function supscript($texto)
{
   print("<sup>".$texto."</sup>");
}

But when i do:

        print "2".supscript("3");

        I get the "3" before the "2", how is that posible?

And:

        print(supscript("3")."2");

        makes the 2 appear before the 3.
        I am confused!

        Thanks

attached mail follows:


On Tue, 2005-02-01 at 01:41 +0000, Pagongski wrote:
> I have this function:
>
> function supscript($texto)
> {
> print("<sup>".$texto."</sup>");
> }
>
> But when i do:
>
> print "2".supscript("3");
>
> I get the "3" before the "2", how is that posible?
>
> And:
>
> print(supscript("3")."2");
>
> makes the 2 appear before the 3.
> I am confused!
>
> Thanks
>

probably because it calls the function before it calls the main print.

try return instead of print.

example:

function supScript($txt)
{
  return "<sup>{$txt}</sup>";
}

print "2" . supScript("3");

You shouldn't print a function that prints.. ;-)

-Robby

--
/***************************************
* Robby Russell | Owner.Developer.Geek
* PLANET ARGON | www.planetargon.com
* Portland, OR | robbyplanetargon.com
* 503.351.4730 | blog.planetargon.com
* PHP/PostgreSQL Hosting & Development
* --- Now hosting PostgreSQL 8.0! ---
****************************************/

attached mail follows:


On Tuesday 01 February 2005 09:41, Pagongski wrote:

Please use a *descriptive* subject.

> I have this function:
>
> function supscript($texto)
> {
> print("<sup>".$texto."</sup>");
> }
>
> But when i do:
>
> print "2".supscript("3");
>
> I get the "3" before the "2", how is that posible?
>
> And:
>
> print(supscript("3")."2");
>
> makes the 2 appear before the 3.
> I am confused!

You're trying to use the function supscript() as though it returned a value,
it doesn't, it just prints something out directly.

--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
New Year Resolution: Ignore top posted posts

attached mail follows:


        Thank you so much, it was really stupid of me, basic mistake. I solved it differently, although your solution is miles away better than mine.
        Heres what i did:

function supscript($texto)
{
        global $supa;
        $supa = "<sup>".$texto."</sup>";
}
supscript("3");
print ("2".$supa);

        Complicated little thing, eh?
        Thanks :-)

        Pag

attached mail follows:


Pagongski wrote:
> I have this function:
>
> function supscript($texto)
> {
> print("<sup>".$texto."</sup>");
> }
>
> But when i do:
>
> print "2".supscript("3");
>
> I get the "3" before the "2", how is that posible?

Your function should return the value, not print it. The way you have it
now, the function must be ran before the original string can be printed.
That's why you see the 3 before the 2.

function supscript($texto)
{ return "<sup>{$texto}</sup>"; }

--

---John Holmes...

Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com

attached mail follows:


On Mon, 2005-01-31 at 20:41, Pagongski wrote:
> I have this function:
>
> function supscript($texto)
> {
> print("<sup>".$texto."</sup>");
> }
>
> But when i do:
>
> print "2".supscript("3");
>
> I get the "3" before the "2", how is that posible?
>
> And:
>
> print(supscript("3")."2");
>
> makes the 2 appear before the 3.
> I am confused!

Your second example does not print the 2 before the 3. And the reason
your first example prints the 3 before the 2 is because the the print
inside the function prints first because the print that contains the
call to it can't print until it receives the return value form the
function. What you probably want is the following:

function supscript($texto)
{
   return "<sup>".$texto."</sup>";
}

print "2".supscript("3");

--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'

attached mail follows:


I have the following:

$p = <a href="http://209.204.172.137/casesearch/php/home.php">Home</a>

However, when I have

print($p); or
echo $p;

the result page does not display as a link; just as the text above.

What have I missed?

Todd

attached mail follows:


On 01/02/2005, at 1:05 PM, Todd Cary wrote:

> I have the following:
>
> $p = <a href="http://209.204.172.137/casesearch/php/home.php">Home</a>

try

$p = '<a
href="http://209.204.172.137/casesearch/php/home.php">Home</a>';
echo $p;

---
Justin French, Indent.com.au
justin.frenchindent.com.au
Web Application Development & Graphic Design

attached mail follows:


Todd Cary wrote:

> I have the following:
>
> $p = <a href="http://209.204.172.137/casesearch/php/home.php">Home</a>
>
> However, when I have
>
> print($p); or
> echo $p;
>
> the result page does not display as a link; just as the text above.
>
> What have I missed?
>
>
> Todd
>
try:
<?php
$p = '<a href="http://209.204.172.137/casesearch/php/home.php">Home</a>';
echo $p;
?>

cheers,
Jeffery
http://melbourne.ug.php.net

attached mail follows:


ok, i have a project where:

-a user adds their email address, name, etc to a database.
-a responder sends an email to them to confirm their email address
(within 72 hrs).
-upon confirmation of their email address, a script will generate a
store coupon with a random coupon id # in the browser (which they can
print at that time).

Now I guess my question relates more to the email confirmation. How
would you go about this? Store it in a database? Every-time the script
is run it also checks to see which requests are more than 72 hrs old
and removes their request from the database? And those that are
confirmed, a flag is added to the database so they are not removed?

Just looking more for ideas on the script flow to accomplish this.

Thanks!

Dustin

attached mail follows:


* Thus wrote Linn Fagerberg:
> Hi,
>
> I am trying to use a php system command to run a script and access files
> from another server using SSH. This does not seem to work in PHP or else I
> am doing it wrong because I keep on getting the system return value=255 when
> I do
>
>
>
> system("/usr/bin/ssh 10.0.0.1", $value)
>
>
>
> I tried to do a "ssh -help" command to see if the reason it did not work was
> that there was a problem with the server, but that did not give me a correct
> return value either, so I am starting to suspect that ssh is different from
> other system commands in php?

If you just do something like:

  ssh hostname

Then ssh will try and establish a terminal connection. If you're
trying to do a command of some sort it will be:

  ssh hostname command

Then of course you'll need to somehow authenticate.. you can google
'man ssh' to find out how to use ssh if you don't have shell access
to the machine.

>
> Is it possible to run ssh using php system command or do I have to try
> something else? I found a new php library called ssh2 but I don't know if
> that could be the solution to my problem? Have anyone used it?

Yes, there is a ssh2 library available for php, it is currently in
beta release, but from my experience it is quite stable to use.

PECL Extension:
http://pecl.php.net/ssh2

Documentation:
http://php.net/ssh2

HTH,

Curt
--
Quoth the Raven, "Nevermore."

attached mail follows:


Sorry, I still don't know how to attain it.
Could you give a sample?

PS: See http://wudicgi.spymac.net/pt/pt_autoflush.gif

attached mail follows:


thanks bobert. I have done it. thanks...

--- Robert Sossomon <LoneWolfnc.rr.com> wrote:

> Look in /etc/httpd/conf.d/php.conf
>
> For a buddy with a file upload need I set it to
> this:
>
> <Files *.php>
> SetOutputFilter PHP
> SetInputFilter PHP
> LimitRequestBody 760217600
> </Files>
>
>
> You will need to set your upload limit higher in
> this file for it to work correctly.
>
> Robert
> --
> Robert Sossomon, Business and Technology Application
> Technician
> 4-H Youth Development Department
> 200 Ricks Hall, Campus Box 7606
> N.C. State University
> Raleigh NC 27695-7606
> Phone: 919/515-8474
> Fax: 919/515-7812
> robert_sossomonncsu.edu
>
>

                
__________________________________
Do you Yahoo!?
Yahoo! Mail - Find what you need with new enhanced search.
http://info.mail.yahoo.com/mail_250

attached mail follows:


PHP General,

    The Situation:
    I am creating a form for users to enter text into a MySQL 3.23
database. The text is often in Japanese, encoded in utf-8 format.

    The Problem:
    When the utf-8 encoded text is inserted into the database, it
becomes random ASCII gibberish.

    What I've Tried So Far:
    I've noticed that it is possible to save utf-8 encoded text in the
database. When I insert Japanese text into the database using
phpMyAdmin, it stores okay, and I can access the text via PHP for
placement on web pages. So my speculation is that there is something
wrong with my script.
    My search on the web for information has turned up indication that
it should be possible to simply store utf-8 text without the need for
modifications. Some places suggest that it might be best to store the
Japanese text as binary. But since I can enter utf-8 text into fields
and store them as text successfully in phpMyAdmin, I am sure there must
be a way for getting around binary storage. I'd like to avoid binary
storage if possible, for a variety of reasons.

    The Question:
    How can I preserve the text so that it does not become garbled when
written to the database?

    For Reference:
    Here is the form and the PHP script that it accesses. $showData is
obtained by querying the database and seeing what is already stored there.

<form enctype="multipart/form-data" action="" method="POST">
<p>English (256 characters)</p>
<p><textarea name="introE" rows="5" cols="50"><?php echo
$showData['introE'];?></textarea></p>
<p>(Japanese)(256 Characters)</p>
<p><textarea name="introJ" rows="5" cols="50"><?php echo
$showData['introJ'];?></textarea></p>
<p><input type="submit" name="submit" value="submit" /></p>
<?php
if (isset ($HTTP_POST_VARS['introE']) || isset ($HTTP_POST_VARS['introJ']))
{
$updateQuery = "UPDATE events SET introE='" . $HTTP_POST_VARS['introE']
. "', introJ='" . $HTTP_POST_VARS['introJ'] . "' WHERE eventid = " . $show;
$updateResult = mysql_query($updateQuery);
}
?>
</form>

    Any help much appreciated.

--
Dave Gutteridge
davetokyocomedy.com
Tokyo Comedy Store
http://www.tokyocomedy.com/english/

attached mail follows:


Dave wrote:
> PHP General,
>
> The Situation:
> I am creating a form for users to enter text into a MySQL 3.23
> database. The text is often in Japanese, encoded in utf-8 format.
>
> The Problem:
> When the utf-8 encoded text is inserted into the database, it becomes
> random ASCII gibberish.
>
> What I've Tried So Far:
> I've noticed that it is possible to save utf-8 encoded text in the
> database. When I insert Japanese text into the database using
> phpMyAdmin, it stores okay, and I can access the text via PHP for
> placement on web pages. So my speculation is that there is something
> wrong with my script.
> My search on the web for information has turned up indication that it
> should be possible to simply store utf-8 text without the need for
> modifications. Some places suggest that it might be best to store the
> Japanese text as binary. But since I can enter utf-8 text into fields
> and store them as text successfully in phpMyAdmin, I am sure there must
> be a way for getting around binary storage. I'd like to avoid binary
> storage if possible, for a variety of reasons.

The difference between text and binary in mysql is that text column type
  takes into account character set for stuff like case insensitive
comparition and the likes. Character set is set per server basis in
mysql < 4.1, so if your mysql is set to use iso-8859-1, it's better to
store utf-8 in binary to get rid of the transformations.

>
> The Question:
> How can I preserve the text so that it does not become garbled when
> written to the database?
>
> For Reference:
> Here is the form and the PHP script that it accesses. $showData is
> obtained by querying the database and seeing what is already stored there.

The main part is missing here - <head> section of your page. It must
contain

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

else it will default to iso-8859-1.

>
> <form enctype="multipart/form-data" action="" method="POST">
> <p>English (256 characters)</p>
> <p><textarea name="introE" rows="5" cols="50"><?php echo
> $showData['introE'];?></textarea></p>
> <p>(Japanese)(256 Characters)</p>
> <p><textarea name="introJ" rows="5" cols="50"><?php echo
> $showData['introJ'];?></textarea></p>

Use htmlspecialchars() to display $showData['introJ']

> <p><input type="submit" name="submit" value="submit" /></p>
> <?php
> if (isset ($HTTP_POST_VARS['introE']) || isset ($HTTP_POST_VARS['introJ']))
> {
> $updateQuery = "UPDATE events SET introE='" . $HTTP_POST_VARS['introE']
> . "', introJ='" . $HTTP_POST_VARS['introJ'] . "' WHERE eventid = " . $show;
> $updateResult = mysql_query($updateQuery);
> }
> ?>
> </form>
>
> Any help much appreciated.
>