[PHP] Remote MySQL Connecton Problems

2009-05-06 Thread Ray Hauge

Hello everyone,

I've run into a bit of a sticky situation trying to connect to a remote 
MySQL database.  Here's the background:


Connecting from the command line on the web server works.

Connecting from a different vhost works.

There's no information in mysql_error.  In fact, mysql_select_db('db') 
or die(mysql_error()); doesn't produce any output.


The only way I know this isn't working is when I try to run a query, the 
result resource is NULL.


If I copy the contents of the query and run it on the command line, from 
the web server, I get the results I expected.


I manage both servers.  I added the new login on the MySQL server and 
also ran flush privileges.  I've gone so far as to reboot both the MySQL 
process and the apache process.


The versions of MySQL are slightly different 5.0.24a (web) vs 5.0.36(db).

It's getting late and I'm just grasping for straws.

Thanks!
Ray

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



[PHP] Re: Remote MySQL Connecton Problems

2009-05-07 Thread Ray Hauge

Nathan Rixham wrote:

Ray Hauge wrote:

Hello everyone,

I've run into a bit of a sticky situation trying to connect to a 
remote MySQL database.  Here's the background:


Connecting from the command line on the web server works.

Connecting from a different vhost works.

There's no information in mysql_error.  In fact, mysql_select_db('db') 
or die(mysql_error()); doesn't produce any output.


The only way I know this isn't working is when I try to run a query, 
the result resource is NULL.


If I copy the contents of the query and run it on the command line, 
from the web server, I get the results I expected.


I manage both servers.  I added the new login on the MySQL server and 
also ran flush privileges.  I've gone so far as to reboot both the 
MySQL process and the apache process.


The versions of MySQL are slightly different 5.0.24a (web) vs 5.0.36(db).

It's getting late and I'm just grasping for straws.

Thanks!
Ray


and thus:
database server works - yes
user and login works locally - yes
user and login works remotely - yes
user and login works on box in question - yes

further debug:
do mysql connections work for any host at all in php? - todo
is the mysql module for php installed - todo check phpinfo() output
is error reporting enabled - todo set error_reporting to E_ALL
does a simple query such as "show databases" return any results
is query properly formatted and are variables properly replaced in php 
version - todo check


I'd reckon that by the time you've checked all the above - you'll have 
your own solution :)


regards!


Thanks Nathan!

I'm not sure what the problem was.  I think I was tired and trying too 
hard to solve an issue that didn't exist.  I was thinking that 
var_export($db_conn) would display "MySQL Resource Id #1" or something 
similar, but it was displaying "NULL".  I took out all my debugging code 
and it's working fine now.


Ray

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



Re: [PHP] Jabber conection manager

2007-02-04 Thread Ray Hauge

Le Phuoc Canh wrote:

It seem that you want to develop a webchat :), today there is a lot library
about Jabber protocol, but all in JAVA language, if you want you can use
library of jivesoftware to develop. I use Wildfire for IM server, and Claros
for webchat in servlet. You can try it for develop Jabber connection manage.
Best Regard.

-Original Message-
From: chetan rane [mailto:[EMAIL PROTECTED] 
Sent: Saturday, February 03, 2007 10:07 PM

To: php-general@lists.php.net
Subject: [PHP] Jabber conection manager

HI all

i want to develop a Jabber connection manage its role will be

1. accept HTTp request from the Client
2. establish connection with a jabber server using TCp 3. and later start
the instant mechanism between them

has any one worked on this please let me know how to do it


--
Have A plesant Day
Chetan. D. Rane
Location: Pune , India
Contact: +91-9890792762
otherID: [EMAIL PROTECTED]
 [EMAIL PROTECTED]



I've used http://cjphp.netflint.net/ for a project at work before.  It 
was a great simple way to just interface with a jabber server.  I didn't 
need to do anything fancy at the time though.  You could probably use 
that source as a base if you wanted.  It's GPL.



--
Ray Hauge
Primate Applications

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



Re: [PHP] Amortization calculator

2007-02-05 Thread Ray Hauge

Dan Harrington wrote:

Hello,

I am looking for a 365-day  (as opposed to 360) amortization calculator.
Does anyone know of one written in PHP that could be used to calculate
payments, P&I, etc on loans with the various variables changeable like this?
http://ray.met.fsu.edu/cgi-bin/amortize

Thanks
Dan





Usually 360 means number of months, not days, in an amortization 
calculator (30 years).  That's a pretty standard loan term.


I used this when I had to write my own amortization calculator:
http://www.hughchou.org/calc/formula.html

I think there's a PHP version you can download on it.

--
Ray Hauge
Primate Applications

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



Re: [PHP] LOL, preg_match still not working.

2007-02-17 Thread Ray Hauge
Maybe you just copied it wrong, but nocomments and invalidchars are not 
quoted, or they're constants.


I don't think you have to, but you might need to escape some of the 
characters (namely * and .) in your regex.  It's been a while, so I'd 
have to look it up.


What's the error you are getting?

Ray Hauge
Primate Applications


Beauford wrote:

Hi,

I previously had some issues with preg_match and many of you tried to help,
but the same  problem still exists. Here it is again, if anyone can explain
to me how to get this to work it would be great - otherwise I'll just remove
it as I just spent way to much time on this.

Thanks

Here's the code.

	if(empty($comment)) { $formerror['comment'] = nocomments; 
	}

elseif(!preg_match('|[EMAIL PROTECTED]&*();:_. /\t-]+$|',
$comment)) {
$formerror['comment'] = invalidchars;
}   

This produces an error, which I believe it should not.

Testing 12345. This is a test of the emergency broadcast system.

WAKE UP!!



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



Re: [PHP] How do you send stylized email?

2008-02-26 Thread Ray Hauge

Robert Cummings wrote:

On Tue, 2008-02-26 at 10:38 -0500, tedd wrote:

At 4:27 PM +0100 2/26/08, Jochem Maas wrote:

tedd schreef:

Now you sound like my wife.  :-)

for your sake I hope I don't look like her :-P

No, I have an absolutely beautiful wife -- no complaints in that department.


that said I'd hazard a guess and say you listen to what she says ... my ex
used to say the same thing.

Ex's are the experience you need to get it to work.

I've always said that everyone should go through at least one divorce 
before getting married.


Marriage?? That's for backwards people stuck in ancient pointless
traditions >:) And moreso in today's culture... it's just a commercial
suckfest when your money could better go to student loans and raising a
family.

I've been happily living in sin with my common-law wife for 9 years.
Besides, isn't marriage primarily a religious thing? In the old
testament marriage was often implied by the simple act of laying with a
woman... or two... or three... Polygamy, how did that fall out of
religious favour? :)

Cheers,
Rob.


I know it was a rhetorical question, but I was curious.

A lot of the modern standards started when St. Augustine started 
teaching that the fall of Adam and Eve was the "original sin" which was 
sex.  Somehow that took hold and then sex became a "bad thing" and to be 
the most holy of holy you should be celibate.


http://en.wikipedia.org/wiki/Augustine_of_Hippo

As far as the history of monogamy goes, I had to look this one up.  It 
also seems to stem from the teachings of St. Augustine (late AD 300s). 
Martin Luther eventually allowed polygamy after coming to the conclusion 
that there was no scriptural evidence that polygamy was wrong. 
Obviously that's no longer in effect though.  It has also been allowed 
after certain wars to beef up the population again.


http://en.wikipedia.org/wiki/Polygamy#Christianity

I typically don't use wikipedia for sole sources, but everything else I 
could find was some religious site that was very biased.


How's that for off topic?

--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] How do you send stylized email?

2008-02-26 Thread Ray Hauge

Robert Cummings wrote:

So... using this system, a world where everyone is as holy as can be
would be a world devoid of humans (gotta have sex to reproduce). I don't
think St. Augustine was thinking it through :)

Cheers,
Rob.


Haha.  I've often wondered why Christianity has survived so long because 
of this.  I'm just glad there's a lot of sinners out there, or at least 
people who aren't that crazy :)


--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] What design patterns do you usually use?

2008-02-27 Thread Ray Hauge

Richard Heyes wrote:

What design patterns do you usually use?


Whatever solves the problem. Factory is quite a common one. MVC is another.



I have a story to kind of touch on what Jochem said about you just don't 
know the name yet.


Just recently I was tasked with creating a new in-house CRM for an 
external partner.  I only had four days and they had particular 
requirements that ruled out Sugar or other things.  I had never really 
understood what the MVC pattern really was.  I knew the basics, but I 
just didn't "get it".  After I finished the first wave of development on 
this project I finally had a chance to sit back and see the forest 
through the trees and sat back and thought "damn... I just used MVC."


If you're willing to shell out a few bucks, there's a pretty good book 
on design patterns for PHP.  http://www.phparch.com/c/books/id/0973589825


You can think of design patterns more like classes you use with your 
code.  They can help you achieve a goal, but they're not going to do 
everything for you.  Maybe an even better analogy would be a really 
expensive set of knives.  They're super sharp, so make sure you know 
what you're doing with them before you use them.


There is also such a thing as too much.  I heard a talk a while ago 
about code maintainability.  The speaker mentioned a co-worker of his 
ran into his cube almost exhausted and proclaimed, "I finally did it!. 
I used every one of the design patterns in my program!"  Just a few 
months later the speaker ended up being in charge of maintaining that 
program, and it was a nightmare.


To make a long story short.  I generally do what's easiest.  It's 
typically faster to develop and easier to maintain.  Unnecessary 
complexity can start a snowball effect.


--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] What design patterns do you usually use?

2008-02-27 Thread Ray Hauge

Robert Cummings wrote:

On Wed, 2008-02-27 at 15:53 +0100, Jochem Maas wrote:

Paul Scott schreef:

On Wed, 2008-02-27 at 14:48 +0100, Jochem Maas wrote:

Paul Scott schreef:
there seems to be some misunderstanding ... a design pattern is not
a component (or anything else of substance) but merely a conceptual
strategy used to tackle a problem ... ever find yourself writing code
that's conceptually identical to previously written code (in a different
site/project/context), if so you've got yourself a pattern and as such it's
probably been documented as an 'official' design pattern with suitable fancy
name (something like 'Observer', 'Delegator', 'Factory')

chances are then that you're already using design patterns - it's just
that you don't know them by name :-)


Ja, that's what I was trying to say in a long, convoluted,
burning-the-candle-at-both-ends type of way :)

lol ... I often have the same problem ... then Richard Lynch comes along
and explains 'whatever' in a way that the rest of the world does understand :-)


Surely he didn't explain OOP to you... he's anti OOP :)

Cheers,
Rob.


You're right.  I just started reading this list again after a 1.5 year 
break, and I still remember some of the great discussions with Richard 
and others about OOP.  Great times :)


--
Ray Hauge
www.primateapplications.com

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



[PHP] Database Abstraction Idea

2008-02-27 Thread Ray Hauge
I've been working on a project that was started from scratch.  I'm a 
minimalist, so I like to keep things as simple as possible.  I've been 
using this idea for a database abstraction, and I thought I'd see if I 
could get some constructive criticism.


Here is an example of how I use this first:

$table = 'customers';

// validation is handled before this
// the class also uses PDO, so escaping isn't a problem
$id = $_CLEAN['customer_id'];

$customer = DB::loadRecord($table, $id);

echo $customer->first_name; // Bob
echo $customer->last_name; // Jones

// etc.

$customer->first_name = 'Robert';

try {
DB::updateRecord($table, $customer)
} catch (e) {
// handle error
}

# END CODE 

There are other methods as well.  I used a static class to kind of 
simulate a namespace.  The database connection is handled elsewhere.  I 
didn't want to make a singleton and have to pass it around within 
functions and stuff.


The methods are:

query_result &query($sql) // for complicated reports mostly

DBRecord loadRecord($table, $id, $fields = null) // fields can be an 
array of fields you want back.  It always gives you an ID though


bool updateRecord($table, DBRecord $record)

DBRecord newRecord($table) // returns a blank record that can be 
inserted later


bool insertRecord($table, DBRecord $record)

query_result find($table, $whereField, $whereOperator, $whereValue)
// whereOperator is basically an Enum

getFieldInfo($table, $field)
// returns the fetch_object of SHOW COLUMNS FROM $table LIKE $field
// For maxlength and other things in my UI class.

The DBRecord is basically the object representation of the table and 
doesn't have to be all the fields.  Example is


tableName->columnName

I'm pretty happy with how it's working now, but I'm concerned I might 
have misses some sort of security issue.  I only had a work week to 
finish the entire project.  We only have MySQL databases, so I didn't 
need to abstract different types of databases or anything.


Thanks,
--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] Database Abstraction Idea

2008-02-27 Thread Ray Hauge

Daniel Brown wrote:

Should catch(e) really be catch(Exception $e) ?


Something like that.  I was paraphrasing, which seems weird, since I was 
looking at the code for the class description anyway :)  Thanks for the 
info.


--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] Are these Truthful Proof about PHP ??

2008-02-27 Thread Ray Hauge

Nathan Nobbe wrote:

On Wed, Feb 27, 2008 at 2:14 PM, Robert Cummings <[EMAIL PROTECTED]>
wrote:


RoR is a framework, not a language. I also save crapload of typing by
using my InterJinn framework. Ruby as a language doesn't float my boat.



where were you in the big ruby stand-off a couple weeks back ? :D

-nathan



I can't help but send along some words from Terry Chay.  I don't know if 
his comments on Ruby were brought up last time (I promise I'll search 
next time), but these are great even if it's just for a good laugh and 
you don't agree with him.


http://terrychay.com/blog/article/mephisto-ruby.shtml

http://terrychay.com/blog/article/is-ruby-the-dog-and-php-the-dogfood.shtml

--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] Guidance

2008-02-27 Thread Ray Hauge

Matty Sarro wrote:

I understand and agree completely, and I really appreciate the help. My goal
isn't so much to keep from re-writing code, but to have a pretty firm
foundation to stand on before I really begin. I mean, with c++ or c, all I
needed was the language, and that was pretty much it. I could do everything
from there. This seems a lot more like its a marriage of a ton of different
technologies :)

On Wed, Feb 27, 2008 at 3:32 PM, Daniel Brown <[EMAIL PROTECTED]> wrote:


On Wed, Feb 27, 2008 at 3:01 PM, Stut <[EMAIL PROTECTED]> wrote:

 Maybe it's just me but I usually end up rewriting everything I write
 at least twice. That's just a fact of life and I've found that I end
 up with far better code that way than I do by trying to get it right
 first time. It also tends to be quicker.

[snip!]

 In short, learn by doing. It's served me well.

   I made it even shorter, Stut.  ;-P

   He's exactly right, Matty.  It's a form of evolution called
"versioning".  No programmer gets everything perfect the first (or
usually even second, third, eighth) time.  Good, usable, lasting code
will be written and rewritten very often.  Look at almost any code
that's been around and distributed (including the PHP project itself)
and you'll notice that there are dozens of versions, because over the
years new ideas have come about to make it more productive, more
economical, and all-around better.

--


Daniel P. Brown
Senior Unix Geek






My suggestion is to write a throw-away app. That way you can learn 
everything you need to, but it doesn't matter if it's not perfect.  I 
did the same thing just recently while learning C#.  I made an XML 
editor just so I could learn the nuances of the language.


Also, don't forget CSS.  It comes in really handy.  I still use 
w3cschools to look up the property names I can't remember, but it's got 
a lot of great resources to point you in the right direction.


http://www.w3schools.com/

--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] Performance Problem

2008-02-27 Thread Ray Hauge

Adriano Manocchia wrote:
Whoa. No need to get snippy. I was being sincere in my gratitude for the 
suggestions. If nothing else, I'm sure I'll be making more use of Xdebug 
in the future.


On Feb 27, 2008, at 3:55 PM, Shawn McKenzie wrote:


Adriano Manocchia wrote:

Well, I just spent more time messing with httpd's conf and it the
problem seems to have resolved itself by turning off hostname lookups. I
know there's overhead associated with it, but I don't really understand
why it only affected PHP, and so drastically. At any rate, I guess this
issue is solved. Thanks for the help.

Adriano


Yes, we all knew exactly what your problem was.  Sorry we didn't post
quicker ;-)

-Shawn

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



He was messing with you if you couldn't tell.  I'm not sure if you're 
just messing back, but it was at least interesting for me to read the 
progression of events and learn a little bit myself :)


--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] Sometimes I wonder why I even started programming...

2008-02-27 Thread Ray Hauge

Jason Pruim wrote:
So I was supposed to go home a half hour ago but that didn't happen... I 
hate deadlines! :P


