[PHP] Re: Sorting an array by value length.

2003-10-22 Thread Justin Patrin
You want to use usort, which lets you specify a comparison function.

function cmpByLength($a, $b) {
  return strlen($a) > strlen($b);
}
usort($arrayToSort, 'cmpByLength');

And change the '>' to '<' if the ordering is wrong.

Rolf Brusletto wrote:
Hey all -

I've been scouring the php.net site for a few hours now trying to find a 
viable way to sort a single dimensional array( array('0'=>'fddfsdsfdds', 
'1'=>','d','2' => 'gofofle'); ). so that the longest lengthed 
item is at the top, and the smallest lengthed item is at the bottom 
is there a function to do this... example:

$arrayToSort = array('0' => 'shorter_length', '1' => 
'longer_than_longer_than_shorter_length', '2' => 
'longer_than_shorter_length');

and I would like to get... whether the keys change or not..

$arrayToSort[0] == 'longer_than_longer_than_shorter_length';
$arrayToSort[1] == 'longer_than_shorter_length';
$arrayToSort[2] == 'shorter_length';
any ideas?

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


[PHP] Re: Check mysq_field_type, display appropriate FORM element

2003-10-22 Thread Justin Patrin
I'm working on a general purpose database data editor in PHP which can 
allow users to edit what you want and also knows about linked record 
with no extra coding. I was planning on putting this kind of field 
typing and type checking in my code, but haven't gotten around to it 
yet. If you're interested, check out:

http://rdbedit.sourceforge.net

If you're interested in developing on it, contact me.

René fournier wrote:

Hello everyone,

I'm upgrading my simple CMS app, and would like to add a [simple] 
function to it—which I'm finding is no so simple (at least for me). To 
illustrate:

The user clicks "Edit" on a particular table row. The CMS then fetches 
that row from the table and begins displaying the value of each field in 
a form (which the user can then edit and at then click "Update") . So 
far, so good.

What I want to add is a function that will, depending on the field type 
(text, set, enum), display the field value as either a  or 
. For example, for a field called "status", which is of 
type ENUM, and can contain the values "Online" or "Offline", I want this 
CMS function to return something like "..." along with 
the allowed values, with the active one selected.

Beyond this, I'd like to extend this check_field_type function to handle 
fields that contain links to images, etc. But this is where I need to 
start.

Thanks.

...Rene

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


[PHP] Re: get user attributes php/ldap/win2k active directory

2003-10-23 Thread Justin Patrin
I've been getting entries from an Active Directory server through LDAP 
for a while now. Here's some example code:

//connect and bind
//$ds should be the handle returned from ldap_connect
//Search LDAP for all users
// note, your OU entries may differ
$sr = ldap_search($ds,
'OU=Employees,OU=Active Accounts,DC=whatever,DC=com', 'CN=*');
// Put the returned data into an array
$info = ldap_get_entries($ds, $sr);
//loop through all the users and display their name
for($i = 0; $i < $info['count']; $i++) {
  echo $info[$i]['cn'][0]."\n";
}
If you need an LDAP Browser, I suggest Softerra LDAP Browser. It's very 
nice for finding OU's and such.

Justin Patrin

Redmond Militante wrote:
hi all

my first email to the list re: php/ldap/win2k AD garnered no responses.  i've got most of the problem solved, however i can't get attributes from the ldap server.

i have a login script that authenticates against our win2k active directory domain controller.  i'm able to open a connection/bind/verify a password/and close the connection.  i'm really having trouble returning a user's attributes (i'm mainly concerned with firstname and last name - cn and givenname).

i've been trying for several days to return attributes.  has anyone accomplished this with php?  i can't find much relevant info for this particular problem on the internet.  if you have any pointers, i'd appreciate hearing them.

i'd post relevant code, but nothing i've tried works, and i'm not sure if the code i've tried is even valid...

thanks

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


Re: [PHP] usort

2003-10-27 Thread Justin Patrin
No need to write your own function, it's already in PHP. :-)

What you're looking for it natsort(). It uses natural order string 
comparison (which takes into account numbers instead of just using 
characters like a regular search does).

There are also lots of other 'nat' functions, such as strnatcmp().

David Otton wrote:
On Sat, 25 Oct 2003 04:03:12 +0300, you wrote:



I don't know what the names are. I just know that there might be numbers. :)

It still doesn't work. It gives very odd results with the $x_out variables.



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


[PHP] Re: Post variables and mysql queries

2003-10-27 Thread Justin Patrin
$query='Select * from users where userid="'.$_POST['userid'].'"';

I tend to use single quotes whenever I can and to use concatenation 
instead of using in-string variables. I do this for three reasons. The 
first is efficiency. Strings surrounded by single chars are not parsed 
for any values, such as variables and backslashed characters (except for 
'). This saves in execution time every time the script is executed. It 
also helps with readability of the code as some syntax highlighting 
doesn't catch variables in strings. The last reason is that I know 
exactly what the code is going to do. I never really know what will be 
used as the variable when I do it in a string. Will it follow a ->? What 
about two? I don't always know and it's easier to debug without all of 
the extra hassle.

Pete M wrote:
$query="Select * from users where userid='".$_POST['userid']."'";

;-)
pete
Luis Lebron wrote:

This may be a dumb question but here goes. I have been trying to use 
$_POST
globals in sql queries.
If I use the following query string it does not work
$query="Select * from users where userid='$_POST['userid']'";

However, this works
$userid=$_POST["userid"]
$query="Select * from users where userid='$userid'";
Is there a mistake in my syntax?

thanks,

Luis R. Lebron
Sigmatech, Inc
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: eregi function?

2003-11-25 Thread Justin Patrin
Jas wrote:

Not sure how to do this but I have a call to a database which pulls the 
contents of a table into an array and I need a eregi string which will 
sift through the contents and put a line break (i.e. \n or ) after 
each ";", "}" or "{".  here is what I have so far...

while($b = mysql_fetch_array($sql)) {

list($id,$date,$user,$level,$global,$vlan01,$hosts01,$vlan02,$hosts02,$vlan03,$hosts03,$vlan04,$hosts04,$vlan05,$hosts05,$vlan06,$hosts06,$vlan07,$hosts07,$vlan08,$hosts08,$vlan09,$hosts09,$vlan10,$hosts10) 
= $b; }
if(!eregi("^[{]+[}]+[;]$", 
$id,$date,$user,$level,$global,$vlan01,$hosts01,$vlan02,$hosts02,$vlan03,$hosts03,$vlan04,$hosts04,$vlan05,$hosts05,$vlan06,$hosts06,$vlan07,$hosts07,$vlan08,$hosts08,$vlan09,$hosts09,$vlan10,$hosts10)) 

// insert line break here
}
Any help with this would be appreciated
Jas
You could always do:

$string = str_replace(array(';', '{', '}'), array(";\n", "{\n", "}\n"), 
$string);

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


Re: [PHP] trim...

2003-11-26 Thread Justin Patrin
trim also gets rid of leading spaces...

Mike Ford wrote:
On 26 November 2003 16:59, [EMAIL PROTECTED] contributed these pearls of wisdom:


Why doesn't this work...?

$body = "
blurb blah
happy days
end of text";
$body = trim($body);

$body now should output:
"blurb blah\nhappy days\nend of text" but it
doesn't...? 


No it shouldn't -- it should output exactly what you've put into the string, minus any trailing spaces (of which there aren't any).  trim() has nothing to do with escapifying newline characters.  If you wnat your text output to javascript with \n in them, then that's exactly what you should put in them -- either that, or run a str_replace() to turn the newlines into \n sequences.

So:

   $body = "blurb blah\\nhappy days\\nend of text";
   echo $body
or

   $body = "
   blurb blah
   happy days
   end of text";
   echo str_replace("\n", '\n', $body);
Cheers!

Mike

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


[PHP] Re: PHP Java extension--hopeless?

2003-11-26 Thread Justin Patrin
If you *must* get it to run in Java (starting and using a JVM for every 
page seems very costly to me) then I would suggest writing a simple Java 
app which writes the decoded values to stdout and using system() in PHP 
to run the JVM manually.

Kelly Hallman wrote:

I am trying to find help or information on running the Java extension with
PHP under Apache on Redhat Linux using a Sun JVM.
I am aware that the PHP documentation says that the Java extension is
experimental. I am also aware that people say the ISAPI version does not
work well and that running PHP as a CGI should give better results. We've
tried, and so far it doesn't seem to be more reliable.
Oddly, it does work most of the time. However, maybe 3/10 times or so it
gives an error. When using the Java extension with PHP running as ISAPI,
PHP gives the error "Unable to create Java Virtual Machine" .. when
running as a CGI I get that or one of several different errors--again,
only part of the time. That is, when an error does appear, refreshing the 
page once or twice will usually bring up the correct output.

A bit more background: The company I work for has a single sign-in system
for web access. You check for a cookie and redirect to another site if the
cookie is not set.  That site authenticates the user via a web-based
login, sets the cookie, and redirects back to your site. Your site then
reads the cookie and decrypts it using a Java object.
At first, I was frustrated that the cookie decrypter was only available in
Java.. However, after a while I began to see why they chose to do it this
way: so that you could decrypt the cookie from various languages and
platforms, but they only needed to maintain one code base.
Now, I'm just frustrated that PHP doesn't work very well with Java.  
Myself and several others have looked extensively for the answer to this 
and we've tried all the viable remedies that have been suggested.  Does 
anyone have any suggestions?  Also, can it be confirmed or denied that 
Java support will eventually be dropped from PHP?  Plans to improve it?

Thanks in advance for any help or pointers!!

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


[PHP] Re: talking to a web page

2003-12-03 Thread Justin Patrin
You can use PEAR's HTTP_Client package 
(http://pear.php.net/package/HTTP_Client) to connect to a website, do 
authentication, post forms, handle redirects, etc. It also keeps track 
of cookies.

Here's a sample (note that the URLs in this will probably not work):

require_once('HTTP/Client.php');
$client = &new HTTP_Client(array('user' => 'username', 'password' => 
'password'));
$code = $client->post('http://www.example.com/script.asp',
  array('var1' = 'val1',
'VAR2' => 'val2'));
$code = $client->get('http://www.example.com/loginRequired.php');

David T-G wrote:

Hi, all --

My host has written a control panel to handle all site management needs,
and it's great except that there's no back-end hook that I can use to
create a new site or user once I have collected my input and verified my
payment in my own pages.  I obviously don't want to have to do all of the
site creations by hand; that's why we have computers :-)
At this point I could either figure out all of the steps for creating a
site -- there are, to my knowledge so far, DB tables to update, dirs to
make, other files to update, and apache to restart -- or figure out how
to talk to the control panel from a script.  With nearly fifteen years of
SysAdmin background but only a few years of PHP background, I know which
I think is probably easier or at least quicker :-) but I don't want to
miss any little things that their interface does that will bite me in the
tail later.
The control panel requires authentication and a cookie and then a few
clicks to get to the fill-ins, so I imagine that I could just construct
that form and hand it off -- except for the login authentication part.
Which route would y'all take, and (more importantly) which would you
recommend to someone at my capable-but-not-expert level?  Remember that
I'll come back to the list when I get stumped ;-)
TIA & HAND

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


[PHP] Re: validating email address

2003-12-03 Thread Justin Patrin
Or you could always use the PEAR package:
http://pear.php.net/package/Validate
Manuel Lemos wrote:

Hello,

On 12/03/2003 04:31 PM, Blake Schroeder wrote:

Whats the best way to validate email address (check for white space, 
check for .com, .net.edu etc)


Try this class: http://www.phpclasses.org/emailvalidation

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


[PHP] Re: validating email address

2003-12-03 Thread Justin Patrin
Actually it does do DNS checking. It doens't yet check to make sure that 
the mail will work, but it could easily be added.

Manuel Lemos wrote:

Hello,

On 12/03/2003 07:53 PM, Justin Patrin wrote:

Or you could always use the PEAR package:
http://pear.php.net/package/Validate


That package only does textual validation of the e-mail address. It does 
not check against the DNS nor tries to ask the end SMTP server if it 
would accept e-mail to the specified address, like this does:

http://www.phpclasses.org/emailvalidation

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


Re: [PHP] Re: talking to a web page

2003-12-03 Thread Justin Patrin
One last thing. If all you need to do is go to a page and not navigate 
it, you could just use HTTP_Request, upon which HTTP_Client is built. 
Then again, if you have multiple request to do and have to keep sending 
the auth data, the Client would be best.

David T-G wrote:

Justin, et al --

...and then Justin Patrin said...
% 
% You can use PEAR's HTTP_Client package 
% (http://pear.php.net/package/HTTP_Client) to connect to a website, do 
% authentication, post forms, handle redirects, etc. It also keeps track 
% of cookies.

Oh, goodie; that sounds great.

% 
% Here's a sample (note that the URLs in this will probably not work):
% 
% require_once('HTTP/Client.php');
% $client = &new HTTP_Client(array('user' => 'username', 'password' => 
% 'password'));

That certainly seems easy enough.

% $code = $client->post('http://www.example.com/script.asp',
%   array('var1' = 'val1',
% 'VAR2' => 'val2'));
OK, so I don't actually need to navigate the page but instead just fill
in the fields and then send it.  Very cool.
% $code = $client->get('http://www.example.com/loginRequired.php');

Now to figure out how to try it out :-)

Thanks & HAND

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


Re: [PHP] PHP - Oracle - BLOBs - Display BLOB data in a table

2003-12-03 Thread Justin Patrin
Actually, I would suggest using two scripts. The first takes the id of 
the row as a GET parameter (say $id) and grabs the image data, sends the 
header, and echoes the data. The second script outputs a web page with 
an img tag. As such:

image.php

page.php


Image.jpg



Chris W. Parker wrote:

Ahbaid Gaffoor 
on Wednesday, December 03, 2003 2:46 PM said:

I have written the first half of my application which stores images in
BLOB fields of an oracle database.
This part of my app. works fine.

I am now trying to download the database stored blob and display it in
my web page.


You might have to write that data to a temporary file and then load that
file in your page. Reason being, in the code sample you gave you are
specifying a header which can't be done halfway down the page unless you
want to get an error. And I think especially you can't change the
Content-type of a page halfway through it and then change it back.
Those are just my thoughts on the subject.

HTH,
Chris.
--
Don't like reformatting your Outlook replies? Now there's relief!
http://home.in.tum.de/~jain/software/outlook-quotefix/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: talking to a web page

2003-12-03 Thread Justin Patrin
Well, technically, you should be using the PEAR installer script to 
install PEAR packages. http://pear.php.net/manual/en/installation.php

Barring that, you can make yourself a PEAR directory somewhere and add 
it to your include_path in your php.ini.

Also note that you have to have all of the dependencies for those 
packages. Easiest way to go is to use the PEAR installer if you're just 
getting started.

David T-G wrote:

Justin, et al --

...and then Justin Patrin said...
% 
% One last thing. If all you need to do is go to a page and not navigate 
% it, you could just use HTTP_Request, upon which HTTP_Client is built. 

That sounds even better; I'm only going to be dealing with a couple of
pages.
% Then again, if you have multiple request to do and have to keep sending 
% the auth data, the Client would be best.

I'll try either both.  I'm having some trouble getting started, though...

I surfed over to pear.php.net, found and downloaded both (yikes, Client
is only a 0.2 release :-) and opened them up.  I made
  /usr/local/lib/php/HTTP

and then copied each's contents in there (well, the docs/ over to the lib
docs file), so I now have
  /usrlocal/lib/php/HTTP/Client.php
  /usrlocal/lib/php/HTTP/Client/CookieManager.php
  /usrlocal/lib/php/HTTP/Client/Listener.php
