Re: [PHP] DLL

2008-10-23 Thread Alain Roger
thx a lot for the links. i'm gonna check them but it seems promising.

On Wed, Oct 22, 2008 at 8:26 PM, Stut [EMAIL PROTECTED] wrote:

 On 22 Oct 2008, at 19:21, Alain Roger wrote:

 i would like to know if it exists a way to create component (maybe using
 python, perl, or something else) to save it as DLL and to use this
 component
 on PHP pages ?
 i mean by component something like a graphical representation of a table.

 this dll should be able to be dynamically loaded by PHP script, not by
 server.


 Sure. Write an extension [1] and use the dl function [2].

 [1] http://jmp.li/ca
 [2] http://jmp.li/cb

 -Stut

 --
 http://stut.net/




-- 
Alain

Windows XP SP3
PostgreSQL 8.2.4 / MS SQL server 2005
Apache 2.2.4
PHP 5.2.4
C# 2005-2008


Re: [PHP] CSV Files

2008-10-23 Thread Ashley Sheridan
On Wed, 2008-10-22 at 22:30 -0400, Andrew Ballard wrote:
 On Wed, Oct 22, 2008 at 10:15 PM, Jason Todd Slack-Moehrle
 [EMAIL PROTECTED] wrote:
  On Oct 22, 2008, at 6:58 PM, Stut wrote:
 
  On 23 Oct 2008, at 02:41, Jason Todd Slack-Moehrle wrote:
 
  Actually i am ending the row headers with a chr(10); // LINE FEED
 
  From the code you included in your original post...
 
  echo /n;
 
 
  There was no mention of chr(10).
 
  Outputting data in CSV format is not hard. Simply echo the header row if 
  necessary, followed by \n. Then output each line taking care to put 
  string values in quotes which means you also need to escape quotes in the 
  data. After each line echo \n. That's really all there is to it.
 
  If you're still having problems I suggest you post the exact code you're 
  using, anything else just makes it harder for us to provide effective help.
 
  -Stut
 
  On Oct 22, 2008, at 5:12 PM, Stut wrote:
 
  On 23 Oct 2008, at 00:59, Jason Todd Slack-Moehrle wrote:
 
  After I right out the column headers do I have to put a '/n' to have it 
  start a new line in the CSV file? I think I do.
 
  A new line is \n not /n, and it must be in double quotes () not single 
  (').
 
 
  Oh, I am not putting quotes around each field that i get from MySQL. There 
  are no quotes in the data so that is good.
 
  Sorry I put /n and I meant to put chr(10).
 
  -Jason
 
 
 Jason, one of the points that Stut was trying to explain is that \n
 and chr(10) are the same thing. They are just two different ways to
 refer to a newline (line feed) character. Most of us probably use \n
 rather than chr(10) in PHP, though. So, the following two lines are
 equivalent:
 
 ?php
 echo Item1, Item2, Item3 . chr(10);
 
 // Note this uses double quotes.
 echo Item1, Item2, Item3\n;
 
 // It won't be the same at all if you use single quotes
 echo 'Item1, Item2, Item3\n';
 
 ?
 
 At any rate, you are correct that you need a line feed/newline
 character at the end of every row in CSV including the header row.
 
 Andrew
 
A line feed and \n are not the same thing at all. Different operating
systems implemented a different method of line endings depending on what
they thought best, either a carriage return or line feed or both. a \n
is meant to be an OS agnostic way of implementing this in the various
programming languages, outputting something that any OS can understand
in the intended way.


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] CSV Files

