php-general Digest 24 Jul 2008 10:08:38 -0000 Issue 5586

2008-07-24 Thread php-general-digest-help

php-general Digest 24 Jul 2008 10:08:38 - Issue 5586

Topics (messages 277214 through 277234):

Re: $_ENV or getenv to get bash environmental variables.. change php.ini?? env 
vars
277214 by: mike

*[SPAM(1.8)]*
277215 by: payne.magi.magidesign.com
277216 by: payne.magi.magidesign.com

Weird issue with PHP5
277217 by: jeff.mills.winsto.net
277218 by: Nathan Nobbe
277219 by: jeff.mills.winsto.net
277220 by: Nathan Nobbe
277221 by: Nathan Nobbe

hash_hmac: Encoding with two different results problem
277222 by: Leon du Plessis
277226 by: Nathan Nobbe
277227 by: Nathan Nobbe

Re: Apache blocking certain requests instead of php
277223 by: Arno Kuhl
277224 by: Chris
277225 by: Børge Holen
277228 by: Arno Kuhl
277229 by: Arno Kuhl
277230 by: Chris
277231 by: Chris
277232 by: Børge Holen
277233 by: Arno Kuhl
277234 by: Per Jessen

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]


--
---BeginMessage---
On 7/23/08, mindspin311 [EMAIL PROTECTED] wrote:

 I want to be able to do a getenv('SYMFONY_HOME'); or any env var that I've
 setup in my /etc/bashrc for everyone. But apache obviously doesn't have a
 shell, so it doesn't know about these. only the stuff in $_ENV.

 What I want to know is how can I read env vars like ANT_HOME, JAVA_HOME,
 etc.. in php? I just need to be able to read symfony's root path so I can
 stop hard coding it into a config file in the project everytime I deploy to
 a new machine.

i believe you can add it to /etc/profile and restart apache (possibly
need to reboot, not sure) and those are global environment variables
everyone receives, including non-interactive shells and processes.
---End Message---
---BeginMessage---
Spam detection software, running on the system magi.magidesign.com, has
identified this incoming email as possible spam.  The original message
has been attached to this so you can view it (if it isn't spam) or label
similar future email.  If you have any questions, see
postmaster for details.

Content preview:  Hi, Can someone please point me to a web site with examples
   of php being use with the cli sending mail. I need to create a couple scripts
   that do that. I have looked on the net and most scripts are for form feed
   back. [...] 

Content analysis details:   (1.8 points, 1.5 required)

 pts rule name  description
 -- --
-1.7 ALL_TRUSTEDPassed through trusted hosts only via SMTP
 1.0 Magi_deSpam from Germany
 0.0 BAYES_50   BODY: Bayesian spam probability is 40 to 60%
[score: 0.4208]
 2.5 MISSING_SUBJECTMissing Subject: header


---BeginMessage---
Hi,

Can someone please point me to a web site with examples of php being use
with the cli sending mail. I need to create a couple scripts that do that.
I have looked on the net and most scripts are for form feed back.

Thanks...

Payne

---End Message---
---End Message---
---BeginMessage---
Spam detection software, running on the system magi.magidesign.com, has
identified this incoming email as possible spam.  The original message
has been attached to this so you can view it (if it isn't spam) or label
similar future email.  If you have any questions, see
postmaster for details.

Content preview:  Hi, Can someone please point me to a web site with examples
   of php being use with the cli sending mail. I need to create a couple scripts
   that do that. I have looked on the net and most scripts are for form feed
   back. [...] 

Content analysis details:   (1.8 points, 1.5 required)

 pts rule name  description
 -- --
-1.7 ALL_TRUSTEDPassed through trusted hosts only via SMTP
 1.0 Magi_deSpam from Germany
 0.0 BAYES_50   BODY: Bayesian spam probability is 40 to 60%
[score: 0.4208]
 2.5 MISSING_SUBJECTMissing Subject: header


---BeginMessage---
Hi,

Can someone please point me to a web site with examples of php being use
with the cli sending mail. I need to create a couple scripts that do that.
I have looked on the net and most scripts are for form feed back.

Thanks...

Payne

---End Message---
---End Message---
---BeginMessage---

I have a module originally written for PHP-Nuke that I have ported to
CPG-Nuke/DragonFlyCMS.

In PHP4, the page I'm displaying works fine.
In PHP5, it doesn't.

The following link is a screenshot of the page using PHP4:
http://nukeleaguedf.winsto.net/working-php4.jpg

And a screenshot 

Re: [PHP] Weird issue with PHP5

2008-07-24 Thread Nathan Nobbe
On Wed, Jul 23, 2008 at 11:43 PM, [EMAIL PROTECTED] wrote:


 
  thats a decent bit of code to pick through, jeff.  glancing at index.txt,
  the code looks pretty straight forward, and by that i mean that it doesnt
  look like theres anything that shouldnt work in php5.
 
  if i were to guess, i would suspect an environmental issue.  you should
  ensure that all the extensions you had in php4 are there in php5.  you
 can
  do this by writing a simple script, phpinfo.php
 
  ?php
  die(phpinfo());
 
  you should run this in both the php4, and php5 environments and make sure
  things look essentially identical.  as well, there are a few things that
  changed in php5, here is a helpful reference from the manual that will
  give
  you things to look out for,
 
  http://www.php.net/manual/en/faq.migration5.php
 
  another thing i would recommend to weed out any environmental issues is
 to
  configure error_reporting to show everything.  so (depending on your
  version
  of php5) if youre using the latest version, your php.ini file should have
  something like this
 
  display_errors = On
  error_reporting = E_ALL
 
  on older versions of php5, you would have to tweak the error reporting to
  also display E_STRICT errors, i doubt thats your problem, but i thought
 to
  mention it.
 
  something else that might be helpful would be setting up a debugger, such
  as
  xdebug + protoeditor.  i can help you through the configuration if you
  want.  this will allow you to set breakpoints and step through the code,
  line-by-line if you wish, which could also help you isolate the problem
  more
  quickly.
 
  -nathan
 

 Hi Nathan,
 it sure is a lot of code to work through. Its been driving me insane for
 the last couple of days.
 phpinfo on the same server when switching from php4 to php5 shows only a
 few differences.
 There is one different module in each version:
 PHP Version 4.4.8_pre20070816-pl0-gentoo
 - sapi_apache2
 PHP Version 5.2.6RC4-pl0-gentoo
 - mod_php5


gentoo, hell yea bro, youre in good company!

I've saved the phpinfo pages.
 http://nukeleaguedf.winsto.net/phpinfo/phpinfov4.htm
 http://nukeleaguedf.winsto.net/phpinfo/phpinfov5.htm


meh, as long as you stuck w/ the same use flags there likely arent any
extensions youre missing, but maybe..

I'm currently installing xdebug, but I don't see protoeditor in my Linux
 distro. Is it available for download?


its not even in portage atm, youll have to build from source, but i can
prolly help out there.  heres the download page:

http://sourceforge.net/project/showfiles.php?group_id=129439

ill hit you back in a few w/ the configure options i used to build it.  btw,
im using kde, if you dont have that, youll likely have to pull down kdebase
as protoeditor is built atop the kate libs (which use kde of course).



 Configuration help would be great, thank you.


it might be a little rough w/o getting a look at ur source, but we can
probly figure it out.  are you running apache locally, or on a separate
box?  if its on another box, youll have to install xdebug on that system.
as well, youll have to have php setup on your local box, and a copy of the
source of course.  i recommend setting up apache locally for this if you
can, cause it makes things a lot easier, but either way we can noc it out ;)

-nathan

btw.
the protoeditor homepage is like mad borked, ill fire off a mail to thiago.


Re: [PHP] Weird issue with PHP5

2008-07-24 Thread Nathan Nobbe
On Thu, Jul 24, 2008 at 12:07 AM, Nathan Nobbe [EMAIL PROTECTED]wrote:

 On Wed, Jul 23, 2008 at 11:43 PM, [EMAIL PROTECTED] wrote:


 
  thats a decent bit of code to pick through, jeff.  glancing at
 index.txt,
  the code looks pretty straight forward, and by that i mean that it
 doesnt
  look like theres anything that shouldnt work in php5.
 
  if i were to guess, i would suspect an environmental issue.  you should
  ensure that all the extensions you had in php4 are there in php5.  you
 can
  do this by writing a simple script, phpinfo.php
 
  ?php
  die(phpinfo());
 
  you should run this in both the php4, and php5 environments and make
 sure
  things look essentially identical.  as well, there are a few things that
  changed in php5, here is a helpful reference from the manual that will
  give
  you things to look out for,
 
  http://www.php.net/manual/en/faq.migration5.php
 
  another thing i would recommend to weed out any environmental issues is
 to
  configure error_reporting to show everything.  so (depending on your
  version
  of php5) if youre using the latest version, your php.ini file should
 have
  something like this
 
  display_errors = On
  error_reporting = E_ALL
 
  on older versions of php5, you would have to tweak the error reporting
 to
  also display E_STRICT errors, i doubt thats your problem, but i thought
 to
  mention it.
 
  something else that might be helpful would be setting up a debugger,
 such
  as
  xdebug + protoeditor.  i can help you through the configuration if you
  want.  this will allow you to set breakpoints and step through the code,
  line-by-line if you wish, which could also help you isolate the problem
  more
  quickly.
 
  -nathan
 

 Hi Nathan,
 it sure is a lot of code to work through. Its been driving me insane for
 the last couple of days.
 phpinfo on the same server when switching from php4 to php5 shows only a
 few differences.
 There is one different module in each version:
 PHP Version 4.4.8_pre20070816-pl0-gentoo
 - sapi_apache2
 PHP Version 5.2.6RC4-pl0-gentoo
 - mod_php5


 gentoo, hell yea bro, youre in good company!

 I've saved the phpinfo pages.
 http://nukeleaguedf.winsto.net/phpinfo/phpinfov4.htm
 http://nukeleaguedf.winsto.net/phpinfo/phpinfov5.htm


 meh, as long as you stuck w/ the same use flags there likely arent any
 extensions youre missing, but maybe..

 I'm currently installing xdebug, but I don't see protoeditor in my Linux
 distro. Is it available for download?


 its not even in portage atm, youll have to build from source, but i can
 prolly help out there.  heres the download page:

 http://sourceforge.net/project/showfiles.php?group_id=129439

 ill hit you back in a few w/ the configure options i used to build it.
 btw, im using kde, if you dont have that, youll likely have to pull down
 kdebase as protoeditor is built atop the kate libs (which use kde of
 course).



 Configuration help would be great, thank you.


 it might be a little rough w/o getting a look at ur source, but we can
 probly figure it out.  are you running apache locally, or on a separate
 box?  if its on another box, youll have to install xdebug on that system.
 as well, youll have to have php setup on your local box, and a copy of the
 source of course.  i recommend setting up apache locally for this if you
 can, cause it makes things a lot easier, but either way we can noc it out ;)

 -nathan

 btw.
 the protoeditor homepage is like mad borked, ill fire off a mail to thiago.




ok, so heres the process to install protoeditor.

1. unpack the source, cd into the unpacked directory.
2. ./configure --prefix=/usr/kde/3.5/ --without-arts --enable-debug=full
3. make  make install