and similar for HTTP_Request but when I run a simple

  echo "" |php -q 

I get back "Failed opening required 'HTTP/Client.php'" :-(

Is there a different install procedure?

TIA & HAND

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


[PHP] Re: Text field comparison

2003-12-03 Thread Justin Patrin
Yes, but the user would have to submit the form and you would have to 
re-fill it out for them and give them a message saying that they must be 
equal. You could use the PEAR HTML_Form and Quickform packages for much 
of this.

Jeff wrote:

I have created a few forms using post. There are certain fields that 
must match (i.e. username/password) before submission. Can this be 
accomplished using PHP? If not, an alternative would be nice. Thanks.

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


Re: [PHP] validating email address

2003-12-03 Thread Justin Patrin
Quick note: The PEAR Validate package does this for you. It also checks 
for an alternate A record.

Terence wrote:

You could use MX records if you wanted to. I found this some time ago...

function checkEmail($Email) {
   //Do the basic Reg Exp Matching for simple validation
   if (eregi("[EMAIL PROTECTED]", $Email)) {
   return FALSE;
   }
   //split the Email Up for Server validation
   list($Username, $Domain) = split("@",$Email);
   //If you get an mx record then this is a valid email domain
   if(getmxrr($Domain, $MXHost)) {
   return TRUE;
   }
   else {
   //else use the domain given to try and connect on port 25
   //if you can connect then it's a valid domain and that's good enough
   if(fsockopen($Domain, 25, $errno, $errstr, 30)) {
   return TRUE;
   }
   else {
   return FALSE;
   }
   }
}
- Original Message - 
From: "Blake Schroeder" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, December 04, 2003 2:31 AM
Subject: [PHP] validating email address

Whats the best way to validate email address (check for white space,
check for .com, .net.edu etc)
-Blake

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


Re: [PHP] CHMOD...

2003-12-04 Thread Justin Patrin
In all fairness, that's not a very good solution. Using system commands 
makes your script not cross platform, meaning it can't work on Windows. 
For a better solution try writing a recursive chmod script that sets the 
permission, the loops through the files and calls itself on them if the 
input is a directory.

Jay Blanchard wrote:
[snip]

exec("chmod 0777 /directory/*");

You still cannot set all sub directory and files within those
permissions. Best to loop through and set each as needed, don't forget
to cahnge them back.


Yes, you can:

exec("chmod -R 0777 /directory/*");
[snip]
*slaps forehead* Duh me! Of course! I so rarely (nearly never) use that
switch that in my haste to fire off an answer I forgot it.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] how to determine if shopping cart has been abandoned?

2003-12-04 Thread Justin Patrin
Of course, this makes problems when you're adding promotional product to 
the cart, which should have a seperate price. Add to this that the 
customer may have special pricing (think Business to Business). So you 
have to have an update mechanism for promotions and the extra price 
lists. Do-able, but it can get hairy.

Robert Cummings wrote:

On Thu, 2003-12-04 at 16:22, Eric Wood wrote:

Chris W. Parker wrote:

Now what do we do? Does the program automatically delete the carts
after a certain (definable) period of time, i.e. 7 days? OR do we
allow the merchant to manually delete the carts at any point they
want? And how do you determine your abandoned cart rate? That is, do
Well, you don't what item to linger too long as prices change.  If a user
add something to their cart and comes back days later, there may be a
different price or the item may have been discontinued, etc..  So you user
may end up getting the wrong price unless you have checkout logic to correct
pricing.
I say, if an incomplete cart hasn't been touched more than 2 hours *and* you
do cleanup processing at 3:00am, then that'll be safe enough, especially if
you have few international orders.
-Eric Wood


Since the shopping cart hasn't been checked out, couldn't the shopping
cart just keep track of inventory IDs and quantity, and finalize price
at checkout time. Thus the prices would be up-to-date even if the user
returned 5 months later. This could also handle products no longer
carried, since hte ID would become invalid and it could automatically be
removed form the shopping cart when the user reconnects. Chances are
after 5 months they don't remember what they ordered anyways.
Cheers,
Rob.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] how to determine if shopping cart has been abandoned?

2003-12-04 Thread Justin Patrin
Of course, now you have to deal with putting inventory back on the shelf 
when the session expiresand you have no way of knowing when that 
would happen unless you're storing *something*.

Chris W. Parker wrote:

Justin French 
on Thursday, December 04, 2003 2:48 PM said:

Rather than storing the shopping cart in a DB, store the cart in the
session.  When the session dies, so does the cart.
When/if they choose to save it, it THEN gets ported into a database.


Aaah...! This makes sense.



Thanks,
Chris.
--
Don't like reformatting your Outlook replies? Now there's relief!
http://home.in.tum.de/~jain/software/outlook-quotefix/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: Handling Database errors in php

2003-12-05 Thread Justin Patrin
If you want to get database errors back in a meaningful format, I'd 
suggest using PEAR::DB or another of the DB abstraction classes. They 
can return an error which you can then check and handle appropriately. 
In addition, it can let you use the same code for multiple database 
types (should you even want to do the same thing on another DB backend).

Manoj Nahar wrote:
Hi guys,

Column of table defined as primary key. there is violation and error 
message from database.

1) First way is to check if the value is already in database and then 
contuninue with insert
   (this invloes an extra select for every insert and leaves defined 
primary key redundant)
   
What is the best approach to be followed for this scenario.?
what if there are several constrains defined on a table?

cheers

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


Re: [PHP] MySQL Dump using PHP

2003-12-06 Thread Justin Patrin
Cesar Aracena wrote:

The thing is that I don't have phisical access to the server and it doesn't
have telnet access either. What I want to achieve is to make a password
protected page inside my site were a button is kept to start a full backup
of my MySQL DB and after clicking on it, be able to select the Internet
Explorer's option to store the file xxx.sql in my HDD. Is this possible?
I use the built'in function of phpbb that does exactly that and it's just
beautifull.
Thanks again,
___
Cesar L. Aracena
Commercial Manager / Developer
ICAAM Web Solutions
2K GROUP
Neuquen, Argentina
Tel: +54.299.4774532
Cel: +54.299.6356688
E-mail: [EMAIL PROTECTED]
"Ajai Khattri" <[EMAIL PROTECTED]> escribió en el mensaje
news:[EMAIL PROTECTED]
On Sat, Dec 06, 2003 at 04:39:22PM -0300, Cesar Aracena wrote:


I am wondering if someone could point me to the right functions to use
to

make a script to dump all the tables in a specific MySQL DB. I need this
to

keep a daily backup from my site as the hackers are screwing up my site
very

often these days.
Much easier to use mysqldump in a shell script to do this.

man mysqldump

--
Aj.
Sys. Admin / Developer
Use mysqldump in a system() call, redirect it to a temp file, then read 
it back and out to the browser.

Or, you could use popen to get the output piped back into php. Make sure 
to check the mysqldump options for things you need (I often use -Q -e 
--add-drop-table).


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


Re: [PHP] PHP & Variables

2003-12-06 Thread Justin Patrin
John W. Holmes wrote:

echo '';

Or even *MORE* correct
echo '';

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


[PHP] Re: getimagesize() & MySQL Image Storage (Running functions on contents of variables)

2003-12-07 Thread Justin Patrin
Galen wrote:

I'm using a MySQL database to store images as BLOBs. I know how to 
handle all the MySQL stuff, it's easy, and really makes keeping track of 
files nice an clean. No permissions, no risk of getting things out of 
sync, finding stuff is as easy as SQL.

My question is about handling stuff once you pull it out of the 
database. When I store images in the database, I currently stash the 
format and the resolution in the database, which works but is a bit 
messy. I can't find any easy way to run getimagesize on the contents of 
a variable, not a file. I could write the image to a file if I needed 
to, but that can be slow and rather inelegant, I'd rather store the 
values in the DB. Any ideas on how I could use getimagesize or similar 
function to determine the format and resolution of the image in a variable?

I have had a similar problem with ftp uploading. There was no way to 
upload the contents of a variable, so I had to write everything to the 
disk, kind of annoying when I have 1,000 files. The script wasn't a very 
heavily used script nor could the public execute it, but it bugged me to 
no end. I think there are some other functions that also only operate on 
files and I've fought with them too.

Is there any kind of generic solution for this? Some kind of wrapper I 
could use to make a variable act like a reference to a file but actually 
be in memory only?

If this seems totally pointless, please tell me. But it seems like there 
should be a way for almost any function that runs off a file to run off 
the contents of a variable, it's just binary data.

Thanks,
Galen
If the programs read from a file descriptor, you could open a pipe, 
write into it on your side, and have the command read from it. But 
that's really messy... and won't work for the image size function.

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


[PHP] Re: preg_match and regular expression

2003-12-08 Thread Justin Patrin
Fred wrote:

Hi

I have problems with a regular expression.

I have a html file like this:


Hello


somthing



And i want to use preg_match to get a list of all the  tags in the
file:
result:
$list[0] = Hello
$list[1] = somthing
I have tryed this:
preg_match('/.*(\.*\<\/div\>).*/', $contents, $list);
Your regex is matching EVERYTHING before and after the div. It's also 
matching the maximum of content between the div tags. Here's a better one:

/(.*?<\/div>/i

1) You don't need to escape the < and >.
2) The ? after .* makes it match a minimum of content between the div tags.
3) the /i matches case insensitive, meaning that DIV will be matched as well
Note that this won't work quite right on nested div tags.

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


[PHP] Re: PHP My SQL vs ASP.NET SQL 2000 Server

2003-12-08 Thread Justin Patrin
Ryotaro Ishikawa Md wrote:

Hi, I am a MD, involved in a very large medical project that requieres a strong database plataform, the project must be .NET , the estimated transactional movement is about 40 on line users accesing a DB with a 200 relational tables. The policy is to program this SW in three layer design, our first oprion is ASP.NET and SQL Server 2000, because is worldwide spread. I had investigated PHP and MySQL, and I wonder if you can give me a imparcial advise if I must continue with ASP.NET or if PHP is a reasonable alternative.

Thanks.



