Re: [PHP] php mail() function and ezmlm

2010-01-13 Thread vikash . iitb
Can you send it to other email addresses?

--
Vikash Kumar
http://vika.sh

On Thu, Jan 14, 2010 at 12:16 PM, Bob Strasser wrote:

> I'm having trouble sending info from a form to the list-subscr...@domain
> Does anyone know why ezmlm doesn't recognize the mail() function?
>
>


[PHP] php mail() function and ezmlm

2010-01-13 Thread Bob Strasser
I'm having trouble sending info from a form to the list-subscr...@domain
Does anyone know why ezmlm doesn't recognize the mail() function?



Re: [PHP] header("Location:...") fails

2010-01-13 Thread Shawn McKenzie
Robert Cummings wrote:
> Just make your life easy and create a redirect() function that generates
> the header instruction, makes a relative URL into an absolute URL and
> does the exit call. Then you just need to do:
> 
> redirect( 'target.php' );
> 
> So much simpler :)
> 
> Cheers,
> Rob.

Definitely!  Technically, header() with Location: should have an
absolute URL, though it works without one most of the time.

-- 
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] Read directory; store filenames found in mySQL table?

2010-01-13 Thread Shawn McKenzie
Kenneth Sande wrote:
> I use the glob function in my little homemade "web cam" page, which can
> really swell up in memory when used against a large amount of files (in
> my case around 30k files).

+1 for glob()


-- 
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] php and XML BibTeX

2010-01-13 Thread Paul M Foster
On Wed, Jan 13, 2010 at 12:45:53PM -0800, Michael A. Peters wrote:

> Hi -
>
> Currently on my web site, book and article references are just stored in
> the database. While it works, I actually would like to move that out of
> the database and to an XML file, the reason being is that if/when I need
> to add fields etc. to the referenced sources, it's a lot easier to just
> edit a text file than modify database and recode my form interface for
> modifying the database. Also, there's an existing XML format for bibTeX
> and there already are tools to go from that to "real" bibTex, which I
> may need to do at some point.
>
> What I'm hoping is that already exists some php classes / functions for
> dealing with the XML bibTeX but I haven't found them. Anyone know of any?

I don't know, but the first place I look for things like that is
phpclasses.org.

Paul

-- 
Paul M. Foster

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



Re: [PHP] Read directory; store filenames found in mySQL table?

2010-01-13 Thread Bastien Koert
On Wed, Jan 13, 2010 at 10:50 AM, Rahul S. Johari
 wrote:
>
> On Jan 13, 2010, at 10:40 AM, Rahul S. Johari wrote:
>
>>
>> On Jan 13, 2010, at 9:50 AM, Warren Windvogel wrote:
>>
>>> On 2010/01/13 04:25 PM, Rahul S. Johari wrote:

 Ave,

 This is what I'm trying to do; I want to read a directory (eg: W:\Test\)
 and take all the filenames found in the directory (eg: 1.vox, 2.wav, 3.txt)
 and store them in  a simple mySQL table.

 Can I do this?
>>>
>>> I tried to very quickly convert something I've done. It may need some
>>> work. Will work in  linux env.
>>>
>>> $origin = "Path"
>>>
>>> #load file listing into an array
>>> $shell = shell_exec("du $origin");
>>> $array  = array_reverse(explode("\n",$shell));
>>> $contIdArr = array();
>>>
>>> $newArr = array();
>>> foreach($array as $elem){
>>>  $newDir = "";
>>>  $pathArray = explode("/", $elem);
>>>  $nodeDepth = count($pathArray);
>>>  for($count=1; $count<$nodeDepth; $count++){
>>>      $newDir = $newDir.$pathArray[$count].'/';
>>>  }
>>>  $newArr[] = '/'.$newDir;
>>> }
>>> sort($newArr);
>>>
>>>
>>> foreach($newArr as $dir){
>>>  $pathArray = explode("/", $dir);
>>>
>>>  $fileListArr = dirList($dir);
>>>
>>>  foreach($fileListArr as $file){
>>>      //Insert file($file) and current dir/path($dir) into db
>>>  }
>>> }
>>>
>>> Kind regards
>>> Warren
>>>
>>
>>
>> Warren,
>>
>> I tried using your code and it definitely is very efficient & fast;
>> however I'm running into a small problem and I'm not sure how to correct it.
>> I'm getting the array with filenames from the folder I'm searching in PLUS
>> all the root folders of the machine as well.
>>
>> This is the code I'm using (note that I'm just echoing the array right
>> now; I'll move to inserting data into mySQL after):
>>
>> function dirList ($directory) {
>>  $results = array();
>>  $handler = opendir($directory);
>>  while ($file = readdir($handler)) {
>>      if ($file != '.' && $file != '..')
>>          $results[] = $file;
>>  }
>>  closedir($handler);
>>  return $results;
>> }
>>
>> $origin = "/Library/WebServer/Documents/folder1/folder2/images/";
>>
>> #load file listing into an array
>> $shell = shell_exec("du $origin");
>> $array  = array_reverse(explode("\n",$shell));
>> $contIdArr = array();
>>
>> $newArr = array();
>> foreach($array as $elem){
>>  $newDir = "";
>>  $pathArray = explode("/", $elem);
>>  $nodeDepth = count($pathArray);
>>  for($count=1; $count<$nodeDepth; $count++){
>>      $newDir = $newDir.$pathArray[$count].'/';
>>  }
>>  $newArr[] = '/'.$newDir;
>> }
>> sort($newArr);
>>
>> foreach($newArr as $dir){
>>  $pathArray = explode("/", $dir);
>>  $fileListArr = dirList($dir);
>>
>>  foreach($fileListArr as $file){
>>        echo $file."";
>>      //Insert file($file) and current dir/path($dir) into db
>>  }
>> }
>>
>>
>> As an output ... i get a list of all the files in the "images" folder
>> preceeded by the all the list of root folders on my machine!! How do I
>> eliminate the list of root folders?
>
>
> Nevermind, I was looking at the wrong output. I got it!! I've got all my
> filenames in my $fileListArr[] array!!
> Now I just to get the values in a mySQL table.
>
>
> ---
> Rahul Sitaram Johari
> Founder, Internet Architects Group, Inc.
>
> [Email] sleepwal...@rahulsjohari.com
> [Web]   http://www.rahulsjohari.com
>
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


consider stacking the insert statements in sql to allow for a certain
number of inserts in one connect.

insert into my_table (field1, field2...fieldn)
values('field1','field2'...fieldn),('field1','field2'...fieldn),('field1','field2'...fieldn),('field1','field2'...fieldn)...

keep to something like 100 to avoid buffer overflows and it should
make the inserts much faster

-- 

Bastien

Cat, the other other white meat

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



Re: [PHP] header("Location:...") fails

2010-01-13 Thread Robert Cummings

Paul M Foster wrote:

On Wed, Jan 13, 2010 at 11:39:18AM -0800, Richard S. Crawford wrote:


Here is a snippet of code that is going to be the death of me:


//  Create a new project
$projectcode = strtoupper(addslashes($_POST['projectcode']));   //  project
code