Can someone tell me why this code works for setting the table name:

function authentication($user, $pass, $authenticated, $table){
   
// Keep in mind, PASSWORD has meaning in MySQL

// Do your string sanitizing here
// (e.g. - $user = mysql_real_escape_string($_POST['user']);)
$salt = "salt";
$salt1 = $salt;
$salt1 .= $pass;

$password = md5("$salt1");
$loginQuery = "SELECT * FROM current WHERE 
loginName='".$user."' AND loginPassword='".$password."' LIMIT 0,1;";
$loginResult = mysql_query($loginQuery) or die("Wrong data 
supplied or database error"  .mysql_error());

while($row1 = mysql_fetch_array($loginResult)) {
$_SESSION['user'] = $row1['loginName'];
$_SESSION['loggedin'] = "YES";
$authenticated = "true";
$_SESSION['table'] = $row1['tableName'];
   
}

return $table;
return $authenticated;
}   


But this code doesn't:

 function authentication($user, $pass, $authenticated, $table){
   
// Keep in mind, PASSWORD has meaning in MySQL

// Do your string sanitizing here
// (e.g. - $user = mysql_real_escape_string($_POST['user']);)
$salt = "salt";
$salt1 = $salt;
$salt1 .= $pass;

$password = md5("$salt1");
$loginQuery = "SELECT * FROM current WHERE 
loginName='".$user."' AND loginPassword='".$password."' LIMIT 0,1;";
$loginResult = mysql_query($loginQuery) or die("Wrong data 
supplied or database error"  .mysql_error());

while($row1 = mysql_fetch_array($loginResult)) {
$_SESSION['user'] = $row1['loginName'];
$_SESSION['loggedin'] = "YES";
$authenticated = "true";
$table = $row1['tableName'];
   
}

return $table;
return $authenticated;
}\


the query that I'm using is simply this: $query = "SELECT * FROM 
".$_SESSION['table']." order by ".$sortOrder."";


Or this: $query = "SELECT * FROM ".$table." order by ".$sortOrder."";

Depending on if you use the working or the non-working code :)

Any ideas?

--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424-9337
www.raoset.com
[EMAIL PROTECTED]






The only difference I'm seeing is you're assigning the 
$row1['tableName'] to $table rather than $_SESSION['table'].  Is that 
intended?  $table isn't defined in the top function, so it would most 
likely return null.


Also, since you're only expecting one result, you could do away with the 
 while loop and just run $row1 = mysql_fetch_array($loginResult). It 
would accomplish the same goal (nitpicking... sorry).


Also, why are there two return statements? The second will never run.

Maybe I missed something though.

--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] Sometimes I wonder why I even started programming...

2008-02-27 Thread Ray Hauge

Jason Pruim wrote:


On Feb 27, 2008, at 5:12 PM, Daniel Brown wrote:


On Wed, Feb 27, 2008 at 4:55 PM, Jason Pruim <[EMAIL PROTECTED]> wrote:

So I was supposed to go home a half hour ago but that didn't happen...
I hate deadlines! :P


   You whine like a mule.


I know... But I get good answers when I do :P




[snip!]

   function authentication($user, $pass, $authenticated, $table){

   // Keep in mind, PASSWORD has meaning in MySQL
   // Do your string sanitizing here
   // (e.g. - $user = 
mysql_real_escape_string($_POST['user']);)

   $salt = "salt";
   $salt1 = $salt;
   $salt1 .= $pass;

   $password = md5("$salt1");
   $loginQuery = "SELECT * FROM current WHERE 
loginName='".$user."'

AND loginPassword='".$password."' LIMIT 0,1;";
   $loginResult = mysql_query($loginQuery) or 
die("Wrong data supplied

or database error"  .mysql_error());
   while($row1 = mysql_fetch_array($loginResult)) {
   $_SESSION['user'] = $row1['loginName'];
   $_SESSION['loggedin'] = "YES";
   $authenticated = "true";
   $table = $row1['tableName'];

   }
   return $table;
   return $authenticated;
   }   \


   I recognize that code, Jason!  At least the base of it (and the
comments).  ;-P


As well you should!




   See in the first block how you're using $_SESSION?  That's why
you're able to read it later because you have two return $xxx
lines in each function.

   As soon as a function reaches a `return` statement, it returns
that data and exits, so the second `return` is never processed.


so the "return $table;" line doesn't ever get processed?

Is there anyway to make it get processed? :) I'm attempting to rewrite 
code so I don't HAVE to use session variables... Hoping I can make it 
work :)



--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424-9337
www.raoset.com
[EMAIL PROTECTED]



You could return an array with string keys.

$array['table'] = 'asdf';
$array['authenticated'] = false;

return $array;

That's just one option, but it would work.

--
Ray Hauge
www.primateapplications.com

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



[PHP] Test

2008-02-27 Thread Ray Hauge
I recently figured out how to use two SMTP accounts in Thunderbird. 
Hopefully this will help the list to not count me as spam so much (I was 
using my own host to send as gmail... doesn't work so well).


Thanks,
--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] Functions not available when run as Scheduled Task?

2008-02-27 Thread Ray Hauge

Brian Dunning wrote:
Don't laugh but we have a Win 2003 Server set up with WAMP, and the 
PHP/MySQL scripts work great. I set one up to run as a scheduled task:


C:\php5\php.exe "D:\wamp\www\scriptname.php"

...but nothing happens and the Scheduled Tasks log says that it exited 
with an (ff). So I entered the above manually into a command prompt, and 
it said that mysql_connect() is an unknown function! WTF? It's like it's 
trying to use a different php.ini file that maybe has mysql commented 
out. I double checked that all the php.ini files on the machine do have 
mysql enabled, and anyway mysql works fine normally.


Anyone know what PHP is doing to me here in the scheduled service?



I think that there might be a separate php-cli.ini file that is not 
loading the modules that apache does.  I'm too lazy to verify, but I 
remember running into that myself a time or two.  Check the output of 
phpinfo(); or C:\php5\php.exe -v (I think that'll work on Windows).


--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] ZCE guidance needed

2008-02-28 Thread Ray Hauge

Nathan Nobbe wrote:

On Wed, Feb 27, 2008 at 10:31 PM, Shelley <[EMAIL PROTECTED]> wrote:


Greetings all,

Im just need some guidance of how to prepare for the ZCE exam.

Is there somebody passed the exam? Any help infor is highly appreciated.



i read the php architect book and paid for 5 of their sample tests.
http://www.phparch.com/c/books/id/0973862149
some of the questions on the test are really obscure, not really like
about the language as much as the set of functions that ship w/ it.
they try and trip you up, like asking very specific questions about
some of the functions and so forth.
good news is a low score still makes the passing grade ;)

-nathan



Same here.  I read the practice book and took the Vulcan training tests.

http://www.phparch.com/c/product/vulcan/view

My work paid for an online training that got me both of them for free, 
so I used them.  The hardest part for me was just setting a date and 
stop procrastinating.  The test was easier than I was expecting, though 
there were a few things that I didn't know on there.  The tests were my 
best training though.


--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] ZCE guidance needed

2008-02-28 Thread Ray Hauge

Nathan Nobbe wrote:

On Wed, Feb 27, 2008 at 10:31 PM, Shelley <[EMAIL PROTECTED]> wrote:


Greetings all,

Im just need some guidance of how to prepare for the ZCE exam.

Is there somebody passed the exam? Any help infor is highly appreciated.



i read the php architect book and paid for 5 of their sample tests.
http://www.phparch.com/c/books/id/0973862149
some of the questions on the test are really obscure, not really like
about the language as much as the set of functions that ship w/ it.
they try and trip you up, like asking very specific questions about
some of the functions and so forth.
good news is a low score still makes the passing grade ;)

-nathan



My SMTP server didn't like my login for a few minutes, so hopefully I 
don't double-post this.


I used the book and the Vulcan Training tests as well.  I think I got 
more out of the tests than the book, but that's just me.


There were a lot of odd functions in there.  I can't even remember the 
ones that I didn't even know existed.  There were also questions about 
how to configure PHP, so look at the php.ini options as well.


--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] auto-wrap on posts

2008-02-28 Thread Ray Hauge

Nathan Nobbe wrote:

all,

a fellow poster has been kind enough to bring to my attention how jacked
some of my posts appear.
i was manually formatting my posts, but it appears the list server must also
be doing some formatting as many of my posts come out all jacked up looking,
some with only a single word on a line.
ive now resolved to just keep on typing all the way to the end of a line in
the gmail editor, but then they look like crap in the editor; though ill do
it to save face for the public postings if i have to ;)
any body else encounter this ?

-nathan



I haven't noticed any issues with your posts either.

Since we're talking about post issues I'll include this.  I don't seem 
to receive my own emails.  Does the list not send them back to you?  I 
haven't been able to find anything yet.  I just like to see all the 
comments.


Is it the list, or is it Thunderbird/Gmail (I use IMAP forwarding).

--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] auto-wrap on posts

2008-02-28 Thread Ray Hauge

Daniel Brown wrote:

On Thu, Feb 28, 2008 at 10:25 AM, Ray Hauge <[EMAIL PROTECTED]> wrote:

 Since we're talking about post issues I'll include this.  I don't seem
 to receive my own emails.  Does the list not send them back to you?  I
 haven't been able to find anything yet.  I just like to see all the
 comments.


It's intelligent design on Gmail's part.  If you send an email to
a list, Gmail filters the message sent back to you so that it doesn't
appear in your inbox until someone replies to the thread.  The
exception is if a bounce is received.



That makes complete sense.  GMail stores my sent message and if I was 
reading it on GMail I'd see my sent message.  I'll have to see if 
there's any way I can change that at the GMail level.


Thanks for the help.

--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] echo returnArray()['a']; // workaround

2008-02-28 Thread Ray Hauge

Nathan Nobbe wrote:

all,

as we have discussed previously, php does not have support for retrieving
array values on the same line in which they are returned.  i have created a
simple workaround, and would like to share.  first there is the class (w/
other features omitted for the post)
theArray = $theArray;
}

public static function create($theArray) {
return new ArrayClass($theArray);
}

public function __get($name) {
if($this->isValidKey($name)) {
return $this->theArray[$name];
}
}

private function isValidKey($name) {
$isValidKey = false;
if(array_key_exists($name, $this->theArray)) {
$isValidKey = true;
}
return $isValidKey;
}
}
?>

and then there is the example,

 1, 'b' => 2, 'c' => 3, 'd' => 4);
}

echo ArrayClass::create(sillyFunc())->a . PHP_EOL;
?>

notice what would be

echo sillyFunc()['a'] . PHP_EOL;

becomes what you see above.

-nathan

ps.  sorry for all the extra newlines; im trying to work w/ the alterations
the list server is applying to my posts so bear w/ me :D



That's pretty cool.  I wasn't sure if it would work with numerically 
indexed arrays, so I tried:


// sillyFunc returns array(0=>1, 1=>2);

ArrayClass::create(sillyFunc())->{"0"}

I just tested it, and that works.  If you leave off the curly braces and 
quotes, then you obviously get a parse error.  The curly braces are 
necessary.


--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] Sometimes I wonder why I even started programming...

2008-02-28 Thread Ray Hauge

Nathan Rixham wrote:

[snip]
Eric Butera wrote:

I can hit tab and shift/tab too and it puts in spaces for me.

[snip]
Robert Cummings wrote:
 > Uhhhm, I hit the tab button also and it does the right thing (namely
 > inserts 4 spaces). Also, when I hit enter it auto tabs.
[snip]

*kicks zend studio* [and nano and textpad and dreamweaver] :(

what ide's editor's do you two use? zend's use of javaw is killing my 
win2k3 dev machine anyways.




Zend Studio can be configured to use spaces.  Nano/Eclipse can as well. 
 I've been using Nano recently, and I think I liked Zend Studio better. 
 Maybe it's just me, but Eclipse is a memory hog... even worse than 
Zend Studio.  I've also been having problems with Shift+Tab not working, 
or working only on certain types of files.  Those are the only two 
gripes I have though.


Other than that I use vim/gvim (you can get gvim for Windows) or Kate. 
I've tried Quanta as well, but I use Linux for my desktop.


--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] Sessions

2008-02-28 Thread Ray Hauge

VamVan wrote:

Hello People,

I wanted to have your assistance in deciding few things here,
basically I want to auto populate a registration form for people
visiting second time or so on.

I have already started a session,I know that session is a cookie so is
it better to rely upon the session cookie for auto populating or
create another cookie on client side.

If i am not mistaken ini_set('session.gc_maxlifetime', 3600);
increases the time session cookie expiration time to 1 hr  right.

Please give me ur suggestions on this. if some one has a working code
can you please share?

Thanks,
V



In the example you provide it would be best to use a regular cookie. 
Sessions are destroyed and garbage collected quite regularly, so you can 
only count on the data being available while they are using your 
application (during their session).  With cookies you can specify an 
expires date so that the information will be available tomorrow, next 
week, etc.


You *could* increase the session cookie lifetime, but I wouldn't count 
on the data being available through a session, especially if they close 
their browser.


--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] auto-wrap on posts

2008-02-29 Thread Ray Hauge

Zoltán Németh wrote:

2008. 02. 28, csütörtök keltezéssel 10.38-kor Nathan Nobbe ezt írta:

On Thu, Feb 28, 2008 at 10:35 AM, David Giragosian <[EMAIL PROTECTED]>
wrote:


On 2/28/08, Nathan Nobbe <[EMAIL PROTECTED]> wrote:

take a look here on the marc archives.
http://marc.info/?l=php-general&m=120415418217911&w=2

there are several lines that have 1 word only in them, some of the words
(for reference) are access, good, patterns, nested.
when i wrote the post (looking in my gmail client) these words are not

on

their own line..
does the post look as it does on marc in your mail clients or are the

words

in sentences where they belong ?

thanks,

-nathan


Your emails come through to my gmail account as you first described,
Nathan, ie, sometimes with just one word on a line, and just like the
marc archives.


thanks, ill just have to be careful editing from gmail then..

Ray, if I start a thread, I'm fairly sure the list sends the email back to

me.


i dont get an email back until someone replies.


that must be a gmail thing, I get everything back

greets,
Zoltán Németh


-nathan





Yeah, it is a gmail thing.  They archive the message you send, so if you 
were using the gmail client, you'd see your response.  The FAQs say that 
it'll send your message through IMAP/POP if someone replies to your 
message, but gmail doesn't do nested threads, so I think it doesn't know 
all the time when you were replied to.


--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] Weird Results from Curl

2008-02-29 Thread Ray Hauge

Wolf wrote:
 Ray Hauge <[EMAIL PROTECTED]> wrote: 

Wolf wrote:

I'm curling a site to process some data, all well and good but the results are 
baffling...

$result = curl_exec($ch);
curl_close($ch);
echo "".gettype ($result);

Of course that's not all the code, but the results contain:
-
0 11
0 1
1 1
1 11
5 An Error Has Occurred During Processing.
Error: An Error occured .
A message has been sent to the System Administrator with the details of the 
problem you have encountered. 1


What I can't seem to figure out is what the result type actually is and how to pull just 
the first piece (0,1,etc) out of the "0 11" that gets returned.

I have tried to do a strlen conversion, that failed.  I've tried bool 
converting but it doesn't come across right either.

Any ideas?

Thanks!
Wolf


It sounds like the error message is being returned from the remote server.

Is gettype() outputting the numbers, or is that part of the output from 
curl?  gettype should be returning a string, so I wouldn't think that 
gettype would be returning the numbers.


Are you using the CURLOPT_RETURNTRANSFER option?  If so, then $result 
would have the text of the site on success, and false on error.


OK, I probably wasn't clear...

The results from the server (0 11, 1 11, 0 1, 1 1, 5 Error 1, etc) are what 
I expect them to be, however I can't pull them out.

*grumble*

I forgot that I commented out the CURLOPT_RETURNTRANSFER line!  UGH!

Thanks!

Wolf


CURLOPT_RETURNTRANSFER has gotten me a few times.  The default of just 
outputting the information directly to the browser always seemed a bit 
odd to me.  Maybe that's just because I've only used it for scraping and 
reading data.


--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] Weird Results from Curl

2008-02-29 Thread Ray Hauge

Wolf wrote:

I'm curling a site to process some data, all well and good but the results are 
baffling...

$result = curl_exec($ch);
curl_close($ch);
echo "".gettype ($result);

