[PHP] Problem with Javascript:...submit()

2005-10-13 Thread Johan Grobler
while ($row = mysql_fetch_array($sql_result))
{
echoForm name=\.$row['LITERATURE_title'].\ action=\searchlit.php\ 
method=\post\
font face=\arial\ size=\2\
a href=\javascript:.$row['LITERATURE_title']..submit();\ 
.$row['LITERATURE_title']. - .$row['res_fname']. .$row['res_lname']./a
...

Everything works as long as $row['LITERATURE_title'] is one word, see this 
variable contains the names of books, and if the books name is Heaven for 
instance it works fine but as soon as the title is something like PHP for 
Dummies it doesnt work and i get a error on page message, I tried using 
numbers as the form name but then the same thing happens.

Any ways around this?

thanx

Disclaimer
This e-mail transmission contains confidential information,
which is the property of the sender.
The information in this e-mail or attachments thereto is
intended for the attention and use only of the addressee.
Should you have received this e-mail in error, please delete
and destroy it and any attachments thereto immediately.
Under no circumstances will the Cape Peninsula University of
Technology or the sender of this e-mail be liable to any party for
any direct, indirect, special or other consequential damages for any
use of this e-mail.
For the detailed e-mail disclaimer please refer to
http://www.ctech.ac.za/polic or call +27 (0)21 460 3911

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



Re: [PHP] Problem with Javascript:...submit()

2005-10-13 Thread Jasper Bryant-Greene

Johan Grobler wrote:

while ($row = mysql_fetch_array($sql_result)) { echoForm
name=\.$row['LITERATURE_title'].\ action=\searchlit.php\
method=\post\ font face=\arial\ size=\2\ a
href=\javascript:.$row['LITERATURE_title']..submit();\
.$row['LITERATURE_title']. - .$row['res_fname'].
.$row['res_lname']./a ...

Everything works as long as $row['LITERATURE_title'] is one word, see
this variable contains the names of books, and if the books name is
Heaven for instance it works fine but as soon as the title is
something like PHP for Dummies it doesnt work and i get a error on
page message, I tried using numbers as the form name but then the
same thing happens.


If you've got a row ID number or something, just call the form lit[id] 
(replacing [id] with the ID number), because I don't think a form name 
can start with a number. Otherwise you could sha1() the title and use 
that as the identifier, or simply remove all spaces...


--
Jasper Bryant-Greene
Freelance web developer
http://jasper.bryant-greene.name/

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



[PHP] Re: ampersand in dom with utf-8

2005-10-13 Thread cc
both `egrave;' and `icirc;' are not entities in charset utf-8, use
`amp;egrave;' and `amp;icirc;' instead.

On 10/13/05, jonathan [EMAIL PROTECTED] wrote:
 I'm now getting this error:

 XML Parsing Error: undefined entity

 with the following entity at the first ampersand:
 item_namefarm lettuces with reed avocado, cregrave;me
 fraicirc;che, radish and cilantro/item_name

 Why is an ampersand considered an undefined entity? The xml version
 is: ?xml version=1.0?

 Any thoughts please?

 -jonathan

 --
 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] Problem with Javascript:...submit()

2005-10-13 Thread Minuk Choi

I'm just taking a wild guess...

but I'm guessing that if you set a name with spaces, it'll be replaced 
with _(underscore).


A couple of ways around this is to
   1) figure out a way to assign a one-word name for all your 
books(e.g. Code, ID number, etc.)
   2) generate a hash code(e.g. md5($row['LITERATURE_title'])) will 
generate a one word(no spaces).


If this is going to be a library application, you can always use 
ISBNX(no spaces, no dashes), since the idea is that every book 
has a unique ISBN number


Johan Grobler wrote:


while ($row = mysql_fetch_array($sql_result))
{
echoForm name=\.$row['LITERATURE_title'].\ action=\searchlit.php\ 
method=\post\
font face=\arial\ size=\2\
a href=\javascript:.$row['LITERATURE_title']..submit();\ .$row['LITERATURE_title']. - 
.$row['res_fname']. .$row['res_lname']./a
...

Everything works as long as $row['LITERATURE_title'] is one word, see this variable contains the 
names of books, and if the books name is Heaven for instance it works fine but as soon 
as the title is something like PHP for Dummies it doesnt work and i get a error on page 
message, I tried using numbers as the form name but then the same thing happens.

Any ways around this?

thanx

Disclaimer 
This e-mail transmission contains confidential information,

which is the property of the sender.
The information in this e-mail or attachments thereto is 
intended for the attention and use only of the addressee. 
Should you have received this e-mail in error, please delete 
and destroy it and any attachments thereto immediately. 
Under no circumstances will the Cape Peninsula University of 
Technology or the sender of this e-mail be liable to any party for

any direct, indirect, special or other consequential damages for any
use of this e-mail.
For the detailed e-mail disclaimer please refer to 
http://www.ctech.ac.za/polic or call +27 (0)21 460 3911


 



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



[PHP] Re: Removing Items from an Array

2005-10-13 Thread cc
could Alan give samples about the input and expected output of the black box?
then we can consider implement it.

On 10/13/05, Alan Lord [EMAIL PROTECTED] wrote:
 Thanks for the replies gents.

 I have cludged together something from your solutions but it isn't yet
 working. I've been staring at multi-dim arrays all day and am getting
 tired, so I'll carry on tomorrow.

 Thanks again,

 Alan

  -Original Message-
  From: Jochem Maas [mailto:[EMAIL PROTECTED]
  Sent: 12 October 2005 19:18
  To: [EMAIL PROTECTED]
  Cc: php-general@lists.php.net; [EMAIL PROTECTED]
  Subject: Re: [PHP] Removing Items from an Array
 
  Id like to continue where TG left off ...
 
  hth.
 
  [EMAIL PROTECTED] wrote:
   If I understand what you're asking, then maybe this will help:
  
   $arrset1 = array(Apples = 3, Oranges = 5, Apricots = 1);
   $arrset2 = array(Couches = 6, Chairs = 2, Benches = 5);
  
   $alldataarr[Fruits] = $arrset1;
   $alldataarr[Furniture] = $arrset2;
  
   Say we want to remove Chairs, and let's do it the hard way:
  
   foreach ($alldataarr as $key = $data) {
 foreach ($data as $subkey = $subdata) {
   if ($subkey == Chairs) {
 unset($alldataarr[$key][$subkey]);
   }
 }
   }
  
   using foreach $arr as $key = $data you can get the
  key/index name as well as the actual value stored in that
  part of your array.  Then all you have to do is refer back up
  to the main array using the current $key/$subkey values as
  your indexes.
  
 
  $filter = array(
  'Fruits'= array('Apples' = 1, 'Oranges' = 1),
  'Furniture' = array('Couches' = 1, 'Chairs' = 1), );
 
  $alldataarr = array();
  $alldataarr[Fruits] = array(Apples = 3, Oranges = 5,
  Apricots = 1); $alldataarr[Furniture] = array(Couches
  = 6, Chairs = 2, Benches = 5);
 
  foreach ($alldataarr as $key = $data) {
  if (!isset($filter[$key]) {
  // we want it all;.
  continue;
  }
  $alldataarr[$key]= array_intersect_keys($data, $filter[$key]); }
 
 
  // heres one I prepared earlier:
 
 
  /**
* array_intersect_keys()
*^--- the internal function (php5.x+?)
  has no 's'
*
* returns the all the items in the 1st array whose keys are
  found in any of the other arrays
*
* @return array()
*/
  function array_intersect_keys()
  {
   $args   = func_get_args();
   $originalArray  = $args[0];
   $res= array();
 
   if(!is_array($originalArray)) { return $res; }
 
   for($i=1;$icount($args);$i++) {
   if(!is_array($args[$i])) { continue; }
   foreach ($args[$i] as $key = $data) {
   if (isset($originalArray[$key])  !isset($res[$key])) {
   $res[$key] = $originalArray[$key];
   }
   }
   }
 
   return $res;
  }
 
 
 
 
  
   Basic example, but I think you can modify this to work with
  what you're doing.
  
   Let me know if you have any questions about this example.
  
   -TG
  
  
  
   = = = Original message = = =
  
   Hi all,
  
   I'm really struggling here! I have a large, multi-dimensional array
   that I want to clean-up a bit before committing to a database.
  
   I want to remove quite a bit of the array but using the
  KEYs not the
   values. I know the keys I want to keep and I know the keys
  I want to
   get rid of. I want to keep the structure and sequence of
  the array in tact.
  
   All of the array traversing functions in PHP seem to
  either: only work
   on the values, or do not allow the removal of elements of the array!
  
   Can anyone offer a clue bat to a tired old array walker!
  
   Thanks
  
   Alan
  
  
   ___
   Sent by ePrompter, the premier email notification software.
   Free download at http://www.ePrompter.com.
  
 
 

 --
 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] Connecting to MySQL Sever using PHP5

2005-10-13 Thread Jacques
I have just installed PHP5. I am using Windows XP and have already installed 
MySQL.

When I try and make a connection to a database on MySQL via Dreamweaver I 
get the following error message: An unidentified error has occurred.

What could be wrong and how can I fix this problem?

Jacques 

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



[PHP] Re: Connecting to MySQL Sever using PHP5

2005-10-13 Thread Mark Rees
 I have just installed PHP5. I am using Windows XP and have already
installed
 MySQL.

 When I try and make a connection to a database on MySQL via Dreamweaver I
 get the following error message: An unidentified error has occurred.

 What could be wrong

Have a look at this:
http://uk2.php.net/mysql_error

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



Re: [PHP] Re: ampersand in dom with utf-8

2005-10-13 Thread Marcus Bointon

On 13 Oct 2005, at 07:24, cc wrote:


both `egrave;' and `icirc;' are not entities in charset utf-8, use
`amp;egrave;' and `amp;icirc;' instead.


I would expect that to result in unconverted entities in the output.  
If you're intending to send that content as HTML, then I guess that  
would be OK. However, if you're using UTF-8 anyway, why not just use  
the real characters?


Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk

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



[PHP] 404 ErrorDocument in safe mode

2005-10-13 Thread Petr Kodytek

Hallo,

I've problem with 404 ErrorDocument in safe mode on version 5.1.0RC1. I'm using error script to 
redirect nonexisting URLs to pages with content from database (something like mod_rewrite).

After when my webhosting provider upgrades to 5.1.0RC1 my pages returns this 
error message :


*Warning*: Unknown: SAFE MODE Restriction in effect. The script
whose uid is 46790 is not allowed to access
/path/to/404.phtml owned by uid 23708 in *Unknown* on line *0*

*Warning*:  Unknown: failed to open stream: No such file or directory in 
*Unknown* on line *0*

*Warning*:  Unknown: Failed opening '/path/to/404.phtml' for inclusion 
(include_path='.') in *Unknown* on line *0
*
Note : /path/to/404.phtml is not real path, I'm changed it only for illustration

*
*When I'm trying to open 404.phtml script directly from browser everything gone 
OK. Have anyone idea to fix this.
Sorry for my English.

--
Kody

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



Re: [PHP] Small regex help?

2005-10-13 Thread Guy Brom
I ended up using the rewriteCountQuery from PEAR::DB_Pager (attached). 
Thanks all!

function rewriteCountQuery($sql)
{
if (preg_match('/^\s*SELECT\s+\bDISTINCT\b/is', $sql) || 
preg_match('/\s+GROUP\s+BY\s+/is', $sql)) {
return false;
}
$queryCount = preg_replace('/(?:.*)\bFROM\b\s+/Uims', 'SELECT COUNT(*) 
FROM ', $sql, 1);
list($queryCount, ) = preg_split('/\s+ORDER\s+BY\s+/is', $queryCount);
list($queryCount, ) = preg_split('/\bLIMIT\b/is', $queryCount);
return trim($queryCount);
}

Philip Hallstrom [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 Can anyone suggest the correct regex to replace col1,col2... with 
 count(*)
 and strip out everything just before ORDER BY?

 so for this:
 SELECT col1,col2... FROM tbl WHERE filter1 filter2 ORDER BY order1,order2

 I would get this:
 SELECT count(*) FROM tbl WHERE filter1 filter2

 $str = SELECT col1,col2... FROM tbl WHERE filter1 filter2 ORDER BY 
 order1,order2;

 $str = ereg_replace(^SELECT .* FROM (.*) ORDER BY .*,
  SELECT COUNT(*) FROM \\1, $str); 

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



Fw: [PHP] Re: Connecting to MySQL Sever using PHP5

2005-10-13 Thread Mark Rees
Back to the list - please use reply-all
- Original Message -
From: Andreja Simovic [EMAIL PROTECTED]
To: Mark Rees [EMAIL PROTECTED]
Sent: Thursday, October 13, 2005 9:58 AM
Subject: Re: [PHP] Re: Connecting to MySQL Sever using PHP5


 Sometimes this error may ocure
 if you do not place trailing slash in define sites url
 http://localhost/mysite1/
 from my expirience

 - Original Message -
 From: Mark Rees [EMAIL PROTECTED]
 To: php-general@lists.php.net
 Sent: Thursday, October 13, 2005 10:43 AM
 Subject: [PHP] Re: Connecting to MySQL Sever using PHP5


  I have just installed PHP5. I am using Windows XP and have already
  installed
  MySQL.
 
  When I try and make a connection to a database on MySQL via Dreamweaver
I
  get the following error message: An unidentified error has occurred.
 
  What could be wrong
 
  Have a look at this:
  http://uk2.php.net/mysql_error
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
 
  __ NOD32 1.1251 (20051012) Information __
 
  This message was checked by NOD32 antivirus system.
  http://www.eset.com
 
 



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



Re: [PHP] Re: Connecting to MySQL Sever using PHP5

2005-10-13 Thread Andreja Simovic


- Original Message - 
From: Mark Rees [EMAIL PROTECTED]

To: php-general@lists.php.net
Sent: Thursday, October 13, 2005 11:54 AM
Subject: Fw: [PHP] Re: Connecting to MySQL Sever using PHP5



Back to the list - please use reply-all
- Original Message -
From: Andreja Simovic [EMAIL PROTECTED]
To: Mark Rees [EMAIL PROTECTED]
Sent: Thursday, October 13, 2005 9:58 AM
Subject: Re: [PHP] Re: Connecting to MySQL Sever using PHP5



Sometimes this error may ocure
if you do not place trailing slash in define sites url
http://localhost/mysite1/
from my expirience

- Original Message -
From: Mark Rees [EMAIL PROTECTED]
To: php-general@lists.php.net
Sent: Thursday, October 13, 2005 10:43 AM
Subject: [PHP] Re: Connecting to MySQL Sever using PHP5


 I have just installed PHP5. I am using Windows XP and have already
 installed
 MySQL.

 When I try and make a connection to a database on MySQL via 
 Dreamweaver

I

 get the following error message: An unidentified error has occurred.

 What could be wrong

 Have a look at this:
 http://uk2.php.net/mysql_error

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




 __ NOD32 1.1251 (20051012) Information __

 This message was checked by NOD32 antivirus system.
 http://www.eset.com






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




__ NOD32 1.1251 (20051012) Information __

This message was checked by NOD32 antivirus system.
http://www.eset.com




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



Re: [PHP] Trouble moving directory

2005-10-13 Thread Robin Vickery
On 10/13/05, -k. [EMAIL PROTECTED] wrote:
 --- Jasper Bryant-Greene [EMAIL PROTECTED] wrote:
  $source_dir = escapeshellarg( '/some/dir/Dir That Won't Move/' );


 Unfortunately escapeshellarg doesn't work for all cases, it will escape the  
 '  in that example
 but it doesn't escape other characters such as  ) . So...

 $source_dir = escapeshellarg( '/some/dir/Dir That (Won't Move)/' );

 ...fails as well. Any other ideas?

?php
  rename(/some/dir/Dir That (Won't Move)/,  '/some/other/dir/');
?

Or if you must use shell_exec(), use addcslashes() to escape the
annoying characters first.

 -robin

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



Re: [PHP] Re: include file to global scope

2005-10-13 Thread Jochem Maas

cc wrote:

yes, its possible, consider this:

/**
 * @param $file_to_include path to php file you want to get its content
 * @return included contents
 */
function get_output($file_to_include){
  ob_start();
  include $file_to_include;
  return ob_get_clean();
}


this will break if the included file assumes its being included
in the global scope (and/or has functions that assume certain globals
exists - which they would do if the file wasn't included within a
function) ...

which brings the OP back to his original problem :-)



of course, you may extend this function to better fit into your situation.
Good luck.

On 10/12/05, Claudio [EMAIL PROTECTED] wrote:


Is it possible to process the file in second php instance?
An only get its output?

Claudio

--
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] Guide for C programmer

2005-10-13 Thread Turgut Hakkı ÖZDEMİR
I'm looking for a document describing differences between C and PHP,
important points for programmers who already know C,C++, and things that
must be taken care.
I'm googling for about an our but i can't find anything. Any suggestions.?
:)


Re: [PHP] Guide for C programmer

2005-10-13 Thread Jochem Maas

Turgut Hakkı ÖZDEMİR wrote:

I'm looking for a document describing differences between C and PHP,


php is a weak  dynamaically typed, intepreted language - C is not.
(aka 'a world of difference')

the php/zend engine are written in C btw.


important points for programmers who already know C,C++, and things that
must be taken care.
I'm googling for about an our but i can't find anything. Any suggestions.?
:)


if you can write C/C++ then php should be easy to get to grips with.
php tutorials specifically for C/C++ programmers don't really exist AFAICT
because C/C++ programmers generally know more than enough to start using php
without the help of some patronizing tutorial.

but you could read here:
http://php.net
http://php.net/tut.php
http://php.net/manual/en/

that should cover it.





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



Re: [PHP] Guide for C programmer

2005-10-13 Thread Paul Waring
On Thu, Oct 13, 2005 at 02:13:37PM +0300, Turgut Hakk? ?ZDEM?R wrote:
 I'm looking for a document describing differences between C and PHP,
 important points for programmers who already know C,C++, and things that
 must be taken care.
 I'm googling for about an our but i can't find anything. Any suggestions.?

I don't see why anyone would write such a document. Other than sharing a
similar syntax and flow control (curly braces, if/else blocks, while
loops etc.), they're different languages. For a start C is compiled
whereas PHP is interpreted, and you can't just jump between the two. You
also don't have to bother, most of the time, with using the right
variable types in PHP because it will handle conversions automatically.

Paul

-- 
Rogue Tory
http://www.roguetory.org.uk

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



[PHP] Re: ampersand in dom with utf-8

2005-10-13 Thread cc
maybe i should have said: egrave; is not an _xml_ entity.
i m not very sure.
sorry.

`egrave;' is an html entity,
represents the letter `è' in iso-8859-1 charset,
which have ascii value of 0xe8 .

to have it recognized by libxml, there are 3 ways to do this:
1, ?xml version=1.0item_name#e8;/item_name
2, ?xml version=1.0 encoding=iso-8859-1item_nameè/item_name
3, ?xml version=1.0item_nameè/item_name

1 can be saved using either utf-8 encoding or iso-8859-1 encoding;
2 must be saved using iso-8859-1 encoding
3 must be saved using utf-8 encoding ( to have `è' be converted properly)


in php, we can do this:

   $html = html_entity_decode('item_namefarm lettuces with reed
avocado, cregrave;me
fraicirc;che, radish and cilantro/item_name');
   $dom = DomDocument::loadXML(?xml version=\1.0\
encoding=\iso-8859-1\$html);



On 10/13/05, Marcus Bointon [EMAIL PROTECTED] wrote:
 On 13 Oct 2005, at 07:24, cc wrote:

  both `egrave;' and `icirc;' are not entities in charset utf-8, use
  `amp;egrave;' and `amp;icirc;' instead.

 I would expect that to result in unconverted entities in the output.
 If you're intending to send that content as HTML, then I guess that
 would be OK. However, if you're using UTF-8 anyway, why not just use
 the real characters?

 Marcus
 --
 Marcus Bointon
 Synchromedia Limited: Putting you in the picture
 [EMAIL PROTECTED] | http://www.synchromedia.co.uk

 --
 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] Connecting to MySQL Sever using PHP5

2005-10-13 Thread Jay Blanchard
[snip]
I have just installed PHP5. I am using Windows XP and have already installed

MySQL.

When I try and make a connection to a database on MySQL via Dreamweaver I 
get the following error message: An unidentified error has occurred.

What could be wrong and how can I fix this problem?
[/snip]

Since the error is unidentified I'll need to use ESPN to figure it out. My
SWAG is that a solid whack on the top of the box will fix it. Yes, do that.

http://www.catb.org/~esr/faqs/smart-questions.html

What version of MySQL are you using? 

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



[PHP] Re: include file to global scope

2005-10-13 Thread cc
the answer

cc wrote:
 yes, its possible, consider this:

 /**
  * @param $file_to_include path to php file you want to get its content
  * @return included contents
  */
 function get_output($file_to_include){
   ob_start();
   include $file_to_include;
   return ob_get_clean();
 }

is to the question

On 10/12/05, Claudio [EMAIL PROTECTED] wrote:
 Is it possible to process the file in second php instance?
 An only get its output?

 Claudio


to ``Is there a way to include this files to global scope? So that difined vars
and functions are global accesseble?'',

there is another answer,

consider these code,

?php
$ov=1;
function o(){
  $iv=1;
  function i(){
  echo i\n;
  var_dump(get_defined_vars());
}
echo o\n;
var_dump(get_defined_vars());
i();
}

o();
i();
var_dump(get_defined_vars());


On 10/13/05, Jochem Maas [EMAIL PROTECTED] wrote:
 cc wrote:
  yes, its possible, consider this:
 
  /**
   * @param $file_to_include path to php file you want to get its content
   * @return included contents
   */
  function get_output($file_to_include){
ob_start();
include $file_to_include;
return ob_get_clean();
  }

 this will break if the included file assumes its being included
 in the global scope (and/or has functions that assume certain globals
 exists - which they would do if the file wasn't included within a
 function) ...

 which brings the OP back to his original problem :-)

 
  of course, you may extend this function to better fit into your
 situation.
  Good luck.
 
  On 10/12/05, Claudio [EMAIL PROTECTED] wrote:
 
 Is it possible to process the file in second php instance?
 An only get its output?
 
 Claudio
 
 --
 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] PHP Mysql Developer needed in South Africa

2005-10-13 Thread Paul
I have a position open for someone in Johannesburg South Africa with
the following skills.

php
mysql
css
xml
xhtml

Image and artwork a bonus (ImageReady,Photoshop, Paintshop, The gimp)
Flash a bonus

Please email me directly at [EMAIL PROTECTED]

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



Re: [PHP] Re: array_slice and for loop problem

2005-10-13 Thread Rodney Green
Thanks Connor. I changed the line to the following. Is it correct now?
The array $output[] is now being populated. However, when I go to
print the values of the $output array using a foreach loop, it prints
out the word Array for each array item.

$output[] = array_slice ($textArray, $int_range[start][$i],
$int_range[end][$i]);



On 10/12/05, Ethilien [EMAIL PROTECTED] wrote:
 Are you trying to put each return from array_slice into $output as an
 array? You need to replace $output = array_slice... with $output[] =
 array_slice...

 Also, you cannot just echo an array (even of characters). It must be a
 string, or else echo will only produce the output 'Array'.

 Hope this helps,
 -Connor McKay

 Rodney Green wrote:
  Hello,
 
  I'm using a for loop to iterate through an array and slice parts of
  the array and add into another array.
 
  When array_slice is called the variable $i is not being substituted
  with the current value of
  $i and the $output array is empty after running the script. Can
  someone look at the code below and give me a clue as to why this
  substitution is not happening? If I uncomment the echo $i; statement
  the value of $i is printed just fine.
 
  Thanks,
  Rod
 
  Here's my code:
 
 
  $number = count ($int_range[start]);
 //echo $number;
 for ($i = 0; $i = $number; $i++) {
 
//echo $i;
 
 $output = array_slice ($textArray, $int_range[start][$i],
  $int_range[end][$i]);
 
 }
 
 
 
 
 foreach ($output as $value) {
 
echo $value;
  }

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




--
There are 10 kinds of people in this world: those who understand
binary data, and those who
don't.

---
Get Firefox Web Browser at the link below! You won't regret it!
http://tinyurl.com/4cqbv

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



Re: [PHP] Re: array_slice and for loop problem

2005-10-13 Thread Rodney Green
$output[] = array_slice ($textArray, $int_range[start][$i],
$int_range[end][$i]); is creating a multi-dimensional array as
$output. In my foreach loop I was treating $output as a
single-dimensional array. That's why it wasn't working. print_r() is 
my friend. :-)