you can also pass the --enable-kate-plugin option to configure, if you want
to build it as a plugin for kate, which is pretty nice.  but i always found
it easier to build as a standalone app, just to get the hang of it at first,
then come back and build it into kate.

on the xdebug side (and this will be gentoo-centric, since thats what youre
running)

1. edit /etc/php/apache2-php5/ext/xdebug.ini
enable the following lines

xdebug.remote_enable=1
xdebug.remote_handler=dbgp
* xdebug.remote_host=10.0.1.6
xdebug.remote_mode=req
xdebug.remote_mode=hit
xdebug.remote_port=9000
xdebug.remote_autostart=1

you see ive put a star by xdebug.remote_host, youll need to set that to the
host of your client box, and if its the same one running apache, it would be
127.0.0.1 (obviously :D).  anyway, if apache is on a different box, that
system will need to be able to send requests to your development system on
port 9000, unless you change xdebug.remote_port, but either way, the server
needs to have access to the client system.

2. smylink the extension into ext-active,
sudo ln -snf /etc/php/apache2-php5/ext/xdebug.ini
/etc/php/apache2-php5/ext-active/xdebug.ini
3. restart apache
4. (optional) i recommend using firefox on your development system, there is
a nice little add-on you can get for xdebug,


[PHP] hash_hmac: Encoding with two different results problem

2008-07-24 Thread Leon du Plessis
hi,
I hope this is the right group for this type of problem:

I am using hash_hmac to provide me with a sha1 encoded hash string. The 
problem is as follows:

$hash = hash_hmac('sha1', 
'030B6A05696E657400C54601C60001550187360603773500018707060373796E63000187340603687474703A2F2F772E73796E632E636F6D2F73796E630001C65901873A06032E2F636F6E7461637473000187070603436F6E74616374732044420001872E0603746578742F782D7663617264000101C6570187310603757365726E616D6500018732060370617373776F72640001010101',
 
'1234');

Note: it is important the key to use during encoding id 1234 for this 
example.

Result:
eb38ffd597c6d1e01cd24a0e46dff426354510fe

Using a hash calculator from slavasoft also yields this result, which 
indicate the encoding is fine.
eb38ffd597c6d1e01cd24a0e46dff426354510fe

However, Slavasoft's calculator has an option to provide the string as Text 
or Hex.

Selecting hex yields this result:
9f9be99ea5bf5ba009af0a5c12021f420cb27652  and this is the string I 
need!!!

So either hash_hmac function needs a way to let it know the string is of 
type hexor the string itself needs to be converted. I have tried some 
conversions on the string but to no avail.
Anyone have any thoughts?



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



RE: [PHP] Apache blocking certain requests instead of php

2008-07-24 Thread Arno Kuhl
 I'm getting a lot of bogus requsts in the form of 
 index.php?id=http://64.15.67.17/~babysona/logo.jpg?;, sometimes more 
 than a hundred a day per domain. The php script catches it, logs the 
 request, sends an email report and replies with access denied, but 
 it takes processing which I'd rather not have php busy with. (The php 
 script rejects anything where id=something_not_numeric.) Is there a 
 way for apache to catch these requests before passing it to php? Is it 
 more efficient for apache to handle this than php?
 
 Arno
 

Yes, in Apache turn off userdir access
In your httpd.conf file do this.
UserDir disabled
That way it will not process url that starts with a tildy ~...
That should take care of it.  Apache should then only report a 404 error to
the error log for the given virtual host.

--
Thanks for the reply. Is that correct htough? I always thought in the
example 
http://mysite.com/index.php?id=http://64.15.67.17/~babysona/logo.jpg?
the url started with index.php...

Most the requests though look more like
http://mysite.com/index.php?id=http://calebsbirth.pisem.su/caleb.htm?
without the tilde.

I was hoping there's a way to tell apache to block requests where
id=non_numeric.

Cheers
Arno


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



Re: [PHP] Apache blocking certain requests instead of php

2008-07-24 Thread Børge Holen
On Thursday 24 July 2008 09:14:55 Chris wrote:
  I was hoping there's a way to tell apache to block requests where
  id=non_numeric.

 It's trying to do a remote inclusion.

 It's easy for you to fix in php:

 if (isset($_GET['id'])) {
   if (!is_numeric($_GET['id'])) {
   die(Die hacker die!);

thats sudden! ;)

   }
 }

 I'm sure there would be a way to do it with ModRewrite or something but
 it's 5 lines of code in php so I'd do it there *shrug*.

 --
 Postgresql  php tutorials
 http://www.designmagick.com/



-- 
---
Børge Holen
http://www.arivene.net

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



Re: [PHP] hash_hmac: Encoding with two different results problem

2008-07-24 Thread Nathan Nobbe
On Thu, Jul 24, 2008 at 12:50 AM, Leon du Plessis [EMAIL PROTECTED] wrote:

 hi,
 I hope this is the right group for this type of problem:

 I am using hash_hmac to provide me with a sha1 encoded hash string. The
 problem is as follows:

 $hash = hash_hmac('sha1',

 '030B6A05696E657400C54601C60001550187360603773500018707060373796E63000187340603687474703A2F2F772E73796E632E636F6D2F73796E630001C65901873A06032E2F636F6E7461637473000187070603436F6E74616374732044420001872E0603746578742F782D7663617264000101C6570187310603757365726E616D6500018732060370617373776F72640001010101',
 '1234');

 Note: it is important the key to use during encoding id 1234 for this
 example.

 Result:
 eb38ffd597c6d1e01cd24a0e46dff426354510fe

 Using a hash calculator from slavasoft also yields this result, which
 indicate the encoding is fine.
 eb38ffd597c6d1e01cd24a0e46dff426354510fe

 However, Slavasoft's calculator has an option to provide the string as Text
 or Hex.

 Selecting hex yields this result:
 9f9be99ea5bf5ba009af0a5c12021f420cb27652  and this is the string I


 need!!!

 So either hash_hmac function needs a way to let it know the string is of
 type hexor the string itself needs to be converted. I have tried some
 conversions on the string but to no avail.
 Anyone have any thoughts?


gotchu covered ;)

found this on the web:

http://www.pgregg.com/projects/php/code/hexstr.phps

so then,

?php

function hexstr($hexstr) {
  $hexstr = str_replace(' ', '', $hexstr);
  $retstr = pack('H*', $hexstr);
  return $retstr;
}

$hash = hash_hmac('sha1', hexstr(
'030B6A05696E657400C54601C60001550187360603773500018707060373796E63000187340603687474703A2F2F772E73796E632E636F6D2F73796E630001C65901873A06032E2F636F6E7461637473000187070603436F6E74616374732044420001872E0603746578742F782D7663617264000101C6570187310603757365726E616D6500018732060370617373776F72640001010101'),
'1234');

echo $hash;
?

produc


Re: [PHP] hash_hmac: Encoding with two different results problem

2008-07-24 Thread Nathan Nobbe
On Thu, Jul 24, 2008 at 1:21 AM, Nathan Nobbe [EMAIL PROTECTED]wrote:

 On Thu, Jul 24, 2008 at 12:50 AM, Leon du Plessis [EMAIL PROTECTED] wrote:

 hi,
 I hope this is the right group for this type of problem:

 I am using hash_hmac to provide me with a sha1 encoded hash string. The
 problem is as follows:

 $hash = hash_hmac('sha1',

 '030B6A05696E657400C54601C60001550187360603773500018707060373796E63000187340603687474703A2F2F772E73796E632E636F6D2F73796E630001C65901873A06032E2F636F6E7461637473000187070603436F6E74616374732044420001872E0603746578742F782D7663617264000101C6570187310603757365726E616D6500018732060370617373776F72640001010101',
 '1234');

 Note: it is important the key to use during encoding id 1234 for this
 example.

 Result:
 eb38ffd597c6d1e01cd24a0e46dff426354510fe

 Using a hash calculator from slavasoft also yields this result, which
 indicate the encoding is fine.
 eb38ffd597c6d1e01cd24a0e46dff426354510fe

 However, Slavasoft's calculator has an option to provide the string as
 Text
 or Hex.

 Selecting hex yields this result:
 9f9be99ea5bf5ba009af0a5c12021f420cb27652  and this is the string I


 need!!!

 So either hash_hmac function needs a way to let it know the string is of
 type hexor the string itself needs to be converted. I have tried some
 conversions on the string but to no avail.
 Anyone have any thoughts?


 gotchu covered ;)

 found this on the web:

 http://www.pgregg.com/projects/php/code/hexstr.phps

 so then,

 ?php

 function hexstr($hexstr) {
   $hexstr = str_replace(' ', '', $hexstr);
   $retstr = pack('H*', $hexstr);
   return $retstr;
 }

 $hash = hash_hmac('sha1', hexstr(

 '030B6A05696E657400C54601C60001550187360603773500018707060373796E63000187340603687474703A2F2F772E73796E632E636F6D2F73796E630001C65901873A06032E2F636F6E7461637473000187070603436F6E74616374732044420001872E0603746578742F782D7663617264000101C6570187310603757365726E616D6500018732060370617373776F72640001010101'),
 '1234');

 echo $hash;
 ?

 produc


damnit, its late, so im going to take the liberty to post a follow-up
message to finish that last one off;

(the code from the previous post) produces

9f9be99ea5bf5ba009af0a5c12021f420cb27652

-nathan


RE: [PHP] Apache blocking certain requests instead of php

2008-07-24 Thread Arno Kuhl
 Is there a
 way for apache to catch these requests before passing it to php? Is it 
 more efficient for apache to handle this than php?

2 x yes. I think you could probably use LocationMatch and ban all access
with Deny from all. 

/Per Jessen, Zürich

--
Thanks for replying Per. Isn't Deny from all more to do with apache
accessing local files on my server? These images aren't on my server, and
the requests aren't trying to access images on my server. What I see are
requests using the php script on my server to try access an image file (or
html or txt or php) on someone else's server. I was hoping there's a way to
tell apache to block requests where id=non_numeric.

Cheers
Arno


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



RE: [PHP] Apache blocking certain requests instead of php

2008-07-24 Thread Arno Kuhl
 I was hoping there's a way to tell apache to block requests where 
 id=non_numeric.

It's trying to do a remote inclusion.

It's easy for you to fix in php:

if (isset($_GET['id'])) {
if (!is_numeric($_GET['id'])) {
die(Die hacker die!);
}
}

I'm sure there would be a way to do it with ModRewrite or something but it's
5 lines of code in php so I'd do it there *shrug*.

--
Thanks, I'm already doing something like that, but I want to stop it getting
to php.

Cheers
Arno


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



Re: [PHP] Apache blocking certain requests instead of php

2008-07-24 Thread Chris
Børge Holen wrote:
 On Thursday 24 July 2008 09:14:55 Chris wrote:
 I was hoping there's a way to tell apache to block requests where
 id=non_numeric.
 It's trying to do a remote inclusion.

 It's easy for you to fix in php:

 if (isset($_GET['id'])) {
  if (!is_numeric($_GET['id'])) {
  die(Die hacker die!);
 
 thats sudden! ;)

ok maybe a bit harsh :P

stop hacker stop ?

;)

-- 
Postgresql  php tutorials
http://www.designmagick.com/

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