The short answer is yes, PHP is used in many production environments and 
is very stable and featureful. There is a large developer community 
which creates lots of extensions. One of the largest and best written 
sets is PEAR (http://pear.php.net).

As for mysql, it also is used in many production environments. If you 
feel that normal mysql doesn't have enough "enterprise" features, you 
could use the InnoDB table type, which supports foreign keys and such. 
If that still doesn't satisfy you, you can use PostgreSQL, which is 
another open-source database system, but has more "enterprise" like 
features. If even that isn't enough, you can always use Oracle or 
another database system that you have to pay for.

The long answer is: get ready for a holy war.

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


[PHP] Re: Reading email from sendmail

2003-12-08 Thread Justin Patrin
Robin Kopetzky wrote:

Good afternoon, all!!

Is there a function or series of functions in PHP that will allow a PHP
package to read email from a sendmail account, look for a specific
information in the subject line, then be able to resend that email to a
group of users?? I know mail can be used to send email but reading from
sendmail???...
Any information is greatly appreciated and profoundly useful.

Robin 'Sparky' Kopetzky
Black Mesa Computers/Internet Service
Grants, NM 87020
You could use the imap functions to read from an IMAP account quite easily.

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


[PHP] Re: query to display the results without...

2003-12-08 Thread Justin Patrin
Eric Holmstrom wrote:

Hi there

I have a database called "Eric" and table name called "Rocket'.

Table consists of three values.
PARTNO | DESCRIPTION | COMMENT
So far if i want to show copper headgaskets from the 5r field i put this
string into the php script (along with the rest of the html/php code)
$sql = "SELECT * FROM rocket WHERE partno like '5r%' AND description like
'COPPER HEADGASKET%'";
The problem is there is 1000s of different querys i want to run and dont
want to make a page for each query. So what im trying to ask is how do i run
a query to display the results (like http://www.domain.com/query.php?"the
query i want to run" rather then link to a .php/html file with the query
inside of it.)
The short answer is to use a GET variable for this.

http://example.com/script.php?sql=SELECT...

You have to remember to url encode the SQL, though (see urlencode()). 
You can access it like this:

$_GET['sql']

The longer answer is to use a package such as DB_DataObject_FormBuilder 
(http://pear.php.net/package/DB_DataObject_FormBuilder) to generate this 
stuff for you. It will take some setup, but once you're used to it, it 
can make this kind of app happen real quick.

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


[PHP] Re: query to display the results without...

2003-12-08 Thread Justin Patrin
Eric Holmstrom wrote:

Okay i have this so far

---


$result = mysql_query($sql, $conn) or die(mysql_error());
while ($newArray = mysql_fetch_array($result)) {
 $partno = $newArray['PARTNO'];
 $description = $newArray['DESCRIPTION'];
  $comment = $newArray['COMMENT'];
 }
?>
---

How do i make it so if i type
http://localhost/test.php?partno=5r&description=copper
Cheers if you can help out!

"Justin Patrin" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
Eric Holmstrom wrote:


Hi there

I have a database called "Eric" and table name called "Rocket'.

Table consists of three values.
PARTNO | DESCRIPTION | COMMENT
So far if i want to show copper headgaskets from the 5r field i put this
string into the php script (along with the rest of the html/php code)
$sql = "SELECT * FROM rocket WHERE partno like '5r%' AND description
like

'COPPER HEADGASKET%'";

The problem is there is 1000s of different querys i want to run and dont
want to make a page for each query. So what im trying to ask is how do i
run

a query to display the results (like
http://www.domain.com/query.php?"the

query i want to run" rather then link to a .php/html file with the query
inside of it.)
The short answer is to use a GET variable for this.

http://example.com/script.php?sql=SELECT...

You have to remember to url encode the SQL, though (see urlencode()).
You can access it like this:
$_GET['sql']

The longer answer is to use a package such as DB_DataObject_FormBuilder
(http://pear.php.net/package/DB_DataObject_FormBuilder) to generate this
stuff for you. It will take some setup, but once you're used to it, it
can make this kind of app happen real quick.
--
paperCrane 
At this point, I will recommend you to ANY PHP tutorial and the PHP 
manual. The point of these lists is to help after you've tried things, 
not to write your code for you.

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


Re: [PHP] post an array into another site

2003-12-08 Thread Justin Patrin
Chris W. Parker wrote:

fred 
on Monday, December 08, 2003 4:31 AM said:

I have an array in php like this:

$arr[0][0] = "Something";
$arr[0][1] = "Hello";
$arr[0][2] = "Hi";
It is possible to post this array to another site in a form? Or how
can i do this?


Yes. Here is a hint: delimit.



Chris.
--
Don't like reformatting your Outlook replies? Now there's relief!
http://home.in.tum.de/~jain/software/outlook-quotefix/
...that's a strange response. I doubt that's what was asked anyway.

What you want is probably a php function/class that can post form data 
to another script. PEAR's HTTP_Request can do that.

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


[PHP] Re: post an array into another site

2003-12-08 Thread Justin Patrin
Manuel Lemos wrote:
Hello,

On 12/08/2003 10:30 AM, Fred wrote:

I have an array in php like this:

$arr[0][0] = "Something";
$arr[0][1] = "Hello";
$arr[0][2] = "Hi";
It is possible to post this array to another site in a form? Or how 
can i do
this?


You may want to try this class that lets you make HTTP requests like a 
normal browser:

http://www.phpclasses.org/httpclient

Or even better, use PEAR's HTTP_Client. 
http://pear.php.net/package/HTTP_Client

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


[PHP] Re: post an array into another site

2003-12-08 Thread Justin Patrin
Manuel Lemos wrote:

Hello,

On 12/08/2003 10:39 PM, Justin Patrin wrote:

$arr[0][0] = "Something";
$arr[0][1] = "Hello";
$arr[0][2] = "Hi";
It is possible to post this array to another site in a form? Or how 
can i do
this?




You may want to try this class that lets you make HTTP requests like 
a normal browser:

http://www.phpclasses.org/httpclient

Or even better, use PEAR's HTTP_Client. http://pear.php.net/package/
 > HTTP_Client

Why better? Have you tried both packages?



No, however, the httpclient system is a lot of code that is part of one 
class. HTTP_Client is based on lots of sub-systems, each of which can be 
used seperately and for other purposes (and each of which is maintained 
by seperate, multiple people). For instance, there is the Socket API, 
URL parsing, the HTTP Request, etc. All of which HTTP_Client is built 
upon instead of re-inventing.

Also, and just as important, using PEAR packages gives you a centralized 
way of dealing with errors.

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


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

2003-12-08 Thread Justin Patrin
Chris Shiflett wrote:

--- Manuel Lemos <[EMAIL PROTECTED]> wrote:

http://www.phpclasses.org/httpclient
Or even better, use PEAR's HTTP_Client. 
http://pear.php.net/package/HTTP_Client
Why better? Have you tried both packages?


I can make a guess as to why he would say this, aside from the obvious
fact that one is part of the PHP project and one is not.
Visitng http://www.phpclasses.org/httpclient results in several pages of
banner ads that one must navigate before finally being shown:
"You need to be a subscriber and log in to access this file."

Visiting http://pear.php.net/package/HTTP_Client results in a relevant
page of information that contains a link to code,
http://pear.php.net/get/HTTP_Client-0.1.tgz.
Ads or code. Which would you choose?

Chris

=
Chris Shiflett - http://shiflett.org/
PHP Security Handbook
 Coming mid-2004
HTTP Developer's Handbook
 http://httphandbook.org/
This is also a very good point.

Actually PEAR isn't a PHP project per se. It is simply supported by many 
of the PHP developers and by many very talented PHP coders. Another very 
important aspect of PEAR that I didn't mention in my other message is 
that PEAR has standards that must be upheld in all of their packages. 
The packages are also under peer-review; anyone cna download and use 
them and anyone can submit bug reports if they find an error or want a 
new feature. In addition, anyone can add a new package or a feature to 
an existing package (after it has been reveiwed, of course).

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


[PHP] Re: restrict access to multiple pages

2003-12-08 Thread Justin Patrin
Chris W. Parker wrote:

Hey y'all.

Ok so I am working on the admin sectin of the e-commerce app I'm writing
and I'm hoping there's a better way to do what I am currently doing.
In an effort to prevent circumvention of the login page I've placed a
check at the beginning of each page that basically does the following:


if(loggedin())
{
// entire page of code goes here
}
else
{
// redirect back to login page
}
?>

By doing this people will not be able to just enter manually any URL
they want and have the page load.
As far as better ways go I was thinking that maybe I could employ
.htaccess somehow? But then I think that might require having user
accounts registered with the server instead of just using a db and I
don't want to do that.
I was thinking that maybe I could change it to this:



// define function stored in class file
// (basic auth function, not at all what i'm using.
// just an example.)
function IsLoggedIn($input)
{
if(isset($input) && !empty($input))
{
return 1;
}
else
{
// redirect to login page
}
}
IsLoggedIn($input);

// entire page of code goes here

?>

Any want to share their experiences and ideas?

Thanks,
Chris.
--
Don't like reformatting your Outlook replies? Now there's relief!
http://home.in.tum.de/~jain/software/outlook-quotefix/
I tend to include the same file which does this for me at the beginning 
of pages which must have authentication. Using a function as you 
described (with automatic redirection to the login page) is how I would 
do it.

You may also want to look into a the PEAR Auth package. 
http://pear.php.net/package/Auth

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


Re: [PHP] post an array into another site

2003-12-08 Thread Justin Patrin
Chris W. Parker wrote:

Justin Patrin <mailto:[EMAIL PROTECTED]>
on Monday, December 08, 2003 4:39 PM said:

If all you want to do is give an array to another
script, sure you can delimit (although that's much more error prone
than serializing).


Serialize, delimit. It's pretty much the same idea.



Chris.
--
Don't like reformatting your Outlook replies? Now there's relief!
http://home.in.tum.de/~jain/software/outlook-quotefix/
Not really. If you just delimit, you have to worry about escaping that 
value in your string somehow. If your delimiter was ',' say and you had 
one in a field, how would you handle it?

In addition, serializing is part of PHP, so you know that what you put 
in is what you get out. Writing your own simple serialization through 
delimiting is just asking for problems. What if, say, the array has 
textual keys instead of just numbered ones? Or the array has three 
indices? Or one of the values is an object? Using serializa() and 
unserialize() means that you don't EVER have to worry about this (unless 
there are errors in these functions, in which case, you submit a bug 
report and it gets fixed).

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


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

2003-12-08 Thread Justin Patrin
Chris Shiflett wrote:

--- Justin Patrin <[EMAIL PROTECTED]> wrote:

Actually PEAR isn't a PHP project per se.


I disagree.

You have to become a member of the PHP development team, as far as I know,
to participate in PEAR development (CVS account, php.net email address,
etc.). The project is also governed by the PHP Group, and it is hosted on
php.net servers (pear.php.net). Many PHP extensions (PECL) are a part of
it (http://pear.php.net/manual/en/pecl.php) also.
Chris

=
Chris Shiflett - http://shiflett.org/
PHP Security Handbook
 Coming mid-2004
HTTP Developer's Handbook
 http://httphandbook.org/
Ok, I can give you that. But anyone (and I mean anyone) can submit 
patches to the maintainers for inclusion. The standards are also there 
and open. All source code and documentation is easily readable (well, 
not docs for all of the projects, but the code is almost always 
documented well enough). My point here is that a team of people deal 
with all of these packages and their interactions.

And even so, you can get a PEAR account if you need one. If you want to 
help maintain a project or create your own, all you have to do is ask 
(and show that you're serious).

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


[PHP] Re: post an array into another site

2003-12-08 Thread Justin Patrin
Manuel Lemos wrote:

Hello,

On 12/08/2003 11:06 PM, Justin Patrin wrote:

You may want to try this class that lets you make HTTP requests 
like a normal browser:

http://www.phpclasses.org/httpclient

Or even better, use PEAR's HTTP_Client. http://pear.php.net/package/


 > HTTP_Client

Why better? Have you tried both packages?



No, however, the httpclient system is a lot of code that is part of one 


No? If you have not tried it at all WTF are you claiming that something 
else is better? Better than what? Something you have not tried?

Even if I have not used the other thing, I am still very likely to work 
with PEAR packages. Why? Because I know that I can get help with it from 
the PEAR developers and get fixes and updates easily and quickly.


class. HTTP_Client is based on lots of sub-systems, each of which can 
be used seperately and for other purposes (and each of which is 
maintained by seperate, multiple people). For instance, there is the 
Socket API, 


Are you telling me that to make HTTP requests, loading half of dozen 
classes is better than doing it all with just one?

Yes, it is better to have them all in seperate packages for 
maintainability. If you have everything in one place, you're VERY prone 
to errors.

Now, I haven't seen the code for the phpclasses project, so I can't say 
anything about it, but in general having thing seperated is much better 
practice.


URL parsing, the HTTP Request, etc. All of which HTTP_Client is built 
upon instead of re-inventing.


AFAIK, this HTTP client class was released for the first time in 1999. 
The way I see it, if anybody reinvented anything, that must have been 
whoever came after that to do the same.

Ok, valid point.


Also, and just as important, using PEAR packages gives you a 
centralized way of dealing with errors.


You meant that 800 line fat base class that many PEAR classes inherit 
and require in order to run even when developers do not want anything 
from it?

No thanks, I am not interested in bloated software development.


PEAR is used in many production systems and the classes are tuned for 
speed. Or if they aren't you can alter them and send in a patch. PEAR 
promotes standards instead of ad-hoc programming. It's better to write 
your error handling code once instead of re-creating it for every 
package you ever write.

Not all PEAR packages inherit from PEAR. Some just use pieces of it. 
Some don't use it at all. It all depends on what the package needs.

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


[PHP] Re: post an array into another site

2003-12-08 Thread Justin Patrin
Justin Patrin wrote:
Manuel Lemos wrote:

Hello,

On 12/08/2003 10:30 AM, Fred wrote:

I have an array in php like this:

$arr[0][0] = "Something";
$arr[0][1] = "Hello";
$arr[0][2] = "Hi";
It is possible to post this array to another site in a form? Or how 
can i do
this?


You may want to try this class that lets you make HTTP requests like a 
normal browser:

http://www.phpclasses.org/httpclient

Or even better, use PEAR's HTTP_Client. 
http://pear.php.net/package/HTTP_Client

I hereby retract the "Or even better" part of my statement. It was wrong 
since I had not used httpclient. However, I still stand by PEAR and am 
still more likely to use PEAR packages than any other, simply because I 
trust them and I like the way that it works.

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


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

2003-12-08 Thread Justin Patrin
Ralph Guzman wrote:
= THE END =
I apologize, everyone. I should have realized a while ago that this 
would become a holy war.

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


[PHP] Re: goto label

2003-12-08 Thread Justin Patrin
Nitin wrote:

Hi all,

I was wondering, if there's any way to achieve 'goto "label":' using PHP

Thanx for ur time

Nitin
goto is a very old and broken way of coding. If you ever find yourself 
in need of a goto, you should re-evaluate how you're doing things. If 
you're having trouble finding out how to do it better, just ask here. :-)

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


Re: [PHP] Re: goto label

2003-12-08 Thread Justin Patrin
Robert Cummings wrote:

On Tue, 2003-12-09 at 00:32, Justin Patrin wrote:

Nitin wrote:


Hi all,

I was wondering, if there's any way to achieve 'goto "label":' using PHP

Thanx for ur time

Nitin
goto is a very old and broken way of coding. If you ever find yourself 
in need of a goto, you should re-evaluate how you're doing things. If 
you're having trouble finding out how to do it better, just ask here. :-)


Goto  is a very broken way of coding. Goto  is a
very useful and structured way of coding especially when creating fast
FSMs for parsing. I was a little disappointed a few months ago when I
found that PHP didn't support  the goto label syntax since it would have
provided the most elegant solution.
Cheers,
Rob.
goto anywhere is broken. For instance, goto-ing out of loops and 
functions, or into one function from another causes untold grief to the 
language developer and makes it very hard to read the code. Then there's 
using goto into and out of class functions, which is even worse.

In truth, goto has no place in a higher level programming language. 
Anything that can be done with goto can be done without it and (IMHO) 
more elegantly.

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


Re: [PHP] Re: goto label

2003-12-09 Thread Justin Patrin
Robert Cummings wrote:

On Tue, 2003-12-09 at 08:14, Bogdan Stancescu wrote:

Robert, I know your grief, been there, I know how it feels. I started my 
childhood with BASIC, which was /the/ "GOTO" programming language, 
learned Turbo Pascal when I was a teenager, and continued to use GOTO's 
(Pascal discourages but doesn't disallow GOTO's, so I was still able to 
"cheat" when "there was a need for it"). Well, later on when I started 
finding out how major projects are being developed, what structured 
programming really means and so on, I felt the way you feel now: 
cheated. "Why in God's name is GOTO bad? It's SO useful! They're mad!" 
Well, it simply isn't true -- the problem is that you have to change 
your mindset about programming, try to really structure the way you see 
a program, break it into efficient stand-alone functions, group those in 
classes, etc, and you'll see that there *is* no need for GOTO, ever. You 
do need to break out of loops, you do need to "short" a loop when a 
condition is met, you do need to break out of switches, if branches and 
the lot - but those tools you have in PHP. GOTO is not needed and 
harmful. Even simply learning to program without GOTO will coerce you 
into saner code.

Sorry if my message sounded melodramatic or something, I remembered the 
frustration feeling so strongly from your message that I wanted to 
reinforce the other people's messages with a personal "testimonial" if 
you wish.


U, I rarely use the goto statement, and I do not advocate it for
regular everyday coding. I do know the difference between well
structured code and otherwise. What I did say, is that goto  has
it's uses, and sometimes it IS the best solution. Just because someone
tells you something is bad, doesn't mean to say it is always bad. It's
like someone saying salt is bad for you, and so you never take salt
again and die from salt deficiency. People really need to change their
mindset about being sheeple (yes sheep people) and blindly following
preached dogma.
I don't mind your message sounding melodramatic, but it doesn't explain
in any way why goto shouldn't be used. It just asserts that you found
out how major projects are done, which IMHO doesn't lend support to why
one shouldn't use the goto statement. In actual fact it makes me think
you are missing a few points. For instance properly structured
programming is often about the functions, objects, and methods, not
about the code within a function that performs the logic. For this
reason the use of goto statements within a given function that
facilitates faster cleaner code is sometimes the best solution not to
mention its contents can be considered a black box by the user of the
function. Also your response seems to indicate that you think I am a
newbie coder, well that would be a bit of an oversight. I've been coding
for over 10 years (some hobby, some academic, and some professional)
using many different styles (functional, procedural, and OOP) and so I
am plenty aware of design paradigms, re-usability, and clarity. I also
have extensive experience refactoring old spaghetti code.
Cheers,
Rob.
While goto may be useful and even elegant for experienced programmers 
(although I see no reason to use it myself with well structured 
programs...there's always break), its inclusion in a language causes 
some programmers (newbies and those who don't yet understand clarity, 
etc.) to make habits which are harmful. It allows them shortcuts which 
get things done, but often lead to bugs and hard to read code.


Personally, I don't think goto should ever be used. Well structured 
programs can always be written to not need a goto and always just as 
elegantly. It may take restructuring of code, but it can always be done, 
and in the end the result is clearer.

You say that a funciton is a "black box" and while this is true for the 
user of a function, the maintainer of the code still has to deal with 
the contents of the function. If you wrote and understand it, then fine. 
The problem comes when others have to understand your code. Yes, a 
single goto isn't all that bad, especially when it is used right, but is 
it easier to screw up a code with a goto than a more structured 
statement, such as break.


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


[PHP] Re: Display Query Result As Editable Form

2003-12-10 Thread Justin Patrin
[EMAIL PROTECTED] wrote:

Hi all, 

I am creating a user form whereby I will do an "INSERT" , "SELECT" , "UPDATE" 
and of course "DELETE" for the form. Right now I am trying to create a form 
whereby when user choose to update their info, they wil be directed to a form 
where the fields region are EDITABLE , before that, the fields should contain 
their "old" info...so can i know how should i go about creating this 
kinda "Editable" fields using php scripting ???Fields should contain old info 
retrieved from the DB.Anyone have any idea??

Realli need some help here. 
Thanks in advance =)

Irin.
Or instead of doing it yourself, you could use PEAR's 
DB_DataObject_Formbuilder, which will create forms for you from records 
in the database. Or, if that's going to far, you could just use 
DB_DataObject to get/insert/update/delete your data and use 
HTML_QuickForm to create the form yourself.

http://pear.php.net/package/DB_DataObject
http://pear.php.net/package/HTML_QuickForm
http://pear.php.net/package/DB_DataObject_FormBuilder
--
paperCrane 
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: removing ?> tag from include files

2003-12-10 Thread Justin Patrin
Priit Kaasik wrote:

hi,
im interested in specific information about removing php end-tags from
include files (which contain php code). it woun't give any warning or error
but will remove all annoying spaces and line breaks before you send your own
header data... how does include function work in these cases? are there any
'bad effects' involved? or should i use output buffering instead since its a
standard solution?
--
pk
The short answer is that you can just leave them off and nothing bad 
will happen.

The long answer is that you should include it, as it is good coding 
practice, but make sure that there is no extra whitespace after it.

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


Re: [PHP] ARRAY

2003-12-10 Thread Justin Patrin
Richard Davey wrote:

Hi,

Wednesday, December 10, 2003, 6:29:43 PM, you wrote:

RM> Because it's and array!  print and echo take strings, not
RM> arrays, I believe.  Anyway, print_r() or a foreach loop will do it
RM> for you.
Agreed.. print_r() is the best, but if you're outputting all of this
text into the browser (which is quite common) then I strongly suggest
you wrap it with some  tags. You'll understand why when you try
it.
You can always use var_dump, too. Not a pretty as print_r, but it gives 
you more info (mostly for debugging). And don't forget var_export. ;-)

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


Re: [PHP] Images in MySQL vs directory/file?

2003-12-10 Thread Justin Patrin
Galen wrote:

I tend to disagree. Images in the database, providing they actually 
associate with other bits of info, are great. I usually keep images in a 
separate table than the data, but it's really easy to keep track of 
everything. No file permissions, backup is as easy as standard SQL 
backups, etc. I my experience, it's a LOT easier to keep track of stuff 
in the database than the filesystem, especially when it comes to moving 
from box to box. There may also be some security advantages, too, as the 
data is not actually stored in the filesystem and couldn't possibly be 
executed or otherwise accessed by someone without database access 
privileges.

As far as it being slow, well, not terribly as long as your files don't 
balloon too large, especially considering all the stuff you might be 
doing with the disk. If you store images that are played with a lot on 
the disk, it'll likely be slower than MySQL due to MySQL having better 
caching. (I have actually shown this on some of my projects that work 
with a lot of images that are worked with quite a bit).

If your site is going to be high volume traffic, implement some sort of 
caching routine for your images. You'll get the convenience of database 
and the performance boost of caching, and as always, if the cache fails, 
just hit the database for the information.

For your needs, give it a try. I doubt you'll have performance problems, 
and you can always switch back to the filesystem if you do have troubles.

-Galen

If you are going to be passing images

On Dec 10, 2003, at 10:32 AM, Adam i Agnieszka Gasiorowski FNORD wrote:

Derrick Fogle wrote:

I've read that, given the choice, you should never store images in a
database because it makes the database dog slow. But I've got some
parameters and issues that might make a difference:


We (at hyperreal.info) are storing all the
 images attached to articles in the database and
 all the structural images (belonging to design)
 in files on filesystem (in CVS). There are no
 problems and backups are much easier...The server
 runs on LAMP.
--
Seks, seksiÄ, seksolatki... news:pl.soc.seks.moderowana
http://hyperreal.info  { iWanToDie }   WiNoNa)   (
http://szatanowskie-ladacznice.0-700.pl  foReVeR(  *  )
Poznaj jej zwiewne ksztaÅty... http://www.opera.com 007
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



I agree, storing images in the database can be a big help.

For caching, you may want to try PEAR's Cache package.

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


Re: [PHP] Images in MySQL vs directory/file?

2003-12-10 Thread Justin Patrin
Gerard Samuel wrote:

On Wednesday 10 December 2003 02:43 pm, Galen wrote:

If you store images that are played with a lot on
the disk, it'll likely be slower than MySQL due to MySQL having better
caching.


I disagree.
Depending on your setup, when a file based image is downloaded to 
a user's computer, its cached there.
No need to fetch it again, till it expires.
I don't think thats possible via images from a database, but
I may be wrong.  Feel free to correct me...
Images are cached client side just as html pages are. Scripts are no 
exception. A script which outputs an image will have the same URI over 
and over, so it will be cached. If the browser isn't cacheing as you 
want, you can always send a header telling the browser to cache it.

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


[PHP] Re: fopen >> custom 404 issue

2003-12-10 Thread Justin Patrin
Mike D wrote:
I am trying to read in a particular page to a variable. How do you handle if
the page is a 404 and then redirects to a custom error page? Am I supposed
to use fsockopen and read headers or ?? Ideally I need to pull the
end-result page to search for a string in it.
Here's the code

$handle = fopen("http://www.amazon.com/exec/obidos/ISBN=12345678";, "rb");
$contents = "";
do 
{
 $data = fread($handle, 8192);
 if (strlen($data)==0)
 break;
 $contents .= $data;
} while(true);
fclose ($handle);

Thanks guys


Mike Dunlop
AWN, Inc.
// www.awn.com
[ e ] [EMAIL PROTECTED]
[ p ] 323.606.4237
You can use PEAR's HTTP_Request, which will do redirects for you (and 
lots of other stuff ;-).
http://pear.php.net/package/HTTP_Request

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


[PHP] Re: Help with associative array in a PHP class. Not working as I'd expect it to?!

2003-12-10 Thread Justin Patrin
Daevid Vincent wrote:

I'm pulling out my hair on this. I don't think I'm doing anything wrong and
I've tried it with PHP 4.3.4 (cli) (built: Nov  7 2003 03:47:25) AND also
v4.1.2 on Linux.
With the line commented as shown, I get this output:
--
[daevid=pts/4]6:[EMAIL PROTECTED]:{/home/daevid}> ./test.php
packetArray:
Array
(
[a] => foo
[b] => bar
[c] => 1
[d] => 2
[e] => 3
)
myPacket:
--

How come I don't get ANY array under "myPacket:"?

How come I don't get a "[test] => 2345245" under "myPacket:" when I
explicitly set it?
Uncommenting the 'blah' element causes this error:

Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or
`T_VAR' or `'}'' in /home/daevid/test.php on line 16
The 'var' keyword seems to be required, or I get that same error also.

I've tried other combinations and can't figure out what I'm doing wrong?

 snip -
#!/usr/bin/php
'foo', 'b'=>'bar', 'c'=>'1', 'd'=>'2', 'e'=>'3');
$AP = array();
$ap['1'] = new kismetap($PACKET);
$ap['1']->printMyVars();
class kismetap
{
 var $myPacket = array();
//   $myPacket["blah"] = "asdfasdfasdf";

function kismetap( $packetArray )
{
echo "packetArray:\n";
print_r($packetArray);
$this->myPacket = $packetArray;
$this->myPacket["test"] = 2345245;
global $myPacket;
$myPacket = $packetArray;
} //kismetap::constructor
function printMyVars()
{
 echo "myPacket:\n";
 print_r($myPacket);
}
} //kismetap class
?>
You've got a few problems here. That commented line of code is invalid. 
It is a normal assignment statement, but it is in the class, but not in 
a function. If you want to initialize a class variable do it in the var 
statement.

var $myPacket = array('blah' => 'asdfasdfasdf');

Or, you can set it in a function (like the costructor)

class kismetap {
  function kismetap() {
$this->$myPacket = array('blah' => 'asdfasdfasdf');
  }
}
Doing

global $myPacket;

is the equivelent of:

$myPacket =& $GLOBALS['myPacket'];

whicks brings the global variable $myPacket into the local namespace of 
the function. This does NOT export the class variable for global use.

If you want to make the class variable $myPacket the same as the global, 
in your constructor you could do:

$this->myPacket =& $GLOBALS['myPacket'];

But that's really not a good idea. Why not just do

function printMyVars() {
  echo "myPacket:\n";
  print_r($this->myPacket);
}
This will give you your expected output.

Please remember ot use globals sparingly as they make very kludgy code.

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


[PHP] Re: Help with associative array in a PHP class. Not working as I'd

2003-12-10 Thread Justin Patrin
Justin Patrin wrote:

class kismetap {
  function kismetap() {
$this->$myPacket = array('blah' => 'asdfasdfasdf');
  }
}
That should be

$this->myPacket = ...

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


Re: [PHP] Re: Write on image in faint color

2003-12-11 Thread Justin Patrin
Al wrote:

4) I'd love to see a PEAR IM module a la PerlMagick (but I haven't even
looked yet, so please don't flame me for missing something obvious).  One
of these days I'll have The Great Rewrite and that will go in then.  I'd
love to be rid of the system() calls to convert and mogrify.


The closest thing out there at the moment (that I know of) is a PHP
extension available through PECL, the PHP extension library. According to
the docs, it "provides a wrapper to the ImageMagick/GraphicsMagick library."
You can find it and download it at http://pecl.php.net/package/imagick.
Hope that helps.

Al
Or, as was said long ago in this thread, you just use the PHP GD 
extension, read in the image, write a bit of text to it, then write it 
back out. You can write a loop that loops through the file sin the 
directory and does this to all of them.

And because I'm such a nice guy:
#!/usr/bin/php

//remember the trailing slash
$dir = '/path/to/files/';
$text = 'www.example.com';
$fontsize = 2;//1 - 5
$dh = opendir($dir);
while(false !== ($file = readdir($dh))) {
if($file[0] != '.') {
echo 'Adding watermark to '.$dir.$file."\n";
$fileinfo = pathinfo($file);
switch(strtolower($fileinfo['extension'])) {
case 'png':
$ih = imagecreatefrompng($dir.$file);
break;
case 'jpg':
case 'jpeg':
case 'jpe':
$ih = imagecreatefromjpeg($dir.$file);
break;
case 'gif':
$ih = imagecreatefromgif($dir.$file);
break;
default:
echo 'I don\'t know what to do with the extension 
'.$fileinfo['extension']."\n";
break;
}
imagealphablending($ih, true);
$color = imagecolorallocatealpha($ih, 255, 255, 255, 50);
$x = (imagesx($ih) - strlen($text) * imagefontwidth($fontsize)) 
/ 2;
$y = imagesy($ih) - imagefontheight($fontsize) * 1.2;
imagestring($ih, $fontsize, $x, $y, $text, $color);
imagepng($ih, $dir.basename($file, $fileinfo['extension']).'png');
}
}
closedir($dh);
?>
--
paperCrane 

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


Re: [PHP] Re: Write on image in faint color

2003-12-11 Thread Justin Patrin
Justin Patrin wrote:

imagepng($ih, $dir.basename($file, $fileinfo['extension']).'png');
Oops, the above line should probably be:

imagepng($ih, $dir.'-watermark'.basename($file, 
$fileinfo['extension']).'png');

so as not to trample your previous files (if any are pngs).

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


Re: [PHP] Error that I can't find causing header() to fail

2003-12-11 Thread Justin Patrin
Rogue wrote:

Yes. The html is after the call to header(). I am very clear on header() 
now :)

