php-general Digest 8 Nov 2005 11:26:58 -0000 Issue 3782

Topics (messages 225252 through 225270):

Re: FileExists?
        225252 by: Jasper Bryant-Greene
        225253 by: Chris Shiflett
        225254 by: James Benson
        225256 by: M
        225265 by: M

Using the echo tag...
        225255 by: Paul Williams
        225260 by: Pablo Gosse
        225264 by: Curt Zirzow
        225267 by: Unknown Unknown
        225268 by: Curt Zirzow

Re: form question??
        225257 by: Vizion

Strange pg_escape_string behavior
        225258 by: -k.
        225266 by: Curt Zirzow

Re: Creating PDF from a Image
        225259 by: Jens Schulze

Security Issues - Where to look?
        225261 by: Richard
        225262 by: Pablo Gosse
        225263 by: Richard Davey

PHP 5 XML/XSL problem
        225269 by: Daniel Lowes

Re: Catch the   WMV first frame picture  in PHP script?
        225270 by: M

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [email protected]


----------------------------------------------------------------------
--- Begin Message ---
On Mon, 2005-11-07 at 20:45 +0100, Gustav Wiberg wrote:
> Hi there!
> 
> File_exists doesn't seem to work with URLs that point to another domain. 
> What to use?
> 
> $x = fopen(http://www.stammis.com/getstart.php);
> if file_exists($x) ....

You are trying to check if a file pointer exists. You want to check if
the file exists. Try:

if( file_exists( "http://www.stammis.com/getstart.php"; ) ) ....

-- 
Jasper Bryant-Greene
General Manager
Album Limited

e: [EMAIL PROTECTED]
w: http://www.album.co.nz/
b: http://jbg.name/
p: 0800 4 ALBUM (0800 425 286) or +64 21 232 3303
a: PO Box 579, Christchurch 8015, New Zealand

--- End Message ---
--- Begin Message ---
Gustav Wiberg wrote:
$x = fopen(http://www.stammis.com/getstart.php);
if file_exists($x)

That wouldn't work on a normal file either. You should always try to reduce your problem to the simplest case. :-)

http://php.net/file_exists

The argument is a filename.

Hope that helps.

Chris

--
Chris Shiflett
Brain Bulb, The PHP Consultancy
http://brainbulb.com/

--- End Message ---
--- Begin Message ---
Read the manual, it clearly states the following:-


Tip: As of PHP 5.0.0 this function can also be used with some URL wrappers. Refer to Appendix M for a listing of which wrappers support stat() family of functionality.





Gustav Wiberg wrote:
Hi there!

File_exists doesn't seem to work with URLs that point to another domain. What to use?

$x = fopen(http://www.stammis.com/getstart.php);
if file_exists($x) ....
....
????

/G
http://www.varupiraten.se/

--- End Message ---
--- Begin Message ---
Gustav Wiberg wrote:
Hi there!

File_exists doesn't seem to work with URLs that point to another domain. What to use?

$x = fopen(http://www.stammis.com/getstart.php);
if file_exists($x) ....
....
????

file_exists() takes filename as parameter, not file pointer.

besides, spare the one http request and use @fopen() (@ will suppress eventual warning), it will speed up your script.
--- End Message ---
--- Begin Message ---
Gustav Wiberg wrote:

----- Original Message ----- From: "M" <[EMAIL PROTECTED]>
To: "Gustav Wiberg" <[EMAIL PROTECTED]>
Sent: Monday, November 07, 2005 11:12 PM
Subject: Re: [PHP] FileExists?


Gustav Wiberg wrote:

Hi there!

File_exists doesn't seem to work with URLs that point to another domain. What to use?

$x = fopen(http://www.stammis.com/getstart.php);
if file_exists($x) ....
....
????



file_exists() takes filename as parameter, not file pointer.

besides, spare the one http request and use @fopen() (@ will suppress eventual warning), it will speed up your script.


I tested to use @fopen instead of fopen and it took 1 second longer...


I meant using:

if(($x = @fopen('http://www.stammis.com/getstart.php')) !== false) {

}

instead of:

if(file_exists('http://www.stammis.com/getstart.php')) {
    $x = fopen('http://www.stammis.com/getstart.php');

}

And you need to check the speed more than once.

--- End Message ---
--- Begin Message ---
I'm relatively new at coding PHP but I was hoping someone can help me with
this.

 

I'm trying to write the following code into my program but each time it
runs, I get an error message. Can anyone help?

 

print <<<< EOF

 

<!-INSERT HTML HEADER HERE -->

$_SERVER['PHP_SELF']

 

EOF;

 

Say that was a part of a HTML Form action tag, everytime I try to run it, I
get an error message am I doing something wrong or do I have to break out of
the here document to use this syntax?


--- End Message ---
--- Begin Message ---
[snip]
I'm relatively new at coding PHP but I was hoping someone can help me
with
this.

I'm trying to write the following code into my program but each time it
runs, I get an error message. Can anyone help?

print <<<< EOF
<!-INSERT HTML HEADER HERE -->
$_SERVER['PHP_SELF']
EOF;

Say that was a part of a HTML Form action tag, everytime I try to run
it, I
get an error message am I doing something wrong or do I have to break
out of
the here document to use this syntax?
[/snip]

What's the error message you're getting?  That will be most helpful in
trying to diagnose the problem.

Likely, though, is the fact that you're trying to output
$_SERVER['PHP_SELF'] within your heredoc syntax, without wrapping it in
curly braces.

It should be:

{$_SERVER['PHP_SELF']}

See
http://www.php.net/manual/en/language.types.string.php#language.types.st
ring.syntax.heredoc for more info.

Cheers,

Pablo

--- End Message ---
--- Begin Message ---
* Paul Williams <[EMAIL PROTECTED]> [2005-11-07 12:31:17 -0500]:

> I'm trying to write the following code into my program but each time it
> runs, I get an error message. Can anyone help?
> 
>  
> 
> print <<<< EOF
> 
>  
> 
> <!-INSERT HTML HEADER HERE -->
> 
> $_SERVER['PHP_SELF']
> 
>  
> 
> EOF;

You might want to read up on the heredoc syntax:
  http://php.net/heredoc


Curt
-- 

--- End Message ---
--- Begin Message ---
you only need 3 <<<

On 11/7/05, Curt Zirzow <[EMAIL PROTECTED]> wrote:
>
> * Paul Williams <[EMAIL PROTECTED]> [2005-11-07 12:31:17 -0500]:
>
> > I'm trying to write the following code into my program but each time it
> > runs, I get an error message. Can anyone help?
> >
> >
> >
> > print <<<< EOF
> >
> >
> >
> > <!-INSERT HTML HEADER HERE -->
> >
> > $_SERVER['PHP_SELF']
> >
> >
> >
> > EOF;
>
> You might want to read up on the heredoc syntax:
> http://php.net/heredoc
>
>
> Curt
> --
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
On Mon, Nov 07, 2005 at 09:40:23PM -0500, Unknown Unknown wrote:
> you only need 3 <<<

Indeed, as well as Pablo's guess of escaping an array within a
heredoc, and i would guess as well that that space between his '<<<
EOF' is invalid as well.

Btw, you do realize your name is 'Unknown Unknown'?


Curt
-- 

--- End Message ---
--- Begin Message ---
On Monday 07 November 2005 10:24,  the author bruce contributed to the 
dialogue on-
 [PHP] form question??: 

>hi...
>
>a while ago, i saw an app that allowed the user to create a form, based on
>various fields, and to setup/create the database schema to create the form.
>the app provided the user with predefined fields, as well as allowed the
>user to define their own fields in order to create the form.
>
>unfortunately, i can't seem to find this app, or any other app that would
>allow me to do this. can anybody point me towards an app that could/would do
>this?
>
If you want something comprehensive and you happen to use Dreamweaver you can 
do what you need and you might also  take a look at some of the extensions 
such as MX Kollection http://www.interaktonline.com or Web Assist 
www.webassist.com  or many other extensions which would five you all you are 
likely to need.

david

-- 
40 yrs navigating and computing in blue waters.
English Owner & Captain of British Registered 60' bluewater Ketch S/V Taurus.
 Currently in San Diego, CA. Sailing bound for Europe via Panama Canal after 
completing engineroom refit.

--- End Message ---
--- Begin Message ---
While using pg_escape_string to clean data being placed in a query sent to me 
by the user i get
the following error after submitting the query with pg_execute:

pg_exec(): Query failed: ERROR: invalid regular expression: invalid escape \ 
sequence . 

It seems to happen when using just a "\" or text ending with a "\" but not if a 
"\" is in the
middle of a string of text.

Why doesn't pg_escape_string catch this?

To restate it maybe a little more clearly, the error occurs when i do something 
like:
(Pretend $_POST['user_item'] has the value "car\" in it )
<?PHP
$user_item = pg_escape_string($_POST['user_item']);

$dbconn = pg_connect('some connection string that works');
$query  = "SELECT * FROM some_table WHERE some_col = '$user_item' ";
$result = pg_execute($dbconn,$query);

?>

I'm running PHP Version 4.3.4, and Apache 1.3.29.



-k.


                
__________________________________ 
Yahoo! FareChase: Search multiple travel sites in one click.
http://farechase.yahoo.com

--- End Message ---
--- Begin Message ---
* -k. wrote:
> ... 
> pg_exec(): Query failed: ERROR: invalid regular expression: invalid escape \ 
> sequence . 
> 
> It seems to happen when using just a "\" or text ending with a "\" but not if 
> a "\" is in the
> middle of a string of text.

I would guess you have magic_quote_gpc on, you can check this:

  var_dump(get_magic_quotes_gpc());

> ...
> $user_item = pg_escape_string($_POST['user_item']);
> 
> $dbconn = pg_connect('some connection string that works');
> $query  = "SELECT * FROM some_table WHERE some_col = '$user_item' ";

Try an:
  echo htmlentities($query); 

And you'll see the problem with the query.


Curt.
-- 

--- End Message ---
--- Begin Message ---
Am Monday, November 7, 2005, 4:20:25 PM beglückte uns 
Manoj ([EMAIL PROTECTED]) mit folgendem Kommentar:

> PNG doen't support CMYK color scheme that's why I want to convert it
> in JPG first and then I want to create pdf file from that PJG file. I
> created pdf file from PJG using fpdf but no idea that how to I convert
> PNG to jpg file (not using any third part tool only uing php).

If you don't want to use the formidable imagemagick package (where the
conversion would be a one line bash command), you are out of look, I
think, because the gdlib often packaged with php doesn't support cmyk
jpeg files. External tool or nothing... ;-)

> Secondly,  My motive is to create Press optimized pdf file rather than
> simple pdf file.

As I said before, from my typesetting experience, PNG file format and
press optimized PDF is something that don't fit together, a cmyk image
isn't something that make a PDF press optimized, you have also look at
the resolution of the images. If I create a file with a layout tool like
Adobe InDesign with 72 dpi images and export it as press optimized PDF,
even when the file is labeled "press optimized", it's a pile of low
quality crap from the prepress view of things. Maybe you should review
your workflow.

Jens

-- 
This mail was scanned by AntiVir Milter.
This product is licensed for non-commercial use.
See www.antivir.de for details.

--- End Message ---
--- Begin Message ---
I've heard that php is not particularly secure, making it problematic if you
intend to create a web site with commerce, etc. Is there a particular news
group that addresses security issues? I'm looking for some guidlines on
ensuring that my site is secure from malicious hackers.

Thanks,
Richard

--- End Message ---
--- Begin Message ---
[snip]
I've heard that php is not particularly secure, making it problematic if
you
intend to create a web site with commerce, etc. Is there a particular
news
group that addresses security issues? I'm looking for some guidlines on
ensuring that my site is secure from malicious hackers.
[/snip]

It's not so much that PHP is not particularly secure, but rather that
some of the people who use it don't know how to make it work in a secure
manner.

Configured and coded properly a PHP application can be very, very
secure.  

However, without careful configuration and good coding it's also
possible to create very, very insecure applications using PHP.  Or .NET.
Or Java.  Or Cold Fusion.  Or JSP.

It's not the technology that's insecure, but the method by which it's
implemented. 

Why not check out these links:

http://www.google.ca/search?q=php+security

http://www.devshed.com/c/a/PHP/PHP-Security-Mistakes/

http://phpsec.org/

Cheers,

Pablo

--- End Message ---
--- Begin Message ---
Hi Richard,

Monday, November 7, 2005, 9:50:59 PM, you wrote:

> I've heard that php is not particularly secure, making it
> problematic if you intend to create a web site with commerce, etc.
> Is there a particular news group that addresses security issues? I'm
> looking for some guidlines on ensuring that my site is secure from
> malicious hackers.

The security of the application will be ultimately down to two
factors: you, and your hosting environment.

Server security is beyond the scope of this mailing list, and is a
multi-faceted and complex area. Shoring up your OS, Apache and the
likes can take years of skill. Or of course, your sys admin / web host
does this all for you. Even so, it's an area not to be ignored. You
can write the most secure application in the world, but if you've gone
and chmod 777'd your directories on a shared box, you're anyones
target.

The security of your application is down to you however. There is a
PHP security mailing list, but it's more for announcements than
discussion. As for guidelines there are many free on-line resources,
and you'd do worse than to start here: http://phpsec.org/library/

The majority of those documents are aimed at experienced PHP
developers however. And the majority of blatant security holes come
from the inexperienced who weren't aware of what they were doing wrong
in the first place. There are several books available on the subject
now, any (or all) of them would give you the grounding you need to
know BEFORE you start coding:

Pro PHP Security by Snyder & Southwell (Apress)
php architect's Guide to PHP Security by Ilia Alshanetsky (Nanobooks)
Essential PHP Security by Chris Shiflett (O'Reilly)

Also some on-line talks: http://brainbulb.com/talks

php architect magazine has a security column each month as well
(www.phparch.com)

There's a lot of reading material out there. Just make sure you read
it _before_ you start building, it'll save you days, if not weeks, of
code changes.

Cheers,

Rich
-- 
Zend Certified Engineer
PHP Development Services
http://www.corephp.co.uk

--- End Message ---
--- Begin Message ---
Hi

I've been using PHP 4 for the last year to do XSL transformations in one of my applications. It worked like a charm, we never had any problems. While I was investigating the feasability of moving to PHP 5, I discovered that for some reason, the exact same XML/XSL fails to transform properly. The relevant bit of XSL is below:

----------------------------
<xsl:param name="pageContext" select="UNDEFINED" />
<xsl:variable name="sections" select="document('../xml/sections.xml')" />

<xsl:variable name="targetID" select="//[EMAIL PROTECTED] = $pageContext]/@id" 
/>
<xsl:variable name="targetFileSrc" select="$sections/sections/[EMAIL PROTECTED] = $targetID]" />

<xsl:variable name="targetFile">
<xsl:choose>
<xsl:when test="($targetFileSrc/sectionContentSrc = 'none') or (string-length($targetFileSrc/sectionContentSrc) = 0)">
<xsl:copy-of select="document('../xml/default.xml')" />
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="document(concat('../xml/', $targetFileSrc/sectionContentSrc))" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>

<xsl:variable name="cornerImage" select="$targetFile/content/headerContent/headerCornerImage" /> <xsl:variable name="shadowImage" select="$targetFile/content/headerContent/headerShadowImage" />
--------------------------------------

with some sample XML as follows:

--------------------------------------
<content>
<headerContent>

<headerCornerImage>home_nav_middle.gif</headerCornerImage>
<headerShadowImage>home_nav_bottom.gif</headerShadowImage>

</headerContent>
</content>
----------------------------------------

I've checked and confirmed that pageContext gets properly initialised, that all the referenced documents exist and are well-formed, and that they contain the expected nodes. The error I get is "evaluating variable 'cornerImage' failed", yet I cannot understand how this can be so. Apart from the fact that it worked perfectly fine in PHP 4, all the XML and XSL conforms to spec. Anyone have an idea? I'm using the PHP 5 DOM and XSL libraries to handle everything in my upgraded version of the code; the PHP 4 version used DOMXML and Sablotron.


--
Pleochism: a moment of perfect beauty, between the "before" and the "after".

Mr Daniel Lowes
Techteam
Department of Computer Science
Information Technology Building, 4-30
University of Pretoria
http://www.cs.up.ac.za/

This message and attachments are subject to a disclaimer. Please refer to www.it.up.ac.za/documentation/governance/disclaimer/ for full details. Hierdie boodskap en aanhangsels is aan 'n vrywaringsklousule onderhewig. Volledige besonderhede is by www.it.up.ac.za/documentation/governance/disclaimer/ beskikbaar.
--- End Message ---
--- Begin Message ---
張 峰銘 wrote:
> Hello:
>  
> I'm try to design WMV movie upload system im my school.
>  
> when teachers upload the wmv movie to the web ,
>  I hope I can grab the first frame picture of wmv 
> and save it to a jpeg file.
>  
> Dose any one do that before ?  Is is difficult to implement in PHP ?
>  
> (I'm in the Linux with Apache & PHP & MySQL)
> Thanks for any helps.

You can execute totem-video-thumbnailer. It captures the middle frame, I
think. The first one is mostly irrelevant or even blank anyway.

--- End Message ---

Reply via email to