//  Make sure the project code is unique
if (!$existingproject = mysql_query("select * from pb_versions where
projectcode like '".strtoupper($projectcode)."'")) {
die ("Could not check for existing project code!".mysql_error());
}

$numprojects = mysql_num_rows($existingproject);

if ($numprojects > 0) {
$pid = mysql_result($existingproject,0,"versionID");
header("Location:managebudget.php?e=1&pid=$pid");
}


Now, even if $numprojects is 1, 2, 3, etc., the header() command is not
executed. Strangely, a header("Location") command later on in the script
*is* executed. I've output the value of $numprojects, so I know that it's
greater than 0, so the command
header("Location:managebudget.php?e=1&pid=$pid"); *should* be executed...
but it isn't. (Weirdly, if I put a die() command *after* this header()
command, it works... but it seems pathologically inelegant to do so.)

Obviously, I'm missing something incredibly basic. Can anyone help me figure
this out?


For one thing, I'd put a space after "Location:" in the header() call.
But I've found that this call will sometimes fail (or *look* like it
fails) unless you put something like exit(); after it. This terminates
execution and forces the script to transfer control as it should. Just
make it a habit to always include and exit(); call after your final
header() call.


Just make your life easy and create a redirect() function that generates 
the header instruction, makes a relative URL into an absolute URL and 
does the exit call. Then you just need to do:


redirect( 'target.php' );

So much simpler :)

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 server am I authenticating to?

2010-01-13 Thread Hansen, Mike
Yep. I found the issue in the apache config. 

Thanks,

Mike

> -Original Message-
> From: Nathan Rixham [mailto:nrix...@gmail.com] 
> Sent: Wednesday, January 13, 2010 1:12 PM
> To: Hansen, Mike
> Cc: php-general@lists.php.net
> Subject: Re: [PHP] What server am I authenticating to?
> 
> Hansen, Mike wrote:
> >  
> > 
> >> -Original Message-
> >> From: daniel.egeb...@gmail.com 
> >> [mailto:daniel.egeb...@gmail.com] On Behalf Of Daniel Egeberg
> >> Sent: Wednesday, January 13, 2010 11:39 AM
> >> To: Hansen, Mike
> >> Cc: php-general@lists.php.net
> >> Subject: Re: [PHP] What server am I authenticating to?
> >>
> >> On Wed, Jan 13, 2010 at 19:04, Hansen, Mike 
> >>  wrote:
> >>> I took over maint of an app, and the former maintainer is 
> >> no longer available.
> >>> I was under the assumption that authentication was done 
> >> through an LDAP. How do I find out which LDAP server is 
> >> PHP/Apache using? It might be right in front of my face in 
> >> the apache config or php.ini, but I can't seem to find it. 
> >> I'm not sure what it'd be called in those config files. There 
> >> is no htaccess or htpasswd files that I could find on the 
> >> server. Below is the code that I believe does the authentication.
> >>> if (!isset($_SERVER['PHP_AUTH_USER'])) {
> >>>header('WWW-Authenticate: Basic realm="***"');
> >>>header('HTTP/1.0 401 Unauthorized');
> >>>echo 'Access denied';
> >>>exit;
> >>> }
> >>> else
> >>>
> >>>
> >>> If anyone can point me right direction, that'd be great.
> >>>
> >>> Mike
> >> Basic HTTP authentication is not using LDAP. You can use 
> PHP_AUTH_USER
> >> and PHP_AUTH_PW to verify that the credentials are correct 
> (they'll be
> >> populated with whatever the user entered). Exactly how you 
> do that is
> >> up to you (hard code it, look in a database, LDAP, etc.). You then
> >> send the 401 response code along with WWW-Authenticate if the
> >> credentials aren't satisfactory.
> >>
> >> -- 
> >> Daniel Egeberg
> >>
> > 
> > I'll do some more digging. Would the LDAP authentication be 
> happening from apache or from within PHP? The user only sees 
> a username and password dialog. If they hit cancel, they get 
> the "Access denied" which I was assuming was from this bit of code.
> > 
> > Mike
> 
> if it's ldap then most likely you should check the sites apache config
> file (apache-dir/sites-available) or .htaccess for something like..
> 
> 
> AuthType Basic
> AuthName "***"
> AuthBasicProvider ldap
> 

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



[PHP] php and XML BibTeX

2010-01-13 Thread Michael A. Peters

Hi -

Currently on my web site, book and article references are just stored in 
the database. While it works, I actually would like to move that out of 
the database and to an XML file, the reason being is that if/when I need 
to add fields etc. to the referenced sources, it's a lot easier to just 
edit a text file than modify database and recode my form interface for 
modifying the database. Also, there's an existing XML format for bibTeX 
and there already are tools to go from that to "real" bibTex, which I 
may need to do at some point.


What I'm hoping is that already exists some php classes / functions for 
dealing with the XML bibTeX but I haven't found them. Anyone know of any?


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



[PHP] Re: POLL: To add the final ?> or not...

2010-01-13 Thread Nathan Rixham
Daevid Vincent wrote:
> I'm having a debate with a co-worker about adding the final ?> on a PHP
> page...
> 
> To be honest, I am the lead, and I could pull rank and be done with the
> discussion, however I don't like to be that way. I would rather do the
> right thing. If my way of thinking is old-school (I've been coding since
> PHP/FI), and what he says is the newfangled proper PHP/Zend way, then I'd
> rather adopt that, despite how icky it makes me feel to leave an unclosed
>  behind"! :)
> 
> Is there ANY side-effects to leaving the end ?> off? Is it any more work
> for the compiler? And yes I know computers are hella-fast and all that, but
> I come from the gaming industry where squeeking out an extra FPS matters,
> and shaving off 0.01s per row of data in a table matters if you have more
> than 100 rows. A 1 second wait IS noticeable and a 10 second is even moreso
> -- just try to talk for 10 seconds straight without a pause. Or sit there
> and stare at a screen for 10 seconds!
> 
> If the main argument is that it's to prevent white-space after the code,
> then most modern editors that I'm aware of will automatically trim
> white-space (or have a setting to do so). Plus this is ONLY a factor when
> you're trying to output a header and things like that. In 90% of your code,
> you don't deal with that. It's also obvious enough when you have an extra
> character/space because PHP pukes on the screen and TELLS you something
> about "blah blah sent before header output" or something to that effect.
> 
> What do you guys all do?
> 

i negate the ?> and treat ?> purely as an instruction to tell php to
stop parsing (because that's what it is) thus for 100% php files you'll
find no ?> in my code; however when it's an html page and esacping in
and out of parser mode is required then obviously I'll use ?>

regards & sorry for the late reply

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



Re: [PHP] header("Location:...") fails

2010-01-13 Thread Paul M Foster
On Wed, Jan 13, 2010 at 11:39:18AM -0800, Richard S. Crawford wrote:

> Here is a snippet of code that is going to be the death of me:
> 
> 
> //  Create a new project
> $projectcode = strtoupper(addslashes($_POST['projectcode']));   //  project
> code
> 
> //  Make sure the project code is unique
> if (!$existingproject = mysql_query("select * from pb_versions where
> projectcode like '".strtoupper($projectcode)."'")) {
> die ("Could not check for existing project code!".mysql_error());
> }
> 
> $numprojects = mysql_num_rows($existingproject);
> 
> if ($numprojects > 0) {
> $pid = mysql_result($existingproject,0,"versionID");
> header("Location:managebudget.php?e=1&pid=$pid");
> }
> 
> 
> Now, even if $numprojects is 1, 2, 3, etc., the header() command is not
> executed. Strangely, a header("Location") command later on in the script
> *is* executed. I've output the value of $numprojects, so I know that it's
> greater than 0, so the command
> header("Location:managebudget.php?e=1&pid=$pid"); *should* be executed...
> but it isn't. (Weirdly, if I put a die() command *after* this header()
> command, it works... but it seems pathologically inelegant to do so.)
> 
> Obviously, I'm missing something incredibly basic. Can anyone help me figure
> this out?

For one thing, I'd put a space after "Location:" in the header() call.
But I've found that this call will sometimes fail (or *look* like it
fails) unless you put something like exit(); after it. This terminates
execution and forces the script to transfer control as it should. Just
make it a habit to always include and exit(); call after your final
header() call.