That isn't the problem since the header() should be called way before 
any output... this is something bizarre here... The offending code is a 
block right smack in the middle of a bunch of other html stuff - which 
is totally similar and removing these lines of code fixes it. So 
strange. AND it is not just one of the rows or something - it is that 
block as a unit for some reason.





On Dec 10, 2003, at 11:53 PM, TheHeadSage wrote:

Is the HTML code before or after the header? As the header(); function
should be before any output is passed to the browser.
I advise you read about the header() function in the PHP manual.

- Original Message -
From: "rogue" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, December 11, 2003 2:34 PM
Subject: [PHP] Error that I can't find causing header() to fail

Hi all,

This template I have, has been driving me nuts. I am trying to debug
someone else's code and have narrowed the problem down to a few lines,
but I can't see what would be causing the problem.
Here is the scoop. When this template loads it is making:

header("Location: http://www.myurl.com";)

Fail. If I remove the following hunk of code, everything works as it
should on the template (redirecting me to the right place). Removing
any ONE row or combination does not seem to fix it, so there is
something to do with this whole block? I am at a loss here and could
really use another pair of eyes.


   

  Fax:


  

   
   

  Street:


  

   
   



  

   
   

  City:


   State:
  

print "$state_name\n";
  }
?>
  

   


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


1) Look in any files you're including before the header() call and see 
if they have any whitespace after a closing php tag (?>).