Re: [PHP] Apache blocking certain requests instead of php

2008-07-24 Thread Chris
 Thanks, I'm already doing something like that, but I want to stop it getting
 to php.

http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html

Ask on an apache list how to use it.

-- 
Postgresql  php tutorials
http://www.designmagick.com/

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



Re: [PHP] Apache blocking certain requests instead of php

2008-07-24 Thread Chris

 I was hoping there's a way to tell apache to block requests where
 id=non_numeric.

It's trying to do a remote inclusion.

It's easy for you to fix in php:

if (isset($_GET['id'])) {
if (!is_numeric($_GET['id'])) {
die(Die hacker die!);
}
}

I'm sure there would be a way to do it with ModRewrite or something but
it's 5 lines of code in php so I'd do it there *shrug*.

-- 
Postgresql  php tutorials
http://www.designmagick.com/

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



Re: [PHP] Apache blocking certain requests instead of php

2008-07-24 Thread Børge Holen
On Thursday 24 July 2008 09:38:57 Chris wrote:
 Børge Holen wrote:
  On Thursday 24 July 2008 09:14:55 Chris wrote:
  I was hoping there's a way to tell apache to block requests where
  id=non_numeric.
 
  It's trying to do a remote inclusion.
 
  It's easy for you to fix in php:
 
  if (isset($_GET['id'])) {
 if (!is_numeric($_GET['id'])) {
 die(Die hacker die!);
 
  thats sudden! ;)

 ok maybe a bit harsh :P

 stop hacker stop ?

I prefer die();
it leaves a bit unsatisfaction for whoever generates the blank page



 ;)

 --
 Postgresql  php tutorials
 http://www.designmagick.com/



-- 
---
Børge Holen
http://www.arivene.net

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



RE: [PHP] Apache blocking certain requests instead of php

2008-07-24 Thread Arno Kuhl
Hi Arno

No, when you use Location it's not filesystem specific any more. But I've
just found out that you can't match on the query-string.

 These images aren't on my server, and
 the requests aren't trying to access images on my server. What I see 
 are requests using the php script on my server to try access an image 
 file (or html or txt or php) on someone else's server. I was hoping 
 there's a way to tell apache to block requests where id=non_numeric.

I think you'll have to use URL rewriting.

Try this:

http://jessen.ch/arnokuhl?id=nonnumeric

That should give you a 403.

http://jessen.ch/arnokuhl?id=

Should give you a print_r() output.

This is the rewrite config:

RewriteEngine on
RewriteCond %{QUERY_STRING} id=[^0-9]+
RewriteRule (/arnokuhl.*) $1 [f]

HTH
Per


Many thanks for all your effort and help Per. That's exactly what I was
trying to achieve.

Cheers
Arno


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



Re: [PHP] Apache blocking certain requests instead of php

2008-07-24 Thread Per Jessen
Chris wrote:

 I'm sure there would be a way to do it with ModRewrite or something
 but it's 5 lines of code in php so I'd do it there *shrug*.

See my reply to Arno - in Apache it's only 2 lines of config. :-)


/Per Jessen, Zürich


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



Re: [PHP] Questions about finding ranges

2008-07-24 Thread Aslan
You guys are just awesome! Thanks already for the help I really 
appreciate it!


My site is up on adslgeek.com/troubleshooter but I have a DNS problem 
that I have to fix over the weekend. :-(


The scenario is an input dashboard, with various settings that measure 
the quality of an ADSL line.
I have then mapped out all of the possible faults that I could think of 
that might fit those settings(did up a flowchart of questions that is huge).


So  for simplicity say the inputs are:
- X Noise on line
- X Distance from exchange
- X Disconnections per day
- Slow speed of x

Then I have a list of all the possible scenarios eg
1) Disconnections caused by noisy line 
2) Disconnections caused by distance

3) Slow due to noisey line
4) Slow due to distance

So how I have currently done this is heaps of nested if statements, but 
that is going to get so unmanageable, and the speed is going to become a 
factor.


What I had envisioned was input all the possible vars, and then SQL just 
finds the closest variable. It is kind of similar in logic to a search 
engine type script - if I had the strings disconnections and noisey 
of 52 then it just finds the closest record.


Does that make sense? Thanks heaps you guys have been so helpful.

Cheers,
Aslan

Micah Gersten wrote:

Here's the info on the weirdness of between:
http://dev.mysql.com/doc/refman/5.0/en/comparison-operators.html#operator_between

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com
  



VamVan wrote:

Hey,

For ranges you can also use Between in the mysql queries.

SELECT * FROM table WHERE Type= Attainable AND Min LIKE $var can be
written as

Select * from table where between min and max

Just remember that between acts a bit wierd with dates or else Jim's
solution would be perfect for you.

Thanks



On Wed, Jul 23, 2008 at 7:58 AM, Jim Lucas [EMAIL PROTECTED] wrote:

  

Aslan wrote:



Hey there,

I have a range of records that represent different faults and different
symptoms that I want to pull out of the database, and to find the records
that are the closest within each range.

I am currently doing it with a barrage of if statements, but I am sure
that this could be done faster and far more elegantly by using SQL

I have a range of conditions eg
Attainable rates:
0-500 KB/sec is very poor
500 - 1000 is marginal
1000- 3000 KB/sec is good

So the database may look like:
Type|Min|Max|Value
Attainable|0|500| This rate is very poor

and then SQL could go something like

SELECT * FROM table WHERE Type= Attainable AND Min LIKE $var


  

You're close, try this

SELECT   *
FROM table
WHEREType = Attainable
 ANDMin = $var
 ANDMax = $var


as long as your min and max do not overlap from row to row, you should only
get one result.  Make sure in your data that you have no overlap.

Row 1 =0 -  499
Row 2 =  500 -  999
Row 3 = 1000 - 1499




But that wouldn't work quite right I don't think.

But where it can get a bit more hairy is that I want to have a whole range
of variables that are input from an entry table, and then it just finds the
the vars that are the closest to what is searching for all the vars. The
closest code I have seen doing something similar is where there it is
finding if an IP is in a certain range.

Does that make sense? feel free to email me if you need more explanation.

It is kind of like a multi variable search engine, that is finding the
root cause of the symptoms that are the very best fit given the
multi-variables...

Thanks heaps for any assistance,
Aslan.



  

--
Jim Lucas

  Some men are born to greatness, some achieve greatness,
  and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
   by William Shakespeare



--
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] Code beautifier

2008-07-24 Thread Richard Heyes
Anyone know of an unintrusive code beautifier written specifically with in mind?

Thanks.

-- 
Richard Heyes
http://www.phpguru.org

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



Re: [PHP] Code beautifier

2008-07-24 Thread Aschwin Wesselius

Richard Heyes wrote:

Anyone know of an unintrusive code beautifier written specifically with in mind?

Thanks.

  

Hi,

With 'what' in mind?


--

Aschwin Wesselius

/'What you would like to be done to you, do that to the other'/


Re: [PHP] Code beautifier

2008-07-24 Thread Richard Heyes
 Anyone know of an unintrusive code beautifier written specifically with in
 mind?


 With 'what' in mind?

Sorry, PHP.

-- 
Richard Heyes
http://www.phpguru.org

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



Re: [PHP] Code beautifier

2008-07-24 Thread Aschwin Wesselius

Richard Heyes wrote:

Anyone know of an unintrusive code beautifier written specifically with in
mind?




  

With 'what' in mind?



Sorry, PHP.
The only one that I've used and got results with is PEAR PHP_Beautifier. 
But the PEAR code itself is butt ugly. I'm thinking about rewriting 
parts of this package for personal use, since it is useful.


I just want a quick and dirty straight forward beautifier. The plugins 
of PHP_Beautifier are nice, so I want to use them too. In combination 
with CodeSniffer you can first sniff what's wrong and then beautify it.


That's my two cents.

--

Aschwin Wesselius

/'What you would like to be done to you, do that to the other'/


Re: [PHP] Code beautifier

2008-07-24 Thread Christoph Boget
 Anyone know of an unintrusive code beautifier written specifically with in 
 mind?

I know it's not quite what you are asking, but the IDE I use has a
really good code beautifier.  It works with a great many languages,
not just for PHP.  This is on top of a gagillion other really useful
features that make coding a lot more fun.

http://www.slickedit.com/

thnx,
Christoph

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



Re: [PHP] Code beautifier

2008-07-24 Thread Thiago H. Pojda
On Thu, Jul 24, 2008 at 8:34 AM, Christoph Boget
[EMAIL PROTECTED]wrote:

  Anyone know of an unintrusive code beautifier written specifically with
 in mind?


I know of what proprietary software that does it very good: polystyle.

(As usual, I'm not related to software creator or anything. I just use and
like it)


Regards,
-- 
Thiago Henrique Pojda


[PHP] Re: *****[SPAM(1.8)]*****

2008-07-24 Thread Colin Guthrie

[EMAIL PROTECTED] wrote:

Can someone please point me to a web site with examples of php being use
with the cli sending mail. I need to create a couple scripts that do that.
I have looked on the net and most scripts are for form feed back.


Just look at the PHP manual's mail() function.

The form feedback examples just use the form to actually gather some 
data but if you want to send mail from a cli PHP app then just gather 
the info in whatever way suits you and then call the same mail() function.


if you need to read input, just to a fgets() or stream_get_line() on a 
handle to php://stdin or something along those lines.


Col


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



[PHP] IPB post date check

2008-07-24 Thread Luca Paolella

Hi,

I'm writing a bot that should let a user log in an IPB forum and do  
some actions after checking that the right conditions are verified in  
the user's account's profile. These conditions are:

1) the user must have registered his account before a certain date
2) the user must have posted a message in a defined period of time  
(between date 1 and date 2)


I'm using a set of functions to get infos about the user from the  
board's db: http://projects.pc-intern.com/index.php?showforum=150
I've been able to verify condition 1, but I don't know what to do  
about the second, since I cannot seem to find a way to check if a user  
posted a message on a certain day. Do you have any idea on how I  
should do this check?


Thanks for your help,
Luca

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



Re: [PHP] IPB post date check

2008-07-24 Thread Dan Shirah
Luca,

You said you have access to the board's DB, correct?

Just from looking at the link you provided I can see that somewhere in the
database it does store the date/time of each post. So, to meet your
conditions your query should be something simple like this:

//
$username = $_POST['user_name'];
$begin_date = 01/01/2001;
$end_date = 01/01/2008;
$register_before_date = 01/01/2008;

$query = SELECT username,
 register_date,
 message_date
   FROM table_1,
  table_2
   WHERE username = '$username'
   AND message_date BETWEEN '$begin_date' AND '$end_date
23:59:59.997'
   AND register_date = '$register_before_date'

Then get your result set...if it isn't empty, that user matches your
criteria and can access the forum. Or if you don't want an array you could
just do a SELECT COUNT and then assign the value to a variable and check
something like: if ($count  0) { allow access }

Hope that helps.
Dan


[PHP] Help with an error...

2008-07-24 Thread payne
Hi,

I am  currently working on a php script that will be called by cron. But I
have an error that keeps coming up.

Parse error: syntax error, unexpected T_VARIABLE inmail_report.php on