Paul

-- 
Paul M. Foster

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



Re: [PHP] What server am I authenticating to?

2010-01-13 Thread Nathan Rixham
Hansen, Mike wrote:
>  
> 
>> -Original Message-
>> From: daniel.egeb...@gmail.com 
>> [mailto:daniel.egeb...@gmail.com] On Behalf Of Daniel Egeberg
>> Sent: Wednesday, January 13, 2010 11:39 AM
>> To: Hansen, Mike
>> Cc: php-general@lists.php.net
>> Subject: Re: [PHP] What server am I authenticating to?
>>
>> On Wed, Jan 13, 2010 at 19:04, Hansen, Mike 
>>  wrote:
>>> I took over maint of an app, and the former maintainer is 
>> no longer available.
>>> I was under the assumption that authentication was done 
>> through an LDAP. How do I find out which LDAP server is 
>> PHP/Apache using? It might be right in front of my face in 
>> the apache config or php.ini, but I can't seem to find it. 
>> I'm not sure what it'd be called in those config files. There 
>> is no htaccess or htpasswd files that I could find on the 
>> server. Below is the code that I believe does the authentication.
>>> if (!isset($_SERVER['PHP_AUTH_USER'])) {
>>>header('WWW-Authenticate: Basic realm="***"');
>>>header('HTTP/1.0 401 Unauthorized');
>>>echo 'Access denied';
>>>exit;
>>> }
>>> else
>>>
>>>
>>> If anyone can point me right direction, that'd be great.
>>>
>>> Mike
>> Basic HTTP authentication is not using LDAP. You can use PHP_AUTH_USER
>> and PHP_AUTH_PW to verify that the credentials are correct (they'll be
>> populated with whatever the user entered). Exactly how you do that is
>> up to you (hard code it, look in a database, LDAP, etc.). You then
>> send the 401 response code along with WWW-Authenticate if the
>> credentials aren't satisfactory.
>>
>> -- 
>> Daniel Egeberg
>>
> 
> I'll do some more digging. Would the LDAP authentication be happening from 
> apache or from within PHP? The user only sees a username and password dialog. 
> If they hit cancel, they get the "Access denied" which I was assuming was 
> from this bit of code.
> 
> Mike

if it's ldap then most likely you should check the sites apache config
file (apache-dir/sites-available) or .htaccess for something like..


AuthType Basic
AuthName "***"
AuthBasicProvider ldap

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



Re: [PHP] header("Location:...") fails

2010-01-13 Thread Andrew Ballard
On Wed, Jan 13, 2010 at 2:39 PM, Richard S. Crawford
 wrote:
> Now, even if $numprojects is 1, 2, 3, etc., the header() command is not
> executed. Strangely, a header("Location") command later on in the script
> *is* executed. I've output the value of $numprojects, so I know that it's
> greater than 0, so the command
> header("Location:managebudget.php?e=1&pid=$pid"); *should* be executed...
> but it isn't. (Weirdly, if I put a die() command *after* this header()
> command, it works... but it seems pathologically inelegant to do so.)
>
> Obviously, I'm missing something incredibly basic. Can anyone help me figure
> this out?

It isn't "pathologically inelegant" at all. All the header function
does is output the header; it does not stop script execution. If you
don't stop the script yourself, it will continue to execute. You
probably want to send a message right after the header call anyway,
just in case someone is using a browser that does not handle
redirection.

Andrew

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



Re: [PHP] header("Location:...") fails

2010-01-13 Thread Bruno Fajardo
2010/1/13 Richard S. Crawford 
>
> Here is a snippet of code that is going to be the death of me:
>
> 
> //  Create a new project
> $projectcode = strtoupper(addslashes($_POST['projectcode']));   //  project
> code
>
> //  Make sure the project code is unique
> if (!$existingproject = mysql_query("select * from pb_versions where
> projectcode like '".strtoupper($projectcode)."'")) {
>    die ("Could not check for existing project code!".mysql_error());
> }
>
> $numprojects = mysql_num_rows($existingproject);
>
> if ($numprojects > 0) {
>    $pid = mysql_result($existingproject,0,"versionID");
>    header("Location:managebudget.php?e=1&pid=$pid");
> }
> 
>
> Now, even if $numprojects is 1, 2, 3, etc., the header() command is not
> executed. Strangely, a header("Location") command later on in the script
> *is* executed. I've output the value of $numprojects, so I know that it's
> greater than 0, so the command
> header("Location:managebudget.php?e=1&pid=$pid"); *should* be executed...
> but it isn't. (Weirdly, if I put a die() command *after* this header()
> command, it works... but it seems pathologically inelegant to do so.)

There's nothing in wrong in putting a die command after the
header("Location"). In fact, it is common. The header() command by
itself don't imply in the send of the request. You can have many
header() commands in sequence, and the header will be sent only in the
end of the process.

Cheers,
Bruno.