2) Remove all ?> HTML HERE 

3) Use output buffering up to the header call. Put ob_start() before the 
beginning of it all, then get to the header() point. If you don't need 
to use the header, use ob_end_flush() to flush the captured output. OR 
you can do ob_end_flush() at the very end of the script.

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


Re: [PHP] php .htaccess autologin

2003-12-11 Thread Justin Patrin
Jas wrote:

Combination of session vars and cookie vars...
example...
[login page]
sets cookie with auth=0 (variable)
sets session with auth=0 (variable)
[logged in page(s)]
sets cookie with auth=1 (variable -client side)
sets session with auth=1 (variable -server side)
hash of users password as client side var
then just write a function to look on the users machine for a cookie 
from your site with auth=1, then if you see that present simply 
authenticate the user.

HTH
Jas
Evan Nemerson wrote:

On Thursday 11 December 2003 04:17 pm, ROBERT MCPEAK wrote:

I've dug around quite a bit and can't figure out how I might use PHP to
handle an .htaccess login.  For example, if I wanted a script to log 
in the
user, rather than the user logging in with the standard .htaccess 
dialog.

Any ideas?


I could be wrong, but I think this would be rather client-dependent. I 
don't think HTTP remembers who you throughout a session- i think the 
headers get sent every time. My only idea from PHP would be to set the 
$_SERVER['PHP_AUTH_*'] stuff, but i sincerely doubt that would do 
anything. I just don't think there's a way  to ask the browser to set 
that info through http. Maybe ask @ javascript forum?

If you find a solution, I'd love to hear it...


Since the .htaccess vars are stored in the browser, should I be 
looking at
a PHP/JavaScritpt 1-2 punch?

Thanks,

Bob



You could also use the PEAR::Auth package to do authentication (through 
a form or a .htaccess style popup).

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


[PHP] Re: PHP IDE?

2003-12-13 Thread Justin Patrin
I use Emacs with syntax PHP highlighting. It does tabbing very well as 
well and has a lot of features that I couldn't easily gert out of vim 
(and there's no annoying mode change ;-). (Note: I used to use vim and 
loved it, but emacs seduced me away.)

-paperCrane 

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


[PHP] Re: Whats wrong with this statement.

2003-12-13 Thread Justin Patrin
Philip J. Newman wrote:


$websiteUrl="http://www.philipnz.com/";;
$websiteEmail="[EMAIL PROTECTED]";
// CHECK TO SEE IF DATA MATCHS WHATS IN THE DATABASE.
 $sql = "SELECT hUrl,hContactEmail FROM hyperlinks_data";
 $sql_result = mysql_query($sql, $connection) or die ("Could not get Query"); 

 $exists_hUrl = "0";
 $exists_hContactEmail = "0";
 
 while ($row = mysql_fetch_array($sql_result))   {

  if ($websiteUrl==$row["hUrl"]) { $exists_hUrl = "1"; break;  }
  if ($websiteEmail==$row["hContactEmail"]) { $exists_hContactEmail = "1";  break;  }
  
 }

  Echo" $exists_hUrl, $exists_hContactEmail";

?>

---
Philip J. Newman
Master Developer
PhilipNZ.com [NZ] Ltd.
[EMAIL PROTECTED]
The "break;" breaks out of the while loop, causing it to skip the second 
check and all remaining records. You should be doing this in the SQL:

SELECT hUrl,hContactEmail FROM hyperlinks_data WHERE hUrl = 
"$websiteUrl" and hContactEmail = "$websiteEmail";

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


Re: [PHP] Sorting arrays

2003-12-14 Thread Justin Patrin
Jake McHenry wrote:

-Original Message-
From: Bronislav Klucka [mailto:[EMAIL PROTECTED] 
Sent: Sunday, December 14, 2003 1:52 AM
To: Jake McHenry; 'Php-general'
Subject: RE: [PHP] Sorting arrays

Try to explain a little bit more how the arrays could be 
sorted asscending and by hitting back and submitting form 
suddnely sorted descending...

Brona


Does anyone know of a way to keep sort from reversing the 
array order? 

That is kinda fuzzy, let me explain.

I have a couple arrays that I am sorting. If the user hits the
back 

button in their browser, and hits submit again without changing 
anything, the array is sorted again, now in decending order 
instead of 

ascending as it was the first time around.

The arrays contain dates, and I want them in ascending order.

Is there a way to limit any of the sort routines to ascending
only?

Thanks,

Jake McHenry
Nittany Travel MIS Coordinator
http://www.nittanytravel.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

This page is for adding / editing / removing airline reservations.
What I have done so far is when the user first gets to this specific
page, they enter their info. If they put a check in the add next
flight checkbox, then the same form comes up again, each time adding
the new info to the same array, building upon the old info. The arrays
are then displayed back into form fields where the user can edit any
info submitted.
I'm sorting the arrays by the flight dates. Each time the user enters
a new flight, the array is sorted by date. This is where I'm seeing
the problem. The first flight is fine, of course. The second is fine.
The third flight entered and all of the flights are now in reverse
order. Then the next flight entered, they're all in the correct order,
etc, etc.
This problem will most likely happen to my other arrays further on in
the project.
Is there any way I can make sure that the dates are always in the
correct order?


Thanks,

Jake McHenry
Nittany Travel MIS Coordinator
http://www.nittanytravel.com
This is very strange. sort() ALWAYS sorts the same way when you call it 
the same way, period. Perhaps you're not sorting on the correct data? 
Could you please show us exactly what your arrays look like, which sort 
function you are using, and how you're calling it?

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


Re: [PHP] Sorting arrays

2003-12-14 Thread Justin Patrin
Jake McHenry wrote:

-Original Message-
From: Bronislav Klucka [mailto:[EMAIL PROTECTED] 
Sent: Sunday, December 14, 2003 2:22 AM
To: Jake McHenry
Cc: 'Php-general'
Subject: RE: [PHP] Sorting arrays



Try to explain a little bit more how the arrays could be sorted 
asscending and by hitting back and submitting form 
suddnely sorted 

descending...

Brona


Does anyone know of a way to keep sort from reversing the
array order?

That is kinda fuzzy, let me explain.

I have a couple arrays that I am sorting. If the user hits the
back

button in their browser, and hits submit again without
changing 

anything, the array is sorted again, now in decending order
instead of

ascending as it was the first time around.

The arrays contain dates, and I want them in ascending order.

Is there a way to limit any of the sort routines to ascending
only?

Thanks,

Jake McHenry
Nittany Travel MIS Coordinator http://www.nittanytravel.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

This page is for adding / editing / removing airline reservations.


What I have done so far is when the user first gets to this 
specific 

page, they enter their info. If they put a check in the add next 
flight checkbox, then the same form comes up again, each 
time adding 

the new info to the same array, building upon the old info. 
The arrays 

are then displayed back into form fields where the user can 
edit any 

info submitted.

I'm sorting the arrays by the flight dates. Each time the 
user enters 

a new flight, the array is sorted by date. This is where I'm
seeing 

the problem. The first flight is fine, of course. The 
second is fine. 

The third flight entered and all of the flights are now in reverse


order. Then the next flight entered, they're all in the 
correct order, 

etc, etc.

This problem will most likely happen to my other arrays 
further on in 

the project.

Is there any way I can make sure that the dates are always in the 
correct order?

I'm pretty confused so user puts information into form, 
he/she submits it, and you have 1 date, he press back button, 
fill the same form again submits form, new date is added and 
it's in correct order, he/she does it for the third and it's 
in reverse order, he/she does it for the fourth and it's in 
correct order... funny... could you paste here the sorting 
part of code?

Brona



The user doesn't even have to hit back, each time the form is
submitted, the data is rearranged in opposite order.
Too keep my data together, here is what the data in the arrays looks
like:
Array
(
[0] => 01-30-2004|Wilkes-Barre|PA|Salt Lake|UT||Yes|Yes
[1] => 01-16-2004|Wilkes-Barre|PA|Salem|WA||Yes|Yes
[2] => 01-02-2004|Wilkes-Barre|PA|Denver|CO||Yes|Yes
[3] => 01-08-2004|Denver|CO|Wilkes-Barre|PA||No|No
[4] => 01-23-2004|Salem|WA|Wilkes-Barre|PA||No|No
[5] => 02-11-2004|Salt Lake|UT|Wilkes-Barre|PA||No|No
)
Then, in my script, after the new data is merged with the existing
array, I sort:
$array = $_SESSION['Air_Reservations'];
sort($array)
New output:

Array
(
[0] => 02-11-2004|Salt Lake|UT|Wilkes-Barre|PA||No|No
[1] => 01-23-2004|Salem|WA|Wilkes-Barre|PA||No|No
[2] => 01-08-2004|Denver|CO|Wilkes-Barre|PA||No|No
[3] => 01-02-2004|Wilkes-Barre|PA|Denver|CO||Yes|Yes
[4] => 01-16-2004|Wilkes-Barre|PA|Salem|WA||Yes|Yes
[5] => 01-30-2004|Wilkes-Barre|PA|Salt Lake|UT||Yes|Yes
)
See now? I didn't add a new record this time, but it happens with our
without adding anything new. Each time the array is sorted, this
happens.


Thanks,
Jake
It may be that because those are strings they are being sorted 
strangely. I have two suggestions.

1) Use a sub-associative array or an object for those entries. Delimited 
strings are ok, but actual structures are generally better.

2) use usort() and specify a function which sorts those dates correctly 
(sorting those won't sort by year, only month). OR you could convert 
those dates to UNIX timstamps (with strtotime() possibly) and sort them 
that way (this may also require using usort()).

Try making an array with ONLY dates in it (not the extra info) and see 
if it sorts those correctly.

One more thing: how are you passing these values between pages?

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


[PHP] Re: PHP and MySQL date

2003-12-15 Thread Justin Patrin
Cesar Aracena wrote:

Hi all,

I'm making a site and need some tables from wich I can extract date, time
and/or date/time later with PHP and I neved had very clear the way the
possible formats work with each other so my question is what is the best (or
recommended) method to store dates and/or times in a MySQL DB for PHP to
work later?
Thanks in advanced,
___
Cesar L. Aracena
Commercial Manager / Developer
ICAAM Web Solutions
2K GROUP
Neuquen, Argentina
Tel: +54.299.4774532
Cel: +54.299.6356688
E-mail: [EMAIL PROTECTED]
The best way is to use a datetime or timestamp type in MySql, depending 
on your use of it. Using MySql's types allows you to use MySql's date 
comparison and functions for queries. You can get a UNIX timestamp using 
the UNIX_TIMESTAMP() function in mysql or by using strtotime() in PHP on 
the value.

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


[PHP] Re: mail question (mime)

2003-12-16 Thread Justin Patrin
You may want to try using PEAR's Mail_Mime class.

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


Re: [PHP] Re: mail question (mime)

2003-12-16 Thread Justin Patrin
Cesar Cordovez wrote:

...and talking about mail, is there a class to parse an incoming mail? 
Let me explain: I'm using the great POP3 pear class to receive mail, but 
I'm having trouble separating the different parts in an 
"multipart/alternative" type of msg.  Is there a class to receive the 
result from POP3 class and convert it into an array of all the specific 
parts of an mail?

Well, you could look for yourself. ;-)
Yes, there is. Mail_Mime does both encoding and decoding.
http://pear.php.net/package/Mail_Mime
--
paperCrane 
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Authentication

