php-general Digest 10 Oct 2006 14:05:57 -0000 Issue 4393
Topics (messages 242880 through 242901):
Re: Working with overly aggressive anti-spam measures
242880 by: Chris
242882 by: Travis Doherty
242885 by: Dave M G
242886 by: Chris
Re: ftp_put and ftp_chmod does not work
242881 by: Chris
242899 by: João Cândido de Souza Neto
Removing quotes
242883 by: John Taylor-Johnston
unexpected T_STRING parse error
242884 by: Ilaria De Marinis
242887 by: Penthexquadium
242893 by: Ilaria De Marinis
If array()
242888 by: John Taylor-Johnston
242889 by: Philipp Schwarz
242890 by: Chris
242892 by: Jochem Maas
Seperate HTML from PHP
242891 by: Sancar Saran
242896 by: Peter Lauri
Passing JAVASCRIPT variable to PHP Script...
242894 by: Captain
242895 by: Penthexquadium
PHP Mailer and SMTP = SPAM?
242897 by: Peter Lauri
Re: Using mysql_real_escape_string
242898 by: Alan Milnes
Re: Apply the hyper link ( javascript functon ) with php
242900 by: edwardspl.ita.org.mo
242901 by: clive
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 ---
Dave M G wrote:
PHP List,
I run a few various social groups, and with each one I keep in contact
with members by emailing them short newsletters.
All my user information is stored in a MySQL database. I use PHP to get
the relevant contact information, and use the mail() command to send out
the emails one by one, so that each email is a little personalized.
I've used this system for many years now with no problems up until now.
What has changed, though, is that in recent years, anti-spam measures
have become so aggressive that more and more people who sign up to my
groups complain that they never receive the emails.
A lot of the times, after they alert me to the issue, I can educate them
a little about the anti-spam measures they most likely have on their
system, and walk them through how to make it so that my newsletters go
through.
However, that is clearly not enough.
To shorten a story that has already gone on a little long, it's come to
my attention that part of the reason that my emails may not be getting
through are because the headers are not sufficiently legitimate looking
enough to bypass some server side anti-spam measures. Things like
"Return-Path" are being set so that they look like they come from an
email address that begins with the username "nobody".
mail($email, $subject, $mailContent, $fromAddress);
You need to set the 5th parameter to change who it comes from (instead
of "nobody"). See php.net/mail for more info.
You can't change that parameter if safe-mode is on for the server or if
exim doesn't have the webserver user as a 'trusted-user' (I think only
exim is affected by this particular issue).
--
Postgresql & php tutorials
http://www.designmagick.com/
--- End Message ---
--- Begin Message ---
Dave M G wrote:
> PHP List,
>
> I run a few various social groups, and with each one I keep in contact
> with members by emailing them short newsletters.
>
> All my user information is stored in a MySQL database. I use PHP to
> get the relevant contact information, and use the mail() command to
> send out the emails one by one, so that each email is a little
> personalized.
>
> I've used this system for many years now with no problems up until now.
>
> What has changed, though, is that in recent years, anti-spam measures
> have become so aggressive that more and more people who sign up to my
> groups complain that they never receive the emails.
>
> A lot of the times, after they alert me to the issue, I can educate
> them a little about the anti-spam measures they most likely have on
> their system, and walk them through how to make it so that my
> newsletters go through.
>
> However, that is clearly not enough.
>
> To shorten a story that has already gone on a little long, it's come
> to my attention that part of the reason that my emails may not be
> getting through are because the headers are not sufficiently
> legitimate looking enough to bypass some server side anti-spam
> measures. Things like "Return-Path" are being set so that they look
> like they come from an email address that begins with the username
> "nobody".
>
> If possible, can anyone help me with creating the PHP code that will
> make an email as legitimate as it can be? I know I can't totally
> prevent my email from being marked as spam (after all, if it were
> possible, all the spammers would do it). But as much as I can prevent
> anti-spam measures getting a false positive when testing my email, the
> better.
>
> Here is the PHP code I currently use (trimmed for clarity):
>
> while ( $member = mysql_fetch_row($mysqlResult) )
> {
> $subscriber = $member[0];
> $email = $member[1];
> $subject = "Report for " . date('l jS F Y');
> $mailContent = "This is an email to " . $subscriber . " at " . $email
> . ".";
> $fromAddress = "[EMAIL PROTECTED]"
> mail($email, $subject, $mailContent, $fromAddress);
> }
>
>
> And here is what the headers for an email from that code looks like:
>
> -Account-Key: account5
> X-UIDL: UID497-1152485402
> X-Mozilla-Status: 0001
> X-Mozilla-Status2: 00000000
> Return-path: <[EMAIL PROTECTED]>
> Envelope-to: [EMAIL PROTECTED]
> Delivery-date: Sun, 03 Sep 2006 14:22:42 -0700
> Received: from nobody by server.myhostingservice.com with local (Exim
> 4.52)
> id 1GJzQQ-0005pA-Mz
> for [EMAIL PROTECTED]; Sun, 03 Sep 2006 14:22:42 -0700
> To: [EMAIL PROTECTED]
> Subject: Report for Monday 4th September 2006
> From: [EMAIL PROTECTED]
> Message-Id: <[EMAIL PROTECTED]>
> Date: Sun, 03 Sep 2006 14:22:42 -0700
>
> Which parts are key to change, and how?
>
> Thank you for any and all advice.
>
> --
> Dave M G
> Ubuntu 6.06 LTS
> Kernel 2.6.17.7
> Pentium D Dual Core Processor
> PHP 5, MySQL 5, Apache 2
>
If it is sendmail it would be the -f parameter to set the Envelope-From
address. ie... php.ini would have 'sendmail_path = /pathto/sendmail -f
[EMAIL PROTECTED]'. Since PHP 4.0.5 you can also set the
additional_parameter like php.net/manual/function.mail.php (the example
there is specifically for this use.)
What you actually should be doing: install SpamAssasin on your
workstation and run the message through it in test mode... Figure out
what rules get hit and work to resolve those. Run it like `spamassassin
-t < message_with_headers`
So, you'd copy your complete message (as you have above) into
message_with_headers and run it through SA. Maybe SA is giving you
points for things like too many exclamations, certain ratio of HTML...
I doubt that having a return-path of 'nobody' is the lowest-hanging
fruit you can pick up here to make yourself look less spammy.
Also make sure the sending mail server isn't listed in any blacklists
(yahoo for RBL lookup tool to check.)
Travis Doherty
--- End Message ---
--- Begin Message ---
Travis, Chris,
Thank you for your advice.
I've installed spamassassin and I'm using it to monitor how well my PHP
generated emails rate as spam.
So far, I'm not doing well. I have two main issues so far:
1. Spamassassin says:
Spam detection software, running on the system "homebase", has
identified this incoming email as possible spam. [...]
Content analysis details: (0.3 points, 5.0 required)
pts rule name description
---- ----------------------
--------------------------------------------------
0.3 AWL AWL: From: address is in the auto white-list
I looked up about auto white-lists on the net, and it says that it's a
comparison between the current and previous emails. But for testing
purposes, I don't really want it to compare against previous emails,
since previous test emails would be "spammier" and bias spamassassin the
wrong way.
How can I compensate for this?
2. I've attempted to add the "Return-Path" headers to my headers, like so:
$headers = "Return-Path: [EMAIL PROTECTED]";
$headers .= "From: Tokyo Street Hockey Association
<[EMAIL PROTECTED]>\n";
$headers .= "X-Sender: [EMAIL PROTECTED]";
mail($member, $subject, $content, $headers);
And yet, when I look at the headers of the email that's being generated,
it says:
Return-Path: <[EMAIL PROTECTED]>
Received: from server.mywebhost.com (ns1.nameserver.com
[123.123.123.123] (may be forged)
(Note that I've changed the names of servers and the DNS just to keep
some info private)
Why are my attempts to set these headers in PHP not taking effect?
--
Dave M G
Ubuntu 6.06 LTS
Kernel 2.6.17.7
Pentium D Dual Core Processor
PHP 5, MySQL 5, Apache 2
--- End Message ---
--- Begin Message ---
Dave M G wrote:
Travis, Chris,
Thank you for your advice.
I've installed spamassassin and I'm using it to monitor how well my PHP
generated emails rate as spam.
So far, I'm not doing well. I have two main issues so far:
1. Spamassassin says:
Spam detection software, running on the system "homebase", has
identified this incoming email as possible spam. [...]
Content analysis details: (0.3 points, 5.0 required)
pts rule name description
---- ----------------------
--------------------------------------------------
0.3 AWL AWL: From: address is in the auto white-list
I looked up about auto white-lists on the net, and it says that it's a
comparison between the current and previous emails. But for testing
purposes, I don't really want it to compare against previous emails,
since previous test emails would be "spammier" and bias spamassassin the
wrong way.
How can I compensate for this?
2. I've attempted to add the "Return-Path" headers to my headers, like so:
$headers = "Return-Path: [EMAIL PROTECTED]";
$headers .= "From: Tokyo Street Hockey Association
<[EMAIL PROTECTED]>\n";
$headers .= "X-Sender: [EMAIL PROTECTED]";
mail($member, $subject, $content, $headers);
And yet, when I look at the headers of the email that's being generated,
it says:
Return-Path: <[EMAIL PROTECTED]>
Received: from server.mywebhost.com (ns1.nameserver.com
[123.123.123.123] (may be forged)
(Note that I've changed the names of servers and the DNS just to keep
some info private)
Why are my attempts to set these headers in PHP not taking effect?
Because the return path can't be set manually.
You need to set the 5th parameter:
mail($to, $subject, $headers, $body, '[EMAIL PROTECTED]');
or
ini_set('sendmail_from', '[EMAIL PROTECTED]');
mail($to, $subject, $headers, $body);
--
Postgresql & php tutorials
http://www.designmagick.com/
--- End Message ---
--- Begin Message ---
João Cândido de Souza Neto wrote:
Hello everyone.
I have got some parts of my system where some files are sent and i use ftp
functions to save suche files.
When i run it in my local machine, it works fine but, when it is on the
server i got some errors.
I was using ftp_put to copy such files from upload_temp folder of php to my
system own folder and it does not work, i thought it could be because the
ftp user has no permission in upload_temp folder of php.
Most likely. ftp users are usually locked in to their own home folders
and can't access any other parts of the system. It's simply a security
thing.
Then i tried to use php_chmod to give permissions for the apache user,
move_uploaded_files to move such file and ftp_chmod agais to remove
permissions. It does not work too, i think it is because the server has
safe_mode on.
chmod will be affected by safe mode (please read the documentation):
When safe mode is enabled, PHP checks whether the files or directories
you are about to operate on have the same UID (owner) as the script that
is being executed. In addition, you cannot set the SUID, SGID and sticky
bits.
move_uploaded_file will always fail because the file isn't uploaded
through a form. The documentation makes this rather clear (see also
is_uploaded_file).
--
Postgresql & php tutorials
http://www.designmagick.com/
--- End Message ---
--- Begin Message ---
"Chris" <[EMAIL PROTECTED]> escreveu na mensagem
news:[EMAIL PROTECTED]
> João Cândido de Souza Neto wrote:
>> Hello everyone.
>>
>> I have got some parts of my system where some files are sent and i use
>> ftp functions to save suche files.
>>
>> When i run it in my local machine, it works fine but, when it is on the
>> server i got some errors.
>>
>> I was using ftp_put to copy such files from upload_temp folder of php to
>> my system own folder and it does not work, i thought it could be because
>> the ftp user has no permission in upload_temp folder of php.
>
> Most likely. ftp users are usually locked in to their own home folders and
> can't access any other parts of the system. It's simply a security thing.
I agree.
>
>
>> Then i tried to use php_chmod to give permissions for the apache user,
>> move_uploaded_files to move such file and ftp_chmod agais to remove
>> permissions. It does not work too, i think it is because the server has
>> safe_mode on.
>
> chmod will be affected by safe mode (please read the documentation):
>
> When safe mode is enabled, PHP checks whether the files or directories you
> are about to operate on have the same UID (owner) as the script that is
> being executed. In addition, you cannot set the SUID, SGID and sticky
> bits.
It means that the UID (owner) of the folder ought to be the apache user or
the ftp user?
>
>
> move_uploaded_file will always fail because the file isn't uploaded
> through a form. The documentation makes this rather clear (see also
> is_uploaded_file).
The file realy was uploaded by a form and it is in the temporary upload
folder of php.
>
> --
> Postgresql & php tutorials
> http://www.designmagick.com/
--- End Message ---
--- Begin Message ---
Someone kindly gave me this once. I now need to reverse engineer it to
remove the quotes and plus signs from $searchenquiry. Is it as simple as
this?
// FINAL RESULT: [+"john" +"johnston"]
$sEnquiry = preg_replace("/\s+/", "+", $sEnquiry);
// RESULT: ["john" "johnston"]
$sEnquiry = preg_replace("/\s+/", "\"", $sEnquiry);
// RESULT: [john johnston]
--------original code-----------------------------------------------
$sEnquiry = preg_replace("/\s+/", " ", $sEnquiry);
// remove whitespace from beginning & end
// RESULT: [john johnston]
$sEnquiry = preg_replace("/\s+/", " ", $sEnquiry);
// replace internal whitespace with single spaces
// RESULT: [john johnston]
$sEnquiry = str_replace(" ", "\" +\"", $sEnquiry);
// replace each space with quote-space-plus-quote
// RESULT: [john" +"johnston]
$sEnquiry = "+\"" . $sEnquiry . "\"";
// add beginning & ending delimiters
// FINAL RESULT: [+"john" +"johnston"]
--- End Message ---
--- Begin Message ---
Hi list,
I got a php error in my apache log:
PHP Parse error: parse error, unexpected T_STRING in
/var/www/html/dummy/typo3conf/ext/direct_mail/locallang_tca.xml on line 1
This is line 1 of locallang_tca.xml file
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
I try to switch "short_open_tag" to off in php.ini, but I got a bad page
visualization.
In fact it's visible also source code while displaying pages.
Any ideas?
Thank in advance
Ilaria
--
------------------------------------------------
De Marinis Ilaria
Settore Automazione Biblioteche
Phone: +3906-44486052
CASPUR - Via dei Tizii ,6b - 00185 Roma
e-mail: [EMAIL PROTECTED]
------------------------------------------------
--- End Message ---
--- Begin Message ---
On Tue, 10 Oct 2006 09:18:18 +0200, Ilaria De Marinis <[EMAIL PROTECTED]> wrote:
> Hi list,
> I got a php error in my apache log:
>
> PHP Parse error: parse error, unexpected T_STRING in
> /var/www/html/dummy/typo3conf/ext/direct_mail/locallang_tca.xml on line 1
>
> This is line 1 of locallang_tca.xml file
> <?xml version="1.0" encoding="utf-8" standalone="yes" ?>
>
> I try to switch "short_open_tag" to off in php.ini, but I got a bad page
> visualization.
> In fact it's visible also source code while displaying pages.
>
> Any ideas?
> Thank in advance
>
> Ilaria
>
> --
> ------------------------------------------------
> De Marinis Ilaria
> Settore Automazione Biblioteche
> Phone: +3906-44486052
> CASPUR - Via dei Tizii ,6b - 00185 Roma
> e-mail: [EMAIL PROTECTED]
> ------------------------------------------------
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
<?php
echo '<' . '?xml version="1.0" encoding="utf-8" standalone="yes" ?>';
// ...
?>
--
Sorry for my poor English.
--- End Message ---
--- Begin Message ---
It's impossible for me to make this change.
xml files are packaged in external modules. I can't manipulate them!
Penthexquadium wrote:
On Tue, 10 Oct 2006 09:18:18 +0200, Ilaria De Marinis <[EMAIL PROTECTED]> wrote:
Hi list,
I got a php error in my apache log:
PHP Parse error: parse error, unexpected T_STRING in
/var/www/html/dummy/typo3conf/ext/direct_mail/locallang_tca.xml on line 1
This is line 1 of locallang_tca.xml file
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
I try to switch "short_open_tag" to off in php.ini, but I got a bad page
visualization.
In fact it's visible also source code while displaying pages.
Any ideas?
Thank in advance
Ilaria
--
------------------------------------------------
De Marinis Ilaria
Settore Automazione Biblioteche
Phone: +3906-44486052
CASPUR - Via dei Tizii ,6b - 00185 Roma
e-mail: [EMAIL PROTECTED]
------------------------------------------------
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
<?php
echo '<' . '?xml version="1.0" encoding="utf-8" standalone="yes" ?>';
// ...
?>
--
Sorry for my poor English.
--
------------------------------------------------
De Marinis Ilaria
Settore Automazione Biblioteche
Phone: +3906-44486052
CASPUR - Via dei Tizii ,6b - 00185 Roma
e-mail: [EMAIL PROTECTED]
------------------------------------------------
--- End Message ---
--- Begin Message ---
How can I use "if" to see an array contains something?
if ($array()) does not work, of course.
John
--- End Message ---
--- Begin Message ---
Try this:
if (is_array($array) && count($array)) {
...
}
John Taylor-Johnston schrieb:
How can I use "if" to see an array contains something?
if ($array()) does not work, of course.
John
--
Mit freundlichen Grüßen
Philipp Schwarz
-------------------------------------------------
comtrance
E-Mail: [EMAIL PROTECTED]
Internet: http://www.comtrance.net
Telefon: +49 (211) 27159 - 20
Fax: +49 (211) 54423 - 05
Anschrift: comtrance GmbH
In der Steele 20
40599 Düsseldorf
--- End Message ---
--- Begin Message ---
John Taylor-Johnston wrote:
How can I use "if" to see an array contains something?
php.net/in_array
--
Postgresql & php tutorials
http://www.designmagick.com/
--- End Message ---
--- Begin Message ---
Philipp Schwarz wrote:
> Try this:
>
> if (is_array($array) && count($array)) {
given that your not interested in the actual count of the array,
only that is is not empty, save yourself a couple of CPU cycles
and use empty() instead ...
if (is_array($array) && !empty($array)) {
foreach ($array as $k => $v) echo htmlentities("$v = $k<br />");
}
> ...
> }
>
> John Taylor-Johnston schrieb:
>> How can I use "if" to see an array contains something?
>>
>> if ($array()) does not work, of course.
>>
>> John
>>
>
>
--- End Message ---
--- Begin Message ---
Hi there, following words are my ideas about that HTML PHP parting. I hope you
can understand my broken english and do not take personally.
SEPERATING html FROM php ARE USELESS
For years, some php users try to show php to look like other programming
languages like C or JAVA. I believe they try to prove PHP can act like other
programming languages because most professionals from other disciplines
thinks that thing PHP was so easy to write to someting and because of this
that PHP thing can't be a professional tool.
To show professionalisim of php, people start to make programs using 3 tier
programming aproach. Then that MAGIC WORD seperating business layer from
presentation layer comes to php land...
After some time community sees templating engines, today you will see lots of
them oh sorry TONS of them...
I'm sorry guys, I admire your efforts, REALLY.
Personally I spend more than 2 years to create some kind of OO library to
making forms easly. And after some time I realize, we cannot standardize
HTML/Javascirpt, every new project we have to challange to new interface
problems and because of this I have to redesign that templating library to
not broke code integritiy. Of course I may use that common library's to solve
problems and of course later or sooner I find myself into a deep trouble.
That new project can't fit that lib.
And of course that was not only problem about templating engines.
They are slow, hell yes SLOW. (yea yea I know your uber template system
blazingly faster than more popular ones). You have to open tons of mini tpl
files, have to parse them, have to manage them.
So if that templating system generates this much of problem why we should use
them ? Just Because of our uber HTML designer can't understand php ?.
I'm sorry, things are changing, nearly all new project are contains dynamic
parts. These visual designers have to learn some degree of php code.
And also I believe we have to change aproaching and usage of php language.
I see most people using php dynamic part of their html code. They using php
like
<a href="somepage.php?a=<?php echo $foo; ?>"><?php echo $bar; ?></a>
And I suggest we can aproaching html marking language to part of php
presentation layer.
Like
<?php
...
generate $head
generate $header
generate $left
generate $content
generate $right
generate $footer
...
include('theme.inc.php')
print $strOutput;
?>
theme.inc.php
<?php
$strOutput="<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"
\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"en\">
<head>
".$head."
</head>
<body>
<div id='mainDiv' class='cMainDiv'>
<div id='headDiv' class='cHeadDiv'>
".$header."
</div>
<div id='contDiv' class='cContDiv'>
<table border='0' cellpadding='0'
cellspacing='1' width='100%'>
<tr>
<td id='contLeftTD'
class='cContLeftTD' valign='top'>
".$left."
</td>
<td id='contCentTD'
class='cContCentTD' valign='top'>
".$content."
</td>
<td id='contRightTD'
class='cContRightTD' valign='top'>
".$right."
</td>
</tr>
</table>
</div>
<div id='footDiv' class='cFootDiv'>
".$footer."
</div>
</div>
</body>
</html>";
?>
Also we can use php to generate some kind of html code to reduce our workload,
I believe best aproach was, do not generate data and html code in same
function...
Seperating html generation and data generation best way to increase code
reuse.
For example
function makeSelects($arrData,$strRequest)
{
$intSize = sizeof($arrData);
for($intS=0;$intS<$intSize;$intS++)
{
@$strReturn.="<option value='".$arrData[$intS]['val']."'";
if(@$strRequest == $arrData[$intS]['val']) { $strReturn.= "
selected"; }
$strReturn.= ">".$arrData[$intS]['tex']."</option>\n";
}
return $strReturn;
}
with this function we can generate select options.
$sqlGetType = "
SELECT typeId,typeName
FROM listType
WHERE typeStatus = 'active'
ORDER BY typeName ASC";
$resGetType = doSql($sqlGetType); // put your sql extraction function here
$intT = 0;
while(!$resGetType->EOF)
{
$arrType[$intT]['val'] = $resGetType->fields[0];
$arrType[$intT]['tex'] = $resGetType->fields[1];
$intT++;
$resGetType->MoveNext();
}
$strType = makeSelects($arrType,@$_REQUEST['type']);
echo "<select name='type' size ='1'>
".$strType."
</select>";
examples may go further.
And please, do not think seperating Html from php and is good thing. All of
them part of the system.
Or just think, can we seperate SQL from php ?, is there any SQLling template
or someting like that library available? If I remember correctly that SQL was
another language.
And of course my ideas has tons of objection and I think this way.
Thanks to reading my ideas about php and html seperation. I hope I can
translate my ideas about the issue.
Regards
Sancar "Delifisek" Saran
--- End Message ---
--- Begin Message ---
Have you tried Smarty (smarty.php.net)?
-----Original Message-----
From: Sancar Saran [mailto:[EMAIL PROTECTED]
Sent: Tuesday, October 10, 2006 3:43 PM
To: [email protected]
Subject: [PHP] Seperate HTML from PHP
Hi there, following words are my ideas about that HTML PHP parting. I hope
you
can understand my broken english and do not take personally.
SEPERATING html FROM php ARE USELESS
For years, some php users try to show php to look like other programming
languages like C or JAVA. I believe they try to prove PHP can act like other
programming languages because most professionals from other disciplines
thinks that thing PHP was so easy to write to someting and because of this
that PHP thing can't be a professional tool.
To show professionalisim of php, people start to make programs using 3 tier
programming aproach. Then that MAGIC WORD seperating business layer from
presentation layer comes to php land...
After some time community sees templating engines, today you will see lots
of
them oh sorry TONS of them...
I'm sorry guys, I admire your efforts, REALLY.
Personally I spend more than 2 years to create some kind of OO library to
making forms easly. And after some time I realize, we cannot standardize
HTML/Javascirpt, every new project we have to challange to new interface
problems and because of this I have to redesign that templating library to
not broke code integritiy. Of course I may use that common library's to
solve
problems and of course later or sooner I find myself into a deep trouble.
That new project can't fit that lib.
And of course that was not only problem about templating engines.
They are slow, hell yes SLOW. (yea yea I know your uber template system
blazingly faster than more popular ones). You have to open tons of mini tpl
files, have to parse them, have to manage them.
So if that templating system generates this much of problem why we should
use
them ? Just Because of our uber HTML designer can't understand php ?.
I'm sorry, things are changing, nearly all new project are contains dynamic
parts. These visual designers have to learn some degree of php code.
And also I believe we have to change aproaching and usage of php language.
I see most people using php dynamic part of their html code. They using php
like
<a href="somepage.php?a=<?php echo $foo; ?>"><?php echo $bar; ?></a>
And I suggest we can aproaching html marking language to part of php
presentation layer.
Like
<?php
...
generate $head
generate $header
generate $left
generate $content
generate $right
generate $footer
...
include('theme.inc.php')
print $strOutput;
?>
theme.inc.php
<?php
$strOutput="<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"
\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"en\">
<head>
".$head."
</head>
<body>
<div id='mainDiv' class='cMainDiv'>
<div id='headDiv' class='cHeadDiv'>
".$header."
</div>
<div id='contDiv' class='cContDiv'>
<table border='0' cellpadding='0'
cellspacing='1' width='100%'>
<tr>
<td id='contLeftTD'
class='cContLeftTD' valign='top'>
".$left."
</td>
<td id='contCentTD'
class='cContCentTD' valign='top'>
".$content."
</td>
<td id='contRightTD'
class='cContRightTD' valign='top'>
".$right."
</td>
</tr>
</table>
</div>
<div id='footDiv' class='cFootDiv'>
".$footer."
</div>
</div>
</body>
</html>";
?>
Also we can use php to generate some kind of html code to reduce our
workload,
I believe best aproach was, do not generate data and html code in same
function...
Seperating html generation and data generation best way to increase code
reuse.
For example
function makeSelects($arrData,$strRequest)
{
$intSize = sizeof($arrData);
for($intS=0;$intS<$intSize;$intS++)
{
@$strReturn.="<option value='".$arrData[$intS]['val']."'";
if(@$strRequest == $arrData[$intS]['val']) { $strReturn.= "
selected"; }
$strReturn.= ">".$arrData[$intS]['tex']."</option>\n";
}
return $strReturn;
}
with this function we can generate select options.
$sqlGetType = "
SELECT typeId,typeName
FROM listType
WHERE typeStatus = 'active'
ORDER BY typeName ASC";
$resGetType = doSql($sqlGetType); // put your sql extraction function here
$intT = 0;
while(!$resGetType->EOF)
{
$arrType[$intT]['val'] = $resGetType->fields[0];
$arrType[$intT]['tex'] = $resGetType->fields[1];
$intT++;
$resGetType->MoveNext();
}
$strType = makeSelects($arrType,@$_REQUEST['type']);
echo "<select name='type' size ='1'>
".$strType."
</select>";
examples may go further.
And please, do not think seperating Html from php and is good thing. All of
them part of the system.
Or just think, can we seperate SQL from php ?, is there any SQLling template
or someting like that library available? If I remember correctly that SQL
was
another language.
And of course my ideas has tons of objection and I think this way.
Thanks to reading my ideas about php and html seperation. I hope I can
translate my ideas about the issue.
Regards
Sancar "Delifisek" Saran
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Hi geeks,
i am uploading a file to server. Uploading part is working fine. i
am struggle with minor part. actually before uploading file, i am checking
for existance of a file. If it is not exists, directly i am uploading that
file. If it exists, i sud ask user that "This file is exits. Do You really
want to Upload it?"...If YES, i will overwrite it. otherwise, i won't do
anything.
i am using javascript for popup windows. i used confirm()
function(CANCEL / OK).
the problem is, i am not able to get the variable value for php
script. Of course, php is server side programming language & javascript
client side programming language.
Plz see my code & give the solution.
See my progress:
"upload.php"
# Checking for the File existance
if (file_exists($fullPath)) {
echo "<script language='JavaScript'>if(confirm('This
file is already Exists ! Do You Want to Duplicate ?')) { var s=1;} else {var
s=0;} </script>";
$decide="<script
language='JavaScript'>document.write(s)</script>";
echo "$decide";
if (!$decide) {
// Don't Upload
exit;
}
else {
// Upload the file
}
In this code, echo "$decide"; is printing whether 1 or 0. But by using that
variable, i cudn't proceed further. Bcoz it is not useful for manipulating.
* Is anyway to store that variable value in a static file, so that, i can
proceed easily.
* Is it possible to execute shell commands by javascript, so that i can
create file & store this variable.
If it is not possible, plz give any other solution.
Expecting ur reply.
Thanks in advance
Prabhakaran.
--
View this message in context:
http://www.nabble.com/Passing-JAVASCRIPT-variable-to-PHP-Script...-tf2415628.html#a6733549
Sent from the PHP - General mailing list archive at Nabble.com.
--- End Message ---
--- Begin Message ---
On Tue, 10 Oct 2006 03:09:42 -0700 (PDT), Captain <[EMAIL PROTECTED]> wrote:
>
> Hi geeks,
> i am uploading a file to server. Uploading part is working fine. i
> am struggle with minor part. actually before uploading file, i am checking
> for existance of a file. If it is not exists, directly i am uploading that
> file. If it exists, i sud ask user that "This file is exits. Do You really
> want to Upload it?"...If YES, i will overwrite it. otherwise, i won't do
> anything.
> i am using javascript for popup windows. i used confirm()
> function(CANCEL / OK).
> the problem is, i am not able to get the variable value for php
> script. Of course, php is server side programming language & javascript
> client side programming language.
> Plz see my code & give the solution.
>
> See my progress:
>
> "upload.php"
>
> # Checking for the File existance
> if (file_exists($fullPath)) {
> echo "<script language='JavaScript'>if(confirm('This
> file is already Exists ! Do You Want to Duplicate ?')) { var s=1;} else {var
> s=0;} </script>";
>
> $decide="<script
> language='JavaScript'>document.write(s)</script>";
> echo "$decide";
> if (!$decide) {
> // Don't Upload
> exit;
> }
> else {
> // Upload the file
> }
>
> In this code, echo "$decide"; is printing whether 1 or 0. But by using that
> variable, i cudn't proceed further. Bcoz it is not useful for manipulating.
>
> * Is anyway to store that variable value in a static file, so that, i can
> proceed easily.
> * Is it possible to execute shell commands by javascript, so that i can
> create file & store this variable.
>
> If it is not possible, plz give any other solution.
> Expecting ur reply.
>
> Thanks in advance
> Prabhakaran.
> --
> View this message in context:
> http://www.nabble.com/Passing-JAVASCRIPT-variable-to-PHP-Script...-tf2415628.html#a6733549
> 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
This is my ideas:
If the file has already existed, the server-side script could save it in
a place temporarily, and marks the file by an unique identification
(such as md5 checksum). And then the the server-side tells the
client-side file exists and gives it the id. If the user choose
overwrite, the client-side only need to post the received id, do not
need to upload the file again.
--
Sorry for my poor English.
--- End Message ---
--- Begin Message ---
Hi,
I am developing a "tell-a-friend" application for one of my customers. We
are going to have it all located on their server, and want to make sure we
take the right decisions on the road so that we don't spam mark our server
and don't end up in the SPAM inbox of the recipients. This is how I have
prepared it all:
1. We have setup an email that do have an inbox and is REAL. We have an
mailbox connected to it and can send and read emails from it via webmail and
pop
2. We have an SMTP server that requires authentication
3. We are going to use PHP Mailer
Using PHP Mailer and the SMTP sending function should make the emails look
pretty real, am I right? On that we make sure that the HTML that we create
is good, check that with http://spamcheck.sitesell.com
<http://spamcheck.sitesell.com/> or similar.
Shouldn't I be pretty good to go? We are not talking about millions of
emails per day here, maybe a few thousands. What are the risks of ending up
being a spam marked ip?
Best regards,
Peter Lauri
www.lauri.se <http://www.lauri.se/> - personal web site
www.dwsasia.com <http://www.dwsasia.com/> - company web site
--- End Message ---
--- Begin Message ---
Thanks everyone.
Alan
--- End Message ---
--- Begin Message ---
Richard Lynch wrote:
>On Sun, October 8, 2006 6:53 pm, [EMAIL PROTECTED] wrote:
>
>
>>How to apply the following function with php ?
>><a href=javascript:popup('index.htm')> Test </a>
>>
>>
>
>If you're new to PHP, be a minimalist, and pull out PHP only when you
>absolutely have to:
>
><a href="javascript:popup('<?php echo $dir?>/index.htm')"> Test </a>
>
>Since $dir is the ONLY part you want to be changing, use PHP only for
>that part.
>
>Switching in/out of PHP like this is very fast/cheap, and leaves you
>with HTML that mostly looks just like you are used to.
>
>YMMV
>
>
>
Hello to you,
php web page ( test.php ) :
<script language="javascript" type="text/javascript">
<!--
function popup(page)
{
window.open(page,title, "height=100,width=100");
}
// -->
</script>
<a href="javascript:popup('./<?php echo $dir?>/index.htm')"> Test </a>
Result : "homepage error"
Web Server error log :
[Tue Oct 10 18:07:36 2006] [error] [client 202.108.22.70] File does not
exist: /home/web/index.htm
[Tue Oct 10 18:10:12 2006] [error] [client 61.135.145.217] File does not
exist: /home/web/test2004.htm
[Tue Oct 10 18:10:14 2006] [error] [client 61.135.145.217] File does not
exist: /home/web/readme.htm
Please help, thanks !
Edward.
--- End Message ---
--- Begin Message ---
Hello to you,
php web page ( test.php ) :
<script language="javascript" type="text/javascript">
<!--
function popup(page)
{
window.open(page,title, "height=100,width=100");
}
// -->
</script>
<a href="javascript:popup('./<?php echo $dir?>/index.htm')"> Test </a>
Result : "homepage error"
Web Server error log :
[Tue Oct 10 18:07:36 2006] [error] [client 202.108.22.70] File does not
exist: /home/web/index.htm
[Tue Oct 10 18:10:12 2006] [error] [client 61.135.145.217] File does not
exist: /home/web/test2004.htm
[Tue Oct 10 18:10:14 2006] [error] [client 61.135.145.217] File does not
exist: /home/web/readme.htm
Please help, thanks !
Edward.
does $dir have a value ?
probably nothing to do with php, does your page work if there was no php
code in it and if you replaced
<?php echo $dir?> with a page url.
and go through some tutorial on php !!!
--
Regards,
Clive
--- End Message ---