What I am trying to do is a simple php script to send me a report
everynight. Any clues as to why? Also does anyone know of a site with mail
srcipts that are ran on the cli?

-
?php
$hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']);

//This is a simple email to give me the status from yesterday.
//This connect the script to the db
require_once('mysql_connect.inc');

$query = Select ip, date, time, CONCAT(city, ', ',country) as location
from ips where country !=' ' and date = current_date() order by
date,time,country asc;;
$result = mysql_query($query)

$mailsend = mail([EMAIL PROTECTED],The IP's that Attacked
$hostname, The following are ip's that have try to attack your
system.\r\n\r\


if ($result) { //if that ran ok, display the record
echo table width=\'150\'trtd Country /tdtd # of
Attacks
/td/tr;

//fetch and print the records

while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
echo trtd align=\'left\'$row[0]/tdtddiv
align=\'right\'$row[1]/div/td/tr;
}

echo '/table';

mysql_free_result ($result); //free up the resources

} else {  //if did not run ok

echo 'pThis could not be display due to a system error.
We apologize
fore any incovenience./pp'. mysql_error() . '/p';

}

,From:[EMAIL PROTECTED] To:[EMAIL PROTECTED]);
print($mailsend);
?




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



Re: [PHP] Help with an error...

2008-07-24 Thread Daniel Brown
On Thu, Jul 24, 2008 at 1:52 PM,  [EMAIL PROTECTED] wrote:
 Hi,

 I am  currently working on a php script that will be called by cron. But I
 have an error that keeps coming up.

 Parse error: syntax error, unexpected T_VARIABLE inmail_report.php on

You didn't include the line number in the message, but when you
receive an error like that, look to the line of code prior.  Usually,
it's just a missing semicolon, which is the case in your situation
here:

$result = mysql_query($query)

-- 
/Daniel P. Brown
Better prices on dedicated servers:
Intel 2.4GHz/60GB/512MB/2TB $49.99/mo.
Intel 3.06GHz/80GB/1GB/2TB $59.99/mo.
Dedicated servers, VPS, and hosting from $2.50/mo.

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



Re: [PHP] Help with an error...

2008-07-24 Thread Micah Gersten
You cannot have commands in the middle of a string.  Try building a
string first, or use output buffering and then capture the buffer and
use that as the string for the mail function.

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com



[EMAIL PROTECTED] wrote:
 Hi,

 I am  currently working on a php script that will be called by cron. But I
 have an error that keeps coming up.

 Parse error: syntax error, unexpected T_VARIABLE inmail_report.php on

 What I am trying to do is a simple php script to send me a report
 everynight. Any clues as to why? Also does anyone know of a site with mail
 srcipts that are ran on the cli?

 -
 ?php
 $hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']);

 //This is a simple email to give me the status from yesterday.
 //This connect the script to the db
 require_once('mysql_connect.inc');

 $query = Select ip, date, time, CONCAT(city, ', ',country) as location
 from ips where country !=' ' and date = current_date() order by
 date,time,country asc;;
 $result = mysql_query($query)

 $mailsend = mail([EMAIL PROTECTED],The IP's that Attacked
 $hostname, The following are ip's that have try to attack your
 system.\r\n\r\


 if ($result) { //if that ran ok, display the record
 echo table width=\'150\'trtd Country /tdtd # of
 Attacks
 /td/tr;

 //fetch and print the records

 while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
 echo trtd align=\'left\'$row[0]/tdtddiv
 align=\'right\'$row[1]/div/td/tr;
 }

 echo '/table';

 mysql_free_result ($result); //free up the resources

 } else {  //if did not run ok

 echo 'pThis could not be display due to a system error.
 We apologize
 fore any incovenience./pp'. mysql_error() . '/p';

 }

 ,From:[EMAIL PROTECTED] To:[EMAIL PROTECTED]);
 print($mailsend);
 ?




   

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



Re: [PHP] Multi-array - What am I missing?

2008-07-24 Thread Jim Lucas

Chris Ditty wrote:

Can anyone point me in the right direction?  I know I am missing something
simple, but I can't place my hands on it.

$myCalTime = act_getCalendarDays($config, $myMonth, $myYear);

foreach($myCalTime as $calTime = $calArrayTime){
$calArray[] = $calArrayTime['day'].=array('NULL','linked-day
.strtolower($calArrayTime['reason']).','.$calArrayTime['day'].'),;
}

act_getCalendarDays returns this
Array
(
[day] = Array
(
[0] = 05
[1] = 06
[2] = 26
[3] = 27
)

[reason] = Array
(
[0] = Vacation
[1] = Vacation
[2] = Vacation
[3] = Vacation
)

)


What am I missing to get this
=array('NULL=','linked-day ',''),

to look like this
05=array(NULL,'linked-day vacation','05'),




$both = array();
foreach ( $myCalTime['day'] AS $i = $date ) {
  $both[$date] = array(null,linked-day {$myCalTime['reason'][$i]},$date);
}

--
Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
by William Shakespeare


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



Re: [PHP] Help with an error...

2008-07-24 Thread Bastien Koert
On Thu, Jul 24, 2008 at 1:52 PM, [EMAIL PROTECTED] wrote:

 Hi,

 I am  currently working on a php script that will be called by cron. But I
 have an error that keeps coming up.

 Parse error: syntax error, unexpected T_VARIABLE inmail_report.php on

 What I am trying to do is a simple php script to send me a report
 everynight. Any clues as to why? Also does anyone know of a site with mail
 srcipts that are ran on the cli?

 -
 ?php
 $hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']);

 //This is a simple email to give me the status from yesterday.
 //This connect the script to the db
 require_once('mysql_connect.inc');

 $query = Select ip, date, time, CONCAT(city, ', ',country) as location
 from ips where country !=' ' and date = current_date() order by
 date,time,country asc;;
 $result = mysql_query($query)

$mailsend = mail([EMAIL PROTECTED],The IP's that Attacked
 $hostname, The following are ip's that have try to attack your
 system.\r\n\r\


if ($result) { //if that ran ok, display the record
echo table width=\'150\'trtd Country /tdtd # of
 Attacks
 /td/tr;

//fetch and print the records

while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
echo trtd align=\'left\'$row[0]/tdtddiv
 align=\'right\'$row[1]/div/td/tr;
}

echo '/table';

mysql_free_result ($result); //free up the resources

} else {  //if did not run ok

echo 'pThis could not be display due to a system error.
 We apologize
 fore any incovenience./pp'. mysql_error() . '/p';

}

 ,From:[EMAIL PROTECTED] [EMAIL PROTECTED]\r\nReply
 To:[EMAIL PROTECTED] [EMAIL PROTECTED]);
 print($mailsend);
 ?




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


first off, you are missing the ending semi-colon from line 11

$result = mysql_query($query); //  -- missing semi colon

secondly, the whole mail thing is really f**ked up. I suggest that you buils
the message body separately and then include it at the end. You just can't
start off with a mail call and drop other stuff into the middle of it



-- 

Bastien

Cat, the other other white meat


Re: [PHP] Help with an error...

2008-07-24 Thread Thorsten Suckow-Homberg

Daniel already answerd regarding your error, but...

?php
$hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']);
  
... if you call the script via cron I'm pretty sure $_SERVER won't be 
available since the script is not used in a running webserver process 
context.


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



Re: [PHP] Help with an error...

2008-07-24 Thread Ted Wood


Micah,

Please provide an example of what your response was referring to in  
the original message.


And it is possible to have commands in the middle of a string by using  
concatenation.


   $str = My name is .strtoupper($name).', but you can call me  
Sam.;



~Ted



On 24-Jul-08, at 10:40 AM, Micah Gersten wrote:


You cannot have commands in the middle of a string.  Try building a
string first, or use output buffering and then capture the buffer and
use that as the string for the mail function.

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com



[EMAIL PROTECTED] wrote:

Hi,

I am  currently working on a php script that will be called by  
cron. But I

have an error that keeps coming up.

Parse error: syntax error, unexpected T_VARIABLE inmail_report.php on

What I am trying to do is a simple php script to send me a report
everynight. Any clues as to why? Also does anyone know of a site  
with mail

srcipts that are ran on the cli?

-
?php
$hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']);

//This is a simple email to give me the status from yesterday.
//This connect the script to the db
require_once('mysql_connect.inc');

$query = Select ip, date, time, CONCAT(city, ', ',country) as  
location

from ips where country !=' ' and date = current_date() order by
date,time,country asc;;
$result = mysql_query($query)

   $mailsend = mail([EMAIL PROTECTED],The IP's that Attacked
$hostname, The following are ip's that have try to attack your
system.\r\n\r\


   if ($result) { //if that ran ok, display the record
   echo table width=\'150\'trtd Country / 
tdtd # of

Attacks
/td/tr;

   //fetch and print the records

   while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
   echo trtd align=\'left\'$row[0]/tdtddiv
align=\'right\'$row[1]/div/td/tr;
   }

   echo '/table';

   mysql_free_result ($result); //free up the resources

   } else {  //if did not run ok

   echo 'pThis could not be display due to a system  
error.

We apologize
fore any incovenience./pp'. mysql_error() . '/p';

   }

,From:[EMAIL PROTECTED] To:[EMAIL PROTECTED]);
print($mailsend);
?







--
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] Help with an error...

2008-07-24 Thread Brady Mitchell


On Jul 24, 2008, at 1052AM, [EMAIL PROTECTED] wrote:


$result = mysql_query($query)


