Re: [PHP] Serving an image

2012-10-17 Thread Wouter van Vliet / Interpotential

 What is the diference between using imagecreatefrompng() and readfile()?
 Any performance improvement?


If you don't do any image minipulation, I would recommend readfile indeed.
The differences being that imagecreatefrompng load the image into memory,
ready to change it (overlay, rotate, crop, colours, .. anything), and
readfile just sends whatever file you point it to back to the browser (or
other output).

Then again, if you all you're doing is sending an image to the browser;
then why not do a redirect - or simply refer to the image directly?

Wouter


Re: [PHP] Class not functioning

2009-12-16 Thread Wouter van Vliet / Interpotential
Allen,

Before you go with my static-approach, please do consider Shawn's registry
pattern suggestion. That's pretty sweet too ;-).

A little response to your long text, before I help you fix the bug. A static
property is basically the same as a regular property on an object. Only
difference is that they are not reset when the class is instantiated into an
object. They are just there.

Now, about your bug. The syntax for referencing a static property is a bit
weird - which has to do with the existence of class constants, which might
have set you off.

Notifier::notifyQueue would reference a class constant. The [] syntax is not
valid here, since a constant is - you got it: constant. And thus cannot be
changed.
Notifier::$notifyQ[] = 'div ... /div'; references the static property.

But... since notifyQ is a proptected static property, it is very unlikealy
that you'll ever actually write Notifier::$notifyQ. You add to this queue
from within the class itself, so therefore self::$notifyQ is a lot better.

Does that answer your question?

Btw; Shawn; Assuming that your Registry class holds objects, there is no
need have the ampersand in front of the get method or $object argument.
Objects are *always* references. And you might want to look at the __get,
__set and __isset magic.

Wouter