On 10/13/05, Rodney Green [EMAIL PROTECTED] wrote:
 Thanks Connor. I changed the line to the following. Is it correct now?
 The array $output[] is now being populated. However, when I go to
 print the values of the $output array using a foreach loop, it prints
 out the word Array for each array item.

 $output[] = array_slice ($textArray, $int_range[start][$i],
 $int_range[end][$i]);



 On 10/12/05, Ethilien [EMAIL PROTECTED] wrote:
  Are you trying to put each return from array_slice into $output as an
  array? You need to replace $output = array_slice... with $output[] =
  array_slice...
 
  Also, you cannot just echo an array (even of characters). It must be a
  string, or else echo will only produce the output 'Array'.
 
  Hope this helps,
  -Connor McKay
 
  Rodney Green wrote:
   Hello,
  
   I'm using a for loop to iterate through an array and slice parts of
   the array and add into another array.
  
   When array_slice is called the variable $i is not being substituted
   with the current value of
   $i and the $output array is empty after running the script. Can
   someone look at the code below and give me a clue as to why this
   substitution is not happening? If I uncomment the echo $i; statement
   the value of $i is printed just fine.
  
   Thanks,
   Rod
  
   Here's my code:
  
  
   $number = count ($int_range[start]);
  //echo $number;
  for ($i = 0; $i = $number; $i++) {
  
 //echo $i;
  
  $output = array_slice ($textArray, $int_range[start][$i],
   $int_range[end][$i]);
  
  }
  
  
  
  
  foreach ($output as $value) {
  
 echo $value;
   }
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 


 --
 There are 10 kinds of people in this world: those who understand
 binary data, and those who
 don't.

 ---
 Get Firefox Web Browser at the link below! You won't regret it!
 http://tinyurl.com/4cqbv



--
There are 10 kinds of people in this world: those who understand
binary data, and those who
don't.

---
Get Firefox Web Browser at the link below! You won't regret it!
http://tinyurl.com/4cqbv

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



Re: [PHP] actually the egrave; not the ampersand

2005-10-13 Thread John Nichel

jonathan wrote:
do you then have to do the reverse operation to get it back for  
rendering. Since it was erroring on me during DOM creation, I feel  like 
I'm going around it to put it into a format it likes but then on  
display via XSL transformation, I will have to convert it back. Or am  I 
missing something?


I'm only on the sending end; I don't know if the people I send the 
documents too have to convert it back.  Don't quote me on this, but if 
you're going to display the information in a web browser, *I think* it 
will display the decimal value properly.


--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

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



[PHP] Re: Store a variable name in a database field.

2005-10-13 Thread Al

Liam Delahunty wrote:

I'm sure this is a pretty basic question, but I have searched for a
decent answer and can't find one.

I have a client that want to be able to write newsletters
(newsleters_tbl.email_body) and use fields from his contact table, so
as we grind through the contact list for newsletters subscribers it
may pull out $first_name, or $last_name, or perhaps the address and so
on, and send an individual email and have it in the $email_body field
from another table.

$email_body is a free form text field, and he wants to be able to type
in anything he desires and have it pulled from the contact table.

I've tried with and without addslashes, and htmlentities. Is there a
solution or I will I have to resort to getting him to use
{{$first_name}} etc.

Lastly, if I have to use {{whatever}} then what's the reason I can't
use $field_name in the database?

--
Kind regards,
Liam Delahunty


Consider using serialize().  It's simple and foolproof.  Read the manual on 
Serialize Objects.

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



[PHP] function to compare ip addr to a ip range

2005-10-13 Thread Bosky, Dave
Does anyone have a function that will check if an ip address falls with
a starting/ending ip address range

 

Thanks,

Dave

 

 


**
HTC Disclaimer:  The information contained in this message may be privileged 
and confidential and protected from disclosure. If the reader of this message 
is not the intended recipient, or an employee or agent responsible for 
delivering this message to the intended recipient, you are hereby notified that 
any dissemination, distribution or copying of this communication is strictly 
prohibited.  If you have received this communication in error, please notify us 
immediately by replying to the message and deleting it from your computer.  
Thank you.
**



Re: [PHP] Store a variable name in a database field.

2005-10-13 Thread Liam Delahunty
On 10/10/05, Richard Lynch [EMAIL PROTECTED] wrote:
  $email_body is a free form text field, and he wants to be able to type
  in anything he desires and have it pulled from the contact table.
 

Firstly please accept my aplogies for the deay in responding to your
questions, I;ve had the most terrible flu.

pseudo code (ish), as I've completely bastardised what I had when I
posed the question.

// insert newsletter into newsleter_tbl in database ...
from a form, body in a textarea field, client wants to type in
whatever he likes with database column names as varibles, eg $email,
$first_name


this is the newsletter write on newsletter_new.php

if ($submit){
// removed error checking etc

$email_subject = htmlentities(addslashes($email_subject));
// tried various combintions of htmlentities, addslashes and nothing
when writting field to DB
if ($email_style == 1){
  $email_body = htmlentities(addslashes($email_body));
}else{
  $email_body = addslashes($email_body);
}
$email_style = htmlentities(addslashes($email_style));

$query = INSERT INTO newsletters_tbl (email_subject, email_body,
email_date, email_style) VALUES ('$email_subject', '$email_body',
NOW(), '$email_style');
if ($result = mysql_query($query, $connection)) {
  $newsletter_id= mysql_insert_id($connection);
  print (pbSuccess/b Add newsletter (# $newsletter_id)
successful. /p\n);
  print (pa
href=\newsletter_test.php?this_nid=$newsletter_idamp;sid=$sidamp;page=$page\CLICK
HERE TO TEST/td/p\n);
} else {
  printf (pbError: %s\n, mysql_errno () . /bbr);
  printf (%s\n, mysql_error () . br);
  print ($query/p\n);
}
  }
}