>
> Obviously, I'm missing something incredibly basic. Can anyone help me figure
> this out?
>
>
> --
> Richard S. Crawford (rscrawf...@mossroot.com)
> http://www.mossroot.com
> Publisher and Editor in Chief, Daikaijuzine (http://www.daikaijuzine.com)

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



[PHP] header("Location:...") fails

2010-01-13 Thread Richard S. Crawford
Here is a snippet of code that is going to be the death of me:


//  Create a new project
$projectcode = strtoupper(addslashes($_POST['projectcode']));   //  project
code

//  Make sure the project code is unique
if (!$existingproject = mysql_query("select * from pb_versions where
projectcode like '".strtoupper($projectcode)."'")) {
die ("Could not check for existing project code!".mysql_error());
}

$numprojects = mysql_num_rows($existingproject);

if ($numprojects > 0) {
$pid = mysql_result($existingproject,0,"versionID");
header("Location:managebudget.php?e=1&pid=$pid");
}


Now, even if $numprojects is 1, 2, 3, etc., the header() command is not
executed. Strangely, a header("Location") command later on in the script
*is* executed. I've output the value of $numprojects, so I know that it's
greater than 0, so the command
header("Location:managebudget.php?e=1&pid=$pid"); *should* be executed...
but it isn't. (Weirdly, if I put a die() command *after* this header()
command, it works... but it seems pathologically inelegant to do so.)

Obviously, I'm missing something incredibly basic. Can anyone help me figure
this out?


-- 
Richard S. Crawford (rscrawf...@mossroot.com)
http://www.mossroot.com
Publisher and Editor in Chief, Daikaijuzine (http://www.daikaijuzine.com)


RE: [PHP] What server am I authenticating to?

2010-01-13 Thread Hansen, Mike
 

> -Original Message-
> From: daniel.egeb...@gmail.com 
> [mailto:daniel.egeb...@gmail.com] On Behalf Of Daniel Egeberg
> Sent: Wednesday, January 13, 2010 11:39 AM
> To: Hansen, Mike
> Cc: php-general@lists.php.net
> Subject: Re: [PHP] What server am I authenticating to?
> 
> On Wed, Jan 13, 2010 at 19:04, Hansen, Mike 
>  wrote:
> > I took over maint of an app, and the former maintainer is 
> no longer available.
> >
> > I was under the assumption that authentication was done 
> through an LDAP. How do I find out which LDAP server is 
> PHP/Apache using? It might be right in front of my face in 
> the apache config or php.ini, but I can't seem to find it. 
> I'm not sure what it'd be called in those config files. There 
> is no htaccess or htpasswd files that I could find on the 
> server. Below is the code that I believe does the authentication.
> >
> > if (!isset($_SERVER['PHP_AUTH_USER'])) {
> >header('WWW-Authenticate: Basic realm="***"');
> >header('HTTP/1.0 401 Unauthorized');
> >echo 'Access denied';
> >exit;
> > }
> > else
> >
> >
> > If anyone can point me right direction, that'd be great.
> >
> > Mike
> 
> Basic HTTP authentication is not using LDAP. You can use PHP_AUTH_USER
> and PHP_AUTH_PW to verify that the credentials are correct (they'll be
> populated with whatever the user entered). Exactly how you do that is
> up to you (hard code it, look in a database, LDAP, etc.). You then
> send the 401 response code along with WWW-Authenticate if the
> credentials aren't satisfactory.
> 
> -- 
> Daniel Egeberg
> 

I'll do some more digging. Would the LDAP authentication be happening from 
apache or from within PHP? The user only sees a username and password dialog. 
If they hit cancel, they get the "Access denied" which I was assuming was from 
this bit of code.

Mike

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



Re: [PHP] Detecting a BOM

2010-01-13 Thread Daniel Egeberg
On Wed, Jan 13, 2010 at 11:42, Leszek Stachowski  wrote:
> Hi,
>
> is there any way to detect BOM in a file? I'm writing a parser which outputs
> a number line if there's an error in it and its content. Every time it
> parser a file saved in UTF-8 with BOM it outputs those three magic letters.
> Can I pre-check for it and skip it? Or convert somehow?
>
> Greetings,
> Leszek Stachowski

The UTF-8 byte order mark is represented by the hexadecimal character
sequence EF BB BF. You can use something like this to detect a BOM:

if (substr($source, 0, 3) == pack('CCC', 0xEF, 0xBB, 0xBF)) {
// has bom
}

-- 
Daniel Egeberg

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



Re: [PHP] What server am I authenticating to?

2010-01-13 Thread Daniel Egeberg
On Wed, Jan 13, 2010 at 19:04, Hansen, Mike  wrote:
> I took over maint of an app, and the former maintainer is no longer available.
>
> I was under the assumption that authentication was done through an LDAP. How 
> do I find out which LDAP server is PHP/Apache using? It might be right in 
> front of my face in the apache config or php.ini, but I can't seem to find 
> it. I'm not sure what it'd be called in those config files. There is no 
> htaccess or htpasswd files that I could find on the server. Below is the code 
> that I believe does the authentication.
>
> if (!isset($_SERVER['PHP_AUTH_USER'])) {
>header('WWW-Authenticate: Basic realm="***"');
>header('HTTP/1.0 401 Unauthorized');
>echo 'Access denied';
>exit;
> }
> else
>
>
> If anyone can point me right direction, that'd be great.
>
> Mike

Basic HTTP authentication is not using LDAP. You can use PHP_AUTH_USER
and PHP_AUTH_PW to verify that the credentials are correct (they'll be
populated with whatever the user entered). Exactly how you do that is
up to you (hard code it, look in a database, LDAP, etc.). You then
send the 401 response code along with WWW-Authenticate if the
credentials aren't satisfactory.

-- 
Daniel Egeberg

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



[PHP] What server am I authenticating to?

2010-01-13 Thread Hansen, Mike
I took over maint of an app, and the former maintainer is no longer available.  

I was under the assumption that authentication was done through an LDAP. How do 
I find out which LDAP server is PHP/Apache using? It might be right in front of 
my face in the apache config or php.ini, but I can't seem to find it. I'm not 
sure what it'd be called in those config files. There is no htaccess or 
htpasswd files that I could find on the server. Below is the code that I 
believe does the authentication.  

if (!isset($_SERVER['PHP_AUTH_USER'])) {
header('WWW-Authenticate: Basic realm="***"');  
header('HTTP/1.0 401 Unauthorized');
echo 'Access denied';   
exit; 
} 
else  


If anyone can point me right direction, that'd be great.   

Mike 

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



Re: [PHP] POLL: To add the final ?> or not...

2010-01-13 Thread Bipper Goes!
You could also sit on the egg.

On Tue, Jan 12, 2010 at 3:41 PM, tedd  wrote:

> At 3:49 PM -0500 1/12/10, Robert Cummings wrote:
>
>> tedd wrote:
>>
>>> At 5:24 PM + 1/12/10, Ashley Sheridan wrote:
>>>
 On Tue, 2010-01-12 at 12:22 -0500, Robert Cummings wrote:

>>>
>>> -- egg snip-its
>>>
>>> While on the subject of eggs and other non-php topics, here's a life
>>> trick.
>>>
>>> If you don't know if an egg is hard-boiled, or not, try spinning it. A
>>> hard-boiled egg will spin while a raw egg will not.
>>>
>>
>> I didn't bother to try, but knowing about physics and fluids, I'm going to
>> argue that your assertion is untrue. The raw egg will spin but will quickly
>> slow down due to the internal drag of the viscous contents that will be
>> spinning at a much slower rate. In contrast the hard boiled egg will not
>> have this internal drag.
>>
>> Cheers,
>> Rob.
>>
>
> Truth is relative when debating the spin of an egg. Of course, just about
> everything you can hold, you can spin to some degree.
>
> The point being, if you want a quick way to determine if an egg is
> hard-boiled, or not, then spinning it will provide convincing evidence as to
> which it is. The truth will be shown to those who try.
>
>
> 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] Read directory; store filenames found in mySQL table? :: SOLVED!!

2010-01-13 Thread Rahul S. Johari


Thanks All (Especially Warren); Final Code:

function dirList ($directory) {
   $results = array();
   $handler = opendir($directory);
   while ($file = readdir($handler)) {
   if ($file != '.' && $file != '..')
   $results[] = $file;
   }
   closedir($handler);
   return $results;
}

$origin = "pathto/images/";

#load file listing into an array
$shell = shell_exec("du $origin");
$array  = array_reverse(explode("\n",$shell));
$contIdArr = array();

$newArr = array();
foreach($array as $elem){
   $newDir = "";
   $pathArray = explode("/", $elem);
   $nodeDepth = count($pathArray);
   for($count=1; $count<$nodeDepth; $count++){
   $newDir = $newDir.$pathArray[$count].'/';
   }
   $newArr[] = '/'.$newDir;
}
sort($newArr);

foreach($newArr as $dir){
   $pathArray = explode("/", $dir);
   $fileListArr = dirList($dir);
}

$db = mysql_connect("localhost","usr","pwd");
mysql_select_db("db",$db);

foreach($fileListArr AS $value) {
$sql="INSERT INTO r2 (ID, RECORDING) VALUES('','$value')";
$result = mysql_query($sql) or die (mysql_error());
}


---
Rahul Sitaram Johari
Founder, Internet Architects Group, Inc.

[Email] sleepwal...@rahulsjohari.com
[Web]   http://www.rahulsjohari.com





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



Re: [PHP] Read directory; store filenames found in mySQL table?

2010-01-13 Thread Rahul S. Johari


On Jan 13, 2010, at 10:40 AM, Rahul S. Johari wrote:



On Jan 13, 2010, at 9:50 AM, Warren Windvogel wrote:


On 2010/01/13 04:25 PM, Rahul S. Johari wrote:

Ave,

This is what I'm trying to do; I want to read a directory (eg: W: 
\Test\) and take all the filenames found in the directory (eg:  
1.vox, 2.wav, 3.txt) and store them in  a simple mySQL table.