Of course that's not all the code, but the results contain:
-
0 11
0 1
1 1
1 11
5 An Error Has Occurred During Processing.
Error: An Error occured .
A message has been sent to the System Administrator with the details of the 
problem you have encountered. 1


What I can't seem to figure out is what the result type actually is and how to pull just 
the first piece (0,1,etc) out of the "0 11" that gets returned.

I have tried to do a strlen conversion, that failed.  I've tried bool 
converting but it doesn't come across right either.

Any ideas?

Thanks!
Wolf



It sounds like the error message is being returned from the remote server.

Is gettype() outputting the numbers, or is that part of the output from 
curl?  gettype should be returning a string, so I wouldn't think that 
gettype would be returning the numbers.


Are you using the CURLOPT_RETURNTRANSFER option?  If so, then $result 
would have the text of the site on success, and false on error.


--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] What design patterns do you usually use?

2008-02-29 Thread Ray Hauge

Zoltán Németh wrote:

2008. 02. 29, péntek keltezéssel 14.28-kor tedd ezt írta:

At 4:36 PM +0100 2/29/08, Zoltán Németh wrote:

sure, all information belonging to an object is usually in a record of a
db.
but, you mean include('user_functions.php') automatically loads that
data? based on what? a global $user_id variable? if so, I would consider
that poor design...
Whoa there, you don't know what it's doing -- so 
saying poor design is probably not a good call.



 > And thus, two lines instead of three.

 But in fairness, the user_functions.php would
 establish a connection to the database and the
 function "set_user_name($user, 'tedd')" would
 simply use 'tedd' with respect to whatever
 "$user" is.

hmm that means you use only one user's info in the script. that's very
limiting.

Again, you don't know what's being called.

No reason to be insulting. What I am calling 
could be a pointer or an id to a record -- BOTH 
-- of which are no more limited than calling a 
class. What do you think languages are doing when 
they call segments of memory for data or function 
-- you think they pass ton's of variables or just 
a pointer? So, there's nothing limited here about 
what I'm doing. Think about it.



hey, no insult intended here... sorry if seemed so.
but, my point was exactly what you stated above. you say 'you don't know
what's being called' - that's the main problem I found with non-oop code
organization. with clearly defined classes every developer knows what he
calls without further explanation.


sure you can duplicate with procedural code anything my tons of classes
do... but above a certain project size it can easily become a
maintenance nightmare and an integration nightmare if there are more
than one developers. classes enforce some strict rules to everyone in
the team, so teamwork is much more efficient and the resulting codebase
is cleaner. I know from experience, as this project with the 400K lines
is a rewrite of the previous procedural version, which was developed and
maintained by a dozen of developers over the years, and it became such a
mess that none of us wants to touch it anymore...
Again -- the difference here is organizational 
style. Everything you can do in your classes I 
can do in my functions. Plus, you can have just 
the same amount of screw-ups as I can when you 
introduce more than one programmer and his style 
into the mix.


I don't like the tone here -- it appears that 
because I'm not agreeing with you that my code is 
limited or of poor design -- because let me 
assure you it's not!


So, let's just drop this -- you have your way and I have mine.


again, sorry for the tone if it was wrong - might be because I'm not a
native english speaker, or maybe because this is one of the craziest
fridays ever, I don't know. for sure, I didn't mean it.

and yes, let's drop this, I see I can't convince you.
anyway, I'm not an oop zealot, I just find it so useful and I tried to
explain my view of it - with absolutely no offense intended - so, happy
coding for you with your style and me with mine :)

greets,
Zoltán Németh


Cheers,

tedd

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





Aww man, I was getting curious to see how nested this conversation would 
get.  Think of the children! :)


PS. Happy Friday!!!

PPS. I'm hopped up on caffeine so ignore any stupid remarks.

--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] Anyone jump from Studio 5.5.x -> Zend Eclipse?

2008-03-02 Thread Ray Hauge

Steve Finkelstein wrote:

Hi all,

I've tried googling around to find some blogs with decent information
on whether Zend Eclipse is mature enough to make the jump over from
5.5.x just yet.

Admittedly, I've dropped Zend Studio as of late and been writing all
of my code in TextMate -- but at the end of the day when a project is
complex enough, Zend Studio is much more powerful than TextMate with
all of its features and remote debugging capabilities.

Anyhow, I'm curious if it's worth it to check out Zend Eclipse yet.
We're a team of about 5-6 developers and I've been getting asked by a
few colleagues if I've tried it out yet since I'm usually the one to
try out the newer technologies.

I'd love to hear some feedback.

Thanks!

/sf



I've recently switched.  On my machine (which hasn't been updated for a 
long time...) Eclipse runs a lot slower.  I only have 1 GB of RAM.  Zend 
Studio has been running faster for me after I turned off the SVN 
integration.  I just use the CLI for SVN anyway.


Sometimes in Eclipse it'll slow down so much that I have to slow down my 
typing.  Mostly that's in CSS files.  I don't know if it's Eclipse in 
general, but Shift+Tab rarely works, and it drives me nuts.  I've tried 
to mess with the key bindings to no avail.  Debugging is a lot slower in 
Eclipse.  Some of the default key bindings in Zend Studio are different 
in Zend Eclipse as well, but that was somewhat expected and hasn't 
bothered me too much.


I've been using the official Zend Eclipse now since the day it came out. 
  Next week I'm going to switch back to regular Zend Studio.  It was 
nicer on the RAM and for the most part "Just Worked"(TM).


That's my experience.  I'd be interested to hear other people's experiences.

--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] Preserving URL after redirect?

2008-03-05 Thread Ray Hauge

Richard Heyes wrote:
So, my question is how would I do that, and I strongly suspect if it's 
possible at all an .htaccess file with the proper entries would be the 
way to do it, not using PHP code to redirect as I am now.


Is this the case?


You would need to use mod_rewrite.



You might also be able to get this to work by changing the include_path 
and creating a special "loader" script in their folder.


define('INCLUDE_PATH', '');

ini_set("include_path", INCLUDE_PATH);

That way the application includes would still work if you didn't specify 
 absolute paths...


I have a few scripts that use the include_path, and they look something 
like:




That way I just have the initial call to set the include path, and I 
don't have to worry about it anymore.


--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] CVS Scripts

2008-03-06 Thread Ray Hauge

Eric Butera wrote:

On Thu, Mar 6, 2008 at 10:58 AM, Adrian Walls <[EMAIL PROTECTED]> wrote:

Firstly thanks for a sensible reply.

 I am using Zend Studio Server and I haven't upgraded to Zend Studio for
 Eclipse as yet.  It also has some CVS capability not its not what I am
 after.

 Google was my first stop but it didn't turn up anything which appeared to be
 in a stable enough state.  Hence my email to the list to see if anyone else
 had come across such a solution.  My application is built from several
 modules contained with cvs.  Some of these modules are used across projects.
 I wanted to create my own web-based script to check these out of cvs and to
 build and configure the application on the fly.

 I had a look at cruisecontrol but its not really what I am looking for
 either.

 Adrian.






 -Original Message-
 From: Wolf [mailto:[EMAIL PROTECTED]


Sent: 06 March 2008 15:42
 To: Adrian Walls
 Cc: 'Eric Butera'; php-general@lists.php.net
 Subject: RE: [PHP] CVS Scripts

  Adrian Walls <[EMAIL PROTECTED]> wrote:
 > 1. It is a legal thing, whether it means anything or not or regardless of
 > what anyone else's take is on it.
 >
 > 2. It was a straight forward question I asked.  I guess it was my mistake
 > for thinking this was a place to ask questions rather than somewhere to
 take
 > the p*ss.  I'll not make the same mistake again.
 >
 

 We're a bunch of helpful and flippant sods on this list, so take the
 criticism as constructive (trim your own sig file down and remove the white
 space and see if you can NOT send the confidentiality notices when broadcast
 mailing).

 As for automatic CVS via PHP, it depends on your take on it...

 Eclipse has a CVS piece to it which seems to work well (I've installed it,
 but most of my stuff is layered and I don't have a reason for CVS), though
 someone also posted about cruisecontrol on the sourceforge site.

 What have you found and tried via a google search?

 Wolf




Maybe look at Phing[1]?  Skimming over the docs (I know you said you
use CVS) I saw a task you can define to check files out form SVN.
There might be a cvs one somewhere or you could extend it and write
your own.

[1] http://phing.info/



Another option would be to write your own.  If your requirements are 
super specific, then that might be the best route.  I can't imagine it 
would be too difficult.


You can use shell_exec to execute the CVS checkout, and any other CVS 
command necessary.  Don't forget to use escapeshellcmd() either:


http://us3.php.net/manual/en/function.escapeshellcmd.php

After it's checked out, then you can use shell_exec() again to run the 
compile command.  If it takes a long time, you might be best just 
sending the command to the output so you can copy and paste and run it 
yourself, or just make sure you set_time_limit(0), or some amount of 
time it should finish compiling in.


I assume it's an internal app, so you wouldn't have to worry too much 
about it looking pretty or any of the other time consuming operations.


$cmd = escapeshellcmd('/usr/bin/cvs -d :ext:[EMAIL PROTECTED]:/.../cvsroot 
checkout module');


$output = shell_exec($cmd);

// do something with output if you need

$cmd = escapeshellcmd('/path/to/module/configure');

$output = shell_exec($cmd);

echo "done!";

?>

Something like that anyway.  That's overly simplified of course, but it 
should get you a start if you want to write it yourself.


--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] CVS Scripts

2008-03-06 Thread Ray Hauge

Wolf wrote:

I am using Zend Studio Server and I haven't upgraded to Zend Studio for
Eclipse as yet.  It also has some CVS capability not its not what I am
after.  


Google was my first stop but it didn't turn up anything which appeared to be
in a stable enough state.  Hence my email to the list to see if anyone else
had come across such a solution.  My application is built from several
modules contained with cvs.  Some of these modules are used across projects.
I wanted to create my own web-based script to check these out of cvs and to
build and configure the application on the fly.

I had a look at cruisecontrol but its not really what I am looking for
either.



You're probably going to have to code that sucker on your own and slide it in 
as a cron job on your build server to get the latest/greatest whenever needed.  
I haven't come across anything like it before, but I definitely like the 
concept.

Wolf



I had an idea to tie a ticket system with SVN.  Each ticket would be 
associated to a change in the code.  In the ticket system you put in the 
different revisions that were checked in for that ticket.  Then when you 
go to "promote" the ticket for testing, it'll check and make sure that 
there were no conflicting changes and merge it if possible to the next 
branch.  The details are a little fuzzy after a few months of not 
thinking about it.  The XML output from SVN would come in quite handy at 
that point though.


It would have been cool, but it would have been complicated.  We didn't 
have the time to work on it.  I think Trac is somewhat similar.


PS. sorry for the thread hijack :)

--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] Re: Transferring files between computers using php

2008-03-06 Thread Ray Hauge

Rahul wrote:

Zareef Ahmed wrote:

On 3/7/08, Rahul <[EMAIL PROTECTED]> wrote:

Thank you all so much for replying... I guess I was very vague in
describing the situation. I will write in detail:

I have three computers A, B and C. To login to B and C I should use A
because it has a SSH key. I don't have any other way of accessing these
two computers. Now, if I need to transfer a file between B and C, I am
unable to find a way that would work... because I don't know how to
authenticate without SSH keys... I was gathering some data in B and C
using PHP. Now, I need these two computers to coordinate a little and
didn't want to use a server in between and so I was thinking of
establishing a direct connection between them..



If you have ruled out web server and ssh, then you can use ftp using 
PHP or

use NFS mounting.




Zareef Ahmed wrote:

On 3/7/08, Shawn McKenzie <[EMAIL PROTECTED]> wrote:

Rahul wrote:

I have a small file to be transferred between two computers every few
seconds. I'm using unix with a bare bones version of php, i.e. just

the

original thing that gets installed when I run "yum install php". As

there is

no webserver on any of these machines, I was wondering if there is a

way

to

transfer a small file between them and if there is, could someone be

kind

enough to provide me with an example please?

Thank You



FYI...  If you're using yum I assume it's a Linux machine (maybe

Fedora)

and not Unix.



If you want to use rsync and scp in a cronjob (for continuous transfer

at a

predefined interval), you may need to set your server (read ssh) to

accept

connection without password.
Ref : http://linuxproblem.org/art_9.html

BUT If you really want to do that from PHP, you can install a web 
server

and

enable http as your stream for opening files. (In php.ini)
 You can read the file using fopen or any other file functions, then 
can

write that file to the server on which script will be running, then you

can

set this script as your cron job.

For example :

$filecontents=file_get_contents("http://firstserver/file.txt";);

$fp=fopen("path to local file", "mode");

Now use $fiiecontents to write the file using $fp resource.

BUT remember, using rsync is always a better solution, and

file_get_contents
and file functions are resource hungry, specially they will consume 
more

memory of your system.



--

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





Well I haven't ruled our webserver and ssh but I don't have much 
options. Number 1 is that I have many such computers and I don't think I 
can afford to install a webserver on all of them atleast. And coming to 
SSH, I can't use it because of the scenario that I explained. Please let 
me know if you have any other advice.


Thank You



I second the NFS mounting.  You can share a directory somewhere on 
computer A.  Then computers B and C connect to it.  That way with PHP 
you just copy the file to the shares, and computers B and C 
automatically see the file there.  Outside of that FTP might work well 
for you.  Maybe even SCP, since you already have the keys on server A 
(as long as you don't have a password when connecting to B or C).  rsync 
can work over SSH as well, and you could create a simple script to run 
rsync as often as you need.


haha, I guess that's not exactly seconding NFS, more seconding not 
transferring files over HTTP.


--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] SMTP

2008-03-09 Thread Ray Hauge

Alain Roger wrote:

Hi,

i know that this is not necessary the best forum for that, but i need to get
a real feedback and i guess you already faced the same issue as mine.
basically, i develop php web application on windows XP platform.
So i have apache 2.24 installed and PHP 5.2.4.

now i would like to test if my application send emails, so i've checked my
php.ini file and it seems ok.
i tried to use IIS from windows to define a default SMTP server, but as my
emails are not sent, i guess something is wrong with IIS.

so does it exist a free SMTP server (similar that linux daemon) but running
on windows XP ?
if yes, where can i find it and what steps should i perform to be sure my
emails are sent ?

i do not want to transfer all my web application each time i want to test
email sending...
i would like to test it locally.

thanks for your feedback.



I could be wrong, but I thought that you had to specify the SMTP server 
in the php.ini file.


http://us2.php.net/manual/en/ref.mail.php#ini.smtp

> now i would like to test if my application send emails, so i've 
checked my

> php.ini file and it seems ok.

Maybe that means you already did that.  The second issue might be that 
your SMTP server is MS Exchange, and it requires authentication.


If that is the case, then search for php SMTP authentication:

http://www.google.com/search?q=php+smtp+authentication&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a

--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] Unexcepted $this

2008-03-10 Thread Ray Hauge

Murat BEŞER wrote:

I can't under stood but PHP gaves me an error:

"UnExcepted $this" for " || $this->getFileExtension($file) == 'jpg' "

When I removed jpg extension check it's okay... PHP script runs well.

What is the problem :)

public function loadImages($folder) {
$result = $this->filemanager->fecthFiles($folder);
$images = array();
if (sizeof($result)>=1 && $result !== false) {
foreach ($result as $file) {
if ($this->getFileExtension($file) == 'gif' || 
$this->getFileExtension($file) == 'png' || 
$this->getFileExtension($file) == 'jpg') {

$images[] = array('name'=>$file);
}
}
}
return $images;
}



Try storing the value in a variable first.  It'll also have the 
side-effect of being marginally faster too.


$extension = $this->getFileExtension($file);

if ($extension == 'gif' || $extension || 'png' || $extension == 'jpg') {
// do something
}

That might help, but I would think that the way you had it would also 
work.  Let us know what happens when you use the variable like I showed 
above.


Thanks,
--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] Unexcepted $this

2008-03-10 Thread Ray Hauge

Philip Thompson wrote:

On Mar 10, 2008, at 8:32 AM, Ray Hauge wrote:


Murat BEŞER wrote:

I can't under stood but PHP gaves me an error:
"UnExcepted $this" for " || $this->getFileExtension($file) == 'jpg' "
When I removed jpg extension check it's okay... PHP script runs well.
What is the problem :)
public function loadImages($folder) {
   $result = $this->filemanager->fecthFiles($folder);
   $images = array();
   if (sizeof($result)>=1 && $result !== false) {
   foreach ($result as $file) {
if ($this->getFileExtension($file) == 'gif' || 
$this->getFileExtension($file) == 'png' || 
$this->getFileExtension($file) == 'jpg') {

   $images[] = array('name'=>$file);
   }
   }
   }
   return $images;
   }