// BTW the contact details are in another table in database already.

// Sending out the newsletter
$nquery= SELECT c.id, first_name, email FROM contact_tbl c LEFT OUTER
JOIN newsletters_contacts_tbl nct ON nct.contact_id =c.id AND
newsletter_id = '$this_nid' WHERE nct.contact_id IS NULL AND
newsletter = '$email_style' GROUP BY email LIMIT 1;
if ($nresult = mysql_query($nquery, $connection)){
  if (mysql_num_rows($nresult)  0){
while ($myrow = mysql_fetch_row($nresult)) {
  $uid=$myrow[0];
  $first_name=stripslashes($myrow[1]);
  $email=stripslashes($myrow[2]);

  $query = SELECT * FROM newsletters_tbl WHERE id = '$this_nid' ;
  $result = mysql_query($query, $connection);
  if($result){
while ($myrow = mysql_fetch_row($result)){
  $newsletter_id = $myrow[0];
  $email_subject = stripslashes($myrow[1]);
  $email_body = stripslashes($myrow[2]);
  $email_date = $myrow[3];
  $email_style = $myrow[4];
  $email_status = $myrow[5];
}
if ($email_status == 0){
  print (pRequires Confirmation/p);
}elseif($email_status == 1){

  /*
  // NOW USING {{ }} as in many templating systems
  // so familar to those sorts of users.
  // would prefer if I could just use $columnName from
  // contact_tbl.
  // Why doesn't it just know the var as we've already
  // got it above...?
  */

  $email_body = ereg_replace (\{\{uid\}\}, $uid, $email_body);
  $email_body = ereg_replace (\{\{email\}\}, $email, $email_body);
  $email_body = ereg_replace (\{\{first_name\}\},
$first_name, $email_body);

  if ($email_style == 1){
// INSERT PLAIN TEXT HEADER
  }elseif ($email_style == 2){
// INSERT HTML MIME HEADERS
  }

  $outquery=INSERT INTO newsletters_contacts_tbl
(newsletter_id, contact_id, sent_date) VALUES ('$newsletter_id',
'$uid', NOW());
  if ($outresult = mysql_query($outquery, $connection)) {
// SEND IT CODE
  } else {
// ERROR CODE
  }
  }
}
  }
}else{
  // ERROR CODE
}


Many thanks for your help on this mater.

--
Kind regards,
Liam

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



[PHP] RE: Removing Items from an Array - My Solution

2005-10-13 Thread Alan Lord
Hi cc and others.

I have had quite a struggle with this. But finally, the end result looks
quite 
simple...

Here is the array of Keys Names I want to preserve:

$filter = array(
   'CategoryId' = 1, 'CategoryLevel' = 1, 'CategoryName' = 1,
'CategoryParentId' = 1
);

Here is the routine which (for ease, creates a new array containing only
the array 
keys contained in $filter:

foreach ($orig_arr as $key = $data) {

   if (is_array($data)) {
   foreach ($data as $subkey = $subdata) {
 if (isset($filter[$subkey])) {
 $sub_arr[$subkey] = $subdata;
 }
  }
   }
   $new_arr[] = $sub_arr;
}

$new_arr has just what I need :-)

This only works on a two dimensional array. But with a bit of tweaking
and turing 
into a function, it could probably be used on any number of dimensions
by making 
it recursive?

Thanks to the contributors who supplied ideas and knowledge..

If anyone thinks this could be done a better way, please feel free to
comment! 

Alan

 -Original Message-
 From: cc [mailto:[EMAIL PROTECTED] 
 Sent: 13 October 2005 07:43
 To: Alan Lord
 Cc: php-general@lists.php.net
 Subject: Re: Removing Items from an Array
 
 could Alan give samples about the input and expected output 
 of the black box?
 then we can consider implement it.
 
 On 10/13/05, Alan Lord [EMAIL PROTECTED] wrote:
  Thanks for the replies gents.
 
  I have cludged together something from your solutions but 
 it isn't yet 
  working. I've been staring at multi-dim arrays all day and 
 am getting 
  tired, so I'll carry on tomorrow.
 
  Thanks again,
 
  Alan
 
   -Original Message-
   From: Jochem Maas [mailto:[EMAIL PROTECTED]
   Sent: 12 October 2005 19:18
   To: [EMAIL PROTECTED]
   Cc: php-general@lists.php.net; [EMAIL PROTECTED]
   Subject: Re: [PHP] Removing Items from an Array
  
   Id like to continue where TG left off ...
  
   hth.
  
   [EMAIL PROTECTED] wrote:
If I understand what you're asking, then maybe this will help:
   
$arrset1 = array(Apples = 3, Oranges = 5, 
 Apricots = 1);
$arrset2 = array(Couches = 6, Chairs = 2, Benches = 5);
   
$alldataarr[Fruits] = $arrset1;
$alldataarr[Furniture] = $arrset2;
   
Say we want to remove Chairs, and let's do it the hard way:
   
foreach ($alldataarr as $key = $data) {
  foreach ($data as $subkey = $subdata) {
if ($subkey == Chairs) {
  unset($alldataarr[$key][$subkey]);
}
  }
}
   
using foreach $arr as $key = $data you can get the
   key/index name as well as the actual value stored in that part of 
   your array.  Then all you have to do is refer back up to the main 
   array using the current $key/$subkey values as your indexes.
   
  
   $filter = array(
 'Fruits'= array('Apples' = 1, 'Oranges' = 1),
 'Furniture' = array('Couches' = 1, 'Chairs' = 1), );
  
   $alldataarr = array();
   $alldataarr[Fruits] = array(Apples = 3, Oranges = 5, 
   Apricots = 1); $alldataarr[Furniture] = array(Couches
   = 6, Chairs = 2, Benches = 5);
  
   foreach ($alldataarr as $key = $data) {
   if (!isset($filter[$key]) {
 // we want it all;.
 continue;
   }
   $alldataarr[$key]= array_intersect_keys($data, 
 $filter[$key]); }
  
  
   // heres one I prepared earlier:
  
  
   /**
 * array_intersect_keys()
 *^--- the internal function (php5.x+?)
   has no 's'
 *
 * returns the all the items in the 1st array whose keys 
 are found 
   in any of the other arrays
 *
 * @return array()
 */
   function array_intersect_keys()
   {
$args   = func_get_args();
$originalArray  = $args[0];
$res= array();
  
if(!is_array($originalArray)) { return $res; }
  
for($i=1;$icount($args);$i++) {
if(!is_array($args[$i])) { continue; }
foreach ($args[$i] as $key = $data) {
if (isset($originalArray[$key])  
 !isset($res[$key])) {
$res[$key] = $originalArray[$key];
}
}
}
  
return $res;
   }
  
  
  
  
   
Basic example, but I think you can modify this to work with
   what you're doing.
   
Let me know if you have any questions about this example.
   
-TG
   
   
   
= = = Original message = = =
   
Hi all,
   
I'm really struggling here! I have a large, multi-dimensional 
array that I want to clean-up a bit before committing 
 to a database.
   
I want to remove quite a bit of the array but using the
   KEYs not the
values. I know the keys I want to keep and I know the keys
   I want to
get rid of. I want to keep the structure and sequence of
   the array in tact.
   
All of the array traversing functions in PHP seem to
   either: only work
on the values, or do not allow the removal of elements 
 of the array!
   
Can anyone offer a clue bat to a tired old array walker!
   
Thanks
   
Alan
   
   

Re: [PHP] function to compare ip addr to a ip range

2005-10-13 Thread Greg Donald
On 10/13/05, Bosky, Dave [EMAIL PROTECTED] wrote:
 Does anyone have a function that will check if an ip address falls with
 a starting/ending ip address range


#!/usr/bin/php
?php

$ip = '10.0.0.1';
$ip2 = '10.0.0.2';
$ip3 = '10.0.0.3';

$ip = abs( ip2long( $ip ) );
$ip2 = abs( ip2long( $ip2 ) );
$ip3 = abs( ip2long( $ip3 ) );

if( $ip2  $ip  $ip2  $ip3
|| $ip2  $ip  $ip2  $ip3 )
{
echo In range\n;
}
else
{
echo Not in range\n;
}

?

--
Greg Donald
Zend Certified Engineer
MySQL Core Certification
http://destiney.com/


Re: [PHP] Any good free easy converting tool?

2005-10-13 Thread Leif Gregory
Hello Gustav,

Wednesday, October 12, 2005, 12:55:11 PM, you wrote:
 Someone know of any good free tool for converting from Access to
 Mysql. I just need to import certain tables into an already
 existance database.

DBTools (freeware)
http://www.dbtools.com.br/

I use it quite a bit.

-- 
  TBUDL/BETA/DEV/TECH Lists Moderator / PGP 0x6C0AB16B
 __       Geocaching:http://gps.PCWize.com
(  )  ( ___)(_  _)( ___)  TBUDP Wiki Site:  http://www.PCWize.com/thebat/tbudp
 )(__  )__)  _)(_  )__)   Roguemoticons  Smileys:http://PCWize.com/thebat
()()()(__)PHP Tutorials and snippets:http://www.DevTek.org

MCSE == Minesweeper Consultant / Solitaire Expert

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



[PHP] What's the safest way to destory/wipe out the arrays within the associative arrays?

2005-10-13 Thread Scott Fletcher
[code]
$xml = array
(
  'NEWSFEED' = array
  (
'0' = array
(
  'MESSAGE' = array
  (
'0' = array
(
  'ATTRIBUTES' = array
  (
'ID' = 'test2',
'TID' = 'test4'
  ),
  'TITLE' = array
  (
'0' = array
(
   'VALUE' = 'Title #1'
),
'1' = array
(
   'VALUE' = 'Title #2'
)
  ),
   'BODY' = array
  (
'0' = array ( 'VALUE' = 'Body #1' )
  ),
  'REFERENCE' = array
  (
'0' = array ( 'VALUE' = 'Reference #1' )
  )
),
'1' = array
(
  'TITLE' = array
  (
'0' = array ( 'VALUE' = 'Title #2' )
  ),
  'BODY' = array
  (
'0' = array ( 'VALUE' = 'Body #2' )
  ),
),
'2' = array
(
  'ATTRIBUTES' = array
  (
'ID' = 'test3'
  ),
  'BODY' = array
  (
'0' = array ( 'VALUE' = 'Body #3' )
  ),
)
  )
)
  ),
 );

echo $xml['NEWSFEED']['0']['MESSAGE']['0']['BODY'];
echo $xml['NEWSFEED']['0']['MESSAGE']['1']['BODY'];
echo $xml['NEWSFEED']['0']['MESSAGE']['2']['BODY'];[/code]

What is the safest way to destroy or take out the
$xml['NEWSFEED']['0']['MESSAGE']['2']. associative arrays starting with
['2'] and those arrays inside of the ['2'] array path?

The unset() would make it not possible to reassign the data to this array
once again, that is what I do not want.

Thanks,
FletchSOD

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



Re: [PHP] chown function

2005-10-13 Thread Scott Fletcher
Well, apache use the nobody:nobody permission...

Keith Spiller [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Hi Jasper,

 When using my Php script, I don't see any error messages.

 I have logged in using SSH, but the directories created are
 owned by 48 and not my ftp user and so I have to switch
 to a super user to make any changes.

 Also, even though I use:
 mkdir($endpath, 0777);
 The resulting directories end up as 755.

 Yeah I have a feeling that you are right, that apache on
 my server does not have chown permissions.

 Thank you very mych for your help.


 Keith

 - Original Message - 
 From: Jasper Bryant-Greene [EMAIL PROTECTED]
 To: php-general@lists.php.net
 Sent: Monday, October 03, 2005 11:27 PM
 Subject: Re: [PHP] chown function


  Keith Spiller wrote:
  I'm using:
 
  chown($endpath, admin);
 
  to try to change the owner of directories after using mkdir()
  to create them.  It continues to fail on my remote Fedora server.
 
  With what error message? Have you tried logging in with SSH or similar
and
  trying the same command?
 
  More than likely the user apache is running as doesn't have permissions
to
  chown -- in fact I believe that in order to chown files one must be root
  (at least that's the way it seems to work on my system).
 
  You could use chmod instead to allow the admin user access to your
  files.
 
  -- 
  Jasper Bryant-Greene
  Freelance web developer
  http://jasper.bryant-greene.name/
 
  -- 
  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] How to automate php with crontab?

2005-10-13 Thread Scott Fletcher
Then do something like this...

0,5,10,15,20,25,30,35,40,45,50,55 * * * *
/usr/local/bin/inquiry_pull_test.php

in the crontab file  Depending on your situation, you might will need to
add or not add the #!/usr/local/bin/php at the top of the php scripts...
I don't know if your php script is a shell script or not so I'm just brought
that up.

FletchSOD

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



Re: [PHP] chown function

2005-10-13 Thread John Nichel

Scott Fletcher wrote:

Well, apache use the nobody:nobody permission...


Apache runs whatever you configure user:group to be.  Default is 
nobody:nobody.


--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

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



Re: [PHP] How to automate php with crontab?

2005-10-13 Thread Greg Donald
On 10/5/05, Scott Fletcher [EMAIL PROTECTED] wrote:
 Then do something like this...

 0,5,10,15,20,25,30,35,40,45,50,55 * * * *
 /usr/local/bin/inquiry_pull_test.php

Or more simply: */5


--
Greg Donald
Zend Certified Engineer
MySQL Core Certification
http://destiney.com/


Re: [PHP] How to automate php with crontab?

2005-10-13 Thread John Nichel

Scott Fletcher wrote:

Then do something like this...

0,5,10,15,20,25,30,35,40,45,50,55 * * * *
/usr/local/bin/inquiry_pull_test.php


Or just...

*/5 * * * * /path/to/script.php

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

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



Re: [PHP] How to automate php with crontab?

2005-10-13 Thread John Nichel

Greg Donald wrote:

On 10/5/05, Scott Fletcher [EMAIL PROTECTED] wrote:


Then do something like this...

0,5,10,15,20,25,30,35,40,45,50,55 * * * *
/usr/local/bin/inquiry_pull_test.php



Or more simply: */5


Jinx.  ;)

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

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



Re: [PHP] What's the safest way to destory/wipe out the arrays within the associative arrays?

2005-10-13 Thread Paul Waring
On Wed, Oct 05, 2005 at 03:12:51PM -0400, Scott Fletcher wrote:
 What is the safest way to destroy or take out the
 $xml['NEWSFEED']['0']['MESSAGE']['2']. associative arrays starting with
 ['2'] and those arrays inside of the ['2'] array path?
 
 The unset() would make it not possible to reassign the data to this array
 once again, that is what I do not want.