Can I do this?
I tried to very quickly convert something I've done. It may need  
some work. Will work in  linux env.


$origin = "Path"

#load file listing into an array
$shell = shell_exec("du $origin");
$array  = array_reverse(explode("\n",$shell));
$contIdArr = array();

$newArr = array();
foreach($array as $elem){
  $newDir = "";
  $pathArray = explode("/", $elem);
  $nodeDepth = count($pathArray);
  for($count=1; $count<$nodeDepth; $count++){
  $newDir = $newDir.$pathArray[$count].'/';
  }
  $newArr[] = '/'.$newDir;
}
sort($newArr);


foreach($newArr as $dir){
  $pathArray = explode("/", $dir);

  $fileListArr = dirList($dir);

  foreach($fileListArr as $file){
  //Insert file($file) and current dir/path($dir) into db
  }
}

Kind regards
Warren




Warren,

I tried using your code and it definitely is very efficient & fast;  
however I'm running into a small problem and I'm not sure how to  
correct it. I'm getting the array with filenames from the folder I'm  
searching in PLUS all the root folders of the machine as well.


This is the code I'm using (note that I'm just echoing the array  
right now; I'll move to inserting data into mySQL after):


function dirList ($directory) {
  $results = array();
  $handler = opendir($directory);
  while ($file = readdir($handler)) {
  if ($file != '.' && $file != '..')
  $results[] = $file;
  }
  closedir($handler);
  return $results;
}

$origin = "/Library/WebServer/Documents/folder1/folder2/images/";

#load file listing into an array
$shell = shell_exec("du $origin");
$array  = array_reverse(explode("\n",$shell));
$contIdArr = array();

$newArr = array();
foreach($array as $elem){
  $newDir = "";
  $pathArray = explode("/", $elem);
  $nodeDepth = count($pathArray);
  for($count=1; $count<$nodeDepth; $count++){
  $newDir = $newDir.$pathArray[$count].'/';
  }
  $newArr[] = '/'.$newDir;
}
sort($newArr);

foreach($newArr as $dir){
  $pathArray = explode("/", $dir);
  $fileListArr = dirList($dir);

  foreach($fileListArr as $file){
echo $file."";
  //Insert file($file) and current dir/path($dir) into db
  }
}


As an output ... i get a list of all the files in the "images"  
folder preceeded by the all the list of root folders on my machine!!  
How do I eliminate the list of root folders?



Nevermind, I was looking at the wrong output. I got it!! I've got all  
my filenames in my $fileListArr[] array!!

Now I just to get the values in a mySQL table.


---
Rahul Sitaram Johari
Founder, Internet Architects Group, Inc.

[Email] sleepwal...@rahulsjohari.com
[Web]   http://www.rahulsjohari.com





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



Re: [PHP] Read directory; store filenames found in mySQL table?

2010-01-13 Thread Rahul S. Johari


On Jan 13, 2010, at 9:50 AM, Warren Windvogel wrote:


On 2010/01/13 04:25 PM, Rahul S. Johari wrote:

Ave,

This is what I'm trying to do; I want to read a directory (eg: W: 
\Test\) and take all the filenames found in the directory (eg:  
1.vox, 2.wav, 3.txt) and store them in  a simple mySQL table.


Can I do this?
I tried to very quickly convert something I've done. It may need  
some work. Will work in  linux env.


$origin = "Path"

#load file listing into an array
$shell = shell_exec("du $origin");
$array  = array_reverse(explode("\n",$shell));
$contIdArr = array();

$newArr = array();
foreach($array as $elem){
   $newDir = "";
   $pathArray = explode("/", $elem);
   $nodeDepth = count($pathArray);
   for($count=1; $count<$nodeDepth; $count++){
   $newDir = $newDir.$pathArray[$count].'/';
   }
   $newArr[] = '/'.$newDir;
}
sort($newArr);


foreach($newArr as $dir){
   $pathArray = explode("/", $dir);

   $fileListArr = dirList($dir);

   foreach($fileListArr as $file){
   //Insert file($file) and current dir/path($dir) into db
   }
}

Kind regards
Warren




Warren,

I tried using your code and it definitely is very efficient & fast;  
however I'm running into a small problem and I'm not sure how to  
correct it. I'm getting the array with filenames from the folder I'm  
searching in PLUS all the root folders of the machine as well.


This is the code I'm using (note that I'm just echoing the array right  
now; I'll move to inserting data into mySQL after):


function dirList ($directory) {
   $results = array();
   $handler = opendir($directory);
   while ($file = readdir($handler)) {
   if ($file != '.' && $file != '..')
   $results[] = $file;
   }
   closedir($handler);
   return $results;
}

$origin = "/Library/WebServer/Documents/folder1/folder2/images/";

#load file listing into an array
$shell = shell_exec("du $origin");
$array  = array_reverse(explode("\n",$shell));
$contIdArr = array();

$newArr = array();
foreach($array as $elem){
   $newDir = "";
   $pathArray = explode("/", $elem);
   $nodeDepth = count($pathArray);
   for($count=1; $count<$nodeDepth; $count++){
   $newDir = $newDir.$pathArray[$count].'/';
   }
   $newArr[] = '/'.$newDir;
}
sort($newArr);

foreach($newArr as $dir){
   $pathArray = explode("/", $dir);
   $fileListArr = dirList($dir);

   foreach($fileListArr as $file){
echo $file."";
   //Insert file($file) and current dir/path($dir) into db
   }
}


As an output ... i get a list of all the files in the "images" folder  
preceeded by the all the list of root folders on my machine!! How do I  
eliminate the list of root folders?


---
Rahul Sitaram Johari
Founder, Internet Architects Group, Inc.

[Email] sleepwal...@rahulsjohari.com
[Web]   http://www.rahulsjohari.com





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



RE: [PHP] RE: Clean PHP 5.2.12 Build Core Dumping / Can't Build Port - FreeBSD 6.1

2010-01-13 Thread Don O'Neil
> ===
> I try a 'make all-depend-list'
> the error shows up
> =
> which error show ?

# make
X11BASE is now deprecated.  Unset X11BASE in make.conf and try again.
*** Error code 1

Stop.

That's the error... happens every time, no matter what I try to set/unset in
/etc/make.conf. I looked through the makefiles to see where X11BASE is
referenced and I can't find any place where it is to just kill it.

