php-general Digest 30 Jul 2009 08:06:56 -0000 Issue 6257

2009-07-30 Thread php-general-digest-help

php-general Digest 30 Jul 2009 08:06:56 - Issue 6257

Topics (messages 296015 through 296049):

Re: Getting rid of extra lines
296015 by: Ashley Sheridan
296016 by: Bob McConnell
296020 by: Jim Lucas
296021 by: Miller, Terion
296022 by: Miller, Terion
296023 by: Jim Lucas
296025 by: Jonathan Tapicer

Re: preg_match too greedy
296017 by: Ben Dunlap
296019 by: Jim Lucas
296041 by: Clancy
296042 by: Daniel Kolbo
296043 by: b
296044 by: b
296045 by: b
296047 by: Daniel Kolbo
296048 by: b

Asterisk anyone?
296018 by: Skip Evans
296024 by: Per Jessen
296038 by: Skip Evans
296049 by: Sancar Saran

Re: Getting rid of extra lines (RESOLVED)
296026 by: Miller, Terion
296027 by: Jim Lucas
296029 by: Miller, Terion

Locating Bad Image Files
296028 by: Floyd Resler

Expand Variables in String
296030 by: Daniel Kolbo
296033 by: Jonathan Tapicer
296039 by: Daniel Kolbo
296040 by: Jonathan Tapicer

Re: Ridiculous ..won't print or echo ...(RESOLVED)
296031 by: Miller, Terion

Page or URL function?
296032 by: Miller, Terion
296035 by: Ben Dunlap
296036 by: Ben Dunlap
296037 by: Ben Dunlap

fileinfo returning wrong mime type for Excel files
296034 by: Christoph Boget
296046 by: Paul M Foster

Administrivia:

To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
php-gene...@lists.php.net


--
---BeginMessage---
[snip/]

Have you thought of just using a regular str_replace() on your code? You
can ask it to replace newlines and carriage returns with nothing and see
if that fixes you problem?

Thanks
Ash
www.ashleysheridan.co.uk

---End Message---
---BeginMessage---
From: Miller, Terion

/* snip */

Before anyone can tell you how to fix it, you need to find out what is
causing that white space. is it empty lines, vertical tabs, thousands of
spaces, ...? Once you find that out, it is pretty easy to decide how to
get rid of them. Can you save the output to a file and open it with a
hex viewer?

Bob McConnell
---End Message---
---BeginMessage---
Miller, Terion wrote:
 I am trying to get rid of empty whitespace lines, I can't us chop() because
 as I read it it will remove all whitespacesright?
 
 Right now my db is outputting with extra lines, I have stripped tags I know
 it isn't that causing it to look like this
 
 Blahlajdlkfjlksdjflkdjsf
 
--how do I get rid of all this extra space?
 
 alkdfjlsdakjflsakdjflksjdf
 
 

If the white space is included in data coming from the db you could run
a simple little regex on the variable to removed any repetitive white
space.  But it might not be the best way to do it.

$clean = preg_replace('|\s+|', ' ', $input);
or
$clean = preg_replace('|\s{2,}|', ' ', $input);

If the white space is being generated in your HTML output, but is not in
your data store, then you need to cleanup your PHP code and that might help.

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



On 7/29/09 1:45 PM, Ashley Sheridan a...@ashleysheridan.co.uk wrote:

[snip/]

Have you thought of just using a regular str_replace() on your code? You
can ask it to replace newlines and carriage returns with nothing and see
if that fixes you problem?

Thanks
Ash
www.ashleysheridan.co.uk



Yep I have tried str_replace to get rid of \n and it didn't work
Boss mentioned to explode the var that is full of so many blank lines then put 
it back together..seems like there has to be an easier way...

This is what I tried:

 $tags = array('\n', 'br');$sNotes = str_replace($tags,, $notes);
---End Message---
---BeginMessage---



On 7/29/09 2:19 PM, Jim Lucas li...@cmsws.com wrote:

$clean = preg_replace('|\s+|', ' ', $input);

Hi Jim,
The extra whitespace lines are in the data store, coming from it I'm going to 
try your method but is there a way to not have mySQL store it with so many 
lines (this is data being screen scraped and put in the db)
My code was at the beginning of this post of how I was inserting it.

Thanks
And Chocolate huh
Terion
---End Message---
---BeginMessage---
Miller, Terion wrote:
 
 
 On 7/29/09 2:19 PM, Jim Lucas li...@cmsws.com wrote:
 
 $clean = preg_replace('|\s+|', ' ', $input);
 
 Hi Jim,
 The extra whitespace lines are in the data store, coming from it I'm going to 
 try your method but is there a way to not have mySQL store it with so many 
 lines (this is data being screen scraped and put in the db)
 My code was at the beginning of this post of how I was inserting it.
 
 Thanks
 And Chocolate huh
 Terion
 

If the method that I give you works on 

php-general Digest 30 Jul 2009 21:25:35 -0000 Issue 6258

2009-07-30 Thread php-general-digest-help

php-general Digest 30 Jul 2009 21:25:35 - Issue 6258

Topics (messages 296050 through 296075):

stdClass - A newbie question
296050 by: MEM
296051 by: Bouz Alexander
296053 by: MEM
296066 by: Shawn McKenzie

Word and UTF-8 (cyrillic, chinese, ...)
296052 by: Sascha Meyer

Re: fileinfo returning wrong mime type for Excel files
296054 by: Christoph Boget
296056 by: Peter Ford
296057 by: b
296058 by: Christoph Boget
296059 by: Christoph Boget
296060 by: Ashley Sheridan
296061 by: Christoph Boget
296062 by: Bob McConnell
296063 by: Ashley Sheridan

Freeing Memory
296055 by: Anton Heuschen
296065 by: Dan Shirah

Re: Asterisk anyone?
296064 by: Per Jessen

Re: preg_match too greedy
296067 by: Ben Dunlap
296068 by: Ben Dunlap

regex - filtering out chinese utf8 characters
296069 by: Merlin Morgenstern
296071 by: Stuart Connolly
296075 by: Daniel Kolbo

PHP 5.3 IIS 5.1 not working...help!
296070 by: Fred Silsbee

Re: Page or URL function? (RESOLVED)
296072 by: Miller, Terion
296073 by: Jim Lucas
296074 by: Ben Dunlap

Administrivia:

To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
php-gene...@lists.php.net


--
---BeginMessage---
Hello everybody, 


In this class sketch:


?php

class Pagination {

...
  
public static function Pagination ($total_records, $limit, $page)


{

  $total_pages = ceil($total_records / $limit);

$page = max($page, 1);

$page = min($page, $total_pages);

$offset = ($page -1) * $limit;



$pagi_obj= new stdClass;

$pagi_obj-total_pages = $total_pages;

$pagi_obj-offset = $offset;

$pagi_obj-limit = $limit;

$pagi_obj-page;



return $pagi_obj;



}  


}


Why do the author used a stdClass ?
What are the advantages of using a stdClass?

Since we are already inside a class, why do we need to create a new object
from another class, inside this one? 
Why do we keep the values passed as params on method Pagination inside this
stdClass object, and not inside Pagination own properties for example? 

Any help clarifying this, knowing that I'm a newbie,

Regards,
Márcio

---End Message---
---BeginMessage---
Hello Márcio,

stdClass is simply an empty class, without any properties or methods.

The object in the code sample is used to return multiple values at once. He 
could also have used an associative array to achieve that, but by choosing an 
object, he shows his affinity to the object oriented programming style.

The empty stdClass has the advantage of being a blank class. You can assign 
new properties or methods without minding about properties and methods that 
already exist in the class.
Besides that, it also doesn't use much memory. (Don't see that as performance 
boosting tip! There are much better ways to do that. Besides that, 
comprehensible design  performance.)

By the way, there are many reasons for creating objects inside of other 
objects. This should not be considered an exception. I don't know where this 
code belongs to, so I can't clear out if it is good or bad OOP style.

Just think about everything in classes and objects - even return values or 
other things, that you would normally consider as volatile. (eg. a network 
connection)

Have a nice day,
Alex





Austrian Optic Technologies GmbH
Eisgrubengasse 2-6, A-2334 Vösendorf/Austria
Firmenbuch Nr.: FN 93629s
Firmenbuchgericht: Landesgericht Wien
UID-NR.: ATU 14976908
 
Disclaimer: Diese Nachricht ist ausschließlich für den bezeichneten Adressaten 
oder deren Vertreter bestimmt. Sollten sie nicht der vorgesehene Adressat 
dieser E-Mail sein, so bitten wir Sie, sich mit dem Absender der E-Mail in 
Verbindung zu setzen. Jede Form der unauthorisierten Nutzung, Veröffentlichung, 
Vervielfältigung oder Weitergabe dieser E-Mail ist nicht gestattet.
This message is exclusively intended for the designated recipient or his 
representatives. If you are not the designated recipient of this e-mail, we 
kindly ask you to notify the sender of this e-mail. Any form of unauthorized 
use, publication, duplication or dissemination of this e-mail is prohibited. 



Von: MEM [mailto:tal...@gmail.com] 
Gesendet: Donnerstag, 30. Juli 2009 12:21
An: php-gene...@lists.php.net
Betreff: [PHP] stdClass - A newbie question

Hello everybody, 


In this class sketch:


?php