Try storing the value in a variable first.  It'll also have the 
side-effect of being marginally faster too.


Good call.



$extension = $this->getFileExtension($file);

if ($extension == 'gif' || $extension || 'png' || $extension == 'jpg') {


Correction:

... $extension == 'png' ...

Personally, I like the in_array() version better - it cleaner and you 
can expand upon it more more easily.


$extensions = array('gif, 'png', 'jpg' [, 'm4a'[, 'etc']]);
if (in_array($extension, $extensions)) { ... }



// do something
}

That might help, but I would think that the way you had it would also 
work.  Let us know what happens when you use the variable like I 
showed above.


Thanks,
--
Ray Hauge



HTH,
~Philip

"Personally, most of my web applications do not have to factor 13.7 
billion years of space drift in to the calculations, so PHP's rand 
function has been great for me..." ~S. Johnson





Thanks for the catch.  I work from home and I hadn't had my coffee yet 
in the morning.  I usually check my news and email right after I get up 
and before I go to  work :)


I have been starting to use in_array more often as well.  Far too many 
times I'll have to go back and add more options later, then the IF 
statement gets huge.  Someday I'll kick the habit for good though.


Oh, it might also be a bit easier to store the acceptable extensions in 
an array before the IF statement


$ext = $this->getFileExtension($file);
$acceptableExtensions = array('png', 'gif', 'jpg');

if ( in_array($ext, $acceptableExtensions) ) {
// do something
}

That way the conditional doesn't grow as more and more values get added.

--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] CSV speed

2008-03-11 Thread Ray Hauge

Wolf wrote:

Danny Brow wrote:

I have about 10 csv files I need to open to access data. It takes a lot
of time to search each file for the values I need. Would it be best to
just dump all the cvs files to an SQL db and then just grab what I need
from there? I'm starting to think it would make a lot of sense. What do
you guys think?

Thanks,
Dan



Dan,

I can tell you that depending on the size of your files is going to 
dictate the route you want to go.  I have a CSV with 568,000+ lines with 
19 different pieces to each line.  The files are around 180M apiece and 
it takes my server about 2 seconds to run a system grep against the 
files.  I can run a recursive call 7 times against a MySQL database with 
the same information and it takes it about 4 seconds.


IF you have system call ability, a grep wouldn't be bad, otherwise I'd 
suggest loading the csv files into MySQL tables and checking them for 
the information, then dropping the tables when you get the next files. 
You can backup the databases such as a cron job overnight even.


HTH,
Wolf




If you do go the MySQL route, MySQL can import CSV files natively, and 
it'll be a lot faster than doing it through PHP.  Just look up the 
syntax for the LOAD DATA INFILE command... or look here.


http://dev.mysql.com/doc/refman/5.1/en/load-data.html

Here's an example:

LOAD DATA LOCAL INFILE '/importfile.csv'
INTO TABLE test_table
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\n'
(field1, filed2, field3);

I've had to do imports of a million or more records from CSV files, and 
PHP is a lot slower than MySQL at importing them :)


--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] setcookie

2008-03-12 Thread Ray Hauge

Wolf wrote:



Tim Daff wrote:

Hi,

I am learning PHP, I am trying to set a simple cookie:



Cookies


   
   


Firefox is returning this error:

Warning: Cannot modify header information - headers already sent by 
(output started at /Users/Daff/Sites/php_sandbox/cookies.php:7) in 
/Users/Daff/Sites/php_sandbox/cookies.php on line 7


I have googled this and can't find out what I am doing wrong.  Any 
help you could give me would be much appreciated.


Tim


 
 
 
 Cookies
 
 



 
 

Cookies HAVE to be at the top of the page...  You output ANYTHING else 
and you get the error you wound up getting.


Wolf




If you're not sure if data has already been sent to the client (I ran 
into an included file having a space after >?) you can use 
http://us3.php.net/manual/en/function.headers-sent.php before you call 
setcookie();


If nothing else it'll help with diagnosing this error when you run into 
it again.


--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] A Quick Reminder....

2008-03-12 Thread Ray Hauge

Jason Pruim wrote:


On Mar 12, 2008, at 11:06 AM, Daniel Brown wrote:

On Wed, Mar 12, 2008 at 11:01 AM, TG <[EMAIL PROTECTED]> 
wrote:
How about something OT that we can argue about...   driving on the 
left side

of the road versus the right side.  How does your country compare?


   Here in Pennsyltucky, a lot of people drive on the left, despite
the fact that the whole US is supposed to drive on the right.  It
usually doesn't turn out very good.  .:shakes head, solemnly:.

   Not very good at all.


Up here in the great big hand (Michigan for those who don't know) during 
the winter we have so much snow on the ground that you just kind of 
drive where ever looks like road... Even if it means you have people 
passing on your right going the opposite way.



--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424-9337
www.raoset.com
[EMAIL PROTECTED]






I'm in Fargo, North Dakota (the "that's a state?" state).  We experience 
very much the same thing.  Especially on the side roads that don't get 
cleared as well.  You just have to make sure that you don't run into 
each other and you're good.


As far as replies, I like bottom posting because it keeps the 
conversation flow more in tact.  GMail does a good job regardless of 
bottom or top posting though.


--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] What's wrong the __autoload()?

2008-03-12 Thread Ray Hauge

Greg Donald wrote:

On 3/12/08, Robert Cummings <[EMAIL PROTECTED]> wrote:

Just because someone got a flashy new toy doesn't mean I want it. I've
 got better things to do than play with flashy toys for the mere purpose
 of playing with flashy toys. I like to use tools that get jobs done.


Translation: I'm too lazy to learn anything new since I already know PHP.

Languages come and go.  There's a reason why we no longer need a
cgi-bin and Perl to make an animated gif.  Going further, who the hell
even uses animated gifs any more?


Ummm, I originally looked into Ruby and RoR because someone spouted off
 "better" and "easier". After reviewing, looking at the language, trying
 some code, reading other peoples blogs, magazine articles, searching the
 web... I decided, using the brain I've been nurturing since I was a
 fetus, that I preferred PHP.


Great, just so long as we're clear on the point that Ruby is better
than PHP, just not for you personally.  I'm totally fine with leaving
the discussion at the "differently preferred opinion" level.  Sounds
like a cop-out but I'm ok with your holding that position all the
same.


But then who would confront your rhetoric and propaganda?


I do exhibit a bit of rhetoric at times, but in my defense it came
standard with my inquisitive mind.

Conversely I do not know what propaganda you speak of.  I've never
once made a specific claim in favor of Ruby that I couldn't back up
with example code.


You're assuming that we choose PHP over RoR based on having seen a 5
 minute tutorial. Wow, aren't you just full of assumptions.


Ok then, how many projects did you pursue before giving up and
concluding Rails or Ruby was too much effort to learn?  URL?

I will point out it's probably a good thing this same lack of effort
on your part did not occur when you began to learn PHP, otherwise we
wouldn't even be having this discussion.


Interestingly, laziness is one of the biggest motivators of innovation.
 Do more with less.


Well that sure as hell ain't PHP.  ROFL.  More with less, using PHP, hilarious.

/me points to SPL and laughs his ass off


That SHOULD be part of any developers mandate... but
 not blindly.


If by blindly you mean fun, fast, test-driven, productive development,
then yeah I guess so.




I didn't want to have to do this, but read some of Terry Chay's work on 
Ruby.  There are plenty of people who just prefer PHP to RoR.  Some 
people like Java, some people like .NET, etc.  Get over yourself.  You 
come to a PHP mailing list to proclaim that RoR is better?  What did you 
expect?  It's people like you that turn a lot of people off to Ruby. 
The community is insane!


This was a great read.  If nothing else he's funny.

http://terrychay.com/blog/article/php-ruby-evil-good.shtml

--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] What's wrong the __autoload()?

2008-03-12 Thread Ray Hauge

Ray Hauge wrote:

Greg Donald wrote:

On 3/12/08, Robert Cummings <[EMAIL PROTECTED]> wrote:

Just because someone got a flashy new toy doesn't mean I want it. I've
 got better things to do than play with flashy toys for the mere purpose
 of playing with flashy toys. I like to use tools that get jobs done.


Translation: I'm too lazy to learn anything new since I already know PHP.

Languages come and go.  There's a reason why we no longer need a
cgi-bin and Perl to make an animated gif.  Going further, who the hell
even uses animated gifs any more?


Ummm, I originally looked into Ruby and RoR because someone spouted off
 "better" and "easier". After reviewing, looking at the language, trying
 some code, reading other peoples blogs, magazine articles, searching 
the

 web... I decided, using the brain I've been nurturing since I was a
 fetus, that I preferred PHP.


Great, just so long as we're clear on the point that Ruby is better
than PHP, just not for you personally.  I'm totally fine with leaving
the discussion at the "differently preferred opinion" level.  Sounds
like a cop-out but I'm ok with your holding that position all the
same.


But then who would confront your rhetoric and propaganda?


I do exhibit a bit of rhetoric at times, but in my defense it came
standard with my inquisitive mind.

Conversely I do not know what propaganda you speak of.  I've never
once made a specific claim in favor of Ruby that I couldn't back up
with example code.


You're assuming that we choose PHP over RoR based on having seen a 5
 minute tutorial. Wow, aren't you just full of assumptions.


Ok then, how many projects did you pursue before giving up and
concluding Rails or Ruby was too much effort to learn?  URL?

I will point out it's probably a good thing this same lack of effort
on your part did not occur when you began to learn PHP, otherwise we
wouldn't even be having this discussion.


Interestingly, laziness is one of the biggest motivators of innovation.
 Do more with less.


Well that sure as hell ain't PHP.  ROFL.  More with less, using PHP, 
hilarious.


/me points to SPL and laughs his ass off


That SHOULD be part of any developers mandate... but
 not blindly.


If by blindly you mean fun, fast, test-driven, productive development,
then yeah I guess so.




I didn't want to have to do this, but read some of Terry Chay's work on 
Ruby.  There are plenty of people who just prefer PHP to RoR.  Some 
people like Java, some people like .NET, etc.  Get over yourself.  You 
come to a PHP mailing list to proclaim that RoR is better?  What did you 
expect?  It's people like you that turn a lot of people off to Ruby. The 
community is insane!


This was a great read.  If nothing else he's funny.

http://terrychay.com/blog/article/php-ruby-evil-good.shtml



One last link, because this one is the one that has caused the most 
"controversy" (for lack of a better word).


http://terrychay.com/blog/article/is-ruby-the-dog-and-php-the-dogfood.shtml

--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] What's wrong the __autoload()?

2008-03-13 Thread Ray Hauge

Greg Donald wrote:

On 3/12/08, Ray Hauge <[EMAIL PROTECTED]> wrote:

You
 come to a PHP mailing list to proclaim that RoR is better?


No dumbass, I have already been here for a long time:


This is my last post on this thread.  It's obvious nobody is going to 
convince anyone else of their being right or wrong.  The issue people 
are having is your attitude from about reply #2 from you on this thread. 
 I just wanted to make that point clear.  Trolling and being 
antagonistic doesn't get you anywhere.


The point of this reply is I didn't say anything about how long you've 
been around here.  The fact is you're still here, and we're talking PHP.


I will give you that you weren't the first to submit an opinion of Ruby 
being the best or the worst.  Your first reply was simply open minded, 
but then you got your feathers all ruffled when someone said they didn't 
like Ruby, albeit in a somewhat negative connotation.


>> It's people like you that turn a lot of people off to Ruby.

>I choose to use a language for a while before forming an opinion.  I
>certainly wouldn't let someone's opinion sway my own inquisitive
>nature to have a go at it myself.

The reason it turns people off is you have to work with the community as 
well as the language.  If you want the project to get better, you need 
to be able to work with the community.  I will admit that the PHP 
Internals list can get pretty heated as well, but those arguments are 
usually based on technical opinions and not religious fervor for the 
language*.


* Note: I haven't read a whole lot on the Internals list, but based on 
summaries by PHP|Architect and other sources I have assumed my conclusion.


--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] Unexcepted $this

2008-03-13 Thread Ray Hauge

Eric Butera wrote:

2008/3/13 Anup Shukla <[EMAIL PROTECTED]>:

Murat BEŞER wrote:
 > So what do you thing about on this thing ?
 >

 I really would like to figure out the problem.
 However, my simple script to mimic your code did not throw any errors.

 If you could provide some more details, maybe we can figure out the problem.

 --
 Regards,
 Anup Shukla



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




It could just be a special character in the code somewhere.  Since
pushing/pulling files happens across so many servers with different
encodings it happens sometimes.  On OSX there is a text editor named
TextWrangler that has a feature called "Zap Gremlins" that I use to
get rid of it when it happens.


Would it be possible to post the code you have now to http://pastebin.com/ ?

That might assist in locating odd characters if that's the case, though 
I'd think that your editor would display them as well.  Usually an 
"Unexpected " means that you missed a parenthesis or curly brace, etc.


--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] Objects as array key names??

2008-03-15 Thread Ray Hauge

Jim Lucas wrote:
This question should probably be directed at the PHP Internals list, but 
I thought I would start by asking here first if anybody would even use 
this feature.


It has been brought to my attention that with Perl and Ruby, you can use 
Objects as the value of the key within an array.  The examples that were 
shown to me make me think that this would be an awesome ability to have 
within PHP.


Here is an example of how I would use such a feature.

I have a table of "customers".
I have a table customers "contact_locations".
This table has a reference ID back to the "customers" table.

Now, in my array of information that I build I have this.

$res = query('Select c_id, c_first_name, c_last_name FROM customers');

$customers = array();
while ( $row = fetch_assoc($res) ) {
$customers[$row]['contact_locations'] = array();
$SQL = "SELECT *
FROM contact_locations
WHERE c_id={$row['c_id']}";
$loc_res = query($SQL);
while ( $loc_row = fetch_assoc($loc_res) ) {
$customers[$row]['contact_locations'][] = $loc_row;
}
}


Now, contained within one array "$customers" I have all the information 
that would be needed for displaying any type of information related to a 
customer or a customers location.


By doing having this feature, I could build the ability to do xPath 
searches within the base array.  That would be nice.


Anyways, what do you all think?  Worth it or not?

Jim Lucas



Maybe I don't get the new concept, but what would be wrong with:

// START CODE //
$cid = null;
$customers = array();

while ( $row = fetch_assoc($res) ) {

$cid = $row['cid'];
$customers[$cid] = $row;
$customers[$cid]['contact_locations'] = array();

$SQL = "SELECT *
FROM contact_locations
WHERE c_id={$cid}";

$loc_res = query($SQL);

while ( $loc_row = fetch_assoc($loc_res) ) {
$customers[$cid]['contact_locations'][] = $loc_row;
}

}
// END CODE //

Now you can easily reference all of your customers by ID and get any of 
the data you want.  I would actually just load the record I want from 
the database and not chew up all that memory, but this is just an 
example anyway.


I guess it could allow you to somewhat consolidate a two-dimensional 
array down to a single dimension.  In order to use the data, you'd have 
to use array_keys() or something similar to use it though.


It's an interesting idea, but I don't know how practical it would be.

--
Ray Hauge
www.primateapplications.com

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



[PHP] Closures

2008-03-18 Thread Ray Hauge
I've been reading up on some of the parts of PHP that has been suggested 
could be improved so that I could be more well informed.  One of the 
more "interesting" (for lack of a better word) suggestions is closures. 
 I've used closures primarily in JavaScript, and they are handy in that 
context, but JavaScript handles events and other more dynamic situations 
like that.


I can't really think of any good examples of why I'd want to use a 
closure instead of just calling functions or class methods in PHP. 
Variable functions and call_user_func*() have worked for any of the 
cases where I did need to be a bit more dynamic.


I found a great summary of some discussion on the internals mailing list 
over here: http://devzone.zend.com/node/view/id/2013#Heading1


After reading that article through, I do like Wez's idea of how to 
create anonymous functions.  The point about it causing confusion with 
people coming from other languages definitely applies though.  This 
article also gives me a second idea for this post.  How many people 
would want closures in PHP?


In summary:

Would you want closures in PHP, and why?

--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] Closures

2008-03-18 Thread Ray Hauge

Nathan Nobbe wrote:
if we were going to see support for anything anonymous that i would 
welcome it would be anonymous objects and the ability to create an 
object on the fly from an interface as per java 5. 