> > This is _exactly_ what I did, and as soon as I try a 'make all-
> depend-list'
> > the error shows up. I don't even have the X11 system installed (it's
> a
> > headless server, with no GUI).
> >
> > This is on a CLEAN 6.1 install, without any upgrades/patches, just
> straight
> > off the ISO install and after a portsnap install/extract.
> >
> > I tried building it _before_ I updated the ports and it would build a
> 5.1.2
> > php ok, but I need 5.2.12. Something has changed in the port between
> 5.1.2
> > and 5.2.12
> >
> >> 1.add
> >> WITHOUT_X11=yes
> >> in /etc/make.conf
> >> 2.remove
> >> X11BASE=""
> >> from that file and
> >>
> >> 4.make all-depend-list
> >> 5.make clean all depend soft
> >> 6.make menuconfig set X11 disable
> >> 7.make &&make install
> >>
> >>
> >> 2010/1/12 Don O'Neil :
> >> > Ok.. just for grins I installed a new instance of 6.1, NO Patches,
> >> just
> >> > straight off the ISO...
> >> >
> >> > I loaded the ports that came WITH the distro, and was able to make
> >> php 5.1.2
> >> > ok...
> >> >
> >> > When I did a portsnap fetch, portsnap extract, then went into the
> >> > /usr/ports/lang/php5 and just typed make I get the same error...
> >> >
> >> > SO as it seems, the port is broken, at least for working with
> FreeBSD
> >> 6.1.
> >> >
> >> > Can anyone give me some hints on how to build this sucker by hand?
> >> Seems as
> >> > though there are a bunch of patches that are referenced in the
> >> distinfo
> >> > file.
> >> >
> >> > I REALLY need to get this taken care of asap, any help is
> >> appreciated.
> >> >
> >> > Thanks!
> >> >
> >> >> > > I tried adding WITHOUT_X11=yes to /etc/make.conf as well as
> >> >> X11BASE=
> >> >> > and
> >> >> > > X11BASE="", but I still get the same error.
> >> >> >
> >> >> > Remove them. This makes sure they are not defined, not even
> >> >> > empty (as in "#define BLA -> symbol 'BLA' is defined").
> >> >> >
> >> >> > > Where to go from here? Do I have and old version of something
> >> that
> >> >> is
> >> >> > > causing this? I get this error _right away_ before anything
> is
> >> even
> >> >> > built.
> >> >> >
> >> >> > It seems to be a check by the Makefile at port's top level.
> >> >>
> >> >> Ok... I have no definition for X11BASE anywhere, not in my env,
> not
> >> in
> >> >> my
> >> >> /etc/make.conf, nowhwere...
> >> >>
> >> >> However, it's still complaining about X11BASE being deprecated. I
> >> tried
> >> >> just
> >> >> adding WITHOUT_X11=yes in /etc/make, and without it. I even
> searched
> >> >> all the
> >> >> Makefiles in /usr/ports, and in the /usr/ports/lang/php5 dir to
> find
> >> >> any
> >> >> reference to X11, or X, or X11BASE, but nada... I don't even know
> >> where
> >> >> this
> >> >> error message is being generated from.
> >> >>
> >> >> I can't even do a basic make without it immediately spitting out
> the
> >> >> error:
> >> >>
> >> >> # make
> >> >> X11BASE is now deprecated.  Unset X11BASE in make.conf and try
> >> again.
> >> >> *** Error code 1
> >> >>
> >> >> Stop.


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



Re: [PHP] Read directory; store filenames found in mySQL table?

2010-01-13 Thread Rahul S. Johari


On Jan 13, 2010, at 10:07 AM, Kenneth Sande wrote:



Ashley Sheridan wrote:

On Wed, 2010-01-13 at 09:25 -0500, Rahul S. Johari wrote:



Ave,

This is what I'm trying to do; I want to read a directory (eg: W: 
\Test \) and take all the filenames found in the directory (eg:  
1.vox,  2.wav, 3.txt) and store them in  a simple mySQL table.


Can I do this?

---
Rahul Sitaram Johari
Founder, Internet Architects Group, Inc.

[Email] sleepwal...@rahulsjohari.com
[Web]   http://www.rahulsjohari.com









You'll probably want to look at the readdir() function. The manual  
page
also has dozens of different example scripts that would be easy to  
tweak

for your purpose.

http://php.net/manual/en/function.readdir.php


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




I use the glob function in my little homemade "web cam" page, which  
can really swell up in memory when used against a large amount of  
files (in my case around 30k files).

=
$imgdir = 'img/south*';
$files = glob( $imgdir );

// Sort files by modified time, latest to earliest
// Use SORT_ASC in place of SORT_DESC for earliest to latest
array_multisort( array_map( 'filemtime', $files ), SORT_NUMERIC,  
SORT_DESC, $files );

=
http://www.php.net/manual/en/function.glob.php
DISCLAIMER: I found this code on a how-to somewhere out there and  
modified it to fit my need. Quite possibly there are much better  
means to this end.


Ken Sande/KC8QNI





Considering that I have over 80K files in the folder, would this be a  
faster/efficient then the readdir() method? Or should I stick to what  
I'm doing (other email)?


---
Rahul Sitaram Johari
Founder, Internet Architects Group, Inc.

[Email] sleepwal...@rahulsjohari.com
[Web]   http://www.rahulsjohari.com





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



Re: [PHP] Read directory; store filenames found in mySQL table?

2010-01-13 Thread Rahul S. Johari


On Jan 13, 2010, at 9:56 AM, Warren Windvogel wrote:


On 2010/01/13 04:25 PM, Rahul S. Johari wrote:

Ave,

This is what I'm trying to do; I want to read a directory (eg: W: 
\Test\) and take all the filenames found in the directory (eg:  
1.vox, 2.wav, 3.txt) and store them in  a simple mySQL table.




Sorry. Forgot to include this.

function dirList ($directory)
{

   // create an array to hold directory list
   $results = array();

   // create a handler for the directory
   $handler = opendir($directory);

   // keep going until all files in directory have been read
   while ($file = readdir($handler)) {

   // if $file isn't this directory or its parent,
   // add it to the results array
   if ($file != '.' && $file != '..')
   $results[] = $file;
   }

   // tidy up: close the handler
   closedir($handler);

   // done!
   return $results;

}

If you're dealing with 1 directory you can use it to read all files  
in it to an array.


Kind regards
Warren




This is an interesting approach. Following is what I came up with to  
scan a directory and store the filenames into an array ... very  
similar to your example:


   $listDir = array();
$dir = "../mounts/wd/IDT/IDT/";
if($handler = opendir($dir)) {
while (($sub = readdir($handler)) !== FALSE) {
if ($sub != "." && $sub != ".." && $sub !=  
"Thumb.db") {

if(is_file($dir."/".$sub)) {
$listDir[] = $sub;
}elseif(is_dir($dir."/".$sub)){
$listDir[$sub] = $this- 
>ReadFolderDirectory($dir."/".$sub);

}
}
}
closedir($handler);
}

and this is what I'm trying to implement in order to store the array  
into a mysql table ..


$db = mysql_connect("localhost","usr","pwd");
mysql_select_db("db",$db);
			$colors=serialize($listDir); //takes the data from a post  