Missing a ; at the end of the line.



   $mailsend = mail([EMAIL PROTECTED],The IP's that Attacked
$hostname, The following are ip's that have try to attack your
system.\r\n\r\


You can't execute code inside of a function call the way you're trying  
to do. Instead do something like:


$message = The following are ip's that have try to attack your system. 
\r\n\r\;


Then in your code below, anywhere you have an echo statement, replace  
it with $message .= code here. For example: $message trtd align= 
\'left\'$row[0]/tdtddiv align=\'right\'$row[1]/div/td/tr;


Then after you're done building your $message for the email,

mail([EMAIL PROTECTED],The IP's that Attacked $hostname,  
$message);


I'd suggest taking another read of the manual page for the mail  
function: http://php.net/manual/en/function.mail.php - the email is  
sent when you make the call, not created and stored in a variable when  
executed.


Brady

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



Re: [PHP] Help with an error...

2008-07-24 Thread Stut

On 24 Jul 2008, at 18:43, Thorsten Suckow-Homberg wrote:

Daniel already answerd regarding your error, but...

?php
$hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']);

... if you call the script via cron I'm pretty sure $_SERVER won't  
be available since the script is not used in a running webserver  
process context.


Not entirely correct. $_SERVER will be available, but parts of it will  
not such as the REMOTE_ADDR since there is not remote entity.


-Stut

--
http://stut.net/

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



Re: [PHP] Help with an error...

2008-07-24 Thread Daniel Brown
On Thu, Jul 24, 2008 at 1:45 PM, Ted Wood [EMAIL PROTECTED] wrote:

   $str = My name is .strtoupper($name).', but you can call me Sam.;

Though ucfirst() would be preferred.  ;-P

-- 
/Daniel P. Brown
Better prices on dedicated servers:
Intel 2.4GHz/60GB/512MB/2TB $49.99/mo.
Intel 3.06GHz/80GB/1GB/2TB $59.99/mo.
Dedicated servers, VPS, and hosting from $2.50/mo.

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



Re: [PHP] Help with an error...

2008-07-24 Thread payne
Thanks guys.  I will take everything that as been stated to heart. Thanks
for the insight. I haven't don't much with mail.

Payne


 On Jul 24, 2008, at 1052AM, [EMAIL PROTECTED] wrote:

 $result = mysql_query($query)

 Missing a ; at the end of the line.


$mailsend = mail([EMAIL PROTECTED],The IP's that Attacked
 $hostname, The following are ip's that have try to attack your
 system.\r\n\r\

 You can't execute code inside of a function call the way you're trying
 to do. Instead do something like:

 $message = The following are ip's that have try to attack your system.
 \r\n\r\;

 Then in your code below, anywhere you have an echo statement, replace
 it with $message .= code here. For example: $message trtd align=
 \'left\'$row[0]/tdtddiv align=\'right\'$row[1]/div/td/tr;

 Then after you're done building your $message for the email,

 mail([EMAIL PROTECTED],The IP's that Attacked $hostname,
 $message);

 I'd suggest taking another read of the manual page for the mail
 function: http://php.net/manual/en/function.mail.php - the email is
 sent when you make the call, not created and stored in a variable when
 executed.

 Brady




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



Re: [PHP] Code beautifier

2008-07-24 Thread mike
On 7/24/08, Richard Heyes [EMAIL PROTECTED] wrote:
 Anyone know of an unintrusive code beautifier written specifically with in 
 mind?

just be prudent (and anal retentive) when you code :)

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



Re: [PHP] Help with an error...

2008-07-24 Thread Micah Gersten
He had code blocks in the middle of a string.  That's what I was
referring to.

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com



Ted Wood wrote:

 Micah,

 Please provide an example of what your response was referring to in
 the original message.

 And it is possible to have commands in the middle of a string by using
 concatenation.

$str = My name is .strtoupper($name).', but you can call me
 Sam.;


 ~Ted



 On 24-Jul-08, at 10:40 AM, Micah Gersten wrote:

 You cannot have commands in the middle of a string.  Try building a
 string first, or use output buffering and then capture the buffer and
 use that as the string for the mail function.

 Thank you,
 Micah Gersten
 onShore Networks
 Internal Developer
 http://www.onshore.com



 [EMAIL PROTECTED] wrote:
 Hi,

 I am  currently working on a php script that will be called by cron.
 But I
 have an error that keeps coming up.

 Parse error: syntax error, unexpected T_VARIABLE inmail_report.php on

 What I am trying to do is a simple php script to send me a report
 everynight. Any clues as to why? Also does anyone know of a site
 with mail
 srcipts that are ran on the cli?

 -
 ?php
 $hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']);

 //This is a simple email to give me the status from yesterday.
 //This connect the script to the db
 require_once('mysql_connect.inc');

 $query = Select ip, date, time, CONCAT(city, ', ',country) as location
 from ips where country !=' ' and date = current_date() order by
 date,time,country asc;;
 $result = mysql_query($query)

$mailsend = mail([EMAIL PROTECTED],The IP's that Attacked
 $hostname, The following are ip's that have try to attack your
 system.\r\n\r\


if ($result) { //if that ran ok, display the record
echo table width=\'150\'trtd Country /tdtd
 # of
 Attacks
 /td/tr;

//fetch and print the records

while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
echo trtd align=\'left\'$row[0]/tdtddiv
 align=\'right\'$row[1]/div/td/tr;
}

echo '/table';

mysql_free_result ($result); //free up the resources

} else {  //if did not run ok

echo 'pThis could not be display due to a system
 error.
 We apologize
 fore any incovenience./pp'. mysql_error() . '/p';

}

 ,From:[EMAIL PROTECTED] To:[EMAIL PROTECTED]);
 print($mailsend);
 ?






 -- 
 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] Code beautifier

2008-07-24 Thread Thiago H. Pojda
On Thu, Jul 24, 2008 at 3:07 PM, mike [EMAIL PROTECTED] wrote:

 On 7/24/08, Richard Heyes [EMAIL PROTECTED] wrote:
  Anyone know of an unintrusive code beautifier written specifically with
 in mind?

 just be prudent (and anal retentive) when you code :)


That doesn't work when you get code from someone else that wasn't prudent
enough ;)

(or even removed code indents *sigh*)


-- 
Thiago Henrique Pojda


Re: [PHP] Code beautifier

2008-07-24 Thread Daniel Brown
On Thu, Jul 24, 2008 at 6:15 AM, Richard Heyes [EMAIL PROTECTED] wrote:
 Anyone know of an unintrusive code beautifier written specifically with in 
 mind?

Rich, I thought you WERE the code beautifier.  ;-P

-- 
/Daniel P. Brown
Better prices on dedicated servers:
Intel 2.4GHz/60GB/512MB/2TB $49.99/mo.
Intel 3.06GHz/80GB/1GB/2TB $59.99/mo.
Dedicated servers, VPS, and hosting from $2.50/mo.

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



Re: [PHP] Code beautifier

2008-07-24 Thread mike
On 7/24/08, Thiago H. Pojda [EMAIL PROTECTED] wrote:

 That doesn't work when you get code from someone else that wasn't prudent
 enough ;)

I figured that'd be the reply - it's not my code ... sadly, I still
go and reformat other coworker's code anyway, heh. Yeah, I'm -that
bad-

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



Re: [PHP] Code beautifier

2008-07-24 Thread Thiago H. Pojda
On Thu, Jul 24, 2008 at 3:14 PM, mike [EMAIL PROTECTED] wrote:

 On 7/24/08, Thiago H. Pojda [EMAIL PROTECTED] wrote:

 sadly, I still go and reformat other coworker's code anyway, heh. Yeah, I'm
 -that bad-


That's why I looked for a tool like that months ago. Big project from
someone else, do you feel like reformatting hundreds of files with hundreds
(thousands?) of lines manually?

I didn't :)

-- 
Thiago Henrique Pojda


Re: [PHP] Code beautifier

2008-07-24 Thread Stut

On 24 Jul 2008, at 19:14, mike wrote:

On 7/24/08, Thiago H. Pojda [EMAIL PROTECTED] wrote:

That doesn't work when you get code from someone else that wasn't  
prudent

enough ;)


I figured that'd be the reply - it's not my code ... sadly, I still
go and reformat other coworker's code anyway, heh. Yeah, I'm -that
bad-


That's not just bad, it's downright anti-productive. You need to  
either have a standard style across a team or accept that other  
developers format their code differently. If you spend time  
reformatting other peoples code it's a waste of your time. Differently  
(not that I didn't say badly) formatted code does not make it wrong,  
it's just different and if you can't live with that then you need to  
work on getting your preferred format adopted as the standard for the  
team.


IMHO.

-Stut

--
http://stut.net/

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



Re: [PHP] Code beautifier

2008-07-24 Thread mike
On 7/24/08, Thiago H. Pojda [EMAIL PROTECTED] wrote:

 That's why I looked for a tool like that months ago. Big project from
 someone else, do you feel like reformatting hundreds of files with hundreds
 (thousands?) of lines manually?

 I didn't :)

If it's something I will wind up working on, I just do it naturally,
it's not even a pain in the ass for me anymore. It also lets me look
line by line for ways to improve/optimize, the problem is I do run
into a lot of why the hell did they do this? and yes, sometimes I do
give up or ignore some code :P

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



Re: [PHP] Code beautifier

2008-07-24 Thread Bastien Koert
On Thu, Jul 24, 2008 at 2:22 PM, Stut [EMAIL PROTECTED] wrote:

 On 24 Jul 2008, at 19:14, mike wrote:

 On 7/24/08, Thiago H. Pojda [EMAIL PROTECTED] wrote:

  That doesn't work when you get code from someone else that wasn't prudent
 enough ;)


 I figured that'd be the reply - it's not my code ... sadly, I still
 go and reformat other coworker's code anyway, heh. Yeah, I'm -that
 bad-


 That's not just bad, it's downright anti-productive. You need to either
 have a standard style across a team or accept that other developers format
 their code differently. If you spend time reformatting other peoples code
 it's a waste of your time. Differently (not that I didn't say badly)
 formatted code does not make it wrong, it's just different and if you can't
 live with that then you need to work on getting your preferred format
 adopted as the standard for the team.

 IMHO.

 -Stut

 --
 http://stut.net/


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


Standard styles are the best to gain that consistency, but a bear to
implement. I've developed and implemented on at my work, but ts so hard to
enforce when you are not supported by those above you who are also coding.

-- 

Bastien

Cat, the other other white meat


Re: [PHP] Code beautifier