I'm not sure if this would solve your problem (my lack of java knowledge 
is showing), but you can create objects either by creating a new 
stdClass() object, or by using (object)NULL.  Example:


test1 = 1;
$object->test2 = 2;

echo $object->test1 . "\n";

echo $object->test2;

?>

After trying to add a way to call a function from an object variable, I 
have come to the conclusion that it's kinda ugly.


test = 2;
$obj->myTestFunc = "myTestFunc";

function myTestFunc () {
   return "test";
}

echo call_user_func($obj->myTestFunc) . $obj->test;

?>

Does anyone have a link to some documentation about the stdClass?  All I 
could find was a bunch of bug reports and other stuff that wasn't what I 
was looking for.  I would have thought there'd be a page for it in the 
manual, but I didn't find one there either.


--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] why use {} around vraiable?

2008-03-20 Thread Ray Hauge

Lamp Lists wrote:

hi,
I saw several times that some people use this
 
$parameters = array(

  'param1' => "{$_POST["param1"]}",
  'param2' => "{$_POST["param2"]}"
 );

or

 $query = mysql_query("SELECT * FROM table1 WHERE id='{$session_id}'");

I would use:

$parameters = array(
  'param1' => $_POST["param1"],
  'param2' => $_POST["param2"]
 );
 
 and


 $query = mysql_query("SELECT * FROM table1 WHERE id=' ".$session_id." ' ");


does it really matter? is there really difference or these are just two 
"styles"?

thanks.

-ll


  

Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ


The brackets are used to enforce that the entire contents between them 
is a variable.  It helps when you're using class members.


$example = "this is an {$example->text}";

It's also handy when you're putting variables in a heredoc.

I would suggest not using "{$_POST["param1"]}", like you said.  It's 
just going to make PHP figure out the string, then put the value in that 
string.  If you really wanted to make sure it's a string type then you 
can do (string)$_POST['param1'].


The short answer is you can do it the way you're doing and everything 
will work out just fine :)


--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] spider

2008-03-21 Thread Ray Hauge

tedd wrote:

Hi gang:

How do you spider a remote web site in php?

I get the general idea, which is to take the root page, strip out the 
links and repeat the process on those links. But, what's the code? Does 
anyone have an example they can share or a direction for me to take?


Also, is there a way to spider through a remote web site gathering 
directory permissions?


I know there are applications, such as Site-sucker, that will travel a 
remote web site looking for anything that it can download and if found, 
do so. But is there a way to determine what the permissions are for 
those directories?


If not, can one attempt to write a file and record the 
failures/successes (0777 directories)?


What I am trying to do is to develop a way to test if a web site is 
secure or not. I'm not trying to develop evil code, but if it can be 
done then I want to know how.


Thanks and Cheers,

tedd



Have a look at something like this:

http://simplehtmldom.sourceforge.net/

I haven't used it, but if it works you should be able to pull up a list 
of all the  tags quite easily through the DOM ala:


foreach($dom->find('a') as $node)
  echo $node->href . '';

--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] google books

2008-03-24 Thread Ray Hauge

John Pillion wrote:

Not a PHP question. but could someone point me in the direction of how to
download/display only a portion of a PDF, much like google books does?  For
example, if you have a 200 page pdf, but the user wishes to see the portion
that is on page 150. rather than downloading the entire PDF, only
download/display page 150?

 


I would like to avoid having to split them into 200 individual PDF's
(whether manually or automatically).

 


Any suggestions?

 


- JP




You could use FPDF and FPDI to just load up the one page:

http://www.setasign.de/support/manuals/fpdi/

Just use importPage($thePageNumberYouWanted);



$pdf = new fpdi('P', 'pt', 'letter');

$pdf->setSourceFile(self::PATH);
$tpl = $pdf->ImportPage(1);
$pdf->AddPage();
$pdf->useTemplate($tpl, 0, 0);

$data = $pdf->buffer;
$pdf->closeParsers();

header("Content-type: application/pdf");
header("Content-disposition: inline; filename=FileName.pdf");
header("Content-length: " . strlen($data));

echo $data;



I just realized that the version of FPDI I've been using is a little 
old.  There's a new update out, so some of the above code might change a 
little.


--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] question about linux editor

2008-03-25 Thread Ray Hauge

Sudhakar wrote:

i need to connect to the linux server using an editor. can anyone suggest
which would be an ideal linux editor to connect to the server.
apart from the ip address, username and password are there any other details
i would need to connect to the server.

please advice.

thanks.



I also will typically use SSH + vi, but Zend Studio (not sure about 
Eclipse) can open an SSH connection and edit files that way.


--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] Dates Again

2008-03-31 Thread Ray Hauge

Zoltán Németh wrote:

VamVan írta:

Hello All,

I have a date in 2008-03-29 12:15:00  format.

   - How can I reduce one day from it?
   - How can I reduce one hour from it?
   - How can I add 1 hour to today's date?

Thanks



just convert it to a timestamp with strtotime()
then you can manipulate it by adding/substracting
- 86400 for a day
- 3600 for an hour
then convert back with strftime()

http://hu.php.net/strtotime
http://hu.php.net/strftime

greets,
Zoltán Németh



I believe you can also use strtoime() 
http://us.php.net/manual/en/function.strtotime.php


$time = strtotime($inputTime);
$time = strtotime('-1 day', $time);
$outputTime = strftime('%Y-%m%d', $time);

I'm not sure which is more efficient, but it helps when you're looking 
for "next thursday" or other things like that.


--
Ray Hauge
www.primateapplications.com

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



[PHP] April Fools Easter Egg

2008-04-01 Thread Ray Hauge

Don't forget to check your phpinfo() page for the annual easter egg.

--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] April Fools Easter Egg

2008-04-01 Thread Ray Hauge

tedd wrote:

At 9:23 AM -0500 4/1/08, Ray Hauge wrote:

Don't forget to check your phpinfo() page for the annual easter egg.

--
Ray Hauge
www.primateapplications.com



You got me.

Cheers,

tedd



Here's the image that I see on PHP 5.1.0. My 5.2.5 site has a distorted 
image instead of the dog.


5.1.0:
http://www.primateapplications.com/info.php.gif

5.2.5:
http://www.primateapplications.com/info.php

--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] Evaluating math without eval()

2008-04-12 Thread Ray Hauge

Jason Norwood-Young wrote:

On Thu, 2008-04-10 at 13:15 +0100, Richard Heyes wrote:

First post to this list! I'm trying to figure out how to evaluate a
string with a mathematical expression and get a result, but without
using eval() as I'm accepting user input into the string. I don't just
want addition, subtraction, multiplication and division - I'd like to
take advantage of other functions like ceil, floor etc. 


So the string "18-10" should give me 8, "ceil(1/2)*10" should be 10 (if
my maths is correct) and the string "18-10;\r\nunlink('/var/www/*');"
should not execute.
If you can provide your users with distinct inputs (if it's a form) go 
that route.


Thanks Richard

Unfortunately it's not that simple. The equation sits in a DB and can be
anything - eg. ((([valuation]/[purchaseprice])/100)*100)/[numyears]
would be a typical field. [valuation], [purchaseprice] and [numyears]
gets replaced by relevant fields from user-entered data. But the system
is expandable which means I don't know what the equations, data or
fields are going to be beforehand. 


I'm working on some kinda preg_replace function to sanitize the data at
the moment and then run an eval - arg I hate regexp! Ideally eval would
have some kind of sandboxing option, or you could limit the functions
available in an eval.

J




you might be able to leverage a call to expr on a bash sell.  Just 
replace the variables you're expecting with preg_replace or some similar 
function.


http://hacktux.com/bashmath
http://sysblogd.wordpress.com/2007/08/26/let-bash-do-the-math-doing-calculations-using-that-bash/

I'm not sure if that's any more secure than eval though.

--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] Should This Newbie Learn From Dreamweaver?

2008-04-22 Thread Ray Hauge

revDAVE wrote:

First of all - I know this is an entirely subjective question, and I know
there's no single approach to learning this technology. I'm just looking for
a few hints from seasoned professionals basically whether Dreamweaver
verbose code (at least it looks like that to me at this beginning point) is
all 'needed & necessary'...
 


Like you said it's all subjective, but my opinion is to learn the basics 
first, then you can rely on your tools to take the mundane work out of 
the way for you.  I'd still suggest using an editor with code completion 
though, because it will help you when you're trying to remember 
parameter orders or even function names to a point.


After you feel comfortable with that, then you'll be able to understand 
what the program is doing for you and it won't be a "black box" that 
really is unsupportable.  I find the best way to do that is to come up 
with some little program that you code up for fun to help get you 
through the learning stages.  You'll learn more figuring out how to get 
something to work than just copying and pasting code.


That's my 2 cents.  Hope that helps.

--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] peer review (was php framework vs just php?)

2008-04-25 Thread Ray Hauge

Jay Blanchard wrote:

I did a quick and dirty of just one of those functions. This function
takes a table and creates a form based on the table. It needs quite a
bit of refining, but I am willing to share and let you guys and gals
throw suggestions;


I use a very similar style of approach, but it's more on a field by 
field basis rather than a whole form.  I also wrote mine on company 
time, so here's an example:






'first_name'); ?>
UI::getBlankTextField($table, 'first_name'); ?>



'city'); ?>
?>



'state'); ?>
'state'); ?>
'zip'); ?>
?>





The UI class figures out the max-length of the field, and there are also 
configurations to determine what type of field it is (text, phone, date, 
textarea, etc.) and security settings based on the user logged in.  This 
has helped keep my template files very clean, and I still have full 
control over the form by not including the fields I don't want.


--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] creating an xls file from mysql data

2008-05-12 Thread Ray Hauge

Chris wrote:

Richard Kurth wrote:

This script will create an xls file from the data that is sent to it
When I run this it only gets one recored and it is supposet to get all
the records that are past by the  $_POST[selectedcontactlist]
I think I have a } in the wrong place but I can not figure it out
anybody have a suggestion

$_POST[selectedcontactlist]="3,45,65,23,12,4,56"; //this is a sample of
what is past

$ExplodeIt = explode(",",rtrim($_POST[selectedcontactlist],","));
$Count = count($ExplodeIt);
for ($i=0; $i < $Count; $i++) {
$sql = "SELECT * FROM contacts WHERE id = '$ExplodeIt[$i]'";


Instead of doing that, do this:

/**
* This section makes sure the id's you are going to use in your query
are actually integer id's.
* If they aren't, you'll get an sql error.
*
*/
$ids = array();
foreach ($_POST['selectedcontactlist'] as $id) {
  if (!is_int($id)) {
continue;
  }
  $ids[] = $id;
}

// all posted values are duds? show an error.
if (empty($ids)) {
  echo "No id's are numeric, try again";
  exit;
}

$sql = "select * from contacts where id in (" . implode(',', $ids) . ")";


That'll get everything for all of those id's and then you can loop over
it all once:

// print out the header for the csv file here.

// then loop over the results:
while ($row = mysql_fetch_assoc($sql_result)) {
  // put it into file here.
}

// close the file
// print it out.



Or you can do it straight from MySQL, which is a lot faster:

SELECT [fields] INTO OUTFILE '/path/to/file.csv' FIELDS TERMINATED BY 
',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n' FROM [tables] 
WHERE [conditions]


If you want a header row, then you can use a UNION statement.

--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] SCanning text of PDF documents

2008-05-15 Thread Ray Hauge

Angelo Zanetti wrote:

Hi All.

This is a quick question.

A client of ours wants a solution that when a PDF document is uploaded that
we use PHP to scan the documents contents and save it in a DB.

I know you can do this with normal text documents using the file commands
and functions.

Is it possible with PDF documents?

My feeling is NO, but perhaps someone will prove me wrong.

Thanks in advance.

Angelo

Web: http://www.elemental.co.za 






One thing you'll have to watch is that if the PDF was created by a 
scanner, then the "text" on the PDF is actually just an image and cannot 
be read without OCR.  I got stumped on that one for a while when I was 
doing something similar :)


--
Ray Hauge
www.primateapplications.com

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



[PHP] Enterprise

2008-05-20 Thread Ray Hauge
I just read an interesting article about enterprise software.  One of 
the most common arguments against PHP tends to be "It's not enterprise 
ready."  This article talks more about ruby, but it could be about any 
"non-enterprise" language as well.


http://lists.canonical.org/pipermail/kragen-tol/2005-April/000772.html

I recently got a new job at a hospital, and the "enterprise software" 
they have is no where near as high quality as it could/should be.  This 
is my first job at a somewhat large organization (500+ employees) so I 
was kind of shocked at the state of their software.  Typically 
healthcare systems are further behind in the technology adoption, but 
having to deal with workarounds all day long sure gets old.


--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] Canvas examples

2008-06-15 Thread Ray Hauge

Richard Heyes wrote:
Does anyone have any more examples of the new canvas element they've 
written?


FF only: http://www.phpguru.org/canvas.html



This is a pretty interesting use of Canvas as well.  Thanks for sharing!

http://ejohn.org/blog/processingjs/

--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] Canvas examples

2008-06-16 Thread Ray Hauge

Richard Heyes wrote:
I guess the other browser doesn't do much with  ? 


Nope. Eg:


This gets shown on none supporting browsers, but not on supportive
browsers.


MSIE just shows the text and doesn't do anything with the canvas.

One thing about using a canvas is bandwidth. If it's a big concern I 
would hazard a guess that a bar chart (for example) would cost less in 
terms of code required to build the image compared to JPGraph, and also 
less in terms of output (particularly if you were to use output 
compression).




Another idea for dynamic graphing could be:

http://solutoire.com/plotr/

It also uses the canvas element, but if you use excanvas for IE it'll 
work in most newer browsers.  I've used it in a project to provide 
dynamic bar graphs from a queue so that they could see in semi-real time 
how many customer requests were in different queues.  It was an internal 
app, or else I'd link it :(


--
Ray Hauge
www.primateapplications.com

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



[PHP] XUL and PHP - what's your opinion?

2006-06-28 Thread Ray Hauge
I keep hearing about XUL, and I was wondering what the opinion of the masses 
was on this subject for an internal application where the browser is 
pre-determined.

From my point of view I, having only read about it and not used it, is that 
XUL would make your applications look more like a desktop application.  Some 
of the widgets they provide come in handy, like tables that can sort 
themselves instead of using AJAX/another page hit.  

The down sides that I see is there would be a 99.999% chance of a learning 
curve for any new developers that come into the company.  Also, I'm not sure 
if XUL would cause extra programming overhead than regular HTML/JS.

-- 
Ray Hauge
Programmer/Systems Administrator
American Student Loan Services
www.americanstudentloan.com
1.800.575.1099

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



Re: [PHP] $previous variable ?

