php-general Digest 5 Jun 2005 15:14:46 -0000 Issue 3495
Topics (messages 216393 through 216406):
Re: url by mail
216393 by: Mark Cain
Re: mozilla & urlencode
216394 by: John Taylor-Johnston
216406 by: Marek Kilimajer
Re: Deerpark (aka Firefox 1.1 alpha) URI's and PHP
216395 by: Richard Lynch
extended charsets
216396 by: Philip Washington
$date("l-m");
216397 by: John Taylor-Johnston
216398 by: Sebastian
216401 by: Jochem Maas
PHP and Zend
216399 by: JamesBenson
Re: missing $_GET
216400 by: Ric Manalac
Re: Help with some OOP
216402 by: Jochem Maas
stripping html tags
216403 by: Dotan Cohen
Unbuffered Reads
216404 by: Steven James Samuel Stapleton
Re: ampersands in href's
216405 by: Jack Jackson
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
php-general@lists.php.net
----------------------------------------------------------------------
--- Begin Message ---
$lines = file('http://www.example.com/');
foreach ($lines as $line) {
echo $line . "\n";
}
This ought to do it. Try it and see.
But be aware that if the "allow_url_fopen" was not enable at the compile
time, this won't work.
Mark Cain
----- Original Message -----
From: "vlad georgescu" <[EMAIL PROTECTED]>
To: "php-general" <php-general@lists.php.net>
Sent: Saturday, June 04, 2005 1:54 PM
Subject: [PHP] url by mail
how can i send a webpage by mail ?
i'v tryed something like that
$fd = fopen ($url, "r");
$contents = fread($fd, 102400);
print $contents;
fclose ($fd);
mail($adr,$url,$contents);
but the message is blank .... :(
what's the problem ?
--- End Message ---
--- Begin Message ---
This works: "District of St. Francis"
http://www.glquebec.org/tezt.php#District+of+St.+Francis
<a name="District+of+St.+Francis"></a>
This does not: "Montréal District #2"
http://www.glquebec.org/tezt.php#Montr%E9al+District+%232
<a name="Montr%E9al+District+%232"></a>
I'm beginning to see the problem lies with the French character "é". I
don't see it being #. In any case, I cannot change existing fields. How
can I get this working?
Pablo Gosse wrote:
I'm not sure, but I see two things that might be causing this. First,
why are spaces, which should be translated as %20, being represented
as a '+'?
Second, you have a # in the actual bookmark name, which I would assume
is not valid since the # denotes the beginning of a bookmark. So
perhaps IE compensates for this, but Mozilla reads the bookmark as
looking for <a name="4"></a> because of the #4 at the end of the
bookmark name.
I generate the link using urlencode.
if ("" != $mydata->district){
echo " - <a
href=\"#".urlencode($mydata->district)."\">$mydata->district</a></h1>";
}else{
echo "</h1>";
}
The link is named:
echo "<hr size=1><a
name=\"".urlencode($mydata->district)."\"></a><h2>$mydata->district</h2>\n";
--- End Message ---
--- Begin Message ---
John Taylor-Johnston wrote:
This works: "District of St. Francis"
http://www.glquebec.org/tezt.php#District+of+St.+Francis
<a name="District+of+St.+Francis"></a>
This does not: "Montréal District #2"
http://www.glquebec.org/tezt.php#Montr%E9al+District+%232
<a name="Montr%E9al+District+%232"></a>
I'm beginning to see the problem lies with the French character "é". I
don't see it being #. In any case, I cannot change existing fields. How
can I get this working?
replace unsafe characters with safe ones
--- End Message ---
--- Begin Message ---
On Sat, June 4, 2005 3:53 am, Chris Drozdowski said:
> Will PHP scripts that work properly with the current version (1.0.4) of
> Firefox need to be modified for the feature detailed below in Firefox
> 1.1?
>
> See:
> http://www.mozilla.org/projects/deerpark/new-web-dev-features.html
>
> "URIs always sent as UTF8
>
> URIs are now always sent to the server as UTF8, regardless of the
> linking page's encoding. This fixes images and links on sites with
> non-ASCII filenames."
AIUI, UTF-8 is a super-set of ASCII.
So if your filenames are all ASCII, you're fine.
If you've been using funky characters like umlauts and they've been
magically working, you could be in trouble...
At least, that's my best guess.
--
Like Music?
http://l-i-e.com/artists.htm
--- End Message ---
--- Begin Message ---
We have 2 different linux servers running apache and php. On one of the
servers the information pulled from the data show degree symbols or
greek lettering, which are supposed to be there. On the other server
the places where these symbols are supposed to appear shows blank
spaces. One server is RHEL3 the other RHEL4.
I am not that familiar with charsets and how they interact with apache
and php. I'd appreciate any help in trying to figure out where this
problem is or what I should be looking for. Both systems pulling from
the same database and displaying different information.
--- End Message ---
--- Begin Message ---
$mydata->lastinsalled = "2004-05";
How can I determne if $mydata->lastinsalled is one year or more older
than the current $date("l-m");
Anyting simple and over looked? I have been browsing the manual::
http://ca.php.net/manual/en/function.strtotime.php
http://ca.php.net/manual/en/function.date.php
John
--- End Message ---
--- Begin Message ---
is it possible for $mydata->lastinsalled to have YYYY-MM-DD format? ie:
2004-05-31
you can use strtotime to convert it to unix timestamp to
compare...something like this:
$stamp = strtotime('2004-06-31'); // $mydata->lastinsalled
if($stamp >= strtotime('1 year ago'))
{
echo 'less than 1 year';
}
else
{
echo 'over 1 year';
}
otherwise its impossible to tell if it is over one year without knowing
the day as well.. unless you guess and figure on the first of the month..
John Taylor-Johnston wrote:
$mydata->lastinsalled = "2004-05";
How can I determne if $mydata->lastinsalled is one year or more older
than the current $date("l-m");
Anyting simple and over looked? I have been browsing the manual::
http://ca.php.net/manual/en/function.strtotime.php
http://ca.php.net/manual/en/function.date.php
John
--- End Message ---
--- Begin Message ---
John Taylor-Johnston wrote:
$mydata->lastinsalled = "2004-05";
take a good look at mktime();
How can I determne if $mydata->lastinsalled is one year or more older
than the current $date("l-m");
Anyting simple and over looked? I have been browsing the manual::
http://ca.php.net/manual/en/function.strtotime.php
http://ca.php.net/manual/en/function.date.php
John
--- End Message ---
--- Begin Message ---
PHP 4.3.11 / Apache 2.0.54 / Zend Optimizer 2.5
I have the above on fedora core 3, Ive ran the zend auto setup to
install but when I open phpinfo.php the version of zend says:-
This program makes use of the Zend Scripting Language Engine:
Zend Engine v1.3.0,
I directed apache to load the php.ini file using the PHPinidir setting
in httpd.conf then in phpinfo.php it said the following:-
This program makes use of the Zend Scripting Language Engine:
Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies with Zend
Extension Manager v1.0.7, Copyright (c) 2003-2005, by Zend Technologies
with Zend Optimizer v2.5.10, Copyright (c) 1998-2005, by Zend Technologies
Ive had it installed before on another copy but never seen this before,
normally has an image plus just one version listed,
Can anyone help?
--- End Message ---
--- Begin Message ---
What PHP version is known to cause this type of problem? Does anyone
know what specific configuration setting causes the $_GET to not catch
values passed through the querystring?
My hosting company's PHP version is 4.3.4. Below are some info from phpinfo():
register_globals is set to On
Configure Command
'./configure' '--host=i686-pc-linux-gnu' '--build=i686-pc-linux-gnu'
'--target=i386-redhat-linux-gnu' '--program-prefix=' '--prefix=/usr'
'--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin'
'--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include'
'--libdir=/usr/lib' '--libexecdir=/usr/libexec' '--localstatedir=/var'
'--sharedstatedir=/usr/com' '--mandir=/usr/share/man'
'--infodir=/usr/share/info' '--cache-file=../config.cache'
'--with-config-file-path=/etc'
'--with-config-file-scan-dir=/etc/php.d' '--enable-force-cgi-redirect'
'--disable-debug' '--enable-pic' '--disable-rpath'
'--enable-inline-optimization' '--with-bz2' '--with-db4=/usr'
'--with-curl' '--with-dom=/usr' '--with-exec-dir=/usr/bin'
'--with-freetype-dir=/usr' '--with-png-dir=/usr' '--with-gd'
'--enable-gd-native-ttf' '--with-ttf' '--with-gdbm' '--with-gettext'
'--with-ncurses' '--with-gmp' '--with-iconv' '--with-jpeg-dir=/usr'
'--with-openssl' '--with-png' '--with-pspell' '--with-regex=system'
'--with-xml' '--with-expat-dir=/usr' '--with-zlib' '--with-layout=GNU'
'--enable-bcmath' '--enable-exif' '--enable-ftp'
'--enable-magic-quotes' '--enable-safe-mode' '--enable-sockets'
'--enable-sysvsem' '--enable-sysvshm' '--enable-discard-path'
'--enable-track-vars' '--enable-trans-sid' '--enable-yp'
'--enable-wddx' '--without-oci8' '--with-pear=/usr/share/pear'
'--with-imap=shared' '--with-imap-ssl' '--with-kerberos=/usr/kerberos'
'--with-ldap=shared' '--with-mysql=shared,/usr' '--with-mhash=shared'
'--with-mcrypt=shared' '--with-oci8=shared' '--with-snmp=shared,/usr'
'--with-snmp=shared' '--enable-ucd-snmp-hack' '--with-pgsql=shared'
'--with-unixODBC=shared' '--enable-memory-limit' '--enable-bcmath'
'--enable-shmop' '--enable-versioning' '--enable-calendar'
'--enable-dbx' '--enable-dio' '--enable-mcal'
'--with-apxs2filter=/usr/sbin/apxs'
Thanks.
On 4 Jun 2005 13:15:23 -0000, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
>
> php-general Digest 4 Jun 2005 13:15:23 -0000 Issue 3493
>
> Topics (messages 216354 through 216369):
>
> missing $_GET
> 216360 by: Ric Manalac
> 216361 by: JamesBenson
>
> ---------- Forwarded message ----------
> From: JamesBenson <[EMAIL PROTECTED]>
> To: php-general@lists.php.net
> Date: Sat, 04 Jun 2005 08:09:34 +0100
> Subject: Re: missing $_GET
> Possibly the PHP version your using, try looking at the PHP manual and
> also getting your PHP version by placing <? phpinfo(); ?>
> into a file and running it in your browser, see this document for other
> methods:-
>
> http://php.net/manual/en/reserved.variables.php#reserved.variables.get
>
--- End Message ---
--- Begin Message ---
JamesBenson wrote:
Hello all, Ive been working with PHP for my websites for a few months,
just attempted to build my own class, after reading all this stuff about
automated robots and XSS attacks etc decided to step up security a bit,
my result is an attempt to create a class for using the token method
within web forms, not even sure whether its the real thing but my work
is below, some advice on whether its ok or what needs improving would be
appreciated, thanks.
<?php
// PHP 4.3.11
class SecretToken {
var $_returnCode;
function GenerateToken() {
if(!isset($_SESSION['token'])) {
session_regenerate_id();
I wonder if regenerating the session id here is useful.
I understand doing it on log off/on but whats the connection
with creating a 'submit token'?
$new_token = md5(uniqid(rand(), true));
$_SESSION['token'] = $new_token;
}
}
function VerifyToken($post) {
if(isset($_SESSION['token'])) {
$saved_token = ($_SESSION['token']);
}
I think you should be unsetting $_SESSION['token']
round about here in order to make sure that each
submit a user does requires a different/new token.
I am assuming you have implemented this class in order
to trap double submits (as well as increasing the
security of you submits somewhat).
at the moment the user gets a single token for
ALL submits he does within a given session.
if($post == $saved_token):
$this->_returnCode = 1;
unset($_SESSION['token']);
else:
$this->_returnCode = 0;
endif;
}
function ReturnCode() {
## Result will be 1 for success or 0 for fail
return $this->_returnCode;
}
you can probably drop the ReturnCode() function
and just have the 1/0 returned directly from VerifyToken() e.g:
if (SecretToken::VerifyToken( $myTok )) {
// lets do a submit
} else {
// evil hacker, set the dogs on him.
}
// end class definition
}
?>
Basically in my web form I call GenerateToken firstly, then when the
forms been submitted I then call VerifyToken and finally check return
codes using a switch statement, seems to work,
sounds fine to me.
rgds,
jochem
TIA
James Benson
--- End Message ---
--- Begin Message ---
I took this example from php.net, but can't figure out where I went
wrong. Why does this:
$text = preg_replace("/<head(.|\s)*?>(.|\s)*?<\/head>/i" , "" , $text);
throw this error:
syntax error at line 265, column 39:
$text = preg_replace("/<head(.|\s)*?>(.|\s)*?<\/head>/i" , "" ,
$text);
======================================^
It seems to be pointing to the 'e' is 'head'. Why? Thanks.
Dotan Cohen
http://lyricslist.com/lyrics/pages/artist_albums.php/416/Queen
--- End Message ---
--- Begin Message ---
Is there any way to perform an unbuffered read in PHP when reading from
STDIN?
I.E. if I have the code
---------------------
$chr = "";
while(!feof(STDIN))
{
$chr = fgetc(STDIN); //I could just as easily do fread(STDIN, 1)
if($chr == " ")
break;
}
---------------------
and enter the following string (note this is how you would enter the string
in a program to have it have the same value I'd type in):
"this is a test\n"
It will stop reading at the newline, and not the first space.
Any ideas?
System Info
Environment: Windows XP Pro (used both the windows and cygwin command lines)
PHP Version: 5.0.3
Thanks
-Jim Stapleton
--- End Message ---
--- Begin Message ---
Thanks!
Leon Poon wrote:
The simplest way to make sure everything work well regardless of what
the values are:
<?
$url = "somepage.php?var1=".urlencode($var1)."&var2=".urlencode($var2);
echo "<a href=\"".htmlspecialchars($url)."\">";
?>
htmlspecialchars() changes characters '&', '"', ''', '<', '>' into the
HTML equivilant. And yup, you should do this for all *ML pages as long
as the thing being printed is not part of the mark-up syntax.
Jack Jackson wrote:>
Rory Browne wrote:
On 6/4/05, Jack Jackson <[EMAIL PROTECTED]> wrote:
Hi, Rory
Rory Browne wrote:
I think you have the idea. The &'s are used to seperate the various
variables. If you want to set $p to something like 'Tom & Jerry' then
personally I'd do something like:
<?php
$p = "Tom & Jerry";
$s = "Cat & Mouse";
printf("<a href='{$_SERVER['PHP_SELF']}?p=%s&s=%s", urlencode($p),
urlencode($s));
?>
That's nice. To get more specific (because my code varies a bit from
yours and I don't wanna mess up the ) and ' and " s:
$p and $c are actually row ID numbers so up to 3 digits. So for
example if
$p=1
$c=32
I was wanting to see a URL of
http://foo.com?r=1&c=32
In that case, you can simply echo them out, once you're sure that $r,
and $c are actually integers.
I forgot to mention that above I did $r = intval($_GET[r])
!
Thanks, everyone!
echo "<a href='http://foo.com?r=$r&c=$c'>whatever</a>"
if not(sure they're integers, you could always
printf("<a href=\"http://foo.com?r=%d&c=%d\">whatever</a>", $r, $c);
Alternatively you could $r = (int)$r;
or echo "<a href='http://foo.com?r=" . (int)$r . "&c=" . (int)$c .
"'>whatever</a>";
There's more than one way to do it.......
so was this the way to go?
//Make a thumbnail table of contents to display in the left sidebar
while ($sidebar = mysql_fetch_assoc($sidebar_result)) {
$sidebar_thumbnails[] = "<a class='img-link'
href='{$_SERVER['PHP_SELF']}?p=%p&c={$sidebar['art_id']},
urlencode($p)'
title=\"{$sidebar['art_title']}\"><img class='sidebar-img'
src='{$image_dir}{$sidebar['art_thumbnail']}' width='50' height='60'
border='0' alt=\"{$sidebar['art_title']}\" /></a>";
}
?
Thanks in advance!
On 6/4/05, Jack Jackson <[EMAIL PROTECTED]> wrote:
Hi,
If I want to make a link to a URL which includes some GETs can I
just do:
<a href='{$_SERVER['PHP_SELF']}?p={$p}&c={$s}' ... etc etc
or must I escape the ampersand somehow?
TIA,
--Jack
--
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
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---