2008-07-24 Thread mike
On 7/24/08, Stut [EMAIL PROTECTED] wrote:

 That's not just bad, it's downright anti-productive. You need to either have
 a standard style across a team or accept that other developers format their
 code differently. If you spend time reformatting other peoples code it's a
 waste of your time. Differently (not that I didn't say badly) formatted code
 does not make it wrong, it's just different and if you can't live with that
 then you need to work on getting your preferred format adopted as the
 standard for the team.

We've shown the team and new people join all the time. They bring
their own styles, use crap editors which leave extra linefeeds,
spaces, etc. all over. It's fine, as I am reviewing their code anyway,
it helps me think clearer, and since I have to support fixing the bugs
later on, I can go back to it and read it quicker as well.

Now if I was just cleaning it up and never seeing it again, yes, it
would be a waste of time. But everything usually falls on my plate
when nobody else can figure it out.

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



Re: [PHP] Code beautifier

2008-07-24 Thread Stut

On 24 Jul 2008, at 19:31, mike wrote:

On 7/24/08, Stut [EMAIL PROTECTED] wrote:

That's not just bad, it's downright anti-productive. You need to  
either have
a standard style across a team or accept that other developers  
format their
code differently. If you spend time reformatting other peoples code  
it's a
waste of your time. Differently (not that I didn't say badly)  
formatted code
does not make it wrong, it's just different and if you can't live  
with that

then you need to work on getting your preferred format adopted as the
standard for the team.


We've shown the team and new people join all the time. They bring
their own styles, use crap editors which leave extra linefeeds,
spaces, etc. all over. It's fine, as I am reviewing their code anyway,
it helps me think clearer, and since I have to support fixing the bugs
later on, I can go back to it and read it quicker as well.

Now if I was just cleaning it up and never seeing it again, yes, it
would be a waste of time. But everything usually falls on my plate
when nobody else can figure it out.


Obviously you can run your team the way you want to, but personally I  
prefer to get all my developers singing from the same hymn sheet such  
that after a couple of weeks they can go to any part of the code and  
not see a horrific mess because they're used to the coding style and  
be able to conform to that style when they make changes.


Any half-decent developer should be able to adopt any style they're  
told to. Likewise they should be able to use any editor you tell them  
to, but even if you would prefer to be flexible in the name of  
productivity there are very few editors beyond Notepad that can't use  
a particular EOL and auto-strip trailing spaces. As far as extra  
linefeeds etc that's all coming from the developer unless you're  
using WYSIWYG editors. I've met far too many developers who don't care  
about formatting their code and unless you slap their nose for it they  
won't change.


Yes it takes effort, and yes you will meet resistance, but for me the  
benefits of getting everyone in sync are worth it.


-Stut

--
http://stut.net/

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



Re: [PHP] Help with an error...

2008-07-24 Thread payne
Well all the insight were great, I am not getting and errors but I am not
getting mail. I am looking but php -e isn't telling me anything, and php
-l says there no syntax. What else can I do for debugged.

Payne

 Thanks guys.  I will take everything that as been stated to heart. Thanks
 for the insight. I haven't don't much with mail.

 Payne


 On Jul 24, 2008, at 1052AM, [EMAIL PROTECTED] wrote:

 $result = mysql_query($query)

 Missing a ; at the end of the line.


$mailsend = mail([EMAIL PROTECTED],The IP's that Attacked
 $hostname, The following are ip's that have try to attack your
 system.\r\n\r\

 You can't execute code inside of a function call the way you're trying
 to do. Instead do something like:

 $message = The following are ip's that have try to attack your system.
 \r\n\r\;

 Then in your code below, anywhere you have an echo statement, replace
 it with $message .= code here. For example: $message trtd align=
 \'left\'$row[0]/tdtddiv align=\'right\'$row[1]/div/td/tr;

 Then after you're done building your $message for the email,

 mail([EMAIL PROTECTED],The IP's that Attacked $hostname,
 $message);

 I'd suggest taking another read of the manual page for the mail
 function: http://php.net/manual/en/function.mail.php - the email is
 sent when you make the call, not created and stored in a variable when
 executed.

 Brady







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



Re: [PHP] Code beautifier

2008-07-24 Thread mike
On 7/24/08, Stut [EMAIL PROTECTED] wrote:

 Obviously you can run your team the way you want to, but personally I prefer
 to get all my developers singing from the same hymn sheet such that after a
 couple of weeks they can go to any part of the code and not see a horrific
 mess because they're used to the coding style and be able to conform to that
 style when they make changes.

Heh, I'd love to see you try to tackle the team I'm on. No matter how
many times I show them things, no matter how many simpler methods of
coding we provide (I have a custom library to make life easier) they
still find new ways since PHP is so open to create obtuse and
overengineered solutions for the simplest of things. It's a
never-ending evolutionary process that will probably continue to be
never-ending.

 Any half-decent developer should be able to adopt any style they're told to.

I never said the quality of developers I had to work with :p Most are
decent in their respective fields, but PHP is new to most people here.
It appears that most .NET/Microsoft style coders don't care about
whitespace, tab however they wish, etc, even though VS editors try to
help them, it always comes out with extra white noise.

 Likewise they should be able to use any editor you tell them to, but even if
 you would prefer to be flexible in the name of productivity there are very
 few editors beyond Notepad that can't use a particular EOL and auto-strip
 trailing spaces. As far as extra linefeeds etc that's all coming from the
 developer unless you're using WYSIWYG editors. I've met far too many
 developers who don't care about formatting their code and unless you slap
 their nose for it they won't change.

Eh, I've shown my way many times... it doesn't really help. Besides,
most of the time I have to review this stuff anyway, or go back and
fix bugs in it, so I'm already messing with the code to begin with.

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



Re: [PHP] Help with an error...

2008-07-24 Thread Dan Shirah
Have you set your SMTP server/port in your php.ini file?

Have you checked your mail logs to make sure it is routing through?

Have you verified it is sending from and to a valid email address?


Re: [PHP] Code beautifier

2008-07-24 Thread Stut

On 24 Jul 2008, at 20:01, mike wrote:

On 7/24/08, Stut [EMAIL PROTECTED] wrote:

Obviously you can run your team the way you want to, but personally  
I prefer
to get all my developers singing from the same hymn sheet such that  
after a
couple of weeks they can go to any part of the code and not see a  
horrific
mess because they're used to the coding style and be able to  
conform to that

style when they make changes.


Heh, I'd love to see you try to tackle the team I'm on. No matter how
many times I show them things, no matter how many simpler methods of
coding we provide (I have a custom library to make life easier) they
still find new ways since PHP is so open to create obtuse and
overengineered solutions for the simplest of things. It's a
never-ending evolutionary process that will probably continue to be
never-ending.


Showing them is rarely enough, even when accompanied by a reasonable  
logical argument. Developers get stuck in their ways (I know I am),  
but if you enforce a certain standard on them you don't leave it open  
to their preferences.


Any half-decent developer should be able to adopt any style they're  
told to.


I never said the quality of developers I had to work with :p Most are
decent in their respective fields, but PHP is new to most people here.
It appears that most .NET/Microsoft style coders don't care about
whitespace, tab however they wish, etc, even though VS editors try to
help them, it always comes out with extra white noise.


It really doesn't matter what language they're used to using, it's all  
text and I'd have to say that my experience is that there are too many  
developers of any language out there who don't care about formatting  
their code. I've even seen poorly formatted Python code which I  
thought would be difficult to accomplish, but apparently I was wrong.


Likewise they should be able to use any editor you tell them to,  
but even if
you would prefer to be flexible in the name of productivity there  
are very
few editors beyond Notepad that can't use a particular EOL and auto- 
strip
trailing spaces. As far as extra linefeeds etc that's all coming  
from the

developer unless you're using WYSIWYG editors. I've met far too many
developers who don't care about formatting their code and unless  
you slap

their nose for it they won't change.


Eh, I've shown my way many times... it doesn't really help. Besides,
most of the time I have to review this stuff anyway, or go back and
fix bugs in it, so I'm already messing with the code to begin with.


But you must see that if you only needed to fix the bugs not modify  
the entire file that would benefit you and the team. In addition it  
keeps asset management diff's clean and focused.


Anyhoo, on with the daily grind.

-Stut

--
http://stut.net/

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



Re: [PHP] Code beautifier

2008-07-24 Thread Richard Heyes
 (and anal retentive) when you code :)

I am; the problem is noone lives up to my standards... :-)

-- 
Richard Heyes
http://www.phpguru.org

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



Re: [PHP] Code beautifier

2008-07-24 Thread Richard Heyes
Hi,

Rich, I thought you WERE the code beautifier.  ;-P

Thanks... There's just so much to do though... :-)

-- 
Richard Heyes
http://www.phpguru.org

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



Re: [PHP] Help with an error...

2008-07-24 Thread payne
 Have you set your SMTP server/port in your php.ini file?
Checking
 Have you checked your mail logs to make sure it is routing through?
Tailing the log as I run it.
 Have you verified it is sending from and to a valid email address?
Yes, those are valid.



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



[PHP] Re: Code beautifier

2008-07-24 Thread Al

The one bundled with phpEdit works great. They seem to offer it as a stand 
alone also.
http://www.waterproof.fr/products/phpCodeBeautifier/download.php


Richard Heyes wrote:

Anyone know of an unintrusive code beautifier written specifically with in mind?

Thanks.



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



Re: [PHP] Help with an error...

2008-07-24 Thread Wolf

 [EMAIL PROTECTED] wrote: 
 Well all the insight were great, I am not getting and errors but I am not
 getting mail. I am looking but php -e isn't telling me anything, and php
 -l says there no syntax. What else can I do for debugged.
 
 Payne
!-- SNip --

1.  BOTTOM POST

2.  mailq - this should display if you have any mail queued up to send on the 
server and possibly if it errored out

3.  check your php error log.  If you don't have one, modify your php.ini to 
create one, restart webserver if running via that, CLI should read it on the 
fly.

Wolf

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



Re: [PHP] Code beautifier

2008-07-24 Thread Aschwin Wesselius

Richard Heyes wrote:

Anyone know of an unintrusive code beautifier written specifically with in mind?

Thanks.

  

Hi,

I want to narrow down to why I looked into PHP_Beautifier from PEAR.

First, it's written in PHP (and uses the PHP tokenizer at it and not 
some regex wizardry) and so it's not part of some IDE and therefore you 
don't need to get used to a new environment.


Second, you can have all sorts of guidelines and call them however it 
suits you. You can even set up a guideline for each coworker and one 
main codestyle. You import the code, run your codestyle guideline on it, 
make your edits and right before the build, you run the main codestyle 
configuration. Voila, no harm done and everybody is happy.


Third, I wanted it to integrate it into phpUnderControl, so I can run a 
CodeSniffer and maybe the Beautifier at the end bit of a build cycle if 
needed, make the documentation, run some unit tests etc. Something you 
can't do with a IDE Beautifier.


The thing is, I can't read some of my coworkers code because they don't 
use enough white-space. I get a headache at the end of the day because I 
can't focus enough and have to read each line 3 times. I hate that. 
People saying white-space takes bytes in the filesize have a point, but 
the same people indent to much or awkward or use comments all over the 
place just for the sake of it.


If your code has enough white-space and clear indenting guidelines, you 
sometimes don't need to comment in your code at all. I hate comments. 
Not only writing them, but especially trying to 'read' around them. The 
code explains a lot and so has the code to be. Comments only get into my 
way. Put 'documentation' into a document, not in a script. You can even 
put PHP-doc in a separate file, run the PHPDocumentor at that file and 
leave your script alone.


I only use PHP_Beautifier to clear up the readability of the code, not 
to make it look nice (or beauty). If someone has problems with my code 
having to much white-space, so be it. They can't say it's unreadable, 
but I can say it about my coworkers code.


So, for now I use PHP_Beautifier and not some IDE tool wich meets only 
half way and misses the point.


Aschwin Wesselius

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



Re: [PHP] Help with an error...

2008-07-24 Thread Jim Lucas

So, to summarize everything said, with my own added notes.

[EMAIL PROTECTED] wrote:

Hi,

I am  currently working on a php script that will be called by cron. But I
have an error that keeps coming up.

Parse error: syntax error, unexpected T_VARIABLE inmail_report.php on

What I am trying to do is a simple php script to send me a report
everynight. Any clues as to why? Also does anyone know of a site with mail
srcipts that are ran on the cli?

-
?php



The following wont work if you use this from the CLI.  There is not remote addr.

$hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']);

//This is a simple email to give me the status from yesterday.
//This connect the script to the db
require_once('mysql_connect.inc');



Loose the semi-colon at the end of your SELECT statements.  The mysql 
extension for PHP will add it on its own.



$query = Select ip, date, time, CONCAT(city, ', ',country) as location
from ips where country !=' ' and date = current_date() order by
date,time,country asc;;


You missed a semi-colon at the end of this line

$result = mysql_query($query)

$mailsend = mail([EMAIL PROTECTED],The IP's that Attacked
$hostname, The following are ip's that have try to attack your
system.\r\n\r\




You can't do this within a function call.  Like someone else said, you need to 
run the if/else and while portion before you mail call.  Capture that data and 
then add it to the mail call.



if ($result) { //if that ran ok, display the record
echo table width=\'150\'trtd Country /tdtd # of
Attacks
/td/tr;

//fetch and print the records

while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
echo trtd align=\'left\'$row[0]/tdtddiv
align=\'right\'$row[1]/div/td/tr;
}

echo '/table';

mysql_free_result ($result); //free up the resources

} else {  //if did not run ok

echo 'pThis could not be display due to a system error.
We apologize
fore any incovenience./pp'. mysql_error() . '/p';

}