2006-07-12 Thread Ray Hauge
On Wednesday 12 July 2006 14:31, Richard Lynch wrote:
> On Tue, July 11, 2006 2:24 am, Roman Rumisek wrote:
> > I am using apache 2.0.50 and php 4.4.3RC2 as mod (on Mandrake 10.1).
> > When I run this script:
> >
> > 
> >
> > in cli php, i give 'Undefined variable' error message - OK.
> > But under apache, this variable has value 'N'. Is  it error ?
> > I found nothing about $previous variable in php.ini and php config
> > directories.
>
> My first guess would be that you have "register_globals" set to "ON"
> in Apache, and $previous is set in Cookies or Get data.
>
> It's also possible that you have managed to do this in some setup with
> session.auto_start and where $_SESSION['previous'] is set to "N"
>
> Having register_globals set to "ON" is probably a Bad Idea for various
> reason.
>
> Using short tags (
> Finally, echo "$previous"; is silly, as the quote marks serve no
> purpose at all.  echo $previous; would be better.
>
> --
> Like Music?
> http://l-i-e.com/artists.htm

A bit off topic, but I hadn't heard about short tags being a bad idea.  What 
reasons make short tags worse than the regular tags.  Just curious.

Ray

-- 
Ray Hauge
Programmer/Systems Administrator
American Student Loan Services
www.americanstudentloan.com
1.800.575.1099

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



Re: [PHP] $previous variable ?

2006-07-12 Thread Ray Hauge
[snip]
Yep, they can interfere with xml processing, and they also make your code
less portable, as they may not be enabled in another environment. If you
are sure your code is never going to move or be mixed with xml, by all
means use them, but why not get into good habits?
[/snip]

Good points.  Thanks.

-- 
Ray Hauge
Programmer/Systems Administrator
American Student Loan Services
www.americanstudentloan.com
1.800.575.1099

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



Re: [PHP] Zend Studio, phpMyAdmin, and mysql.sock

2006-07-14 Thread Ray Hauge
On Thursday 13 July 2006 21:53, Dave M G wrote:
> PHP List,
>
> I am trying out Zend Studio for editing and debugging my PHP scripts.
>
> When I first ran it, it kept giving me this error:
> Can't connect to local MySQL server through socket /tmp/mysql.sock
>
> After some research on the web, I found that this could be solved by
> editing /etc/mysql/my.conf so that it said:
> socket = /tmp/mysql.sock
>
> I was not thrilled about the idea of changing my MySQL server to meet
> the needs of one application, but I wanted to see if it would work, and
> it does.
>
> But, now phpMyAdmin doesn't work, saying:
> The server is not responding (or the local MySQL server's socket is not
> correctly configured)
>
> So what I really want to do is put my /etc/mysql/my.conf file back to
> the way it was, and make Zend listen on mysql's default socket, not on
> /tmp/mysql.sock.
>
> But, after much searching on the web, and in the Zend forums, I can't
> find any information on configuring Zend in this matter.
>
> What do I need to do to make Zend listen on the MySQL socket that I want
> it to listen on?
>
> (Which, by the way, is /var/run/mysqld/mysqld.sock)
>
> Thank you for any advice.
>
> --
> Dave M G

I ran into this problem myself.  I had to not use --skip-networking.  I use 
Slackware linux, so that was in the /etc/rc.d/rc.mysqld script.

I don't know why that would make PHPMyAdmin not work though.

HTH

-- 
Ray Hauge
Programmer/Systems Administrator
American Student Loan Services
www.americanstudentloan.com
1.800.575.1099

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



Re: [PHP] Return XML using PHP and Content-Type with UTF-8 breaks the UTF-8

2006-07-19 Thread Ray Hauge
On Wednesday 19 July 2006 09:27, Mathijs wrote:
> Hello there,
>
> I Have an problem with UTF-8 and XML.
>
> I Output perfect XML (according to IE, Opera and Firefox).
> I use the Content-Type header with "text/xml; charset=utf-8".
> For some reason this breaks UTF-8 output.
> When i remove it it works. But i need the text/xml header.
>
> If i save an document as .xml with the same contents as UTF-8 it works.
>
> Is this a known problem?
>
> Thx in advanced.

I would try just specifying UTF-8 in the XML header, and remove the charset 
from the content-type header, and just have the text/xml.



HTH

-- 
Ray Hauge
Programmer/Systems Administrator
American Student Loan Services
www.americanstudentloan.com
1.800.575.1099

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



Re: [PHP] Basic PHP knowledge test

2006-07-19 Thread Ray Hauge
On Wednesday 19 July 2006 10:31, John Nichel wrote:
> We're looking to hire an entry level php programmer here, and I've been
> tasked with writing the test to evaluate the potential candidates.
> Being the lazy guy that I am, I naturally turned to Google to see if I
> could find some tests that I could use.  After clicking thru many links,
> and finding mostly 'basic php tutorials', I've come here to ask you
> people to do my homework for me.  ;)  Does anyone have any
> links/resources for a basic php knowledge test?  If not, I'll have to
> write one from scratch myself, and mess up the rest of my day of goofing
> off/sleeping.
>
> --
> John C. Nichel IV
> Programmer/System Admin (ÜberGeek)
> Dot Com Holdings of Buffalo
> 716.856.9675
> [EMAIL PROTECTED]

I just recently ran into the same problem.  I got tired of trying to find one, 
so I made it myself.  It's very specific to what we do here though.  I'd 
definitely be interested in that info though, because we're still looking, 
and I'm not totally happy with mine, as I didn't have a whole lot of time to 
write it.

-- 
Ray Hauge
Programmer/Systems Administrator
American Student Loan Services
www.americanstudentloan.com
1.800.575.1099

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



Re: [PHP] Basic PHP knowledge test

2006-07-19 Thread Ray Hauge
On Wednesday 19 July 2006 11:12, John Nichel wrote:
> Yeah, reading the writing on the wall, I think I'm just going to have to
> suck it up, and write it.  The worst part of it is, I'm going to have to
> be involved in the interview process, and I'm *not* a people person.  ;)
>
> I think I'll go with a few syntax questions (not really worried about
> that aspect, cause even after 8 years of doing php, I still hit the
> manual a few times a week), maybe have the people write a basic function
> or two to check how clean/readable their code it.  Possibly also test
> how efficient their code would be (like to they call a function inside
> of a loop to get a static value that could have been set outside the
> loop).  Basic db stuff...ugh, I don't feel like doing this.
>
> I'll post what I come up with here; maybe we (this list) can combine
> ideas and such, and actually put together a pretty good test or two so
> we can spare the next poor soul who gets put into this position by MBA
> wielding managers.

That's pretty much what I did.  I went with questions that would show how much 
they understand from a conceptual level.  I don't know many people who don't 
have www.php.net as a bookmark.  I did basic questions to show they 
understood OOP, recursion, pass-by-reference, etc.

I also had to be in the interview.  There were a lot of odd moments of silence 
when people were looking at me to ask some questions.  I just wanted him to 
do the quiz and that was pretty much it ;)

-- 
Ray Hauge
Programmer/Systems Administrator
American Student Loan Services
www.americanstudentloan.com
1.800.575.1099

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



Re: [PHP] Basic PHP knowledge test

2006-07-20 Thread Ray Hauge
On Thursday 20 July 2006 07:23, John Nichel wrote:
> Yeah, one of my earliest thoughts on this was to have them write
> something simple like connecting to a db, selecting multiple rows,
> parsing our the result, and displaying it in some fashion.

Don't forget making it secure.  Here is one of my questions people can use if 
they like.  Feel free to re-word it.  I'm a programmer, not a writer ;)

What change(s) would you make to the following code to make it more secure?

$id = $_GET['id'];
mysql_query(“DELETE FROM myTbl WHERE id = $id”);

I like this question, because they have to know at least the fundamentals of 
PHP security.

-- 
Ray Hauge
Programmer/Systems Administrator
American Student Loan Services
www.americanstudentloan.com
1.800.575.1099

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



Re: [PHP] Session breaks when form data submitted

2006-07-20 Thread Ray Hauge
On Thursday 20 July 2006 09:09, Jeffrey wrote:
> We have a site which requires users log in. Once they do so a session is
> created (session_start), some data is saved as session data,
> particularly data which identifies the user, their privileges, etc. If
> the session ends, breaks, etc. The user must log in again.
>
> There are also forms on the site. When a user submits a form, data, both
> posted and session, is saved to a MySQL database.
>
> If a session breaks when a user submits data via the form, the result is
> that the user must log in again, the data is lost and the user unhappy.
> This happens rarely - but when it does, it can upset the user who has
> put effort into completing the form.
>
> Is there a simple yet secure way of preventing this problem - for
> example passing the session id  with the form and resurrecting the
> session if it has broken?
>
> Thanks,
>
> Jeff

To my knowledge, this particular behavior is by design.  After the time limit 
for a session has been reached, then the garbage collection will usually 
clean it up.  The only way to not break a session is to never clean up the 
session files, or set the timeout to a day or so.

I wouldn't suggest sending the PHPSESSID via a form.  That leads to people 
being able to hijack sessions


; After this number of seconds, stored data will be seen as 'garbage' and
; cleaned up by the garbage collection process.
session.gc_maxlifetime = 1440


HTH

-- 
Ray Hauge
Programmer/Systems Administrator
American Student Loan Services
www.americanstudentloan.com
1.800.575.1099

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



Re: [PHP] [Case Closed - Idiot Found Behind Keyboard] Re: [PHP] APC - problems with CLI & odd return values from apc_clear_cache()

2006-07-29 Thread Ray Hauge
On Saturday 29 July 2006 05:47, Jochem Maas wrote:
> Jon Anderson wrote:
> > Just replying to the list on this one 'cause I'm pretty sure you're on
> > it. :-)
> >
> > AFAIK, with many caches the web server cache and CLI caches are
> > exclusive to each process. The APC manual seems to suggest that the CLI
> > cache is not connected to the web server cache:
> >
> > From: http://ca.php.net/manual/en/ref.apc.php
> >
> > apc.enable_cli *integer*
> > 
> >
> >Mostly for testing and debugging. Setting this enables APC for the
> >CLI version of PHP. Normally you wouldn't want to create, populate
> >and tear down the APC cache on every CLI request, but for various
> >test scenarios it is handy to be able to enable APC for the CLI
> >version of APC easily.
>
> thanks, you are right - what I thought had been working all this time had
> not, or atleast the code did work but it was clearing the cache belonging
> to the CLI, which was a pointless act!
>
> I'm an idiot.
>
> but wanting to clear the webservers APC cache from a cmdline script doesn't
> seem like such a stupid thing to want to do. but there is no nice way of
> doing it; so now I do this at the end of my cmdline script instead:
>
> exec('apachectl -k graceful');
>
> which sucks in so many ways it hurts  but it does clear the APC cache

You could create a script that basically just does apc_clear_cache() et all. 
and call it from lynx, curl, wget, etc. and throw that into a cron job.  That 
would technically get you to call the script from the cli, but it should 
clear the webserver cache. 

Ray

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



Re: [PHP] Retrieving response headers from an off-site page

2006-07-31 Thread Ray Hauge
On Monday 31 July 2006 17:36, John Gunther wrote:
> I'm trying to programatically retrieve a sales tax lookup page using
> file_get_contents() but the page doesn't return data unless a session id
> is first retrieved and then supplied.
>
> You can see how it works as follows:
>
> The first time I send the following request:
> http://www7.nystax.gov/STLR/stlrHome?street=48%20central%20ave&zip=12472&B1
>=Lookup%20Address I get an empty form back, and one of the response headers
> is Set-Cookie with a value of, say,
> JSESSIONID=0001WQEmZF6tI-yClq4S9_7a8ii:10amela49;Path=/
>
> If I then reload the same URL, the resulting page includes the desired
> info, probably because the second time one of the request headers is
> Cookie with a value of JSESSIONID=0001WQEmZF6tI-yClq4S9_7a8ii:10amela49
>
> I want to get the second version of the page, the one with data, using
> file_get_contents(), but it appears I first have to get the page to
> return a sessionid and then I have to send it in a Cookie header the
> second time.
>
> Reading the first GET's response headers and sending the needed request
> header on the second GET - in combination with file_get_contents() - is
> just beyond me. Can anyone enlighten me?
>
> John Gunther

I deal with screen-scraping a lot at work.  I would suggest using cURL to 
store the cookie data, and then subsequently get the data you need.

check out

http://us3.php.net/manual/en/ref.curl.php

and the curl man page for more info.

or, you can use your own HTTP implementation ;)

HTH

-- 
Ray Hauge
Programmer/Systems Administrator
American Student Loan Services
www.americanstudentloan.com
1.800.575.1099

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



Re: [PHP] writing to fild on another server

2006-08-04 Thread Ray Hauge
On Friday 04 August 2006 10:07, Robert Cummings wrote:
> You mean the http protocol won't let you write. At any rate, you can try
> using ftp instead of http (you'll need to make sure it's set up on the
> images server). Alternatively you can use a network file system or use
> CURL or low level sockets to POST them to your images server.
>

That's what I was thinking if you wanted to keep it all HTTP.  You could have 
an script on the images server that you submit the file to through a POST.  
Then the script would move it to the appropriate place.  Remember to keep 
security in mind though.

-- 
Ray Hauge
Programmer/Systems Administrator
American Student Loan Services
www.americanstudentloan.com
1.800.575.1099

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



Re: [PHP] Cron running 'Hello world' script dies with "Could not startup."

2006-08-08 Thread Ray Hauge
On Tuesday 08 August 2006 08:47, Ivo F.A.C. Fokkema wrote:
> > Does the user running the cron have permission to execute the php binary?
>
> Yes, the file's owner is me and it's my crontab. Also, I've made the file
> readable to all, just in case. All directories up the directory tree are
> readable/executable, as well.

I think he's asking if the php program is executable to you, the user.  It is 
possible that it would only have execute for owner and group, not other.

-- 
Ray Hauge
Programmer/Systems Administrator
American Student Loan Services
www.americanstudentloan.com
1.800.575.1099

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



Re: [PHP] Cron running 'Hello world' script dies with "Could not startup."

2006-08-08 Thread Ray Hauge
On Tuesday 08 August 2006 09:01, Ivo F.A.C. Fokkema wrote:
> On Tue, 08 Aug 2006 09:01:42 -0500, Ray Hauge wrote:
> > On Tuesday 08 August 2006 08:47, Ivo F.A.C. Fokkema wrote:
> >> > Does the user running the cron have permission to execute the php
> >> > binary?
> >>
> >> Yes, the file's owner is me and it's my crontab. Also, I've made the
> >> file readable to all, just in case. All directories up the directory
> >> tree are readable/executable, as well.
> >
> > I think he's asking if the php program is executable to you, the user. 
> > It is possible that it would only have execute for owner and group, not
> > other.
>
> Sorry, yes, The PHP binary is executable by all. Actually, I'm very sure
> the error message "Could not startup." is generated by PHP-cli. When
> googling on that exact message, I found it in the PHP-cli source code
> (including the period at the end). However, I cannot determine from the
> PHP-cli source code what's up.

It looks like when you run the script, then it works just fine, but it blows 
up when you run it through cron.

Two things I would check:

1) Cron can read your *.php files.

2) Cron can run php

to test #2, have cron do a php -i and see what happens.

-- 
Ray Hauge
Programmer/Systems Administrator
American Student Loan Services
www.americanstudentloan.com
1.800.575.1099

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



Re: [PHP] Create an EUC-JP encoded file just for download, not to be kept on server