Could you not just do:

$xml['NEWSFEED']['0']['MESSAGE']['2'] = null;

I think that would still keep the array element open, but there would be
no data there.

Paul

-- 
Rogue Tory
http://www.roguetory.org.uk

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



[PHP] Re: [PHP-WIN] Re: [PHP] Removing Items from an Array

2005-10-13 Thread tg-php
That works just as well, if you have only two levels of depth.  Mostly I was 
trying to illustrate how to use $key = $value in a foreach and what to do if 
you need to go multiple levels down.  Once you get to the bottom level, then 
you can use isset() certainly.

Just wanted to make sure that it was clear what to do with $key and $subkey 
relating to the main array ($alldataarr in this example)

-TG

= = = Original message = = =

Well to give my .02 here. 

Why even go through the second foreach? By doing this you are making your code 
very inefficient in
that it must read through the entire set of arrays. Sure it works fine if you 
have only a few. But
if there are a few thousand it takes longer.

As the arrays are structures you have the key (Apples, Oranges, Apricots, 
Couches,
Chairs, Benches)

so why not just something like:

?php
$arrset1 = array(Apples = 3, Oranges = 5, Apricots = 1);
$arrset2 = array(Couches = 6, Chairs = 2, Benches = 5);

$alldataarr[Fruits] = $arrset1;
$alldataarr[Furniture] = $arrset2;

//Say we want to remove Chairs, and let's do it the hard way:

// Debug
//echo initial arraypre;
//print_r($alldataarr);
//echo /pre;

$delete_key = Chairs;
foreach ($alldataarr as $key = $data) 

  ~if (isset($alldataarr[$key][$delete_key]))
  ~
~~unset($alldataarr[$key][$delete_key]);
  ~


// Debug
//echo after arraypre;
//print_r($alldataarr);
//echo /pre;

?


--- [EMAIL PROTECTED] wrote:

 Thanks for the addition Jochem..  one reason I post here, even if it's a 
 basic example, is
 because if there's a better way or a chance to learn something new, I want to 
 have that
 opportunity.  Thanks again!
 
 -TG
 
 = = = Original message = = =
 
 Id like to continue where TG left off ...
 
 hth.
 
 [EMAIL PROTECTED] wrote:
  If I understand what you're asking, then maybe this will help:
  
  $arrset1 = array(Apples = 3, Oranges = 5, Apricots = 1);
  $arrset2 = array(Couches = 6, Chairs = 2, Benches = 5);
  
  $alldataarr[Fruits] = $arrset1;
  $alldataarr[Furniture] = $arrset2;
  
  Say we want to remove Chairs, and let's do it the hard way:
  
  foreach ($alldataarr as $key = $data) 
foreach ($data as $subkey = $subdata) 
  if ($subkey == Chairs) 
unset($alldataarr[$key][$subkey]);
  

  
  
  using foreach $arr as $key = $data you can get the key/index name as well 
  as the actual value
 stored in that part of your array.  Then all you have to do is refer back up 
 to the main array
 using the current $key/$subkey values as your indexes.
  
 
 $filter = array(
 ~'Fruits'= array('Apples' = 1, 'Oranges' = 1),
 ~'Furniture' = array('Couches' = 1, 'Chairs' = 1),
 );
 
 $alldataarr = array();
 $alldataarr[Fruits] = array(Apples = 3, Oranges = 5, Apricots = 1);
 $alldataarr[Furniture] = array(Couches = 6, Chairs = 2, Benches = 
 5);
 
 foreach ($alldataarr as $key = $data) 
 if (!isset($filter[$key]) 
 ~// we want it all;.
 ~continue;
 
 $alldataarr[$key]= array_intersect_keys($data, $filter[$key]);
 
 
 
 // heres one I prepared earlier:
 
 
 /**
   * array_intersect_keys()
   *^--- the internal function (php5.x+?) has no 's'
   *
   * returns the all the items in the 1st array whose keys are found in any of 
 the other arrays
   *
   * @return array()
   */
 function array_intersect_keys()
 
  $args   = func_get_args();
  $originalArray  = $args[0];
  $res= array();
 
  if(!is_array($originalArray))  return $res; 
 
  for($i=1;$icount($args);$i++) 
  if(!is_array($args[$i]))  continue; 
  foreach ($args[$i] as $key = $data) 
  if (isset($originalArray[$key])  !isset($res[$key])) 
  $res[$key] = $originalArray[$key];
  
  
  
 
  return $res;
 
 
 
 
 
  
  Basic example, but I think you can modify this to work with what you're 
  doing.
  
  Let me know if you have any questions about this example.
  
  -TG
  
  
  
  = = = Original message = = =
  
  Hi all,
  
  I'm really struggling here! I have a large, multi-dimensional array that
  I want to clean-up a bit before committing to a database.
  
  I want to remove quite a bit of the array but using the KEYs not the
  values. I know the keys I want to keep and I know the keys I want to get
  rid of. I want to keep the structure and sequence of the array in tact. 
  
  All of the array traversing functions in PHP seem to either: only work
  on the values, or do not allow the removal of elements of the array!
  
  Can anyone offer a clue bat to a tired old array walker!
  
  Thanks
  
  Alan
  
  
  ___
  Sent by ePrompter, the premier email notification software.
  Free download at http://www.ePrompter.com.
 
 
 
 ___
 Sent by ePrompter, the premier email notification software.
 Free download at http://www.ePrompter.com.
 
 -- 
 PHP Windows Mailing List 

Re: [PHP] function to compare ip addr to a ip range

2005-10-13 Thread tg-php
You could try converting to long IP addresses and comparing that way:

?php

// To actually get the long IP address that you can use in http://
// you sometimes need to use something like printf(%u\n, ip2long($ip));

// See also:  http://us3.php.net/manual/en/function.ip2long.php

$startip = 192.168.0.5;
$endip   = 192.168.0.16;
$targetip = 192.168.0.7;

$startlong = ip2long($startip);
$endlong   = ip2long($endip);
$targetlong = ip2long($targetip);

if ($startlong = $targetlong AND $targetlong = $endlong) 
  echo within range;
 else 
  echo out of range;


?

= = = Original message = = =

Does anyone have a function that will check if an ip address falls with
a starting/ending ip address range

 

Thanks,

Dave


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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



Re: [PHP] Is DOM the right thing for the job?

2005-10-13 Thread Stephen Leaf
On Thursday 13 October 2005 12:30 am, Chris wrote:
 Snag #1)
 The DOMDocument seems to represent an entire page, all I'd like to do is
 represent a Form tag and it's internal HTML. I can actually get it to
 work that way, but it seems like it's the wrong way to go about things.
being how XML works you can only have 1 Document Node. So I don't see how this 
would be an issue.
You can however create a form DOM Element. it will  be associated with the 
document node however again you can't really have more than 1 to begin with 
so?


 Snag #2)
 The creation of a DOMElement object is very limited without being
 associated with a DOMDocument, I'd like to create an independent
 DOMElement inside the Element class, including possible sub-DOMElements,
 without having to create the DOMDocument in the Form object..
Why? I don't see any reason to have an Element be separate from the main 
Document?
Even tho it will be associated with that Document. you still have full access 
as to where it goes.
you could even make that form the main node.

$form = DOMDocument('form');


 I realize after writing this that these don't seem like very serious
 snags, but I jsut dont' have a fuzzy feeling about the way this would
 work if I implemented it knowing what I've stated here. Any assistance
 would be greatly appreciated.

 Thanks!
 Chris

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



[PHP] Can't compare a decrypted variable to a string ?

2005-10-13 Thread Graham Anderson

For some reason,
I have to store a decrypted string as a variable before I can compare  
it to another string.


The decrypt function is located in another php script

//Get variable
$cmd = $_REQUEST['cmd'];

echo $cmd; //  uJy4p09z6bSR80eLNFnBWBj/EsRCfIz2C/WrcFNcZE8=
echo decrypt($cmd);// makesmil

 $realcmd =  decrypt($cmd); // 'makesmil'

if(decrypt($cmd)=='makesmil')makesmil 
();  // FAILS
elseif(decrypt($cmd)==$realcmd)makesmil(); // 
SUCCEEDS


I'm sure it is something stupid

what am I doing wrong ?
g

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



Re: [PHP] Problem with Javascript:...submit()

2005-10-13 Thread Stephen Leaf
On Thursday 13 October 2005 01:13 am, Johan Grobler wrote:
 while ($row = mysql_fetch_array($sql_result))
 {
 echoForm name=\.$row['LITERATURE_title'].\ action=\searchlit.php\
 method=\post\ font face=\arial\ size=\2\
 a href=\javascript:.$row['LITERATURE_title']..submit();\
 .$row['LITERATURE_title']. - .$row['res_fname'].
 .$row['res_lname']./a ...

 Everything works as long as $row['LITERATURE_title'] is one word, see this
 variable contains the names of books, and if the books name is Heaven for
 instance it works fine but as soon as the title is something like PHP for
 Dummies it doesnt work and i get a error on page message, I tried using
 numbers as the form name but then the same thing happens.
Another way you can access these is by using this function.

document.getElementByName('name');
or
document.getElementById('id');

As I recall w3 sees ByName as standard but Mozilla(and many others) only 
support ById, the last time I checked.


 Any ways around this?

 thanx
 
 Disclaimer
 This e-mail transmission contains confidential information,
 which is the property of the sender.
 The information in this e-mail or attachments thereto is
 intended for the attention and use only of the addressee.
 Should you have received this e-mail in error, please delete
 and destroy it and any attachments thereto immediately.
 Under no circumstances will the Cape Peninsula University of
 Technology or the sender of this e-mail be liable to any party for
 any direct, indirect, special or other consequential damages for any
 use of this e-mail.
 For the detailed e-mail disclaimer please refer to
 http://www.ctech.ac.za/polic or call +27 (0)21 460 3911

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



[PHP] Social Networking

2005-10-13 Thread JM
Hi all,
I've been looking for social networking software like you see on
myspace.comhttp://myspace.comor
hi5.com http://hi5.com. Does anyone know of any? I'd like to check out
some freeware first. TIA.
 JM


[PHP] Trouble figuring out a Walk through an Array

2005-10-13 Thread Phillip S. Baker
Greetings All,

Having trouble figureing out a certain walk through an array.
And I am not finding the help I need in the manual or anything.

I have an associative arr ($arr) With about 20 elements in it.
Ten of which are required. So I have another associative array called
$required, with all the elements in the array that are required.

I have initaited a foreach loop on the $arr splitting things into $key and
$value.

Now the part I am having trouble with is this.

I want to see if $key matches any of the values in $required. If so do
something in particular. If not then do something else. It does not
particularly matter which value in the $required it matches, just so long as
it matches.

Thanks for any help.

Phillip

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



Re: [PHP] Trouble figuring out a Walk through an Array

2005-10-13 Thread Greg Donald
On 10/13/05, Phillip S. Baker [EMAIL PROTECTED] wrote:
 I want to see if $key matches any of the values in $required. If so do
 something in particular. If not then do something else. It does not
 particularly matter which value in the $required it matches, just so long as
 it matches.

in_array()


--
Greg Donald
Zend Certified Engineer
MySQL Core Certification
http://destiney.com/


[PHP] Trouble figuring out a Walk through an Array

2005-10-13 Thread Phillip S. Baker
Greetings All,

Having trouble figureing out a certain walk through an array.
And I am not finding the help I need in the manual or anything.

I have an associative arr ($arr) With about 20 elements in it.
Ten of which are required. So I have another associative array called
$required, with all the elements in the array that are required.

I have initaited a foreach loop on the $arr splitting things into $key and
$value.

Now the part I am having trouble with is this.

I want to see if $key matches any of the values in $required. If so do
something in particular. If not then do something else. It does not
particularly matter which value in the $required it matches, just so long as
it matches.

Thanks for any help.

Phillip

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



Re: [PHP] Trouble figuring out a Walk through an Array

2005-10-13 Thread Richard Davey
Hi Phillip,

Thursday, October 13, 2005, 4:56:30 PM, you wrote:

 Having trouble figureing out a certain walk through an array.
 And I am not finding the help I need in the manual or anything.

 I have an associative arr ($arr) With about 20 elements in it.
 Ten of which are required. So I have another associative array called
 $required, with all the elements in the array that are required.

 I have initaited a foreach loop on the $arr splitting things into $key and
 $value.

 Now the part I am having trouble with is this.

 I want to see if $key matches any of the values in $required. If so do
 something in particular. If not then do something else. It does not
 particularly matter which value in the $required it matches, just so long as
 it matches.

While for-eaching through your $arr you could simply do an:

if (in_array($key, $required))

Unless you need something more complex than this?

Cheers,

Rich
-- 
Zend Certified Engineer
http://www.launchcode.co.uk

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



Re: [PHP] Can't compare a decrypted variable to a string ?

2005-10-13 Thread Robin Vickery
On 10/13/05, Graham Anderson [EMAIL PROTECTED] wrote:

   $realcmd =  decrypt($cmd);
[...]
  elseif(decrypt($cmd) == $realcmd)

That's obviously going to succeed no matter what $cmd decrypts into.
It doesn't really tell you anything useful.

   $realcmd =  decrypt($cmd); // 'makesmil'
[...]
  if( decrypt($cmd) == 'makesmil')

If this really fails, it means that $cmd doesn't decrypt into
'makesmil'.  Are you sure that it's not been padded with spaces or
something?

 -robin

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



[PHP] Trouble figuring out a Walk through an Array

2005-10-13 Thread Phillip S. Baker
Greetings All,

Having trouble figureing out a certain walk through an array.
And I am not finding the help I need in the manual or anything.

I have an associative arr ($arr) With about 20 elements in it.
Ten of which are required. So I have another associative array called
$required, with all the elements in the array that are required.

I have initaited a foreach loop on the $arr splitting things into $key and
$value.

Now the part I am having trouble with is this.

I want to see if $key matches any of the values in $required. If so do
something in particular. If not then do something else. It does not
particularly matter which value in the $required it matches, just so long as
it matches.

Thanks for any help.

Phillip

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



Re: [PHP] function to compare ip addr to a ip range

2005-10-13 Thread Richard Lynch
On Thu, October 13, 2005 9:26 am, Bosky, Dave wrote:
 Does anyone have a function that will check if an ip address falls
 with
 a starting/ending ip address range

If you are using PostgreSQL, it has a built-in IP address data type
which almost for sure does this. :-)

Maybe what you want to do is just convert the IP to an integer.

function ipd($ip){
  list($a, $b, $c, $c) = explode('.', $ip);
  $ipd = $a * 0x100 + $b * 0x1 + $c * 0x100 + $d;
  return $ipd;
}

Now you can just compare idp() of any IP addresses to see if they are
in a 'range'

There's probably a better way.

And you should probably use bit-shifting operators ( and ) insted
of my * 0x100 method, as it might be faster.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] Can't compare a decrypted variable to a string ?

2005-10-13 Thread Jochem Maas

Graham Anderson wrote:

For some reason,
I have to store a decrypted string as a variable before I can compare  
it to another string.


The decrypt function is located in another php script

//Get variable
$cmd = $_REQUEST['cmd'];

echo $cmd; //  uJy4p09z6bSR80eLNFnBWBj/EsRCfIz2C/WrcFNcZE8=
echo decrypt($cmd);// makesmil


try
var_dump() or print_r() for more info on the var in question. (
like for instance that is actually 8 chars long as you expect.)

as Robin Vickery pointed out you probably have blank space hanging around
somewhere.



 $realcmd =  decrypt($cmd); // 'makesmil'

if(decrypt($cmd)=='makesmil')makesmil ();  
// FAILS
elseif(decrypt($cmd)==$realcmd)makesmil(); // 
SUCCEEDS


I'm sure it is something stupid

what am I doing wrong ?
g



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



Re: [PHP] What's the safest way to destory/wipe out the arrays within the associative arrays?

2005-10-13 Thread Richard Lynch
On Wed, October 5, 2005 2:12 pm, Scott Fletcher wrote:
 What is the safest way to destroy or take out the
 $xml['NEWSFEED']['0']['MESSAGE']['2']. associative arrays starting
 with
 ['2'] and those arrays inside of the ['2'] array path?

 The unset() would make it not possible to reassign the data to this
 array
 once again, that is what I do not want.

Hunh?

?php
  $xml['NEWSFEED']['0']['MESSAGE']['2'] = array('whatever');
  var_dump($xml);
  unset($xml['NEWSFEED']['0']['MESSAGE']['2']);
  $xml['NEWSFEED']['0']['MESSAGE']['2'] = array('something else');
  var_dump($xml);
?

You can reassign data any time you want.

I don't understand the problem you're having, personally...

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] Obsession with BC, take 2

2005-10-13 Thread Richard Lynch
On Wed, October 12, 2005 4:31 pm, GamblerZG wrote:
 Since nobody ansvered the real question my previous message, I will
 re-phrase it.

 PHP developers assume that PHP5 will be frequently used to parse PHP4
 scripts. Why?

Because that's how the real world works.

Somebody installs PHP5 on a server.

Somebody else installs code from PHP4 and expects it to work with
little or no modification.

 And what's so horrible about using separate engines to
 run
 php 4 and 5 scripts?

Nothing, if you can identify which are which, and have the
infrastructure to set up both and...

It's a great deal of system administration which, in most real-world
scenarios, doesn't happen.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



[PHP] Ardent Pursing help

2005-10-13 Thread Chirantan Ghosh
Hi All,

My company is trying to send an offer email to all Ford dealers in USA.
We don't intend to send them unapproved emails i.e. sp*m hence, we will call 
then first.

Is there any way I can generate a PHP client/code that can search 
Google/Yahoo/MSN and grab the PR/Sales contacts ( e.g. address, phone number, 
email)?

I have e-grabber  can have it done manually but it hardly seems a solution. I 
could really use some help.
As for proof I am not a sp*mmer/ list seller you can visit or website 
www.primarywave.com and the number we intend to offer is 1-877-NEW FORD .

Thanks for the help,

CG


Re: [PHP] Problem with Javascript:...submit()

2005-10-13 Thread Jochem Maas

Stephen Leaf wrote:

On Thursday 13 October 2005 01:13 am, Johan Grobler wrote:


while ($row = mysql_fetch_array($sql_result))
{
echoForm name=\.$row['LITERATURE_title'].\ action=\searchlit.php\
method=\post\ font face=\arial\ size=\2\
a href=\javascript:.$row['LITERATURE_title']..submit();\


.$row['LITERATURE_title']. - .$row['res_fname'].


.$row['res_lname']./a ...

Everything works as long as $row['LITERATURE_title'] is one word, see this
variable contains the names of books, and if the books name is Heaven for
instance it works fine but as soon as the title is something like PHP for
Dummies it doesnt work and i get a error on page message, I tried using
numbers as the form name but then the same thing happens.


Another way you can access these is by using this function.


Stephen is being polite - he means the 'correct' way ;-)



document.getElementByName('name');
or
document.getElementById('id');

As I recall w3 sees ByName as standard but Mozilla(and many others) only 
support ById, the last time I checked.


script language=Javascript
!--

the value of a name attribute does not need to be unique, where as the value
of the id attribute _MUST_ be unique (according to the specs) 

document.getElementsByName('name');
   ^---notice the 's'

that method returns an array of elements.
out of interest there is also:

document.getElementsByTagName('INPUT');

which also returns an array.

note that these DOM methods will not work in some older browsers, you
may not care but if you do you will probably want to look into
finding a browser compatibility library (some code) that will patch the
problem for you.

//--
/script





Any ways around this?

thanx

Disclaimer
This e-mail transmission contains confidential information,
which is the property of the sender.
The information in this e-mail or attachments thereto is
intended for the attention and use only of the addressee.
Should you have received this e-mail in error, please delete
and destroy it and any attachments thereto immediately.
Under no circumstances will the Cape Peninsula University of
Technology or the sender of this e-mail be liable to any party for
any direct, indirect, special or other consequential damages for any
use of this e-mail.
For the detailed e-mail disclaimer please refer to
http://www.ctech.ac.za/polic or call +27 (0)21 460 3911





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



Re: [PHP] Connecting to MySQL Sever using PHP5

2005-10-13 Thread Jochem Maas

Jay Blanchard wrote:

[snip]
I have just installed PHP5. I am using Windows XP and have already installed

MySQL.

When I try and make a connection to a database on MySQL via Dreamweaver I 


can we make Dreamweaver illegal?


get the following error message: An unidentified error has occurred.

What could be wrong and how can I fix this problem?
[/snip]

Since the error is unidentified I'll need to use ESPN to figure it out. My
SWAG is that a solid whack on the top of the box will fix it. Yes, do that.

http://www.catb.org/~esr/faqs/smart-questions.html

What version of MySQL are you using? 



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



Re: [PHP] Guide for C programmer

2005-10-13 Thread Richard Lynch
On Thu, October 13, 2005 6:13 am, Turgut Hakký ÖZDEMÝR wrote:
 I'm looking for a document describing differences between C and PHP,
 important points for programmers who already know C,C++, and things
 that
 must be taken care.
 I'm googling for about an our but i can't find anything. Any
 suggestions.?

Try reading this:
http://www.php.net/manual/en/faq.languages.php

which compares PHP with other languages, which may be useful.

Other than that, things you should know:

Most of the grungy details of variable types, storage allocation, and
type-juggling is just plain a non-issue 99.9% of the time in PHP.

PHP classes are way more like stripped-down Java than C++.  Or, think
of it as C++ 0.0.1 from Bjourne, which never actually existed, much
less got released, and that's about where it would be.

Probably the biggest learning tasks have nothing to do with
language/syntax per se.

PHP syntax pretty much fits in a small chapter:
http://www.php.net/manual/en/langref.php

Figuring out HTTP and client/server issues would be a book, if
somebody actually wrote it.

Browser oddities would be an encyclopedia, if a team actually wrote
that.  And it would be chock-full of mistakes, mis-interpretations,
and mis-information anyway, and outdated before it went to press, much
less finished writing.  Browsers suck. :-)

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] Ardent Pursing help

2005-10-13 Thread tg-php
I would just go to Ford's dealership lookup page here:
http://www.fordvehicles.com/dealerships/index.asp

Pick a major city or two or three in each state and go down the list.  that 
should get you a list of all the major Ford dealerships and be quicker than 
finding/implementing and/or using a PHP script to attempt to find the info.

Or just call Ford directly and ask for a directory of registered dealerships.  
They might be able to email you a complete list.

-TG

= = = Original message = = =

Hi All,

My company is trying to send an offer email to all Ford dealers in USA.
We don't intend to send them unapproved emails i.e. sp*m hence, we will call 
then first.

Is there any way I can generate a PHP client/code that can search 
Google/Yahoo/MSN and grab the PR/Sales contacts ( e.g. address, phone number, 
email)?

I have e-grabber  can have it done manually but it hardly seems a solution. I 
could really use some help.
As for proof I am not a sp*mmer/ list seller you can visit or website 
www.primarywave.com and the number we intend to offer is 1-877-NEW FORD .

Thanks for the help,

CG


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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



[PHP] Mark Email as Urgent

2005-10-13 Thread Nathaniel Hall
I have a PHP script that automatically sends an e-mail when accessed.  Is there 
any way to mark the e-mail that is sent
as urgent or flagged?

Any help is appreciated.

--
Nathaniel Hall, GSEC

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



Re: [PHP] Mark Email as Urgent

2005-10-13 Thread John Nichel

Nathaniel Hall wrote:

I have a PHP script that automatically sends an e-mail when accessed.  Is there 
any way to mark the e-mail that is sent
as urgent or flagged?


Yes.


Any help is appreciated.


http://us2.php.net/manual/en/function.mail.php

additional_headers

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

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



Re: [PHP] Mark Email as Urgent

2005-10-13 Thread Dan McCullough
add a header in the mail function between 1 - 5, 1 being the highest
$headers .= X-Priority: 1\n;

On 10/13/05, Nathaniel Hall [EMAIL PROTECTED] wrote:
 I have a PHP script that automatically sends an e-mail when accessed.  Is 
 there any way to mark the e-mail that is sent
 as urgent or flagged?

 Any help is appreciated.

 --
 Nathaniel Hall, GSEC

 --
 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] Mark Email as Urgent

2005-10-13 Thread Richard Lynch
On Thu, October 13, 2005 12:47 pm, Nathaniel Hall wrote:
 I have a PHP script that automatically sends an e-mail when accessed.
 Is there any way to mark the e-mail that is sent
 as urgent or flagged?

 Any help is appreciated.

Yes, but...

You can add a header Priority: High (I think it's High)

But only spammers use that [1], so it increases the odds of getting
marked as spam.

The urgency of an email, as defined by the sender, has turned out to
be relatively useless, since the urgency, as defined by the recipient,
rarely matches.  While you may have the luxury of knowing for sure
that the two urgencies (sender/recipient) *DO* match up, it's a rare
occurrence.

If you have sufficient control over sender and recipient accounts, you
could add URGENT to the Subject: and/or set up filtering on the email
client to force the message to be flagged there, based on criteria
that are less likely to get the email flagged as junk.

Maybe if Priority email cost more to send and bulk was cheaper, these
settings would become meaningful again.  But, as it stands now, they
are largely useless to the sender.  I'm sure some recipients
re-prioritize email based on filters, and that remains useful.

[1] This was an exaggeration, though not a huge one. Actually, savvy
spammers no longer use a Priority setting.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] Can't compare a decrypted variable to a string ?

2005-10-13 Thread Graham Anderson

many thanks :)

I'll try this

g
On Oct 13, 2005, at 10:27 AM, Jochem Maas wrote:


Graham Anderson wrote:


For some reason,
I have to store a decrypted string as a variable before I can  
compare  it to another string.

The decrypt function is located in another php script
//Get variable
$cmd = $_REQUEST['cmd'];
echo $cmd; //  uJy4p09z6bSR80eLNFnBWBj/EsRCfIz2C/WrcFNcZE8=
echo decrypt($cmd);// makesmil



try
var_dump() or print_r() for more info on the var in question. (
like for instance that is actually 8 chars long as you expect.)

as Robin Vickery pointed out you probably have blank space hanging  
around

somewhere.



 $realcmd =  decrypt($cmd); // 'makesmil'
if(decrypt($cmd)=='makesmil')makesmil  
();  // FAILS
elseif(decrypt($cmd)==$realcmd)makesmil 
(); // SUCCEEDS

I'm sure it is something stupid
what am I doing wrong ?
g



--
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] Re: Run a php script as a separate thread/process

2005-10-13 Thread Richard Lynch
On Wed, October 12, 2005 10:23 am, cc wrote:
 On 10/12/05, Tommy Jensehaugen [EMAIL PROTECTED] wrote:
 Thank you very much. This is what I ended up with if anyone needs
 it:

 ?php
 function runSeparateThread($strHost, $strPath=/) {
  $fFile = fsockopen($strHost, 80, $intError, $strError);
  if ($fFile) {
   $out = GET .$strPath. HTTP/1.1\r\n;
   $out .= Host: .$strHost.\r\n;
   $out .= Connection: Close\r\n\r\n;
   if(!fwrite($fFile, $out)){
$result = runSeparateThread():fwrite(). Could not
 write:'.$out.'.
 Host:'.$strHost.'. Path:'.$strPath.';
   } else {
$result = true;
   }
   fclose($fFile);
  } else {
   $result = runSeparateThread():fsockopen(): Could not connect to
 .$strHost. (.$intError.) .$strError..;
  }
  return $result;
 }
 ?

I missed the original question...

One thing to consider would be to have a list of hosts/urls you want,
and to open up all the sockets non-blocking, and then loop through
each socket and fread() data in a convenient-sized chunk and snag it.

This will make all the remote computers run in parallel to some degree.

This is most useful if the GETs you are doing are dynamic and take
awhile for the remote server to generate the output.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



[PHP] RE: Removing Items from an Array

2005-10-13 Thread Alan Lord
Hi TG and others,

I think I must be missing something here.

Your example doesn't seem to traverse down into a multidim array. 

Also, it appears as though your script assumes that the structure of the
array is known. It isn't and it is retrieved from far away and I have
no control over it's structure/depth/size etc... I can take a good guess
at the keys I want to keep and keep those in an array in my config.inc.
But I would ideally like to be able to have a function which is as
array agnostic as possible.

I tried to do an unset($arr[key]) in one of my other attempts at
solving this problem.  But from what I read in the manual (if I
understood correctly :-)), it seems as though you can't really do this
from within a function/routine which is walking through the array at
that time as the array is not re-ordered...

Thanks and no offence intended, I am just trying to understand... :-)

Alan
--
Tg wrote:

That works just as well, if you have only two levels of depth.  Mostly I
was trying to illustrate how to use $key = $value in a foreach and what
to do if you need to go multiple levels down.  Once you get to the
bottom level, then you can use isset() certainly.

Just wanted to make sure that it was clear what to do with $key and
$subkey relating to the main array ($alldataarr in this example)
-snip-

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



Re: [PHP] RE: Removing Items from an Array

2005-10-13 Thread Jochem Maas

Alan Lord wrote:

Hi TG and others,

I think I must be missing something here.

Your example doesn't seem to traverse down into a multidim array. 


Also, it appears as though your script assumes that the structure of the
array is known. It isn't and it is retrieved from far away and I have
no control over it's structure/depth/size etc... I can take a good guess
at the keys I want to keep and keep those in an array in my config.inc.
But I would ideally like to be able to have a function which is as
array agnostic as possible.


shouldn't be 'array paragnostic' or maybe 'array gnostic' -
psychic hypertext processor. does what you mean.



I tried to do an unset($arr[key]) in one of my other attempts at
solving this problem.  But from what I read in the manual (if I
understood correctly :-)), it seems as though you can't really do this
from within a function/routine which is walking through the array at
that time as the array is not re-ordered...