2003-12-16 Thread Justin Patrin
Robert Sossomon wrote:

I am not trying to authenticate off of a database though.  I have
scripts that automatically modify the .htaccess file as I change a user,
so I need to authenticate off the .htaccess file and store the users
information into a cookie.  I think from the cookie I can do everything
else, just not sure how to get the information from the browser to show
me the user of the page.
~~~
"I am a quick leaner, dependable, and motivated."
-Real live resume statement 
~~~

-Original Message-
From: Chris Shiflett [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, December 16, 2003 11:53 AM
To: Robert Sossomon; [EMAIL PROTECTED]
Subject: Re: [PHP] Authentication

--- Robert Sossomon <[EMAIL PROTECTED]> wrote:

I currently use a .htaccess file for users to login, and now I need to


make some changes to how the site works.

I need to be able to have the users login, and once that is done the 
login needs to be used to pass through the database.


Search PEAR (http://pear.php.net/), because I'm pretty sure there are
aome authentication classes that let you use a database to store the
access credentials.
Hope that helps.

Chris

=
Chris Shiflett - http://shiflett.org/
PHP Security Handbook
 Coming mid-2004
HTTP Developer's Handbook
 http://httphandbook.org/
Well, you could use PEAR::Auth to do these things without having to 
write to a .htaccess file (That's a potential security risk).

Then answer to your question is $_SERVER['PHP_AUTH_USER']. That variable 
will give you the currently logged in user. $_SERVER['PHP_AUTH_PW'] is 
the password.

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


[PHP] Re: saving resource objects

2003-12-16 Thread Justin Patrin
Michael Lewis wrote:
How can I pass this variable and its contents so they are usable to the next
web page?
The short answer is that you can't pass resources back and forth between 
pages. You could consider passing the current index, rerunning the 
query, and seeking to the new index.

OR, you could have it all done for you with:
http://pear.php.net/package/DB_Pager
Not only does this do you "paging" for you, it gets you started using 
DB, a database abstraction class that gives you a standard interface for 
 all databases, lots of useful utility functions, and allows you to 
switch databases if you need to with minimal change to your code.

Or if you don't want ot use DB, you can just use the Pager:
http://pear.php.net/package/Pager
--
paperCrane 
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: saving resource objects

2003-12-16 Thread Justin Patrin
If you're doing a large JOIN (which slows things down) you might try 
writing it all as multiple queries in PHP and having PHP join it 
together. It *may* be faster, especially for many joins.

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


[PHP] Re: Trying to make my session code smarter

2003-12-16 Thread Justin Patrin
Gerard Samuel wrote:

Currently in my code, if a user is blocking cookies (for what ever reason that 
may be), it keeps generating session ids for each page load.
Is there a way to ignore and/or work around these "users"??

Thanks
You can turn on URL rewriting for sessions. I'm not sure where it is 
just nowjust search the PHP docs.

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


[PHP] Re: Help with php output to file

2003-12-18 Thread Justin Patrin
Paul Godard wrote:

Hi

I have develop an online catalog in php/mysql.  Now the client needs the 
web site on a cd.  Of course without php or mysql...

What is the fastes and easiest way to convert the only 2-3 dynamic php 
pages into static html files?

Of course I could copy the html code generated by the php pages for each 
product and save it as different product1.html product2.html ... but 
that will take ages ... 2000 products in 2 languages.

Is there a way to redirect the output of php pages to a file instead of 
to the screen?  So I could create a simple php script that loop for each 
product & languages to generate all the pages.
Well, you could always use web site mirroring software to pull it all. 
Such as "wget -m". It would pull the dynamically generated HTML and 
store it all in files and change the links accordingly. Or you could use 
something else such as WinHTTrack.

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


[PHP] Re: Retrieve key from $_POST

2004-01-05 Thread Justin Patrin
Robin Kopetzky wrote:

Is there any way to retrieve a key value from $_POST when there is more than
one $_POST array entry?
I'm trying to retrieve the name of an 'INPUT TYPE="image"' control with HTML
because you can't pass a value back. I need to get the name of the control
to use in a 'switch' statement.
Well, you can use array_keys() to get the keys of the array. You can 
also use
foreach($_POST as $key => $value) {
  //do stuff here
}
to loop through the entire array.

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


Re: [PHP] [Fwd: failure notice] Why??

2004-01-05 Thread Justin Patrin
Richard Davey wrote:

Hello Rolf,

Tuesday, January 6, 2004, 1:26:31 AM, you wrote:

RB> Whenever I submit a message to this list, I get a bounce back saying its
RB> a dupe, anyone have any ideas?
I get exactly the same - it's highly annoying and happens every time.

Do you use Pair Networks by any chance? (I do and post via their SMTP
server).
I get these as well using my own SMTP server.

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


[PHP] Re: Is there a way to protect PHP's $_POST, $_GET when user tamper with post string in URL toolbox???

2004-01-07 Thread Justin Patrin
When the page is submitted, set your session vars, then redirect to the 
next page.

Or you can set the session vars before you do any other processing.

Scott Fletcher wrote:

Will check into whether did I use the post method correctly.

Speaking of session, I don't see how can it be done to put the data into the
session after the user click the submit button before going over to the next
webpage.
FletchSOD

"Scott Fletcher" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
Hi!

  I wanted to know is is there a way to configure PHP to make it not be
affected when the web user tamper with the values in the post string after
a

webpage is submitted or something.  (Further explanation below)

  I noticed when I use the hidden html input tag with hidden data in it
then when I click the submit button to submit the webpage, the hidden data
then show up in the URL address.  Fine, no problem.  But I noticed one
problem, I can changed the value in the URL toolbar of the web-browser and
get different result on the webpage.   I know it is where $_REQUEST[],
$_GET, etc. come into play.  So, is there a way to keep that $_REQUEST[],
$_GET[] data unchanged?  Does this require the php.ini configuration or
what?
Thanks,
FletchSOD


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


Re: [PHP] Not working?

2004-01-08 Thread Justin Patrin
Roger Spears wrote:
Try this:
system(rename('/path/to/new.sh', '/path/to/old.$today'));
Actually, it should be this:
rename('/path/to/new.sh', '/path/to/old.$today');
--
paperCrane 
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: post vars not by form

2004-01-08 Thread Justin Patrin
Nabil wrote:

HI,
Anyone can help , how to post variables from server side .. as from php page
to other without HTML form and submistion ???
i want post method , to post my vars to another php on another server , then
i have to read the body that will be printed by fopen ... so i can not use
Location:
example :
i wwant to post to www.example.com?var=1&var2=2
and then read the the body from that link .. as 1 or 0   ..
Regards
You can use PEAR's HTTP_Request class to post vars to a site (and a lot 
more). You could also use HTTP_Client if you need things like cookie 
management.

http://pear.php.net/package/HTTP_Request
http://pear.php.net/package/HTTP_Client
--
paperCrane 
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: not sure why regex is doing this

2004-01-09 Thread Justin Patrin
while (eregi(',\s*,',$query)):
 $query = preg_replace('/,\s*,/',',NULL,', $query, -1);
endwhile;
Please don't mix the regex engines like that...it could lead to much 
suffering.
instead of eregi, use preg_match.

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


[PHP] Re: Headers and sessions in php .cgi

2004-01-10 Thread Justin Patrin
BøRge Strand wrote:
Hi there,

I have a problem setting my headers right with php running as .cgi. I
have to specify a Content-type for the cgi file to work. But how
should I do both that and start a session?
I have a few options:

#! /usr/local/bin/php

This way $_SESSION['count'] stays unset even though I say
$_SESSION['count'] = 1; in my program.
To swap the two lines won't work because I heard \n\n terminates the
header portion. Anyway, here goes:
#! /usr/local/bin/php

Now I get "Warning: session_start(): Cannot send session cookie -
headers already sent by... line 3" and then "Warning: session_start():
Cannot send session cache limiter - headers already sent...".
I have tried replacing print 'Content-type: text/html' . "\n\n"; by
print 'Content-type: text/html' . "\n"; (one \n instead of two) with
exactly the same result. With no \n at all I only get "Warning:
session_start(): Cannot send session cache limiter - headers already
sent".
The next thing I try is to replace print 'Content-type: text/html' and
the \n's by sending the same text in header(). This variety gives me a
"500 Internal Server Error" independant on the number of \n's.
Anyway, here's all my code. No matter what I do it always prints "Your
visit number 1". $_SESSION['count'] doesn't get increased at all!

#! /usr/local/bin/php
' . "\n";
print '' . "\n";
if (!isset($_SESSION['count']))
{
$_SESSION['count'] = 1;
}
else
{
$_SESSION['count']++;
}
print 'Your visit number ' . $_SESSION['count'] . "\n";
print '' . "\n";
print '' . "\n";
?>

I hope you can help me out getting my headers straight.

Regards, 

Børge
You should be using header as such:

header('Content-type: text/html');

You don't need and should not include the newlines. The reason that 
other things aren't set is that two newlines ends headers (includeing 
cookies and such) which breaks sessions.

If you simply use header() all of this is dealt with for you as it 
should be. Just make sure that you don't print or echo anything before 
using it (or starting a session).

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


[PHP] Re: Array Key Test

2004-01-12 Thread Justin Patrin
Cameron B. Prince wrote:
Hi,

How would I go about determining if a specific key exists in an array?

I want to see if $conf['hOpt'] is defined. is_array only works at the $conf
level.
You want:

if(isset($conf['hOpt'])) {
 ...
}
You should always use isset to check if a variable is set, whether it is 
a straight variable, an array index, or an object member.

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


[PHP] Re: to array or not to array..

2004-01-12 Thread Justin Patrin
Edward Peloke wrote:

Ok,

This is probably a basic question, I am just looking for opinions and
examples as to the best way to handle this...
I cycling through a query and displaying results to the user such as ...

usernamecan add can delete
eddieY N
frankN N
martha   Y Y
each of the 'Y's and 'N's represent a checkbox.  The user can click
checkboxes for several users then click the update button.  When they click
the update button, I then need to loop through and make updates to the table
for each client.  What is the best way to handle this?  Should these values
be put into a multidemensional array keyed off the users id then loop
through the array to insert into the table?  Should I not use an array and
just someone loop through the results?
Thanks,
Eddie
I would use an array or arrays using [] syntax in the HTML variable names.



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


Re: [PHP] to array or not to array..

2004-01-12 Thread Justin Patrin
The way I deal with this is one of two ways. An easy way is to populate 
hidden fields in the page with the indexes of the users, thwn loop 
through those, checking the indexes of the arrays sent back.


User 5 

User 7 
Another is to loop through, say, records from the DB and use their IDs 
for the indexes of the arrays.

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


Re: [PHP] class design question

2004-01-12 Thread Justin Patrin
Jason Sheets wrote:

Take a look at the PEAR DB Abstraction layer, I usually store connection
info in an XML or INI file and use parse_ini or PEAR Config to parse the
configuration file.  http://pear.php.net

hi there.

i am working out the finishing touches on a authentication class that
uses mysql to store the time of last access and some other goodies.
my question is, when developing a class that uses a database, what is
the best way to handle the database bit? for now i just set the
connection in an .inc file and include that in the class, but there has
got to be a better way - especially for portability sake.
thanks for any suggestions.

- rogue

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
You could even use PEAR's Auth package to even further simplify things. ;-)

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


[PHP] Re: iteration of $GLOBAL

2004-01-12 Thread Justin Patrin
Chris Sherwood wrote:

hello everyone

I feel a little stupid asking this but I have tried multiple searches on google and on php.net and cant seem to find the snippet of code that will iterate through all the global variables for the session

thanks in advance
This will work for any associative array.

foreach($GLOBALS as $key => $value) {
  echo $key.' = '.$value."\n";
}
--
paperCrane Question Everything, Reject Nothing
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Storing PHP code in a database

2004-01-13 Thread Justin Patrin
John W. Holmes wrote:

Justin French wrote:

Is there much I need to know about storing mixed PHP/HTML text in a 
mysql database table, and then using eval() to execute it?

All I managed to find so far is that I should store it in a blob.


A TEXT or BLOB column will do. Only difference is BLOB is case sensitive.

Do I need to escape characters, or perform any other 
filtering/conversions before I store it in the database?  Similarly, 
what steps would people recommend when pulling the data out, before 
executing it?


You're inserting a string, so you need to run addslashes on the data 
before you insert it in your query. You don't have to do anything after 
pulling it out, just stick it in eval().

Just be smart about all this and make sure you're really controlling 
what's being passed to eval(). If you're not careful and let user input 
go directly to eval(), you could be in for some trouble. :)