2006-08-09 Thread Ray Hauge
On Wednesday 09 August 2006 11:20, Dave M G wrote:
> PHP List,
>
> In the last stage of my current script, I need to take a bunch of data
> from the database and put it into a text file for the user to save to
> their computer and import into an application.
>
> The file being created is just a list of Japanese words and definitions
> delineated by tabs.
>
> The file format should be a text file. Actually, it could also be CSV
> file, since it's tab delineated data.
>
> The application being imported to only accepts EUC-JP encoding for text
> files that include Japanese text, so my data, which is stored in the
> database as UTF-8, will need to be converted to EUC-JP at some point
> along the way to being written to the file.
>
> This file need not ever be stored on the server. In fact, I'd rather it
> not so as to avoid any headaches with permissions settings (which always
> give me a headache, but that's a rant for another day).
>
> So, I'm looking on php.net for functions that would be able to create a
> file out of some data and pass it along to the user.
>
> But it seems that the assumption of all the file functions (that I've
> found) such as fwrite(), fopen(), file(), readfile(), and others are all
> about taking an existing file and working with it. And more importantly,
> all of them seem to assume that the place where the file would be stored
> is on the servers system, and not immediately passed on to the user.
>
> I have a suspicion that this is one of those situations where the
> starting point is assumed to be so simple that no one goes out of their
> way to document or explain it.
>
> I'm too lost to know where to begin.
>
> How do I create a file that the user saves, and is not stored on the
> server?
>
> --
> Dave M G

For re-encoding to EUC-JP, I would check out the multibyte functions... 
specifically mb_convert_encoding:

http://us2.php.net/manual/en/function.mb-convert-encoding.php

HTH
-- 
Ray Hauge
Programmer/Systems Administrator
American Student Loan Services
www.americanstudentloan.com
1.800.575.1099

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



Re: [PHP] Best way to get PHP5

2006-08-09 Thread Ray Hauge
On Wednesday 09 August 2006 12:03, Jonathan Duncan wrote:
> On Wed, 9 Aug 2006, Chris W. Parker wrote:
> > Hello,
> >
> > Generally (well, actually 100%) I just use whatever version of PHP is
> > included with a certain distro (Redhat pre-Fedora, Fedora Core, CentOS).
> > None of the versions I've used have come with PHP5 and I'd really like
> > to get with the times and use PHP5.
> >
> > I know that Fedora Core 5 offers PHP 5.1.2 but I've heard some negative
> > things about it in general (FC5).
> >
> > I've never compiled PHP myself so admittedly I'm a bit skeered... Is the
> > recommended path to just go with whatever distro I prefer and then
> > download PHP5 from php.net and install it myself?
> >
> > Thanks,
> > Chris.
>
> Yes, I would recommend that.  If you are serious about using PHP for a
> while it would be benefitial to you to understand the installation aspect
> of the language.  If you are comfortable with the command line this should
> be pretty easy for you.  If not it will be a bit harder but still very
> possible.  Here are installation instructions from php.net:
>
> http://www.php.net/manual/en/install.unix.php
>
> Good luck!
>
> Jonathan

Also, when compiling it yourself you can specify what extensions you want.  
This allows you to keep your install as minimal as possible for your needs, 
which increases the performance of PHP.

-- 
Ray Hauge
Programmer/Systems Administrator
American Student Loan Services
www.americanstudentloan.com
1.800.575.1099

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



[PHP] Compiling and iconv

2006-08-11 Thread Ray Hauge
I use Slackware linux, and XMLRPC is not compiled in by default with my 
distro, so I'm compiling PHP myself.  It's always been a simple enough task.  
First I get and install the required xmlrpc-epi libraries, and then I compile 
PHP telling it where I just installed them.  Now I get this error message:

undefined reference to `libiconv'

when compiling PHP.  I did some searching, and the only thing I've found in 
reference to this error was a bug in version 4.3.10.  Has anyone run into 
this issue, or have some suggestions?

I have checked that /usr/include/iconv.h is there, and it defines all the 
iconv_* and iconv compiler flags etc.  I can also vouch that using iconv on 
the command line works just fine.

Thanks,
-- 
Ray Hauge
Programmer/Systems Administrator
American Student Loan Services
www.americanstudentloan.com
1.800.575.1099

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



[PHP] Problem Loading Extension

2006-08-11 Thread Ray Hauge
Hello everyone,

I successfully compiled PHP 4.4.3 and PHP 5.1.4 today.  I'm having a problem 
with loading the PDFLib extension (pdflib_php.so).  It works fine in PHP 4, 
but PHP5 is not loading it.  I do know that I have the file in the correct 
location (same as the mysql.so file), and when I take out mysql.so, then 
mysql functions are not available.  I am not sure why this module is not 
loading.

I checked the error_log, and I didn't get any error messages at all.  STFW 
didn't give me a whole lot of information.  Anyone have any ideas of where to 
look to find out why it's not loading?

Thanks,
-- 
Ray Hauge
Programmer/Systems Administrator
American Student Loan Services
www.americanstudentloan.com
1.800.575.1099

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



Re: [PHP] Problem Loading Extension

2006-08-11 Thread Ray Hauge
On Friday 11 August 2006 18:15, Michael B Allen wrote:
> On Fri, 11 Aug 2006 17:50:12 -0500
>
> Ray Hauge <[EMAIL PROTECTED]> wrote:
> > Hello everyone,
> >
> > I successfully compiled PHP 4.4.3 and PHP 5.1.4 today.  I'm having a
> > problem with loading the PDFLib extension (pdflib_php.so).  It works fine
> > in PHP 4, but PHP5 is not loading it.  I do know that I have the file in
> > the correct location (same as the mysql.so file), and when I take out
> > mysql.so, then mysql functions are not available.  I am not sure why this
> > module is not loading.
> >
> > I checked the error_log, and I didn't get any error messages at all. 
> > STFW didn't give me a whole lot of information.  Anyone have any ideas of
> > where to look to find out why it's not loading?
>
> Was the module compiled for 5? Check the apache error.log. If the .so
> can't resolve a symbol or similar, usually that type of error appears in
> the apache error log. Also, of course the .so needs to be in the right
> location and the php.ini needs the appropriate extension directive.
>
> Mike

Thanks for the info.  I found out I had to download the latest version of 
PDFlib to support PHP 5.1.X.  It's working fine now.

-- 
Ray Hauge
Programmer/Systems Administrator
American Student Loan Services
www.americanstudentloan.com
1.800.575.1099

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



Re: [PHP] Compiling and iconv

2006-08-14 Thread Ray Hauge
On Sunday 13 August 2006 22:00, Chris wrote:
> Ray Hauge wrote:
> > I use Slackware linux, and XMLRPC is not compiled in by default with my
> > distro, so I'm compiling PHP myself.  It's always been a simple enough
> > task. First I get and install the required xmlrpc-epi libraries, and then
> > I compile PHP telling it where I just installed them.  Now I get this
> > error message:
> >
> > undefined reference to `libiconv'
> >
> > when compiling PHP.  I did some searching, and the only thing I've found
> > in reference to this error was a bug in version 4.3.10.  Has anyone run
> > into this issue, or have some suggestions?
> >
> > I have checked that /usr/include/iconv.h is there, and it defines all the
> > iconv_* and iconv compiler flags etc.  I can also vouch that using iconv
> > on the command line works just fine.
>
> Try explicitly telling php where iconv is by adding this option to your
> configure command:
>
> --with-iconv-dir=/usr

Thanks for the reply.  I enentually got it to comipile by adding "-liconv" to 
the LDFLAGS environment variable to tell it to actually link in the iconv 
code.

-- 
Ray Hauge
Programmer/Systems Administrator
American Student Loan Services
www.americanstudentloan.com
1.800.575.1099

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



[PHP] OT? XUL XML-RPC Client

2006-08-14 Thread Ray Hauge
We've decided to start using XUL for intranet applications.  I've written up 
my XML-RPC server (php script) and I had found a tutorial showing how to use 
XML-RPC through XUL/JavaScript, but now I can't find any information on it.  
Anyone have any experience/links to information about XML-RPC with XUL?

Thanks,
-- 
Ray Hauge
Programmer/Systems Administrator
American Student Loan Services
www.americanstudentloan.com
1.800.575.1099

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



Re: [PHP] Capturing System output

2006-08-15 Thread Ray Hauge
On Tuesday 15 August 2006 09:19, Brad Bonkoski wrote:
> Hello All..
>
> Had this problem in the past, and always programmed around it, but
> wondering if there is an easier way.
>
> Good Example:
> Creating a setup for connecting to a mysql database.  Want to do
> something simple to make sure they have entered a valid
> username/password for the database.
> So, the idea is something like:
> $rc = exec("mysql -u $user -p{$pass}", $output);
> The problem is one error, the stderr does not go to the output array,
> but rather to the screen.
>
> Previously I would redirect the stderr to a file, and then evaluate the
> contents of the file, but is there an easier way to get this into the
> PHP variable with no risk of having the output make it through to the
> screen?
>
> Thanks
> -Brad

I'd take a look at shell_exec.  There'sa comment about capturing stderr.  I'm 
not sure if shell_exec captures stderr, but it should at least point you in 
the right direction.  Just do a search for stderr and you should find some 
good info.

-- 
Ray Hauge
Programmer/Systems Administrator
American Student Loan Services
www.americanstudentloan.com
1.800.575.1099

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



Re: [PHP] Capturing System output

2006-08-15 Thread Ray Hauge
On Tuesday 15 August 2006 09:38, Brad Bonkoski wrote:
> Stut wrote:
> > Brad Bonkoski wrote:
> >> Had this problem in the past, and always programmed around it, but
> >> wondering if there is an easier way.
> >>
> >> Good Example:
> >> Creating a setup for connecting to a mysql database.  Want to do
> >> something simple to make sure they have entered a valid
> >> username/password for the database.
> >> So, the idea is something like:
> >> $rc = exec("mysql -u $user -p{$pass}", $output);
> >> The problem is one error, the stderr does not go to the output array,
> >> but rather to the screen.
> >>
> >> Previously I would redirect the stderr to a file, and then evaluate
> >> the contents of the file, but is there an easier way to get this into
> >> the PHP variable with no risk of having the output make it through to
> >> the screen?
> >
> > I may be missing something, but why in the name of all that is holy
> > would you want to shell out to try connecting to mysql? Why not use
> > mysql_connect and avoid the potentially massive security hole you're
> > building?
> >
> > -Stut
>
> Perhaps poor illustration of the question...the question being how to
> issue system like commands in PHP which would allow you to trap not only
> stdout, but also stderr.
> -Brad

Best example I found was:

$shell_return = shell_exec($shell_command." 2>&1");

that should redirect stderr to stdout and thus you'd get both.

-- 
Ray Hauge
Programmer/Systems Administrator
American Student Loan Services
www.americanstudentloan.com
1.800.575.1099

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



Re: [PHP] Creating User Friendly URLS

2006-08-17 Thread Ray Hauge
On Thursday 17 August 2006 09:43, Dave M G wrote:
> PHP List,
>
> My goal is to create user and search engine friendly URLs like:
> mysite.com/my_web_page_title
>
> Instead of:
> mysite.com/index.php?pageID=1
>
> I asked about this before:
> http://marc.theaimsgroup.com/?l=php-general&m=113597988027012&w=2
>
> And there is this helpful tutorial:
> http://agachi.name/weblog/archives/2005/01/30/rewriting-dynamic-urls-into-f
>riendly-urls.htm
>
>
> Both of which refer to a variable called $_SERVER['PATH_INFO'].
>
> But, in the php.net manual, in the predefined variables page,
> 'PATH_INFO' is only obliquely referenced in the $_SERVER variable
> description, under the 'PATH_TRANSLATED' element.
>
> When I've tried echoing out the contents of $_SERVER['PATH_INFO'], I get
> nothing.
>
> I'm trying to set it so that pages are named according to their title in
> my MySQL database. So my script will pull "my_web_page_title" out of the
> URL, match that against the database, and then display the appropriate
> contents.
>
> I thought I could do this by simply making my link into:
> My Web Page Title
>
> And then stripping out the "index.php", and using the remainder  for
> both the URL and the database lookup.
>
> But, while I'm sure there are more steps than that, I'm halted initially
> because I'm not sure where in the $_SERVER array my URL is being stored.
>
> Any advice on how to proceed here would be greatly appreciated. Thank you.
>
> --
> Dave M G

Richard has a good article related to this.  Mostly it's about how to force a 
download with a correct filename, but the last part of the article should get 
you pointed in the right direction if you don't want to use mod_rewrite with 
apache.

http://richardlynch.blogspot.com/

-- 
Ray Hauge
Programmer/Systems Administrator
American Student Loan Services
www.americanstudentloan.com
1.800.575.1099

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



Re: [PHP] active directory and PHP

2006-08-17 Thread Ray Hauge
On Thursday 17 August 2006 11:35, Michael B Allen wrote:
> Hi Alain,
>
> PlexSSO is by far the best and easiest solution available for PHP SSO
> with Active Directory. We provide:
>
>   o Windows Integerated Authentication (WIA)
>   o Script level access to user info like username, home drive, etc.
>   o Script level access control using windows group names
>
> Someone else mentioned LDAP but I don't know why because it doesn't
> provide authentication [1]. For authorization LDAP doesn't automatically
> perform proper group expansion and is redundant to start with since the
> Kerberos ticket has the fully expanded groups in it already.
>
> Our authorization code very easy to use. An access check looks like:
>
>  if (plexsso_is_memberof("FOONET\\Managers")) {
>   echo "You're a manager.";
>   }
>   ?>
>
> None of the mod_authz_* Apache modules can do this. These checks are
> also very fast. Once the SIDs for the groups used in your scripts are
> cached they're instantaneous.
>
> Check us out. It's very affordable (free for 25 users and 25 groups),
> we're adding major features in our next release, and we bring serious
> SSO experience to the table.
>
>http://www.ioplex.com/
>
> Mike
>
> [1] You could proxy the user's username and password to ldap_sasl_bind but
> aside from being a hack it's not SSO and doesn't scale because it requires
> communication with the DC whereas Kerberos does not. And it's insecure
> because you have to cache the users "credentials" in the user's session.
>
> --
> Michael B Allen
> PHP Active Directory SSO
> http://www.ioplex.com/
>
> On Thu, 17 Aug 2006 12:14:18 +0200
>
> "Alain Roger" <[EMAIL PROTECTED]> wrote:
> > Hi,
> >
> > I'm new to PHP, so sorry if my question looks like stupid.
> >
> > I have a web application which use authorization and authentication
> > process to log-in.
> > I would like to know if it exists a way to synchronize the authentication
> > with our Active Directory domain ?
> > Something like a single side-on.
> >
> > In fact, i want from my web application users to make them remember only
> > their login/pwd from Active directory to use my application.

LDAP can authenticate with Active Directory just fine:

http://www.google.com/search?hl=en&q=php+exchange+ldap+authentication&btnG=Google+Search

or

http://www.google.com/search?hl=en&lr=&q=php+active+directory+ldap+authentication&btnG=Search

The question is how secure is it.  You can set up LDAP to use SSL, so that 
would make it more secure.  Kerberos is more secure than LDAP, and you 
_could_ set it up so that the browser forwards the ticket on to mod_kerb for 
authentication, thus not needing a sign-on other than to the domain.  From my 
experiences that isn't exactly easy to set up though.

-- 
Ray Hauge
Programmer/Systems Administrator
American Student Loan Services
www.americanstudentloan.com
1.800.575.1099

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



Re: [PHP] Dhtml/javasript layer tips or software (0.T)

2006-08-18 Thread Ray Hauge
On Friday 18 August 2006 10:30, Ryan A wrote:
> Hello,
> I am working on a php project that needs a little
> extra JS/DHTML solution. I am sure some of you might
> have come to use something like this before, please
> recommend a solution (commerial solutions are fine /
> willing to pay)
>
> Basically, I will have a page with around 10 questions
> for students and then two buttons for [HINT] and
> [SOLUTION]
>
> When either of these buttons/text is clicked the
> resulting text should be displayed in the side/bottom
> cell, the user should also be able to 'close' this
> resulting explanation.
>
> Note, on each page there will be around 10 questions,
> so each of these questions will have a hint & solution
> button/text.
>
> Thanks in advance,
> Ryan
>
> --
> - The faulty interface lies between the chair and the keyboard.
> - Creativity is great, but plagiarism is faster!
> - Smile, everyone loves a moron. :-)
>
> __
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com

I find that the Yahoo User Interface Library is pretty nice.

http://developer.yahoo.com/yui/index.html

I'm not sure that you really need a library to do what you want though.  It 
could be as simple as using a div, and then the buttons change text with 
innerHTML (as long as you're not expecting to use that text after the 
submit).

-- 
Ray Hauge
Programmer/Systems Administrator
American Student Loan Services
www.americanstudentloan.com
1.800.575.1099

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



Re: [PHP] switch()