right so you have to write your own function. and/or maybe combine it with
array_map() and/or array_filter() ... here is a routine that drills
into an array given an array of values that act as the 'path'
into the array your 'drilling' (can you handle php5?), may be that
inspires you a bit:

/*
 * eg

$yourDataSet = array();
$yourDataSet['A'] = array();
$yourDataSet['B'] = array();
$yourDataSet['A']['A'] = array();
$yourDataSet['B']['B'] = array();
$yourDataSet['B']['B']['coolstuff'] = array(
'foo' = 'bar',
'bar' = 'qux',
);

ArrayDriller::setSource( $yourDataSet );
$somedata = ArrayDriller::get( array('B','B','coolstuff') )
 */

class ArrayDriller
{
static private $source;

static public function setSource($var)
{
// do a check to make sure the keys are associative?
if (is_array($var)  count($var)) self::$source = $var;
}

static public function set($varName, $value = null)
{
if (is_array(self::$source)  $varName  !is_numeric($varName)) {
if (is_array( $varName )) {
$tmpArr = self::$source;
while ( 1 ) {
self::chkVarName($k = array_shift( $varName ));
if ( !count( $varName )) {
return ($tmpArr[ $k ] = $value);
break;
} else if (! isset($tmpArr[ $k ]) || ! is_array($tmpArr[ $k 
])) {
$tmpArr[ $k ] = array();
}

$tmpArr = $tmpArr[ $k ];
}
} else {
self::chkVarName($varName);
return (self::$source[ $varName ] = $value);
}
}
}

static public function get($varName)
{
if (is_array(self::$source)  $varName) {
if (is_array( $varName )) {
$tmpArr = self::$source;
while ( 1 ) {
self::chkVarName($k = array_shift( $varName ));

/* endpoint */
if ( !count( $varName )) {
if (@is_array($tmpArr)  array_key_exists($k, 
$tmpArr)) {
return $tmpArr[ $k ];
}
break;
}
else if (!array_key_exists($k, $tmpArr) ||
 !is_array($tmpArr[ $k ]))
{
// we can go no deeper
break;
}

$tmpArr = $tmpArr[ $k ];
}
} else {
self::chkVarName( $varName );
if (array_key_exists($varName, self::$source)) {
return self::$source[ $varName ];
}
}
}

return null;
}

static private function chkVarName($varName)
{
if (strval( $varName )) {
return;
} else {
throw new Exception('backup buster, call that an assoc key?');
// trigger_error(); // er? php4 anyone?
}
}
}




Thanks and no offence intended, I am just trying to understand... :-)

Alan
--
Tg wrote:

That works just as well, if you have only two levels of depth.  Mostly I
was trying to illustrate how to use $key = $value in a foreach and what
to do if you need to go multiple levels down.  Once you get to the
bottom level, then you can use isset() certainly.

Just wanted to make sure that it was clear what to do with $key and
$subkey relating to the main array ($alldataarr in this example)
-snip-



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



Re: [PHP] Connecting to MySQL Sever using PHP5

2005-10-13 Thread Edward Vermillion

Jochem Maas wrote:

Jay Blanchard wrote:


[snip]
I have just installed PHP5. I am using Windows XP and have already 
installed


MySQL.

When I try and make a connection to a database on MySQL via Dreamweaver I 



can we make Dreamweaver illegal?


[snip]

But *I* use DW...

I know, I know... really it's just a *real* expensive text editor with 
some nice ftp/project whizbang thingies...


but I've gotten used to it. ;)

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



RE: [PHP] RE: Removing Items from an Array

2005-10-13 Thread Alan Lord
Blimey...

That's going to take some de-ciphering... It looks fascinating :-)

Thanks!

Alan

 -Original Message-
 From: Jochem Maas [mailto:[EMAIL PROTECTED] 
 Sent: 13 October 2005 20:53
 To: Alan Lord
 Cc: php-general@lists.php.net
 Subject: Re: [PHP] RE: Removing Items from an Array
 
 Alan Lord wrote:
  Hi TG and others,
  
  I think I must be missing something here.
  
  Your example doesn't seem to traverse down into a multidim array. 
  
  Also, it appears as though your script assumes that the 
 structure of 
  the array is known. It isn't and it is retrieved from far 
 away and I 
  have no control over it's structure/depth/size etc... I can take a 
  good guess at the keys I want to keep and keep those in an 
 array in my config.inc.
  But I would ideally like to be able to have a function which is as 
  array agnostic as possible.
 
 shouldn't be 'array paragnostic' or maybe 'array gnostic' - 
 psychic hypertext processor. does what you mean.
 
  
  I tried to do an unset($arr[key]) in one of my other attempts at 
  solving this problem.  But from what I read in the manual (if I 
  understood correctly :-)), it seems as though you can't 
 really do this 
  from within a function/routine which is walking through the 
 array at 
  that time as the array is not re-ordered...
 
 right so you have to write your own function. and/or maybe 
 combine it with
 array_map() and/or array_filter() ... here is a routine that 
 drills into an array given an array of values that act as the 'path'
 into the array your 'drilling' (can you handle php5?), may be 
 that inspires you a bit:
 
 /*
   * eg
 
 $yourDataSet = array();
 $yourDataSet['A'] = array();
 $yourDataSet['B'] = array();
 $yourDataSet['A']['A'] = array();
 $yourDataSet['B']['B'] = array();
 $yourDataSet['B']['B']['coolstuff'] = array(
   'foo' = 'bar',
   'bar' = 'qux',
 );
 
 ArrayDriller::setSource( $yourDataSet ); $somedata = 
 ArrayDriller::get( array('B','B','coolstuff') )
   */
 
 class ArrayDriller
 {
  static private $source;
 
  static public function setSource($var)
  {
   // do a check to make sure the keys are associative?
   if (is_array($var)  count($var)) self::$source = $var;
  }
 
  static public function set($varName, $value = null)
  {
  if (is_array(self::$source)  $varName  
 !is_numeric($varName)) {
  if (is_array( $varName )) {
  $tmpArr = self::$source;
  while ( 1 ) {
  self::chkVarName($k = array_shift( $varName ));
  if ( !count( $varName )) {
  return ($tmpArr[ $k ] = $value);
  break;
  } else if (! isset($tmpArr[ $k ]) || ! 
 is_array($tmpArr[ $k ])) {
  $tmpArr[ $k ] = array();
  }
 
  $tmpArr = $tmpArr[ $k ];
  }
  } else {
  self::chkVarName($varName);
  return (self::$source[ $varName ] = $value);
  }
  }
  }
 
  static public function get($varName)
  {
  if (is_array(self::$source)  $varName) {
  if (is_array( $varName )) {
  $tmpArr = self::$source;
  while ( 1 ) {
  self::chkVarName($k = array_shift( $varName ));
 
  /* endpoint */
  if ( !count( $varName )) {
  if (@is_array($tmpArr)  
 array_key_exists($k, $tmpArr)) {
  return $tmpArr[ $k ];
  }
  break;
  }
  else if (!array_key_exists($k, $tmpArr) ||
   !is_array($tmpArr[ $k ]))
  {
  // we can go no deeper
  break;
  }
 
  $tmpArr = $tmpArr[ $k ];
  }
  } else {
  self::chkVarName( $varName );
  if (array_key_exists($varName, self::$source)) {
  return self::$source[ $varName ];
  }
  }
  }
 
  return null;
  }
 
  static private function chkVarName($varName)
  {
  if (strval( $varName )) {
  return;
  } else {
  throw new Exception('backup buster, call that an 
 assoc key?');
   // trigger_error(); // er? php4 anyone?
  }
  }
 }
 
 
  
  Thanks and no offence intended, I am just trying to 
 understand... :-)
  
  Alan
  --
  Tg wrote:
  
  That works just as well, if you have only two levels of 
 depth.  Mostly 
  I was trying to illustrate how to use $key = $value in a 
 foreach and 
  what to do if you need to go multiple levels down.  Once you get to 
  the bottom level, then you can use isset() certainly.
  
  Just 

[PHP] prevent user from getting scripts outside the web folder

2005-10-13 Thread Graham Anderson
How does a hacker get access to your scripts located outside the web  
folder?

I asked a friend to hack my php script within the web folder...


all of my crucial function were called by:
require_once(/home/siren/includes/fonovisa.inc);
the 'encrypt' functions are MCRYPT_RIJNDAEL_256

He was able to get access to the 'fonovisa.inc'  php script [outside  
the web folder] and all the stuff inside
Based on my current knowledge, my security breaches are probably big  
enough to drive a truck through :(



how can I prevent this ?
I am VERY new at the whole 'security' thing so any help is appreciated



this is the script within the web folder:
?php
require_once(/home/siren/includes/fonovisa.inc);
$thisScriptURL = ThisScriptsAbsoluteHTTPLocation($_SERVER 
['SCRIPT_NAME']);

qtversiondetect($_SERVER['HTTP_USER_AGENT']);




//
//   This PHP script is performing three tasks
//   1)  Creates a SMIL playlist of Quicktime movies from a database  
call

//   2)  Reads each requested movie file from outside the web folder
//Movies are downloaded by passing the GET variable, 'path',  
to the 'freadMovie()' function
//This function is located in the script,  
'fonovisa.inc', located outside the web folder
//The movie files are fread chunk  by chunk  in  
binary format and loaded into the the Quicktime Player
//   3) Build the Actual Quicktime Media Link with all the EMBED  
attributes like KIOSKMODE and QUITWHENDONE

//
//

//   Flow of the Code:
//   If the GET variable, 'cmd', equals 'makesmil'
// Build the  SMIL playlist
//   ElseIf the GET variable, 'cmd', equals 'getmovie'
//  Send the requested url [with the encrypted movie file  
path] to the freadmovie() function
//  which freads the requested movie file data  to the  
Quicktime Player

//   Else
//Build the Quicktime Media Link that generated the  
Headers and Embed  tags
//where the 'src' attribute points to the  SMIL Playlist  
Movie function in THIS script

//   Endif
//


// any variable there ?
if( isset($_REQUEST['cmd']) OR isset($_REQUEST['path'] ))
{


// Ok, there is a 'cmd' and/or 'path' variable, what are they ?


//make the SMIL playlist of movie
if(trim(decrypt( $_REQUEST['cmd'])) ==makesmil) 
makesmil($thisScriptURL);


 //fread a movie file in the playlist and send to QuickTime
elseif(trim(decrypt($_REQUEST['cmd']))==getmovie) 
freadMovie($_REQUEST['path']);



}else{
///
//  No commands were given
//  So make the Quicktime Media Link with all the EMBED attributes
//  The 'src' attribute  is going to call the 'makesmil'  
function to generate the SMIL playlist movie

//
buildQTMediaLinkForSMILPlaylist( $autoplay=true,
 
$cache=false,
 
$kioskmode=true,
 
$quitwhendone=true,
 
$movieid=md5(time()),
 
$moviename=Commercial Reel 2005,
 
$src=$thisScriptURL?cmd=.encrypt('makesmil')

);

///
// Output the Correct QuickTime Headers and the Embed Tags  
and send the movie to QuickTime

///
OutputHeaders($_SERVER['HTTP_USER_AGENT']);
echo $finalQTMovie;


}


/
// Local Functions
/

function makesmil($thisScriptURL)
{
buildSMILArray($thisScriptURL,$d='siren',$playlist=Show Reel);

// format the SMIL playlist
buildSMILPlaylist(   $timeslider=true,
$chaptermode=all,
 
$immediateinstantiation=false,

$autoplay=true,
$left=1,
$top=1,
$height=208,
$width = 352,
$fit= fill,
$title = Commercial  
Reel 2005,

$regionid=siren,
$bgcolor=black,
$movieid=md5(time()),
$moviename=Commercial  
Reel 2005,

$movieArray);
}


//-
// Santize the 

Re: [PHP] prevent user from getting scripts outside the web folder

2005-10-13 Thread John Nichel

Graham Anderson wrote:
How does a hacker get access to your scripts located outside the web  
folder?

I asked a friend to hack my php script within the web folder...


all of my crucial function were called by:
require_once(/home/siren/includes/fonovisa.inc);
the 'encrypt' functions are MCRYPT_RIJNDAEL_256