2008-10-23 Thread Andrew Ballard
On Thu, Oct 23, 2008 at 2:22 AM, Ashley Sheridan
[EMAIL PROTECTED] wrote:
 On Wed, 2008-10-22 at 22:30 -0400, Andrew Ballard wrote:
 On Wed, Oct 22, 2008 at 10:15 PM, Jason Todd Slack-Moehrle
 [EMAIL PROTECTED] wrote:
  On Oct 22, 2008, at 6:58 PM, Stut wrote:
 
  On 23 Oct 2008, at 02:41, Jason Todd Slack-Moehrle wrote:
 
  Actually i am ending the row headers with a chr(10); // LINE FEED
 
  From the code you included in your original post...
 
  echo /n;
 
 
  There was no mention of chr(10).
 
  Outputting data in CSV format is not hard. Simply echo the header row if 
  necessary, followed by \n. Then output each line taking care to put 
  string values in quotes which means you also need to escape quotes in the 
  data. After each line echo \n. That's really all there is to it.
 
  If you're still having problems I suggest you post the exact code you're 
  using, anything else just makes it harder for us to provide effective 
  help.
 
  -Stut
 
  On Oct 22, 2008, at 5:12 PM, Stut wrote:
 
  On 23 Oct 2008, at 00:59, Jason Todd Slack-Moehrle wrote:
 
  After I right out the column headers do I have to put a '/n' to have 
  it start a new line in the CSV file? I think I do.
 
  A new line is \n not /n, and it must be in double quotes () not single 
  (').
 
 
  Oh, I am not putting quotes around each field that i get from MySQL. There 
  are no quotes in the data so that is good.
 
  Sorry I put /n and I meant to put chr(10).
 
  -Jason
 

 Jason, one of the points that Stut was trying to explain is that \n
 and chr(10) are the same thing. They are just two different ways to
 refer to a newline (line feed) character. Most of us probably use \n
 rather than chr(10) in PHP, though. So, the following two lines are
 equivalent:

 ?php
 echo Item1, Item2, Item3 . chr(10);

 // Note this uses double quotes.
 echo Item1, Item2, Item3\n;

 // It won't be the same at all if you use single quotes
 echo 'Item1, Item2, Item3\n';

 ?

 At any rate, you are correct that you need a line feed/newline
 character at the end of every row in CSV including the header row.

 Andrew

 A line feed and \n are not the same thing at all. Different operating
 systems implemented a different method of line endings depending on what
 they thought best, either a carriage return or line feed or both. a \n
 is meant to be an OS agnostic way of implementing this in the various
 programming languages, outputting something that any OS can understand
 in the intended way.


 Ash
 www.ashleysheridan.co.uk

As I understood, \n was strictly a line feed (ASCII character 10), not
an OS agnostic end-of-line terminator. It happens to be the line
terminator for *nix. Windows uses the combined carriage return and
line feed characters (ASCII characters 13 and 10) which are
represented by \r\n in PHP, while Mac used only the the carriage
return.  There is a PHP constant PHP_EOL that I'm pretty sure is
supposed to represent the line terminator defined on the operating
system of the computer executing the script, but I don't think it is
truly agnostic either. At least, if you have a text file saved in
Windows and split it on a Linux machine based on PHP_EOL, I believe
all of your array values will have a carriage return character hanging
on the end of them. Am I mistaken?

Andrew

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



Re: [PHP] MkDir Help

2008-10-23 Thread Yeti
If you are prior PHP5 write your own recursive mkdir function [1] as
posted on this list a while ago.

[1] http://marc.info/?l=php-generalm=121926660406116w=2

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



Re: [PHP] CSV Files

2008-10-23 Thread Ashley Sheridan
On Thu, 2008-10-23 at 02:26 -0400, Andrew Ballard wrote:
 On Thu, Oct 23, 2008 at 2:22 AM, Ashley Sheridan
 [EMAIL PROTECTED] wrote:
  On Wed, 2008-10-22 at 22:30 -0400, Andrew Ballard wrote:
  On Wed, Oct 22, 2008 at 10:15 PM, Jason Todd Slack-Moehrle
  [EMAIL PROTECTED] wrote:
   On Oct 22, 2008, at 6:58 PM, Stut wrote:
  
   On 23 Oct 2008, at 02:41, Jason Todd Slack-Moehrle wrote:
  
   Actually i am ending the row headers with a chr(10); // LINE FEED
  
   From the code you included in your original post...
  
   echo /n;
  
  
   There was no mention of chr(10).
  
   Outputting data in CSV format is not hard. Simply echo the header row 
   if necessary, followed by \n. Then output each line taking care to 
   put string values in quotes which means you also need to escape quotes 
   in the data. After each line echo \n. That's really all there is to 
   it.
  
   If you're still having problems I suggest you post the exact code 
   you're using, anything else just makes it harder for us to provide 
   effective help.
  
   -Stut
  
   On Oct 22, 2008, at 5:12 PM, Stut wrote:
  
   On 23 Oct 2008, at 00:59, Jason Todd Slack-Moehrle wrote:
  
   After I right out the column headers do I have to put a '/n' to have 
   it start a new line in the CSV file? I think I do.
  
   A new line is \n not /n, and it must be in double quotes () not 
   single (').
  
  
   Oh, I am not putting quotes around each field that i get from MySQL. 
   There are no quotes in the data so that is good.
  
   Sorry I put /n and I meant to put chr(10).
  
   -Jason
  
 
  Jason, one of the points that Stut was trying to explain is that \n
  and chr(10) are the same thing. They are just two different ways to
  refer to a newline (line feed) character. Most of us probably use \n
  rather than chr(10) in PHP, though. So, the following two lines are
  equivalent:
 
  ?php
  echo Item1, Item2, Item3 . chr(10);
 
  // Note this uses double quotes.
  echo Item1, Item2, Item3\n;
 
  // It won't be the same at all if you use single quotes
  echo 'Item1, Item2, Item3\n';
 
  ?
 
  At any rate, you are correct that you need a line feed/newline
  character at the end of every row in CSV including the header row.
 
  Andrew
 
  A line feed and \n are not the same thing at all. Different operating
  systems implemented a different method of line endings depending on what
  they thought best, either a carriage return or line feed or both. a \n
  is meant to be an OS agnostic way of implementing this in the various
  programming languages, outputting something that any OS can understand
  in the intended way.
 
 
  Ash
  www.ashleysheridan.co.uk
 
 As I understood, \n was strictly a line feed (ASCII character 10), not
 an OS agnostic end-of-line terminator. It happens to be the line
 terminator for *nix. Windows uses the combined carriage return and
 line feed characters (ASCII characters 13 and 10) which are
 represented by \r\n in PHP, while Mac used only the the carriage
 return.  There is a PHP constant PHP_EOL that I'm pretty sure is
 supposed to represent the line terminator defined on the operating
 system of the computer executing the script, but I don't think it is
 truly agnostic either. At least, if you have a text file saved in
 Windows and split it on a Linux machine based on PHP_EOL, I believe
 all of your array values will have a carriage return character hanging
 on the end of them. Am I mistaken?
 
 Andrew
I'm afraid I do disagree with your there:

When writing a file in text mode, '\n' is transparently translated to
the native newline sequence used by the system

This is from the Wikipedia article I found:
http://en.wikipedia.org/wiki/Newline



Ash
www.ashleysheridan.co.uk


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



[PHP] class constructor overloading

2008-10-23 Thread Alain Roger
Hi,

is it possible to overload the class construct(or) ?
if yes, how ?
thx.

-- 
Alain

Windows XP SP3
PostgreSQL 8.2.4 / MS SQL server 2005
Apache 2.2.4
PHP 5.2.4
C# 2005-2008


Re: [PHP] export data to a ms excel file using php

2008-10-23 Thread gopi krishnan
Hi,

Could any one explain better. I need just the grid lines for the excel
sheet. I already tried that table border=1 but it shows the linings only
to the valued cells. But i need to show the grid as in MS Excel. I tried
TEXT/XML
but i get the following error

---

The XML page cannot be displayed

Cannot view XML input using XSL style sheet. Please correct the error and
then click the Refresh javascript:location.reload() button, or try again
later.
--

A string literal was expected, but no opening quote character was found.
Error processing resource 'http://localhost/dbtoxl...

table border=1tr td width=10025 /tdtd width=100 jana
/tdtd  width=100...


---

thanks in advance


On Thu, Oct 23, 2008 at 3:21 AM, Nitsan Bin-Nun [EMAIL PROTECTED] wrote:

 And what about users who use office version  2003 (which do NOT support
 .xml charts)
 You can google a bit, I'm pretty sure I have already encountered a class
 for this case at Manuel's site (phpclasses).

 Nitsan

 On Wed, Oct 22, 2008 at 9:00 PM, Ashley Sheridan [EMAIL PROTECTED]
  wrote:

 On Wed, 2008-10-22 at 11:20 -0700, Jim Lucas wrote:
  [EMAIL PROTECTED] wrote:
   Hi,
  
   I have tried your MS-Excel MIME type in PHP. But am facing a small
 problem. I can't get the grid lines as look like in normal Excel file.
  
   Am using windows XP, Internet explorer 6.0, MS Excel 2003
  
   Thanks in advance.-- Jim Lucas wrote :
   abderrazzak nejeoui wrote:
   can you help me to export data to a ms excel file using php. i tried
 to
   export them to an html format and change the extension to .xls that's
 work
   but i have lost the formatting
  
   excel and the navigator doesn't interpret my code in the same why
 (celles
   are not in the same size)
  
  
   Ok, so with the examples of others here, here is the shortest example
 that I came up with that
   should get you going.
  
   ?php
  
   header(Content-Type:  application/vnd.ms-excel);
   header(Expires: 0);
   header(Cache-Control: must-revalidate, post-check=0, pre-check=0);
  
   $x = $y = range(0, 12);
  
   echo 'table';
  
   echo 'trtd /tdtd' . join('/tdtd', $x) . '/td/tr';
  
   foreach ( $x AS $xx ) {
   echo trtd{$xx}/td;
   foreach ( $y AS $yy ) {
   echo
 td=sum(.(chr(ord('b')+$yy)).1*a.($xx+2).)/td;
   }
   echo /tr;
   }
   echo '/table';
  
   ?
  
   This will output a 14x14 table.  It will calculate the totals for each
 cell in the actual
   spreadsheet once excel loads it.
  
   If you have any questions, ask away.
  
 
  You could change this line
 
  echo 'table';
 
  to this
 
  echo 'table border=1';
 
  This will give you borders around your content at least.
 
  Example:
 
 http://www.cmsws.com/examples/php/testscripts/[EMAIL PROTECTED]/0001.php
 
  I would checkout phpexcel also
 
  --
  Jim Lucas
 
 Some men are born to greatness, some achieve greatness,
 and some have greatness thrust upon them.
 
  Twelfth Night, Act II, Scene V
  by William Shakespeare
 
 
 I think you really need to save the file as an XML file, with the
 text/xml mime-type. Then, save an Excel file in the M$ Office 2003 XML
 file-type (not the 2007 xlsx!) and look at the code it produces and try
 to mimic that output as closely as possible. All you're doing is
 creating an HTML table and hoping Excel knows what to do with it, which
 is a bit like creating an image, sending it to the browser with a PDF
 mime and hoping it will open up in Adobe Reader; just not gonna work
 that way!

 Your best bet by far though, is to use a pre-built Excel export class.
 Take a look at PEAR of PHPLib, as these both have classes that do what
 you need.


 Ash
 www.ashleysheridan.co.uk


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





Re: [PHP] class constructor overloading

2008-10-23 Thread David Otton
2008/10/23 Alain Roger [EMAIL PROTECTED]:

 is it possible to overload the class construct(or) ?
 if yes, how ?

class A
{
function __construct()
{
echo A;
}
}

class B extends A
{
function __construct()
{
echo B;
parent::__construct();
}
}

$B = new B();

-- 

http://www.otton.org/

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



[PHP] Re: XCache, APC, Memcached... confused

2008-10-23 Thread Colin Guthrie

Stut wrote:

On 23 Oct 2008, at 00:04, Martin Zvarík wrote:
I am looking at the eAccelerator's website and I realize what got me 
confused:


there is a function for OUTPUT CACHE, so it actually could cache the 
whole website and then run out of memory I guess...


that means I would be able to store anything into the memory and 
reference it by a variable? are the variables accessible across the 
whole server? I still don't really understand, but I am trying...


Having never used eAccelerator I can only guess, but it sounds like it's 
a way to cache HTML output. As for how accessible that is I have no 
idea. I suggest you find the eAccelerator mailing list, subscribe to 
that and ask your question there.


If you are looking into caching things in a very flexible way I'd look 
at the Zend_Cache API from the Zend Framework.


It has backedns to connection to APC and Memcache and also implements a 
disk-based caching system. You can cache all sorts of output, from 
function calls (both return value and side-effect output), html output 
and arbitrary objects.


Using an opcode cache is generally a good idea (part of the APC core 
will be included in PHP6, which is why I'm currently backing that 
particular horse), but for an application-level caching strategy, I 
think Zend_Cache has a lot going for it :)


Col

--

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mandriva Linux Contributor [http://www.mandriva.com/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]


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



[PHP]Keep the modification date of a file when archiving it.

2008-10-23 Thread Bastien Helders

Hi,

When I'm archiving files in a ZIP file, using the class ZipArchive, the 
modification date is modified to when ZipArchive::close is called. I would like 
to keep the original modification date. Is that even possible?

Best Regards,
Bastien Helders

_
Téléphonez gratuitement à tous vos proches avec Windows Live Messenger  !  
Téléchargez-le maintenant !
http://www.windowslive.fr/messenger/1.asp

Re: [PHP] class constructor overloading

2008-10-23 Thread Alain Roger
thanks a lot, this is exactly what i needed.
if the construct of based class A accept arguments, i guess that construct
of class B must have the sames.
moreover, i guess that something like that must be written:
class A
{
  function __construct($nameA)
  {
...
  }
}

class B extends A
{
  function __construct($nameB)
  {
parent::__construct($nameB);
  }
}

am i right ?

thanks.

A.


[PHP] Politics

2008-10-23 Thread Amy

prints mosfet customercontrol universally lastinfirstout unixlike techie 
perversities agreement

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



Re: [PHP] Re: Problem changing file encoding

2008-10-23 Thread Thodoris



Thodoris wrote:

Hi guys,
I am developing a project and I wrote an interface to import 
contracts in it. The problem is that when the user uploads the file I 
don't know what is the encoding it has. So I decided that a good idea 
is to make the user tell me the encoding from a drop down before I 
parse the file.


Then I could probably change the encoding with iconv and use it to 
validate the data and make the inserts in mysql. Although in the unix 
world I have available the iconv command and I can change the file to 
the new encoding like this:


iconv -f  CP737 -t UTF-8 -o newfile.csv original_file.csv

I can't find a way to do this from within php. Iconv support gives me 
some options but only to convert strings and there is not a way AFAIK 
to get all the supported encodings from the system as I can do in 
command line with this:


iconv --list

Is this the best way to do this ? Can I use mbstring as an alternative ?

Please make any suggestions you might think because I am stuck.



made this a while back.. might help :)
http://programphp.com/iconv.phps



Thanks Natham this is a nice approach and it certainly helps.

--
Thodoris


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



Re: [PHP] class constructor overloading

2008-10-23 Thread Jim Lucas

Alain Roger wrote:

thanks a lot, this is exactly what i needed.
if the construct of based class A accept arguments, i guess that construct
of class B must have the sames.
moreover, i guess that something like that must be written:
class A
{
  function __construct($nameA)
  {
...
  }
}

class B extends A
{
  function __construct($nameB)
  {
parent::__construct($nameB);
  }
}

am i right ?

thanks.

A.



Yes


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



Re: [PHP] class constructor overloading

2008-10-23 Thread David Otton
2008/10/23 Alain Roger [EMAIL PROTECTED]:
 thanks a lot, this is exactly what i needed.
 if the construct of based class A accept arguments, i guess that construct
 of class B must have the sames.

No, you can change the signature of a method when you overload it.
Below, B::__construct() accepts 1 argument while A::__construct()
accepts 0 arguments:

class A
{
   function __construct()
   {
   echo A;
   }
}

class B extends A
{
   function __construct( $string )
   {
   echo $string;
   parent::__construct();
   }
}

$B = new B( B );

If you need to force a certain signature in child classes, you can
declare the parent class abstract:

abstract class A
{
   abstract function f( $a );
}

class B extends A
{
function f( $a, $b ) // throws an error
{
echo $a, $b;
}
}

$B = new B(B, C);

However, if you declare the constructor as abstract, it will be ignored.

-- 

http://www.otton.org/

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



[PHP] Inheritance of class methods

2008-10-23 Thread Alain Roger
Hi,

i have the following classes:
class A
{
  public function EchoMe($txt)
  {
echo $txt;
  }
}

class B extends A
{
  ...
}

in theory i can write something like that:

$b = new B();
$b-EchoMe(test);

and i should get echo test on screen.
am i correct ?

-- 
Alain

Windows XP SP3
PostgreSQL 8.2.4 / MS SQL server 2005
Apache 2.2.4
PHP 5.2.4
C# 2005-2008


[PHP] Re: Inheritance of class methods

2008-10-23 Thread Nathan Rixham

Alain Roger wrote:

am i correct ?


yup [unless you overwrite it in class B with another method of the same 
name that functions differently]


--
nathan ( [EMAIL PROTECTED] )
{
  Senior Web Developer
  php + java + flex + xmpp + xml + ecmascript
  web development edinburgh | http://kraya.co.uk/
}

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



Re: [PHP] Inheritance of class methods

2008-10-23 Thread Yeti
Using extends means that a class IS-A substructure of its parent class(es).

EXAMPLE:

class plant { };
class tree extends plant { };
class apple_tree extends tree { };

apple_tree inherits all methods and attributes from plant and tree
So if there was a methods plant-growth() you can also call it from
tree and apple_tree

IS-A versus HAS-A

apple_tree IS-A tree
apple_tree HAS-A fruit called apple

So apple does not extend apple_tree because it is not a tree

EXAMPLE:

class apple {
var color = 'blue';
var inhabitant = 'worm';
}
class apple_tree extends tree {
var apples = array(new apple());
}

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



Re: [PHP] Inheritance of class methods

2008-10-23 Thread Jochem Maas
Alain Roger schreef:
 Hi,
 
 i have the following classes:
 class A
 {
   public function EchoMe($txt)
   {
 echo $txt;
   }
 }
 
 class B extends A
 {
   ...
 }
 
 in theory i can write something like that:
 
 $b = new B();
 $b-EchoMe(test);
 
 and i should get echo test on screen.
 am i correct ?

with regard to theory, here's one of mine:

in the time you wrote the email you could have run the code and
found out for yourself.

enjoy.

 


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



Re: [PHP] Re: ZendOptimizer + APC

2008-10-23 Thread Jochem Maas
Nathan Nobbe schreef:
 On Wed, Oct 22, 2008 at 4:39 PM, Martin Zvarík [EMAIL PROTECTED] wrote:
 
 Jochem Maas napsal(a):

napsal(a) ... that's even weirder than my 'schreef' :-)

 anyone know whether running ZendOptimizer + APC simultaneously still
 causes allsorts
 of problems ... I know it did in the past but I can't find any very recent
 stuff about the
 issues online.

 I believe you should look up eAccelerator or XCache, which should work with
 ZendOptimizer.
 
 
 as Jocheem said before the app is bound to apc; depends on the
 implementation whether it could be ported to another solution.

technically I can remove/replace APC - but time and desire say otherwise.

the joke is that the server in question will only be running my app ... with
the expection of a generic controlpanel thang for server management ...
which requires ZendOptimizer ... and the sysadmin doesn't want to turn off
ZendOptimizer because then the controlpanel app won't work
(the server only exists to run the app/site/foo I wrote for a given client,
but obviously I'll have to 'fix' my stuff so that the controlpanel can
continue to run)

just another wtf. regardless, thanks to those that responded.



 
 -nathan


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



RE: [PHP] export data to a ms excel file using php

2008-10-23 Thread Jay Blanchard
[snip]
Could any one explain better. I need just the grid lines for the excel
sheet. I already tried that table border=1 but it shows the linings
only
to the valued cells. But i need to show the grid as in MS Excel. I tried
TEXT/XML
but i get the following error
[/snip]

http://evolt.org/node/26896

Part of the problem is that an empty table cell has no borders. To
combat this you can test for a value and if it has none place a
non-breaking space it (nbsp;)

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



Re: [PHP] class constructor overloading

2008-10-23 Thread Jochem Maas
Alain Roger schreef:
 thanks a lot, this is exactly what i needed.
 if the construct of based class A accept arguments, i guess that construct
 of class B must have the sames.
 moreover, i guess that something like that must be written:

I guess you find guessing preferable to RTFM and/or trying code out.

 class A
 {
   function __construct($nameA)
   {
 ...
   }
 }
 
 class B extends A
 {
   function __construct($nameB)
   {
 parent::__construct($nameB);
   }
 }
 
 am i right ?

are you?

 
 thanks.
 
 A.
 


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



Re: [PHP] Politics

2008-10-23 Thread Jochem Maas
Amy schreef:
 prints mosfet customercontrol universally lastinfirstout unixlike techie 
 perversities agreement
 

going by the last 4 words she must be talking about Cummings ... we all agree 
his doll fetish is
rather perverse and he's definitely unixlike

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



[PHP] Printing JPEG

2008-10-23 Thread Kyle Terry
I'm stuck... What is the best way to send a jpg to a printer with PHP? Looks
like it is only working with png and bmp...

-- 
Kyle Terry | www.kyleterry.com


Re: [PHP] Half way

2008-10-23 Thread tedd

At 5:27 PM +0200 10/22/08, Jochem Maas wrote:

personally I prefer the solution where there is no ad shown at all.



I hear that -- I hate it when you develop a beautiful site for a 
client and then they want to hang ads off it -- and then complain 
about the site being too wide.


Can't win

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



Re: [PHP] Mysql search

2008-10-23 Thread tedd

At 11:16 PM -0700 10/21/08, Ryan S wrote:


clipp
 Am hoping someone out there can recommend a better script or maybe 
share some of your own code?


 Any help would be appreciated.


Do it right... read up on MySQL's fulltext matching.

Cheers,
Rob.
/clipp

Did some searching based on your tip, got what i was looking for, 
just didnt know where to start.. and now feeling like the man who 
was taught how to fish :D


Thanks!
R


I often feel like a fish given a matchbook.

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



Re: [PHP]Keep the modification date of a file when archiving it.

2008-10-23 Thread Kyle Terry
Before changing the file, use the filemtime()
http://us3.php.net/filemtimefunction to get the mod date, then use
touch() http://us3.php.net/manual/en/function.touch.php to set the date
after you change the file.

On Thu, Oct 23, 2008 at 2:25 AM, Bastien Helders
[EMAIL PROTECTED]wrote:


 Hi,

 When I'm archiving files in a ZIP file, using the class ZipArchive, the
 modification date is modified to when ZipArchive::close is called. I would
 like to keep the original modification date. Is that even possible?

 Best Regards,
 Bastien Helders

 _
 Téléphonez gratuitement à tous vos proches avec Windows Live Messenger  !
 Téléchargez-le maintenant !
 http://www.windowslive.fr/messenger/1.asp




-- 
Kyle Terry | www.kyleterry.com


Re: [PHP] XCache, APC, Memcached... confused

2008-10-23 Thread ceo

 First of all you need to get it clear in your head what an opcode cache 

 is actually doing. It does not cache the website, it caches the 

 compiled version of the PHP scripts such that PHP doesn't need to 

 recompile each file every time it's included which is the default way 

 PHP works.



And, to be really clear, the savings in compile time is gravy.



The REAL savings is not hitting that slow-spinning disk drive to LOAD the PHP 
script into RAM.



You'd get very similar performance boost if the opcode cache simply cached the 
PHP source.



But it's just as easy to cache the compiled version, and that saves a few more 
microseconds/milliseconds.



Depends how big/long/convoluted the PHP source is, but, really, it rarely is 
that big of a file.



I doubt that 2 opcode caches can run in parallel, as they both hook into the 
same line of code in PHP.  And if they did run in parallel, the second one 
would not help in the least, and would actually just be more overhead for zero 
gain.



PS

All the opcode caches have a strategy for unloading less-used scripts if RAM is 
full, so don't sweat it unless you have crazy number of scripts.



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



RE: [PHP]Keep the modification date of a file when archiving it.

2008-10-23 Thread Boyd, Todd M.
 -Original Message-
 From: Bastien Helders [mailto:[EMAIL PROTECTED]
 Sent: Thursday, October 23, 2008 4:26 AM
 To: php-general@lists.php.net
 Subject: [PHP]Keep the modification date of a file when archiving it.
 
 
 Hi,
 
 When I'm archiving files in a ZIP file, using the class ZipArchive,
the
 modification date is modified to when ZipArchive::close is called. I
 would like to keep the original modification date. Is that even
 possible?

www.php.net/touch

bool touch  ( string $filename  [, int $time  [, int $atime  ]] )

Attempts to set the access and modification times of the file named in
the filename parameter to the value given in time . Note that the access
time is always modified, regardless of the number of parameters.

If the file does not exist, it will be created.

--

So... I would say just call that on your file after you
ZipArchive::close it.

HTH,



Todd Boyd
Web Programmer

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



Re: [PHP] Difficulty navigating symlinks

2008-10-23 Thread Seth Foss

Jim Lucas wrote:

Seth Foss wrote:
  

Jim Lucas wrote:


Seth Foss wrote:
 
  

Hi everyone,

I am trying to run multiple sites on the same server, that have mostly
identical code - a pre-built application.

Anyway, I would like to save  disk space by specifying independent
configuration files for each site, then using symbolic links to access
the rest of the code for the application.

I have managed to configure apache so one such directory is accessed via
a symlink, which is ok. However, a file within the linked directory
attempts to include the configuration file (../config.php) from the
actual parent directory instead of the directory containing the symlink.

Is there any way to configure apache or php to trace back the symlink
when using '..', or can that only go one direction?

Thanks,
Seth




You can set the include path for your code to include the parent
directory
from where the symlink is and then remove the ../ part of the call.

  
  

Jim,

I had considered that, but I plan to have multiple directories following
symlinks to the same place.

For example,

/var/www/site1 has a config.php and a symlink to var/www/universal/app
while
/var/www/site2 has a different config.php and a symlink to
var/www/universal/app

var/www/universal/app has an index.php with include(../config.php) that
needs the config from the site that is using it (i.e., sometimes site1,
sometimes site2)

Does that make sense? Or did I misunderstand your suggestion?

Thanks,
Seth





You might have miss understood me.

In your VHOST entries, make an entry on each domain

VirtualHost X.X.X.X
DocumentRoot /path/to/example.com/public_html
ServerName example.com
php_value include_path '/path/to/example.com/public_html
/VirtualHost


Now you have your app symlinked into the public_html dir as such (guessing here)

ln -s /path/to/my/app /path/to/example.com/public_html/app

Now, in the app directory you have index.php that has include '../config.php';

Your problem is that the ../config.php reference refers to
/path/to/my/app/../config.php == /path/to/my/
instead of
/path/to/example.com/public_html/app/../config.php

Correct???

This is because it is being referenced logically from
/path/to/my/app/index.php

any symbolically from
/path/to/example.com/public_html/app/index.php

If that is the case, add the vHOST entry that I talked about above, then
reference the config file as include 'config.php';  and it will then look in
the include_path location(s) for the files and not think of referencing the
current directory that it is in.

Mind you that you can also enter this information into a .htaccess that is
located in the /path/to/example.com/public_html/ directory.  As long as
.htaccess files are allowed.

I usually have my include_path set to .:/path/to/example.com/public_html/ in
my vhosts entry for each domain.

Hope this helps
  
I did misunderstand. This approach is working for me. Unfortunately, as 
I am implementing it, it seems there are more files than I expected that 
utilize a series of '..'s instead of the absolute path from the config 
file, and more files than I expected that include the config file 
themselves.


However, these would cause me the same headaches with any of the 
proposed solutions.


Long story short, problem is solved. Setting the include path in VHOST 
lets me set it uniquely for each site, and then including config.php 
directly (no ..) uses that include path to grab the appropriate config file.


Thanks to everyone for your help, and especially you, Jim, for your 
elegant solution.


Seth

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



Re: [PHP] class constructor overloading

2008-10-23 Thread Christoph Boget
 is it possible to overload the class construct(or) ?
 if yes, how ?

No, it's not.

 class A
 {
function __construct()
{
echo A;
}
 }

 class B extends A
 {
function __construct()
{
echo B;
parent::__construct();
}
 }
 $B = new B();

The above is an example of overriding, not overloading; PHP allows the
former but not the latter.

Examples of overloading include:

class A
{
  function myFunc( $boolean )
  {

  }

  function myFunc( $string )
  {

  }

  function myFunc( $array )
  {

  }
}

Because PHP is loosely typed, the above is largely moot/unnecessary.

class B
{
  function myFunc( $boolean )
  {

  }

  function myFunc( $boolean, $string )
  {

  }

  function myFunc( $boolean, $string, $array )
  {

  }
}

PHP allows you to get around the above by allowing you to define
default values for arguments.  Doing that is kind of like overloading
but only in a fake-me-out kind of way.  So instead of overloading the
myFunc method, you could just define it as follows:

class B
{
  function myFunc( $boolean = FALSE, $string = '', $array = array())
  {

  }
}

but even that doesn't ensure that the data type of each argument is as
you might expect.  As I stated above, PHP is loosely typed so there is
nothing preventing, say, the $string argument from actually being a
numeric datatype.  If you are using PHP5+, you can sort of get around
that by using type hinting
(http://us.php.net/manual/en/language.oop5.typehinting.php) but you
can only type hint objects and arrays.

In closing, to answer your question,

Overriding: yes
Overloading: no

thnx,
Chris

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



Re: [PHP] export data to a ms excel file using php

2008-10-23 Thread gopi krishnan
Dear all,

I found the solution for my problem.
try this core...

---

?php
#Setting MIME Type in header
/*header(Content-Type:  application/vnd.ms-excel); */
header(Content-Type:  application/vnd.ms-excel);
header(Expires: 0);
/*header(Cache-Control: must-revalidate, post-check=0, pre-check=0); */
header(Cache-Control: must-revalidate);


# Connecting to oracle server
$dbh = oci_connect ('TESTDB', 'TESTDB', '//192.168.3.197/ORCL');

# Querry for fetching the column names
$stmt = oci_parse ($dbh, Select COLUMN_NAME from user_tab_columns where
table_name='EMPLOYEE');

# Execution of above statement
oci_execute ($stmt);
$cnt = 1;

# Fetching column names and printing
while ($result = oci_fetch_array($stmt)) {
echo $result['COLUMN_NAME'] . ,;
$cnt = $cnt +1;
}
# Make a new line to write the record sets in the next line
echo \n;

# Querry for fetching the recors sets
$stmt = oci_parse ($dbh, 'select * from employee');

# Here we execute the statement:
oci_execute ($stmt);
$cnt = 1;
/*echo 'table border=1';*/
# Then we fetch rows in a loop until we're done
while ($result = oci_fetch_array($stmt)) {
/*echo gopi, gopi, gopi, gopi, gopi, gopi, gopi \n;*/
   /*echo Employee id  . $result['EID'] .   . $result['FNAME'] .   .
$result['LNAME'] . $result[SALARY] .br;*/
   echo $result['EID'] . , . $result['FNAME'] . , . $result['LNAME'] .
, . $result[SALARY] .\n;
   $cnt = $cnt +1;
}
/*echo '/table';*/
# last we close the database handle
oci_close($dbh);
?

---



On Thu, Oct 23, 2008 at 5:15 PM, Jay Blanchard [EMAIL PROTECTED]wrote:

 [snip]
 Could any one explain better. I need just the grid lines for the excel
 sheet. I already tried that table border=1 but it shows the linings
 only
 to the valued cells. But i need to show the grid as in MS Excel. I tried
 TEXT/XML
 but i get the following error
 [/snip]

 http://evolt.org/node/26896

 Part of the problem is that an empty table cell has no borders. To
 combat this you can test for a value and if it has none place a
 non-breaking space it (nbsp;)



Re: [PHP] export data to a ms excel file using php

2008-10-23 Thread Yeti
I'm not into MS Office, but isn't there some weird Office XML format
since Office 2007?
At MSDN I could find a nice description of the wannabe standard [1].
So if the new Excel can take XML it wouldn't be too difficult to
export the data I guess.

[1] http://msdn.microsoft.com/en-us/library/aa338205.aspx

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



[PHP] Method of connecting image

2008-10-23 Thread napura
Hi

Is there a method of connecting the jpg image with PHP?
For instance, four images tie by two in two length in side. 


Napura

Linux Debian4 (Server)
PHP 5.2.2
Apache 2.2.4
MySQL

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



Re: [PHP] Method of connecting image

2008-10-23 Thread Aschwin Wesselius
[EMAIL PROTECTED] wrote:
 Hi

 Is there a method of connecting the jpg image with PHP?
 For instance, four images tie by two in two length in side. 


 Napura
 
 Linux Debian4 (Server)
 PHP 5.2.2
 Apache 2.2.4
 MySQL

   
Hi,

I guess you have to use a new clean image pointer (lookup the image
functions of PHP), that has the size of the result size.

Than you can import the four seperate images into four seperate pointers
(or loop over them), and put them inside the clean image.

How to do that is up to you, but it is possible to include one image
into another and decide the position of it. So one or four, doesn't matter.

-- 

Aschwin Wesselius

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


[PHP] Method of connecting image

2008-10-23 Thread napura
Hi

Is there a method of connecting the jpg image with PHP?
For instance, four images tie by two in two length in side. 


Napura

Linux Debian4 (Server)
PHP 5.2.2
Apache 2.2.4
MySQL

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



RE: [PHP] export data to a ms excel file using php

2008-10-23 Thread Boyd, Todd M.
 -Original Message-
 From: Yeti [mailto:[EMAIL PROTECTED]
 Sent: Thursday, October 23, 2008 9:36 AM
 To: gopi krishnan; PHP - General
 Subject: Re: [PHP] export data to a ms excel file using php
 
 I'm not into MS Office, but isn't there some weird Office XML format
 since Office 2007?
 At MSDN I could find a nice description of the wannabe standard [1].
 So if the new Excel can take XML it wouldn't be too difficult to
 export the data I guess.
 
 [1] http://msdn.microsoft.com/en-us/library/aa338205.aspx

Yes, the new extension for these files is *.xlsx . Also with Office 2007
are *.docx, *.pptx, etc. (See a pattern here?) When trying to load
generated *.xls files in Office 2007, I'm greeted with a warning about
Excel not being able to determine the type of the file. It still loads
fine, and all the data and formatting are there... just barks at you
every time you open it (or at least initially).

I believe this is a known bug, but I don't have the time/patience to
track it down in MSDN to link here. :)

But to comment on your second point--yep, Excel 2007 will load XML (and
even an associated XSD for determining formatting, validation, etc.). I
haven't played with it too much, but I have successfully imported XML
documents and used its best guess algorithm to build them into *.xls
workbooks. No major hang-ups.

(BTW, OpenOffice.org v3 has been released. http://www.openoffice.org -
it supports the new Office 2007 formats, and could maybe be leveraged
for conversion, etc.)

HTH,


Todd Boyd
Web Programmer

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



Re: [PHP] what's the difference in the following code?

2008-10-23 Thread Chris Shiflett

On Oct 17, 2008, at 1:58 PM, Lamp Lists wrote:


I'm reading Essential PHP Security by Chris Shiflett.

on the very beginning, page 5  6, if I got it correct, he said this  
is not good:


$search = isset($_GET['search']) ? $_GET['search'] : '';

and this is good:

$search = '';
if (isset($_GET['search']))
{
   $search = $_GET['search'];
}

what's the difference? I really can't see?


I believe I was trying to emphasize how simple, obvious code can be a  
boon to security. I'm sure I could have picked a better example, but  
let me show you a line of code I noticed in a security audit just  
yesterday (only the variable name has been changed to be generic):


$host = strlen($host)  0 ? $host : htmlentities($host);

We have developed tools to help us find things like this, but imagine  
you're manually reviewing a colleague's code, and you're looking  
through a few thousand lines to try to help identify security problems.


In this particular example, my first thought was to suggest specifying  
the character encoding when using htmlentities(), and making sure this  
matches the Content-Type header, to avoid things like this:


http://shiflett.org/blog/2005/dec/google-xss-example

You might also be distracted by the comparison of strlen() to 0, since  
it seems like you could simply rely on a boolean evaluation of  
strlen() instead.


Can you spot the bigger problem?

The order is reversed, so if $host has a non-zero length, it is not  
escaped.


When spending mere seconds per line, on average, reviewing a lot of  
code, this is exactly the sort of thing that's not that hard to miss.  
The real question is whether it would be slightly harder to miss if  
expanded:


if (strlen($host)  0) {
   $host = $host;
} else {
   $host = htmlentities($host);
}

I think it's much less likely to be overlooked when written like this,  
and this is the sort of decision that many developers take for  
granted. If you're too proud to admit that the ternary is less  
obvious, or too proud to admit that you could ever make a mistake like  
this, maybe you can at least convince yourself that not everyone is as  
clever as you, and code that is easier to review is ultimately going  
to be better code.


Hope that helps,

Chris

--
Chris Shiflett
http://shiflett.org/



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



Re: [PHP] Politics

2008-10-23 Thread Robert Cummings
On Thu, 2008-10-23 at 13:59 +0200, Jochem Maas wrote:
 Amy schreef:
  prints mosfet customercontrol universally lastinfirstout unixlike techie 
  perversities agreement
  
 
 going by the last 4 words she must be talking about Cummings ... we all agree 
 his doll fetish is
 rather perverse and he's definitely unixlike

On that note... has anyone seen Lars and the Real Girl? I thought it was
going tobe a comedy after I laughed so hard at the introduction. Then it
was all drama :/

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



Re: [PHP] Difficulty navigating symlinks

2008-10-23 Thread Robert Cummings
On Thu, 2008-10-23 at 09:46 -0400, Seth Foss wrote:
 Jim Lucas wrote:
  Seth Foss wrote:

  Jim Lucas wrote:
  
  Seth Foss wrote:
   

  Hi everyone,
 
  I am trying to run multiple sites on the same server, that have mostly
  identical code - a pre-built application.
 
  Anyway, I would like to save  disk space by specifying independent
  configuration files for each site, then using symbolic links to access
  the rest of the code for the application.
 
  I have managed to configure apache so one such directory is accessed via
  a symlink, which is ok. However, a file within the linked directory
  attempts to include the configuration file (../config.php) from the
  actual parent directory instead of the directory containing the symlink.
 
  Is there any way to configure apache or php to trace back the symlink
  when using '..', or can that only go one direction?
 
  Thanks,
  Seth
 
  
  
  You can set the include path for your code to include the parent
  directory
  from where the symlink is and then remove the ../ part of the call.
 


  Jim,
 
  I had considered that, but I plan to have multiple directories following
  symlinks to the same place.
 
  For example,
 
  /var/www/site1 has a config.php and a symlink to var/www/universal/app
  while
  /var/www/site2 has a different config.php and a symlink to
  var/www/universal/app
 
  var/www/universal/app has an index.php with include(../config.php) that
  needs the config from the site that is using it (i.e., sometimes site1,
  sometimes site2)
 
  Does that make sense? Or did I misunderstand your suggestion?
 
  Thanks,
  Seth
 
 
  
 
  You might have miss understood me.
 
  In your VHOST entries, make an entry on each domain
 
  VirtualHost X.X.X.X
  DocumentRoot /path/to/example.com/public_html
  ServerName example.com
  php_value include_path '/path/to/example.com/public_html
  /VirtualHost
 
 
  Now you have your app symlinked into the public_html dir as such (guessing 
  here)
 
  ln -s /path/to/my/app /path/to/example.com/public_html/app
 
  Now, in the app directory you have index.php that has include 
  '../config.php';
 
  Your problem is that the ../config.php reference refers to
  /path/to/my/app/../config.php == /path/to/my/
  instead of
  /path/to/example.com/public_html/app/../config.php
 
  Correct???
 
  This is because it is being referenced logically from
  /path/to/my/app/index.php
 
  any symbolically from
  /path/to/example.com/public_html/app/index.php
 
  If that is the case, add the vHOST entry that I talked about above, then
  reference the config file as include 'config.php';  and it will then look in
  the include_path location(s) for the files and not think of referencing the
  current directory that it is in.
 
  Mind you that you can also enter this information into a .htaccess that is
  located in the /path/to/example.com/public_html/ directory.  As long as
  .htaccess files are allowed.
 
  I usually have my include_path set to .:/path/to/example.com/public_html/ 
  in
  my vhosts entry for each domain.
 
  Hope this helps

 I did misunderstand. This approach is working for me. Unfortunately, as 
 I am implementing it, it seems there are more files than I expected that 
 utilize a series of '..'s instead of the absolute path from the config 
 file, and more files than I expected that include the config file 
 themselves.
 
 However, these would cause me the same headaches with any of the 
 proposed solutions.
 
 Long story short, problem is solved. Setting the include path in VHOST 
 lets me set it uniquely for each site, and then including config.php 
 directly (no ..) uses that include path to grab the appropriate config file.
 
 Thanks to everyone for your help, and especially you, Jim, for your 
 elegant solution.

You could probably set a value in the vhost that makes the absolute path
to the web root available to your script. Personally, I hate to rely on
anything magical like non-standard include paths :)

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



Re: [PHP] what's the difference in the following code?

2008-10-23 Thread Robert Cummings
On Thu, 2008-10-23 at 11:00 -0400, Chris Shiflett wrote:
 On Oct 17, 2008, at 1:58 PM, Lamp Lists wrote:
 
  I'm reading Essential PHP Security by Chris Shiflett.
 
  on the very beginning, page 5  6, if I got it correct, he said this  
  is not good:
 
  $search = isset($_GET['search']) ? $_GET['search'] : '';
 
  and this is good:
 
  $search = '';
  if (isset($_GET['search']))
  {
 $search = $_GET['search'];
  }
 
  what's the difference? I really can't see?
 
 I believe I was trying to emphasize how simple, obvious code can be a  
 boon to security. I'm sure I could have picked a better example, but  
 let me show you a line of code I noticed in a security audit just  
 yesterday (only the variable name has been changed to be generic):
 
 $host = strlen($host)  0 ? $host : htmlentities($host);
 
 We have developed tools to help us find things like this, but imagine  
 you're manually reviewing a colleague's code, and you're looking  
 through a few thousand lines to try to help identify security problems.
 
 In this particular example, my first thought was to suggest specifying  
 the character encoding when using htmlentities(), and making sure this  
 matches the Content-Type header, to avoid things like this:
 
 http://shiflett.org/blog/2005/dec/google-xss-example
 
 You might also be distracted by the comparison of strlen() to 0, since  
 it seems like you could simply rely on a boolean evaluation of  
 strlen() instead.
 
 Can you spot the bigger problem?
 
 The order is reversed, so if $host has a non-zero length, it is not  
 escaped.

That was the first thing I noticed. What I still don't understand is why
bother with the strlen? An empty string marked up with htmlentities() is
still an empty string. Now the code has two functions invoked when the
string is non-empty rather than one... htmlentities().

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



Re: [PHP] Politics

2008-10-23 Thread Daniel P. Brown
On Thu, Oct 23, 2008 at 11:40 AM, Robert Cummings [EMAIL PROTECTED] wrote:

 On that note... has anyone seen Lars and the Real Girl? I thought it was
 going tobe a comedy after I laughed so hard at the introduction. Then it
 was all drama :/

And I missed it all while I was in the hospital.  Internal
bleeding is overrated.  Some day I'll have to check the archives.

-- 
/Daniel P. Brown
http://www.parasane.net/ [New Look]
[EMAIL PROTECTED] || [EMAIL PROTECTED]

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



Re: [PHP] mysqli, prepare and fetch_row

2008-10-23 Thread Marten Lehmann

Hi,

Kyle Terry wrote:

Why don't you want to bind the results?


thats poor programming style and bad performance (dozends of bind 
calls). Since there is a method fetch_row(), then why shouldn't I use 
it? It is a bit strange that I cannot find any example for its use 
besides in conjunction with silly -query(), which doesn't allow to bind 
parameters with ?.


Regards
Marten

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



Re: [PHP] CSV Files

2008-10-23 Thread Andrew Ballard
On Thu, Oct 23, 2008 at 2:54 AM, Ashley Sheridan
[EMAIL PROTECTED] wrote:
 On Thu, 2008-10-23 at 02:26 -0400, Andrew Ballard wrote:
 On Thu, Oct 23, 2008 at 2:22 AM, Ashley Sheridan
 [EMAIL PROTECTED] wrote:
  On Wed, 2008-10-22 at 22:30 -0400, Andrew Ballard wrote:
  On Wed, Oct 22, 2008 at 10:15 PM, Jason Todd Slack-Moehrle
  [EMAIL PROTECTED] wrote:
   On Oct 22, 2008, at 6:58 PM, Stut wrote:
  
   On 23 Oct 2008, at 02:41, Jason Todd Slack-Moehrle wrote:
  
   Actually i am ending the row headers with a chr(10); // LINE FEED
  
   From the code you included in your original post...
  
   echo /n;
  
  
   There was no mention of chr(10).
  
   Outputting data in CSV format is not hard. Simply echo the header row 
   if necessary, followed by \n. Then output each line taking care to 
   put string values in quotes which means you also need to escape quotes 
   in the data. After each line echo \n. That's really all there is to 
   it.
  
   If you're still having problems I suggest you post the exact code 
   you're using, anything else just makes it harder for us to provide 
   effective help.
  
   -Stut
  
   On Oct 22, 2008, at 5:12 PM, Stut wrote:
  
   On 23 Oct 2008, at 00:59, Jason Todd Slack-Moehrle wrote:
  
   After I right out the column headers do I have to put a '/n' to 
   have it start a new line in the CSV file? I think I do.
  
   A new line is \n not /n, and it must be in double quotes () not 
   single (').
  
  
   Oh, I am not putting quotes around each field that i get from MySQL. 
   There are no quotes in the data so that is good.
  
   Sorry I put /n and I meant to put chr(10).
  
   -Jason
  
 
  Jason, one of the points that Stut was trying to explain is that \n
  and chr(10) are the same thing. They are just two different ways to
  refer to a newline (line feed) character. Most of us probably use \n
  rather than chr(10) in PHP, though. So, the following two lines are
  equivalent:
 
  ?php
  echo Item1, Item2, Item3 . chr(10);
 
  // Note this uses double quotes.
  echo Item1, Item2, Item3\n;
 
  // It won't be the same at all if you use single quotes
  echo 'Item1, Item2, Item3\n';
 
  ?
 
  At any rate, you are correct that you need a line feed/newline
  character at the end of every row in CSV including the header row.
 
  Andrew
 
  A line feed and \n are not the same thing at all. Different operating
  systems implemented a different method of line endings depending on what
  they thought best, either a carriage return or line feed or both. a \n
  is meant to be an OS agnostic way of implementing this in the various
  programming languages, outputting something that any OS can understand
  in the intended way.
 
 
  Ash
  www.ashleysheridan.co.uk

 As I understood, \n was strictly a line feed (ASCII character 10), not
 an OS agnostic end-of-line terminator. It happens to be the line
 terminator for *nix. Windows uses the combined carriage return and
 line feed characters (ASCII characters 13 and 10) which are
 represented by \r\n in PHP, while Mac used only the the carriage
 return.  There is a PHP constant PHP_EOL that I'm pretty sure is
 supposed to represent the line terminator defined on the operating
 system of the computer executing the script, but I don't think it is
 truly agnostic either. At least, if you have a text file saved in
 Windows and split it on a Linux machine based on PHP_EOL, I believe
 all of your array values will have a carriage return character hanging
 on the end of them. Am I mistaken?

 Andrew
 I'm afraid I do disagree with your there:

 When writing a file in text mode, '\n' is transparently translated to
 the native newline sequence used by the system

 This is from the Wikipedia article I found:
 http://en.wikipedia.org/wiki/Newline



 Ash
 www.ashleysheridan.co.uk



Interesting. I didn't know it behaved differently when writing files.
I just know that when using it as a search pattern or for splitting
text that it is only the newline character. I thought the behavior you
are describing was specifically why PHP added PHP_EOL. Further down
the same article it says:

Some languages have created special variables, constants and
subroutines to facilitate newlines during program execution. One
example is the PHP constant PHP_EOL, which will produce either '\r\n'
or '\n' appropriate to the operating system the program is executed
on.[3] Though special newline handling facilities can aid execution
during runtime, they do not ensure the validity of newlines for the
source code itself.

I guess since PHP is written in C it picks up the behavior you
describe from the underlying libraries. That's definitely interesting
to keep in mind.

Andrew

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



Re: [PHP] Difficulty navigating symlinks

2008-10-23 Thread Jim Lucas
Robert Cummings wrote:
 On Thu, 2008-10-23 at 09:46 -0400, Seth Foss wrote:
 Jim Lucas wrote:
 Seth Foss wrote:
   
 Jim Lucas wrote:
 
 Seth Foss wrote:
  
   
 Hi everyone,

 I am trying to run multiple sites on the same server, that have mostly
 identical code - a pre-built application.

 Anyway, I would like to save  disk space by specifying independent
 configuration files for each site, then using symbolic links to access
 the rest of the code for the application.

 I have managed to configure apache so one such directory is accessed via
 a symlink, which is ok. However, a file within the linked directory
 attempts to include the configuration file (../config.php) from the
 actual parent directory instead of the directory containing the symlink.

 Is there any way to configure apache or php to trace back the symlink
 when using '..', or can that only go one direction?

 Thanks,
 Seth

 
 
 You can set the include path for your code to include the parent
 directory
 from where the symlink is and then remove the ../ part of the call.

   
   
 Jim,

 I had considered that, but I plan to have multiple directories following
 symlinks to the same place.

 For example,

 /var/www/site1 has a config.php and a symlink to var/www/universal/app
 while
 /var/www/site2 has a different config.php and a symlink to
 var/www/universal/app

 var/www/universal/app has an index.php with include(../config.php) that
 needs the config from the site that is using it (i.e., sometimes site1,
 sometimes site2)

 Does that make sense? Or did I misunderstand your suggestion?

 Thanks,
 Seth


 
 You might have miss understood me.

 In your VHOST entries, make an entry on each domain

 VirtualHost X.X.X.X
 DocumentRoot /path/to/example.com/public_html
 ServerName example.com
 php_value include_path '/path/to/example.com/public_html
 /VirtualHost


 Now you have your app symlinked into the public_html dir as such (guessing 
 here)

 ln -s /path/to/my/app /path/to/example.com/public_html/app

 Now, in the app directory you have index.php that has include 
 '../config.php';

 Your problem is that the ../config.php reference refers to
 /path/to/my/app/../config.php == /path/to/my/
 instead of
 /path/to/example.com/public_html/app/../config.php

 Correct???

 This is because it is being referenced logically from
 /path/to/my/app/index.php

 any symbolically from
 /path/to/example.com/public_html/app/index.php

 If that is the case, add the vHOST entry that I talked about above, then
 reference the config file as include 'config.php';  and it will then look in
 the include_path location(s) for the files and not think of referencing the
 current directory that it is in.

 Mind you that you can also enter this information into a .htaccess that is
 located in the /path/to/example.com/public_html/ directory.  As long as
 .htaccess files are allowed.

 I usually have my include_path set to .:/path/to/example.com/public_html/ 
 in
 my vhosts entry for each domain.

 Hope this helps
   
 I did misunderstand. This approach is working for me. Unfortunately, as 
 I am implementing it, it seems there are more files than I expected that 
 utilize a series of '..'s instead of the absolute path from the config 
 file, and more files than I expected that include the config file 
 themselves.

 However, these would cause me the same headaches with any of the 
 proposed solutions.

 Long story short, problem is solved. Setting the include path in VHOST 
 lets me set it uniquely for each site, and then including config.php 
 directly (no ..) uses that include path to grab the appropriate config file.

 Thanks to everyone for your help, and especially you, Jim, for your 
 elegant solution.
 
 You could probably set a value in the vhost that makes the absolute path
 to the web root available to your script. Personally, I hate to rely on
 anything magical like non-standard include paths :)
 
 Cheers,
 Rob.

You are probably right.

I was thinking, why could the app know its home and then also use just
DOCUMENT_ROOT?

I can't imagine a time that DOCUMENT_ROOT would not be correct, even from a
symlinked directory.

/app/index.php
?php

define('ROOT', $_SERVER['DOCUMENT_ROOT']);

include ROOT . 'config.php';

...

?

You could also then use this ROOT constant else where in your code when you
need to refer to the website root path, instead of the app path

-- 
Jim Lucas

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

Twelfth Night, Act II, Scene V
by William Shakespeare


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



[PHP] Re: Politics

2008-10-23 Thread Colin Guthrie

Daniel P. Brown wrote:

On Thu, Oct 23, 2008 at 11:40 AM, Robert Cummings [EMAIL PROTECTED] wrote:

On that note... has anyone seen Lars and the Real Girl? I thought it was
going tobe a comedy after I laughed so hard at the introduction. Then it
was all drama :/


And I missed it all while I was in the hospital.  Internal
bleeding is overrated.  Some day I'll have to check the archives.


Ohh dear, doesn't sound like fun :s Hope you're on the mend now.

Col

--

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mandriva Linux Contributor [http://www.mandriva.com/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]


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



Re: [PHP] Difficulty navigating symlinks

2008-10-23 Thread Seth Foss

Jim Lucas wrote:

Robert Cummings wrote:
  

On Thu, 2008-10-23 at 09:46 -0400, Seth Foss wrote:


Jim Lucas wrote:
  

Seth Foss wrote:
  


Jim Lucas wrote:

  

Seth Foss wrote:
 
  


Hi everyone,

I am trying to run multiple sites on the same server, that have mostly
identical code - a pre-built application.

Anyway, I would like to save  disk space by specifying independent
configuration files for each site, then using symbolic links to access
the rest of the code for the application.

I have managed to configure apache so one such directory is accessed via
a symlink, which is ok. However, a file within the linked directory
attempts to include the configuration file (../config.php) from the
actual parent directory instead of the directory containing the symlink.

Is there any way to configure apache or php to trace back the symlink
when using '..', or can that only go one direction?

Thanks,
Seth



  

You can set the include path for your code to include the parent
directory
from where the symlink is and then remove the ../ part of the call.

  
  


Jim,

I had considered that, but I plan to have multiple directories following
symlinks to the same place.

For example,

/var/www/site1 has a config.php and a symlink to var/www/universal/app
while
/var/www/site2 has a different config.php and a symlink to
var/www/universal/app

var/www/universal/app has an index.php with include(../config.php) that
needs the config from the site that is using it (i.e., sometimes site1,
sometimes site2)

Does that make sense? Or did I misunderstand your suggestion?

Thanks,
Seth



  

You might have miss understood me.

In your VHOST entries, make an entry on each domain

VirtualHost X.X.X.X
DocumentRoot /path/to/example.com/public_html
ServerName example.com
php_value include_path '/path/to/example.com/public_html
/VirtualHost


Now you have your app symlinked into the public_html dir as such (guessing here)

ln -s /path/to/my/app /path/to/example.com/public_html/app

Now, in the app directory you have index.php that has include '../config.php';

Your problem is that the ../config.php reference refers to
/path/to/my/app/../config.php == /path/to/my/
instead of
/path/to/example.com/public_html/app/../config.php

Correct???

This is because it is being referenced logically from
/path/to/my/app/index.php

any symbolically from
/path/to/example.com/public_html/app/index.php

If that is the case, add the vHOST entry that I talked about above, then
reference the config file as include 'config.php';  and it will then look in
the include_path location(s) for the files and not think of referencing the
current directory that it is in.

Mind you that you can also enter this information into a .htaccess that is
located in the /path/to/example.com/public_html/ directory.  As long as
.htaccess files are allowed.

I usually have my include_path set to .:/path/to/example.com/public_html/ in
my vhosts entry for each domain.

Hope this helps
  

I did misunderstand. This approach is working for me. Unfortunately, as 
I am implementing it, it seems there are more files than I expected that 
utilize a series of '..'s instead of the absolute path from the config 
file, and more files than I expected that include the config file 
themselves.


However, these would cause me the same headaches with any of the 
proposed solutions.


Long story short, problem is solved. Setting the include path in VHOST 
lets me set it uniquely for each site, and then including config.php 
directly (no ..) uses that include path to grab the appropriate config file.


Thanks to everyone for your help, and especially you, Jim, for your 
elegant solution.
  

You could probably set a value in the vhost that makes the absolute path
to the web root available to your script. Personally, I hate to rely on
anything magical like non-standard include paths :)

Cheers,
Rob.



You are probably right.

I was thinking, why could the app know its home and then also use just
DOCUMENT_ROOT?

I can't imagine a time that DOCUMENT_ROOT would not be correct, even from a
symlinked directory.

/app/index.php
?php

define('ROOT', $_SERVER['DOCUMENT_ROOT']);

include ROOT . 'config.php';

...

?

You could also then use this ROOT constant else where in your code when you
need to refer to the website root path, instead of the app path

  
I am ashamed to say that so much have my php coding experience has been 
the modification of third-party apps that I never even knew the $_SERVER 
variable existed. Even if I had, I probably would have assumed that it 
would have given me the app path instead of the website path.


Tried it using Stut's snippet, and it works (not that they should be 
related, but just figured I'd mention that it works whether i added the 
include path to my VHOST or not).


Two great solutions! I 

Re: [PHP] Re: Politics

2008-10-23 Thread Daniel P. Brown
On Thu, Oct 23, 2008 at 1:12 PM, Colin Guthrie [EMAIL PROTECTED] wrote:

 Ohh dear, doesn't sound like fun :s Hope you're on the mend now.

Yessir, and thanks.  When I was incommunicado for a bit back in
August, that's the reason.  You and many others here and elsewhere on
the web know me better than to shut the hell up for a while otherwise.

  Mandriva Linux Contributor [http://www.mandriva.com/]

Hooray for Cooker!

-- 
/Daniel P. Brown
http://www.parasane.net/ [New Look]
[EMAIL PROTECTED] || [EMAIL PROTECTED]

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



Re: [PHP] what's the difference in the following code?

2008-10-23 Thread tedd

At 11:00 AM -0400 10/23/08, Chris Shiflett wrote:

On Oct 17, 2008, at 1:58 PM, Lamp Lists wrote:


I'm reading Essential PHP Security by Chris Shiflett.

on the very beginning, page 5  6, if I got it correct, he said 
this is not good:


$search = isset($_GET['search']) ? $_GET['search'] : '';

and this is good:

$search = '';
if (isset($_GET['search']))
{
   $search = $_GET['search'];
}

what's the difference? I really can't see?


I believe I was trying to emphasize how simple, obvious code can be 
a boon to security.


That's the way I read what you wrote and your example was fine with me.

The problem here is that the OP simply misunderstood what you were 
trying to convey. Because of a language problem, he did not realize 
that you were simply showing how a tainted variable could stand-out 
in one set of code while being obscured in another. Instead, he 
thought you were saying that one method was secure and the other 
wasn't and wanted to have someone explain the difference.


I did my best to convey what I thought you were saying, but all 
clarifications lead to more confusion.


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



Re: [PHP] what's the difference in the following code?

2008-10-23 Thread Jochem Maas
Chris Shiflett schreef:
 On Oct 17, 2008, at 1:58 PM, Lamp Lists wrote:
 
 I'm reading Essential PHP Security by Chris Shiflett.

 on the very beginning, page 5  6, if I got it correct, he said this
 is not good:

 $search = isset($_GET['search']) ? $_GET['search'] : '';

 and this is good:

 $search = '';
 if (isset($_GET['search']))
 {
$search = $_GET['search'];
 }

 what's the difference? I really can't see?
 
 I believe I was trying to emphasize how simple, obvious code can be a
 boon to security. I'm sure I could have picked a better example, but let
 me show you a line of code I noticed in a security audit just yesterday
 (only the variable name has been changed to be generic):
 
 $host = strlen($host)  0 ? $host : htmlentities($host);
 
 We have developed tools to help us find things like this, but imagine
 you're manually reviewing a colleague's code, and you're looking through
 a few thousand lines to try to help identify security problems.
 
 In this particular example, my first thought was to suggest specifying
 the character encoding when using htmlentities(), and making sure this
 matches the Content-Type header, to avoid things like this:
 
 http://shiflett.org/blog/2005/dec/google-xss-example
 
 You might also be distracted by the comparison of strlen() to 0, since
 it seems like you could simply rely on a boolean evaluation of strlen()
 instead.
 
 Can you spot the bigger problem?
 
 The order is reversed, so if $host has a non-zero length, it is not
 escaped.

first thing that I noticed, second wondering why no charset was specified,
thirdly was wondering why it's not plain:

$host = htmlentities($host);

but nonetheless your point stands, :-)

now about that charset ... your blog post uses UTF-7 to demonstrate the
potential for problems ... but htmlentities() doesn't support that charset,
or at least not according to the docs, in fact the list of supported charsets
is quite limited, out of curiosity what would your recommendation be
if one is faced with a having 'htmlentize' a string encoded in UTF-7 or
some other charset not supported by htmlentities() ?

a second question: strip_tags() doesn't have a charset parameter, how does
it manage to cope without knowing the input string encoding? or does it
not and is it actually vulnerable to maliciously encoded input?


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



Re: [PHP] what's the difference in the following code?

2008-10-23 Thread Thomas Wicht

On Oct 17, 2008, at 1:58 PM, Lamp Lists wrote:


I'm reading Essential PHP Security by Chris Shiflett.

on the very beginning, page 5  6, if I got it correct, he said this  is 
not good:


$search = isset($_GET['search']) ? $_GET['search'] : '';

and this is good:

$search = '';
if (isset($_GET['search']))
{
   $search = $_GET['search'];
}

what's the difference? I really can't see?




The difference between the examples are still nothing, it do the same.

But I never use the short version of if, because when I look after some 
month in some projects I have a better overview when there is a long if , 
its much easier to extend.


sorry for my bad english

greetz
Thomas


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



Re: [PHP] export data to a ms excel file using php

2008-10-23 Thread Jim Lucas
gopi krishnan wrote:
 Dear all,
 
 I found the solution for my problem.
 try this core...
 
 ---
 
 ?php
 #Setting MIME Type in header
 /*header(Content-Type:  application/vnd.ms-excel); */
 header(Content-Type:  application/vnd.ms-excel);
 header(Expires: 0);
 /*header(Cache-Control: must-revalidate, post-check=0, pre-check=0); */
 header(Cache-Control: must-revalidate);
 
 
 # Connecting to oracle server
 $dbh = oci_connect ('TESTDB', 'TESTDB', '//192.168.3.197/ORCL');
 
 # Querry for fetching the column names
 $stmt = oci_parse ($dbh, Select COLUMN_NAME from user_tab_columns where
 table_name='EMPLOYEE');
 
 # Execution of above statement
 oci_execute ($stmt);
 $cnt = 1;
 
 # Fetching column names and printing
 while ($result = oci_fetch_array($stmt)) {
 echo $result['COLUMN_NAME'] . ,;
 $cnt = $cnt +1;
 }
 # Make a new line to write the record sets in the next line
 echo \n;
 
 # Querry for fetching the recors sets
 $stmt = oci_parse ($dbh, 'select * from employee');
 
 # Here we execute the statement:
 oci_execute ($stmt);
 $cnt = 1;
 /*echo 'table border=1';*/
 # Then we fetch rows in a loop until we're done
 while ($result = oci_fetch_array($stmt)) {
 /*echo gopi, gopi, gopi, gopi, gopi, gopi, gopi \n;*/
/*echo Employee id  . $result['EID'] .   . $result['FNAME'] .   .
 $result['LNAME'] . $result[SALARY] .br;*/
echo $result['EID'] . , . $result['FNAME'] . , . $result['LNAME'] .
 , . $result[SALARY] .\n;
$cnt = $cnt +1;
 }
 /*echo '/table';*/
 # last we close the database handle
 oci_close($dbh);
 ?
 
 ---
 

This would be correct.  But, just to point out, you have a column count
mismatch.  You have 4 data fields that you are populating with 3 commas
separating them.  Yet in the column headers, you are outputting (i assume) 4
column headers with an extra comma at the end.  I'm not sure what difference
it would make your case.

-- 
Jim Lucas

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

Twelfth Night, Act II, Scene V
by William Shakespeare


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



[PHP] Politics

2008-10-23 Thread Amy

mouso prefixes egging gestures loozr selected incomprehensibly assumed sexism

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



Re: [PHP] export data to a ms excel file using php

2008-10-23 Thread Ashley Sheridan
On Thu, 2008-10-23 at 13:05 +0530, gopi krishnan wrote:
 Hi,
 
 Could any one explain better. I need just the grid lines for the excel
 sheet. I already tried that table border=1 but it shows the linings only
 to the valued cells. But i need to show the grid as in MS Excel. I tried
 TEXT/XML
 but i get the following error
 
 ---
 
 The XML page cannot be displayed
 
 Cannot view XML input using XSL style sheet. Please correct the error and
 then click the Refresh javascript:location.reload() button, or try again
 later.
 --
 
 A string literal was expected, but no opening quote character was found.
 Error processing resource 'http://localhost/dbtoxl...
 
 table border=1tr td width=10025 /tdtd width=100 jana
 /tdtd  width=100...
 
 
 ---
 
 thanks in advance
 
 
 On Thu, Oct 23, 2008 at 3:21 AM, Nitsan Bin-Nun [EMAIL PROTECTED] wrote:
 
  And what about users who use office version  2003 (which do NOT support
  .xml charts)
  You can google a bit, I'm pretty sure I have already encountered a class
  for this case at Manuel's site (phpclasses).
 
  Nitsan
 
  On Wed, Oct 22, 2008 at 9:00 PM, Ashley Sheridan [EMAIL PROTECTED]
   wrote:
 
  On Wed, 2008-10-22 at 11:20 -0700, Jim Lucas wrote:
   [EMAIL PROTECTED] wrote:
Hi,
   
I have tried your MS-Excel MIME type in PHP. But am facing a small
  problem. I can't get the grid lines as look like in normal Excel file.
   
Am using windows XP, Internet explorer 6.0, MS Excel 2003
   
Thanks in advance.-- Jim Lucas wrote :
abderrazzak nejeoui wrote:
can you help me to export data to a ms excel file using php. i tried
  to
export them to an html format and change the extension to .xls that's
  work
but i have lost the formatting
   
excel and the navigator doesn't interpret my code in the same why
  (celles
are not in the same size)
   
   
Ok, so with the examples of others here, here is the shortest example
  that I came up with that
should get you going.
   
?php
   
header(Content-Type:  application/vnd.ms-excel);
header(Expires: 0);
header(Cache-Control: must-revalidate, post-check=0, pre-check=0);
   
$x = $y = range(0, 12);
   
echo 'table';
   
echo 'trtd /tdtd' . join('/tdtd', $x) . '/td/tr';
   
foreach ( $x AS $xx ) {
echo trtd{$xx}/td;
foreach ( $y AS $yy ) {
echo
  td=sum(.(chr(ord('b')+$yy)).1*a.($xx+2).)/td;
}
echo /tr;
}
echo '/table';
   
?
   
This will output a 14x14 table.  It will calculate the totals for each
  cell in the actual
spreadsheet once excel loads it.
   
If you have any questions, ask away.
   
  
   You could change this line
  
   echo 'table';
  
   to this
  
   echo 'table border=1';
  
   This will give you borders around your content at least.
  
   Example:
  
  http://www.cmsws.com/examples/php/testscripts/[EMAIL PROTECTED]/0001.php
  
   I would checkout phpexcel also
  
   --
   Jim Lucas
  
  Some men are born to greatness, some achieve greatness,
  and some have greatness thrust upon them.
  
   Twelfth Night, Act II, Scene V
   by William Shakespeare
  
  
  I think you really need to save the file as an XML file, with the
  text/xml mime-type. Then, save an Excel file in the M$ Office 2003 XML
  file-type (not the 2007 xlsx!) and look at the code it produces and try
  to mimic that output as closely as possible. All you're doing is
  creating an HTML table and hoping Excel knows what to do with it, which
  is a bit like creating an image, sending it to the browser with a PDF
  mime and hoping it will open up in Adobe Reader; just not gonna work
  that way!
 
  Your best bet by far though, is to use a pre-built Excel export class.
  Take a look at PEAR of PHPLib, as these both have classes that do what
  you need.
 
 
  Ash
  www.ashleysheridan.co.uk
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
the problem here is that you don't seem to understand the difference
between xml, html and the binary excel format. Pick one, find out how it
works and go with it. You seem to think that if you send down html to a
browser, but give it a mime-type of application/excel it will suddenly
become an excel document. not gonna happen, ever, period.

my suggestion about using the text/xml header will only work _if you
write the file as xml_ which you aren't. try using a class, or pay
someone to do it if you can't.


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] Method of connecting image