,From:[EMAIL PROTECTED] To:[EMAIL PROTECTED]);
print($mailsend);
?






So here is the code re factored.

?php

# Setup your variables for later use.
$recipient = '[EMAIL PROTECTED]';
$subject   = 'The IP\'s that Attacked';
$add_headers[] = 'From: [EMAIL PROTECTED]';
$add_headers[] = 'Reply To: [EMAIL PROTECTED]';
$separator = \r\n;

//This is a simple email to give me the status from yesterday.
//This connect the script to the db
require_once('mysql_connect.inc');

$query = 
SELECT   ip,
 date,
 time,
 CONCAT(city, ', ',country) as location
FROM ips
WHEREcountry != ''
  ANDdate = current_date()
ORDER BY date, time, country asc
;

$result = mysql_query($query);

ob_start();
echo TXT
The following are ip's that have try to attack your system.

TXT;

//if that ran ok, display the record
if ($result) {
  echo TABLE

table width='150'trtdCountry/tdtd# of Attacks/td/tr
TABLE;

  //fetch and print the records
  while ( $row = mysql_fetch_assoc($result) ) {
echo ROW
tr
  td align='left'{$row['ip']}/td
  tddiv align='right'[$row['date']}/div/td
/tr
ROW;
  }

echo '/table';

//free up the resources
mysql_free_result ($result);

} else {
  //if did not run ok
  echo 'pThis could not be display due to a system error.
We apologize for any incovenience./pp'. mysql_error() . '/p';

}

$body = ob_get_clean();

$mailsend = mail($recipient, $subject, $body, join($separator, $add_headers));

print($mailsend);

?

--
Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
by William Shakespeare


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



Re: [PHP] Help with an error...

2008-07-24 Thread Payne

Jim Lucas wrote:

So, to summarize everything said, with my own added notes.

[EMAIL PROTECTED] wrote:

Hi,

I am  currently working on a php script that will be called by cron. 
But I

have an error that keeps coming up.

Parse error: syntax error, unexpected T_VARIABLE inmail_report.php on

What I am trying to do is a simple php script to send me a report
everynight. Any clues as to why? Also does anyone know of a site with 
mail

srcipts that are ran on the cli?

-
?php



The following wont work if you use this from the CLI.  There is not 
remote addr.

$hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']);

//This is a simple email to give me the status from yesterday.
//This connect the script to the db
require_once('mysql_connect.inc');



Loose the semi-colon at the end of your SELECT statements.  The mysql 
extension for PHP will add it on its own.



$query = Select ip, date, time, CONCAT(city, ', ',country) as location
from ips where country !=' ' and date = current_date() order by
date,time,country asc;;


You missed a semi-colon at the end of this line

$result = mysql_query($query)

$mailsend = mail([EMAIL PROTECTED],The IP's that Attacked
$hostname, The following are ip's that have try to attack your
system.\r\n\r\




You can't do this within a function call.  Like someone else said, you 
need to run the if/else and while portion before you mail call.  
Capture that data and then add it to the mail call.



if ($result) { //if that ran ok, display the record
echo table width=\'150\'trtd Country /tdtd 
# of

Attacks
/td/tr;

//fetch and print the records

while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
echo trtd align=\'left\'$row[0]/tdtddiv
align=\'right\'$row[1]/div/td/tr;
}

echo '/table';

mysql_free_result ($result); //free up the resources

} else {  //if did not run ok

echo 'pThis could not be display due to a system 
error.

We apologize
fore any incovenience./pp'. mysql_error() . '/p';

}

,From:[EMAIL PROTECTED] To:[EMAIL PROTECTED]);
print($mailsend);
?






So here is the code re factored.

?php

# Setup your variables for later use.
$recipient = '[EMAIL PROTECTED]';
$subject   = 'The IP\'s that Attacked';
$add_headers[] = 'From: [EMAIL PROTECTED]';
$add_headers[] = 'Reply To: [EMAIL PROTECTED]';
$separator = \r\n;

//This is a simple email to give me the status from yesterday.
//This connect the script to the db
require_once('mysql_connect.inc');

$query = 
SELECT   ip,
 date,
 time,
 CONCAT(city, ', ',country) as location
FROM ips
WHEREcountry != ''
  ANDdate = current_date()
ORDER BY date, time, country asc
;

$result = mysql_query($query);

ob_start();
echo TXT
The following are ip's that have try to attack your system.

TXT;

//if that ran ok, display the record
if ($result) {
  echo TABLE

table width='150'trtdCountry/tdtd# of Attacks/td/tr
TABLE;

  //fetch and print the records
  while ( $row = mysql_fetch_assoc($result) ) {
echo ROW
tr
  td align='left'{$row['ip']}/td
  tddiv align='right'[$row['date']}/div/td
/tr
ROW;
  }

echo '/table';

//free up the resources
mysql_free_result ($result);

} else {
  //if did not run ok
  echo 'pThis could not be display due to a system error.
We apologize for any incovenience./pp'. mysql_error() . '/p';

}

$body = ob_get_clean();

$mailsend = mail($recipient, $subject, $body, join($separator, 
$add_headers));


print($mailsend);

?


Jim,

thanks, well I am still trying to work it out. Your scripts gives me 
this when I run it


--

[EMAIL PROTECTED]
to me
  
show details 9:02 PM
  
  
Reply
  
  
Reply To: [EMAIL PROTECTED]


The following are ip's that have try to attack your system.

table width='150'trtdCountry/tdtd# of Attacks/td/tr/table




And mine is doing this nowe-mails the html code and nothing from the 
db



html
head
titleAttack's on $hostname/title
/head
body
   if ($result) { //if that ran ok, display the record
   echo table width='150'trtd Country /tdtd # of 
Attacks /td/tr;
 
   //fetch and print the records
 
   while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
   echo trtd align='left'$row[0]/tdtddiv 
align='right'$row[1]/div/td/tr;

   }
 
   echo /table;
 
   mysql_free_result ($result); //free up the resources
 
   } else {  //if did not run ok
 
   echo pThis could not be display due to a system 
error. We apologize fore any incovenience./pp. mysql_error() . /p;
 
   }
 
   

Re: [PHP] Help with an error...

2008-07-24 Thread Micah Gersten
It seems like you're still calling functions inside the string.  Instead
of concatenating, try the output buffering like was mentioned before. 
Also, if you want HTML tags in your PHP code, you need to end and start
the PHP tags again, or print them as output in quotes.

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com



Payne wrote:
 Jim Lucas wrote:
 So, to summarize everything said, with my own added notes.

 [EMAIL PROTECTED] wrote:
 Hi,

 I am  currently working on a php script that will be called by cron.
 But I
 have an error that keeps coming up.

 Parse error: syntax error, unexpected T_VARIABLE inmail_report.php on

 What I am trying to do is a simple php script to send me a report
 everynight. Any clues as to why? Also does anyone know of a site
 with mail
 srcipts that are ran on the cli?

 -
 ?php


 The following wont work if you use this from the CLI.  There is not
 remote addr.
 $hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']);

 //This is a simple email to give me the status from yesterday.
 //This connect the script to the db
 require_once('mysql_connect.inc');


 Loose the semi-colon at the end of your SELECT statements.  The mysql
 extension for PHP will add it on its own.

 $query = Select ip, date, time, CONCAT(city, ', ',country) as location
 from ips where country !=' ' and date = current_date() order by
 date,time,country asc;;

 You missed a semi-colon at the end of this line
 $result = mysql_query($query)

 $mailsend = mail([EMAIL PROTECTED],The IP's that Attacked
 $hostname, The following are ip's that have try to attack your
 system.\r\n\r\



 You can't do this within a function call.  Like someone else said,
 you need to run the if/else and while portion before you mail call. 
 Capture that data and then add it to the mail call.

 if ($result) { //if that ran ok, display the record
 echo table width=\'150\'trtd Country
 /tdtd # of
 Attacks
 /td/tr;

 //fetch and print the records

 while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
 echo trtd align=\'left\'$row[0]/tdtddiv
 align=\'right\'$row[1]/div/td/tr;
 }

 echo '/table';

 mysql_free_result ($result); //free up the resources

 } else {  //if did not run ok

 echo 'pThis could not be display due to a system
 error.
 We apologize
 fore any incovenience./pp'. mysql_error() . '/p';

 }

 ,From:[EMAIL PROTECTED] To:[EMAIL PROTECTED]);
 print($mailsend);
 ?





 So here is the code re factored.

 ?php

 # Setup your variables for later use.
 $recipient = '[EMAIL PROTECTED]';
 $subject   = 'The IP\'s that Attacked';
 $add_headers[] = 'From: [EMAIL PROTECTED]';
 $add_headers[] = 'Reply To: [EMAIL PROTECTED]';
 $separator = \r\n;

 //This is a simple email to give me the status from yesterday.
 //This connect the script to the db
 require_once('mysql_connect.inc');

 $query = 
 SELECT   ip,
  date,
  time,
  CONCAT(city, ', ',country) as location
 FROM ips
 WHEREcountry != ''
   ANDdate = current_date()
 ORDER BY date, time, country asc
 ;

 $result = mysql_query($query);

 ob_start();
 echo TXT
 The following are ip's that have try to attack your system.

 TXT;

 //if that ran ok, display the record
 if ($result) {
   echo TABLE

 table width='150'trtdCountry/tdtd# of Attacks/td/tr
 TABLE;

   //fetch and print the records
   while ( $row = mysql_fetch_assoc($result) ) {
 echo ROW
 tr
   td align='left'{$row['ip']}/td
   tddiv align='right'[$row['date']}/div/td
 /tr
 ROW;
   }

 echo '/table';

 //free up the resources
 mysql_free_result ($result);

 } else {
   //if did not run ok
   echo 'pThis could not be display due to a system error.
 We apologize for any incovenience./pp'. mysql_error() . '/p';

 }

 $body = ob_get_clean();

 $mailsend = mail($recipient, $subject, $body, join($separator,
 $add_headers));

 print($mailsend);

 ?

 Jim,

 thanks, well I am still trying to work it out. Your scripts gives me
 this when I run it

 --

 [EMAIL PROTECTED]
 to me
   show details 9:02 PM
 Reply
 Reply To: [EMAIL PROTECTED]

 The following are ip's that have try to attack your system.

 table width='150'trtdCountry/tdtd# of Attacks/td/tr/table


 

 And mine is doing this nowe-mails the html code and nothing from
 the db


 html
 head
 titleAttack's on $hostname/title
 /head
 body