2006-08-29 Thread Ray Hauge
On Tuesday 29 August 2006 13:31, [EMAIL PROTECTED] wrote:
> I have something like this:
>
>  $query = mysql_query("
>   SELECT col_1, col_2
>   FROM table
>   ");
> $result = mysql_fetch_array($query);
> if ($result['col_1'] == 'value_1')
> {
>   // do something
> }
>
> if ($result['col_2'] == 'value_2')
> {
>   // do something
> }
> ?>
>
> when I tried to use swiitch()
>  switch (true)
> {
>   case ($result['col_1'] == 'value_1'):
>   // do something
>   break;
>
>   case ($result['col_2'] == 'value_2'):
>   // do something
>   break;
> }
> ?>
>
> it will give me only the first true case. if $result['col_1'] == 'value_1'
> is true 2nd case will never be executed?
> Does it mean I CANNOT use switch() in this case?
>
> -afan

Using a switch like this is more equivalent of 

if(something){
// true
} else {
// false
}

You're doing :

if(something1){
// true 1
}

if(something2){
// true2
}

hope that helps.

-- 
Ray Hauge
Programmer/Systems Administrator
American Student Loan Services
www.americanstudentloan.com
1.800.575.1099

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



Re: [PHP] switch()

2006-08-29 Thread Ray Hauge
On Tuesday 29 August 2006 13:44, Ray Hauge wrote:
> Using a switch like this is more equivalent of
>
> if(something){
> // true
> } else {
> // false
> }

Actually, it's more like an if/elseif/else (if you use default:) or if/elseif 
(without default:)

-- 
Ray Hauge
Programmer/Systems Administrator
American Student Loan Services
www.americanstudentloan.com
1.800.575.1099

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



Re: [PHP] switch()

2006-08-29 Thread Ray Hauge
On Tuesday 29 August 2006 14:12, [EMAIL PROTECTED] wrote:
> No. They are two if statements because they are indepedent.
>
> > On Tuesday 29 August 2006 13:44, Ray Hauge wrote:
> >> Using a switch like this is more equivalent of
> >>
> >> if(something){
> >> // true
> >> } else {
> >> // false
> >> }
> >
> > Actually, it's more like an if/elseif/else (if you use default:) or
> > if/elseif
> > (without default:)
> >
> > --
> > Ray Hauge
> > Programmer/Systems Administrator
> > American Student Loan Services
> > www.americanstudentloan.com
> > 1.800.575.1099
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php

I was unclear.  Using a switch to replace an if statement would be replacing 
the if/elseif/else with the switch.  You are right though.

-- 
Ray Hauge
Programmer/Systems Administrator
American Student Loan Services
www.americanstudentloan.com
1.800.575.1099

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



Re: [PHP] Re: Format of Encrypted Password

2006-09-06 Thread Ray Hauge
On Wednesday 06 September 2006 04:02, Mourad Boulahboub wrote:
> Hi Kevin,
>
> Kevin Murphy schrieb am 06.09.2006 00:27:
> > $_SERVER['PHP_AUTH_PW']
>
> this is needed if you run HTTP-Authentication for e.g. .htaccess/.htpasswd
>
> i think you will find a string like
>
> Header("WWW-Authenticate: Basic
>
> in your scripts also.
> I think the passwords are stored in MD5

It is possible that it's MD5, but the field in MySQL is only a varchar(16).  
I've seen things like that before...  I've also been in a place where they 
offloaded creating passwords to htpasswd.

I would suggest looking at the code where new accounts are created (if there 
is code to do that).  That should tell you what's going on.

-- 
Ray Hauge
Programmer/Systems Administrator
American Student Loan Services
www.americanstudentloan.com
1.800.575.1099

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



Re: [PHP] Newbie question about

2006-09-09 Thread Ray Hauge
On Saturday 09 September 2006 08:19, Mike Borrelli wrote:
> Good day,
>
> While I've been using php for more than a little while now, I've never
> understood why the use of the "" short tag is noted "to be
> avoided".
>
> Or rather, I understand that there's an option to disable it, and that's
> why it's noted in this way, but I don't understand why it's disabled?
> What's gained by writing  over  some_function(); ?>
>
> Thanks in advance.
>
> Cheers,
> Mike

As was said before, the major reasons for not using short tags are:

1) Not everyone has access to the ini file, and might not be able to use short 
tags.  If you're releasing your code to the public, you want to work in as 
many places as possible, so then you should use 

-- 
Ray Hauge
Programmer/Systems Administrator
American Student Loan Services
www.americanstudentloan.com
1.800.575.1099

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



Re: [PHP] Open file on a Mounted Share on Mac OS X

2006-09-12 Thread Ray Hauge
On Tuesday 12 September 2006 16:27, Rahul S. Johari wrote:
> Ave,
>
> I¹m getting really frustrated with this. How do I get PHP to open/read a
> file which is on a Share, mounted on Mac OS X.
>
> My Mac OS X is connected to a Windows 2003 Server... A Shared Folder
> remains mounted on my Mac OS X and I need PHP to read a file off that
> share. But it won¹t! I just can¹t get the path to work!!
>
> I¹ve tried ³/Volumes/Server/file.dbf² . I¹ve tried to create Aliases
> (shortcuts)... But nothing seems to work! What¹s the trick? How can I get
> this to work? Any suggestions?
>
> Rahul S. Johari
> Supervisor, Internet & Administration
> Informed Marketing Services Inc.
> 500 Federal Street, Suite 201
> Troy NY 12180
>
> Tel: (518) 687-6700 x154
> Fax: (518) 687-6799
> Email: [EMAIL PROTECTED]
> http://www.informed-sources.com

First I would check to make sure that permissions are set correctly.  PHP 
doesn't (necessarily) run under your user account.  Other than that I have no 
idea.

HTH

-- 
Ray Hauge
Programmer/Systems Administrator
American Student Loan Services
www.americanstudentloan.com
1.800.575.1099

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



Re: [PHP] Open file on a Mounted Share on Mac OS X

2006-09-12 Thread Ray Hauge
On Tuesday 12 September 2006 16:33, Rahul S. Johari wrote:
> In my Windows 2003 Server I've given the Mac OS X user all the permissions
> possible for that Share.
>
> Is there something I have to do in php as far as permissions are concerned?
>
> On 9/12/06 5:31 PM, "John Nichel" <[EMAIL PROTECTED]> wrote:
> > Rahul S. Johari wrote:
> >> Ave,
> >>
> >> I¹m getting really frustrated with this. How do I get PHP to open/read a
> >> file which is on a Share, mounted on Mac OS X.
> >>
> >> My Mac OS X is connected to a Windows 2003 Server... A Shared Folder
> >> remains mounted on my Mac OS X and I need PHP to read a file off that
> >> share. But it won¹t! I just can¹t get the path to work!!
> >>
> >> I¹ve tried ³/Volumes/Server/file.dbf² . I¹ve tried to create Aliases
> >> (shortcuts)... But nothing seems to work! What¹s the trick? How can I
> >> get this to work? Any suggestions?
> >
> > Permissions?
>
> Rahul S. Johari
> Supervisor, Internet & Administration
> Informed Marketing Services Inc.
> 500 Federal Street, Suite 201
> Troy NY 12180
>
> Tel: (518) 687-6700 x154
> Fax: (518) 687-6799
> Email: [EMAIL PROTECTED]
> http://www.informed-sources.com

This may be due to my huge lack of experience with Mac OSX, but I would think 
it has its own permissions for files.  I'm not sure if they stuck with the 
BSD type file permissions or implemented their own.  I'd check that first.

If that doesn't work, what is the error that you get?  "Access Denied"?
-- 
Ray Hauge
Programmer/Systems Administrator
American Student Loan Services
www.americanstudentloan.com
1.800.575.1099

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



Re: [PHP] Open file on a Mounted Share on Mac OS X

2006-09-12 Thread Ray Hauge
On Tuesday 12 September 2006 16:45, Rahul S. Johari wrote:
> If I hit 'Get Info' on the share folder, a file within that folder, or even
> the DBF I'm trying to open... Mac OS X tells me that I have 'Read & Write'
> access to it. Basically All permissions have been provided to the Mac OS X
> user for that share.
>
> This is the error I get:
> Warning: dbase_open() [function.dbase-open]: unable to open database
> /Volumes/foresight/2qc0831.dbf in
> /Library/WebServer/Documents/site.com/folder/file.php on line 29
>
> On 9/12/06 5:46 PM, "Ray Hauge" <[EMAIL PROTECTED]> wrote:
> > On Tuesday 12 September 2006 16:33, Rahul S. Johari wrote:
> >> In my Windows 2003 Server I've given the Mac OS X user all the
> >> permissions possible for that Share.
> >>
> >> Is there something I have to do in php as far as permissions are
> >> concerned?
> >>
> >> On 9/12/06 5:31 PM, "John Nichel" <[EMAIL PROTECTED]> wrote:
> >>> Rahul S. Johari wrote:
> >>>> Ave,
> >>>>
> >>>> I¹m getting really frustrated with this. How do I get PHP to open/read
> >>>> a file which is on a Share, mounted on Mac OS X.
> >>>>
> >>>>
> >>>> My Mac OS X is connected to a Windows 2003 Server... A Shared Folder
> >>>> remains mounted on my Mac OS X and I need PHP to read a file off that
> >>>> share. But it won¹t! I just can¹t get the path to work!!
> >>>>
> >>>> I¹ve tried ³/Volumes/Server/file.dbf² . I¹ve tried to create
> >>>> Aliases (shortcuts)... But nothing seems to work! What¹s the trick?
> >>>> How can I get this to work? Any suggestions?
> >>>
> >>> Permissions?
> >>
> >> Rahul S. Johari
> >> Supervisor, Internet & Administration
> >> Informed Marketing Services Inc.
> >> 500 Federal Street, Suite 201
> >> Troy NY 12180
> >>
> >> Tel: (518) 687-6700 x154
> >> Fax: (518) 687-6799
> >> Email: [EMAIL PROTECTED]
> >> http://www.informed-sources.com
> >
> > This may be due to my huge lack of experience with Mac OSX, but I would
> > think it has its own permissions for files.  I'm not sure if they stuck
> > with the BSD type file permissions or implemented their own.  I'd check
> > that first.
> >
> > If that doesn't work, what is the error that you get?  "Access Denied"?
>
> Rahul S. Johari
> Supervisor, Internet & Administration
> Informed Marketing Services Inc.
> 500 Federal Street, Suite 201
> Troy NY 12180
>
> Tel: (518) 687-6700 x154
> Fax: (518) 687-6799
> Email: [EMAIL PROTECTED]
> http://www.informed-sources.com

Out of curiosity, can you do an fopen() on it?  Maybe something happened to 
the structure of the file...

-- 
Ray Hauge
Programmer/Systems Administrator
American Student Loan Services
www.americanstudentloan.com
1.800.575.1099

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



Re: [PHP] Open file on a Mounted Share on Mac OS X

2006-09-12 Thread Ray Hauge
Hmmm... That's odd.

I would use your terminal program, then change directory to the location of 
the file, and do "pwd".  That should give you your working directory.  If you 
can get to it on OSX, and PHP is on OSX, then PHP  should be able to see the 
file in the same path.

-- 
Ray Hauge
Programmer/Systems Administrator
American Student Loan Services
www.americanstudentloan.com
1.800.575.1099

On Tuesday 12 September 2006 16:51, Rahul S. Johari wrote:
> As a matter of fact... I'm trying to do file_exists...and it says the file
> does not exist in the given location... And that's because my path isn't
> correct. I just don't know what path I need to specify for a shared server
> folder on a mac os x.

>
> On 9/12/06 5:53 PM, "Ray Hauge" <[EMAIL PROTECTED]> wrote:
> > On Tuesday 12 September 2006 16:45, Rahul S. Johari wrote:
> >> If I hit 'Get Info' on the share folder, a file within that folder, or
> >> even the DBF I'm trying to open... Mac OS X tells me that I have 'Read &
> >> Write' access to it. Basically All permissions have been provided to the
> >> Mac OS X user for that share.
> >>
> >> This is the error I get:
> >> Warning: dbase_open() [function.dbase-open]: unable to open database
> >> /Volumes/foresight/2qc0831.dbf in
> >> /Library/WebServer/Documents/site.com/folder/file.php on line 29
> >>
> >> On 9/12/06 5:46 PM, "Ray Hauge" <[EMAIL PROTECTED]> 
wrote:
> >>> On Tuesday 12 September 2006 16:33, Rahul S. Johari wrote:
> >>>> In my Windows 2003 Server I've given the Mac OS X user all the
> >>>> permissions possible for that Share.
> >>>>
> >>>> Is there something I have to do in php as far as permissions are
> >>>> concerned?
> >>>>
> >>>> On 9/12/06 5:31 PM, "John Nichel" <[EMAIL PROTECTED]> wrote:
> >>>>> Rahul S. Johari wrote:
> >>>>>> Ave,
> >>>>>>
> >>>>>> I¹m getting really frustrated with this. How do I get PHP to
> >>>>>> open/read a file which is on a Share, mounted on Mac OS X.
> >>>>>>
> >>>>>>
> >>>>>> My Mac OS X is connected to a Windows 2003 Server... A Shared Folder
> >>>>>> remains mounted on my Mac OS X and I need PHP to read a file off
> >>>>>> that share. But it won¹t! I just can¹t get the path to work!!
> >>>>>>
> >>>>>> I¹ve tried ³/Volumes/Server/file.dbf² . I¹ve tried to create
> >>>>>> Aliases (shortcuts)... But nothing seems to work! What¹s the trick?
> >>>>>> How can I get this to work? Any suggestions?
> >>>>>
> >>>>> Permissions?
> >>>>
> >>>> Rahul S. Johari
> >>>> Supervisor, Internet & Administration
> >>>> Informed Marketing Services Inc.
> >>>> 500 Federal Street, Suite 201
> >>>> Troy NY 12180
> >>>>
> >>>> Tel: (518) 687-6700 x154
> >>>> Fax: (518) 687-6799
> >>>> Email: [EMAIL PROTECTED]
> >>>> http://www.informed-sources.com
> >>>
> >>> This may be due to my huge lack of experience with Mac OSX, but I would
> >>> think it has its own permissions for files.  I'm not sure if they stuck
> >>> with the BSD type file permissions or implemented their own.  I'd check
> >>> that first.
> >>>
> >>> If that doesn't work, what is the error that you get?  "Access Denied"?
> >>
> >> Rahul S. Johari
> >> Supervisor, Internet & Administration
> >> Informed Marketing Services Inc.
> >> 500 Federal Street, Suite 201
> >> Troy NY 12180
> >>
> >> Tel: (518) 687-6700 x154
> >> Fax: (518) 687-6799
> >> Email: [EMAIL PROTECTED]
> >> http://www.informed-sources.com
> >
> > Out of curiosity, can you do an fopen() on it?  Maybe something happened
> > to the structure of the file...
>
> Rahul S. Johari
> Supervisor, Internet & Administration
> Informed Marketing Services Inc.
> 500 Federal Street, Suite 201
> Troy NY 12180
>
> Tel: (518) 687-6700 x154
> Fax: (518) 687-6799
> Email: [EMAIL PROTECTED]
> http://www.informed-sources.com

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



Re: [PHP] Open file on a Mounted Share on Mac OS X

2006-09-12 Thread Ray Hauge
You could try getting a directory listing with PHP to see if you can see what 
files are in there, or if you can access that directory through PHP.

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

-- 
Ray Hauge
Programmer/Systems Administrator
American Student Loan Services
www.americanstudentloan.com
1.800.575.1099


On Tuesday 12 September 2006 17:08, Rahul S. Johari wrote:
> I did exactly that... Used Terminal to find the correct path. Did "pwd" in
> terminal window where my file is located. And this is what I got:
> /Volumes/foresight
>
> Which is what I have used in php to specify the path. But it still says
> file doesn't exist.
>
> On 9/12/06 6:05 PM, "Ray Hauge" <[EMAIL PROTECTED]> wrote:
> > Hmmm... That's odd.
> >
> > I would use your terminal program, then change directory to the location
> > of the file, and do "pwd".  That should give you your working directory. 
> > If you can get to it on OSX, and PHP is on OSX, then PHP  should be able
> > to see the file in the same path.
>
> Rahul S. Johari
> Supervisor, Internet & Administration
> Informed Marketing Services Inc.
> 500 Federal Street, Suite 201
> Troy NY 12180
>
> Tel: (518) 687-6700 x154
> Fax: (518) 687-6799
> Email: [EMAIL PROTECTED]
> http://www.informed-sources.com

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



Re: [PHP] Open file on a Mounted Share on Mac OS X

2006-09-13 Thread Ray Hauge
On Wednesday 13 September 2006 10:30, John Nichel wrote:
> Rahul S. Johari wrote:
> > Nope.
> > It looks like this...
> >
> >
> > drwxr-xr-x  3 root root 4096 Sep 13 10:44 .
> > drwxr-xr-x  3 root root 4096 Sep 13 10:46 ..
> > drwx--  1 rjohari  admin  16384 13 Sep 10:38 foresight
> >
> > Foresight being the mounted share.
>
> Does your webserver run as the user 'rjohari'?
>
> *permission light bulb*
>
> --
> John C. Nichel IV
> Programmer/System Admin (ÜberGeek)
> Dot Com Holdings of Buffalo
> 716.856.9675
> [EMAIL PROTECTED]

nice catch.

My suggestion would be to change the group to the group the webserver runs as 
(nobody, www, etc.) and allow read and write access to the group level as 
well.  That should solve your problem.

-- 
Ray Hauge
Programmer/Systems Administrator
American Student Loan Services
www.americanstudentloan.com
1.800.575.1099

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



Re: [PHP] Open file on a Mounted Share on Mac OS X

2006-09-13 Thread Ray Hauge
On Wednesday 13 September 2006 10:58, Rahul S. Johari wrote:
> Been reading and reading... Can't get much out of it.
> Everytime I try the mount command, I get "can't get net id"
>
> On 9/13/06 11:39 AM, "John Nichel" <[EMAIL PROTECTED]> wrote:
> > Rahul S. Johari wrote:
> >> How can I set the "drwxr-xr-x" permissions on my mounted share? I've set
> >> everything I possibly could in the windows 2003 server to give the mac
> >> os x user full control!
> >
> > man mount
>
> Rahul S. Johari
> Supervisor, Internet & Administration
> Informed Marketing Services Inc.
> 500 Federal Street, Suite 201
> Troy NY 12180
>
> Tel: (518) 687-6700 x154
> Fax: (518) 687-6799
> Email: [EMAIL PROTECTED]
> http://www.informed-sources.com

You could just try using chmod to change the permissions of the folder.  It 
might not stick after a reboot, but it'll get you working in the mean time.

-- 
Ray Hauge
Programmer/Systems Administrator
American Student Loan Services
www.americanstudentloan.com
1.800.575.1099

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



  1   2   3   >