2009/12/16 Allen McCabe allenmcc...@gmail.com

 Wouter,

 Implementing your static idea was pretty easy, I was already referencing
 Notifier with the :: operator in my other methods, however I am running into
 trouble assigning new values to the static array.

 I am getting a syntax error, unexpected '['  on this line of my Notifier
 class:

 Notifier::notifyQ[] = 'div class='.$message;

 . . .

 Any ideas why this is causing an error?
 (note: I did try using $this-Notifier, and it said I cannot do what-not to
 a non-object, can't remember the exact message at the moment)

 On Tue, Dec 15, 2009 at 2:30 PM, Wouter van Vliet / Interpotential 
 pub...@interpotential.com wrote:

 Allen,

 The short answer (but don't follow this):
 ?php
 class Meetgreet {
   public function deleteSingle($id, $number) {
   // do something
   global $Notify;
   $Notify-addToQ( .. );
   }
 }
 ?

 The long(er) answer:
 I assume your Notifier object functions as singleton? Ie; accross your
 entire application, there is only one instance of that class?

 Why not go-static? That is, to my experience, the sweetest way to make
 something globally accessible - without making something global. Like so

 ?php
 class Notifier {

protected static $queue = Array();

// make sure it can't be instantiated
private constructer __construct() {
}

public static function addToQ( $arg, $anotherArg) {
self::$queue[] = $arg.' - '.$anotherArg;
}

 }

 // and then from within any method anywhere, call
 Notifier::addToQ('foo', 'bar');

 ?

 Does that work for you?

 Regards,
 Wouter

 (ps. call me a purist, but a function defined in a class is no longer
 called a function, but a *method*)

 2009/12/15 Allen McCabe allenmcc...@gmail.com

  Hey all (and Nirmalya, thanks for the help!),


 I have a question that I just can't seem to find via Google.

 I want to be able to add messages to a qeue whenever my classes complete
 (or
 fail to complete) specific functions. I think have a call within my html
 to
 my Notifier class to print all qeued messages (via a function 'printQ').

 How do I access a globally instantiated class from within another class?

 Example:

 ?php

 // INSTANTIATE
 $Meetgreet = new Meetgreet;
 $Notify = new Notifier;

 ...
 ...

 $Meetgreet-deleteSingle($id, 1); // This completes a function within
 Meetgreet class. That function needs to be able to use the Notifier
 function
 addtoQ(), how would this be accomplished?

 ?
 ...
 ...

 ?php  $Notify-printQ()  ?

 On Mon, Dec 14, 2009 at 6:07 PM, Nirmalya Lahiri
 nirmalyalah...@yahoo.comwrote:

  --- On Tue, 12/15/09, Allen McCabe allenmcc...@gmail.com wrote:
 
   From: Allen McCabe allenmcc...@gmail.com
   Subject: [PHP] Class not functioning
   To: phpList php-general@lists.php.net
   Date: Tuesday, December 15, 2009, 6:17 AM
Hey everyone, I just delved into
   classes recently and have been having
   moderate success so far.
  
   I have a puzzler though.
  
   I have the following class decalred and instantiated:
  
   class Notify {
var $q = array();
  
public function addtoQ($string, $class)
{
 $message = 'span class='. $class .''.
   $string .'/span';
 $this-q[] = $message;
}
  
public function printQ()
{
 if (isset($q))
 {
  echo 'p align=center
   class=notification';
  foreach($this-q as $msg)
  {
   echo $msg .\n;
  }
  echo '/p';
 }
  
 return;
}
  
function __destruct()
{
 if (isset($q))
 {
  unset($this-q);
 }
}
   } // END CLASS Notify
  
  
   And in my script, I call it like so:
   $Notif = new Notify;
  
   I have run other statements in other

[PHP] Debian Lenny: Which 5.3 package should I use?

2009-12-15 Thread Wouter van Vliet / Interpotential
Hi Guys  Gals,

I've been playing around with PHP 5.3 for a while now on development servers
and servers solely used for start-ups and lower-profile apps. But now I'm
about to upgrade the servers for a high profile/high traffic website and
with this upgrade I'd also like to make the switch from 5.2 to 5.3. But -
which package should I choose? I want to rely on community tested builds, so
compiling myself is out of the question.

The server will run on Debian Lenny. The Two and a Half options I've been
able to find are:

  DotDeb:
http://www.dotdeb.org/2009/12/06/the-php-5-3-1-packages-have-been-updated/
  Debian Experimental: http://packages.debian.org/source/experimental/php5
  ~raaa Launchpad: https://launchpad.net/~raaa/+archive/ppa

Are there any others? Which is the best when it comes to:

   - Security?
   - Stability?
   - Ease of upgrade to Debian Squeeze later next year?

Thanks in advance for any help you're able to offer!

Regards,
Wouter

-- 
http://www.interpotential.com
http://www.ilikealot.com

Phone: +4520371433


Re: [PHP] strip tags but preserve title attributes

2009-12-15 Thread Wouter van Vliet / Interpotential
I've had quite some luck using the html2text class by Jon Abernathy

   http://www.chuggnutt.com/html2text.php

It's targetted to php 4, and rather old code - but it does the job for me.
Where the 'job for me' is converting html to text for when I'm sending out
emails in HTML format and want to offer the proper plain text alternative.

To be honest, I haven't checked how it handles title/alt attributes on
images - but I'm confident that it does it nicely, and if it doesn't that
you can add it yourself.

And if that doesn't suit your needs - you might want to take a look at this:

http://sourceforge.net/projects/simplehtmldom/

Regards,
Wouter

2009/12/15 Andrew Ballard aball...@gmail.com

 On Mon, Dec 14, 2009 at 6:43 PM, Ashley Sheridan
 a...@ashleysheridan.co.uk wrote:
  I'm looking for a way to strip HTML tags out of some text content
  (sourced from a web page) to leave just the text which I'll be running
  some basic analysis on. The thing is, I want to preserve text that is in
  alt and title attributes. I can't use any DOM functions, as I can't
  guarantee that the content will be valid XHTML, although it should be
  valid HTML.
 
  I'm happy doing this with string functions and regular expressions, but
  I was wondering if something for this already existed? The server I plan
  on putting this on does not have access to the shell (although it is a
  Linux server) so I won't be able to have Lynx or Elinks parse the
  content for me either :(
 
  Thanks,
  Ash
  http://www.ashleysheridan.co.uk
 

 Are you sure you can't use DOM? It has a function specifically for
 parsing HTML that does not have to be well-formed to load.

 http://www.php.net/manual/en/domdocument.loadhtml.php


 If that doesn't work, you might look at Zend_Filter_StripTags in ZF. I
 don't know if it will do exactly what you're after, but it seems to be
 more flexible than the strip_tags function built into PHP.

 Andrew

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




-- 
http://www.interpotential.com
http://www.ilikealot.com

Phone: +4520371433


Re: [PHP] Parsing JSON; back-slash problem

2009-12-15 Thread Wouter van Vliet / Interpotential


 If you don't have access to do this, look at stripslashes()


And if you absolutely want to be on the safe side - check* if the
magic_quotes option is enabled - if so; do stripslashes. If not - then
obviously don't.

* http://www.php.net/manual/en/function.get-magic-quotes-gpc.php




 --
 Thanks!
 -Shawn
 http://www.spidean.com

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




-- 
http://www.interpotential.com
http://www.ilikealot.com

Phone: +4520371433


Re: [PHP] Class not functioning

2009-12-15 Thread Wouter van Vliet / Interpotential
Allen,

The short answer (but don't follow this):
?php
class Meetgreet {
  public function deleteSingle($id, $number) {
  // do something
  global $Notify;
  $Notify-addToQ( .. );
  }
}
?

The long(er) answer:
I assume your Notifier object functions as singleton? Ie; accross your
entire application, there is only one instance of that class?

Why not go-static? That is, to my experience, the sweetest way to make
something globally accessible - without making something global. Like so

?php
class Notifier {

   protected static $queue = Array();

   // make sure it can't be instantiated
   private constructer __construct() {
   }

   public static function addToQ( $arg, $anotherArg) {
   self::$queue[] = $arg.' - '.$anotherArg;
   }

}

// and then from within any method anywhere, call
Notifier::addToQ('foo', 'bar');

?

Does that work for you?

Regards,
Wouter

(ps. call me a purist, but a function defined in a class is no longer called
a function, but a *method*)

2009/12/15 Allen McCabe allenmcc...@gmail.com

 Hey all (and Nirmalya, thanks for the help!),


 I have a question that I just can't seem to find via Google.

 I want to be able to add messages to a qeue whenever my classes complete
 (or
 fail to complete) specific functions. I think have a call within my html to
 my Notifier class to print all qeued messages (via a function 'printQ').

 How do I access a globally instantiated class from within another class?

 Example:

 ?php

 // INSTANTIATE
 $Meetgreet = new Meetgreet;
 $Notify = new Notifier;

 ...
 ...

 $Meetgreet-deleteSingle($id, 1); // This completes a function within
 Meetgreet class. That function needs to be able to use the Notifier
 function
 addtoQ(), how would this be accomplished?

 ?
 ...
 ...

 ?php  $Notify-printQ()  ?

 On Mon, Dec 14, 2009 at 6:07 PM, Nirmalya Lahiri
 nirmalyalah...@yahoo.comwrote:

  --- On Tue, 12/15/09, Allen McCabe allenmcc...@gmail.com wrote:
 
   From: Allen McCabe allenmcc...@gmail.com
   Subject: [PHP] Class not functioning
   To: phpList php-general@lists.php.net
   Date: Tuesday, December 15, 2009, 6:17 AM
Hey everyone, I just delved into
   classes recently and have been having
   moderate success so far.
  
   I have a puzzler though.
  
   I have the following class decalred and instantiated:
  
   class Notify {
var $q = array();
  
public function addtoQ($string, $class)
{
 $message = 'span class='. $class .''.
   $string .'/span';
 $this-q[] = $message;
}
  
public function printQ()
{
 if (isset($q))
 {
  echo 'p align=center
   class=notification';
  foreach($this-q as $msg)
  {
   echo $msg .\n;
  }
  echo '/p';
 }
  
 return;
}
  
function __destruct()
{
 if (isset($q))
 {
  unset($this-q);
 }
}
   } // END CLASS Notify
  
  
   And in my script, I call it like so:
   $Notif = new Notify;
  
   I have run other statements in other classes that should be
   adding to the $q
   array (ie. Notify::addtoQ('ERROR! There Was An Error
   Updating The
   Database!', 'error');)
  
   However, when I try to get my webpage to display them
   using:
  
   $Notify-printQ();
  
   it does not seem to want to loop through this array (and
   print the
   messages). I am getting NO error message, in fact
   everything 'looks' fine,
   I'm just not seeing the appropriate message.
  
   Any help would be appreicated!
  
 
  Allen,
   You have made a small typing mistake in function printQ() where you
 would
  like to checked the array for its existence. By mistake you have wrote
 if
  (isset($q)). But your array variable is not an freely accessible
 array,the
  array is embedded into an object. So, you have to write the like if
  (isset($this-q)).
 
   Another point, you can't add a message into the array by calling the
  member function addtoQ() using scope resolution operator ::. If you
 really
  want to add message into the array, you have to call the member function
  from within the object. (ie. $Notif-addtoQ('ERROR! There Was An Error
  Updating The Database!', 'error');).
 
  ---
  নির্মাল্য লাহিড়ী [Nirmalya Lahiri]
  +৯১-৯৪৩৩১১৩৫৩৬ [+91-9433113536]
 
 
 
 
 




-- 
http://www.interpotential.com
http://www.ilikealot.com

Phone: +4520371433


Re: [PHP] Security Issue

2007-09-04 Thread Wouter van Vliet / Interpotential
Karl,

Some simple checks on $contpath could solve your problem. Make sure that:

 - it doesn't start with a /
 - doesn't contain /../
 - it doesn't contain a double slash //, or make sure the URL Fopen wrapper
is disabled:
http://nl3.php.net/manual/en/ref.filesystem.php#ini.allow-url-fopen

Usually $contpath = str_replace('/', '', $contpath); takes care of
everything.

On 04/09/07, Karl-Heinz Schulz [EMAIL PROTECTED] wrote:

  It was able to call up external includes using the below code which
 resulted that the server was used to send out spam.

 How can I protect the code?

 TIA

 ?php

 session_start();


 //---

 // index.php


 //---

 include(../inc/const.php);

 include(../inc/mysql.php);

  $menu=2;

 include(../inc/static.php);

 //include(../inc/prolog.php);

 $base = getenv(SERVER_NAME).getenv(SCRIPT_NAME);

 //$menu = $HTTP_GET_VARS['menu'];

 $submenu_list = $HTTP_GET_VARS['submenu_list'];

 $contfile = $HTTP_GET_VARS['contfile'];

 $id = $HTTP_GET_VARS['id'];

 $stk = $HTTP_GET_VARS['stk'];

 $contpath = $HTTP_GET_VARS['contpath'];

 if ($contpath==)

 { $contpath=./; }

 ?

 html

 head

 titleNeuer Wissenschaftlicher Verlag - ?php print
 $typ_subnav[$menu]?/title

 script language=javascript SRC=../js/rollover.js/script

 link rel=stylesheet href=../css/bor.css

 /head

 body bgcolor=#ff topmargin=0 leftmargin=0 marginheight=0
 marginwidth=0 link=#00 vlink=#00 alink=#00

 table height=100% width=100% topmargin=0 cellspacing=0
 cellpadding=0 border=0

 tr valign=top height=105

 td colspan=3 valign=top

 ? include(../inc/prolog.php);?

 /td

 /tr

 tr valign=top height=30

 td valign=top height=30
 background=../../img_pool/bg_left_right.gif?
 include(../inc/leftmenu.php);?/td

 td width=100%nbsp;/td

 !-- hier ist die rechte spalte mit dem background --

 !-- td height=30
 background=../../img_pool/bg_left_right.gifimg src=../img/trans.gif
 width=180 height=1/td --

 /tr

 tr valign=top

 td valign=top
 background=../../img_pool/bg_left_right.gif?php nav_menupic($menu);?

 ?php


 //

   //  Subnavigation


 //

 include(../inc/subnav.php);

 ?

 /td

 !-- END LEFT-NAV --

  td valign=top

  ?php include($contpath . /content.php);?

 !-- END CONTENT --

  /td



  ?//php include(../inc/epilog.php);

  ?

   /tr

  /table



  /body



 /html




-- 
Interpotential.com
Phone: +31615397471


Re: [PHP] Reload page after form submit

2007-08-30 Thread Wouter van Vliet / Interpotential
On 30/08/2007, Per Jessen [EMAIL PROTECTED] wrote:

 Wagner Garcia Campagner wrote:

  Hello,
 
  I'm building a web page just like a blog...
 
  Where the user input some information... (name, website and comment)
 
  This information is stored in a file...
 
  And then the page displays it...
 
  When the user access the page the first time, the information is
  displayed correct...
 
  After the user submit the information, the page become outdated...
  without this last information the user submitted...
 
  Is there a way to tell PHP to reload the page after the user submit
  the information, so the page is always updated??

 After you've processed the POST request, you finish with something like
 this:

 header(HTTP/1.0 303 See other);
 header(Location: #);
 exit;


It needs a little bit more than that. The script to which the form has been
submitted knows about the $_POST data, once you Location: to another page
that gets forgotten. Just add a line like $_SESSION['lastFormSubmit'] =
$_POST just before the first header() call and you're fine.






-- 
Interpotential.com
Phone: +31615397471


Re: [PHP] Database includes

2007-08-27 Thread Wouter van Vliet / Interpotential
On 27/08/07, Stut [EMAIL PROTECTED] wrote:

 I use a slightly different approach to prevent the need to mess about
 with files when moving to production. At the end on config.php I have
 this...

 if (file_exists('config_dev.php'))
  require 'config_dev.php';


I've got my own variation on this, came to use it to prevent overwriting
config files for stage/dev/live or other versions of a site. I've got a
general purpose constants file, which defines a lot of constants which are
generally used a lot in my applications (file rootdir, DAY, HOUR, database
passwords, some regexes, these things). Instead of just defining them there,
I define them using a simple conditional define function (if
(!defined($constantName) define($constantName, $value)). On top of my
constants.inc.php (as I chose to call it) I use the following:

if (isset($_SERVER['SERVER_NAME'])) {
$_config_file =
dirname(__FILE__).'/../eg/'.$_SERVER['SERVER_NAME'].'.inc.php';
@include($_config_file);
}

The included hostname specific config file would then define some constants,
and because they are already defined the default values from
constants.inc.php don't get set anymore.

Hope this is of help to anybody, it has certainly relaxed my deployment
process..

Wouter


In config_dev.php I override anything defined in config.php that needs
 to be different on the current server. The config_dev.php file is *not*
 in source control so it doesn't exist in production but each development
 and test environment has a version that modifies the production
 environment.

 There is a hit involved in the call to file_exists, but PHP caches it so
 the effect is minimal.

 -Stut

 --
 http://stut.net/

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




-- 
Interpotential.com
Phone: +31615397471


Re: [PHP] help with session

2007-08-26 Thread Wouter van Vliet / Interpotential
I would go for:

if (isset($_REQUEST['gender'])) $_SESSION['registrationGender'] =
$_REQUEST['gender'];
print isset($_SESSION['registrationGender']) ? You are registered as
gender: .$_SESSION['registrationGender'] : Your gender is unknown;

And make no assumptions about a gender when you don't know any ;-)

On 26/08/07, Jason Cartledge [EMAIL PROTECTED] wrote:


 Hi, this is my first post to this newsgroup. Does this code look ok or is
 there a more clean way of doing this? I am learning. Thank you for reading.
 Jason

if ( !empty($_REQUEST['gender']) )
   {
 $registrationGender=$_REQUEST['gender'];
   }
   else {
  if (session_is_registered('registrationGender'))
   {
$registrationGender=$_SESSION['registrationGender'];
print you are preregistered as a $registrationGender;
   }
   else
   {
print your gender is unknown, youare assumed to be a
 male;
$registrationGender=male;
   }
}

 $_SESSION['registrationGender']=$registrationGender;

 _
 100's of Music vouchers to be won with MSN Music
 https://www.musicmashup.co.uk/index.html
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




-- 
Interpotential.com
Phone: +31615397471


Re: [PHP] Creating a table with merged cells

2007-08-23 Thread Wouter van Vliet / Interpotential
You may want to look into the rowspan and colspan attributes of td

G'luck!

On 23/08/07, Phpmanni [EMAIL PROTECTED] wrote:

 Hi
 I need to represent a sort of map. The map is a rectangular
 table of size X in widht and Y in height, so that I have X*Y
 square cells. I need to record in a database some infos for
 each cell.
 This is easy, I thought to use a record that is something
 like (X,Y,MyData), so with two nested loops I can create the
 HTML table with data in it.
 The problem is that I need to join adjacent cells, so that I
 can obtain bigger cells made of base little square cells.
 So, starting from a table like this (see with fixed size font)
 +-+-+-+-+-+-+-+-+-+
 | | | | | | | | | |
 +-+-+-+-+-+-+-+-+-+
 | | | | | | | | | |
 +-+-+-+-+-+-+-+-+-+
 | | | | | | | | | |
 +-+-+-+-+-+-+-+-+-+

 I must find a way to store in the database a table like this
 +-+-+-+-+-+-+-+-+-+
 | 2 | | | |4 cells|
 +-+-+-+-+-+-+-+-+-+
 | |BIGBIGB| | | | |
 +-+BIGBIGB+-+-+-+-+
 | |BIGBIGB| | | | |
 +-+-+-+-+-+-+-+-+-+

 I thougt to use a record like (X,Y,XWIDTH,YHEIGHT,DATA), but
 I cannot imagine the way to create the resulting HTML table.
 Using graphics will be a lot easyer, but I must insert
 combos and checkboxes into the cells, so I must use html...
 Any ideas?

 Thanks!

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




-- 
Interpotential.com
Phone: +31615397471


Re: [PHP] Out of Memory error

2007-08-23 Thread Wouter van Vliet / Interpotential
I've got a followup question to this. Whenever you're doing something that
takes too much memory, having a file uploaded that's bigger than max upload
size (actually, not sure if that applies but I think it does) or when your
script is taking too long to execute it just dies with a very unfriendly
error.

Is there any way to catch these errors, stop the script in some other way
just before it ends so we can provide some reasonable feedback to the user?

On 23/08/07, Robert Cummings [EMAIL PROTECTED] wrote:

 On Fri, 2007-08-24 at 01:21 +1000, Naz Gassiep wrote:
  I'm getting out of memory errors in my image handling script, I *think*
  its because I'm handling images that are too large to fit in memory, but
  I thought I'd check before just upping the setting to 32mb.
 
  It is currently set to 16mb and I am working with a 2048x1536 image. Is
  it possible that the image is what is causing the scrip to OOM?

 Very likely.

 Cheers,
 Rob.
 --
 ...
 SwarmBuy.com - http://www.swarmbuy.com

 Leveraging the buying power of the masses!
 ...

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




-- 
Interpotential.com
Phone: +31615397471


Re: [PHP] Override parent class constants

2007-08-22 Thread Wouter van Vliet / Interpotential
I hate to disappoint you, but there's no real alternative. Same annoyance
with get_class() and __CLASS__ always giving you the class in which the
call is defined instead of the class which is actually being called when
dealing with static methods.

What you could do is define a protected static method in every subclass,
something like getConstant(), which always gives you the constant from the
correct class. I can't come up with a better solution than that. And I've
been trying to find one since the first version of php5 ;-)

On 22/08/07, James Ausmus [EMAIL PROTECTED] wrote:

 Hello - I'm trying to find a (sane) way to, in an extended class,
 override the parent class's constants, something like the following
 (which doesn't actually work):

 class baseClass
 {
   const myBaseVar = base value!;

   protected $myVar;

   function __construct()
   {
 $this-myVar = self::myBaseVar;
 echo $this-myVar;
   }
 }

 class extClass
 {
   const myBaseVar = overriden value!;
 }


 And, when instanciated, should do the following:

 $bc = new baseClass();
 Output: base value!

 $ec = new extClass();
 Output: overridden value!


 Any way to do that?
 There's a hacky way to do it, which would be to change the
 __contruct() function to the following:

 function __construct()
 {
   $this-myVar = eval(echo  . get_class($this) . ::myBaseVar;);
   echo $this-myVar;
 }

 but that is really, really ugly - I don't want to have to change all
 instances of myVar re-initialization in my baseClass methods into eval
 statements...


 Any thoughts?

 -James

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




-- 
Interpotential.com
Phone: +31615397471


Re: [PHP] Re: Table shows even when if () is false

2007-08-22 Thread Wouter van Vliet / Interpotential
On 22/08/07, M. Sokolewicz [EMAIL PROTECTED] wrote:

 I'm pretty sure
 if(!empty($result_deferred_comments)) {

 does something else than you think it does.
 $result_deferred_comments = mssql_query($deferred_comments) or
 die(mssql_error());

 if it fetches any rows it will return a RESOURCE (yes, a resource which
 is NEVER empty()), if it has 0 rows, it will return TRUE(yes! Again
 non-empty), if it errors, it will return false (yes, empty).

 Instead, use
 if(false !== $result_deferred_comments  true !==
 $result_deferred_comments){


Minor addition; you actually want to know if the result value is a resource
or a boolean. So, why not use 'is_resource' ?

Apart from having shorter lines of code I usually prefer checking for
something that's true, but maybe that's a personal thing ;-)

Dan Shirah wrote:
  From my understanding, if $result_deferred_comments is empty, than none
 of
  the code below the if should be executed, correct?
 
  The actualy rows/columns that would contain the data do not appear, but
 I am
  still seeing the DEFERRED PAYMENT REQUEST COMMENTS table. Is the only
 way
  to block out EVERYTHING from being displayed if
 $result_deferred_comments is
  empty to use   around all of the HTML and not exit out of the PHP
 tags?
  Or am I doing something else wrong?
 
  Or, is it a problem with (!empty())?  Since the value is an array, will
 it
  never be parsed as empty even if there is no data retrieved?
 
  Below is my code:
 
  ?php
  $credit_card_id = $_GET['credit_card_id'];
 
  $deferred_comments= SELECT * FROM comments WHERE credit_card_id =
  '$credit_card_id' AND request_type = 'D';
  $result_deferred_comments = mssql_query($deferred_comments) or
  die(mssql_error());
 
  if(!empty($result_deferred_comments)) {
  ?
  table width=700 border=1 align=center
tr
  td bgcolor=#FF9900
  div align=centerstrongDEFERRED PAYMENT REQUEST
  COMMENTS/strong/div/td
/tr
  /table
  table width=700 border=0 align=center
  ?php
  while ($row_deferred_comments =
  mssql_fetch_array($result_deferred_comments)) {
 $id_deferred_comment = $row_deferred_comments['request_id'];
 $dateTime_deferred = $row_deferred_comments['comment_date'];
 $deferred_comments = $row_deferred_comments['comments'];
 $deferred_wrap_comments = wordwrap($deferred_comments, 60, br
 /\n);
  ?
  tr
  td width='108' height='13' align='center' bgcolor=#FFD9C6
  class='tblcell'
div align='center'?php echo $id_deferred_comment
 ?/div/td
  td width='148' height='13' align='center' bgcolor=#FFD9C6
  class='tblcell'
div align='center'?php echo $dateTime_deferred ?/div/td
  td width='444' height='13' align='center' bgcolor=#FFD9C6
  class='tblcell'
  div align='left'?php echo $deferred_wrap_comments; ?/div/td
  /tr
  ?php } ?
  /table
  ?php } ?
 
  Thanks,
  Dan
 

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




-- 
Interpotential.com
Phone: +31615397471


Re: [PHP] Redirection with header (was Re: [PHP] Cookies and sent headers)

2007-08-20 Thread Wouter van Vliet / Interpotential
On 20/08/07, tedd [EMAIL PROTECTED] wrote:

 At 10:40 PM +0200 8/19/07, Wouter van Vliet / Interpotential wrote:
 What you're proposing, is to actually display some content on another
 page
 then were the content is originally intended? I'm sorry, but I would
 consider that 'bad practice'. To me, it makes perfect sense that you
 don't
 want to leave the user on the page where login was originally handled.
 For
 various reasons. One very obvious would be the 'refresh thing', where
 your
 browser asks the user if they want to send the form again. Quite
 annoying.
 Then, what about bookmarks? ...


 No, what I had proposed was an alternate method to accomplish what
 you said you wanted. But, it appears that my efforts and the demo did
 not receive sufficient attention for you to understand what wass
 being presented. Instead, you tell me that what I've shown you is bad
 practice -- interesting.


First of all - I didn't ask the initial question ;-). Other than that, I
think our philosophies our basically the same. But when you say that you are
redirecting the user to another page, while you are actually including a php
script - that's not my understanding of redirecting.

You said that you wanted to remove login from the browser history,
 which is screwing around with the user's browser and is clearly bad
 practice.


Generally yes, removing a page from the browser's history would be
considered bad practice. However, we are not really talking about a page
here. What I understood from the initial question is as follows:

 - http://www.site.com/ contains some login form, action of that form is
(for example) /login.php
 - The user is sent to /login.php where the login is checked
 - From there, the user either gets to a content page where it would
typically show welcome {user} or something, or back to the index page when
login failed
 - As you see, login.php is not really a page but more of a 'pseudo page'
and therefore I cannot see any reason not to send a proper 303 header. see:
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html

My method simply stops the user from visiting the same page more than
 once during a session and leaves their browser data alone -- nothing
 bad practice about that!

 AFTER my demo runs, if you repeatedly refresh the page you are
 directed to, then certainly that would become annoying. But that
 wasn't the intent, nor part of the demo, which you clearly didn't
 read and obviously didn't understand.

 As far as bookmarking the page, but of course you can bookmark the
 page! Did you even try?

 Oh well, so much for trying to help someone understand sessions. As
 my mother often said No good deed ever goes unpunished.


I've got another one, There is no selfless good deed.

If you had simply said, I don't understand, please explain; or asked
 a question or two; or said thanks, but no thanks, I'm going to do it
 another way, then that would have been fine. But to say that the demo
 I prepared for you exhibited bad practice, especially when you are
 absolutely friggen clueless as to what it is doing, is a bit too much
 -- I'll be sure to pass over your post in the future.


I don't think there wasn't anybody who didn't appriciate your suggestion.
Only thing I was trying to do was chip in my two cents. Again, I wasn't the
one who originally asked the question and I certainly am not friggen
clueless. I just came to think about what the teacher at my Flex course
from a couple of months ago said about good and bad practice. He said
there is none. If your solution works good for you, that's your good
practice. And if mine doesn't work for you, it's your bad practice - while
it is still my good practice.

Something however I am trying to fight against, if you let me put it like
that - is people approaching scripts as if they are pages. When you are
including a script that is usually called as a page into another script
you should be very aware for any clashes between variables. Another reason
why it may be easier to just put in a Location: header and call your script
as it was originally intended.

Wouter

tedd

 ---

 
 I would definately go for the Location: header solution!
 
 On 19/08/07, tedd [EMAIL PROTECTED] wrote:
 
   At 8:52 AM +0200 8/19/07, Otto Wyss wrote:
   In my case I could easilly do without redirection but just exit and
   fall back on the calling page. Yet I want to remove the login page
   from the browser history. Does the header function have the same
   effect?
   
 
   O. Wyss:
 
   Instead of messing with the user's browser (not good IMO), why not
   use $_SESSION and make it such that if the user selects the log-on
   page again, they are redirected to another page? You don't even need
   header() to do that.
 
   Here's an example:
 
http://webbytedd.com/bb/one-time
 
   You will only see that page only once -- unless you find a way to
   clear the session.
 
   The process is simply to set a session variable and allow the user to
   see the page once. Upon

Re: [PHP] Redirection with header (was Re: [PHP] Cookies and sent headers)

2007-08-19 Thread Wouter van Vliet / Interpotential
What you're proposing, is to actually display some content on another page
then were the content is originally intended? I'm sorry, but I would
consider that 'bad practice'. To me, it makes perfect sense that you don't
want to leave the user on the page where login was originally handled. For
various reasons. One very obvious would be the 'refresh thing', where your
browser asks the user if they want to send the form again. Quite annoying.
Then, what about bookmarks? ...

I would definately go for the Location: header solution!

On 19/08/07, tedd [EMAIL PROTECTED] wrote:

 At 8:52 AM +0200 8/19/07, Otto Wyss wrote:
 In my case I could easilly do without redirection but just exit and
 fall back on the calling page. Yet I want to remove the login page
 from the browser history. Does the header function have the same
 effect?
 

 O. Wyss:

 Instead of messing with the user's browser (not good IMO), why not
 use $_SESSION and make it such that if the user selects the log-on
 page again, they are redirected to another page? You don't even need
 header() to do that.

 Here's an example:

 http://webbytedd.com/bb/one-time

 You will only see that page only once -- unless you find a way to
 clear the session.

 The process is simply to set a session variable and allow the user to
 see the page once. Upon returning, the session variable is checked
 and if it is not null, then the user is redirected to another page
 like so:

 if($visit != null)
 {
 ob_clean();
 include('a.php');
 exit(0);
 }

 Very simple.

 Cheers,

 tedd

 --
 ---
 http://sperling.com  http://ancientstones.com  http://earthstones.com

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




-- 
Interpotential.com
Phone: +31615397471


Re: [PHP] Cookies and sent headers

2007-08-18 Thread Wouter van Vliet / Interpotential
You best option would be to go through all of your include'd or require'd
files and make sure there is no whitespace before and after you open your
php tags. Those are often the cause for such problems. The easy way would
indeed be to use output buffering. In that case, put the call to ob_start();
on the first line of the file you're calling. You will still have to make
sure to not have any whitespace before your ?php opening.

To even bypass that, the output_buffering ini setting might be useful. Alter
it in your php.ini if you can, otherwise try your apache vhost configuration
or .htaccess. The syntax there is:

 php_flag output_buffering On

Good luck!

On 18/08/07, Kelvin Park [EMAIL PROTECTED] wrote:

 Kelvin Park wrote:
  Otto Wyss wrote:
  If built a simple login page and store any information within
  $_SESSION's. Yet I'd like to move these into cookies but I always get
  an error about sent headers. Is there a way to circumvent this
  problem without changing too much in the page?
 
  The setting of the cookies happens just at the end of the page.
 
if (!$errortext and $Anmelden) {
  if (!empty($Permanent)) {
$expires = time()+ 365 * 86400;  // 365 days
setcookie (l.Lastname, $_SESSION['l_Lastname'], $expires);
setcookie (l.Firstname, $_SESSION['l_Firstname'], $expires);
setcookie (l.Email1, $_SESSION['l_Email1'], $expires);
setcookie (l.Email2, $_SESSION['l_Email2'], $expires);
  }
  echo script type=\text/javascript\
parent.location.replace('$index_php;
/script;
  exit;
}
 
  O. Wyss
 
  ob_start() might help
 

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




-- 
Interpotential.com
Phone: +31615397471


Re: [PHP] Capturing shell command output.

2007-08-18 Thread Wouter van Vliet / Interpotential
You may want to look into shell_exec, which executes a command and returns
the output. If you're accepting arguments from user input, don't forget
proper use of escapeshellcmd and escapeshellarg ;-).

Something else that might cause your commands from failing, is that the
utilities are not inside apache's PATH - trying to call them by there
absolute filename can help out. Have you inspected your error_log? There
often tends to be a lot of useful stuff in there.

Good luck!
Wouter

On 18/08/07, shiplu [EMAIL PROTECTED] wrote:

 HI,
 I am working on a PHP project that interacts with command  line utilities.
 My php is running by apache. Means I am not running any php CLI.

 here is the function that I am using for capturing command output.

 function run_command($comamnd){
 $ret=`$command 1 COMMAND.OUT 21`;
 $contents=get_file_contents(COMMAND.OUT);
 return $contents;
 }

 The function does not work. If I use any shell command like ls, cat,
 echo, set. it works.
 But If I use any utility like, mpg321, cd-info. It does not work. It
 outputs a blank string.
 I used system(), passthru() with both 21 and 21. But no out put.
 All the time, its blank.
 Even I used a shell script run.sh
 run.sh contents:
 =
 #!/bin/sh
 sh COMMAND 1 COMMAND.OUT 21
 cat COMMAND.OUT
 echo 0  COMMAND
 =

 I called this script by this function
 function run_command($command){
$h=fopen(COMMAND,w);
fwrite($h,$command);
fclose($h);
ob_start();
passthru(./run.sh);
$ret = ob_get_contents();
ob_end_clean();
return $ret;
 }

 and by this.

 function run_command($command){
$h=fopen(COMMAND,w);
fwrite($h,$command);
fclose($h);
return system(./run.sh);
 }

 Please help me. or show me some way.


 --
 shout at http://shiplu.awardspace.com/

 Available for Hire/Contract/Full Time

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




-- 
Interpotential.com
Phone: +31615397471


Re: [PHP] Photo upload framework/library for PHP

2007-08-18 Thread Wouter van Vliet / Interpotential
I often use MCImageManager, by moxiecode:
http://tinymce.moxiecode.com/paypal/item_imagemanager.php. Integrates well
into tinyMCE, but can be used without that as well.

I'm not entirely sure it's what you are looking for, but I think it very
well may be. And if it doesn't help you now, it may do so at some other
point ;-)

On 18/08/07, Steve Finkelstein [EMAIL PROTECTED] wrote:

 Hi all,

 Can anyone suggest a photo upload/framework type library I can incorporate
 seamlessly into a PHP project I'm working on?

 I'd like for users to have an elegant UI to upload photos of their
 vehicles
 into my application. Mutli-file and progress bars would be a plus. I'm
 looking to integrate this code using the Code Igniter framework.

 Thanks all for any suggestions.

 - sf




-- 
Interpotential.com
Phone: +31615397471


Re: [PHP] cant get if logic correct..

2007-08-17 Thread Wouter van Vliet / Interpotential
is_integer probably wouldn't work, since you're dealing with strings here.
Your best friend here would probably be 'is_numeric' which would return true
on both the string '1' as the integer 1 true. As well as 1.1 and '1.1'. The
only one solution I could think if would be:

   preg_match('/^\d+$/', $stnr);

--
Ain't it always the small things like this that consume too much time?

On 17/08/07, Sanjeev N [EMAIL PROTECTED] wrote:

 Why don't you try to check for if it is integer. You will get the function
 to check the variable (is_integer not sure) in manual.

 Warm Regards,
 Sanjeev
 http://www.sanchanworld.com
 http://webdirectory.sanchanworld.com - Submit your website URL
 http://webhosting.sanchanworld.com - Choose your best web hosting plan

 -Original Message-
 From: Gregory Machin [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, August 15, 2007 7:01 PM
 To: php-general@lists.php.net
 Subject: [PHP] cant get if logic correct..

 Hi
 i have a piece of code that gets info from a comma delimited file,
 then gets each value that is to be insterted into the database 

 The variabls must only contain numbers and must not be null ..
 but the  logic i have is iether not working or there are some hidden
 characters creeping in because it is processing the data ... how can i
 do this better ?


 for($i=2;$i$arrsize;$i++){
   $parts=explode(,,$lines[$i]);
   $stnr=$parts[0];
   $subj=$parts[1];
   $mark=$parts[4];
 if (($stnr) and ($subj) and ($mark)){
//do alot of something lol
}
}

 --
 Gregory Machin

 --
 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




-- 
Interpotential.com
Phone: +31615397471


[PHP] HTML attribute / url safe wordwrap function

2005-01-04 Thread Wouter van Vliet
Howdy,

Yes, I've googled - and yes, I've searched the archives - but didn't
find a solution for my problem. Here's the deal:

On a website ppl can react on articles and post messages. The content
of a message is given to a function which parses it all, taking care
of long words which could mess up the interface. Or actually - it
does do that. It all wraps perfectly fine with the following lines of
code:

?php
 $txt = 'website ppl can react on articles a
href=http://aspn.activestate.com/ASPN/docs/PHP/function.wordwrap.html;wordwrap/a';
 $txt = preg_replace('#(a.*)((http|ftp|www).{13})(.*)(.{20})(/a)#U',
' $1$2(...)$5$6 ', $txt);
 $txt = preg_replace('/([\.\?\w\)\(\:\',!\-\=]{30})/', '$1 ', $txt);
?

Unfortunately, this also breaks the weblink address. So, some
wordwrapping function that doesn't do that would be cool. So far, I
haven't been able to find it or create it myself.

Somebody out there feels like giving it a shot?

Thanks,
Wouter

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



Re: [PHP] Re: Calculate No Of Days

2005-01-04 Thread Wouter van Vliet
On Mon, 03 Jan 2005 22:58:49 -0500, Jerry Kita [EMAIL PROTECTED] wrote:
 Khuram Noman wrote:
  Hi
 
  Is there any function avialable in PHP to calculate
  the no of days by passing 2 dates like 1 argument is
  1/1/2005 and the second one is 1/2/2005 then it
  returns the no of days or how can i do that if there
  is no builtin function .
 
  Regards
  Khuram Noman
 

Maybe you can try the pear Date package - it has some handy function
that does exactly what you're asking for:

http://pear.php.net/package/Date/docs/1.4.2/apidoc/Date-1.4.2/Date_Calc.html#methoddateDiff

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



Re: [PHP] Apache Server with php

2005-01-04 Thread Wouter van Vliet
On Tue, 4 Jan 2005 08:37:26 -0800, Ramiro Trevino
[EMAIL PROTECTED] wrote:
 Hi,
 
 I am having issues with the installation and configuration of my Apache
 server 2.0.52(win32). All is well when I restart the server with the
 exception of, when I load the following lines.
 
 I opened up the httpd.conf file and searched for #LoadModule ssl_module
 modules/mod_ssl.so.
 Directly underneath that line, I added LoadModule php4_module
 D:/php/sapi/php4apache2.dll.
 My plan was to run PHP as a module for Apache, instead of as a CGI binary but
 every time I add this line my server will not restart but I get an error
 stating The requested operation has failed.
 
 I checked to ensure the path was correct to this dll and all is well. Any
 suggestions?
 
 Thanks,
 Ramiro

there's some *more* dll's you need to copy from the php package to
somewhere under your PATH. I'm not really sure which ones, but the
install notes do explain a lot. Or you can try to point your cmd line
to the apache bin dir, and execute apache.exe . That should tell you
why it can't start.

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



Re: [PHP] HTML attribute / url safe wordwrap function

2005-01-04 Thread Wouter van Vliet
On Tue, 4 Jan 2005 16:41:16 -0500, [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote:
 I don't know if I understand exactly what you're trying to do, but you might 
 try the HTML tag nobr/nobr to get the HTML not to wrap the line.  See if 
 that helps at all.
 
 Good luck!
 
 -TG
 
 = = = Original message = = =
 
 Howdy,
 
 Yes, I've googled - and yes, I've searched the archives - but didn't
 find a solution for my problem. Here's the deal:
 
 On a website ppl can react on articles and post messages. The content
 of a message is given to a function which parses it all, taking care
 of long words which could mess up the interface. Or actually - it
 does do that. It all wraps perfectly fine with the following lines of
 code:
 
 ?php
  $txt = 'website ppl can react on articles a
 href=http://aspn.activestate.com/ASPN/docs/PHP/function.wordwrap.html;wordwrap/a';
  $txt = preg_replace('#(a.*)((http|ftp|www).13)(.*)(.20)(/a)#U',
 ' $1$2(...)$5$6 ', $txt);
  $txt = preg_replace('/([\.\?\w\)\(\:\',!\-\=]30)/', '$1 ', $txt);
 ?
 
 Unfortunately, this also breaks the weblink address. So, some
 wordwrapping function that doesn't do that would be cool. So far, I
 haven't been able to find it or create it myself.
 
 Somebody out there feels like giving it a shot?
 
 Thanks,
 Wouter
 

Nono .. this is actually quite the opposite ;). Thing is, I'm
expecting input like:


Hi I aM sOmeBodY whO Is anNoyiNg
*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=
looK heRe: a 
href=www.somewhere.com/some/long/path/exceeding/30/chars/and/even?more=notlesswww.somewhere.com/some/long/path/exceeding/30/chars/and/even?more=notless/a


this long line of sequential characters causes the website interface
to stretch and thus needs to be wrapped. Using php's wordwrap()
function won't do, cuz it will also wrap the URL so I'd be looking for
some function that only adds some whitespace to strings outside 
and  signs. Or: not between  and 

(input is shown as it eventually reaches the mentioned calls - I do
not actually allow thtml to be entered :P)

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



Re: [PHP] Weird characters output

2004-09-20 Thread Wouter van Vliet
 I have recently moved a site over to a new server. Now certain
 characters are being replaced by weird characters. EG: the ' single
 quote is being replaced by a question mark and other characters are also
 affected. the information that contains these characters is inside a
 mysql database. The webserver is Apache and it is running on a linux, I
 have googled and found that it is an Apache PHP issue but have yet to
 come up with a solution. If anyone knows whats causing the problem and
 could help that would be great.

Most likely this is one of many occurences of the UTF problem. Try
adding the line
AddDefaultCharset iso-8859-1

to your httpd.conf, either within your vhost specification or by
replacing the main one. Then restart Apache. Should work.

If you don't have root access - try adding it to an .htaccess file,
but I don't know of this directive is allowed in there ..

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



Re: [PHP] Fork PHP script X at a time.

2004-09-20 Thread Wouter van Vliet
 Hi, I have a bit of a cold today so I probably would have figured this
 out for myself eventually but hey ;-)
 
 Right I have a script that I need to run around 90 times thru a cron job
 but passing a different i.d. to it each time.
 
 I have experimented with running all 90 at once and its a no go as it
 just makes the server run to slow and the session cookies I use time out
 (I am doing some libcurl things).
 
 Also running them in a loop one at a time is no use because it takes
 about 8 hours.
 
 What I would like to do is fork off say 5-10 at a time and when one is
 done start another one in its place, as they all take different length
 of times to compleate.
 
 Any clues at where to start? Here is my fork all 90+ code...
 
 $sql = SELECT * FROM locations WHERE parent = '0';
 $res = mysql_query($sql) or die ($sql.mysql_error());
 while($data = mysql_fetch_array($res)){
exec(/usr/local/bin/php fork.php .$_data[id].  /dev/null );
 }

You should be able to find out about the PID's for every forked
process, and use a loop (advisable with a sleep() in it) to see how
many procs are still running.. When the amount drops somewhat, spawn
another ..

Hope will get you somewhere!

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



Re: [PHP] perl regex in php and multiple escape rules

2004-09-14 Thread Wouter van Vliet
On Tue, 14 Sep 2004 11:18:33 +0200, Christophe Chisogne
[EMAIL PROTECTED] wrote:
 
 In a word:
 
 I'm looking for more detailed information about preg_replace
 (and other perl regex functions) than in the php manual,
 specifically about different escape rules interaction.
 
 In more words:
 
 PHP has it's own way of escaping strings [2]
 Ex \ within '' is '\' (or '\\' if at the end or before ' )
 \ within  is \ (or \\ if at the end or before  )
 So  \\  can be written '\\\' or '' or \\\ or 
 and \\\ can be written '\' or '\\' (same with  )
 (rule 1)
 
 Perl regex are powerfull and came with other escape rules [3]
 Ex regex to match... is ...
   \  /\\/
(newline)  \n /\n/
(2 chars)  \n /\\n/
 (rule 2)
 
 My problem is about preg_replace function, because it's entry in
 the php manual [1] is not specific enough -- I mean, writing
 a real specification seems impossible without more details
 
 The 'pattern' argument is a string, but how does php proceed it?
 I guess it first uses rule1 then rule2, ie php string escape rule
 (for '  and \ ) then perl regex rule (via verbatim use in perlre C library?)
 
 This mean that to match \n (the 2 chars), the perl re is \\n
 so correct php pattern is '\\\n' or 'n' or \\\n or n.
 (see comment 29-Mar-2004 05:46 on [1]). Is this right?
 /me think using perl regex is easier in perl than in php ;-)
 
 Is it the same for the 'replacement' argument?
 
 Another comment (steven -a-t- acko dot net, 08-Feb-2004 12:45) says
 To make this easier, the data in a backreference with /e is run through
   addslashes() before being inserted in your replacement expression.
 Is that user right?
 
 Ok, I can try to guess answers to my questions by probing things.
 But that didnt tell me if my guesses are wrong, or if what I guess
 is exactly what php pcre functions are supposed to do
 (not only now with php x.y.z but in the future too).
 And I prefer specifications over guesses.
 (think about ppl using alt attribute instead of title
   on img html tags : they guessed wrong by not reading html spec)
 
 In other words, is there some details about escape rules
 in pcre php functions? I feel much better when I can use
 a stable, reliable and precise API.
 
 Christophe
 
 [1] preg_replace in php manual
 http://www.php.net/manual/en/function.preg-replace.php
 
 [2] strings in php manual
 http://www.php.net/manual/en/language.types.string.php
 
 [3] pcre syntax in php manual
 http://www.php.net/manual/en/reference.pcre.pattern.syntax.php
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 

It's all very easy, actually. You take the real regex, and convert
that to a php string.

for example:

to match the two chars \n, in perl you'd do: 

  /\\n/

php requires each slash to be slashed again, so you'd get

 $regex = '/n/';

whenever you're in doubt, put the regex into a var, print that var and
if that what you get is exactly the regex you'd use in perl, you're
good. And yes, I do agree with anybody who'd state that it's a bit
confusing. Cuz it is!

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



Re: [PHP] Problem creating a date before 1970 on Fedora

2004-09-14 Thread Wouter van Vliet
On Mon, 13 Sep 2004 12:39:26 -0500, Greg Donald [EMAIL PROTECTED] wrote:
 
 
 On Mon, 13 Sep 2004 19:03:09 +0200, Wouter van Vliet
 [EMAIL PROTECTED] wrote:
  Howdy,
 
  I would assume this to be a common problem, but as I wrote to this
  list myself a couple of days ago I was only aware of it's existence on
  windows systems. Here's some sample code
 
1 ?php
2 $date = strtotime('12 feb 1950');
3 print $date.': '.date('r', $date).\n;
4 $date = mktime(0,0,0,2,12,1950);
5 print $date.': '.date('r', $date).\n;
6 ?
 
  And this is it's output:
 
  -1: Thu,  1 Jan 1970 00:59:59 +0100
  -3662: Wed, 31 Dec 1969 23:58:58 +0100
 
  My search on google didn't help me out, the docs say that it should
  work and I can remember me having used such code and got it working.
  Please fella's, what am I missing?
 
 The bottom of the strtotime() manual page where it says:
 
 Note:  The valid range of a timestamp is typically from Fri, 13 Dec
 1901 20:45:54 GMT to Tue, 19 Jan 2038 03:14:07 GMT. (These are the
 dates that correspond to the minimum and maximum values for a 32-bit
 signed integer.) Additionally, not all platforms support negative
 timestamps, therefore your date range may be limited to no earlier
 than the Unix epoch. This means that e.g. dates prior to Jan 1, 1970
 will not work on Windows, some Linux distributions, and a few other
 operating systems.
 
 A couple years ago when upgrading some web servers we found RedHat 7
 had this issue, strtotime() basically didn't work and always returned
 -1 on 'negative' unix timestamps.  I have never used Fedora but it's
 probably the same issue all over again.  I know this isn't the answer
 you were hoping for, but I wanted to share my experience.
 

so, basically my problem is confirmed to be existent - such a relieve
;) It's just that ppl I work for do want to be able to be born before
1970, cuz some are.

Mashed patatoes :@ - is there really no way to deal with this? Might
somebody have created a nice rpm of the kernel with t_*smth* set to 64
or 32 bits signed? I have full control over the server, so if i'd need
to make any changes, that is possible.

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



Re: [PHP] PHP: Supported OS

2004-09-14 Thread Wouter van Vliet
On Tue, 14 Sep 2004 12:12:16 +0200, FireSnake [EMAIL PROTECTED] wrote:
 Thanks for ur reply.
 
 I was looking for ports for these OS.
 server-side OS, not client-side.
 
 But i guess Php doesnt support severs with these OS then,
 at least i could not find any downloads like i did for Perl.
 
 Marlen
 
 Dan Joseph [EMAIL PROTECTED] schrieb im Newsbeitrag
 news:[EMAIL PROTECTED]
 
 
 
  Hi,
 
   could anyone tell me if PHP supports these OS?
   I wasnt able to find anything on the net.
  
   LynxOS
   MVS
   OS390
   QNX
   VMS
   Windows CE
   Xenix
  
   Thanks,
   FireSnake
 
  www.php.net
 
  You should be able to find builds for Windows and Linux (as far as
  server...).  If you are wondering what browsers on which OSes will display
  PHP pages, all of them, PHP is server side.
 
  -Dan Joseph
 

If you have some experience in compiling sourcecode into binaries, you
might be able to compile for all OS's you'd want to use it on.
Basically the only thing you'd need on each platform is a nice c
compiler.

Keep me posted!

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



Re: [PHP] Re: Simple Problem about forms and sending info to db

2004-09-14 Thread Wouter van Vliet
On Tue, 14 Sep 2004 18:32:50 +0800, Jason Wong [EMAIL PROTECTED] wrote:
 On Tuesday 14 September 2004 18:06, Logan Moore wrote:
  Ok I think I figured out my own problem. The speechmarks in the Form break
  up the speech marks in the echo statement so I originally changed the echo
  statements speechmark to a ' which worked but was informed that this was
  considered bad syntax and that maybe I should add a \ in front of all
  speechmarks which are not part of the echo statement.
 
 It's up to you. IMO, using single quote strings and breaking out when handling
 variables is more readable than using double quote strings and escaping the
 double quote (\).
 
  I could still do with an example of how to put the information from the
  form into the db though. As I have never done this before.
 
 Plenty of tutorials out there.
 

First of all, you're making some pretty harsh coding style errors. For
the sake of compatibility, always make sure you're quoting
non-numerical elements in an array, thus: write $_GET['action']
instead of $_GET[action]. Imagine, for example, what would happen if
you've got some field named public and you're upgrading to php5? Or
when, in php 5.4 (just saying smth), action suddenly becomes a
keyword. You're stuck then with dead code.

Good practice is also to check whether your expected array entry is
actually set. I usually do smth like:

isset($_GET['action']) or $_GET['action'] = 'thedefaultvalue';

or

if (!isset($_GET['action'])) {
  $_GET['action'] = 'thedefalutvalue'];
};

(both do the same, first one is just a lot shorter).

As adviced before, whenever you have to check if a certain variable
has a certain value, and if one of them is true, none of the others
will be true (which is the case with $_GET['action'] checks, usually)
- use the

if ( /* conditions */ ) {
} elseif ( /* other conditions */ ) {
}

method, rather than all seperate if's. I once changed this in somebody
else's code and found the script running about 5 (!!) times faster,
with about 15 conditions.

For inserting into the databas, mysql_connect() and mysql_execute()
are very good options. Or, if you're able to use the PEAR::DB package
I'd advice you to use that. It's more fun to do it that way, and will
help a lot if ever you'd want to change your database server from
mysql to something else (postgres, for example). Ow, and it also helps
a lot with any quoting problem you'd come up with.

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



Re: [PHP] Re: prob parsing Url

2004-09-14 Thread Wouter van Vliet
On Tue, 14 Sep 2004 13:21:09 +0300, Niklas Lampén
[EMAIL PROTECTED] wrote:
 Urlencode() and urldecode() should help you out.
 
 Niklas
 
 
 
 
 Sagar C Nannapaneni wrote:
  Hi folks..
 
  I'm using a form to send data from one page to another.
 
  one of the input fields in the form has a quotation mark
 
  Ex.: samsung 15 monitor
 
  in the next page i cant get the text after the  symbol in the field.
 
  I've tried both GET and POST methods.
 
  what might b the problem
 
  /sagar
 

I'd go for htmlentities($str, ENT_QUOTES); to encode and decode the
quotes, and other characters that are actually invalid to use in
normal html code... (

Later versions of php have a reverse function, called
html_entity_decode or smth)

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



Re: [PHP] small query prob in Mysql

2004-09-14 Thread Wouter van Vliet
On Tue, 14 Sep 2004 05:37:30 +, Curt Zirzow
[EMAIL PROTECTED] wrote:
 * Thus wrote Sagar C Nannapaneni:
 
 
  Hi everybody,
 
  I'm having a database named items, inthat
  one field name is itemname and the contents of
  that field is as follows
 
  Monitor 15 - LG
  Monitor 17 - Samsung
  Keyboard - TVS
  Monitor 15 - Samsung
  Mouse - Genius
  Keyboard - Microsoft
  
  
  The first part is the component name and the second is the Company name
  I need to have the distinct components in this field...like this
 
  Monitor
  Keyboard
  Mouse
 
  Any help would b greatly appreciated
 
 In order to do that properly, you would need a normalized database,
 a properly flattened data structure or hacked with some string
 manipulation.  Seek more help from a SQL or mysql list.
 
 Curt
 --
 The above comments may offend you. flame at will.
 

Little handson: there is a way of selecting a certian part of a field,
for instance everything till the first occurance of a space or dash.
Probably two ways even, one with regexes the other one with substr
kinda calls - all directly requestable to mysql.

though I'd follow Curt's advice if i were you, take two columns, or
even three - components, specifications, brand .. or smth.

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



Re: [PHP] Problem creating a date before 1970 on Fedora

2004-09-14 Thread Wouter van Vliet
On Tue, 14 Sep 2004 11:45:51 +0200, Christophe Chisogne
[EMAIL PROTECTED] wrote:
 Wouter van Vliet a écrit :
 Note:  The valid range of a timestamp is typically from Fri, 13 Dec
 1901 20:45:54 GMT to Tue, 19 Jan 2038 03:14:07 GMT. (These are the
 dates that correspond to the minimum and maximum values for a 32-bit
 signed integer.)
 
 To avoid unix timestamps limits, dont reinvent the wheel.
 The Pear Date class [1] can probably help you.
 Perhaps this should go in the manual for date() [2],
 as it looks like a FAQ.
 
 [1] pear Date
 http://pear.php.net/package/Date
 
 [2] php date()
 http://www.php.net/manual/en/function.date.php
 

I'll have a look at it, thanks!

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



[PHP] Problem creating a date before 1970 on Fedora

2004-09-13 Thread Wouter van Vliet
Howdy,

I would assume this to be a common problem, but as I wrote to this
list myself a couple of days ago I was only aware of it's existence on
windows systems. Here's some sample code

  1 ?php
  2 $date = strtotime('12 feb 1950');
  3 print $date.': '.date('r', $date).\n;
  4 $date = mktime(0,0,0,2,12,1950);
  5 print $date.': '.date('r', $date).\n;
  6 ?

And this is it's output:

-1: Thu,  1 Jan 1970 00:59:59 +0100
-3662: Wed, 31 Dec 1969 23:58:58 +0100

My search on google didn't help me out, the docs say that it should
work and I can remember me having used such code and got it working.
Please fella's, what am I missing?

Wouter

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



Re: [PHP] Perplexing problem, suggestions or answer needed

2004-09-11 Thread Wouter van Vliet
On Sat, 11 Sep 2004 03:11:08 -0700 (PDT), Mag [EMAIL PROTECTED] wrote:
 
 --- John Holmes [EMAIL PROTECTED] wrote:
 
  Mag wrote:
 
   Hi,
   I will be getting input from a textarea and then I
  am
   using explode to break the text into an array
  when
   it encounters a space.
  
   eg:
   one two three four ninty
   would be broken into 5 parts of an array.
  
   ** The array would then be put into a session **
   now I need to display the last part (which would
  be
   ninty using the above example) then take out the
   last part from the array then echo the next last
  part
   (which would be four) then take out the last
  part
   (using unset? ) etc etc so I have something like:
  
   Displaying Array :
   ninty
   (deleteing ninty)
   four
   (deleteing four)
   three
   (deleteing three)
   etc
  
   I have been reading the manual and have come this
  far,
   then I think I have to use the array splice
  function..
   Am totally confused, any help, links, tutorials,
   pointers, tips or code would be appreciated.
 
  Why not just use array_reverse() and then print them
  out in order using
  foreach?
 
  --
 
  ---John Holmes...
 
 Hello John,
 The reason is I am trying to chain some programs,
 the idea is to take the first part (in the original
 example ninty, then redirect to the second script
 passing that value...after the second script finishes
 it redirects back to the first script which will pass
 the second value (which would be four) which would
 be be passed to the second script etc
 
 I think the main part which is confusing me is how I
 can take out just certain used parts of the array in
 the $_SESSION array...ideas?
 
 Thanx,
 Mag
 

I guess you're looking for array_pop(), it pops the last element off
the end of the array. Look it up in the manual to convince yourself.

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



[PHP] find quoted string within a string (more of a regex question, though ..)

2004-09-10 Thread Wouter van Vliet
Howdy,

Thanks for the answers on my previous question, though it hasn't
resulted in a quicker dirparsing.. Anyway, here's a next one.

For my own reasons (can explain, would take long, won't till sbody
asks) I want to match a quoted string within a string. That is somehow
kind of easy, I know ... if it weren't for the slashing of quotes.
I've set up a regex that will nearly do the trick and now I'm looking
for an enhancement (or replacement) that will work in all cases.
Here's the code I use:

?php
$str= the quick \brown fox ' jumps \' over \the ' lazy \dog;
print Test String: $str\n;

$regex = '/(
([\'])
.*?
(
(?!)
\\2)
)/x';

print Regex to use: $regex\n;

preg_match($regex, $str, $m);
print_r($m);
?
(x modifier allows whitespaces in the regex).

When run, it produces the following output:

[output]
Test String: the quick brown fox ' jumps \' over \\the ' lazy dog
Regex to use: /(
(['])
.*?
(
(?!\\)
\2)
)/x
Array
(
[0] = brown fox ' jumps \' over \\the ' lazy 
[1] = brown fox ' jumps \' over \\the ' lazy 
[2] = 
[3] = 
)
[/output]

basically, I think that I'll need to change the assertion (?!\\) to
match only odd numbers of slashes - but I don't know how to do it. Who
does?

Thanks,
Wouter

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



Re: [PHP] Users of RDBMS

2004-09-10 Thread Wouter van Vliet
On Fri, 10 Sep 2004 03:07:35 +0530, Mulley, Nikhil
[EMAIL PROTECTED] wrote:
 You can create user from mysql prompt by connecting it through first
 cmdmysql -h host -u userid -p instance
 password : **
 then type
 GRANT ALL PRIVILGES ON *.* TO 'newuser'@'host'
 IDENTIFIED BY 'password' with GRANT OPTION;
 where newuser is new users id and host may be either localhost or any other host,if 
 you want to add that user to connect from any host then replace 'host' with '%'
 with single quotes.
 and password is new users password.
 Regards
 Nikhil
 
Please, please, please, do not use *.* and with GRANT OPTION for any
user you may want to create. Usually:

 GRANT all ON dbname.* TO [EMAIL PROTECTED] IDENTIFIED BY 'password'; 

does the trick, while *.* and with GRANT OPTION creates a new
superuser for the database. Also, I'd advice to explicitly specify the
host from which this user is allowed to login (don't use the '%').
Especially when you're creating a superuser ;).

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



Re: [PHP] Re: foreach()

2004-09-10 Thread Wouter van Vliet
On Wed, 08 Sep 2004 16:41:38 +0200, Daniel Kullik [EMAIL PROTECTED] wrote:
 Anthony Ritter wrote:
  I get a:
 
  Warning: Invalid argument supplied for foreach() in
  c:\apache\htdocs\or_6.4.php on line 15
 
  after submitting the form.
 
 
 Hello Anthony!
 
 As long as you don't submit the form with a single option selected there
 will be no $_POST['lunch'], therefore foreach() won't be able to loop
 through it.
 
 Add the line print_r($_POST) to your code in order to see what actually
 happens if you hit the submit-button of your form.
 
 
 Daniel
 

And when you've found out about the cause of your problem and what to
get rid of the notice, do either one of the following

if (!(isset($_POST['lunch'])  is_array($_POST['lunch'])))
$_POST['lunch'] = Array();
---
if (isset($_POST['lunch'])  is_array($_POST['lunch']) foreach
($_POST['lunch'] as $choice) {
 /* and the rest of your code */
}

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



Re: [PHP] problems setting up php5 on apache2 (WinXP Pro)

2004-09-10 Thread Wouter van Vliet
Ok, first of all: really, do use linux. It's not THAT bad for a home machine ;)

Now, the solution is quite simple as it is documented. Just copy the
file 'libmysql.dll' to your %WINDIR% folder and all should work. If it
doesn't, take libmysqli.dll as well. While you're at it, you might as
well copy all .dll's from the footdir of the zippackage to your
%WINDIR%, windows can't be hurt anymore than it already hurts and
it'll save you some hassle next time you want to enable another
extension.

Cheers,
Wouter

On Fri, 10 Sep 2004 09:31:43 -0400, Mathieu Dumoulin
[EMAIL PROTECTED] wrote:
 (Don't write to me telling me to use linux, i dont want to, this is my home
 machine not a production server, thank you, now if you really want to help
 keep on reading)
 
 I got a most recent copy of PHP 5.01 extracted into C:\php and everything
 seems to be working fine as long as i dont ask to load extensions. Any
 extension that i try to add will fail to load and i'm clueless.
 
 At first in the PHP.ini file this was the original directive:
 
 ; Directory in which the loadable extensions (modules) reside.
 extension_dir = ./
 
 And it would not work so i changed it to a hardcoded path
 
 ; Directory in which the loadable extensions (modules) reside.
 extension_dir = C:\php\ext
 
 Still no extensions wont load. Whats the weirdest, all the DLLs are at the
 correct location, apache reports: PHP startup: Unable to load dynamic
 library 'C:\php\ext\php_mysql.dll' - The specified module could not be
 found.
 
 but it IS there, at the exact location, i even looked and compared both
 paths manually letter by letter. Another weird thing to note is that some
 extensions DO load while some don't, here is a list of the extensions that
 i'm loading and which one fails (Note ALL extensions DLL are indeed in the
 folder intended, they just dont load)
 
 extension=php_bz2.dll
 extension=php_gd2.dll
 extension=php_imap.dll
 extension=php_mysql.dll  fails but it's vital to me
 
 these extensions are activated, only mysql fails, but there are other i
 wanted earlier lemme see which ones: (These would be nice to have, i'll tell
 you which one fails too)
 
 ;extension=php_exif.dll  fails
 ;extension=php_ldap.dll  fails (The file really isnt there so it's not a
 real problem)
 ;extension=php_openssl.dll  fails
 ;extension=php_pdf.dll
 ;extension=php_pgsql.dll
 ;extension=php_snmp.dll
 ;extension=php_sockets.dll
 ;extension=php_tidy.dll
 ;extension=php_zip.dll
 
 All of these will load... S I'm stuck there, i need help, tell me if you
 need to know anything else. i'll be glad to give you info, i want to set
 this up to further my PHP developement at home. We intensively use PHP4 at
 work but i wanted to start working on PHP5 to see how good it is.
 
 Till then
 See ya'll
 TheInsaneCoder
 
 --
 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] find quoted string within a string (more of a regex question, though ..)

2004-09-10 Thread Wouter van Vliet
On Fri, 10 Sep 2004 16:41:56 +0300, Robin Vickery [EMAIL PROTECTED] wrote:
 On Fri, 10 Sep 2004 11:43:54 +0200, Wouter van Vliet
 [EMAIL PROTECTED] wrote:
 
  For my own reasons (can explain, would take long, won't till sbody
  asks) I want to match a quoted string within a string. That is somehow
  kind of easy, I know ... if it weren't for the slashing of quotes.
 
 The standard perl regexp for matching double-quote delimited strings is this:
 
/([^\\]|\\.)*/
 
 which copes nicely with escaped characters. You'll probably need to
 double up the backslashes in php.
 
   $regex = '/([^]|.)*/';
 

Strawberryjuice on earth, I was expecting something very easy - but
this beats it all. Changed it a little, for it to also find 
single-quote delimited strings:

/( ([^\\]|\\.)* | '([^'\\]|\\.)*' )/x

works like a coconut!

Thanks a lot!
Wouter

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



Re: [PHP] Ouput buffer and vertual()

2004-09-10 Thread Wouter van Vliet
On Fri, 10 Sep 2004 09:24:06 -0400, John Holmes
[EMAIL PROTECTED] wrote:
 From: Ivik Injerd [EMAIL PROTECTED]
 
  --- test.php:
  ob_start();
  virtual(blah.pl);
  $tmp = ob_get_contents();
  echo \n[ TMP: $tmp ];
  ob_end_clean();
 
  --- test.php (output):
  blah
  [ TMP:  ]
 
  Looks like vertual() gets past the output buffer. How can I keep it in the
  buffer?
 
 I believe a RTFM is in order here.
 
 Quote: To run the sub-request, all buffers are terminated and flushed to
 the browser, pending headers are sent too.
 
 You can assume the good F or the back F, it's up to you. :)
 
 ---John Holmes... 
 
 

I think I must add something here - besides the fact that a function
like vertual() doesn't exist - I believe Ivik asked how he could get
around this, still doing something like the virtual but keep buffering
the output.

(and well, I'm quite curious for this myself too)

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



Re: [PHP] problems setting up php5 on apache2 (WinXP Pro)

2004-09-10 Thread Wouter van Vliet
On Fri, 10 Sep 2004 10:16:28 -0400, John Holmes
[EMAIL PROTECTED] wrote:
 From: Wouter van Vliet [EMAIL PROTECTED]
  Ok, first of all: really, do use linux. It's not THAT bad for a home
  machine ;)
 
  Now, the solution is quite simple as it is documented. Just copy the
  file 'libmysql.dll' to your %WINDIR% folder and all should work. If it
  doesn't, take libmysqli.dll as well. While you're at it, you might as
  well copy all .dll's from the footdir of the zippackage to your
  %WINDIR%, windows can't be hurt anymore than it already hurts and
  it'll save you some hassle next time you want to enable another
  extension.
 
 I believe the installation instructions have been updated so that copying
 files to the windows directories are not recommended or needed anymore. May
 want to consult the manual once again (but Apache not finding libmysql.dll
 is your problem).
 
 ---John Holmes...
 

;), solution remains as easy as it is documented. I just based my
advice on the docs downloading with php5.0.0, new docs are indeed a
bit different. Should've known that before.

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



Re: [PHP] Array inside Class

2004-09-10 Thread Wouter van Vliet
On Fri, 10 Sep 2004 14:26:22 -0400, John Holmes
[EMAIL PROTECTED] wrote:
 From: dirk [EMAIL PROTECTED]
  can anyone explain to me, why I can't resize an array inside a class?
  Sample Code:
 
  ?php
  class Liste {
var $input = array (1,2,3);
var $input2 = array_pad ($input,10, 1);
  }
  ?
 
  Output:
  Parse error: parse error, unexpected '(', expecting ',' or ';' in
  /srv/www/htdocs/stundenplan/stpoo.php on line 4
 
 You can't assign values like that.
 
 Try this:
 var $input = array(1,2,3);
 var $input2 = array();
 $this-input2 = array_pad($this-input,10,1);
 

To summarize:

?php
class Liste {

   var $input2;
   var $input;

function Liste() { /* or, if you're using php5: public function
__construct() { */
   $this-input = array(1,2,3);
   $this-input2 = array_pad($this-input,10,1);
}
}

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



Re: [PHP] image size?

2004-09-10 Thread Wouter van Vliet
You probably need this to set the Content-length: header, don't you?

I'd go into:

ob_start()
imagegif($imageResource);
// or whatever type of image you're writing
$blob = ob_get_clean();
unset($imageResource); // free the memory once you're not using the image

// size in bytes = strlen()+1, due to the \0 or null character at the end.
$byteSize = strlen($blob)+1;


On Fri, 10 Sep 2004 10:02:42 -0700, Ed Lazor [EMAIL PROTECTED] wrote:
  -Original Message-
  On Friday 10 September 2004 06:59, Ed Lazor wrote:
   Is there a way to get the size of an image created using the imagecreate
   function?
 
  Size as in ... ?
 
 I was looking for the size of the image in bytes.
 
 -Ed
 
 --
 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] A somewhat faster alternative to is_dir and is_file?

2004-09-09 Thread Wouter van Vliet
Howdy,

I've written some, kinda coolish, class that reads directories
recursively with some simple calls. Yihaaa, .. (but I'm not the only
one who has done that, I guess :P). Anyway, during the process of
traversing a directory it checks to see if the something that was
found is either a directory or a file, based on that it will do some
things. Fine, works.

But, now that I've got a directory with about 800 files to read I
noticed that it takes the poor script almost two seconds to find the
correct type of all the somethings. In fact, I timed it on a steady
1.71.

I've tried to use filetype() on the something, but that took even
longer - while looping through the directory without any checks
finishes in 0.01 seconds.

Now, for the question: does anybody know an alternative method on
checking whether a something is either file or directory?

Wouter

(this time, I'm on a Windows XP machine running PHP5 - just tested the
same thing on Linux and PHP 4.3.8 and came out on 0.63 secs, ..)

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



Re: [PHP] Timing on an internal email

2004-09-09 Thread Wouter van Vliet
  Not necessarily outside of php, but outside of webserver. You need to
  setup a cron job that will execute the phpmailer script.
 
 Gotcha..,
 
 My webserver is a windows box, so I can just run a task schedule and give it;
 php.exe myfile.php
 and that should do it?
 
 Would it be more efficient as a command line task or as an instance of
 the browser?

You can use a windows version of cron, find it here:
http://www.kalab.com/freeware/cron/cron.htm

Or, if you don't want to or can't install it - you can ask somebody
with a linux server/machine to setup a cron script that does a request
to a webpage that should send the emails.

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



Re: [PHP] converting seconds since unix epoc to date array

2004-09-07 Thread Wouter van Vliet
 beware of dates before 1969.

That problem mostly occurs on windows systems, and in fact it's dates
before 1 jan 1970 0:00 - php on windows will issue a warning if you
try to use dates like that

   Can anyone tell me how to convert a date stored in the format
   -MM-DD to an integer of seconds since unix epoc,

As for converting a -MM-DD date to epoch seconds, if it comes for
mysql (as suggested)  you should use

select UNIX_TIMESTAMP(date_column), * FROM tablename;

From another source, strtotime should work on this format. Consider
the 1 jan 1970 problem, check your error logs, call
error_reporting(E_ALL); to see for any additional problems... the
problem might as well be a typo in your varname.

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



Re: [PHP] Regex for Validating URL

2004-09-07 Thread Wouter van Vliet
On Tue, 7 Sep 2004 10:58:48 +0300, Burhan Khalid [EMAIL PROTECTED] wrote:
 -Original Message-
 From: Nick Wilson [mailto:[EMAIL PROTECTED]
 Sent: Thursday, September 02, 2004 11:59 AM

 Hi all,

 yeah, i know, i did do quite a bit of searching but I just cant find it...

 Does anyone have the regex to make sure an http address is full and without
 error? like http://www.example.com

 http://www.php.net/parse_url should do what you require.  If all you want to
 do is filter out the different parts of the url and check if they exist or
 not.

Consider what you'd mark as a full url, do you want to accept ftp://
and such links as well.. quite generic, I'd go for smth like:

/^([a-z]+):\/\/(([\w\.]+)\.([a-z]{2,3}))(:(\d+))?(\/.*)?$/

Which would give you:
Array
(
   [0] = ftp://www.example.com.com.uk:88/something/to/remember
   [1] = ftp
   [2] = www.example.com.com.uk
   [3] = www.example.com.com
   [4] = uk
   [5] = :88
   [6] = 88
   [7] = /something/to/remember
)

Here're seme things I didn't take into account:
* double dots (www...example..com)
* double slashes (www.example.com//asdfasf//asdfasf)
* check for protocol validity, might wanna change the first part to
(ftp|http|chrome|.. any protocol you want to accept)
* I left everything after the first slash completely to the
imagination of your input data - this can contain pretty much anything
anyways
* login details (user:[EMAIL PROTECTED])

If you want to have a full regex that is really complete, check out:
http://www.foad.org/~abigail/Perl/url3.pl, and execute it ..  (linked
from http://www.foad.org/~abigail/Perl/url2.html)

Enjoy!

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



Re: [PHP] Dynamic Class Methods

2004-09-07 Thread Wouter van Vliet
On Tue, 7 Sep 2004 09:37:44 -0400, Mathieu Dumoulin
[EMAIL PROTECTED] wrote:
 I'm trying to setup a function from user code inside a defined object or a
 class definition but it doesnt seem to work. Am i doing it right? Is there
 something i need to know... is it even possible?
 
 I know create_function can be used to create a function and it returns the
 ident to run the function later on, lookup create_function on php.net and it
 seems possible. Now i wonder if you can actually assign this function inside
 a class. My final goal is to create a set of functions or objects that will
 be able to implement interfaces to object classes, which is something
 missing to the PHP language.
 
 --
 RESULT
 --
 allo
 Fatal error: Call to undefined function: b() in
 /home/tech/web/testboard/implements.php on line 21
 
 -
 CODE
 -
 ?php
 class cls_a {
  function a(){
   echo 'allo';
  }
 }
 
 class impl_a {
  function get_impl_b(){
   return array('', 'echo Hello world;');
  }
 }
 
 $a = new cls_a();
 $b_code = impl_a::get_impl_b();
 $a-b = create_function($b_code[0], $b_code[1]);
 $a-a();
 $a-b();
 ?

First of all, I must say that from PHP5, the php (zend) engine does
support interfaces and implementing interfaces. So, maybe that's what
you're looking for... Anyway, now let's go on to helping you out with
your question.

Your approach is impossible. I'm stuck with the same thing, trying to
get the function name from a constant.. but there is a very nice way
of dealing with this. If you're running php5, it plainly works.
Earlier versions will need the (experimental) overload
(http://nl2.php.net/manual/en/ref.overload.php) function..


?php
class Obj {
  var $gen = Array();
  function registerFunction($name, $args, $imp) {
$this-gen[$name] = create_function($args, $imp);
  }
  function __call($n, $args) {
call_user_func_array(Array($this, $this-gen[$n]), $args);
  }
}
?

after a registerFunction call, you can call your function as you'd
expect to call it. Everything I just wrote is untested, but I'm pretty
sure it'll work - safe for maybe some typo's.

have fun!

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



Re: [PHP] ERROR

2004-09-07 Thread Wouter van Vliet
 ?
 session_start();
 //echo session_id();
 
 if (!isset($_SESSION['Id'])){
 
 echo(scripttop.location.href='../portada.php';/script);
 }
 ?
 
  Can somebody helps me ? the error is that login don' t access and I don't found the 
 error.

Jorge,

can you supply somewhat more information on what you're doing? Where
do you set the $_SESSION['id'] value? Do you make a call to
session_start() on the page where you set $_SESSION['id']?

(though, from the look of this post - the problem is probably the use
of a capital I in Id instead of a lowercase one. Case mangling is a
very common error ..)
(also, I'd advise you to use the somewhat more elegant ?php
header('Location: http://www.domain.com/path/to/portada.php');
exit(0); ? way of redirecting.)

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



Re: [PHP] Multi-User Text-Editing

2004-09-07 Thread Wouter van Vliet
 ?php
 
 $str1 = NEWTXT
 Once there was a Bar
 It was red
 It had some Foo
 Underneath its Foobar
 NEWTXT;
 
 $str2 = OLDTXT
 Once there was a Bar
 It had some Foo
 Underneath its Foobar
 OLDTXT;
 
 $arr1 = explode('\n', $str1);
 $arr2 = explode('\n', $str2);
 
 $count = 0;
 
 foreach ($arr1 as $line_num = $line) {
 if (isset($arr2[$count]  ($line === $arr2[$count]))) {
 echo Unchanged \ . $line . \\n;
 } elseif ($line !== $arr2[$count]) {
 echo Changed to \ . $line . \ from \ . $arr2[$count] 
 . \\n;
 } elseif (!isset($arr2[$count])) {
 echo Added \ . $line . \, was  . $arr2[$count] . 
 \\n;
 }
 
 $count++;
 }
 
 ?
 
 Then i'd get something like this:
 
 Unchanged Once there was a Bar
 Changed to It was red from It had some Foo
 Changed to It had some Foo from Underneath its Foobar
 Added Underneath its Foobar
 
 Where the second, third and fourth line is wrong - i added a line
 between There was a Bar and It had some Foo...
 
 How should i do this?

Add something that goes to the next line in one file and stays on the
same line in the other whenver an addition is found - and use
http://nl2.php.net/manual/en/function.levenshtein.php or
http://nl2.php.net/manual/en/function.similar-text.php instead of !=
to see if a line has changed. I've never used it myself, but the
return value gives you a number indicating how different the strings
are. If they're very different AND the number of lines is not equal
you know for almost sure it's an addition.

Have fun finding the difference!

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



Re: [PHP] Re: Instantiating class, classname in constant

2004-08-31 Thread Wouter van Vliet
Quoting Catalin Trifu [EMAIL PROTECTED]:
  ?php
  class Foo {
   const Bar   = 'Foo_Bar';
   const Chocolate = 'Foo_Chocolate';
   const Target= 'Foo Target';
  }
 
  $bar = new Foo::Bar();
  ?

 Foo::Bar() is taken by php as a function call and then it tries to
 instantate whatever that function returns.
 This is quite logical behaviour since function calls always end up with
 ().
 When you call
 $bar = new Foo::Bar;
 then the Foo::Bar is definetely refering to constant Bar in class Foo

 Cheers,
 Catalin
First of all: thank you Catalin for your thoughts!

Seems logical from that point of view.

According to the list if differences between variables and constants
(http://nl2.php.net/manual/en/language.constants.php) though, they should
pretty much work the same (no difference is mentioned). Thus, when both $bar
and Foo::Bar evaluate to the same value I would expect PHP to do the same
thing. Let me at least hope that the php team has considered many options on
how to deal with this...

If I do want to use the :: notation between PackageName and the actual name of
the class, I'm probably gonna be stuck using smth like:

?php
class Foo {
  public static function Bar() {
return new Foo_Bar();
  }
}
?

Or smth with the __call() function and an (iew) eval() call, since
call_user_func_array() doesn't work on constructors (or so I heard, haven't
tried it).

--
Always consider all options before deciding which object to talk to

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



RE: [PHP] Re: Problems with very special characters

2004-05-10 Thread Wouter van Vliet
Hi,

Thanks for your suggestion. The problem appeared to be in the
AddDefaultCharSet directive. It was set to UTF-8, and for the characters to
be displayed it should've been set to iso-8859-1. 

Wouter

(wonder why redhat uses UTF-8 encoding, if it causes this many problems ...
)

-Original Message-
From: Aidan Lister [mailto:[EMAIL PROTECTED] 
Sent: Sunday, May 09, 2004 04:08
To: [EMAIL PROTECTED]
Subject: [PHP] Re: Problems with very special characters

Hi,

Make sure the charset of your document matches the charset sent by the
server - If you tell the browser the charset is A, and use characters from
charset B, you will get the problem observed.

The charset can be sent from Apache, PHP and the actual charset is set in
the document.

It's a pain in the arse to fix, I've had the same problem, it took a lot of
experimenting

Good luck,


Wouter Van Vliet [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Hello everybody,

I'm back! (been a subscriber here before, a while ago .. was quite an active
one at that time .. ;)) .. and I'm back for a reason, having a very wicked
problem. The setup is one RedHat linux 9 machine (called s007), previously
in use as both our web and database server. As traffic increased
dramatically earlier this week, we had to grab another server, running
RedHat Fedora. We'll call her s006, and use to serve the webpages. All
happened very quickly and smooth for most of it. Only currently still
existing problem has (appearantly) to do with transferring the very special
characters over the lines between s007 and s006, displaying them on the
screen and entering them in the database through webforms. Normal special
chars like é, ê, à and so on seem to be displayed ok (after calling
htmlentities in php: PHP 4.3.3 (cgi) (built: Oct 21 2003 09:51:55) on s006
and PHP 4.3.4 (cli) (built: Jan 24 2004 22:34:14) on s007), but the more
exotic ones (~ and ^ signs on and under Z, S .. and stuff like that) still
cause problems on the s006. Same script, requesting data from the same rows
of the same database on the s007 works as it is supposed to.

MySQL version of both servers is mysql  Ver 11.18 Distrib 3.23.58, for
redhat-linux-gnu (i386), for both machines, /etc/sysconfig/i18n looks like:

  1 LANG=en_US
  2 SUPPORTED=nl_NL:nl_NL:nl:en_US:en
  3 SYSFONT=lat0-sun16
  4 SYSFONTACM=iso15

(numbers are line numbers). To compare the pages:
http://esctoday.s007.interlize.net/annual/2004/participants.php
 http://esctoday.s006.interlize.net/annual/2004/participants.php
http://esctoday.s006.interlize.net/annual/2004/participants.php

I'm stuck here with my hands in my hair, and would very much appriciate any
clue to a solution, Wouter van Vliet

(ps. since I'm not sure of the solution will be found in php, mysql or any
other place I have posted this message also to the mysql-general list)

--
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] Problems with very special characters

2004-05-08 Thread Wouter van Vliet
Hello everybody,
 
I'm back! (been a subscriber here before, a while ago .. was quite an active
one at that time .. ;)) .. and I'm back for a reason, having a very wicked
problem. The setup is one RedHat linux 9 machine (called s007), previously
in use as both our web and database server. As traffic increased
dramatically earlier this week, we had to grab another server, running
RedHat Fedora. We'll call her s006, and use to serve the webpages. All
happened very quickly and smooth for most of it. Only currently still
existing problem has (appearantly) to do with transferring the very special
characters over the lines between s007 and s006, displaying them on the
screen and entering them in the database through webforms. Normal special
chars like é, ê, à and so on seem to be displayed ok (after calling
htmlentities in php: PHP 4.3.3 (cgi) (built: Oct 21 2003 09:51:55) on s006
and PHP 4.3.4 (cli) (built: Jan 24 2004 22:34:14) on s007), but the more
exotic ones (~ and ^ signs on and under Z, S .. and stuff like that) still
cause problems on the s006. Same script, requesting data from the same rows
of the same database on the s007 works as it is supposed to.
 
MySQL version of both servers is mysql  Ver 11.18 Distrib 3.23.58, for
redhat-linux-gnu (i386), for both machines, /etc/sysconfig/i18n looks like:
 
  1 LANG=en_US
  2 SUPPORTED=nl_NL:nl_NL:nl:en_US:en
  3 SYSFONT=lat0-sun16
  4 SYSFONTACM=iso15

(numbers are line numbers). To compare the pages:
http://esctoday.s007.interlize.net/annual/2004/participants.php
 http://esctoday.s006.interlize.net/annual/2004/participants.php
http://esctoday.s006.interlize.net/annual/2004/participants.php   
 
I'm stuck here with my hands in my hair, and would very much appriciate any
clue to a solution,
Wouter van Vliet
 
(ps. since I'm not sure of the solution will be found in php, mysql or any
other place I have posted this message also to the mysql-general list)


RE: [PHP] Request form duplicate names

2003-12-19 Thread Wouter van Vliet
input type='checkbox' name='id[]' value='1'

:P

On vrijdag 19 december 2003 11:10 Frédéric HARDY told the butterflies:
 Try input type'checkbox' name='id[]' value='1'
 
 So in your script :
 
 $ids = $POST['name'];
 $first_id = $POST['name'][0];
 
 Best regards, Fred
 ===
 Frederic HARDYEmail: [EMAIL PROTECTED]
 HEXANET SARL  URL: http://www.hexanet.fr/
 ZAC Les CharmillesTel: +33 (0)3 26 79 30 05
 3, allée Thierry Sabine   Direct: +33 (0)3 26 61 77 84
 BP 202 - 51686 REIMS CEDEX 2 FRANCE
 ===
 
 - Original Message -
 From: Terence [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Friday, December 19, 2003 10:41 AM
 Subject: [PHP] Request form duplicate names
 
 
  
  Dear All,
  
  Is there a way to request form fields which have the same name
  using POST? 
  
  I generate dynamic checkboxes all with the same name, but with
  different values 
  
  input type'checkbox' name='id' value'1'
  input type'checkbox' name='id' value'7'
  input type'checkbox' name='id' value'78'
  etc
  
  I could alternatively do it through GET and split the querystring,
  but i'd prefer POST. 
  
  Thanks
  Terence
  
  --
  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] PHP IDE?

2003-12-15 Thread Wouter van Vliet
Yeah .. vim is my god too. You can do so many things with so little
keystrokes. And it basically has the best syntax highlighting I've ever
seen. With some easy tricks you can even let it highlight your own
functions. I haven't doen so, but I know it's possible :P... Also, it exists
on most servers so you can work directly on the server. Without having to
mess with (Samba) filesharing. Another advantage is that it runs both on
Linux as well as on Windows.

W.

(ps. Ahbaid or anyone else .. how can I get code to re-fold. I've setup my
vim to fold every PHP function and class, which works when I load te file.
But when I'm done editing a certain block, what do I do to make it fold back
in again?)

On zondag 14 december 2003 18:27 Ahbaid Gaffoor told the butterflies:
 with folding you can fold your code in chunks, you
 basically setup a start fold and an end fold and place
 code between them, then you can open and close (fold) that
 block of code as you need to or don't need to see it...
 
 for example:
 
 # {{{ PHP Code to do something...
 
 ..
 ..
 1 lines of code...
 ..
 ..
 # }}}
 
 would collapse to one line when folded and look something like:
 
 + PHP Code to do something
 
 then when you hit space on it it expands. (I use {{{ and }}}
 as my start and end folds)
 
 
 ctags allows you to build a dictionary of words which you can
 hook into
 vim, that way you can do tab completion on PHP words etc.
 
 I also like to map keystrokes to coding templates for things like
 functions, loops, declarations etc.
 
 Everyone's got their own setup :)
 
 Plus I always use a CVS repository for my work, so my routine
 of, code,
 test, commit is habit.
 
 Looking at the responses there seems to be a lot of neat editors out
 there, to each his own. 
 
 regards,
 
 Ahbaid.
 
 Jough Jeaux wrote:
 
  Hmm, I'm currently a vim user also.  You'll have to
  elaborate on this folding and ctag business though...
  
  
  --- Ahbaid Gaffoor [EMAIL PROTECTED] wrote:
  
  
   vim - with folding and ctags
   
   sweet.
   
   Ahbaid
   
   Jough Jeaux wrote:
   
   
   
Was wondering what everyone's favortie IDE is for
coding in PHP.  I've got a big PHP project in the
works.  I'll be doing alot with it and am looking


   for
   
   
ways to boost my productivity.

--Jough


__
Do you Yahoo!?
New Yahoo! Photos - easier uploading and sharing.
http://photos.yahoo.com/





   --
   PHP General Mailing List (http://www.php.net/)
   To unsubscribe, visit: http://www.php.net/unsub.php
   
   
   
  
  __
  Do you Yahoo!?
  New Yahoo! Photos - easier uploading and sharing.
  http://photos.yahoo.com/

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



RE: [PHP] $GLOBALS containing itself!!!

2003-12-15 Thread Wouter van Vliet
On maandag 15 december 2003 10:24 Gerard Samuel told the butterflies:
 Just curious about something I came across.
 I was looking at the $GLOBAL array, to see what my script was leaving
 behind. $GLOBALS contains a reference to itself.
 Even though its a reference, whats the sense with that??
 Once its global, why should it have to call on itself?
 Im currently running php 4.3.4 on FreeBSD 4.9
 
 Thanks
 
 A script to try out -
 ?php
 
 header('content-type: text/plain');
 
 var_dump(isset($GLOBALS['GLOBALS']['GLOBALS']));  // returns true
 
 // Prints out the $GLOBALS array
 // including one reference to itself
 // then starts another but quits with *RECURSION* var_dump($GLOBALS);
 
  

Well .. it basically just Contains a reference to every variable which is
currently available within the global scope of the script. The keys of this
array are the names of the global variables.. Since $GLOBALS itself is
global, that too is contained.

So: 


var_dump(isset($GLOBALS['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS
']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBAL
S']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBA
LS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOB
ALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLO
BALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GL
OBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['G
LOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['
GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS'][
'GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']
['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS'
]['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS
']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBAL
S']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBA
LS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOB
ALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLO
BALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GL
OBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['G
LOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['
GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS'][
'GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']
['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS'
]['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS
']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBAL
S']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBA
LS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOB
ALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLO
BALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GL
OBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['G
LOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['
GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS'][
'GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']
['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS']['GLOBALS'
]));

Will still print out true. the displaying of *RECURSION* is to prevent, well
.. ehmm, recursively printing out the $GLOBALS array over and over again.
This is something new in PHP 4.0.4. Read the manual on page
http://nl3.php.net/manual/en/function.print-r.php:

Note: Prior to PHP 4.0.4, print_r() will continue forever if given
an array or object that contains a direct or indirect reference to itself.
An example is print_r($GLOBALS) because $GLOBALS is itself a global variable
that contains a reference to itself. 

:),
Wouter

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



RE: [PHP] Re: post an array into another site

2003-12-09 Thread Wouter van Vliet
On dinsdag 9 december 2003 13:11 Jay Blanchard told the butterflies:
 [snip]
 ...wow...
 [/snip]
 
 All of this an no one mentioned cURL? ;) http://www.php.net/curl

Yes .. ehmm, especially considering this wasn't the guy's actual question.
If I read it correctly, it was this:

On 12/08/2003 10:30 AM, Fred wrote:
 I have an array in php like this:
 
 $arr[0][0] = Something;
 $arr[0][1] = Hello;
 $arr[0][2] = Hi;
 
 It is possible to post this array to another site in a form? Or how 
 can i do this?

which makes me think he just wants to post same data from one page of a site
to another page of (possibly) another site. For that I would probably
rethink some major parts of my code, if I find myself wanting to do that. If
it turns out I really want it, serialize(), htmlentities() and a hidden
field would be my solution. Or, if I remain on my own site add it to
$_SESSION.

It was an interesting discussion, though ;)

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



RE: [PHP] Leechers...

2003-12-09 Thread Wouter van Vliet
On dinsdag 9 december 2003 13:50 [EMAIL PROTECTED] told
the butterflies: 
 I've just installed and am happily using Galery HP
 (http://www.galleryhp.org/)
 A great photo gallery package...
 Anyhoo,
 
 I want to now be able to stop people from linking to the
 images directly, and only be able to access the images via my site...
 
 Is this possible...?
 
 Perhaps my questio is to vauge, but I'm just having a think
 at teh mo...
 
 For the record, Gallery HP does a good job of hiding the full
 URL anyway.
 
 *
 The information contained in this e-mail message is intended
 only for the personal and confidential use of the
 recipient(s) named above.
 If the reader of this message is not the intended recipient
 or an agent responsible for delivering it to the intended
 recipient, you are hereby notified that you have received
 this document in error and that any review, dissemination,
 distribution, or copying of this message is strictly
 prohibited. If you have received this communication in error,
 please notify us immediately by e-mail, and delete the
 original message.
 **
 *

You haven't been googling around, have you? Me neither, but you'll probably
find that you want to block requests with a referrer other than your own
website. This can be done with mod_rewrite.

Have fun!
Wouter

In the future, can you please create a NEW email message, rather than
replying to another and clearing it's entire contents when you're making a
new thread... !?!?!

(Welcome to the world, Catharina-Amalia Beatrix Carmen Victoria)

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



RE: [PHP] Leechers...

2003-12-09 Thread Wouter van Vliet
On dinsdag 9 december 2003 14:30 Wouter van Vliet told the butterflies:
 On dinsdag 9 december 2003 13:50
 [EMAIL PROTECTED] told the butterflies:
  I've just installed and am happily using Galery HP
  (http://www.galleryhp.org/)
  A great photo gallery package...
  Anyhoo,
  
  I want to now be able to stop people from linking to the images
  directly, and only be able to access the images via my site...
  
  Is this possible...?
  
  Perhaps my questio is to vauge, but I'm just having a think at teh
  mo... 
  
  For the record, Gallery HP does a good job of hiding the full URL
  anyway. 
  
  
 *
  The information contained in this e-mail message is intended only
  for the personal and confidential use of the
  recipient(s) named above.
  If the reader of this message is not the intended recipient or an
  agent responsible for delivering it to the intended recipient, you
  are hereby notified that you have received this document in error
  and that any review, dissemination, distribution, or copying of
  this message is strictly prohibited. If you have received this
  communication in error, please notify us immediately by e-mail, and
  delete the original message. 
  **
  *
 
 You haven't been googling around, have you? Me neither, but
 you'll probably find that you want to block requests with a
 referrer other than your own website. This can be done with
 mod_rewrite. 
 
 Have fun!
 Wouter
 
 In the future, can you please create a NEW email message,
 rather than replying to another and clearing it's entire
 contents when you're making a new thread... !?!?!
 
 (Welcome to the world, Catharina-Amalia Beatrix Carmen Victoria)

Curse me, I mislooked. You did make a fresh post.. 

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



RE: [PHP] converting string into array with regex

2003-12-05 Thread Wouter van Vliet
On vrijdag 5 december 2003 12:23 Burhan Khalid told the butterflies:
 Adam i Agnieszka Gasiorowski FNORD wrote:
 
  How would you specify a regex to
   convert string into array using preg_split?
   Is there some symbol specyfying a place  between letters ?
  
  s t r i n g = array('s', 't', 'r', 'i', 'n', 'g')
   ^ ^ ^ ^ ^
 
 You can access a string's characters with an index without declaring
 it as an array. 
 
 $string = foo;
 echo $string{0}; //outputs f
 
 http://www.php.net/substr (has an example)
 
 Maybe this will solve your problem without using preg_split?
 
 --
 Burhan Khalid
 phplist[at]meidomus[dot]com
 http://www.meidomus.com
 ---
 Documentation is like sex: when it is good,
   it is very, very good; and when it is bad,
   it is better than nothing.

You kinda need to realize that

$String = 'FooBar';
print $String[4];

also prints out an 'B'. But this is adviced AGAINST because it is the same
syntax as you do for array elements.

To get a real array, do something like this:

$Array = Array();
for($i=0;$istrlen($String);$i++) $Array[] = $String{$i};

But if you have a string with char-space-char stuff, split(' ', $String);
would do too.

Wouter




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



RE: [PHP] SID problem

2003-12-04 Thread Wouter van Vliet
On donderdag 4 december 2003 10:36 Binay told the butterflies:
 Hi everybody,
 
 I m trying to disable/off  session.use_trans_sid.
 I don have access to php.ini file... hence trying to unset in
 the php scripts and .htaccess file .
 
 While this works in php script i.e
 ini_set(session.use_trans_sid,0);
 
 but in .htaccess it seems it doesn't
 i.e php_flag session.use_trans_sid off ... This doesn't work..
 
 My .htaccess file contain only above statement and nothing else ...
 
 I can not go for ini_set as it needs to be done in all the
 file ... so .htaccess is the right solution for me .
 but it doesn't work in .htaccess ...
 
 What may be the possible reason/causes??
 
 Please help me ..
 
 PHP 4.2.2
 
 Thanks in advance
 
 Binay

Reason is possibly/most likely that AllowOverride is disabled on the
server.

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



RE: [PHP] SID problem

2003-12-04 Thread Wouter van Vliet
On donderdag 4 december 2003 10:53 Binay told the butterflies:
 Yes AllowOverride is set to None 
 
 But then i can not change it as i don have access .. wht
 other method/solution i can look except ini_set then ??
 
 - Original Message -
 From: Wouter van Vliet [EMAIL PROTECTED]
 To: 'Binay' [EMAIL PROTECTED]; [EMAIL PROTECTED]
 Sent: Thursday, December 04, 2003 3:08 PM
 Subject: RE: [PHP] SID problem
 
 
  On donderdag 4 december 2003 10:36 Binay told the butterflies:
   Hi everybody,
   
   I m trying to disable/off  session.use_trans_sid.
   I don have access to php.ini file... hence trying to unset in the
   php scripts and .htaccess file .
   
   While this works in php script i.e
   ini_set(session.use_trans_sid,0);
   
   but in .htaccess it seems it doesn't i.e php_flag
   session.use_trans_sid off ... This doesn't work..
   
   My .htaccess file contain only above statement and nothing else
   ... 
   
   I can not go for ini_set as it needs to be done in all the file
   ... so .htaccess is the right solution for me .
   but it doesn't work in .htaccess ...
   
   What may be the possible reason/causes??
   
   Please help me ..
   
   PHP 4.2.2
   
   Thanks in advance
   
   Binay
  
  Reason is possibly/most likely that AllowOverride is disabled on
  the server.

I'm sorry, but there are no other options. You can, though, ask your hosting
provider to change the setting in the httpd.conf file for you. Or else I'd
advice you to create one file to include in all other files, which sets
global options.

 global.inc.php 
?php
ini_set('session.use_trans_sid, '0');

// I've got my database connection settings and some other
// global calls also in this file.
?

 any-other-file.php 
?php
include('global.inc.php');

(.. the rest of your code ..)
?

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



RE: [PHP] include-problem

2003-12-02 Thread Wouter van Vliet
On maandag 1 december 2003 15:23 Rasmus Lerdorf told the butterflies:
 On Mon, 1 Dec 2003, Wouter van Vliet wrote:
  ?php
  print !!!;
  ob_start();
  include 'http://server.com/test/echo.php';
  $XML = ob_get_clean(); // or use ob_get_contents(); and
  ob_end_clean() for PHP  4.3 print ???; 
  
  print '[Between this you'll get your XYZ]'; print $XML; print
  '[Between this you'll get your XYZ]'; ?
 
 Or just use file_get_contents() which would be more efficient
 than using output buffering for this.
 
 -Rasmus

yes, probably. But isn't file_get_contents(); only implemented from php4.3
.. might wanna try 

join('', file());

or

$fd = fopen($FileName, 'r');
fread($fd, filesize($fd));

if you're running an older version.

-me.

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



RE: [PHP] date() function doesn't seem to work right...

2003-12-02 Thread Wouter van Vliet
On maandag 1 december 2003 21:04 Curt Zirzow told the butterflies:
 * Thus wrote Scott Fletcher ([EMAIL PROTECTED]):
  When I do this script, I didn't get a : and numbers in
  second. --snip-- date(Y-m-d H:i:s);
  --snip--
  
 
 works fine with phpversion() 4.2.2
 
 Curt
 --
 If eval() is the answer, you're almost certainly asking the
 wrong question. -- Rasmus Lerdorf, BDFL of PHP

Yep, for PHP 4.3.4 it works juust fiine. What version are you using?

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



RE: [PHP] Error message trying to include a file

2003-12-02 Thread Wouter van Vliet
On maandag 1 december 2003 23:17 Curt Zirzow told the butterflies:
 * Thus wrote Matthias Wulkow ([EMAIL PROTECTED]):
  
  I have an array filled with urls of javascript files and then I
  include them one by one in a loop.
  
  for( $i = 0 ; $i  sizeof($this-page-javascript) ; $i++ ){
  
   include($this-page-javascript[$i]);
   //This line above is line 52 shown on error warning }
 
 what does print_r($this-page-javascript) yield?
 
 you'd be better off with a loop like:
 foreach($this-page-javascript as $file_to_include) {  
 include($file_to_include); }
 
 
 
 Curt
 --
 If eval() is the answer, you're almost certainly asking the
 wrong question. -- Rasmus Lerdorf, BDFL of PHP

Probably 

include($this-page-javascript[$i]);

Is the problem. There's this thing in PHP that you can't do this thing with
referencing to an object property from within an other object. Or whatever
to call that. Sounds silly and stupid, but it bullies me too. Try this:

$Page = $this-page;
foreach($Page-javascript as $File) include($File);

or this (if you care about memory usage):

$Page = $this-page;
foreach(array_keys($Page-javascript) as $i)
include($Page-javascript[$i]);

Because php doesn't do reference thingies in a foreach loop, sadly.

Wouter

-note that you do not need { and } for oneline if/foreach/for/while/..
blocks

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



RE: [PHP] Picture Width and Height in $_FILES

2003-12-02 Thread Wouter van Vliet
On dinsdag 2 december 2003 3:40 Dimitri Marshall told the butterflies:
 Hi there,
 I've seen the code somewhere but can't remember what it is exactly.
 Basically I need to know what the PHP is to get the picture
 width and height.
 
 I tried:
 
  $pic = $_FILES[$objectNumber];
  $width = $pic['width'];
  $height = $pic['height'];
 
 ... with no success.
 
 Any help is greatly appreciated.
 
 Thanks,
 Dimitri Marshall

There's this getimagesize() function, it will tell you everything about an
image that you need to know. Even who made it, if that's in the exif headers
:P.

Wouter

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



RE: [PHP] regular expression, image, name, alt, title, preg_match_all

2003-12-01 Thread Wouter van Vliet
Sophie Mattoug wrote:
 Adam i Agnieszka Gasiorowski FNORD wrote:
 
  I'm trying to develop a regex for matching  with preg_match_all, I
 want to match such things  like image name, image alt text, image
 title in  construct like this: 
 
 html...
 div class=class style=style
  img src=img=name alt=alt title=title /  span class=class
   style=style text
  /span
 /div
 html...
 The rexex as for now is:
 
 define(
'REGEX_IMAGE_NAMES_AND_TITLES_AND_ALTS_FROM_CONTENT',   
 '{ (?:\s*img\s+src\s*=\s*(?:|\')?\s*(?:img)?\s*=\s*)
   #  img
 (?\b\S+\b)
   # name
 (?:title\s*=\s*(?:|\'))
   # title
 (?\b\S*\b)
 (?:|\')*\s*
 (?:alt\s*=\s*(?:|\'))
   # alt
 (?\b\S*\b)
 (?:|\')*\s*
 (?:\|\'||/|\s)
   # img /
 }Uix'
  );
 

My approach would be somewhat something good from both worlds it IS
possible to match an entire image tag with preg_match_all:

/img (\s*(alt|src|style|title|name)=\s*([^]*)\s*)*\/?/i

Of course, this is not tested .. but should come at least a bit close to
what you want ...

Wouter

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



RE: [PHP] include-problem

2003-12-01 Thread Wouter van Vliet
Rasmus Lerdorf wrote:
 On Mon, 1 Dec 2003, Sophie Mattoug wrote:
 Victor Spång Arthursson wrote:
 
 Hi!
 
 I'm having a problem with including files. What I want to achieve is
 to execute a PHP-script on another server, and then to include the
 result (which will be XML-output) in another PHP-script (currently
 on my local computer). 
 
 On the server I have the file
 http://server.com/test/echo.php with
 the content
 
 ---
 ?php
 echo 'xyz';
 
 ---
 
 Locally I've a file with the following content:
 
 ---
 ?php
 echo !!!;
 include (http://server.com/test/echo.php;);
 echo ???;
 
 ---
 
 I was expecting the output from my locally testfile to be something
 like: 
 
 ---
 !!!???
 ---
 
 but rather it is
 
 ---
 !!!xyz???
 ---
 
 I've also tried with a $fp = readfile(http…) with the same result,
 which is output of the echo-statement in the remote file which I am
 expecting to be evaluated remotely.
 
 How can I do to include the PHP-script and have it to be ran before
 it is included? 
 
 Sincerely
 
 Victor
 
 
 This is a perfectly normal behaviour ! See www.php.net/include to
 understand what this function does. (comparing to
 www.php.net/require) 
 
 It's perfectly normal, yes, but it has nothing to do with include vs.
 require. 
 
 I guess I don't really understand the question.  I assume you
 realize that an include 'http://server.com/file.php' is going
 to send an HTTP request to server.com asking for file.php and
 if server.com is configured to execute php for file.php then
 what will come back across the wire is the result of php
 running the script in file.php.  As such, when you do:
 
  echo '!!!';
  include 'http://server.com/file.php';
  echo '???';
 
 you will of course see: !!!xyz??? because that is exactly
 what you have asked it to do.  Print !!!, then send an HTTP
 request to server.com and include the output of that script
 right here, and finally print out ???.
 So I don't understand why this output is surprising you and I
 don't understand your question about expecting it to be
 evaluated remotely.
 file.php was of course evaluated remotely on server.com.  If
 file.php had written something to the filesysts, for example,
 then that something would be on server.com not on your server.
 
 -Rasmus

You can use the output buffer functions to catch the xyz into a var:

?php
print !!!;
ob_start();
include 'http://server.com/test/echo.php';
$XML = ob_get_clean(); // or use ob_get_contents(); and ob_end_clean() for
PHP  4.3
print ???;

print '[Between this you'll get your XYZ]';
print $XML;
print '[Between this you'll get your XYZ]';
?

Hope it helps ya,
Wouter

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



RE: [PHP] String construction help required please

2003-12-01 Thread Wouter van Vliet
Jay Blanchard wrote:
 [snip]
 I need to display : $_POST[$var],
 
 Including the  and the , .
 
 I have tried : \\$_POST[\.$var.\], but that is very wrong.
 
 Could one of you kind list members show me what it should be please ?
 
 
 You have a couple of options... just pick the one that suits you...
 
 ?
 echo \{$_POST[$var]},\;
 echo ''.$_POST[$var].',';
 
 [/snip]
 
 var should not have a $ in front of it, should it?
 
 echo \{$_POST['var']},\;
 echo ''.$_POST['var'].',';

That all depends. Consider the following:

Assume:
input type='text' name='something' value='foo'
to be posted to the script

print '$_POST[$var],'; // prints (literally): $_POST[$var],
print ''.$_POST['something'].,; // prints: foo,
print ''.$_POST[$var].,; // Issues a 'notice: undefined index..' and
prints: ,

$var = 'something';
print ''.$_POST[$var].,; // prints: foo,

Pick your flavor.

Wouter

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



RE: [PHP] Receiving a warning... no clue how to resolve it and need help badly :(

2003-11-28 Thread Wouter van Vliet
 |
\./
 .

Aaron Wolski wrote:
 *** Sorry if this is a duplicate for some on another list**
 
 Hi Guys,
 
 I need help with this code I am about to paste. It works on a
 testing server running PHP 4.2.2 but not 4.3.2
 
 Here is the error:
 
 Warning: array_merge_recursive(): recursion detected in
 /services2/webpages/r/i/rinkrake.com/public/test.php on line 26
 
 Here is the code:
 
 ?php
 echo Generating results, this could take a minutebr;
 // Allow the script enough time to finish (lots of data, lots
 of loops) set_time_limit(999);
 
 // db connection
 $link = mysql_connect(xxx, xxx, xxx); mysql_select_db(xxx);
 
 // We need these queries to do our job
 $we_ordered_1 = mysql_query(select OrderTable.cart_id,
 CartTable.cart_id, CartTable.product_index from OrderTable,
 CartTable where CartTable.product_index = 1 and
 OrderTable.cart_id = CartTable.cart_id);
 
 $we_ordered_14 = mysql_query(select OrderTable.cart_id,
 CartTable.cart_id, CartTable.product_index from OrderTable,
 CartTable where CartTable.product_index = 14 and
 OrderTable.cart_id = CartTable.cart_id);
 
 $customers = mysql_query(select cart_id, first, last, email
 from OrderTable);
 
 // Compare cart_id's between customers who ordered product #1 and
 #14. If the customer // ordered #1 and not #14, put their cart_id in
 the $good_customers array and move on // to the next.
 while ($row1 = mysql_fetch_row($we_ordered_1))
 {
 while ($row2 = mysql_fetch_row($we_ordered_14))  
 { if ($row1[0] != $row2[0])
 {
 $temp[cust_id] = $row1[1];
 $good_customers =
 array_merge_recursive($good_customers,$temp);
 }
 }
 mysql_data_seek($we_ordered_14,0);
 }
 
 // Free up some memory, reset things back to square one (just
 to be on the safe side) // and get rid of any duplicate items
 in our newly created array.
 mysql_free_result($we_ordered_1);
 mysql_free_result($we_ordered_14);
 unset ($temp);
 reset ($good_customers);
 $good_customers = array_unique($good_customers[cust_id]);
 
 // Fetch a customer, step through the $good_customers array
 and // compare the cart_id stored in $good_customers, if they
 match, // kick out a 'record' with the necessary data.
 while ($row3 = mysql_fetch_row($customers))
 {
 foreach ($good_customers as $value)
 {
 if ($row3[0] == $value)
 {
 echo $row3[0]. |
 .$row3[1]. | .$row3[2]. | .$row3[3].br\n;
 }
 }
 }
 mysql_close($link);
 echo script language=JavaScriptalert(\Done!\);/script;
 
 
 CAN anyone help me resolve the problem? I know it has to do
 with a bug being fixed for array_merge_recursive but I don't
 know how to resolve the problem and get the results I need :-(
 
 Please help?
 
 Thanks so much!!!
 
 Aaron

Am not sure about the bug in yout script, but what are you trying to do? For
what I understand you are trying to find all customers who ordered Product
ID #1 and not Product ID #14? If that's right, simply fire:

?php
$Orders = mysql_query('SELECT *
FROM OrderTable LEFT JOIN CartTable on OrderTable.cart_id =
CartTable.cart_id
WHERE CartTable.product_index IN (1,14)
ORDER BY product_index ASC');

$Ones   = Array();
while($Order = mysql_fetch_assoc($Orders)) {
if ($Order['product_index'] == 1) {
$Ones['cart_id'] = Array($Order);
} elseif {
($Order['product_index'] == 14) unset($Ones['cart_id']; 
}
}
?

This will leave you with an array $Ones with all returned rows where the
cusomer ordered #1 and not #14. The trick is that I ordered on
product_index, so that I am sure that I'm processing all 1's first, and then
all 14's. With some more advanced order by tricks (this one's pretty simple)
you can probably leave out the enire where clause, and getting entire orders
matching the criteria you set. 

Hope it helped you ;)
Wouter

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



RE: [PHP] .htaccess authentification problem

2003-11-28 Thread Wouter van Vliet
Michael Hübner wrote:
 Hallo,
 
 Hope somebody can help me.
 
 I'm working on Linux, Apache.
 
 On my start-site the user can log in via inserting Username
 and Password into normal formfields, which are compared with a DB.
 
 After this login, he can change to his own user-directory
 which is .htpasswd and .htaccess protected. Thats the reson
 he has to insert his Username and Password again ;(
 
 My Question:
 
 Is there a way, so the user has to insert his data only once?
 
 I've also tried it by doing a authentification like this first:
 
 ?php
   if (!isset($_SERVER['PHP_AUTH_USER'])) {
Header(WWW-Authenticate: Basic realm=\My Realm\);
Header(HTTP/1.0 401 Unauthorized);
echo Text to send if user hits Cancel button\n;exit;
 } else {
 echo Hello {$_SERVER['PHP_AUTH_USER']};
 echo pYou entered {$_SERVER['PHP_AUTH_PW']} as your
   password./p; }
 
 
 but it doesn't work for me, because when switching to the
 userdirs, the .htaccess authentification window pops up again
 (it is the same pwd and uid in the DB and the .htpasswd) ;(
 
 Thank you in advance,
 
 Michael

Please, please .. somebody come up with a solution to this and this kind of
problems that as been bugging (I think) every php
developer/scripter/programmer (however you call yourself) that has to deal
with security. Eventually I found myself doing the entire security procedure
in auto_prepend'ed files. But this only blocks access to php files. Isn't
there like some apache module mod_auth_php, just like there is
mod_auth_mysql and others?

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



[PHP] RE: Blessing an object

2003-11-28 Thread Wouter van Vliet
Greg Beaver wrote:
 Wouter,
 
 you could try this adding this method to each object you need
 blessings from:
 
 function bless($classname)
 {
  if ($classname == get_class($this)) {
  return $this;
  }
  $vars = get_object_vars($this);
  $ret = new $classname;
  return $ret-loadValues($vars);
 }
 
 function loadValues($vals)
 {
  foreach ($vals as $name = $val) {
  $this-$name = $val;
  }
  return $this;
 }
 
 In the Load() method, you should determine what class you
 need, and call $ret = $this-bless('classname'), and then return
 $ret. 
 
 Then, instead of doing
 
 $Thing-Load();
 
 do
 
 $Thing = $Thing-Load();
 
 and have Load() return an object instance (either $this or the newly
 blessed object). 
 
 This will maintain encapsulation and achieve the results you're
 looking for. 
 
 Regards,
 Greg
 

Thanks Greg .. this comes pretty close to what I had done myself as a
workaround. Only thing that's different is that in my bless implementation I
don't return the blessed value, but overwrite the $this var. Which works.
What advantage do you think I would get from your appraoch?

[snip The Way I Bless {example from own memory, cannot reach the actual code
at this time} ]
function Bless($ClassName) {
// return false if class doesn't exist
if (!class_exists($ClassName)) return false;

$New = new $ClassName();

foreach($this as $Key = $Value) $New[$Key] = $Value;
$this = $New;
unset $New);
}
[/snip The Way I Bless]

Hmm .. maybe I'm thinking 'out of te box' here, but can I manually add this
functionality to stdClass, so that they are available in each and ever
object I create?

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



RE: [PHP] Capturing $_POST variables

2003-11-28 Thread Wouter van Vliet
Shaun wrote:
 Hi,
 
 is it possible to capture $_POST variables sent from a
 previous page so i can send them on to the next page?
 
 Thanks for your help.

might wanna try (before any output, including spaces):

?php
session_start();
foreach($_POST as $Key = $Value) $_SESSION[$Key] = $Value;

But consider some checks to test if no values from $_SESSOIN are accidently
overwritten (a user can post ANY value to ANY page he/she wants, this is NOT
restricted to the form fields you have defined).
?

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



RE: [PHP] Capturing $_POST variables

2003-11-28 Thread Wouter van Vliet
Thorsten Körner wrote:
 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1
 
 Hi Shaun
 Am Freitag, 28. November 2003 14:41 schrieb Shaun:
 Thanks for your reply,
 
 I don't really need to do anything with them, just make sure they all
 retain their original values...
 
 If you are using a form to sent the data again to third page
 you can do this foreach ($_POST as $key = $value) {
   echo input type=\hidden\ name=\.$key.\ value=.
 $value.\; }
 
 Another way is the following:
 
 $postData = $_POST;
 
 echo input type=\hidden\ name=\postData\ value=.
 $postData.\; 
 
 CU
 
 Thorsten

This won't work. $_POST is always an array. If you want to go all the way of
re-posting the postdata, this is an appraoch that would WORK. I'm not saying
it's a GOOD appraoch (as others have said, it isn't :D):

echo input type='hidden' name='PreviousPostData'
value='.htmlentities(addslashes(serialize($_POST))).';

and on the other one

$PreviousPostData = unserialize(stripslashes($_POST['PreviousPostData']));

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



RE: [PHP] Re: Blessing an object

2003-11-27 Thread Wouter van Vliet
[EMAIL PROTECTED] wrote:
 Hello
 
 Just out of curiosity why do you need such a function? I'm no
 perl programmer and have very little knowledge of the
 language ... yet ; ) but the way you describe it it seems to
 me that you have  a fundamentle design flaw in your script if
 you need to change types on the fly that are in no way
 related to each other. (Even in a typeless language such as PHP)
 
 My suggestion:
 For the cases you need the blessing create a proxy object or
 an adapter object to give you access to the needed stuff.
 
 Regards
 Stefan Langer

There might be a design flaw in the scripts. Though what you mention is not
entirely true. I don't want to change the type of my object to change it to
another that is not related. They are related, very much. I'm changing an
instance of a 'superclass' to one of it's 'subclasses'. Here's the picture a
little more in detail, though still global:

- Two classes, SuperClass and SubClass
- One Table in the database
- This table holds some columns, one of them being instance_of
- my class SuperClass has a method -New($ID); which loads the row
from
the database representing the wanted object. At this point I do not
know
what the object should be an instance of.
- As soon as the Object finds out it's in instance of SubClass I
want
it to become an instance of this SubClass, because there's some
overloaded
methods that are to be called upon loading and stuff. And of course
some
others to be run at other points in the script ;)

Any design related remarks are just as welcome as suggestion on how to bless
the object.

Wouter

[Example Snipplet]
class SuperClass {
(.. attributes ..)
function SuperClass($ID = false) {
if ($ID) $this-Load($ID);
}

function Load($ID) {
$Row = mysql_select('SELECT * FROM table WHERE id =
'.$ID.'')
( .. Hey, now I see it should become SubClass
how can I become that .. )
$this-DoSomething($Row);
}

function DoSomething($dbRow) {
( .. processing some things .. )
}
}

class SubClass {
( .. attributes .. )
funtion SubClass() {

}

function DoSomething($dbRow) {
( .. also some processing, but a little different .. )
}
}
[/Example Snipplet]

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



RE: [PHP] how can I capture/ or make a history file?

2003-11-27 Thread Wouter van Vliet
[EMAIL PROTECTED] wrote:
 Hello all,
 
 I want to make a history file while
 runing a script in a shell.
 
 Does anyone know how to store all
 the history and the result to a file I want?
 
 what is the command for it?
 
 thank you in advance
 
 Joshua

Though way off topic, ...

Linux usually keeps a history of commands run by itself. With the command
history you can view your last actions. Probably a 'man history' will tell
you in what file it is stored..

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



RE: [PHP] Blessing an object

2003-11-26 Thread Wouter van Vliet
Raditha Dissanayake wrote:
 Hi Wouter,
 
 Wouter van Vliet wrote:
 
 Hi Folks
 
 I was wondering (mostly because I came across some situations where
 I need it) if PHP supplies any methods to bless an array or object
 to become some other object. In perl, I can simply do:
(..)
 
 
 I suspect that the reason that you find bless in perl is
 because it's OO foundations are not as strong as even that of
 PHP. Well PHP's OO foundations are weak enough. :-)
 
 The specific scenario you have described can IMHO be achieved
 with the use of serialize / deserialize.

Hmm, seriailze and deserialize.. Don't think that's what I would want to do.
You probably mean that I can serialize an object, hack the string to change
the Class reference. That's not really what I want to do. Right now I'm
hacking through it by

*) Creating a new instance of the desired class ($New = new
OtherClass())
*) Copy all attributes (foreach($this as $Key=$Value) $New[$Key] =
$Value)
*) Replace the $this var ($this = $New)

Not the best solution, I now .. But it works, currently. Please, there must
be another way to do this !

Wouter

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



RE: [PHP] Time

2003-11-25 Thread Wouter van Vliet
Fernando Melo wrote:
 Hi there,
 
 I have a RH Linux Web server  running apache and PHP.
 
 I recently changed the system clock, the time zone and hardware clock.
 The time and date are showing up correctly in Webmin and in
 the O/S itself.
 But when I call a php function to display the date and time
 it shows it as one hour behind!
 
 How do I fix this?
 
 Regards
 Fernando

Must be something with your locale settings. Probably your sytem clock is
set to the GMT time, while you are in GMT+1 yourself. Not really sure how to
fix this, but this might be something that helps you find the solution. Let
me know !

Wouter

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



RE: [PHP] Locking mysql tables with PHP

2003-11-25 Thread Wouter van Vliet
Marek Kilimajer wrote:
 Tony Crockford wrote:
 Hi
 
 bit confused!
 
 here's what I want to do:
 
 get a numeric value from a MySQL table, do a calculation, then on
 another PHPpage update the numeric value in the table.
 
 what I don't want is anyone else getting the same number from the
 table before I've updated it. 
 
 what PHP would you use to do this?
 
 Sorry for what is probably a really basic question - I did look at
 the MySQL manual, but I'm not sure how exactly to issue an SQL query
 LOCK TABLES using PHP. 
 
 
 LOCK TABLES will not work because the lock is released when
 the first page is finished. You could use a file that will
 you will use as a lock, but this could lock your table for
 minutes and eventualy, if the user desides not to take any
 action, forever. I would suggest to use a temporary table to
 hold taken numbers.

I may be wrong here, but doesn't PHP let MySQL retain the locks when you've
connected with the mysql_pconnect(); function? (persistent connect, I would
expect locks to get released on a disconnect, which usually happens on a
page refresh (new mysql_connect() call).

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



[PHP] Blessing an object

2003-11-25 Thread Wouter van Vliet
Hi Folks

I was wondering (mostly because I came across some situations where I need
it) if PHP supplies any methods to bless an array or object to become some
other object. In perl, I can simply do:

my $SomeInstance = bless { item = 'value', 'Item2' = 'value2' },
'SomeObject';

And then if I decide that $SomeInstance should be an intance of some other
object:

bless $SomeInstance, 'OtherObject';

In PHP it would be extremely useful for for doing something like this:

?php
Class Foo {

Load() {
( .. )
}

};

Class Bar extends Foo {

}

$Thing = new Foo();
$Thing-Load();
?

In Load the object data is loaded from the database, and now imagine one row
to contain the subclass this instance of Foo should become. I then would
want $Thing to become and thus behave like an instance of Bar (if my
database row says so).

Hope this message wasn't too confusing ;)
Wouter

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



RE: [PHP] Removing security-problematic chars from strings

2003-11-21 Thread Wouter van Vliet
 -Oorspronkelijk bericht-
 Van: John W. Holmes [mailto:[EMAIL PROTECTED]

 Troy S wrote:

  What is the best way to remove the characters from strings that may
  cause security problems?  Namely, `, ', , , , \ and all non-printing
  strings.  Did I miss any?  Thanks.

 Why do you need to remove them? So I can't type grin? Is that a
 security violation? All you need to do is use htmlentities() and/or
 addslashes() to protect data being displayed or entered into a database.


If you're worried about HTML code being entered (guess from desire to strip
,  and /) and messing up your site's layout, you might wanna call
strip_tags($String, $AllowedTags); where $AllowedTags is a string like
'bui' if you want to allow bold, underline and italics.

What is your intention?

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



RE: [PHP] xslt_create error

2003-11-21 Thread Wouter van Vliet
In your configure command, you have enabled xml support, but not xslt
support. Read http://nl3.php.net/manual/en/ref.xslt.php


Installation
On UNIX, run configure with the --enable-xslt --with-xslt-sablot options.
The Sablotron library should be installed somewhere your compiler can find
it.

Make sure you have the same libraries linked to the Sablotron library as
those, which are linked with PHP. The configuration
options: --with-expat-dir=DIR --with-iconv-dir=DIR are there to help you
specify them. When asking for support, always mention these directives, and
whether there are other versions of those libraries installed on your system
somewhere. Naturally, provide all the version numbers.


so, the function is, as the error says, undefined ;)

 -Oorspronkelijk bericht-
 Van: Mr. Me [mailto:[EMAIL PROTECTED]
 Verzonden: vrijdag 21 november 2003 14:39
 Aan: [EMAIL PROTECTED]
 Onderwerp: [PHP] xslt_create error


 Hi!

 I get the error: Fatal error: Call to undefined function:
 xslt_create() on
 line 5 when I try a call to the function... I'm using a webhotel
 with PHP:

 PHP Version 4.3.3

 System  FreeBSD web06.talkactive.net 4.7-RELEASE FreeBSD
 4.7-RELEASE #0: Wed
 Oct i386
 Build Date  Aug 29 2003 16:48:03
 Configure Command  './configure' '--enable-versioning'
 '--enable-memory-limit' '--with-layout=GNU' '--with-zlib-dir=/usr'
 '--disable-all' '--with-regex=php' '--disable-cli'
 '--with-apxs=/usr/local/sbin/apxs' '--enable-ctype'
 '--with-curl=/usr/local'
 '--with-gd' '--enable-gd-native-ttf' '--enable-gd-jis-conv'
 '--with-freetype-dir=/usr/local' '--with-jpeg-dir=/usr/local'
 '--with-png-dir=/usr/local' '--with-xpm-dir=/usr/local'
 '--with-mysql=/usr/local' '--enable-overload' '--with-pcre-regex=yes'
 '--enable-posix' '--enable-session' '--enable-sockets'
 '--enable-tokenizer'
 '--enable-xml' '--with-expat-dir=/usr/local' '--with-zlib=yes'
 '--prefix=/usr/local' 'i386-portbld-freebsd4.7'
 Server API  Apache
 Virtual Directory Support  disabled
 Configuration File (php.ini) Path  /usr/local/etc/php.ini
 PHP API  20020918
 PHP Extension  20020429
 Zend Extension  20021010
 Debug Build  no
 Thread Safety  disabled
 Registered PHP Streams  php, http, ftp, compress.zlib


 what is it I do wrong??

 thanks!

 _
 Få alle de nye og sjove ikoner med MSN Messenger http://messenger.msn.dk

 --
 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] Removing security-problematic chars from strings

2003-11-21 Thread Wouter van Vliet


 -Oorspronkelijk bericht-
 Van: John W. Holmes [mailto:[EMAIL PROTECTED]
 Verzonden: vrijdag 21 november 2003 14:38

 Wouter van Vliet wrote:
 John W. Holmes
 Troy S wrote:
 What is the best way to remove the characters from strings that may
 cause security problems?  Namely, `, ', , , , \ and all non-printing
 strings.  Did I miss any?  Thanks.
 
 Why do you need to remove them? So I can't type grin? Is that a
 security violation? All you need to do is use htmlentities() and/or
 addslashes() to protect data being displayed or entered into a database.
 
  If you're worried about HTML code being entered (guess from
 desire to strip
  ,  and /) and messing up your site's layout, you might wanna call
  strip_tags($String, $AllowedTags); where $AllowedTags is a string like
  'bui' if you want to allow bold, underline and italics.

 You could do this if you want to allow cross site scripting
 vulerabilities on your site:

 Hello b onmouseover=alert('hi');you/b.

 And prevent such evil text as grin or foo...

 --

Let's make this personal: what would be your answer if I would advice the
friendly person to do this:

?php
(..) $Content holds the string that you would want to be safe

# Create an array with allowed tags
$Allowed = Array('b', 'u', 'i', 'grin', 'foo');

# Compose var to send to strip_tags
$AllowedTags = '';
foreach($Allowed as $Tag) $AllowedTags .= ''.$Tag.'';

# Strip tags
$Content = strip_tags($Content, $AllowedTags);

# Make tags SAFE
$Content = preg_replace('/('.join($Allowed, '|').')([^]+)/', '$1',
$Content);
?

Your turn !

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



RE: [PHP] Removing security-problematic chars from strings

2003-11-21 Thread Wouter van Vliet
CPT John W. Holmes wrote:
 From: Wouter van Vliet [EMAIL PROTECTED]
 
 Let's make this personal: what would be your answer if I would advice
 the friendly person to do this:
 
 Heh.. I hope you're just kidding about making it
 personal... I was just presenting security problems with various
 solutions. 
 

Yes, I was just kidding. 

 ?php
 (..) $Content holds the string that you would want to be safe
 
 # Create an array with allowed tags
 $Allowed = Array('b', 'u', 'i', 'grin', 'foo');
 
 # Compose var to send to strip_tags
 $AllowedTags = '';
 foreach($Allowed as $Tag) $AllowedTags .= ''.$Tag.'';
 
 # Strip tags
 $Content = strip_tags($Content, $AllowedTags);
 
 # Make tags SAFE
 $Content = preg_replace('/('.join($Allowed, '|').')([^]+)/',
 '$1', $Content); ?
 
 I didn't actually try that, but I'm sure it's fine. I seems
 to remove any extra data in the tags you want to allow. It's
 good that you're still stopping me from entering such devious
 and sinister code such as (.) (.) and bar...

Neither did I try my own code. And yes, sinister code like bar and
probably (.) (.) wouldn't come through the strip_tags function. Though I'm
not sure about the second one. (nor the first one, but a little more)

 
 My point here is that I absolutely loath the strip_tags()
 function and think it should be banished to the 12th circle
 of hell, meaning mainly ASP or JSP.
 I can think of no valid reason where anyone would require that
 function. 

I sometimes use it to allow certain HTML code to be entered in a form. For
example on a news site, where news editors are pretty familiar to HTML
without any desire to use a new markup language. PHP is a programming
language (as you no doubt know) designed and most used for web applications.
I think PHP would lose it's identity as such without direct HTML code
manipulating functions.

 
 In any program, if I enter the string foo, then I expect
 to either 1) Receive an error or 2) See _exactly_ that string
 on any web page, email, etc, showing my string. I do not want
 your program (speaking in general terms here) to remove
 something from my string because it assumes it could possibly be
 something bad. 

Agree.

 
 I'm against letting users enter HTML in their data, also. I'd
 rather emply a bbcode type solution, turning [b] into b,
 etc. This way, YOU set the rules and say the user can do
 these _5_ things in this exact syntax. Otherwise you're held
 at the mercy of the HTML and browser specs and hoping that
 even just allowing b in the future won't have any security
 issues. When _you_ set the rules, you win.

Usually agree for forum like applications. Not for HTML email sending
applications.

 
 So, my suggestions:
 
 1. Just run everything through htmlentities(). If the users
 require advanced formatting, provide a bbcode solution.
 
 2. If you just _have to_ let users use HTML like b and i,
 then I'd use a solution similar to what you have above, but drop the
 strip_tags. 
 
 $allowed_tags = array('b','i');
 
 $safe_data = htmlentities($unsafe_data,ENT_QUOTES);
 
 foreach($allowed_tags as $tag)
 { $formatted_data = preg_replace('/lt;' . $tag .
 'gt;(.*)lt;\/' . $tag .
 'gt;/Ui',$tag$1/$tag,$safe_data); }
 
 Untested of course, but the only point that someone should
 take away is that you should set the rules...

H ... Still considering a reply to that one ;)

 
 ---John Holmes...

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



RE: [PHP] Removing security-problematic chars from strings

2003-11-21 Thread Wouter van Vliet
Chris Shiflett wrote:
 --- CPT John W. Holmes [EMAIL PROTECTED] wrote:
 Heh... my turn to disagree again. You can do a simple str_replace()
 to convert lt;bgt; back into b, but you're going to have to
 do it for each case. Also by doing that blindly, you can end up with
 orphaned tags affecting the rest of your page (making it all bold,
 for example).
 
 How does bbcode make this easier or even different? It seems
 to me that lt;bgt; and [b] are a lot alike; they're both
 specific strings that you want to be converted to b. The
 difference is relying on the user to learn a markup language
 specific to your application. With no real benefit in doing
 so, this is an unnecessary complication.
 
 Slash uses regular HTML, and unlike any of our PHP
 equivalents (unfortunately), it is actually a nice CMS that
 isn't plagued with security vulnerabilities. So, my opinion
 isn't unique. Maybe I'm just the only non-Perl guy who thinks this
 way. :-) 
 
 Your turn. :)
 
 Heh. :-) I don't think taking turns will help. We're probably
 both too stubborn to yield our respective positions. This
 isn't a new topic to me, and unless someone can bring up a
 point I haven't considered before, my opinion was made long ago.
 
 Chris

I don't think there is ONE pbest solution in this. It all comes down to what
kind of user you're expecting to use the application and what kind of input
you would want to allow. To what extent those users are 'to be trusted'. And
also what to do with invalid input. The way I see it, in HTML there are four
major groups of tags

1) tags to separate sections (HTMLBODYFRAMESET)
2) tags that go into the header
3) tags to lay the structure of your PAGE (divtable)
4) tags harmless for the structure, used for text formatting only
(biufont)

In my experience, web applications that let users input some code only
provide tags from group 4. Just let users markup their own text, but make
sure the general site layout is not influenced. Too wide TABLE's or layers
would push out parts of the webpage's structure, so not wanted. B tags are
generally harmless. When you can trust your users to be of good nature, not
WANTING to mess up the page, safe to allow those and strip_tags the rest
ones out.

If you cannot trust the users, and expect them to be wanting to mess up OR
are expecting users without a lot of HTML experience, give them ubb'like
things to mess with. Give them [bold], [green], [quote] and they are as
happy as you are.

Now let's look at allowing grin and what to do with entered table tags.
A user would want it's grin text to be displayed as is, where a user
entering disallowed TABLE tags is probably best of with either an ignored
post or just not showing the TABLE text. First example: gt; and lt; are
GREAT, I love them and do use them a lot. Second example: strip_tags() is my
bitch. 

Then you'd have to think about what properties to (dis)allow. When
preg_replace()'ing things like 

/(style|class|on[\w]+)=[']?[^' ]*[']? /

To an empty string, you're getting safer and safer.

So .. Turn passes left ;)
Wouter

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



RE: [PHP] tar and ownership

2003-11-21 Thread Wouter van Vliet
Rodney Green wrote:
 Marek Kilimajer wrote:
 
 Rodney Green wrote:
 
 Greetings!
 
 I'm writing a script that downloads a tarball from an FTP server and
 unpacks it into a directory. Here's the line of code that does this.
 
 exec(tar -C /scripts/ -zxv --preserve-permissions -f  .
 /scripts/mailfiles.tar.gz) or die('Tar failed!');
 
 My problem is that the files' ownership is changed when the tarball
 is unpacked. I'm executing the script from a web browser and Apache
 is running as the user apache so the files are unpacked and
 ownership given to the user apache. How can I make it so the files
 will keep the original ownerships? This is important because the
 files are mail files and the script is used to restore the mail
 files from backup so the users can access them.
 
 
 Only root can change file ownership.
 
 Thanks for replying. Any suggestions on how to do this then?
 
 Rod

Multiple solutions, some better, easier, faster or securer than others

- Make a 'cron' script, executing as root, which handles ownerships.
- Make a 'cron' script, executing as your own user, that extracts
the tarball
- Use the suexec wrapper, to change the using user of your virtual
host
- Run Apache as another user
- Make the users member of group 'apache', and give g+r file
permissions (group gets read)

With some inspiration you can probably come up with a few more, just as I
could if I wanted too ;P

Good luck!

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



RE: [PHP] echo or print

2003-11-21 Thread Wouter van Vliet
David T-G wrote:
 Eugene, et al --
 
 ...and then Eugene Lee said...
 %
 % p class=tonue-in-cheek
 %
 % Also, the letter 'e' is smaller than 'p', so ASCII-based
 function % lookups will be faster as well.
 
 Most of these speed increases can't be noticed in a small
 script, where the end is within a few lines, but echo()
 really works well in larger scripts where the end is far away.
 
 In addition, print() only sort of works well in the near
 case and doesn't work at all in the far case (as
 demonstrated when trying to throw something printed, such as a book).
 
 Finally, echo()ed statements always remain in the proper
 order, but throwing a bunch of print()s will just get you a
 big mess on the floor requiring an intelligent sort() to
 clean up -- and you know how tough it can be to write a quick
 sort() algorithm!
 
 
 %
 % /p
 
 
 HTH  HAND
 
 ;-D

Guys, Jay asked a serious question (I think). Anyways, let's take this one
step further to something that I've really been wondering about.

(.. long bunch of HTML ..)
Jay asked ?=$Question?, then Tom said ? echo $Answer; ?. ?php

print 'Meanwhile a lot of others read it including '.$Strangers[0].',
'.$Strangers[2].', '.$Strangers[3].' and '.$Strangers[4].'.\n;
echo After a short while, among others, $Kirk[firstname] {$Kirk[lastname]}
also said his things.;
?

Point is, which of the inline printing style is preferred by you guyes. I
tend to use ?=$Var? a lot, since it reads easier but get into struggles
with myself when I do that multiple times in a row.

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



[PHP] FW: [ERR] RE: [PHP] tar and ownership

2003-11-21 Thread Wouter van Vliet
[EMAIL PROTECTED] wrote:
 Transmit Report:
 
  To: [EMAIL PROTECTED], 402 Local User Inbox Full ([EMAIL PROTECTED])

Is someone able to unsubscribe [EMAIL PROTECTED] .. I'm getting annoyed by
all those User inbox full replies.
---BeginMessage---
Rodney Green wrote:
 Marek Kilimajer wrote:
 
 Rodney Green wrote:
 
 Greetings!
 
 I'm writing a script that downloads a tarball from an FTP server and
 unpacks it into a directory. Here's the line of code that does this.
 
 exec(tar -C /scripts/ -zxv --preserve-permissions -f  .
 /scripts/mailfiles.tar.gz) or die('Tar failed!');
 
 My problem is that the files' ownership is changed when the tarball
 is unpacked. I'm executing the script from a web browser and Apache
 is running as the user apache so the files are unpacked and
 ownership given to the user apache. How can I make it so the files
 will keep the original ownerships? This is important because the
 files are mail files and the script is used to restore the mail
 files from backup so the users can access them.
 
 
 Only root can change file ownership.
 
 Thanks for replying. Any suggestions on how to do this then?
 
 Rod

Multiple solutions, some better, easier, faster or securer than others

- Make a 'cron' script, executing as root, which handles ownerships.
- Make a 'cron' script, executing as your own user, that extracts
the tarball
- Use the suexec wrapper, to change the using user of your virtual
host
- Run Apache as another user
- Make the users member of group 'apache', and give g+r file
permissions (group gets read)

With some inspiration you can probably come up with a few more, just as I
could if I wanted too ;P

Good luck!

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


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

RE: [PHP] echo or print

2003-11-21 Thread Wouter van Vliet
Chris W. Parker wrote:
 Wouter van Vliet mailto:[EMAIL PROTECTED]
 on Friday, November 21, 2003 10:55 AM said:
 
 Point is, which of the inline printing style is preferred by you
 guyes. I tend to use ?=$Var? a lot, since it reads easier but get
 into struggles with myself when I do that multiple times in a row.
 
 Because of this I usually do the following:
 
 echo phere is some text with a $variable in it.br/\n
   .And this is another like of text with a $variable1 in it.br/\n
   .And so on...br/\n
   .And so forth./p\n;
 
 I also prefer ?= $variable ? to ?php echo $variable; ?
 except that for the sake of cross-system compatibility* I now
 choose to do ?php echo $variable; ?.
 
 
 Chris.
 
 * What I mean by that is if I give my code to someone else I
 want it to work with as few changes as possible. Some php
 installs don't have ? ? turned on (short tags?).
 

Well, there is an eye opener. I always thought that the ?=$Var? printing
style was not influenced by short_open_tag, but now I did a test to be sure
about it and it turned out it does..

quick test
  1 ?php
  2 echo 'ini setting short_open_tag: '.ini_get('short_open_tag');
  3 ?
  4
  5 Long open tags: ?php print 'OK'; ?
  6 Short open tags ? print 'OK'; ?
  7 Short print style ?='OK'?
output short_open_tags=On
ini setting short_open_tag: 1
Long open tags: OK
Short   open tags OK
Short print style OK
/output
output short_open_tags=Off
ini setting short_open_tag:
Long open tags: OK
Short open tags ? print 'OK'; ?
Short print style ?='OK'?
/output
/quick_test

Thanks!
Wouter

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



RE: [PHP] tar and ownership

2003-11-21 Thread Wouter van Vliet
Nigel Jones wrote:
 I think if you are using the Unix Tar Version you can do tar
 -C /scripts/ -zxv -f  ./scripts/mailfiles.tar.gz
 --owner=REPLACEME --group=REPLACEME
 

I sure hope this is NOT possible, since it would be a major security
problem. Think for example in terms of the php safe_mode. When you'd do
this, you would be able to create files as any user thinkable, and thus well
.. Need I go any further.

Knowing that 'chown' only lets you change the 'group' part of the ownership
to a group you actually belong to FROM files that are owned by yourself and
I think even the group part has to mach too.

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



RE: [PHP] echo or print

2003-11-21 Thread Wouter van Vliet
Kelly Hallman wrote:
 On Fri, 21 Nov 2003, Wouter van Vliet wrote:
 Point is, which of the inline printing style is preferred by you
 guyes. I tend to use ?=$Var? a lot, since it reads easier but get
 into struggles with myself when I do that multiple times in a row.
 
 Ultimately I think you'd want to be doing very little of any,
 if you're working with more than a basic, one-page script.
 
 Even if you are (gulp) generating your HTML output within
 functions, it seems better to be returning that back to some
 level where there are only a couple of echo/prints necessary..
 
 Think output layer...
 

Yep, that's how I usually think. For projects set up by me I usually put as
many as none logic into the output scripts, and just have them echo some
values. For example, on a news-page I call a function which returns an array
with (non-layout) specific values. And it are those values that make it
their way to ?=$News['Title']? and stuff like that. Sometimes though, I
find myself in a situation wheren I am merely changing someone else's code
and their approach isn't always (=usually not) like this at all.

But this is not really what the topic is about ;)


Chris Shiflett wrote:
 --- Chris W. Parker [EMAIL PROTECTED] wrote:
 I also prefer ?= $variable ? to ?php echo $variable; ? except
 that for the sake of cross-system compatibility* I now choose to do
 ?php echo $variable; ?.
 
 I think explicitly using echo is much more readable. While it
 may be obvious to many what ?= does, it is one more little
 thing that might seem like magic to someone else. The less of
 that type of syntax, the better, in my opinion. If you want
 magic syntax, there's Perl. It has a lot of great shortcuts,
 if you're familiar with the syntax. With PHP, most things you
 don't understand are easy to look up. I'd rather search for echo
 than ?= if I was new to PHP.

I disagree on that. ?php echo $Var; ? is much longer and causes lines to
wrap and stuff. That is what I find unreadable. Yes, ?=$Var? looks a bit
like magic, but no more than Harry Potter magic. Not like Gdanalf magic or
anything. If you want Gandalf magic, I can give you some:

?=($WhoseMagic=='Tolkien'?'Gandalf':'Harry Potter')?

Still I care more about compactness than the level of magic. Good
programmers/scripters could read my code, bad ones can't. This is called
natural selection, since bad scripters should stay out of my code. :P:P

 
 * What I mean by that is if I give my code to someone else I want it
 to work with as few changes as possible. Some php installs don't have
 ? ? turned on (short tags?).
 
 Right, plus I don't think ?php= will work (you might have
 been suggesting this). This was discussed on the internals
 list a year or two ago, and it was voted down.

Too bad, is anything known about maybe implementing a new directive next to
short_open_tags .. Something like short_echo_style, so that you won't be
allowed to open tags the short way, while still being able to echo in short
style. I see them as two different entities.

 
 Chris

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



RE: [PHP] RE: Prefilled forms (solved)

2003-11-20 Thread Wouter van Vliet
 -Oorspronkelijk bericht-
 Van: Eugene Lee [mailto:[EMAIL PROTECTED]

 On Thu, Nov 20, 2003 at 11:22:02AM +0200, Veress Berci wrote:
 :
 : Scuse me, if I write some totally dumb thing.
 : I am quite new to PHP and programming, and maybe I'm not understanding
 : the question, but:
 :
 : What if you assign a value to every form field like this:
 :
 : input type=text name=something value=?php echo $something; ?
 :
 : or - safer, with register_globals off:
 :
 : input type=text name=something value=?php echo
 $_POST['something'];
 : ?

 Actually, you can do one more thing:

   input type=text name=something value=?php echo
 htmlentities($_POST['something']); ?

 : Again, please apologize, if i'm stupid.

 Ummm, what is the question?  :-)


In some context it turned out most handy for me to fill in the form values
by running a simple javascript function after pageload. Did it by just
looping through the $_POST global array, and simple js tricks. Reason in
this was that the FORM html came from a CMS system, but it might be the best
solution in other cases too.

Another related thing: does anybody know of a PHP module providing most of
the CGI.pm (perl) functionalities for generating HTML pages? When perling,
that one DOES automatically fill the values of your form elements based on
the previously posted or getted values.

(or you could post parse your generated (form) HTML code with php, setting
the values .. )



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



RE: [PHP] Why is the php loop, 'for()', so slow????

2003-11-20 Thread Wouter van Vliet
As a substitute for substr, you might want to give a regex a chance.. have
no clue if it's faster, but it might just be.

/^.{2}(.{0,8})/

would be your regex if you want to start at offset THREE and take out a MAX
EIGHT char string (remove the 0 and get ONLY EIGHT char strings). Not sure
if PHP sets $1, $2, .. vars, else give the optional third Matches param to
preg_match();

Wouter

 -Oorspronkelijk bericht-
 Van: Scott Fletcher [mailto:[EMAIL PROTECTED]
 Verzonden: donderdag 20 november 2003 15:44
 Aan: [EMAIL PROTECTED]
 Onderwerp: Re: [PHP] Why is the php loop, 'for()', so slow


 Well, should have make one long string to the $res_str variable a lot
 shorter.  :-)

 It turned out that the for() loop isn't the slow part when you mentioned
 about substr().  I tried out the while() loop and it is pretty
 much the same
 when the loop take over 5 minutes.  So, it now seem to have to do with
 substr() function.  Yea, I'm not sure what hte best substitute of it would
 be.  In other branches off of this posting, someone said about using the
 strpos().  I'm willing to give this a try but I have problem with this
 because I have two !CDATA[[***]] tags in it and I want to use
 both, not
 just first one.

 Scott

 Chris W. Parker [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
 Scott Fletcher mailto:[EMAIL PROTECTED]
 on Wednesday, November 19, 2003 1:12 PM said:

  function CBC_XML_BreakUp($strResponse_XML, $strResponse_HTML)
 
  {

 [snip]

 Wow I didn't think you were going to post your whole program. :0

 1. Are you sure the for() loop is the slow part?

 2. As someone already suggested, calculating the sizeof() outside of the
 loop should help a lot. Another enhancement is changing your for() to
 while(). (This is a small enhancement but makes a bigger difference as
 your iterations increase.)

 REGULAR for() loop construct:

 $iMax = 99;

 for($iCnt = 0; $iCnt  $iMax; $iCnt++)
 {
 }

 OPTIMIZED:

 $iMax = 99;
 $iCnt = -1;

 while(++$iCnt  $iMax)
 {
 }

 Like I said it's only slightly faster, but might make a difference
 depending on your number of iterations.

 3. I think what may be slowing you down is your substr() calls. Maybe
 there is a substitute function that is faster? (I don't have any ideas
 unfortunately.)


 Let us know if you figure something out.

 HTH,
 Chris.
 --
 Don't like reformatting your Outlook replies? Now there's relief!
 http://home.in.tum.de/~jain/software/outlook-quotefix/

 --
 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] .html extension PHP page be interpret

2003-11-18 Thread Wouter van Vliet

 -Oorspronkelijk bericht-
 That's simple, just modify your Apache httpd.conf on the line
 where it says something along the lines of:

 AddType application/x-httpd-php .php4 .php .php3 .inc

 change it to:

 AddType application/x-httpd-php .php4 .php .html .php3 .inc

And please, PLEASE remove .inc from the list, and add smth like

Files /.*\.inc/
Deny from all
/Files

I'm not sure about the syntax, but believe me .. what I am telling you is
what you want :D:D

Wouter

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



RE: [PHP] sorting an array of regexes

2003-11-18 Thread Wouter van Vliet
 -Oorspronkelijk bericht-
 Van: Eugene Lee [mailto:[EMAIL PROTECTED]
 On Tue, Nov 18, 2003 at 01:15:32PM +0100, Adam i Agnieszka
 Gasiorowski FNORD wrote:
 :
 : There is an array of regexes, for example
 :
 :  $array = array('moon', '[wh]ood', '[^as]eed' ...
 :  (about 300 entries).
 :
 : I want to sort it comparing to the
 :  character lenght of a regex. For example
 :  [wh]ood is 4 characters, moon is 4 characters.
 :  There are only letters of the alphabet and
 :  letter ranges present in those regexes. I
 :  want the longest ones first.
 :
 : How would you write the sorting function?

 This might be the most functionally correct, although it's definitely
 not the fastest route.

   function re_len($pat)
   {
   return strlen(preg_replace('/\[[^]]+]/', '_', $pat));

I think you meant:

/\[[^\]]+]/

as regex ;) Not sure, but I think one more block-bracked needed to be
escaped ;)

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



RE: [PHP] How to get the key of a specific index of array?

2003-11-18 Thread Wouter van Vliet
 -Oorspronkelijk bericht-
 Van: PhiSYS [mailto:[EMAIL PROTECTED]

 How to get the key of a specific index of array?

 It seems that key($_POST[$i]) is a wrong syntax.

 I've worked around like this:

   $allkeys = array_keys($_POST);
   $allvalues = array_values($_POST);

   for($I=3; $I  count($_POST); $I++) {
 echo $allkeys[$I];
 echo $allvalues[$I];
   }


First of all, you said to use the first three values of the array for anoter
reason .. well the, what I'd do is this:

$FirstThree = array_splice($_POST, 0, 3);

Which will give you the first three elements of the array, and leave you
with a $_POST array you can do foreach with.

Second, to manually loop through an array, use:
http://nl.php.net/manual/en/function.prev.php
http://nl.php.net/manual/en/function.next.php
http://nl.php.net/manual/en/function.current.php
http://nl.php.net/manual/en/function.reset.php
http://nl.php.net/manual/en/function.end.php

Third, don't rely on the order your array elements are given to you by post
data. Rather just use foreach() and (ignore|do something else with) the
key-value pairs you don't want for this thing.

Fourth, I hope I'm not spoiling Jay Blanchard statement on how uncredibly
great this online PHP Manual is since you could probably find all the
answers to array related questions right here:
http://nl.php.net/manual/en/ref.array.php

And all you other answers around here:
http://nl.php.net/docs.php
and here
http://www.google.com

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



RE: [PHP] I need answers for the questions

2003-11-18 Thread Wouter van Vliet
 -Oorspronkelijk bericht-
 Van: John Nichel [mailto:[EMAIL PROTECTED]

 Arivazhagi Govindarajan wrote:
 PHP Questions
 
  1. Explain about session management and cookies ? In PHP how we can
  maintain a session

While writing PHP code you put your body in risk of getting work related
problems. Manage your PHP Code Writing sessions so that you do not spend
too much time behind your screen. Read about PHP in a book too sometimes, or
print several pages of the online PHP reference manual.

 
  2. What is HTTP tunneling
HTTP is a new brand of car. Drive one through a tunnel and you are HTTP
Tunneling

 
  3. How to enable PHP in Apache server manually?
Ramble your server box several times.

 
  4. When we upload a file using INPUT tag of the type FILE what are
  global variables become available for use in PHP
None, since any self respecting PHP Scripter has register_globals set to
Off

 
  5. Explain SQL injections ? How we can avoid this
A new method exposed by the US and Iraqi government for proteting their
citizens for eachothers weapons of mass desctruction. Expanded to: Single
Query Lineup

 
  9. what is search engine optimization ? In HTML using which tag we can
  attain this?
It's mostly about asking the right questions to Jeeves.com. Make sure you
don't ask him HTML specific questions, since he tends to give you false
answers on that

Here you have it .. I've given you most of the answers, you should be able
to figure the rest out on your own. Make sure to post your grade on the list
to. Especially mail it to me at [EMAIL PROTECTED] cuz I'm rather interested
in how good you did with my answers.

Wouter

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



RE: [PHP] Microsoft .NET arguement

2003-11-17 Thread Wouter van Vliet
Jay Blanchard wrote:
 [snip]
 I have someone here at my desk arguing that Microsoft's .NET
 is better than PHP - faster to process, easier and quicker to
 program, etc. 
 
 They also (claim) that Microsoft's SQL is much faster and such vs.
 MySQL. 
 
 Any comments to help me defend PHP or to educate me? [/snip]
 
 Both 'arguments' are so general as to be laughable. Come up
 with some specific issues and we can go toe-to-toe.
 
 NET v PHP
 1. Platform dependency? (Run on M$ platforms v. running on a
 variety of platforms, including M$)
 
 MySQL v MSSQL
 1. MSSQL is bloated. Speed is an issue. Footprint is an issue.
 2. Platform dependency?
 
 Have fun!

To add a little bit to this conversation, one thing I heard about the .NET
technology is that it supports multiple scripting languages in one file. Not
that it would really (usually) be the best thing, but that means that you
can use Perl, C#, PHP and ASP.NET all in the same file.. 

;),
Wouter

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



RE: [PHP] form action=?

2003-11-12 Thread Wouter van Vliet
 -Original Message-
 From: Chris Shiflett [mailto:[EMAIL PROTECTED] 
 Sent: woensdag 12 november 2003 17:23
 To: Alan Lord; [EMAIL PROTECTED]
 Subject: Re: [PHP] form action=?
 
 --- Alan Lord [EMAIL PROTECTED] wrote:
  can I put a function_name() in the form action=... place holder?

For once and for all .. NO, you cannot do that. The form is submitted to a
page, and this page will execute funtions.

What you might want to do is this (though I doubt if you want to do it cuz
it is pretty unsafe):

forma action='execute.php?f=function_name' method='post' 

== execute.php ==
?php
if (isset($_POST['f'])) $_POST['f'](); 
?

 
 I think you can do this with JavaScript, yes.

No, Chris. For as far as I know you cannot even do this with JavaScript.
Though I've never tried it. What you can do is use the 'onSubmit' event like
this:

form action='foo.php' onSubmit='return
FunctionDeclaredInJavascript()'

Where FunctionDeclaredInJavascript() is a function declared in JS (not in
PHP).  If it returns false the form will not be submitted, if it returns
true the form will .. Guesss what? :P

 
 Chris
 
 =
 My Blog
  http://shiflett.org/
 HTTP Developer's Handbook
  http://httphandbook.org/
 RAMP Training Courses
  http://www.nyphp.org/ramp
 
 --
 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



  1   2   >