2008-10-23 Thread Ashley Sheridan
On Thu, 2008-10-23 at 23:44 +0900, [EMAIL PROTECTED] wrote:
 Hi
 
 Is there a method of connecting the jpg image with PHP?
 For instance, four images tie by two in two length in side. 
 
 
 Napura
 
 Linux Debian4 (Server)
 PHP 5.2.2
 Apache 2.2.4
 MySQL
 
Sorry, what is the question again? I'm afraid I don't understand what it
is you're looking for.


Ash
www.ashleysheridan.co.uk


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



[PHP] Re: Politics

2008-10-23 Thread Colin Guthrie

Daniel P. Brown wrote:

 Mandriva Linux Contributor [http://www.mandriva.com/]


Hooray for Cooker!


:D

--

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mandriva Linux Contributor [http://www.mandriva.com/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]


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



RE: [PHP] web shot script

2008-10-23 Thread Joey
Hi Guys,

Really I want to do this, not pay someone to do it via those services you
linked to.
So nobody has seen open source code for this?


 -Original Message-
 From: Joey [mailto:[EMAIL PROTECTED]
 Sent: Saturday, October 18, 2008 4:59 AM
 To: PHP
 Subject: [PHP] web shot script
 
 Hello All,
 
 
 Does anyone know of a script to capture web pages and store the image?
 
 Trying to see all of my sites screenshots and have it updated on occasion.
 
 
 
 Thanks!
 
 
 
 Joey



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



[PHP] index search

2008-10-23 Thread Ryan S
Hey all,
Was wondering how this is done, have a bunch of links like so:
0-9 : a : b : c - till Z

these will be linked to the program (so far have done this) but when the user 
clicks any of those links I want to query the DB for just the first alphabet 
from the field title, using LIKE is not working for me because its catching 
alphabets from the middle of the word as well.

Also how to do 0-9? do i have to have 10 if() conditions for that?

Ideas and suggestions welcome.

Thanks!
Ryan

 --
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)



  

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



Re: [PHP] web shot script

2008-10-23 Thread Andrew Barnett
Hey Joey,
I had a search, and from what I found, it would be very difficult unless you
have root access to a server. Another way would be to create a HTML/CSS
renderer using PHP, and then using that to take a screenshot.

A link from DigitalPoint 
http://forums.digitalpoint.com/showthread.php?t=76454 may provide some
clues, or discouragement as I found.

Let us know if you work out how to do it. I'd love to know.


Andrew

2008/10/24 Joey [EMAIL PROTECTED]

 Hi Guys,

 Really I want to do this, not pay someone to do it via those services you
 linked to.
 So nobody has seen open source code for this?


  -Original Message-
  From: Joey [mailto:[EMAIL PROTECTED]
  Sent: Saturday, October 18, 2008 4:59 AM
  To: PHP
  Subject: [PHP] web shot script
 
  Hello All,
 
 
  Does anyone know of a script to capture web pages and store the image?
 
  Trying to see all of my sites screenshots and have it updated on
 occasion.
 
 
 
  Thanks!
 
 
 
  Joey



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




Re: [PHP] web shot script

2008-10-23 Thread Afan Pasalic


Andrew Barnett wrote:

Hey Joey,
I had a search, and from what I found, it would be very difficult unless you
have root access to a server. Another way would be to create a HTML/CSS
renderer using PHP, and then using that to take a screenshot.

  

or, maybe, as an idea, save the page as pdf?



A link from DigitalPoint 
http://forums.digitalpoint.com/showthread.php?t=76454 may provide some
clues, or discouragement as I found.

Let us know if you work out how to do it. I'd love to know.


Andrew

2008/10/24 Joey [EMAIL PROTECTED]

  

Hi Guys,

Really I want to do this, not pay someone to do it via those services you
linked to.
So nobody has seen open source code for this?




-Original Message-
From: Joey [mailto:[EMAIL PROTECTED]
Sent: Saturday, October 18, 2008 4:59 AM
To: PHP
Subject: [PHP] web shot script

Hello All,


Does anyone know of a script to capture web pages and store the image?

Trying to see all of my sites screenshots and have it updated on
  

occasion.



Thanks!



Joey
  


--
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] index search

2008-10-23 Thread Robert Cummings
On Thu, 2008-10-23 at 19:30 -0700, Ryan S wrote:
 Hey all,
 Was wondering how this is done, have a bunch of links like so:
 0-9 : a : b : c - till Z
 
 these will be linked to the program (so far have done this) but when the user 
 clicks any of those links I want to query the DB for just the first alphabet 
 from the field title, using LIKE is not working for me because its catching 
 alphabets from the middle of the word as well.

You're using like wrong... you want to use it with one %...

where foo like 'a%'

 Also how to do 0-9? do i have to have 10 if() conditions for that?

Maybe you could add a new field to the table and set it to the first
character of the field or 0 if it's a digit. Then you can index it and
not use like or multiple conditions to match digits.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



Re: [PHP] Method of connecting image

2008-10-23 Thread Bastien Koert
On Thu, Oct 23, 2008 at 7:11 PM, Ashley Sheridan
[EMAIL PROTECTED]wrote:

 On Thu, 2008-10-23 at 23:44 +0900, [EMAIL PROTECTED] wrote:
  Hi
 
  Is there a method of connecting the jpg image with PHP?
  For instance, four images tie by two in two length in side.
 
 
  Napura
  
  Linux Debian4 (Server)
  PHP 5.2.2
  Apache 2.2.4
  MySQL
 
 Sorry, what is the question again? I'm afraid I don't understand what it
 is you're looking for.


 Ash
 www.ashleysheridan.co.uk


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

  Google 'php image stitcher' and go thru the results. There are lots of
entries, some good some bad...


-- 

Bastien

Cat, the other other white meat


Re: [PHP] web shot script

2008-10-23 Thread Andrew Barnett
Are you suggesting to create a PDF, and then convert from PDF to an image?

Andrew



2008/10/24 Afan Pasalic [EMAIL PROTECTED]


 Andrew Barnett wrote:

 Hey Joey,
 I had a search, and from what I found, it would be very difficult unless
 you
 have root access to a server. Another way would be to create a HTML/CSS
 renderer using PHP, and then using that to take a screenshot.



 or, maybe, as an idea, save the page as pdf?


  A link from DigitalPoint 
 http://forums.digitalpoint.com/showthread.php?t=76454 may provide some
 clues, or discouragement as I found.

 Let us know if you work out how to do it. I'd love to know.


 Andrew

 2008/10/24 Joey [EMAIL PROTECTED]



 Hi Guys,

 Really I want to do this, not pay someone to do it via those services you
 linked to.
 So nobody has seen open source code for this?




 -Original Message-
 From: Joey [mailto:[EMAIL PROTECTED]
 Sent: Saturday, October 18, 2008 4:59 AM
 To: PHP
 Subject: [PHP] web shot script

 Hello All,


 Does anyone know of a script to capture web pages and store the image?

 Trying to see all of my sites screenshots and have it updated on


 occasion.



 Thanks!



 Joey



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










Re: [PHP] Politics

2008-10-23 Thread Bastien Koert
On Thu, Oct 23, 2008 at 6:05 PM, Amy [EMAIL PROTECTED] wrote:


 mouso prefixes egging gestures loozr selected incomprehensibly assumed
 sexism

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


Time to remove her from the list.

-- 

Bastien

Cat, the other other white meat


Re: [PHP] web shot script

2008-10-23 Thread Afan Pasalic


Andrew Barnett wrote:

Are you suggesting to create a PDF, and then convert from PDF to an image?

I'm sorry. didn't get it has to be an image.




Andrew



2008/10/24 Afan Pasalic [EMAIL PROTECTED] mailto:[EMAIL PROTECTED]


Andrew Barnett wrote:

Hey Joey,
I had a search, and from what I found, it would be very
difficult unless you
have root access to a server. Another way would be to create a
HTML/CSS
renderer using PHP, and then using that to take a screenshot.

 


or, maybe, as an idea, save the page as pdf?


A link from DigitalPoint 
http://forums.digitalpoint.com/showthread.php?t=76454 may
provide some
clues, or discouragement as I found.

Let us know if you work out how to do it. I'd love to know.


Andrew

2008/10/24 Joey [EMAIL PROTECTED] mailto:[EMAIL PROTECTED]

 


Hi Guys,

Really I want to do this, not pay someone to do it via
those services you
linked to.
So nobody has seen open source code for this?


   


-Original Message-
From: Joey [mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED]]
Sent: Saturday, October 18, 2008 4:59 AM
To: PHP
Subject: [PHP] web shot script

Hello All,


Does anyone know of a script to capture web pages and
store the image?

Trying to see all of my sites screenshots and have it
updated on
 


occasion.
   



Thanks!



Joey
 



--
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] web shot script

2008-10-23 Thread Andrew Barnett
You might actually be onto something there Afan.

As long as Ghostscript and Imagemagick are installed on the server, you will
be able to convert a PDF to an image. So maybe that will help.

Although, is it possible to have a continuous length PDF, or does it only
fit to specific page sizes.

Its probably worth a shot though Joey.


Andrew



2008/10/24 Afan Pasalic [EMAIL PROTECTED]


 Andrew Barnett wrote:

 Are you suggesting to create a PDF, and then convert from PDF to an image?

 I'm sorry. didn't get it has to be an image.



 Andrew



 2008/10/24 Afan Pasalic [EMAIL PROTECTED] mailto:[EMAIL PROTECTED]


Andrew Barnett wrote:

Hey Joey,
I had a search, and from what I found, it would be very
difficult unless you
have root access to a server. Another way would be to create a
HTML/CSS
renderer using PHP, and then using that to take a screenshot.


or, maybe, as an idea, save the page as pdf?


A link from DigitalPoint 
http://forums.digitalpoint.com/showthread.php?t=76454 may
provide some
clues, or discouragement as I found.

Let us know if you work out how to do it. I'd love to know.


Andrew

2008/10/24 Joey [EMAIL PROTECTED] mailto:[EMAIL PROTECTED]


Hi Guys,

Really I want to do this, not pay someone to do it via
those services you
linked to.
So nobody has seen open source code for this?



-Original Message-
From: Joey [mailto:[EMAIL PROTECTED] mailto:[EMAIL 
 PROTECTED]]
Sent: Saturday, October 18, 2008 4:59 AM
To: PHP
Subject: [PHP] web shot script

Hello All,


Does anyone know of a script to capture web pages and
store the image?

Trying to see all of my sites screenshots and have it
updated on

occasion.


Thanks!



Joey


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









RE: [PHP] web shot script

2008-10-23 Thread Paul Scott

On Thu, 2008-10-23 at 22:20 -0400, Joey wrote:

 Really I want to do this, not pay someone to do it via those services you
 linked to.
 So nobody has seen open source code for this?

I run a free (freedom and beer) webservice to do this via the Chisimba
framework (http://avoir.uwc.ac.za) The docs and files are all in svn so
if you would like em, get em! The screenshot code is in python though.

--Paul

All Email originating from UWC is covered by disclaimer 
http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm 

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

[PHP] PHP/mySQL question using ORDER BY with logic

2008-10-23 Thread Rob Gould

Question about mySQL and PHP, when using the mySQL ORDER BY method...


	Basically I've got data coming from the database where a wine  
producer-name is a word like:


Château Bahans Haut-Brion

or

La Chapelle de La Mission Haut-Brion

or

Le Clarence de Haut-Brion

but I need to ORDER BY using a varient of the string:

	1)  If it begins with Château, don't include Chateau in the  
string to order by.
	2)  If it begins with La, don't order by La, unless the first  
word is Chateau, and then go ahead and order by La.



	Example sort:  Notice how the producer as-in comes before the  
parenthesis, but the ORDER BY actually occurs after a re-ordering of  
the producer-string, using the above rules.


Red: Château Bahans Haut-Brion (Bahans Haut-Brion, Château )
	Red: La Chapelle de La Mission Haut-Brion (Chapelle de La Mission  
Haut-Brion, La )

Red: Le Clarence de Haut-Brion (Clarence de Haut-Brion, Le )
Red: Château Haut-Brion (Haut-Brion, Château )
Red: Château La Mission Haut-Brion (La Mission Haut-Brion, Château )
	Red: Domaine de La Passion Haut Brion (La Passion Haut Brion,  
Domaine de )

Red: Château La Tour Haut-Brion (La Tour Haut-Brion, Château )
Red: Château Larrivet-Haut-Brion (Larrivet-Haut-Brion, Château )
Red: Château Les Carmes Haut-Brion (Les Carmes Haut-Brion, Château )


	That logic between mySQL and PHP, I'm just not sure how to  
accomplish?  I think it might involve a mySQL alias-technique but I  
could be wrong.


Right now, my PHP call to generate the search is this:

$query = 'SELECT * FROM wine WHERE MATCH(producer, varietal,  
appellation, designation, region, vineyard, subregion, country,  
vintage) AGAINST ( ' . $searchstring . ')  ORDER BY producer LIMIT  
0,100';