operation...
			$sql="INSERT INTO recordings (ID, RECORDING, ADDED)  
VALUES('','$colors','')";

$result = mysql_query($sql) or die (mysql_error());

I'm not sure if this the best or fastest approach ... but it's running  
in the background as I write this (I should have tested on a smaller  
folder). The folder I'm scanning has literally over 80,000 files ...  
so it's taking LOOONG!!


---
Rahul Sitaram Johari
Founder, Internet Architects Group, Inc.

[Email] sleepwal...@rahulsjohari.com
[Web]   http://www.rahulsjohari.com





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



Re: [PHP] Read directory; store filenames found in mySQL table?

2010-01-13 Thread Kenneth Sande


Ashley Sheridan wrote:

On Wed, 2010-01-13 at 09:25 -0500, Rahul S. Johari wrote:

  

Ave,

This is what I'm trying to do; I want to read a directory (eg: W:\Test 
\) and take all the filenames found in the directory (eg: 1.vox,  
2.wav, 3.txt) and store them in  a simple mySQL table.


Can I do this?

---
Rahul Sitaram Johari
Founder, Internet Architects Group, Inc.

[Email] sleepwal...@rahulsjohari.com
[Web]   http://www.rahulsjohari.com









You'll probably want to look at the readdir() function. The manual page
also has dozens of different example scripts that would be easy to tweak
for your purpose.

http://php.net/manual/en/function.readdir.php


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



  
I use the glob function in my little homemade "web cam" page, which can 
really swell up in memory when used against a large amount of files (in 
my case around 30k files).

=
$imgdir = 'img/south*';
$files = glob( $imgdir );

// Sort files by modified time, latest to earliest
// Use SORT_ASC in place of SORT_DESC for earliest to latest
array_multisort( array_map( 'filemtime', $files ), SORT_NUMERIC, 
SORT_DESC, $files );

=
http://www.php.net/manual/en/function.glob.php
DISCLAIMER: I found this code on a how-to somewhere out there and 
modified it to fit my need. Quite possibly there are much better means 
to this end.


Ken Sande/KC8QNI


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



Re: [PHP] Read directory; store filenames found in mySQL table?

2010-01-13 Thread Ashley Sheridan
On Wed, 2010-01-13 at 09:25 -0500, Rahul S. Johari wrote:

> Ave,
> 
> This is what I'm trying to do; I want to read a directory (eg: W:\Test 
> \) and take all the filenames found in the directory (eg: 1.vox,  
> 2.wav, 3.txt) and store them in  a simple mySQL table.
> 
> Can I do this?
> 
> ---
> Rahul Sitaram Johari
> Founder, Internet Architects Group, Inc.
> 
> [Email]   sleepwal...@rahulsjohari.com
> [Web] http://www.rahulsjohari.com
> 
> 
> 
> 
> 


You'll probably want to look at the readdir() function. The manual page
also has dozens of different example scripts that would be easy to tweak
for your purpose.

http://php.net/manual/en/function.readdir.php


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




[PHP] Read directory; store filenames found in mySQL table?

2010-01-13 Thread Rahul S. Johari

Ave,

This is what I'm trying to do; I want to read a directory (eg: W:\Test 
\) and take all the filenames found in the directory (eg: 1.vox,  
2.wav, 3.txt) and store them in  a simple mySQL table.


Can I do this?

---
Rahul Sitaram Johari
Founder, Internet Architects Group, Inc.

[Email] sleepwal...@rahulsjohari.com
[Web]   http://www.rahulsjohari.com





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



Re: [PHP] Need Idea to make Backup

2010-01-13 Thread Ashley Sheridan
On Wed, 2010-01-13 at 14:57 +0100, Jens Geier wrote:

> Hello Ashley,
> 
> yes rsync is a good idea, but does this also work if there is only a 
> internet conection to may SERVER ?
> 
> Kind Regards
> Jens Geier
> 
> "Ashley Sheridan"  schrieb im Newsbeitrag 
> news:1263377397.5952.60.ca...@localhost...
> > On Wed, 2010-01-13 at 10:53 +0100, Jens Geier wrote:
> >
> >> Hello,
> >>
> >> my idea is to make a backup of some paths of my laptop via PHP.
> >>
> >> I like to use a MySQL Datebase to trace which file was uploaded from 
> >> which
> >> path and so on.
> >>
> >> Also it should be uses to look up it is nessasery to backup this file
> >> because it was changed since last time or not.
> >>
> >> All this files should be uploaded to the SERVER in a special folder where
> >> this files run to a tape backup machine.
> >>
> >> I hope some one can give me some ideas for this.
> >>
> >> Kind Regards
> >> Jens Geier
> >>
> >>
> >>
> >>
> >
> >
> > There's a few ways to go about doing this, but I reckon you should do
> > something similar to the following:
> >
> >
> >  * schedule a cron job to run as often as you want the backup to be
> >done, and have the cron call a script
> >  * the script can either be php and use your own code to create
> >copies of files and check file dates for backup purposes, or use
> >the rsync tool which pretty much does all of this for you
> >automatically
> >  * update a database as you need. this can be done either from a
> >php script or directly via mysql on the console
> >
> >
> > If you do use PHP for this, you'll want to code it as a CLI script
> > rather than a web page script. On the whole it won't make much of a
> > difference, but obviously some global variables will change a bit.
> >
> > Thanks,
> > Ash
> > http://www.ashleysheridan.co.uk
> >
> >
> > 
> 
> 
> 


I don't understand what you mean? 

Ps, please try not to top-post.

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




Re: [PHP] Need Idea to make Backup

2010-01-13 Thread Jens Geier
Hello Ashley,

yes rsync is a good idea, but does this also work if there is only a 
internet conection to may SERVER ?

Kind Regards
Jens Geier

"Ashley Sheridan"  schrieb im Newsbeitrag 
news:1263377397.5952.60.ca...@localhost...
> On Wed, 2010-01-13 at 10:53 +0100, Jens Geier wrote:
>
>> Hello,
>>
>> my idea is to make a backup of some paths of my laptop via PHP.
>>
>> I like to use a MySQL Datebase to trace which file was uploaded from 
>> which
>> path and so on.
>>
>> Also it should be uses to look up it is nessasery to backup this file
>> because it was changed since last time or not.
>>
>> All this files should be uploaded to the SERVER in a special folder where
>> this files run to a tape backup machine.
>>
>> I hope some one can give me some ideas for this.
>>
>> Kind Regards
>> Jens Geier
>>
>>
>>
>>
>
>
> There's a few ways to go about doing this, but I reckon you should do
> something similar to the following:
>
>
>  * schedule a cron job to run as often as you want the backup to be
>done, and have the cron call a script
>  * the script can either be php and use your own code to create
>copies of files and check file dates for backup purposes, or use
>the rsync tool which pretty much does all of this for you
>automatically
>  * update a database as you need. this can be done either from a
>php script or directly via mysql on the console
>
>
> If you do use PHP for this, you'll want to code it as a CLI script
> rather than a web page script. On the whole it won't make much of a
> difference, but obviously some global variables will change a bit.
>
> 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] RE: Clean PHP 5.2.12 Build Core Dumping / Can't Build Port - FreeBSD 6.1

2010-01-13 Thread hack988 hack988
===
I try a 'make all-depend-list'
the error shows up
=
which error show ?