class Pagination {

...
  
public static function Pagination ($total_records, $limit, $page)


{

  $total_pages = ceil($total_records / 

Re: [PHP] Asterisk anyone?

2009-07-30 Thread Sancar Saran
On Wednesday 29 July 2009 10:18:08 pm Skip Evans wrote:
 Hey,

 I've been asked to write a simple couple of public pages that
 would let an Asterisk customer modify their account
 configuration, but the client has no idea how Asterisk stores
 its data, apparently not in MySQL.

 Anyone know of any resources for accessing Asterisk from PHP?

 If anyone has done this can you tell me if I'm on the right
 track here?

 http://www.voip-info.org/wiki/view/Asterisk+AGI+php#PHPTipsandExamples

Hello,

Asterisk's default storage was text files.

You should check Trixbox. 

It was a Asterisk with MySQL backend. Also it has all bells and whistles. And 
web based management console.

Even it comes packed with a centos.

Your link shows how to remote asterisk console from web.

Regards

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



[PHP] stdClass - A newbie question

2009-07-30 Thread MEM
Hello everybody, 


In this class sketch:


?php

class Pagination {

...
  
public static function Pagination ($total_records, $limit, $page)


{

  $total_pages = ceil($total_records / $limit);

$page = max($page, 1);

$page = min($page, $total_pages);

$offset = ($page -1) * $limit;



$pagi_obj= new stdClass;

$pagi_obj-total_pages = $total_pages;

$pagi_obj-offset = $offset;

$pagi_obj-limit = $limit;

$pagi_obj-page;



return $pagi_obj;



}  


}


Why do the author used a stdClass ?
What are the advantages of using a stdClass?

Since we are already inside a class, why do we need to create a new object
from another class, inside this one? 
Why do we keep the values passed as params on method Pagination inside this
stdClass object, and not inside Pagination own properties for example? 

Any help clarifying this, knowing that I'm a newbie,

Regards,
Márcio


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



AW: [PHP] stdClass - A newbie question

2009-07-30 Thread Bouz Alexander
Hello Márcio,

stdClass is simply an empty class, without any properties or methods.

The object in the code sample is used to return multiple values at once. He 
could also have used an associative array to achieve that, but by choosing an 
object, he shows his affinity to the object oriented programming style.

The empty stdClass has the advantage of being a blank class. You can assign 
new properties or methods without minding about properties and methods that 
already exist in the class.
Besides that, it also doesn't use much memory. (Don't see that as performance 
boosting tip! There are much better ways to do that. Besides that, 
comprehensible design  performance.)

By the way, there are many reasons for creating objects inside of other 
objects. This should not be considered an exception. I don't know where this 
code belongs to, so I can't clear out if it is good or bad OOP style.

Just think about everything in classes and objects - even return values or 
other things, that you would normally consider as volatile. (eg. a network 
connection)

Have a nice day,
Alex





Austrian Optic Technologies GmbH
Eisgrubengasse 2-6, A-2334 Vösendorf/Austria
Firmenbuch Nr.: FN 93629s
Firmenbuchgericht: Landesgericht Wien
UID-NR.: ATU 14976908
 
Disclaimer: Diese Nachricht ist ausschließlich für den bezeichneten Adressaten 
oder deren Vertreter bestimmt. Sollten sie nicht der vorgesehene Adressat 
dieser E-Mail sein, so bitten wir Sie, sich mit dem Absender der E-Mail in 
Verbindung zu setzen. Jede Form der unauthorisierten Nutzung, Veröffentlichung, 
Vervielfältigung oder Weitergabe dieser E-Mail ist nicht gestattet.
This message is exclusively intended for the designated recipient or his 
representatives. If you are not the designated recipient of this e-mail, we 
kindly ask you to notify the sender of this e-mail. Any form of unauthorized 
use, publication, duplication or dissemination of this e-mail is prohibited. 



Von: MEM [mailto:tal...@gmail.com] 
Gesendet: Donnerstag, 30. Juli 2009 12:21
An: php-general@lists.php.net
Betreff: [PHP] stdClass - A newbie question

Hello everybody, 


In this class sketch:


?php

class Pagination {

...
  
public static function Pagination ($total_records, $limit, $page)


{

  $total_pages = ceil($total_records / $limit);

$page = max($page, 1);

$page = min($page, $total_pages);

$offset = ($page -1) * $limit;



$pagi_obj= new stdClass;

$pagi_obj-total_pages = $total_pages;

$pagi_obj-offset = $offset;

$pagi_obj-limit = $limit;

$pagi_obj-page;



return $pagi_obj;



}  


}


Why do the author used a stdClass ?
What are the advantages of using a stdClass?

Since we are already inside a class, why do we need to create a new object
from another class, inside this one? 
Why do we keep the values passed as params on method Pagination inside this
stdClass object, and not inside Pagination own properties for example? 

Any help clarifying this, knowing that I'm a newbie,

Regards,
Márcio


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

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



[PHP] Word and UTF-8 (cyrillic, chinese, ...)

2009-07-30 Thread Sascha Meyer
Hi there,

I am currently struggling in forcing Word to show a UTF-8 encoded document. The 
generated document is a normal web page with generated content from a mysql 
database.
When I remove the header commands, the document with proper russian characters 
is displayed fine in the browser, but when I add
[CODE]
  header (Content-Type: application/vnd.ms-word;charset=utf-8);
  header (Content-Disposition: 
attachment;filename=questionnaire_.date(Ymd_his)..doc);
[/CODE]
, Word opens and displays the information as chinese letters instead of 
russian. This also happens for spanish and french special characters, they are 
also incorrectly displayed.

Any clues how I can force Word to display UTF-8 correctly?

Thanks a lot in advance!

Best regards,

Sascha
-- 
Jetzt kostenlos herunterladen: Internet Explorer 8 und Mozilla Firefox 3 -
sicherer, schneller und einfacher! http://portal.gmx.net/de/go/atbrowser

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



RE: [PHP] stdClass - A newbie question

2009-07-30 Thread MEM
 By the way, there are many reasons for creating objects inside of other
 objects. This should not be considered an exception. I don't know where
 this code belongs to, so I can't clear out if it is good or bad OOP
 style.

I do not intend to public judge the author, but the original article is here, 
just for proper credit:
http://www.phpro.org/tutorials/Pagination-with-PHP-and-PDO.html
 
 
 Just think about everything in classes and objects - even return values
 or other things, that you would normally consider as volatile. (eg. a
 network connection)

It would be a nice exercise to practice. :) Thanks for the tip.


And thanks a lot for the reply, I'm almost there... one last newbie question:

When we have something like this:
Class Pagination 
{
Public static function Pagination ($limit, $total_records, $page)
{
$pagi_obj= new stdClass;

$pagi_obj-total_pages = $total_pages;

$pagi_obj-offset = $offset;

$pagi_obj-limit = $limit;

$pagi_obj-page = $page;



return $pagi_obj;
...

How can we, later, have something like this, for example:
$pagination_obj=Pagination::Pagination(some params)
$pagination_obj-offset;

?

I mean:
When we instantiate the class by doing: 
$pagination_obj=Pagination::Pagination(some params) 

We will have an object ($pagi_obj) returned where the properties of that object 
will be *referring* to the values passed on the method argument, right?

How does those $pagi_obj properties, can then be accessible by doing 
$pagination_obj-offset; ? I mean, they are attributes of our stdClass object 
(aka pagi_obj), and they are not attributes of our Pagination class, or are 
they?


Thanks in advance,
Márcio





 


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



Re: [PHP] fileinfo returning wrong mime type for Excel files

2009-07-30 Thread Christoph Boget
  /usr/share/file/magic
 /usr/share/file/magic has lots of rules to know its type and its just
 matching it.

I know it has a lot of rules.  Grepping it for excel shows that there
are rules in it for those types of files as well.

 Maybe your file is quite strange . have you tried with other xls files?

Yes, I have; the result is the same for all.

 what does  file /path/to/my/excel.xls  say

$ file excel.xls
excel.xls: Microsoft Office Document

Interestingly...

$ file word.doc
word.doc: Microsoft Office Document

So apparently, to the file command, there is no distinction.  That
seems both odd and wrong to me.  But not nearly as wrong as fileinfo
reporting application/msword as the mime type of an excel document.

thnx,
Christoph

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



[PHP] Freeing Memory

2009-07-30 Thread Anton Heuschen
How  would you go about ensuring the memory is not exhausted when running a
script ?

I have a script, which to make it basic ... reads values from files, I
create an array of values per file then with a foreach insert values into a
table, I have added a line to echo the memory use after each array is done
(after insert is done and the foreach is complete for the file) with: -
echo Mem SQL: .memory_get_usage() . \n;

It gave me this result below:

Mem SQL: 8341312
Mem SQL: 8461856
Mem SQL: 8693440
Mem SQL: 9327008
Mem SQL: 9798952
Mem SQL: 10238392
Mem SQL: 10604776

As can be seen the mem usage simply grows,

I have added a line after each iteration of the foreach is complete to unset
the vars and array ... thinking this would basically clear up the allocated
memmory used by the array ... and it would start at 0 again for the next
array looped, but obviously this is not quite the answer.

The question is then how do you clear  memmory then ?


Re: [PHP] fileinfo returning wrong mime type for Excel files

2009-07-30 Thread Peter Ford
Christoph Boget wrote:
 /usr/share/file/magic
 /usr/share/file/magic has lots of rules to know its type and its just
 matching it.
 
 I know it has a lot of rules.  Grepping it for excel shows that there
 are rules in it for those types of files as well.
 
 Maybe your file is quite strange . have you tried with other xls files?
 
 Yes, I have; the result is the same for all.
 
 what does  file /path/to/my/excel.xls  say
 
 $ file excel.xls
 excel.xls: Microsoft Office Document
 
 Interestingly...
 
 $ file word.doc
 word.doc: Microsoft Office Document
 
 So apparently, to the file command, there is no distinction.  That
 seems both odd and wrong to me.  But not nearly as wrong as fileinfo
 reporting application/msword as the mime type of an excel document.
 
 thnx,
 Christoph


Have you tried using 'file -i' from the command line: after all you are looking
for a MIME type with your fileinfo...

Having said that, with file -i on my system, Word documents are
'application/msword' and Excel files are 'application/octet-stream'

-- 
Peter Ford  phone: 01580 89
Developer   fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

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



Re: [PHP] fileinfo returning wrong mime type for Excel files

2009-07-30 Thread b

On 07/30/2009 08:53 AM, Peter Ford wrote:


Have you tried using 'file -i' from the command line: after all you are looking
for a MIME type with your fileinfo...

Having said that, with file -i on my system, Word documents are
'application/msword' and Excel files are 'application/octet-stream'



Fedora11 (2.6.29.6-213.fc11.i586)

$ file excel.xls
excel.xls: CDF V2 Document, Little Endian, Os: Windows, Version 5.1, 
Code page: 1252, Author: ??, Last Saved By: 
ELAN, Name of Creating Application: Microsoft Excel, Last Printed: Sun 
Nov  6 18:04:20 2005, Create Time/Date: Tue Nov  1 02:56:47 2005, 
Security: 0


$ file -i excel.xls
excel.xls: application/vnd.ms-excel; charset=binary

Using 5.2.9, the OP's script prints:
application/vnd.ms-excel; charset=binary

I wonder if the problem lies with the documents themselves. Last May, I 
posted a msg here about how FileInfo was reporting back 
application/msword application/msword for some (but not all) Word 
docs. I never received a reply about it but came up with a hack to split 
on the space, if present.


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



Re: [PHP] fileinfo returning wrong mime type for Excel files

2009-07-30 Thread Christoph Boget
 Have you tried using 'file -i' from the command line: after all you are 
 looking
 for a MIME type with your fileinfo...
 Having said that, with file -i on my system, Word documents are
 'application/msword' and Excel files are 'application/octet-stream'

$ file -i excel.xls
excel.xls: application/msword

The xls file I am using was generated with Excel (of Office 2007) for
the Mac.  So either you have a different magic file (assuming that's
what the file command uses) than I do or different versions of excel
contain different information.

thnx,
Christoph

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



Re: [PHP] fileinfo returning wrong mime type for Excel files

2009-07-30 Thread Christoph Boget
 Having said that, with file -i on my system, Word documents are
 'application/msword' and Excel files are 'application/octet-stream'
 Fedora11 (2.6.29.6-213.fc11.i586)
 $ file excel.xls
 excel.xls: CDF V2 Document, Little Endian, Os: Windows, Version 5.1, Code
 page: 1252, Author: ??, Last Saved By: ELAN, Name of
 Creating Application: Microsoft Excel, Last Printed: Sun Nov  6 18:04:20
 2005, Create Time/Date: Tue Nov  1 02:56:47 2005, Security: 0

Red Hat 4.1.2-14

$ file excel.xls
excel.xls: Microsoft Office Document

I'm not getting all that extra information.

 $ file -i excel.xls
 excel.xls: application/vnd.ms-excel; charset=binary

$file -i excel.xls
excel.xls: application/msword

 I wonder if the problem lies with the documents themselves. Last May, I
 posted a msg here about how FileInfo was reporting back application/msword
 application/msword for some (but not all) Word docs. I never received a
 reply about it but came up with a hack to split on the space, if present.

I saw that post and that is something we are getting occasionally as
well.  And it may perhaps be an issue with the documents themselves.
As I stated in a post I just made, the excel document I'm looking at
was created using Office 2007 for the Mac.

thnx,
Christoph

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



Re: [PHP] fileinfo returning wrong mime type for Excel files

2009-07-30 Thread Ashley Sheridan
On Thu, 2009-07-30 at 09:51 -0400, Christoph Boget wrote:
  Having said that, with file -i on my system, Word documents are
  'application/msword' and Excel files are 'application/octet-stream'
  Fedora11 (2.6.29.6-213.fc11.i586)
  $ file excel.xls
  excel.xls: CDF V2 Document, Little Endian, Os: Windows, Version 5.1, Code
  page: 1252, Author: ??, Last Saved By: ELAN, Name of
  Creating Application: Microsoft Excel, Last Printed: Sun Nov  6 18:04:20
  2005, Create Time/Date: Tue Nov  1 02:56:47 2005, Security: 0
 
 Red Hat 4.1.2-14
 
 $ file excel.xls
 excel.xls: Microsoft Office Document
 
 I'm not getting all that extra information.
 
  $ file -i excel.xls
  excel.xls: application/vnd.ms-excel; charset=binary
 
 $file -i excel.xls
 excel.xls: application/msword
 
  I wonder if the problem lies with the documents themselves. Last May, I
  posted a msg here about how FileInfo was reporting back application/msword
  application/msword for some (but not all) Word docs. I never received a
  reply about it but came up with a hack to split on the space, if present.
 
 I saw that post and that is something we are getting occasionally as
 well.  And it may perhaps be an issue with the documents themselves.
 As I stated in a post I just made, the excel document I'm looking at
 was created using Office 2007 for the Mac.
 
 thnx,
 Christoph
 

To test that, is there any way you could put a blank spreadsheet
document created from that same computer online somewhere so that people
on the list can check to see if it is the file that is being bad and not
your mime types file?

Thanks,
Ash
http://www.ashleysheridan.co.uk


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



Re: [PHP] fileinfo returning wrong mime type for Excel files

2009-07-30 Thread Christoph Boget
 The xls file I am using was generated with Excel (of Office 2007) for
 the Mac.  So either you have a different magic file (assuming that's
 what the file command uses) than I do or different versions of excel
 contain different information.

I just tried using an excel spreadsheet saved using Office 2003 on XP
and received the same output: application/msword.

thnx,
Christoph

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



RE: [PHP] fileinfo returning wrong mime type for Excel files

2009-07-30 Thread Bob McConnell
From: Christoph Boget

 Have you tried using 'file -i' from the command line: after all you
are looking
 for a MIME type with your fileinfo...
 Having said that, with file -i on my system, Word documents are
 'application/msword' and Excel files are 'application/octet-stream'
 
 $ file -i excel.xls
 excel.xls: application/msword
 
 The xls file I am using was generated with Excel (of Office 2007) for
 the Mac.  So either you have a different magic file (assuming that's
 what the file command uses) than I do or different versions of excel
 contain different information.

Those two statements are not mutually exclusive. Both may be true.

Bob McConnell

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



Re: [PHP] fileinfo returning wrong mime type for Excel files

2009-07-30 Thread Ashley Sheridan
On Thu, 2009-07-30 at 07:12 -0700, Christoph Boget wrote:
 Well, I didn't want to upload a file to the list.  Putting it in a
 central location where those interested parties could access it would
 be a much better option.
 
 
 thnx,
 Chris
 
 
 __
 From: Ashley Sheridan a...@ashleysheridan.co.uk
 To: Christoph Boget jcbo...@yahoo.com
 Sent: Thursday, July 30, 2009 10:05:33 AM
 Subject: Re: [PHP] fileinfo returning wrong mime type for Excel files
 
 On Thu, 2009-07-30 at 07:04 -0700, Christoph Boget wrote: 
   To test that, is there any way you could put a blank spreadsheet
   document created from that same computer online somewhere so that people
   on the list can check to see if it is the file that is being bad and not
   your mime types file?
  
  
  Sure.  Do you know of a place I can put it?  What I'm working on is an 
  intranet.
  
  thnx,
  Christoph
  
  

 You could email it to me, which I presume is better if you replied
 back just to me and not the list?
 
 
 Thanks,
 Ash
 http://www.ashleysheridan.co.uk
 
 
Just copying the list back on in this one now. I don't know of any
places that you could upload a file to off the top of my head. Anyone
have any links?

Thanks,
Ash
http://www.ashleysheridan.co.uk


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



Re: [PHP] Asterisk anyone?

2009-07-30 Thread Per Jessen
Skip Evans wrote:

 Per Jessen wrote:
 Depends on which data we're talking about.  Asterisk is very
 flexible.
 
 
 For example, the first screen they want people to be able to
 change data on is:
 
 call waiting,do not disturb
 and then it looks like numbers (forwarding?)
 unconditional,unavailable,busy
 
 I'm trying to figure out now are these values stored in a
 regular relational database like MySQL.

I think that is part of the dialplan, which is typically kept in a text
file in /etc/asterisk/extensions.conf or extensions.ael.  I'm not sure
if there is an option to use a database, coz' the dialplan can be quite
complicated.

 But so far the documentation I see is really all about how to
 handle calls, not manage customer data.

Yeah, that is what asterisk is all about - customer data depends on
the context.


/Per

-- 
Per Jessen, Zürich (22.8°C)


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



Re: [PHP] Freeing Memory

2009-07-30 Thread Dan Shirah

 How  would you go about ensuring the memory is not exhausted when running a
 script ?

 I have a script, which to make it basic ... reads values from files, I
 create an array of values per file then with a foreach insert values into a
 table, I have added a line to echo the memory use after each array is done
 (after insert is done and the foreach is complete for the file) with: -
 echo Mem SQL: .memory_get_usage() . \n;

 It gave me this result below:

 Mem SQL: 8341312
 Mem SQL: 8461856
 Mem SQL: 8693440
 Mem SQL: 9327008
 Mem SQL: 9798952
 Mem SQL: 10238392
 Mem SQL: 10604776

 As can be seen the mem usage simply grows,

 I have added a line after each iteration of the foreach is complete to
 unset
 the vars and array ... thinking this would basically clear up the allocated
 memmory used by the array ... and it would start at 0 again for the next
 array looped, but obviously this is not quite the answer.

 The question is then how do you clear  memmory then ?


I don't know what version of SQL you are using, but I have found that using:

mysql_free_result($result);
mssql_free_result($result);
ifx_free_result($result);

Helped my queries run much faster and use less resources. I had something
similar to your script where I would read lines from a huge file and then
insert the contents into my database.  Before adding the above the process
would take 20-30 minutes.  After freeing the results after each insert my
script completed in about 5-8 minutes.

Just add that within your foreach loop after you execute your query that
inserts the info.

Hope that helps.

Dan


Re: [PHP] stdClass - A newbie question

2009-07-30 Thread Shawn McKenzie
MEM wrote:
 By the way, there are many reasons for creating objects inside of other
 objects. This should not be considered an exception. I don't know where
 this code belongs to, so I can't clear out if it is good or bad OOP
 style.
 
 I do not intend to public judge the author, but the original article is here, 
 just for proper credit:
 http://www.phpro.org/tutorials/Pagination-with-PHP-and-PDO.html
  
  
 Just think about everything in classes and objects - even return values
 or other things, that you would normally consider as volatile. (eg. a
 network connection)
 
 It would be a nice exercise to practice. :) Thanks for the tip.
 
 
 And thanks a lot for the reply, I'm almost there... one last newbie question:
 
 When we have something like this:
 Class Pagination 
 {
   Public static function Pagination ($limit, $total_records, $page)
   {
   $pagi_obj= new stdClass;
 
   $pagi_obj-total_pages = $total_pages;
 
   $pagi_obj-offset = $offset;
 
   $pagi_obj-limit = $limit;
 
   $pagi_obj-page = $page;
 
 
 
   return $pagi_obj;
 ...
 
 How can we, later, have something like this, for example:
 $pagination_obj=Pagination::Pagination(some params)
 $pagination_obj-offset;
 
 ?
 
 I mean:
 When we instantiate the class by doing: 
 $pagination_obj=Pagination::Pagination(some params) 

Here you are calling the static method of the Pagination class which
returns the stdClass object which you are assigning to $pagination_obj.

 
 We will have an object ($pagi_obj) returned where the properties of that 
 object will be *referring* to the values passed on the method argument, right?

$pagi_obj is what is was in the Pagination class, but when it was
returned you assigned it to $pagination_obj.


 How does those $pagi_obj properties, can then be accessible by doing 
 $pagination_obj-offset; ? I mean, they are attributes of our stdClass object 
 (aka pagi_obj), and they are not attributes of our Pagination class, or are 
 they?

The Pagination class built the object for you and assigned those vars to
it.  It then returned the object and you assigned it the name
$pagination_obj.

HTH

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

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



Re: [PHP] preg_match too greedy

2009-07-30 Thread Ben Dunlap
 echo (preg_match($pattern, $test) != false)

 The  != false  here is redundant.
 
 Understood. But what you think is redundancy is, to me, clarity in
 programming. I happen to think that boolean tests shouldn't ride on
 whether or not an array returned from a function is empty or not (or a
 freaking boolean). If what I'm looking for is a false then that's what
 I'll test for.

Fair enough, but in that case I think you want !== false. The expression you
have -- ($x != false) -- will be true whether $x is 0, NULL, an empty string,
an empty array, or actually FALSE.

But $x !== false will only be true in the last case.

Ben

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



Re: [PHP] preg_match too greedy

2009-07-30 Thread Ben Dunlap
Ben Dunlap wrote:
 have -- ($x != false) -- will be true whether $x is 0, NULL, an empty 
 string,
[8]
 But $x !== false will only be true in the last case.

Sorry, replace be true with be false above.

-Ben

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



[PHP] regex - filtering out chinese utf8 characters

2009-07-30 Thread Merlin Morgenstern

Hi there,

I am trying to filter out content that is not ascii. Can I do this with 
regex? For example:


$regex = '[AZ][09]';
if (preg_match($regex, $text)) {
return TRUE;
}
else {
return FALSE;
}

The reason I need to do this is that I am doing a mysql query with the 
text and I need to make sure it is not UTF8. Otherwise I do get 
following error:


Error: 		Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and 
(utf8_general_ci,COERCIBLE) for operation '='


I am new to regex and would be happy for a jump start to get this fixed.

Best regards, Merlin

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



[PHP] PHP 5.3 IIS 5.1 not working...help!

2009-07-30 Thread Fred Silsbee

http://72.47.28.125:8080/phpinfo.php not working
ERROR:
The website cannot display the page 
 HTTP 500  

IIS 5.1, PHP 5.3 XP Prof SP3 + all updates
PHP 5.2.8 worked great and took a few minutes to install

phpinfo.php is in C:\inetpub\wwwroot 

?php
phpinfo();
?

php.ini has:
doc_root = C:\inetpub\wwwroot // for IIS/PWS (tried removing the )
 extension_dir = ext
php.ini put into 

C:\php
C:\Windows
C:\Windows\system
C:\windows\system32
system variable PHPRC set = C:\php

http://72.47.28.125:8080/aspx/abc.aspx works great with IIS 5.1

IIS 5.1 application configuration mappings .php   C:\php\php5.dll (that is all 
there is)
There is no php5isapi file!
home directory = C:\inetpub\wwwroot
web site: IP all unassigned, TCP Port 8080
directory security unchanged: IUSR_machine name...allow IIS to control 
password

VC9 versions downloaded and put into C:\php
Microsoft 2008 C++ Runtime (x86) installed
VC9 x86 Non Thread Safe (2009-Jun-30 08:52:54)

C:\php;c:\php\ext put on the end of the path environmental
  system variable


yes I rebooted many times

command line (black window) 
cd C:\php
php -i   generates plenty stuff

I am administrator!







  


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



Re: [PHP] regex - filtering out chinese utf8 characters

2009-07-30 Thread Stuart Connolly

Hi Merlin,

I think the pattern you're looking for is '/[a-zA-Z0-9]/' which will  
match all alphanumeric characters.


Cheers

Stuart

On 30 Jul 2009, at 19:13, Merlin Morgenstern wrote:


Hi there,

I am trying to filter out content that is not ascii. Can I do this  
with regex? For example:


$regex = '[AZ][09]';
if (preg_match($regex, $text)) {
return TRUE;
}
else {
return FALSE;
}

The reason I need to do this is that I am doing a mysql query with  
the text and I need to make sure it is not UTF8. Otherwise I do get  
following error:


Error: 		Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and  
(utf8_general_ci,COERCIBLE) for operation '='


I am new to regex and would be happy for a jump start to get this  
fixed.


Best regards, Merlin

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





smime.p7s
Description: S/MIME cryptographic signature


Re: [PHP] Re: Page or URL function? (RESOLVED)

2009-07-30 Thread Miller, Terion
I Figured it out using this:

 if ($_SERVER['SCRIPT_FILENAME'] = browse.php ) { 
$default = A; 
  } 
else {  
   $default = ;   
 }  
 $letter = 
isset($_GET['letter'])? $_GET['letter'] :$default ;


On 7/29/09 4:34 PM, Ben Dunlap bdun...@agentintellect.com wrote:

Ben Dunlap wrote [TWICE]:
 The $_SERVER global array has this sort of information. The 'PHP_SELF' key
[8]
 Ben

Very sorry for the double-post. Reply-all in Thunderbird News seems a little
overzealous by default.

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




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



Re: [PHP] Re: Page or URL function? (RESOLVED)

2009-07-30 Thread Jim Lucas
Miller, Terion wrote:
 I Figured it out using this:
 
  if ($_SERVER['SCRIPT_FILENAME'] = browse.php ) {   
   $default = A; 
   }   
   else {  
$default = ; 
}  
  $letter = 
 isset($_GET['letter'])? $_GET['letter'] :$default ;
 

unless you are doing more then what you are showing above.

I would do it like this:

if ( $_SERVER['SCRIPT_FILENAME'] = 'browse.php' ) {
if ( isset($_GET['letter']) ) {
$letter = $_GET['letter'];
} else {
$letter = 'A';
}
} else {
$letter = '';
}

Basically, it is the same thing.  But it doesn't execute the additional
IF statement when it doesn't need to.

Jim

 
 On 7/29/09 4:34 PM, Ben Dunlap bdun...@agentintellect.com wrote:
 
 Ben Dunlap wrote [TWICE]:
 The $_SERVER global array has this sort of information. The 'PHP_SELF' key
 [8]
 Ben
 
 Very sorry for the double-post. Reply-all in Thunderbird News seems a little
 overzealous by default.
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
 



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



Re: [PHP] Re: Page or URL function? (RESOLVED)

2009-07-30 Thread Ben Dunlap
Jim Lucas wrote:
 Miller, Terion wrote:
 I Figured it out using this:

 if ($_SERVER['SCRIPT_FILENAME'] = browse.php ) {
 $default = A;
 } else {
 $default = ;
 }

 $letter = isset($_GET['letter'])? $_GET['letter'] :$default ;
 
 unless you are doing more then what you are showing above.
 
 I would do it like this:
 
 if ( $_SERVER['SCRIPT_FILENAME'] = 'browse.php' ) {
   if ( isset($_GET['letter']) ) {
   $letter = $_GET['letter'];
   } else {
   $letter = 'A';
   }
 } else {
   $letter = '';
 }
 
 Basically, it is the same thing.  But it doesn't execute the additional
 IF statement when it doesn't need to.

They end up slightly different. In your version, Jim, only the page
'browse.php' will examine the GET-parameter called 'letter'.

In Terion's version, any page with this code in it will examine the 'letter'
parameter.

Either one might be appropriate, depending on the context, but they don't have
quite the same effect.

Ben

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



Re: [PHP] regex - filtering out chinese utf8 characters

2009-07-30 Thread Daniel Kolbo
Merlin Morgenstern wrote:
 Hi there,
 
 I am trying to filter out content that is not ascii. Can I do this with
 regex? For example:
 
 $regex = '[AZ][09]';
 if (preg_match($regex, $text)) {
 return TRUE;
 }
 else {
 return FALSE;
 }
 
 The reason I need to do this is that I am doing a mysql query with the
 text and I need to make sure it is not UTF8. Otherwise I do get
 following error:
 
 Error: Illegal mix of collations (latin1_swedish_ci,IMPLICIT)
 and (utf8_general_ci,COERCIBLE) for operation '='
 
 I am new to regex and would be happy for a jump start to get this fixed.
 
 Best regards, Merlin
 
You prolly have already been here:
http://www.regular-expressions.info/

But if not, that site is certainly useful for all things regex.

Sorry I can't be of more help for your specific question.

dK
`

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



Re: [PHP] regex - filtering out chinese utf8 characters

2009-07-30 Thread Jim Lucas
Merlin Morgenstern wrote:
 Hi there,
 
 I am trying to filter out content that is not ascii. Can I do this with
 regex? For example:
 
 $regex = '[AZ][09]';
 if (preg_match($regex, $text)) {
 return TRUE;
 }
 else {
 return FALSE;
 }
 
 The reason I need to do this is that I am doing a mysql query with the
 text and I need to make sure it is not UTF8. Otherwise I do get
 following error:
 
 Error: Illegal mix of collations (latin1_swedish_ci,IMPLICIT)
 and (utf8_general_ci,COERCIBLE) for operation '='
 
 I am new to regex and would be happy for a jump start to get this fixed.
 
 Best regards, Merlin
 

You might want to read up on iconv.  I think it will do what you are
wanting to do.

http://us2.php.net/manual/en/book.iconv.php

specifically...

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


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



Re: [PHP] Asterisk anyone?

2009-07-30 Thread Skip Evans
I'm looking at this page now that shows working with the 
database through socket type stuff, but now the ball is in the 
client's court what they want to do. Not sure, so I'm just 
reading up.


http://www.voip-info.org/tiki-index.php?page=Web+based+Asterisk+Database+maintenance

But thanks all for the pointers. It has been helpful. I've 
looked up Trixbox, thanks.


Skip

--

Skip Evans
Big Sky Penguin, LLC
503 S Baldwin St, #1
Madison WI 53703
608.250.2720
http://bigskypenguin.com

Those of you who believe in
telekinesis, raise my hand.
 -- Kurt Vonnegut

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



[PHP] Formatting plain text file

2009-07-30 Thread Skip Evans

Hey all,

Am I brain fading or what? I'm so used to formatting text in 
tables for HTML display I can't think of how to do it for a 
plain text file.


I just need to create a columned table of names and addresses 
type stuff... sprintf?

--

Skip Evans
Big Sky Penguin, LLC
503 S Baldwin St, #1
Madison WI 53703
608.250.2720
http://bigskypenguin.com

Those of you who believe in
telekinesis, raise my hand.
 -- Kurt Vonnegut

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



Re: [PHP] Formatting plain text file

2009-07-30 Thread Jim Lucas
Skip Evans wrote:
 Hey all,
 
 Am I brain fading or what? I'm so used to formatting text in tables for
 HTML display I can't think of how to do it for a plain text file.
 
 I just need to create a columned table of names and addresses type
 stuff... sprintf?

or a little str_pad on each variable...



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



Re: [PHP] Formatting plain text file

2009-07-30 Thread Skip Evans

Jim Lucas wrote:

Skip Evans wrote:

Hey all,

Am I brain fading or what? I'm so used to formatting text in tables for
HTML display I can't think of how to do it for a plain text file.

I just need to create a columned table of names and addresses type
stuff... sprintf?


or a little str_pad on each variable...



Sure, that will do it. But isn't there some way to construct 
formatted tables similar to HTML?



--

Skip Evans
Big Sky Penguin, LLC
503 S Baldwin St, #1
Madison WI 53703
608.250.2720
http://bigskypenguin.com

Those of you who believe in
telekinesis, raise my hand.
 -- Kurt Vonnegut

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



Re: [PHP] Formatting plain text file

2009-07-30 Thread Robert Cummings

Skip Evans wrote:

Jim Lucas wrote:

Skip Evans wrote:

Hey all,

Am I brain fading or what? I'm so used to formatting text in tables for
HTML display I can't think of how to do it for a plain text file.

I just need to create a columned table of names and addresses type
stuff... sprintf?

or a little str_pad on each variable...



Sure, that will do it. But isn't there some way to construct 
formatted tables similar to HTML?


You can use a combination of wordwrap(), str_pad(), and swathe of 
judicious (but simplistic) math :)


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



[PHP] This isn't infinitely recursive is it?

2009-07-30 Thread Matt Neimeyer
I'm cleaning up some inherited code in our data import module. For a
variety of reasons we have to support old standards of the import
format. Since some of those old versions were created we have since
renamed some fields in our data structure. So right now I've a hard
map for some field names...

function GetMappedField($Field)
   {
   $FieldMap[A] = B;
   $FieldMap[C] = D;

   return isset($FieldMap[$Field])?$FieldMap[$Field]:$Field);
   }

But I've just spent a while tracking down a bug where someone mapped A
to B and then someone else mapped B to C.

I'm thinking of changing the return to...

   return isset($FieldMap[$Field])?GetMappedField($FieldMap[$Field]):$Field);

...but I'm worried about the recursion. (Which isn't a strength of mine)

I don't THINK I need to worry about circular mappings... but I'm not
sure how to check for it if I did...

Any suggestions? Thanks!

Matt

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



Re: [PHP] This isn't infinitely recursive is it?

2009-07-30 Thread Jonathan Tapicer
Hi,

Well, you will have an infinite recursion there if the mapping has
cycles, something like A-B, B-C, C-A would generate an invite
recursion.

Checking if the mapping has cycles is pretty simple: you have to
create a directed graph and then go through the graph in DFS marking
each visited node, if you have to mark a node already marked then you
have a cycle. Tarjan's algorithm does that and a little more, see
here: 
http://en.wikipedia.org/wiki/Tarjan%27s_strongly_connected_components_algorithm

Hope that helps.

Jonathan

On Thu, Jul 30, 2009 at 8:38 PM, Matt Neimeyerm...@neimeyer.org wrote:
 I'm cleaning up some inherited code in our data import module. For a
 variety of reasons we have to support old standards of the import
 format. Since some of those old versions were created we have since
 renamed some fields in our data structure. So right now I've a hard
 map for some field names...

 function GetMappedField($Field)
   {
   $FieldMap[A] = B;
   $FieldMap[C] = D;

   return isset($FieldMap[$Field])?$FieldMap[$Field]:$Field);
   }

 But I've just spent a while tracking down a bug where someone mapped A
 to B and then someone else mapped B to C.

 I'm thinking of changing the return to...

   return isset($FieldMap[$Field])?GetMappedField($FieldMap[$Field]):$Field);

 ...but I'm worried about the recursion. (Which isn't a strength of mine)

 I don't THINK I need to worry about circular mappings... but I'm not
 sure how to check for it if I did...

 Any suggestions? Thanks!

 Matt

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



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



[PHP] Re: This isn't infinitely recursive is it?

2009-07-30 Thread Ben Dunlap
 I don't THINK I need to worry about circular mappings... but I'm not
 sure how to check for it if I did...
 
 Any suggestions? Thanks!

Would the following work? It avoids recursion entirely and also checks for
circular mappings. You can plug in your own code where the comments are to do
whatever is appropriate when a circular mapping is detected.

function GetMappedField($Field)
{
$OriginalField = $Field;

while (isset($FieldMap[$Field]) {
$Field = $FieldMap[$Field];

if ($Field === $OriginalField) {
/*
 * circular mapping has been detected;
 * report an error or explode or whatever
 */
 break;
}
}

return $Field;
}


Ben

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



Re: [PHP] Asterisk anyone?

2009-07-30 Thread Nathan Nobbe
On Wed, Jul 29, 2009 at 1:18 PM, Skip Evans s...@bigskypenguin.com wrote:

 Hey,

 I've been asked to write a simple couple of public pages that would let an
 Asterisk customer modify their account configuration, but the client has no
 idea how Asterisk stores its data, apparently not in MySQL.

 Anyone know of any resources for accessing Asterisk from PHP?

 If anyone has done this can you tell me if I'm on the right track here?

 http://www.voip-info.org/wiki/view/Asterisk+AGI+php#PHPTipsandExamples


this should get you off to a good start,

http://www.voip-info.org/wiki/view/Asterisk+CDR+csv+mysql+import

-nathan


[PHP] Re: This isn't infinitely recursive is it?

2009-07-30 Thread Ben Dunlap
 while (isset($FieldMap[$Field]) {

Oops, left out the final close-parenthesis. I always do that with isset() for
some reason.

Ben

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



[PHP] Better Formatting Options?

2009-07-30 Thread sono-io

Is there a more efficient way to write the following?

?php $result = mysql_query(SELECT priceList FROM catalog WHERE  
itemid='ABC1',$db);
printf(iList: s%s/s/ibr /\n, money_format('$%i',  
mysql_result($result,0,priceList))); ?


	I have many products per page and this code pulls the list price and  
formats it.  It works fine, but I'd like to know if I can shorten it.


	I've looked at number_format over money_format and it's a little  
shorter, but not by much.  Are there better options than printf and  
mysql_result for my use?


Thanks,
Frank

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



Re: [PHP] Formatting plain text file

2009-07-30 Thread b

On 07/30/2009 06:29 PM, Skip Evans wrote:

Jim Lucas wrote:

Skip Evans wrote:

Hey all,

Am I brain fading or what? I'm so used to formatting text in tables for
HTML display I can't think of how to do it for a plain text file.

I just need to create a columned table of names and addresses type
stuff... sprintf?


or a little str_pad on each variable...



Sure, that will do it. But isn't there some way to construct formatted
tables similar to HTML?




Are you thinking of a CSV file that you can open in a spreadsheet prog? 
Or, do you literally mean a plaintext file with columns? For the latter, 
you'd need to measure the max char length of each column for every 
line in the file, then go back and print each line using str_pad().



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



Re: [PHP] Formatting plain text file

2009-07-30 Thread kranthi
?php
//assuming you have a 2d matrix $table
$table = array(
array(c11, c12, c13),
array(c21, c22, c23)
);
foreach($table as $rows) {
$row = vsprintf(str_repeat(%-10s, count($rows)), $rows);
echo {$row}br /\n;
}

wont this do ?

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



Re: [PHP] fileinfo returning wrong mime type for Excel files

2009-07-30 Thread b

On 07/30/2009 10:15 AM, Ashley Sheridan wrote:

On Thu, 2009-07-30 at 07:12 -0700, Christoph Boget wrote:



You could email it to me, which I presume is better if you replied
back just to me and not the list?


Just copying the list back on in this one now. I don't know of any
places that you could upload a file to off the top of my head. Anyone
have any links?



Just google upload file; there are a bunch of sites that do this to 
choose from.


(I've never used any so I can't recommend one over the others)


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



[PHP] PHP 5.2.9 + NCurses

2009-07-30 Thread Martin Scotta
Hi all

I have start a shell script and I want to use ncurses.
It was a quite difficulty to get it working, but now I'm done to start
to develop.

I have already search on sf.net and phpclasses and found a couple, but
I'm looking more stable or with a better OO design.

Do you know any set of classes that handle ncurses easily?

-- 
Martin Scotta

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