Rather than addslashes, I would suggest using a database specific 
quoting function. For mysql, use mysql_escape_string() or 
mysql_real_escape_string(). Or if you're using PEAR::DB, use $db->quote().

--
paperCrane 
--
Question Everything, Reject Nothing
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: class functions where the function name == class name

2004-01-13 Thread Justin Patrin
Glenn Yonemitsu wrote:

Hey there guys I just started trying out with writing classes. I've been 
looking at a lot of PEAR class files and noticed this:

class classname {
   function classname() {
   }
}
I know that "$object = new classname;" will automatically run 
$object->classname();. But is it neccessary for every class to have this 
function? I read all these scripts and they all have them. I made one 
simple database class but it failed horribly, and I'm curious to if the 
initiated functions have anything to do with them.

Thanks.
Glenn
If you're writing a database abstraction class, you may want to look at 
PEAR's DB and related packages. http://pear.php.net/package/DB

--
paperCrane 
--
Question Everything, Reject Nothing
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] URL rewriting...anybody done this?

2004-01-14 Thread Justin Patrin
RewriteEngine On
RewriteRule ^show/(.*)/(.*) /show.php?sid=$1&id=$2
Try:
RewriteRule ^show/([^/]*)/([^/]*) /show.php?sid=$1&id=$2
--
paperCrane 
--
Question Everything, Reject Nothing
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: dynamic list/menu in php

2004-01-15 Thread Justin Patrin
I didn't really understand most of what you said (your English is really 
confusing), but you might want to check out DB_DataObject_FormBuilder. 
It will create forms for editing of DB records with select boxes for 
foreign keys. There are also lots of new options in the newest CVS 
version which isn't realeased yet.

http://pear.php.net/DB_DataObject_FormBuilder
--
Question Everything, Reject Nothing
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: addslashes

2004-01-15 Thread Justin Patrin
JoãO CâNdido De Souza Neto wrote:

Hello to all.

I'm using str_replace("\r\n","\\r\\n",addslashes($campo)) to add "\" in
mysql data to send to javascript variable.
Running in my machine with win xp + iis it's all ok, but in server with
linux + apache, the javascript variable no have "\" causing error in my
script.
This could easily be a difference between magic_quotes settings on the 
machines. Check your php.ini file son btoh machines and see if 
magic_quotes_gpc or magic_quotes_runtime is on. If the settings differ 
between machines, this is probably your problem.

--
paperCrane 
--
Question Everything, Reject Nothing
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] 2 x DB connections at once

2004-01-22 Thread Justin Patrin
You're running into an old error. I believe that this was a problem with 
previous versions of PHP, are you using the newest version?

Barring that, if you add true to the end of the mysql_connect call to 
make it a different connection, that should also fix things.

Or you could try using PEAR::DB or one of the other DB abstraction 
classes which will take care of all of that for you.

http://pear.php.net/package/db

Donald Tyler wrote:

OK, now I have done some work and it gets even stranger.

Two Objects

Validator
Importer
Both objects have private variables called $this->Connection