2010/1/13 Don O'Neil :
> This is _exactly_ what I did, and as soon as I try a 'make all-depend-list'
> the error shows up. I don't even have the X11 system installed (it's a
> headless server, with no GUI).
>
> This is on a CLEAN 6.1 install, without any upgrades/patches, just straight
> off the ISO install and after a portsnap install/extract.
>
> I tried building it _before_ I updated the ports and it would build a 5.1.2
> php ok, but I need 5.2.12. Something has changed in the port between 5.1.2
> and 5.2.12
>
>> 1.add
>> WITHOUT_X11=yes
>> in /etc/make.conf
>> 2.remove
>> X11BASE=""
>> from that file and
>>
>> 4.make all-depend-list
>> 5.make clean all depend soft
>> 6.make menuconfig set X11 disable
>> 7.make &&make install
>>
>>
>> 2010/1/12 Don O'Neil :
>> > Ok.. just for grins I installed a new instance of 6.1, NO Patches,
>> just
>> > straight off the ISO...
>> >
>> > I loaded the ports that came WITH the distro, and was able to make
>> php 5.1.2
>> > ok...
>> >
>> > When I did a portsnap fetch, portsnap extract, then went into the
>> > /usr/ports/lang/php5 and just typed make I get the same error...
>> >
>> > SO as it seems, the port is broken, at least for working with FreeBSD
>> 6.1.
>> >
>> > Can anyone give me some hints on how to build this sucker by hand?
>> Seems as
>> > though there are a bunch of patches that are referenced in the
>> distinfo
>> > file.
>> >
>> > I REALLY need to get this taken care of asap, any help is
>> appreciated.
>> >
>> > Thanks!
>> >
>> >> > > I tried adding WITHOUT_X11=yes to /etc/make.conf as well as
>> >> X11BASE=
>> >> > and
>> >> > > X11BASE="", but I still get the same error.
>> >> >
>> >> > Remove them. This makes sure they are not defined, not even
>> >> > empty (as in "#define BLA -> symbol 'BLA' is defined").
>> >> >
>> >> > > Where to go from here? Do I have and old version of something
>> that
>> >> is
>> >> > > causing this? I get this error _right away_ before anything is
>> even
>> >> > built.
>> >> >
>> >> > It seems to be a check by the Makefile at port's top level.
>> >>
>> >> Ok... I have no definition for X11BASE anywhere, not in my env, not
>> in
>> >> my
>> >> /etc/make.conf, nowhwere...
>> >>
>> >> However, it's still complaining about X11BASE being deprecated. I
>> tried
>> >> just
>> >> adding WITHOUT_X11=yes in /etc/make, and without it. I even searched
>> >> all the
>> >> Makefiles in /usr/ports, and in the /usr/ports/lang/php5 dir to find
>> >> any
>> >> reference to X11, or X, or X11BASE, but nada... I don't even know
>> where
>> >> this
>> >> error message is being generated from.
>> >>
>> >> I can't even do a basic make without it immediately spitting out the
>> >> error:
>> >>
>> >> # make
>> >> X11BASE is now deprecated.  Unset X11BASE in make.conf and try
>> again.
>> >> *** Error code 1
>> >>
>> >> Stop.
>> >>
>> >
>> >
>> > --
>> > 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
>>
>> No virus found in this incoming message.
>> Checked by AVG - www.avg.com
>> Version: 9.0.725 / Virus Database: 270.14.136/2616 - Release Date:
>> 01/11/10 23:35:00
>
>

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



[PHP] Re: [PHP-DEV] any solution about array_walk with pass-by-reference UseData?

2010-01-13 Thread hack988 hack988
Online document say's
Note: Please note that this function only checks one dimension of a
n-dimensional array. Of course you can check deeper dimensions by
using, for example, array_udiff_uassoc($array1[0], $array2[0],
"data_compare_func", "key_compare_func");.

It's not my needed

My need is
$disable_full=array("a","b","c");
$disable_start=array("_","HTTP");

$check_array=array(array("http"=>"a"),"a"=>"dabdd");


I want to unset all element's key full match in $disable_full and
start with string in $disable_start array;

2010/1/13 Joey Smith :
> This might be better served by taking it to php-general, because I don't
> think you need to pin your question so hard to the behaviour of
> array_walk(). Here's a quick example of (if I understood your question
> correctly) how you might solve it using array_udiff_uassoc and 5.3's new
> 'closure' syntax (not required for this, but I do so enjoy using them!)
>
>  $return=array();
> $disable_full=array('a','b','c');
> $disable_start=array('_','!','HTTP'/*,'ddd','ddd','ddd','ddd','ddd'*/);
> $check_array=array("a"=>1,"_POST"=>'c',"HTTP"=>"f","ddd"=>array('fefe'));
>
> function buildFilter($keys, $starts_with) {
>   return function ($a, $b) use ($keys, $starts_with) {
>      if (in_array($a, $keys)) return 0;
>      foreach($starts_with as $value) if (strpos($a, $value)===0) return 0;
>      return 1;
>   };
> }
>
> $foo = buildFilter($disable_full, $disable_start);
>
> var_dump(array_udiff_uassoc($check_array, $disable_full, $disable_start, 
> function () { return 0; }, $foo));
>
>

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



[PHP] Detecting a BOM

2010-01-13 Thread Leszek Stachowski
Hi,

is there any way to detect BOM in a file? I'm writing a parser which outputs
a number line if there's an error in it and its content. Every time it
parser a file saved in UTF-8 with BOM it outputs those three magic letters.
Can I pre-check for it and skip it? Or convert somehow?

Greetings,
Leszek Stachowski


Re: [PHP] Need Idea to make Backup

2010-01-13 Thread Ashley Sheridan
On Wed, 2010-01-13 at 10:53 +0100, Jens Geier wrote:

> Hello,
> 
> my idea is to make a backup of some paths of my laptop via PHP.
> 
> I like to use a MySQL Datebase to trace which file was uploaded from which
> path and so on.
> 
> Also it should be uses to look up it is nessasery to backup this file
> because it was changed since last time or not.
> 
> All this files should be uploaded to the SERVER in a special folder where
> this files run to a tape backup machine.
> 
> I hope some one can give me some ideas for this.
> 
> Kind Regards
> Jens Geier
> 
> 
> 
> 


There's a few ways to go about doing this, but I reckon you should do
something similar to the following:


  * schedule a cron job to run as often as you want the backup to be
done, and have the cron call a script
  * the script can either be php and use your own code to create
copies of files and check file dates for backup purposes, or use
the rsync tool which pretty much does all of this for you
automatically
  * update a database as you need. this can be done either from a
php script or directly via mysql on the console


If you do use PHP for this, you'll want to code it as a CLI script
rather than a web page script. On the whole it won't make much of a
difference, but obviously some global variables will change a bit.

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




[PHP] Need Idea to make Backup

2010-01-13 Thread Jens Geier
Hello,

my idea is to make a backup of some paths of my laptop via PHP.

I like to use a MySQL Datebase to trace which file was uploaded from which
path and so on.

Also it should be uses to look up it is nessasery to backup this file
because it was changed since last time or not.

All this files should be uploaded to the SERVER in a special folder where
this files run to a tape backup machine.

I hope some one can give me some ideas for this.

Kind Regards
Jens Geier




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