Re: [PHP] PHP/mySQL question using ORDER BY with logic

2008-10-23 Thread Robert Cummings
On Fri, 2008-10-24 at 00:18 -0400, Rob Gould wrote:
 Question about mySQL and PHP, when using the mySQL ORDER BY method...
 
 
   Basically I've got data coming from the database where a wine  
 producer-name is a word like:
 
   Château Bahans Haut-Brion
 
   or
 
   La Chapelle de La Mission Haut-Brion
 
   or
 
   Le Clarence de Haut-Brion
 
 but I need to ORDER BY using a varient of the string:
 
   1)  If it begins with Château, don't include Chateau in the  
 string to order by.
   2)  If it begins with La, don't order by La, unless the first  
 word is Chateau, and then go ahead and order by La.
 
 
   Example sort:  Notice how the producer as-in comes before the  
 parenthesis, but the ORDER BY actually occurs after a re-ordering of  
 the producer-string, using the above rules.
 
   Red: Château Bahans Haut-Brion (Bahans Haut-Brion, Château )
   Red: La Chapelle de La Mission Haut-Brion (Chapelle de La Mission  
 Haut-Brion, La )
   Red: Le Clarence de Haut-Brion (Clarence de Haut-Brion, Le )
   Red: Château Haut-Brion (Haut-Brion, Château )
   Red: Château La Mission Haut-Brion (La Mission Haut-Brion, Château )
   Red: Domaine de La Passion Haut Brion (La Passion Haut Brion,  
 Domaine de )
   Red: Château La Tour Haut-Brion (La Tour Haut-Brion, Château )
   Red: Château Larrivet-Haut-Brion (Larrivet-Haut-Brion, Château )
   Red: Château Les Carmes Haut-Brion (Les Carmes Haut-Brion, Château )
 
 
   That logic between mySQL and PHP, I'm just not sure how to  
 accomplish?  I think it might involve a mySQL alias-technique but I  
 could be wrong.
 
 Right now, my PHP call to generate the search is this:
 
 $query = 'SELECT * FROM wine WHERE MATCH(producer, varietal,  
 appellation, designation, region, vineyard, subregion, country,  
 vintage) AGAINST ( ' . $searchstring . ')  ORDER BY producer LIMIT  
 0,100';

Maybe there's a good way to do it with the table as is... but I'm
doubtful. I would create a second field that contains a pre-processed
version of the name that performs stripping to achieve what you want.
This could be done by a PHP script when the data is inserted into the
database, or if not possible like that, then a cron job could run once
in a while, check for entries with this field empty and generate it.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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