He was able to get access to the 'fonovisa.inc'  php script [outside  
the web folder] and all the stuff inside
Based on my current knowledge, my security breaches are probably big  
enough to drive a truck through :(



how can I prevent this ?
I am VERY new at the whole 'security' thing so any help is appreciated


Just looking briefly at the below script; NEVER trust user input! 
Sanatize it, escape it, check to see it's what you expect, and do it 
again.  Doing things like this...


freadMovie($_REQUEST['path']);

is just asking for trouble.


this is the script within the web folder:
?php
require_once(/home/siren/includes/fonovisa.inc);
$thisScriptURL = ThisScriptsAbsoluteHTTPLocation($_SERVER ['SCRIPT_NAME']);
qtversiondetect($_SERVER['HTTP_USER_AGENT']);




//
//   This PHP script is performing three tasks
//   1)  Creates a SMIL playlist of Quicktime movies from a database  call
//   2)  Reads each requested movie file from outside the web folder
//Movies are downloaded by passing the GET variable, 'path',  to 
the 'freadMovie()' function
//This function is located in the script,  
'fonovisa.inc', located outside the web folder
//The movie files are fread chunk  by chunk  in  binary 
format and loaded into the the Quicktime Player
//   3) Build the Actual Quicktime Media Link with all the EMBED  
attributes like KIOSKMODE and QUITWHENDONE

//
//

//   Flow of the Code:
//   If the GET variable, 'cmd', equals 'makesmil'
// Build the  SMIL playlist
//   ElseIf the GET variable, 'cmd', equals 'getmovie'
//  Send the requested url [with the encrypted movie file  path] 
to the freadmovie() function
//  which freads the requested movie file data  to the  
Quicktime Player

//   Else
//Build the Quicktime Media Link that generated the  Headers 
and Embed  tags
//where the 'src' attribute points to the  SMIL Playlist  
Movie function in THIS script

//   Endif
//


// any variable there ?
if( isset($_REQUEST['cmd']) OR isset($_REQUEST['path'] ))
{


// Ok, there is a 'cmd' and/or 'path' variable, what are they ?


//make the SMIL playlist of movie
if(trim(decrypt( $_REQUEST['cmd'])) ==makesmil) 
makesmil($thisScriptURL);


 //fread a movie file in the playlist and send to QuickTime
elseif(trim(decrypt($_REQUEST['cmd']))==getmovie) 
freadMovie($_REQUEST['path']);



}else{
///
//  No commands were given
//  So make the Quicktime Media Link with all the EMBED attributes
//  The 'src' attribute  is going to call the 'makesmil'  function 
to generate the SMIL playlist movie

//
buildQTMediaLinkForSMILPlaylist( $autoplay=true,
 
$cache=false,
 
$kioskmode=true,
 
$quitwhendone=true,
 
$movieid=md5(time()),
 
$moviename=Commercial Reel 2005,
 
$src=$thisScriptURL?cmd=.encrypt('makesmil')

);

///
// Output the Correct QuickTime Headers and the Embed Tags  and 
send the movie to QuickTime

///
OutputHeaders($_SERVER['HTTP_USER_AGENT']);
echo $finalQTMovie;


}


/
// Local Functions
/

function makesmil($thisScriptURL)
{
buildSMILArray($thisScriptURL,$d='siren',$playlist=Show Reel);

// format the SMIL playlist
buildSMILPlaylist(   $timeslider=true,
$chaptermode=all,
 
$immediateinstantiation=false,

$autoplay=true,
$left=1,
$top=1,
$height=208,
$width = 352,
$fit= fill,
$title = Commercial  Reel 
2005,

$regionid=siren,
$bgcolor=black,
 

Re: [PHP] prevent user from getting scripts outside the web folder

2005-10-13 Thread Jochem Maas

Graham Anderson wrote:
How does a hacker get access to your scripts located outside the web  
folder?

I asked a friend to hack my php script within the web folder...



er. why don't you [EMAIL PROTECTED]#(%*[EMAIL PROTECTED](_*^#()% %   er ask 
him.



all of my crucial function were called by:
require_once(/home/siren/includes/fonovisa.inc);
the 'encrypt' functions are MCRYPT_RIJNDAEL_256

He was able to get access to the 'fonovisa.inc'  php script [outside  
the web folder] and all the stuff inside
Based on my current knowledge, my security breaches are probably big  
enough to drive a truck through :(



how can I prevent this ?


santize your input - make sure your webserver is secure.
don't give php files a .inc extension if you don't know what your doing.

your probably doing the equivelant of (although some what less obviously):

?

echo get_file_contents( $_GET['anyfileyoulike'] );

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



Re: [PHP] prevent user from getting scripts outside the web folder

2005-10-13 Thread Robert Cummings
On Thu, 2005-10-13 at 17:05, Graham Anderson wrote:
 How does a hacker get access to your scripts located outside the web  
 folder?
 I asked a friend to hack my php script within the web folder...

Ummm, the obvious thing to do is ask your friend how he did it, then
we'll tell you how to prevent it in the future. Otherwise we're all just
shooting in the dark.

Cheers,
Rob.

 
 
 all of my crucial function were called by:
 require_once(/home/siren/includes/fonovisa.inc);
 the 'encrypt' functions are MCRYPT_RIJNDAEL_256
 
 He was able to get access to the 'fonovisa.inc'  php script [outside  
 the web folder] and all the stuff inside
 Based on my current knowledge, my security breaches are probably big  
 enough to drive a truck through :(
 
 
 how can I prevent this ?
 I am VERY new at the whole 'security' thing so any help is appreciated
 
 
 
 this is the script within the web folder:
 ?php
 require_once(/home/siren/includes/fonovisa.inc);
 $thisScriptURL = ThisScriptsAbsoluteHTTPLocation($_SERVER 
 ['SCRIPT_NAME']);
 qtversiondetect($_SERVER['HTTP_USER_AGENT']);
 
 
 
 
 //
 //   This PHP script is performing three tasks
 //   1)  Creates a SMIL playlist of Quicktime movies from a database  
 call
 //   2)  Reads each requested movie file from outside the web folder
 //Movies are downloaded by passing the GET variable, 'path',  
 to the 'freadMovie()' function
 //This function is located in the script,  
 'fonovisa.inc', located outside the web folder
 //The movie files are fread chunk  by chunk  in  
 binary format and loaded into the the Quicktime Player
 //   3) Build the Actual Quicktime Media Link with all the EMBED  
 attributes like KIOSKMODE and QUITWHENDONE
 //
 //
 
 //   Flow of the Code:
 //   If the GET variable, 'cmd', equals 'makesmil'
 // Build the  SMIL playlist
 //   ElseIf the GET variable, 'cmd', equals 'getmovie'
 //  Send the requested url [with the encrypted movie file  
 path] to the freadmovie() function
 //  which freads the requested movie file data  to the  
 Quicktime Player
 //   Else
 //Build the Quicktime Media Link that generated the  
 Headers and Embed  tags
 //where the 'src' attribute points to the  SMIL Playlist  
 Movie function in THIS script
 //   Endif
 //
 
 
 // any variable there ?
 if( isset($_REQUEST['cmd']) OR isset($_REQUEST['path'] ))
 {
 
  
  // Ok, there is a 'cmd' and/or 'path' variable, what are they ?
  
 
  //make the SMIL playlist of movie
  if(trim(decrypt( $_REQUEST['cmd'])) ==makesmil) 
 makesmil($thisScriptURL);
 
   //fread a movie file in the playlist and send to QuickTime
  elseif(trim(decrypt($_REQUEST['cmd']))==getmovie) 
 freadMovie($_REQUEST['path']);
 
 
  }else{
  ///
  //  No commands were given
  //  So make the Quicktime Media Link with all the EMBED attributes
  //  The 'src' attribute  is going to call the 'makesmil'  
 function to generate the SMIL playlist movie
  //
  buildQTMediaLinkForSMILPlaylist( $autoplay=true,
   
 $cache=false,
   
 $kioskmode=true,
   
 $quitwhendone=true,
   
 $movieid=md5(time()),
   
 $moviename=Commercial Reel 2005,
   
 $src=$thisScriptURL?cmd=.encrypt('makesmil')
  );
 
  ///
  // Output the Correct QuickTime Headers and the Embed Tags  
 and send the movie to QuickTime
  ///
  OutputHeaders($_SERVER['HTTP_USER_AGENT']);
  echo $finalQTMovie;
 
 
  }
 
 
 /
 // Local Functions
 /
 
 function makesmil($thisScriptURL)
 {
  buildSMILArray($thisScriptURL,$d='siren',$playlist=Show Reel);
 
  // format the SMIL playlist
  buildSMILPlaylist(   $timeslider=true,
  $chaptermode=all,
   
 $immediateinstantiation=false,
  $autoplay=true,
  $left=1,
  $top=1,
  $height=208,
  $width = 352,
  $fit= fill,
  $title = Commercial  
 

Re: [PHP] prevent user from getting scripts outside the web folder

2005-10-13 Thread Graham Anderson


Ok, I just heard back from him and feel like an idiot

my htaccess file for the folder containing  the php script  was not  
set properly
guess at this point, I'll take all of the advice you guys gave and  
implement it :)


g

On Oct 13, 2005, at 2:21 PM, Robert Cummings wrote:


On Thu, 2005-10-13 at 17:05, Graham Anderson wrote:


How does a hacker get access to your scripts located outside the web
folder?
I asked a friend to hack my php script within the web folder...



Ummm, the obvious thing to do is ask your friend how he did it, then
we'll tell you how to prevent it in the future. Otherwise we're all  
just

shooting in the dark.

Cheers,
Rob.





all of my crucial function were called by:
require_once(/home/siren/includes/fonovisa.inc);
the 'encrypt' functions are MCRYPT_RIJNDAEL_256

He was able to get access to the 'fonovisa.inc'  php script [outside
the web folder] and all the stuff inside
Based on my current knowledge, my security breaches are probably big
enough to drive a truck through :(


how can I prevent this ?
I am VERY new at the whole 'security' thing so any help is  
appreciated




this is the script within the web folder:
?php
require_once(/home/siren/includes/fonovisa.inc);
$thisScriptURL = ThisScriptsAbsoluteHTTPLocation($_SERVER
['SCRIPT_NAME']);
qtversiondetect($_SERVER['HTTP_USER_AGENT']);




//
//   This PHP script is performing three tasks
//   1)  Creates a SMIL playlist of Quicktime movies from a database
call
//   2)  Reads each requested movie file from outside the web folder
//Movies are downloaded by passing the GET variable, 'path',
to the 'freadMovie()' function
//This function is located in the script,
'fonovisa.inc', located outside the web folder
//The movie files are fread chunk  by chunk  in
binary format and loaded into the the Quicktime Player
//   3) Build the Actual Quicktime Media Link with all the EMBED
attributes like KIOSKMODE and QUITWHENDONE
//
//

//   Flow of the Code:
//   If the GET variable, 'cmd', equals 'makesmil'
// Build the  SMIL playlist
//   ElseIf the GET variable, 'cmd', equals 'getmovie'
//  Send the requested url [with the encrypted movie file
path] to the freadmovie() function
//  which freads the requested movie file data  to the
Quicktime Player
//   Else
//Build the Quicktime Media Link that generated the
Headers and Embed  tags
//where the 'src' attribute points to the  SMIL Playlist
Movie function in THIS script
//   Endif
//


// any variable there ?
if( isset($_REQUEST['cmd']) OR isset($_REQUEST['path'] ))
{

 
 // Ok, there is a 'cmd' and/or 'path' variable, what are they ?
 

 //make the SMIL playlist of movie
 if(trim(decrypt( $_REQUEST['cmd'])) ==makesmil)
makesmil($thisScriptURL);

  //fread a movie file in the playlist and send to QuickTime
 elseif(trim(decrypt($_REQUEST['cmd']))==getmovie)
freadMovie($_REQUEST['path']);


 }else{
 ///
 //  No commands were given
 //  So make the Quicktime Media Link with all the EMBED  
attributes

 //  The 'src' attribute  is going to call the 'makesmil'
function to generate the SMIL playlist movie
 //
 buildQTMediaLinkForSMILPlaylist( $autoplay=true,

$cache=false,

$kioskmode=true,

$quitwhendone=true,

$movieid=md5(time()),

$moviename=Commercial Reel 2005,

$src=$thisScriptURL?cmd=.encrypt('makesmil')
 );

 ///
 // Output the Correct QuickTime Headers and the Embed Tags
and send the movie to QuickTime
 ///
 OutputHeaders($_SERVER['HTTP_USER_AGENT']);
 echo $finalQTMovie;


 }


/
// Local Functions
/

function makesmil($thisScriptURL)
{
 buildSMILArray($thisScriptURL,$d='siren',$playlist=Show Reel);

 // format the SMIL playlist
 buildSMILPlaylist(   $timeslider=true,
 $chaptermode=all,

$immediateinstantiation=false,
 $autoplay=true,
 $left=1,
 $top=1,
 $height=208,
 $width = 352,
 $fit= fill,
 $title = Commercial
Reel 2005,
 $regionid=siren,
 $bgcolor=black,
 $movieid=md5(time()),
 $moviename=Commercial
Reel 2005,
 

Re: [PHP] Connecting to MySQL Sever using PHP5

2005-10-13 Thread Jochem Maas

Edward Vermillion wrote:

Jochem Maas wrote:


Jay Blanchard wrote:


[snip]
I have just installed PHP5. I am using Windows XP and have already 
installed


MySQL.

When I try and make a connection to a database on MySQL via 
Dreamweaver I 




can we make Dreamweaver illegal?


[snip]

But *I* use DW...

I know, I know... really it's just a *real* expensive text editor with 
some nice ftp/project whizbang thingies...


but I've gotten used to it. ;)


you'll just have to start using it in secret.





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



Re: [PHP] prevent user from getting scripts outside the web folder [this better?]

2005-10-13 Thread Graham Anderson

Is this a bit better ?
As directed, I 'sanitized' all user input variables with trim and  
mysql_real_escape_string.


thanks for everyone's patience as I am starting at ground zero  
concerning security.



if( isset($_REQUEST['cmd']) OR isset($_REQUEST['path'] ))
{
// decrypt and santize variables
$cmd = isset($_REQUEST['cmd']) ? cleanser(decrypt($_REQUEST 
['cmd'])) : $cmd=null;
$path = isset($_REQUEST['path']) ? cleanser(decrypt($_REQUEST 
['path'])) : $path=null;

.
.
.

the cleanser script:
function cleanser( $value )
{
return mysql_real_escape_string( trim( $value ) ) ;
}

the 'decrypt' function uses MCRYPT_RIJNDAEL_256 with a $key stored  
outside the web folder.


many thanks :)
g


On Oct 13, 2005, at 2:36 PM, Graham Anderson wrote:



Ok, I just heard back from him and feel like an idiot

my htaccess file for the folder containing  the php script  was not  
set properly
guess at this point, I'll take all of the advice you guys gave and  
implement it :)


g

On Oct 13, 2005, at 2:21 PM, Robert Cummings wrote:



On Thu, 2005-10-13 at 17:05, Graham Anderson wrote:



How does a hacker get access to your scripts located outside the web
folder?
I asked a friend to hack my php script within the web folder...




Ummm, the obvious thing to do is ask your friend how he did it, then
we'll tell you how to prevent it in the future. Otherwise we're  
all just

shooting in the dark.

Cheers,
Rob.






all of my crucial function were called by:
require_once(/home/siren/includes/fonovisa.inc);
the 'encrypt' functions are MCRYPT_RIJNDAEL_256

He was able to get access to the 'fonovisa.inc'  php script [outside
the web folder] and all the stuff inside
Based on my current knowledge, my security breaches are probably big
enough to drive a truck through :(


how can I prevent this ?
I am VERY new at the whole 'security' thing so any help is  
appreciated




this is the script within the web folder:
?php
require_once(/home/siren/includes/fonovisa.inc);
$thisScriptURL = ThisScriptsAbsoluteHTTPLocation($_SERVER
['SCRIPT_NAME']);
qtversiondetect($_SERVER['HTTP_USER_AGENT']);




//
//   This PHP script is performing three tasks
//   1)  Creates a SMIL playlist of Quicktime movies from a database
call
//   2)  Reads each requested movie file from outside the web folder
//Movies are downloaded by passing the GET variable, 'path',
to the 'freadMovie()' function
//This function is located in the script,
'fonovisa.inc', located outside the web folder
//The movie files are fread chunk  by chunk  in
binary format and loaded into the the Quicktime Player
//   3) Build the Actual Quicktime Media Link with all the EMBED
attributes like KIOSKMODE and QUITWHENDONE
//
//

//   Flow of the Code:
//   If the GET variable, 'cmd', equals 'makesmil'
// Build the  SMIL playlist
//   ElseIf the GET variable, 'cmd', equals 'getmovie'
//  Send the requested url [with the encrypted movie file
path] to the freadmovie() function
//  which freads the requested movie file data  to the
Quicktime Player
//   Else
//Build the Quicktime Media Link that generated the
Headers and Embed  tags
//where the 'src' attribute points to the  SMIL Playlist
Movie function in THIS script
//   Endif
//


// any variable there ?
if( isset($_REQUEST['cmd']) OR isset($_REQUEST['path'] ))
{

 
 // Ok, there is a 'cmd' and/or 'path' variable, what are they ?
 

 //make the SMIL playlist of movie
 if(trim(decrypt( $_REQUEST['cmd'])) ==makesmil)
makesmil($thisScriptURL);

  //fread a movie file in the playlist and send to QuickTime
 elseif(trim(decrypt($_REQUEST['cmd']))==getmovie)
freadMovie($_REQUEST['path']);


 }else{
 ///
 //  No commands were given
 //  So make the Quicktime Media Link with all the EMBED  
attributes

 //  The 'src' attribute  is going to call the 'makesmil'
function to generate the SMIL playlist movie
 //
 buildQTMediaLinkForSMILPlaylist( $autoplay=true,

$cache=false,

$kioskmode=true,

$quitwhendone=true,

$movieid=md5(time()),

$moviename=Commercial Reel 2005,

$src=$thisScriptURL?cmd=.encrypt('makesmil')
 );

 ///
 // Output the Correct QuickTime Headers and the Embed Tags
and send the movie to QuickTime
 ///
 OutputHeaders($_SERVER['HTTP_USER_AGENT']);
 echo $finalQTMovie;


 }


/
// Local Functions
/

function makesmil($thisScriptURL)
{
 buildSMILArray($thisScriptURL,$d='siren',$playlist=Show  
Reel);


 // format the SMIL playlist
 buildSMILPlaylist(   $timeslider=true,
 

Re: [PHP] Mark Email as Urgent

2005-10-13 Thread Nathaniel Hall
Richard Lynch wrote:
 On Thu, October 13, 2005 12:47 pm, Nathaniel Hall wrote:
 
I have a PHP script that automatically sends an e-mail when accessed.
Is there any way to mark the e-mail that is sent
as urgent or flagged?

Any help is appreciated.
 
 
 Yes, but...
 
 You can add a header Priority: High (I think it's High)
 
 But only spammers use that [1], so it increases the odds of getting
 marked as spam.
 
 The urgency of an email, as defined by the sender, has turned out to
 be relatively useless, since the urgency, as defined by the recipient,
 rarely matches.  While you may have the luxury of knowing for sure
 that the two urgencies (sender/recipient) *DO* match up, it's a rare
 occurrence.
 
 If you have sufficient control over sender and recipient accounts, you
 could add URGENT to the Subject: and/or set up filtering on the email
 client to force the message to be flagged there, based on criteria
 that are less likely to get the email flagged as junk.
 
 Maybe if Priority email cost more to send and bulk was cheaper, these
 settings would become meaningful again.  But, as it stands now, they
 are largely useless to the sender.  I'm sure some recipients
 re-prioritize email based on filters, and that remains useful.
 
 [1] This was an exaggeration, though not a huge one. Actually, savvy
 spammers no longer use a Priority setting.
 

This is all for internal use.  The PHP webpage is used as a honeypot on our 
website.  When people visit the appropriate
page, I would like an Urgent e-mail to be sent to my e-mail and my cell phone 
(to the phones email address).  I am able
to send text messages as urgent and they vibrate and ring differently already.  
I have the page working now, but it does
not mark anything as urgent or high priority.

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



Re: [PHP] 电子传单 ,最廉价的宣传方式

2005-10-13 Thread Stephen Johnson
请停止发送电子邮件到这个列表, 或我将被迫使解开一千头骆驼蚤入您的腋窝。
?php
/*

Stephen Johnson c | eh
The Lone Coder

http://www.ouradoptionblog.com
Join our journey of adoption

http://www.thelonecoder.com
[EMAIL PROTECTED]

continuing the struggle against bad code

*/ 
?


 From: KOKO电子传单 [EMAIL PROTECTED]
 Date: Fri, 14 Oct 2005 06:33:57 +0800
 To: php-general@lists.php.net
 Subject: [PHP] 电子传单,最廉价的宣传方式
 
   南海鳄神无法可施,心想:“我既不能杀他,他又不肯求我,这就难了。”一瞥眼,见木婉清满脸关切的神
 色,灵机一动,猛地纵身过去,抓住她后领,将她身子高高提起,反身几下跳跃,已到了崖边,左足翘起,右
 足使招‘金鸡独立’势,在那千仞壁立的高崖上摇摇幌幌,便似要和木婉清一齐摔将下去。

   手掌刚要碰到程英后心,一瞥间见她颈中系着一条锦帕,素底缎子上绣着红花绿叶,正是当年自己精
 心绣就、赠给意中人之物,不禁一呆,倏地收回掌力,往日的柔情密意瞬息间在心中滚了几转,心想:“他
 虽与那姓何的小贱人成亲,心下始终没忘了我,这块帕儿也一直好好放着。他求我饶他后人,却饶是不
 饶?”一时心意难决,决定先毙了陆无双再说。拂尘抖处,银丝击向陆无双后心,阳光耀眼之下,却见她颈中
 也系着一条锦帕,李莫愁“咦”了一声,心道:“怎地有两块帕儿?定有一块是假的。”拂尘改击为卷,裹住陆
 无双头颈,将她倒拉转来。 

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



Re: [PHP] prevent user from getting scripts outside the web folder [this better?]

2005-10-13 Thread Ben

Graham Anderson said the following on 10/13/05 15:31:

Is this a bit better ?
As directed, I 'sanitized' all user input variables with trim and  
mysql_real_escape_string.


thanks for everyone's patience as I am starting at ground zero  
concerning security.



if( isset($_REQUEST['cmd']) OR isset($_REQUEST['path'] ))
{
// decrypt and santize variables
$cmd = isset($_REQUEST['cmd']) ? cleanser(decrypt($_REQUEST 
['cmd'])) : $cmd=null;
$path = isset($_REQUEST['path']) ? cleanser(decrypt($_REQUEST 
['path'])) : $path=null;

.
.
.

the cleanser script:
function cleanser( $value )
{
return mysql_real_escape_string( trim( $value ) ) ;
}

the 'decrypt' function uses MCRYPT_RIJNDAEL_256 with a $key stored  
outside the web folder.


many thanks :)


My understanding is that mysql_real_escape_string will only work while 
you are connected to mysql.  Not sure if that is the case in your situation.


- Ben

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



[PHP] Setting up Linux and SendMail for SMTP

2005-10-13 Thread Todd Cary
I have a Linux server on my network, however my main mail is handled by 
Thunderbird on my PC which uses my ISP's SMTP server (UserName and PW). 
 Can I configure SendMail to send mail to my ISP's SMTP server using 
the built in mail() function of PHP?


If I use one of the Mail Classes, I can do it and on my client's Linux 
server, mail() works (but they are not using an outside SMTP server).


Many thanks...

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



Re: [PHP] Obsession with BC, take 2

2005-10-13 Thread GamblerZG

Richard Lynch wrote:
 PHP developers assume that PHP5 will be frequently used to parse PHP4
 scripts. Why?
 Because that's how the real world works.

The real world works that way because, as you just said, installing 2 
php modules side by side is a great deal of system administration.



And what's so horrible about using separate engines to
run
php 4 and 5 scripts?



Nothing, if you can identify which are which, and have the
infrastructure to set up both and...

It's a great deal of system administration


Let me get it straight. There are two ways of running PHP four and five 
on one server. First one is by using five's compatibility mode, and it 
breaks some of the old scripts. The second one is by using two different 
apache modules. It *does not break anything*, but it's a pain to setup.


Judging sheerly by functionality and compatibility the second ways is 
better.


However, judging from what I know about PHP, nobody tries to make that 
way easier, because everybody assume that everyone else use the first 
way. Is it good old catch 22 in action, or are there some design 
considerations I'm not aware of?


--
Best regards,
Roman S.I.

http://sf.net/projects/naturalgine/

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



Re[2]: [PHP] Obsession with BC, take 2

2005-10-13 Thread Richard Davey
Hi,

Friday, October 14, 2005, 1:07:04 AM, you wrote:

 Let me get it straight. There are two ways of running PHP four and
 five on one server. First one is by using five's compatibility mode,
 and it breaks some of the old scripts. The second one is by using
 two different apache modules. It *does not break anything*, but it's
 a pain to setup.

There's another way - php4 runs as an Apache module, while php5 runs
as cgi (mapped to .php5, or to .php if you override it via htaccess).

Far less hassle to set-up.  Probably why the largest independent
hosting company in the world* does it this way. If they can manage it
across their thousands of servers, any host can.

* www.pair.com

Cheers,

Rich
-- 
Zend Certified Engineer
http://www.launchcode.co.uk

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



[PHP] Re: Obsession with BC

2005-10-13 Thread Oliver Grätz
GamblerZG schrieb:
 Recently, I asked my hosting provider when they are going to switch to 
 PHP5. They replied that it will not happen any time soon, since they 
 will install PHP5 only on new servers. Their reasoning was simple: PHP5 
 will inevitably break some old scripts, and it's just not worh all the 
 trouble. 

Must be the same reason why we are all still using DOS since some of the
best games just refuse to run on WinXP !? Noo...

There are a whole lot of new scripts that don't work with PHP4 so I
guess chances are the problem is already bigger in this direction (PHP5
code not running on PHP4) than in the other.

The provider arguments are FALSE! If they don't want to break old
scripts they can easily deploy both PHP4 and PHP5 as parallel
installation, either one of them as CGI or by using two Apache servers
and a proxy. The real arguemnts for the providers are

a) They are too lazy to do this
b) Two PHP versions in parallel might need more
   computing power which they refuse to invest for


AllOLLi

The answer is 42.
[Douglas Adams]

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



[PHP] Login is not working. Please help....

2005-10-13 Thread twistednetadmin
When I fill in the form with user and password, it goes to the
loginerror.php anyway.
Is this because I use switch with only one case(I'm going to make more
later), and if it is. What should I use instead?
This is my first php-script. I have tested this on both php4 and php5.
Please help.

(login.php)
?php


include (connection); // obvious



session_start();
switch (@$_GET['action']) // Gets set by the form action
{
case login:
$sql = SELECT name FROM DB
WHERE name='$_POST[user]';
$result = mysql_query($sql) or die(Couldn't execute query.);
$num = mysql_num_rows($result);
if ($num ==1) // loginname found
{
$sql = SELECT name FROM DB
WHERE name='$_POST[user]'
AND pass=password('$_POST[pass]');
$result2 = mysql_query($sql) or die(Couldn't execute query 2.);
$num2 = mysql_num_rows($result2);
if ($num2  0) // password is correct
{
$_SESSION['auth']=yes;
$logname=$_POST['user'];
$_SESSION['logname'] = $logname;
header(Location: page1.php);
}
else // password is not correct
{
unset($action);
header(Location: loginerror.php);
}
}
elseif ($num == 0) // Wrong name. Name not in db
{
unset($action);
header(Location: loginerror.php);
}

}

?

(form.php)


table
form action=login.php?action=login method=post

tr
td align=center valign=middle class=maintext

Login as:input type=text name=name

/td
/tr
tr
td align=center valign=middle class=maintext

Password:input type=password name=passbr

/td
/tr
tr

td align=center valign=middle class=maintext

input name=log type=submit value=Enter/td

/tr
/form
/table



[PHP] Re: Login is not working. Please help....

2005-10-13 Thread David Robley
twistednetadmin wrote:

 When I fill in the form with user and password, it goes to the
 loginerror.php anyway.
 Is this because I use switch with only one case(I'm going to make more
 later), and if it is. What should I use instead?
 This is my first php-script. I have tested this on both php4 and php5.
 Please help.
 
 (login.php)
 ?php
 
 
 include (connection); // obvious
 
 
 
 session_start();
 switch (@$_GET['action']) // Gets set by the form action
 {
 case login:
 $sql = SELECT name FROM DB
 WHERE name='$_POST[user]';
 $result = mysql_query($sql) or die(Couldn't execute query.);
 $num = mysql_num_rows($result);
 if ($num ==1) // loginname found
 {
 $sql = SELECT name FROM DB
 WHERE name='$_POST[user]'
 AND pass=password('$_POST[pass]');
 $result2 = mysql_query($sql) or die(Couldn't execute query 2.);
 $num2 = mysql_num_rows($result2);
 if ($num2  0) // password is correct
 {
 $_SESSION['auth']=yes;
 $logname=$_POST['user'];
 $_SESSION['logname'] = $logname;
 header(Location: page1.php);
 }
 else // password is not correct
 {
 unset($action);
 header(Location: loginerror.php);
 }
 }
 elseif ($num == 0) // Wrong name. Name not in db
 {
 unset($action);
 header(Location: loginerror.php);
 }
 
 }
 
 ?
 
 (form.php)
 
 
 table
 form action=login.php?action=login method=post
 
 tr
 td align=center valign=middle class=maintext
 
 Login as:input type=text name=name
 
 /td
 /tr
 tr
 td align=center valign=middle class=maintext
 
 Password:input type=password name=passbr
 
 /td
 /tr
 tr
 
 td align=center valign=middle class=maintext
 
 input name=log type=submit value=Enter/td
 
 /tr
 /form
 /table
 

Seems to me that you are passing a value 'name' as the username, but when
you search the database, you are using a value of $_POST[user] which does
not exist.

Note that the correct syntax should be $_POST['varname']


Cheers
-- 
David Robley

What goes up has probably been doused with petrol.

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



Re: [PHP] prevent user from getting scripts outside the web folder [this better?]

2005-10-13 Thread David Robley
Ben wrote:

 Graham Anderson said the following on 10/13/05 15:31:
 Is this a bit better ?
 As directed, I 'sanitized' all user input variables with trim and
 mysql_real_escape_string.
 
 thanks for everyone's patience as I am starting at ground zero
 concerning security.
 
 
 if( isset($_REQUEST['cmd']) OR isset($_REQUEST['path'] ))
 {
 // decrypt and santize variables
 $cmd = isset($_REQUEST['cmd']) ? cleanser(decrypt($_REQUEST
 ['cmd'])) : $cmd=null;
 $path = isset($_REQUEST['path']) ? cleanser(decrypt($_REQUEST
 ['path'])) : $path=null;
 .
 .
 .
 
 the cleanser script:
 function cleanser( $value )
 {
 return mysql_real_escape_string( trim( $value ) ) ;
 }
 
 the 'decrypt' function uses MCRYPT_RIJNDAEL_256 with a $key stored
 outside the web folder.
 
 many thanks :)
 
 My understanding is that mysql_real_escape_string will only work while
 you are connected to mysql.  Not sure if that is the case in your
 situation.

That is incorrect. mysql_real_escape_string is a php function, not mysql.




Cheers
-- 
David Robley

Computer programmers do it byte by byte.

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



[PHP] Volunteers Wanted for How-To testing / contribution

2005-10-13 Thread Brian Fioca
I've recently released version 1.0 of the WASP framework for PHP 5.http://wasp.sourceforge.netAnd I'm in the final draft stages of a How-To article:http://fioca.com/brian/wiki/index.php/How-To_Write_a_Simple_Blog_in_WASPWASP is a lightweight but powerful framework written in the spirit of (but rather different than) Ruby on Rails.  The purpose, really, is to utilize all of the enhancements made to PHP in version 5 to build a reusable framework for large applications.I'm looking for volunteers to try out the How-To to see if it works, makes sense, and is easy to follow and complete.  Any contributions will be properly credited in the final version.  I'm also looking for contributors to the framework, especially in the areas of Windows support, and ensuring it works on many database platforms.Check it out and send me an email if you'd like to contribute, or join the mailing list and send contributions there.Thanks!Brian /** * Brian Fioca * Chief Scientist / Sr. Technical Consultant * PangoMedia - http://pangomedia.com */ 

smime.p7s
Description: S/MIME cryptographic signature