However, when I change the DB for one objects connection pointer, the other
objects connection pointer ALSO changes DB.
Is it not possible to have two completely separate DB connections active at
the same time?
-Original Message-
From: Donald Tyler [mailto:[EMAIL PROTECTED] 
Sent: Thursday, January 22, 2004 3:08 PM
To: [EMAIL PROTECTED]
Subject: [PHP] 2 x DB connections at once

I thought this was possible, but it doesn't seem to be working:

I have a class, that has a private variable called $this->Connection, which
is a Database Connection pointer to a MySQL database. During the lifetime of
the Class, it uses the connection multiple times without a problem.
The class also uses a function from an include file that has its OWN
Database Connection pointer. And it seems that for some reason, as soon as
that external function is called, the Private Database Pointer within my
Class suddenly points to the Database name that the external functions
Database Pointer was using.
I ALWAYS specify which connection pointer I want to use when selecting the
DB and doing a mysql_query, so I have no earthly idea how the external
Connection pointer is affecting my Private Connection Pointer.
I hope I explained that well enough; it's real difficult to put into words.

Does anyone have any idea what might be happening?



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


Re: [PHP] pass by reference

2004-01-23 Thread Justin Patrin
Kevin Waterson wrote:

This one time, at band camp, Tom Rogers <[EMAIL PROTECTED]> wrote:



php can output the stream without having to save it to a file first if
that is what is worrying you.


That was sorta my concern, but not so much as a file, does it copy to
memory anywhere, or, is it a direct stream to the browser?
Well, you're making a few copies doing it through PHP. Or possibly just 
one. When PHP fetches it from the DB, it's stored in a variable (and the 
data *may* be stored in an intermediate form by the PHP internals, but I 
certainly don't know for sure. My gut says that it is, though.).  Then 
you output it to the browser.

Yes, this is somewhat inefficient, but the only way I can think of to 
make it more efficient would be to make the images files and have the 
webserver send them directly. I suppose this terraserver might be able 
to "stream" the data as it gets it from the DB server, but it's still 
makign a copy. It just happens to be very small pieces of the image, 
outputted as they get to the server. While this is kinda cool, it seems 
a bit too far to go for normal applications. If you're worried this much 
about speed, you shouldn't be storing the images in the DB in the first 
place. Storing them as files will nearly always be faster than any other 
method (unless you've cached them in RAM somehow ;-).

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


Re: [PHP] what PHP really needs

2004-01-23 Thread Justin Patrin
John W. Holmes wrote:

From: "Chris Boget" <[EMAIL PROTECTED]>

[snip]

[/snip]
Learn and use C++
Or sessions.
Along with serialize() and deserialize(), all are your friends in this
case.

He's talking about the same set of data being available to all instances of
PHP, though. I think they're called Application Variables. So if I set
$instance=1 as an application variable, any other PHP script that runs can
read that value. I imagine the same thing could be done with an object.
Either that or I'm way off base. It does sound useful, but I see how it
could be overused and abused.
---John Holmes...
Then you could use a serialized file in the filesystem that any app can 
read. For added speed, make a RAM-disk and store the file there. Slight 
overhead deserializing, but it's likely faster than recreating whatever 
it is (if it's large).

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


Re: [PHP] Best practice to re-write a tutorial website

2004-07-23 Thread Justin Patrin
On Fri, 23 Jul 2004 17:51:52 +0300, EE <[EMAIL PROTECTED]> wrote:
> On Fri, 2004-07-23 at 00:06, Justin Patrin wrote:
> > On Thu, 22 Jul 2004 23:48:54 +0300, EE <[EMAIL PROTECTED]> wrote:
> > > Dears,
> > >
> > > I am planing to rewrite my website. My site is tutorial-type site I
> > > wrote it, when I first learned php3, as an undergraduate research class.
> > > I think the code is sloppy as it is mixed with the HTML. I would like to
> > > rewrite the site utilizing the good things such OOP classes, template,
> > > etc. I would also like to separate my styles (CSS) from the HTML.
> 
> Do you recommend any any tutorial?
> > >
> > > I would like to have the following functions:
> > >
> > > 1. Printer Friendly Version Capability
> >
> > You can use CSS and @media print to have *different* CSS for printing,
> > right from the same site. You could also just have a different
> > stylesheet that you include when the user wants to print. Or you could
> > have multiple templates. Whatever floats your boat.
> >
> > > 2. Search-ability
> >
> > A CMS could possibly handle this, but may be a bit big for this. If
> > you want search capabilities, I'd look into a local solution that
> > indexes your site manually. I've had good luck with mnogosearch.
> > 
> How about using MySQL fulltext?
> 
> > > 3. Search Engine Friendly
> > >
> >
> > https://www.reversefold.com/tikiwiki/tiki-index.php?page=PHPFAQs#id926344
> >
> 
> I read the aritcle and it is good.
> 
> > > Therefore, I have the following questions:
> > >
> > > 1. What is the best way to store the tutorials. Should they be in a
> > > database or each in a separate HTML file.
> >
> > I'd go for database. But if you do that, you may want to look into
> > some existing CMS software.
> 
> Do you recommend any? I'll appreciate if you point me to the right
> track.
> 

Wellthere's tikiwiki, which I'm using on my personal site right
now. It's real quick to get up and use. Then there's TYPO3, which I'm
using for work. It's very large and complex, but a very nice system.

> >
> > >
> > > 2. How to implement the above three points?
> > >
> > > I know it is a broad question but you can help me on whatever you know?
> > >
> 

-- 
DB_DataObject_FormBuilder - The database at your fingertips
http://pear.php.net/package/DB_DataObject_FormBuilder

paperCrane --Justin Patrin--

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



Re: [PHP] Refer a class

2004-07-26 Thread Justin Patrin
On Sun, 25 Jul 2004 20:00:18 +0200, Michael Ochs <[EMAIL PROTECTED]> wrote:
> I can call $myclass->module['mymodule']->variable; so I think the class is
> instantiate correctly. But the reference doesn't seem to work, cause the
> variable I get ist always the same:
> 
> $myclass->nickname = "xyz";
> $class2 = $myclass->loadModule("mysecondclass");
> $myclass->nickname = "abc";
> 
> Now, when I call $this->main->nickname in $class2, wich actually should call
> $myclass, it returns "xyz" instead of "abc"!
> 
> Any idea?
> 

It's being copied somewhere. Maybe try this in the loadModule function:
$this->module[$name] =& new $name($this);

You don't need the & for $this as you've defined the function to send
it by reference.

> Thanks, Michael
> 
> "Jason Davidson" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
> news:[EMAIL PROTECTED]
> 
> 
> > If there is no error, check the values of all the vars and array
> > ellements in your logic for the first method.  Make sure its actually
> > getting to the point where it instantiates the new object.
> >
> > Jason
> >
> > On Sun, 25 Jul 2004 19:36:44 +0200, Michael Ochs <[EMAIL PROTECTED]>
> wrote:
> > > Hi,
> > > I try to load some 'modules' into my class. These modules are other
> classes.
> > > I want to refer the main class to this new module but that doesn't work.
> At
> > > the moment it looks like this:
> > >
> > > Mainclass:
> > >
> > > function loadModule($name) {
> > > if(class_exists($name)) { //Class found
> > > if(!$this->module[$name]) {
> > > $this->module[$name] = new $name(&$this);
> > > }
> > > return true;
> > > } else {
> > > return false;
> > > }
> > > }
> > >
> > > The mainfunktion of the module:
> > >
> > > function module_artikelvote(&$parent) {
> > > $this->main = &$parent;
> > > return true;
> > > }
> > >
> > > I can use $this->main->VARIABLE but the values are old. If I call a
> function
> > > with $this->main->func_name(); it doesn't work, but there also isn't an
> > > error message!
> > >
> > > What's wrong with these functions?
> > >
> > > Thanks for help, Michael
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> > >
> > >

-- 
DB_DataObject_FormBuilder - The database at your fingertips
http://pear.php.net/package/DB_DataObject_FormBuilder

paperCrane --Justin Patrin--

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



Re: [PHP] Fwd: IMPORTANT: Please Verify Your Message

2004-07-26 Thread Justin Patrin
On Sun, 25 Jul 2004 19:05:38 -0700 (PDT), Mark <[EMAIL PROTECTED]> wrote:
> --- Jason Wong <[EMAIL PROTECTED]> wrote:
> > On Sunday 25 July 2004 09:42, Mark wrote:
> > > Am I the only one who gets annoyed at these?
> > 
> > No you're not. Look in the past week's archives.
> >
> > > [EMAIL PROTECTED], [EMAIL PROTECTED] is currently
> >
> > You've got the culprit here. Either lambast him publically (since
> > he doesn't
> > want to receive your private mail). Or do what this says:
> > 
> > > http://www.tgpwizards.com/spamcease2/verify.php?id=1334886
> >
> > Or set a filter to trash these messages.
> 
> If he doesn't want my emails, so be it. Filter is set... Seems pretty
> incompetent to not be able to whitelist a dstribution list.
> 

This isn't nearly fair. Some of the PHP lists still have spam coming
in on them, so whitelisting it will let the spam in.

> BTW, I just got one that *implies* php-general is using their filter.
> There was no other address, and it appears to be forged from
> [EMAIL PROTECTED]
> 

Well then, it *does* sound like something isn't right here.

-- 
DB_DataObject_FormBuilder - The database at your fingertips
http://pear.php.net/package/DB_DataObject_FormBuilder

paperCrane --Justin Patrin--

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



Re: [PHP] [Fwd: IMPORTANT: Please Verify Your Message]

2004-07-26 Thread Justin Patrin
On Mon, 26 Jul 2004 11:27:32 +0300, EE <[EMAIL PROTECTED]> wrote:
> What is this? I got this message few times from php.net...
> 

Well, that's weirdI've never seen that one.

-- 
DB_DataObject_FormBuilder - The database at your fingertips
http://pear.php.net/package/DB_DataObject_FormBuilder

paperCrane --Justin Patrin--

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



Re: [PHP] Re: PHP editor that doesn't require installation

2004-07-26 Thread Justin Patrin
On Mon, 26 Jul 2004 10:20:56 -0700, barophobia <[EMAIL PROTECTED]> wrote:
> On Sat, 24 Jul 2004 16:37:03 +0200, rush <[EMAIL PROTECTED]> wrote:
> 
> > scite, from the scintilla fame. TemplateTamer would also work fine if you
> > just copy the whole directory
> 
> wow. that's a pretty awesome editor. too bad it can't connect to FTP
> sites. all my files are remote!
> 
> anyone have a work around for this?
> 

Edit locally and FTP manually.

Or get some kind of mounted FTP filesystemdoesn't Windows XP have
something like this built in?

-- 
DB_DataObject_FormBuilder - The database at your fingertips
http://pear.php.net/package/DB_DataObject_FormBuilder

paperCrane --Justin Patrin--

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



Re: [PHP] Problem with PEAR DB & MySQLi

2004-07-26 Thread Justin Patrin
On Mon, 26 Jul 2004 12:18:37 -0500 (CDT), Rodolfo Gonzalez Gonzalez
<[EMAIL PROTECTED]> wrote:
> Hi,
> 
> I'm trying to use PEAR's DB class with the new PHP 5 MySQLi support on
> MySQL 4.1.3, using this example from the PEAR's docs (with my parameters
> of course). I'm getting "DB unknown error" messages after the query. The
> same query from the mysql client works fine, there are no connection
> problems... anyone has tried PEAR with mysqli?.
> 
>  // Create a valid DB object named $db
> // at the beginning of your program...
> require_once 'DB.php';
> 
> $db =& DB::connect('mysqli://prueba:[EMAIL PROTECTED]:3306/mibase');
> if (DB::isError($db)) {
> die($db->getMessage());
> }
> 
> // Proceed with a query...
> $res =& $db->query('SELECT * FROM users');
> 
> // Always check that result is not an error
> if (DB::isError($res)) {
> die($res->getMessage());
> }
> ?>
> 
> result:
> 
> DB Error: unknown error
> 

Echo $res->getUserInfo() as well. It has the real error.

-- 
DB_DataObject_FormBuilder - The database at your fingertips
http://pear.php.net/package/DB_DataObject_FormBuilder

paperCrane --Justin Patrin--

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



Re: [PHP] issue a value on header, not working..

2004-07-26 Thread Justin Patrin
On Tue, 27 Jul 2004 11:59:14 +0800, Louie Miranda <[EMAIL PROTECTED]> wrote:
> This outputs a filename on $catchresult, and im working on redirecting
> it to that file via header. But when ever i run this the value of
> $catchresult is not being pass to the header() on php.
> 
> $catchresult = $db_view->getOne($getfile);
> header('Location: clients/FILES/$catchresult');
> 
> Hmm, it seems simple but, its really not working..
> 

When using single quotes, variables aren't replaced by their content.
Using double quotes would fix it, but consider this alternative:

header('Location: clients/FILES/'.$catchresult);

Cleaner, more obvious that you're using a variable, will be
highlighted correctly by syntax highlighters, and, most important,
it's faster. :-)

-- 
DB_DataObject_FormBuilder - The database at your fingertips
http://pear.php.net/package/DB_DataObject_FormBuilder

paperCrane --Justin Patrin--

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



Re: [PHP] exists max number of case block in switch steatment ?

2004-07-27 Thread Justin Patrin
On Tue, 27 Jul 2004 15:36:13 +0200, Gianni Pirini
<[EMAIL PROTECTED]> wrote:
> Hello !!
> First of all, sorry for my english...
> I've one question, what is a reasonable max number of case block in a switch
> steatment?
> If i want to redirect 300 pages, for example, to one page index.php?id=32
> and include in this page, in base of the id value, 300 different pages, i
> can have some problem or not ?
> 

Sorry, I have no idea what you're asking. Are you saying you want a
switch with 300 case statements, all redirecting to one page? That
doesn't make sense. If you mean a switch with 300 different cases, yes
you can do itbut you should really switch to maybe a DB backend as
300 case statements would be very hard to maintain.

-- 
DB_DataObject_FormBuilder - The database at your fingertips
http://pear.php.net/package/DB_DataObject_FormBuilder

paperCrane --Justin Patrin--

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



Re: [PHP] Sendmail Return-Path

2004-07-27 Thread Justin Patrin
On Tue, 27 Jul 2004 22:07:52 +0100, Enda Nagle - Lists
<[EMAIL PROTECTED]> wrote:
> Hi Guys,
> 
> I¹m using PHP¹s mail() function on several sites, but have difficulty
> sometimes with the mails being tagged as SPAM.
> 
> I want to have the Return-Path set to the site admin, but can¹t see where to
> do this.
> 
> I know that it can be done at server root level but I can¹t really do that
> as its a shared server.
> 
> I do have my own php.ini file for my site, but can only see the following
> vars:
> 
> mail function]
> ; For Win32 only.
> SMTP = localhost
> 
> ; For Win32 only.
> sendmail_from = [EMAIL PROTECTED]
> 
> ; For Unix only.  You may supply arguments as well (default: "sendmail -t
> -i").
> sendmail_path = /usr/sbin/sendmail -t -i
> 
> I¹m working off a Linux box, so presumably I can¹t use the sendmail_from
> variable?

Nope, that's only for windows.

> 
> I also tried to set the following variable in the headers for the mail:
> 
> $headers .= "X-Return-path: ME <[EMAIL PROTECTED]>\r\n";

This should work if you put it in the right place in the call. Try
just \n as well. If it doesn't work, try using a mailing class such
as:

http://pear.php.net/package/Mail

> 
> Any help appreciated,
> 
> Thanks
> 
> Enda
> --
> 
> - + - + - + - + - + - + - + - + - + - + - + - + -
> 
> Enda Nagle
> +353 86 168 0774
> [EMAIL PROTECTED]
> www.category9.com
> 
> - + - + - + - + - + - + - + - + - + - + - + - + -
> 
> !DSPAM:4106c542182671082813648!
> 


-- 
DB_DataObject_FormBuilder - The database at your fingertips
http://pear.php.net/package/DB_DataObject_FormBuilder

paperCrane --Justin Patrin--

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



Re: [PHP] Verifying AUthorised Users through Session Variables not Working...?

2004-07-27 Thread Justin Patrin
On Tue, 27 Jul 2004 23:21:34 +0100, Harlequin
<[EMAIL PROTECTED]> wrote:
> Hi all.
> 
> I'm using session variables to identify if a user is authorised, if yes -
> display x and so on.
> 
> However, I've come across a couple of issues:
> 
> when users access a page that's 2 folders deep into the root I.e.
> www.mydomain.com/folder1/folder2 any include references I use have to be
> absolute instead of relative, has anyone else come across this...?
> 

Relative includes are relative to the "starting" script's location. So
if you have config.php in folder1 and you're accessing folder2, you
have to use ../config.php.

One way to get around this is to have all includes in a central place
and add it to your include_path (This is what I do). I do it through
ini_set, but you could do it through a .htaccess file or the php.ini
much easier.

> Also: users are not being authorised even though there's a variable that
> says they are. I have verified this by placing a file in folder1 and it
> displays fine but if I click a link to access a file in foder2 I get a login
> page - I shouldn't. Any ideas...?

I assume you're calling session_start() in *all* of these pages?
Sessions *will* work across all folders on your website. Or at least
they should. You're not changing domains, right? Like from without
www. to with www.?

> 
> --
> -
>  Michael Mason
>  Arras People
>  www.arraspeople.co.uk
> -
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> !DSPAM:4106d348216571949498371!
> 
> 


-- 
DB_DataObject_FormBuilder - The database at your fingertips
http://pear.php.net/package/DB_DataObject_FormBuilder

paperCrane --Justin Patrin--

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



Re: [PHP] eliminate keyword

2004-07-27 Thread Justin Patrin
On Tue, 27 Jul 2004 18:29:42 -0500, Raúl Castro <[EMAIL PROTECTED]> wrote:
> Hello,
> 
> I have a form with a textarea field, I'm trying to eliminate the  keywords 
> that users write on it, what can I do using php? for instance: the original phrase 
> would be: "Hello  world!"
> after using a function php must be: "Hello world!".
> 

If you don't want newlines, don't use a textarea.

But it you really want it:

$text = str_replace(array("\n", "\r"), ' ', $text);

-- 
DB_DataObject_FormBuilder - The database at your fingertips
http://pear.php.net/package/DB_DataObject_FormBuilder

paperCrane --Justin Patrin--

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



Re: [PHP] Showing all users who are logged in

2004-07-27 Thread Justin Patrin
On Tue, 27 Jul 2004 19:55:49 -0400, Jason Giangrande
<[EMAIL PROTECTED]> wrote:
> Anyone have any suggestions as to the best way to keep track of all
> users who are logged in at a given time?  I thought of writing them to a
> temp text file and them deleting the names from the file when a user
> logged out, but I think there has to be a better way.  Anyone have any
> suggestions?
> 

Save when a user logs in to the DB. Or whenever they access a page.
Clear them out after x minutes and no activity.

-- 
DB_DataObject_FormBuilder - The database at your fingertips
http://pear.php.net/package/DB_DataObject_FormBuilder

paperCrane --Justin Patrin--

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



Re: [PHP] Adding +7 more days on date() value problem

2004-07-27 Thread Justin Patrin
On Wed, 28 Jul 2004 11:30:42 +0800, Louie Miranda <[EMAIL PROTECTED]> wrote:
> I can't figure how could i add +7 more days on the DD (Day) value. My
> problem is, when the day is close on the end of the month like
> 
> 07/29/2004
> 
> when i add +7 on 29 = 36, its obvious we dont have 36 on the calendar.
> And im creating a program below, to explode it and maybe just add +.
> But i think its useless if im just going to do + on the DD (Day)
> value.
> 
> Hmm :?
> 
> ##
>  $curdate = date("Y-m-d");
> $plus7 = explode("-", $curdate);
> 
> print ("
> cut:
> " .$plus7[0]. "
> " .$plus7[1]. "
> " .$plus7[2]. "
> 
> 
> Current Date: $curdate
> +7 Dats Date: $plus7
> 
> ");
> ?>
> ##
> 

$add7days = date('Y-m-d', strtotime($oldDate) + 7 * 24 * 60 * 60);

-- 
DB_DataObject_FormBuilder - The database at your fingertips
http://pear.php.net/package/DB_DataObject_FormBuilder

paperCrane --Justin Patrin--

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



Re: [PHP] Data management tool

2004-07-27 Thread Justin Patrin
On Tue, 27 Jul 2004 22:09:35 -0700 (PDT), Jaskirat Singh
<[EMAIL PROTECTED]> wrote:
> Hi Everyone,
> I am looking for a tool that lets me do simple data managment ie.
> edit,update,insert and delete records in tables of a database.
> 
> I am kinda fed up of writing those php scripts for back ends of
> websites over and over :). I am looking for some thing generic to
> replace that if possible.
> 
> PhpMyAdmin is a great tool but I don't want the user to have access to
> drop table and empty table etc. I cannot change the permissions of
> MySQL user.
> 


Bum bu da bah!


Enter DB_DataObject_FormBuilder and its simple, yet powerful frontend.
For more info:
http://pear.php.net/package/DB_DataObject_FormBuilder
http://opensource.21st.de/tiki-index.php?page=DB_DataObject_FormBuilder
http://www.reversefold.com/tikiwiki/tiki-index.php?page=DB_DataObject_FormBuilder_Frontend

If you need help using DataObject, FormBuilder, or the frontend, don't
hesitate to ask for help.

-- 
DB_DataObject_FormBuilder - The database at your fingertips
http://pear.php.net/package/DB_DataObject_FormBuilder

paperCrane --Justin Patrin--

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



Re: [PHP] PHP Templates Cached on Server

2004-07-28 Thread Justin Patrin
On Wed, 28 Jul 2004 14:41:20 -0400, rogue <[EMAIL PROTECTED]> wrote:
> Hi all,
> 
> I am doing some development work on a new server I put together. For
> some reason, changes I make to PHP templates don't show up right away.
> I have not figured out how long they take to start showing, but it
> could be somewhere around 30 - 60 seconds.
> 
> Where is this setting modified?
> 

If you're talking about actual PHP files, they normally aren't cached
at all. Are you running some kind of cache, such as Turck MMCache?

If you're talking about something like Smarty templates then you need
to look into the settings of your template system.

-- 
DB_DataObject_FormBuilder - The database at your fingertips
http://pear.php.net/package/DB_DataObject_FormBuilder

paperCrane --Justin Patrin--

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



  1   2   3   4   5   6   >