if ($result) { //if that ran ok, display the record
echo table width='150'trtd Country /tdtd #
 of Attacks /td/tr;
 //fetch and print the records
 while ($row = mysql_fetch_array($result,
 MYSQL_NUM)) {
echo trtd 

Re: [PHP] Help with an error...

2008-07-24 Thread Jim Lucas

Payne wrote:

Jim Lucas wrote:

So, to summarize everything said, with my own added notes.

[EMAIL PROTECTED] wrote:

Hi,

I am  currently working on a php script that will be called by cron. 
But I

have an error that keeps coming up.

Parse error: syntax error, unexpected T_VARIABLE inmail_report.php on

What I am trying to do is a simple php script to send me a report
everynight. Any clues as to why? Also does anyone know of a site with 
mail

srcipts that are ran on the cli?

-
?php



The following wont work if you use this from the CLI.  There is not 
remote addr.

$hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']);

//This is a simple email to give me the status from yesterday.
//This connect the script to the db
require_once('mysql_connect.inc');



Loose the semi-colon at the end of your SELECT statements.  The mysql 
extension for PHP will add it on its own.



$query = Select ip, date, time, CONCAT(city, ', ',country) as location
from ips where country !=' ' and date = current_date() order by
date,time,country asc;;


You missed a semi-colon at the end of this line

$result = mysql_query($query)

$mailsend = mail([EMAIL PROTECTED],The IP's that Attacked
$hostname, The following are ip's that have try to attack your
system.\r\n\r\




You can't do this within a function call.  Like someone else said, you 
need to run the if/else and while portion before you mail call.  
Capture that data and then add it to the mail call.



if ($result) { //if that ran ok, display the record
echo table width=\'150\'trtd Country /tdtd 
# of

Attacks
/td/tr;

//fetch and print the records

while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
echo trtd align=\'left\'$row[0]/tdtddiv
align=\'right\'$row[1]/div/td/tr;
}

echo '/table';

mysql_free_result ($result); //free up the resources

} else {  //if did not run ok

echo 'pThis could not be display due to a system 
error.

We apologize
fore any incovenience./pp'. mysql_error() . '/p';

}

,From:[EMAIL PROTECTED] To:[EMAIL PROTECTED]);
print($mailsend);
?






So here is the code re factored.

?php

# Setup your variables for later use.
$recipient = '[EMAIL PROTECTED]';
$subject   = 'The IP\'s that Attacked';
$add_headers[] = 'From: [EMAIL PROTECTED]';
$add_headers[] = 'Reply To: [EMAIL PROTECTED]';
$separator = \r\n;

//This is a simple email to give me the status from yesterday.
//This connect the script to the db
require_once('mysql_connect.inc');

$query = 
SELECT   ip,
 date,
 time,
 CONCAT(city, ', ',country) as location
FROM ips
WHEREcountry != ''
  ANDdate = current_date()
ORDER BY date, time, country asc
;

$result = mysql_query($query);

ob_start();
echo TXT
The following are ip's that have try to attack your system.

TXT;

//if that ran ok, display the record
if ($result) {
  echo TABLE

table width='150'trtdCountry/tdtd# of Attacks/td/tr
TABLE;

  //fetch and print the records
  while ( $row = mysql_fetch_assoc($result) ) {
echo ROW
tr
  td align='left'{$row['ip']}/td
  tddiv align='right'[$row['date']}/div/td
/tr
ROW;
  }

echo '/table';

//free up the resources
mysql_free_result ($result);

} else {
  //if did not run ok
  echo 'pThis could not be display due to a system error.
We apologize for any incovenience./pp'. mysql_error() . '/p';

}

$body = ob_get_clean();

$mailsend = mail($recipient, $subject, $body, join($separator, 
$add_headers));


print($mailsend);

?


Jim,

thanks, well I am still trying to work it out. Your scripts gives me 
this when I run it


--

[EMAIL PROTECTED]
to me
  show details 9:02 PM
Reply
Reply To: [EMAIL PROTECTED]

The following are ip's that have try to attack your system.

table width='150'trtdCountry/tdtd# of Attacks/td/tr/table




And mine is doing this nowe-mails the html code and nothing from the 
db



html
head
titleAttack's on $hostname/title
/head
body
   if ($result) { //if that ran ok, display the record
   echo table width='150'trtd Country /tdtd # of 
Attacks /td/tr;

//fetch and print the records
while ($row = mysql_fetch_array($result, 
MYSQL_NUM)) {
   echo trtd align='left'$row[0]/tdtddiv 
align='right'$row[1]/div/td/tr;

   }
echo /table;
mysql_free_result ($result); //free up the 
resources

} else {  //if did not run ok
echo pThis could not be display due to a 
system error. We apologize fore any incovenience./pp. mysql_error() 
. /p;

}

Re: [PHP] Help with an error...

2008-07-24 Thread Wolf
!-- SNIP --

Here is the updated code 
 

Notice!! 
 $message doesn't contain any PHP code within it
$query only has a single ; within the whole line, right at the end of the ; to 
complete the PHP assignment string.  Placing one inside it will barf the script 
typically.

$headers are all concactenated together, you were overwriting them all with 
your last statement.


?php 
//VAR Are set here 

$hostname = `hostname -f`; 

//This is a simple email to give me the status from yester day. 
//This connect the script to the db 

//To use ',' between e-mail address for multiple recipents 
$to = '[EMAIL PROTECTED]'; 

//Set the Subject here... 
$subject = The IPs that Attacked .$hostname. report from Fyre; 

//Database Set is here... 
require_once('mysql_connect.inc'); 

$query = Select ip, date, time, CONCAT(city, ', ',country) as location from 
ips where country !=' ' and date = current_date() order by date,time,country 
asc; 
$result = mysql_query($query) ; 

if ($result) //if that ran ok, display the record 
{
 $data = table width='150'trth Country /thth # of Attacks 
/th/tr;
 //fetch and print the records 
 while ($row = mysql_fetch_array($result,MYSQL_NUM))
 { 
  $data.= trtd align=left$row[0]/tdtddiv 
align=right$row[1]/div/td/tr; 
 } 
 $data.= /table; 

 mysql_free_result ($result); //free up the resources 
}
else //if did not run ok 
{
 $data=pThis could not be display due to a system error. We apologize fore 
any incovenience./pp.mysql_error()./p; 
} 
mysql_close(); //Close the database connection. 



//The Message goes here 
$message = html 
head 
 titleAttack's on $hostname/title 
/head 
body;
$message .=$data;
$message .=/body 
/html; 

//To Send HTML Mail; The Content-type header must be set 
$headers = 'MIME-Version: 1.0' . \r\n; 
$headers .= 'Content-type: text/html; charset=iso-8859-1' . \r\n; 
$headers .= 'From: FYRE REPORT [EMAIL PROTECTED]'; 

// Mail it 
mail($to, $subject, $message, $headers); 
? 
 

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



[PHP] storing and then displaying HTML for update

2008-07-24 Thread Rod Clay
I'm writing a php application which includes accepting and storing HTML 
for routine display by the application.  All of this seems to be working 
fine.


However, I also want to display the raw HTML for administrators of the 
system to update as necessary.  I just discovered that this does NOT 
seem to be working.  When I attempt to put this raw HTML into a textarea 
field on my page, I get unpredictable results.


There must be a way to do this, since I've seen this done in other php 
applications.  Can someone tell me how to do this?  Is there some way to 
do this other than to put all of this raw HTML into a textarea field, or 
is there some technique for getting it successfully into a textarea 
field?  I'm stumped right now.


Thanks for any help anyone can give me.

Rod

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



[PHP] running base64 code from unknown source

2008-07-24 Thread imar81-report
Hi there,

I may have come into trouble when i tried to use the code i saw on a tutorial 
(http://www.phpeasystep.com/phptu/28.html). 

I am just a newbie in PHP and exploring its functions.

I tried the example:
###
Example
Before encode
?php
echo Hello World;
?

After encoded
?php $_F=__FILE__;$_X='Pz48P3BocA0KNWNoMiAiSDVsbDIgVzJybGQiOw0KPz4=';
eval(base64_decode('JF9YPWJhc2U2NF9kZWNvZGUoJF9YKTskX1g9c3RydHIoJF9YLC
cxMjM0NTZhb3VpZScsJ2FvdWllMTIzNDU2Jyk7JF9SPWVyZWdfcmVwbGFjZSgnX19GS
UxFX18nLCInIi4kX0YuIiciLCRfWCk7ZXZhbCgkX1IpOyRfUj0wOyRfWD0wOw=='));?

###

Not knowing the risk, I have run it and my antivirus prompt me a threat.
I dont know exactly what it have caused to my PC and Server.

Tried decoding it manually, piece by piece, because I am a newbie I am having a 
hard time figuring out the code.

The
$_F=__FILE__; //as is

base64_decode('JF9YPWJhc2U2NF9kZWNvZGUoJF9YKTskX1g9c3RydHIoJF9YLC
cxMjM0NTZhb3VpZScsJ2FvdWllMTIzNDU2Jyk7JF9SPWVyZWdfcmVwbGFjZSgnX19GS
UxFX18nLCInIi4kX0YuIiciLCRfWCk7ZXZhbCgkX1IpOyRfUj0wOyRfWD0wOw==')
== this resulted to this:

$_X=base64_decode($_X);$_X=strtr($_X,'123456aouie','aouie123456');$_R=ereg_replace('__FILE__','.$_F.',$_X);eval($_R);$_R=0;$_X=0;
and the
$_X='Pz48P3BocA0KNWNoMiAiSDVsbDIgVzJybGQiOw0KPz4='; 
==decoding this with the statment: $_X=base64_decode($_X); == ?



I dont know if i am doing it right, but it seems its not just a code that would 
display a Hello World on the screen.

If this is a false code, hope we can do something about it.

Thank you in advance.

ian


Re: [PHP] running base64 code from unknown source

2008-07-24 Thread Ashley M. Kirchner

[EMAIL PROTECTED] wrote:

If this is a false code, hope we can do something about it.
  

   Code works as expected and spits out 'Hello World' as it should.

--
H | It's not a bug - it's an undocumented feature.
 +
 Ashley M. Kirchner mailto:[EMAIL PROTECTED]   .   303.442.6410 x130
 IT Director / SysAdmin / Websmith . 800.441.3873 x130
 Photo Craft Imaging   . 3550 Arapahoe Ave. #6
 http://www.pcraft.com . .  ..   Boulder, CO 80303, U.S.A. 



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



Re: [PHP] storing and then displaying HTML for update

2008-07-24 Thread Chris
Rod Clay wrote:
 I'm writing a php application which includes accepting and storing HTML
 for routine display by the application.  All of this seems to be working
 fine.
 
 However, I also want to display the raw HTML for administrators of the
 system to update as necessary.  I just discovered that this does NOT
 seem to be working.  When I attempt to put this raw HTML into a textarea
 field on my page, I get unpredictable results.

It's probably not being escaped properly when it's being put in the
textarea - which means a  in the content will close the textarea and
start it's own tags etc.

Try:

$textarea_content = htmlspecialchars($content, ENT_QUOTES);

-- 
Postgresql  php tutorials
http://www.designmagick.com/

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



Re: [PHP] storing and then displaying HTML for update

2008-07-24 Thread Daniel Brown
On Fri, Jul 25, 2008 at 12:31 AM, Rod Clay [EMAIL PROTECTED] wrote:

 However, I also want to display the raw HTML for administrators of the
 system to update as necessary.  I just discovered that this does NOT seem to
 be working.  When I attempt to put this raw HTML into a textarea field on my
 page, I get unpredictable results.

What is being displayed in your textarea when you output the raw HTML?

-- 
/Daniel P. Brown
Better prices on dedicated servers:
Intel 2.4GHz/60GB/512MB/2TB $49.99/mo.
Intel 3.06GHz/80GB/1GB/2TB $59.99/mo.
Dedicated servers, VPS, and hosting from $2.50/mo.

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