[PHP] Re: mod_rewrite from .htaccess

2005-04-13 Thread Dasmeet Singh
Matthew Weier O'Phinney wrote:
* Amir Mohammad Saied <[EMAIL PROTECTED]>:
I want to use mod_rewrite patterns, but i have not access to the 
httpd.conf so i think i should use .htaccess, but the patterns don't 
work properly there, have my admin should set any settings in the 
httpd.conf?

I use mod_rewrite from .htaccess all the time; just make sure that you
have the 'RewriteEngine on' directive in your .htaccess file before your
rewrite rules. 

It's entirely possible, however, that the server admin has denied
permission for that action in the global httpd.conf, though. If you
simply cannot get rules to work -- rules that you know work on another
machine, for instance, that would be the next step to try.
This should help you :)
http://www.yourhtmlsource.com/sitemanagement/urlrewriting.html
http://www.webmasterworld.com/forum92/82.htm
Regards,
Dasmeet
http://hostwindow.info
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: User Management

2005-04-13 Thread Dasmeet Singh
This seems to be something exactly as i was looking for.. Can you pls 
send me some tutorials/examples/links on how to implement it?

Regards,
Dasmeet
http://hostwindow.info
Eugene Voznesensky wrote:
Yoy can try this one:
http://pear.php.net/package/LiveUser

Hi!
I am developing an applicaton in PHP where
different users would have 

different permissions and access to different
functions/pages of website. 

Now whats the best way to do tht?
One way I can think of is keep all permissions in
a table and divide 

everyting on site into functions..and when every
function is called, check 

whether thecurrent user has permission to
particular function..
But this method looks quiet complicated..is ther
any other way to do this?
Also if you can give me some links to
articles/tutorials on user/levels 

management in PHP, it would be really helpful..
Thanks in advance 
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


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


Re: [PHP] Re: Index of /base-1.1

2005-04-13 Thread Mark Sargent
Mark Sargent wrote:
David Robley wrote:
Mark Sargent wrote:
 

Hi All,
typing localhost/bse-1.1 gives me access, but, in this format,
Index of /base-1.1
Icon  Name Last
modified   Size
  Description

 

[DIR] Parent Directory 
-   [DIR] admin/ 
04-Apr-2005 05:27-   [   ] base_ag_common.php
  04-Apr-2005 
05:26 3.5K

a listing of the dir, which, I guess, is not too good. What have I done
wrong here..?
  

Forgotten to add appropriate information for DirectoryIndex in your 
Apache
configuration maybe?

David
 

Hi All,
thanx, David, will check tomorrow at work. Cheers.
Mark Sargent.
Hi All,
seems it was that. What I don't understand, though, is, why the 
index.php file worked in the document_root dir and also in another dir, 
testphp, that I created to test the working index.php that copied into 
it, but the index.php files in both the base dir and the phpmyadmin 
wouldn't. Cheers.

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


Re: [PHP] php and javascript

2005-04-13 Thread Richard Lynch
On Mon, April 11, 2005 5:04 pm, Marek Kilimajer said:
> Richard Lynch wrote:
>> On Mon, April 11, 2005 4:23 pm, Jared Williams said:
>>
>>>Hmm, document.forms['Selection'].elements['distID[]'][0].value is
>>>perfectly valid, and should work in any decent browser.
>>>
>>>There is also document.getElementsByName()
>>
>>
>> Didja try it?
>>
>> Cuz every time *I* ever tried it (back in Browser Wars 3.0/4.0 days,
>> mind
>> you) the JavaScript would see the [] as an array reference and *NOT* as
>> part of the name.
>
> That was a long time ago. Try it now.

No.

My clients are starving musicians who get their computers out of the
dumpsters after yours throw them away :-)

They're stuck with version 3/4 browsers by hardware limitations.

Maybe some day I'll even use CSS... Nah.  Too flaky even now.  I'll
probably be dead before they get that mess cleaned up.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] dynamic image will not print properly

2005-04-13 Thread Richard Lynch
On Mon, April 11, 2005 5:48 pm, DuSTiN KRySaK said:
> On 11-Apr-05, at 5:05 PM, Richard Lynch wrote:
>
>> On Mon, April 11, 2005 3:04 pm, DuSTiN KRySaK said:
>> Fourth:  On the broken server, take *OUT* the header() lines in your
>> script, and surf directly to the image URL.  If you see PHP messages,
>> well, fix your script to get rid of them.  If you see a bunch of weird
>> characters, that's what it *should* be -- Pretty much the "same" as you
>> would see if you opened up a real JPEG in a text editor.
>
> I get the proper JPG results. As I said earlier - the output is only
> messed in the win/ie combo while printing.

Sorry, forgot that part...

Okay, try this.

Take your HTML page, scrape down as a static page, upload it, and try to
print the static page with the static image.

Pehaps GD, PHP, and everything else have *nothing* to do with this.

Maybe the *PRINTER* just chokes on some specific JPEG images, dynamic or not.

If so, then you are looking for a new printer driver, or documentation of
known issues with that printer and printing JPEGs of particular
characteristics.

The more I think about this, the more likely it is that the printer just
doesn't like that JPEG, period.

If the browsers likes it just fine...

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] Storing password in cookie

2005-04-13 Thread Richard Lynch
On Mon, April 11, 2005 8:12 pm, Chris Shiflett said:
> Richard Lynch wrote:
>> On a shared server, every other PHP scripter can read your session data,
>> if they work at it a little bit.
>
> You should mention that this is assuming a default configuration. There
> are ways to avoid this.

There aren't a whole lot of shared servers that are running a different
pool of httpd for each user, nor using only CGI with different user ids,
nor...

I daresay that unless you are setting up a shared server yourself, rather
than renting space on one, you'll be hard-pressed to find that feature...

Perhaps phpsec.org would want to list hosts who go above and beyond the
current norm and actually provide that.

I know I've never seen one, at least not that's affordable to me.

>> For truly sensitive stuff like a CC#, do *NOT* put that in session data.
>> Write your script to get the CC# via SSL, process it, and throw it away,
>> all in one single PHP script.
>
> This is good advice, but if there is a business need to store the credit
> card number (for whatever reason), it's not necessarily always best to
> avoid storing it in the session.

If you can think of a good business reason to store somebody's CC# in
$_SESSION, I guess it must exist.

I sure can't think of one...

> Performance considerations can require that you couple its retrieval
> with other session data rather than incur the extra expense. It's just
> one of those things that is a little bit application-specific.

I dunno...  I mean, for me, a CC# comes from $_GET or $_POST, gets
scrubbed and validated for reasonable digits, gets sent to the Credit Card
processor, and you store the resulting transaction code from the Credit
Card guys, and that's it.

Any other data you've got tied in to the transaction, session, user, or
whatever, you've got a unique number you gave the Credit Card guys, and
you can match that up before you run the CC#, or even later on, if you
give the Credit Card guys a non-ephemeral unique ID to tie to the
transaction.

I guess I'm just blinded by experience to doing anything else with a CC#
-- That or shocked by seeing CC#s sitting in a new client's MySQL
database, in perpetuity, after transactions had been done.  [shudder] 
That sure got changed in a hurry. :-^

I'm certainly interested to know when/why Chris Shiflett would store a CC#
anywhere at all, unless he's actually working *FOR* the Credit Card guys,
cuz that's what they're there for. :-)  That doesn't count.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



[PHP] Dedicated server (0T)

2005-04-13 Thread Ryan A
Hey,
Can anyone recommend a host for dedicated hosting? Hopefully one that you
have used.
Please reply offlist so as not to disturb anyone else.

Thanks,
Ryan



-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.9.9 - Release Date: 4/13/2005

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



Re: [PHP] Storing password in cookie

2005-04-13 Thread Richard Lynch
On Tue, April 12, 2005 4:40 am, [EMAIL PROTECTED] said:
[lots and lots of stuff, mostly valid, about Security being applied in
ratio with the data being protected]

I don't have the time to answer this point by point.

So I'll stick with some generalizations.

I have what I consider a MINIMUM standard level of security for any site
that asks for a password.

That would include:
Not storing the password *ANYWHERE* in clear-text.
  Not in database.
  Not in $_SESSION
  Not in COOKIES

Not storing an encrypted username/password in $_SESSION/COOKIE if having
those values provides access.  Because at that point, the encryption is
rather meaningless, as it's really a clear-text 32-character code that
happens to be the encrypted value of something secret, but the clear-text
32-character code gives the Bad Guy access, whether they know the secret
or not.

If your content/application/data is important enough to warrant a
username/password, then it should be important enough to secure with this
minimal level of security, IN MY OPINION.

The "tie-in" from a given user's session data should be ephemeral -- it
should expire within a short time frame.

It should also be un-guessable, like PHP's session IDs.

It should not, in and of itself, provide enough data for a Bad Guy with
the means to readily compromise an account on a long-term basis.

If users forget passwords, they should get new random passwords, with the
application/email directing them to change those passwords to memorable
(to them) but hopefully un-guessable (to Bad Guys) values.

Nothing I am recommending is significantly more difficult, nor complex,
then the alternatives you are presenting.

I would contend that anything less is simply a false sense of security,
provided to the un-informed, by using inherently insecure
username/password methodolgy.

The fact that 10 zillion sites are currently doing exactly that does not
make it "right".

You obviously disagree, and think everything is just hunky-dory in the 10
zillion sites that are leaking passwords to any Bad Guy with half a clue.

We'll simply have to agree to disagree on what is a minimal standard level
of security, and move forward.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] Finding records within 15 minutes from now?

2005-04-13 Thread Richard Lynch
On Tue, April 12, 2005 12:33 pm, J J said:
> I'm struggling with the php or mysql query to find
> records within my database that are within 15 minutes
> from now and prior.
>
> Example:
> It's 2:30pm on 4/12/05
>
> I need to find all records with a RecordTime of 2:45pm
> and previous.
>
> So it should find:
> rec1 time: 2:45 date: 4/12/05
> rec2 time: 2:00 date: 4/12/05
> rec3 time: 1:30 date: 4/8/05
> etc.
>
> It would not find:
> rec4 time: 3:15 date: 4/12/05
> rec5 time: 4:00 date: 4/23/05

If RecordTime does not contain the DATE as well, as I suspect, then you
need to add/combine the two fields (date & time) before you compare to
'now()' with date_add() and INTERVAL.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] Storing password in cookie

2005-04-13 Thread Richard Lynch
On Tue, April 12, 2005 8:03 pm, [EMAIL PROTECTED] said:
> On 11 Apr 2005 Chris Shiflett wrote:
>
>> > > DO NOT STORE PASSWORDS ON USERS COMPUTER
>> >
>> > A couple of people have stated this but I think it is incorrect.
>>
>> Please refrain from such speculation, because it does nothing to improve
>> the state of security within our community. This idea of storing
>> passwords in cookies is absurd.
>
> Hmmm, sorry, it wasn't speculation but an opinion in response to what I
> thought had moved from a practical into a theoretical discussion.  I
> agree, storing even an encrypted password in a cookie is a poor idea in
> most situations.  But to me development is about selecting the right
> tool and using it the right way for the job at hand, and as a matter of
> principle I'm not convinced that a password stored in some form in a
> cookie can never, ever be the right tool for any job -- even if it's
> the wrong tool for many or most.

Some absolutes are absolute.

That's why we call them absolutes.

This is one of them.

If you can think of a single real-life counter-example, feel free to post
it, and shock the world.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] enterprise patterns headache

2005-04-13 Thread Richard Lynch
On Wed, April 13, 2005 2:01 pm, Robert Janeczek said:

I can't claim a detailed understanding of what you are doing, and,
frankly, it sounds like you are creating a BUNCH of over-engineered
headache-inducing code without a good, proven need for it.  YMVV.

That said, one thing I *did* understand and can comment on:

> Sample code:
> $company = CompanyMapper::find(1); // we have ghost inside $company
> //some other operations, but we don`t touch $company
> $company2 = CompanyMapper::findByName('Big Ltd.');
>
> Now let`s assume, that company with ID=1 has name Big Ltd. We have two
> independent copies of the same object what kinda sucks :] The problem is
> that both finding methods return ghosts and the second one doesn`t know
> his ID yet. If there would be only ID-based searching than Identity Map
> would detect it and caused returning the same instance, but it`s not...

So why not do this:
Make findByName look up the $ID with the query you already use, possibly
caching the other fields/data you use frequently in some kind of very temp
space: $row (array returned from query).
Then call CompanyMapper::find($ID, $row);
which uses the info it already has given for free in $row, but can also
check your cache of existing object, fill in any free data from $row, and
return the existing object if it's there.

> Unfortunately, we cannot afford to loose lazy load for those searching
> methods which use something different than ID. Our current solution is
> putting every ghost object inside handler object, because it allows us
> to switch object inside without rest of application noticing. This
> however requires many classes with nothing more than bunch of methods
> which transfer calls to another objects. We are working on piece of
> code, which will use Reflection to autogenerate these classes, but still
> it`s not very nice solution imho.

Perhaps a specialized object that manipulates/returns other objects based
on arguments is in order.  Instead of a zillion objects that all do that
same thing, only one for each real object, you have one that handles all
the other objects the same way, but trying to find the same object in your
cache first, then digging deeper into lazy load (or whatever) to build it.

How certain are you that all this code is saving you *ANYTHING*?

Is it worth the development/maintenance expense?

Only you can answer those questions.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



RE: [PHP] Creating intelligent forms

2005-04-13 Thread Mike
 
> The first idea I had was to make a function to display the 
> form.  When the form is submitted, the page would be called 
> again (i.e. the form's ACTION=itself), and then the POST or 
> GET or SESSION variables will be the arguments to the form.  
> The idea is, when this happens, the form will be able to 
> check the data that was sent, verify it, etc etc.  If there 
> are no problems with the data, then the user is directed to 
> step 2 of the form, or the second page, to enter in 
> additional data.  But how should the redirection happen?
> 
> At that point, am I able to manipulate the headers for a 
> different Location:, that location being the second form to 
> be filled out?  Since this would be the first data sent to 
> the BROWSER, I thought that this might work.

What I've done is just have one script (call it form.php) and when you
process the data it posts/gets to itself. The first thing you do is validate
the data. You then flag each piece that has a problem. If you have no
problems after you've parsed all the data, you can simply include the
"processing" code from another file and then run that (no redirection) and
output what you need to output. If there are problems, just re-run the
print-form portion of the script but output the fields with the
previously-submitted data and also some sort of visual marker for the user
to identify that there's a problem (such as red text saying "Please correct
this field" or something).

> I've been toying with both of these ideas with varying 
> success, but haven't quite gotten it figured out.  I'm sure 
> that, with due time, I'll be able to figure it out.  However, 
> I just want to make sure that this is a "correct" way of 
> writing forms, and if it's normally accepted as a common 
> practice, so I don't waste my time doing something that might 
> not actually work.

I've done the above with much success. And I prefer not to have to redirect
people all over the place if possible. There's truly many ways of doing it
and different ways may work best for your needs - but I wanted to share what
has worked for me in the past.

-M

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



[PHP] Creating intelligent forms

2005-04-13 Thread dan
Hello, all -
I had some questions regarding the creation of "intelligent" forms - 
forms that take data, and then parse it for errors, "real" data, etc etc.

The first idea I had was to make a function to display the form.  When 
the form is submitted, the page would be called again (i.e. the form's 
ACTION=itself), and then the POST or GET or SESSION variables will be 
the arguments to the form.  The idea is, when this happens, the form 
will be able to check the data that was sent, verify it, etc etc.  If 
there are no problems with the data, then the user is directed to step 2 
of the form, or the second page, to enter in additional data.  But how 
should the redirection happen?

At that point, am I able to manipulate the headers for a different 
Location:, that location being the second form to be filled out?  Since 
this would be the first data sent to the BROWSER, I thought that this 
might work.

I've been toying with both of these ideas with varying success, but 
haven't quite gotten it figured out.  I'm sure that, with due time, I'll 
be able to figure it out.  However, I just want to make sure that this 
is a "correct" way of writing forms, and if it's normally accepted as a 
common practice, so I don't waste my time doing something that might not 
actually work.

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


[PHP] app to create directories with a browser...

2005-04-13 Thread bruce
hi...

i'm trying to find an app to allow me to somehoe specify a dir/folder
structure and to be able to create the dir on the hard drive, using the
browser...

in other words, if i have a project:
   proj
 --include
 --docs
 --bin
 --src
 --obj

i'd like to be able to somehow enter this into a browser/app and have the
app then create the underlying structure on the harddrive...

anybody have any ideas/knowledge of such an app. i'd prefer it to be GUI is
possible, but i'll look at pretty much anything that works...

thanks

bruce
[EMAIL PROTECTED]

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



Re: [PHP] is fwrite atomic?

2005-04-13 Thread Rasmus Lerdorf
Cabbar Duzayak wrote:
As the subject mentions, is fwrite method atomic in PHP? What I mean
by that is, does fwrite function acquire an implicit lock while
writing or do I need to explicitly acquire an EXCLUSIVE lock on the
file before I call fwrite?
That depends on your mode.  If you opened the file in append mode, then 
yes, it is atomic.  On some operating systems that may or may not be 
true over network filesystems like NFS if you are writing more than a 
block size, but if it is a local fs and you are in append mode, you can 
count on it being atomic.  If you are not in append mode, then it is not 
atomic at all.

The problem I am having is that, I want to track user requests by
logging simple request parameters such as user IP, request URI, etc.
instead of inserting into the db for avoiding overheads. And I will
have a cronjob read this data around midnight and write it into the
database (when there is little load on the server).
For straight logging like this you should be able to simply append to 
the log file and thus your fwrite will be atomic.

2. While I am inserting this data into the database, I will have to
lock the file, dump them into the database and empty it. So, this
might make some users wait, which is something I am trying to avoid.
But, in anycase I will need to have a secondary lock object which
controls access to this log I guess, i.e. acquire secondary lock,
rename the file to .tmp or something, release the lock, and in the
meantime read from .tmp, parse it and put it in the db.
Have your cronjob rename the file to a temporary filename which is also 
an atomic operation.  Then read that temp file into your database.  The 
only slight wrinkle here is that a process could be writing to the file 
as you rename it.  This in itself is fine.  The write will survive the 
rename and still complete writing to your renamed file since at that 
level it is simply an open file descriptor and it doesn't care what its 
name is.  To make sure any outstanding writes complete, simply add a 
little delay between your rename and your read in your cron job.

The next log write that comes in after the rename will automatically 
recreate the file since you are opening it in create+append mode.

This way you avoid all locking and your application will actually work. 
 Locks are evil!

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


Re: [PHP] image calculation problem

2005-04-13 Thread Ryan A
Thanks mate, it works perfectly.
-Ryan



On 4/13/2005 11:35:23 PM, Philip Hallstrom ([EMAIL PROTECTED]) wrote:
> see below...
>
>
>
> > Basically I am trying to make a thumb where the width is 87px...I dont
>
> > care what the height is, heres the code:
>
> >
>
> > function prop_thumb_height()
>
> > {
>
> > // The file
>
> > $filename = 'cat.jpg';
>
> >
>
> > // Content type
>
> > header('Content-type: image/jpeg');
>
> >
>
> > // Get new dimensions
>
> > list($width_orig, $height_orig) = getimagesize($filename);
>
> >
>
>
>
> $width = 87;
>
>
>
> // note
> I'm not checking if $width_orig == 0
> $scale_by = $width / $width_orig;
>
> $height = floor($height_orig * $scale_by + 0.5);
>
> > // Resample
> > $image_p = imagecreatetruecolor($width, $height);
> > $image = imagecreatefromjpeg($filename);
> > imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height,
$width_orig, $height_orig);
> >
> > // Output
> > imagejpeg($image_p, 'ryan.
> jpg', 100);
> > }
> >



-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.9.7 - Release Date: 4/12/2005

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



Re: [PHP] image calculation problem

2005-04-13 Thread Philip Hallstrom
see below...
Basically I am trying to make a thumb where the width is 87px...I dont 
care what the height is, heres the code:

function prop_thumb_height()
{
// The file
$filename = 'cat.jpg';
// Content type
header('Content-type: image/jpeg');
// Get new dimensions
list($width_orig, $height_orig) = getimagesize($filename);
$width = 87;
// note I'm not checking if $width_orig == 0
$scale_by = $width / $width_orig;
$height = floor($height_orig * $scale_by + 0.5);
// Resample
$image_p = imagecreatetruecolor($width, $height);
$image = imagecreatefromjpeg($filename);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, 
$height_orig);
// Output
imagejpeg($image_p, 'ryan.jpg', 100);
}
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] image calculation problem

2005-04-13 Thread Ryan A
Hi,
I copied this from the php site, but trying to modify it is driving me nuts
coz its not working.

Basically I am trying to make a thumb where the width is 87px...I dont care
what the height is,
heres the code:

function prop_thumb_height()
{
// The file
$filename = 'cat.jpg';

// Set a maximum height and width
$width = 87;
$height = 175;

// Content type
header('Content-type: image/jpeg');

// Get new dimensions
list($width_orig, $height_orig) = getimagesize($filename);

if ($width && ($width_orig < $height_orig)) {
   $width = ($height / $height_orig) * $width_orig;
} else {
   $height = ($width / $width_orig) * $height_orig;
}

// Resample
$image_p = imagecreatetruecolor($width, $height);
$image = imagecreatefromjpeg($filename);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height,
$width_orig, $height_orig);

// Output
imagejpeg($image_p, 'ryan.jpg', 100);
}



Thanks,
Ryan



-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.9.7 - Release Date: 4/12/2005

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



Re: [PHP] is fwrite atomic?

2005-04-13 Thread Philip Hallstrom
As the subject mentions, is fwrite method atomic in PHP? What I mean
by that is, does fwrite function acquire an implicit lock while
writing or do I need to explicitly acquire an EXCLUSIVE lock on the
file before I call fwrite?
While I haven't checked, I would imagine the answer is NO.
The problem I am having is that, I want to track user requests by
logging simple request parameters such as user IP, request URI, etc.
instead of inserting into the db for avoiding overheads. And I will
have a cronjob read this data around midnight and write it into the
database (when there is little load on the server).
So, the questions I have is:
1. While writing this information, do I need to get an exclusive lock
before writing? Say I have a 200 bytes string, and 2 people call
fwrite at the same time with 2 strings, will they be written
sequentually or will it mix these strings depending on the O/S IO
buffer size.
I certainly would.  I don't know how the data will get written out in 
simultaneous writes.  I would guess it involves filesystem options, what 
OS, kernel buffers, etc...

Just create a "data.lock" file, open that, flock it, do your write, and 
close everything.

2. While I am inserting this data into the database, I will have to
lock the file, dump them into the database and empty it. So, this
might make some users wait, which is something I am trying to avoid.
But, in anycase I will need to have a secondary lock object which
controls access to this log I guess, i.e. acquire secondary lock,
rename the file to .tmp or something, release the lock, and in the
meantime read from .tmp, parse it and put it in the db.
I'd lock your data.lock file, move your actual data file, create an empty 
new data file, remove the lock, then process your local copy.

You might also consider using syslog to send things there, but that might 
be more messy then it's worth...

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


[PHP] enterprise patterns headache

2005-04-13 Thread Robert Janeczek
Hi!
I`m currently working on PHP5-based extranet system which makes
intensive use of enterprise patterns. Some problems encountered during
developement cause serious haeadaches, but we`re going forward :)
I`m not 100% happy with architecture decisions we`ve made in the process
and therefore I came here to ask if maybe someone has better ideas than
we did.
Whole system is built on Data Mapper + Unit of Work + Identity Map +
Lazy Load base. Everything worked well until we started testing if lazy
loading is as lazy as it is supposed to be. We've used __set and __get
magic methods to automate loading data to ghost object when something
tried to access data inside. Yesterday was magic-methods-removal-day,
because we realized post-factum that using magic method sets a flag
blocking usage of another magic methods within that call. With high
encapsulation we were screwed - there was no way to assure not having
chained magic method calls (which still was far from being infinite
recurrency). __get returning null in such situations without any warning
caused many acts of disbelief in power of debugger among the developers
:] Yes, I know it`s all in comments to manual page. NOW I know that :]
Back to the architecture problem...
Inside mappers we have standard find($ID) methods returning ghosts of
real objects, which are filled at later time. Currently this mechanism
is implemented almost exacly as in Martin Fowler's sample code - by
adding notifyRead/notifyWrite in first line of public setters and
getters. This works nicely, collections of object also don`t cause
problems because they are not instantiated before we really need the
elements.
We also use separate methods for finding objects using criteria
different than just ID in database. So, some objects have
findByName($name) or findActive() methods which work very similiar to
find($ID) method, but use different queries. The problem with this
methods is the same thing which helps us very much in different parts of
application - Lazy Load.
Sample code:
$company = CompanyMapper::find(1); // we have ghost inside $company
//some other operations, but we don`t touch $company
$company2 = CompanyMapper::findByName('Big Ltd.');
Now let`s assume, that company with ID=1 has name Big Ltd. We have two
independent copies of the same object what kinda sucks :] The problem is
that both finding methods return ghosts and the second one doesn`t know
his ID yet. If there would be only ID-based searching than Identity Map
would detect it and caused returning the same instance, but it`s not...
Unfortunately, we cannot afford to loose lazy load for those searching
methods which use something different than ID. Our current solution is
putting every ghost object inside handler object, because it allows us
to switch object inside without rest of application noticing. This
however requires many classes with nothing more than bunch of methods
which transfer calls to another objects. We are working on piece of
code, which will use Reflection to autogenerate these classes, but still
it`s not very nice solution imho.
Long story short - what`s the best way to be able to load business
objects as ghosts using different criteria without problem with multiple
instances of the same object in the application.
rashid
ps. wow.. that was looong... :D
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] is fwrite atomic?

2005-04-13 Thread Cabbar Duzayak
Hi,

As the subject mentions, is fwrite method atomic in PHP? What I mean
by that is, does fwrite function acquire an implicit lock while
writing or do I need to explicitly acquire an EXCLUSIVE lock on the
file before I call fwrite?

The problem I am having is that, I want to track user requests by
logging simple request parameters such as user IP, request URI, etc.
instead of inserting into the db for avoiding overheads. And I will
have a cronjob read this data around midnight and write it into the
database (when there is little load on the server).

So, the questions I have is:

1. While writing this information, do I need to get an exclusive lock
before writing? Say I have a 200 bytes string, and 2 people call
fwrite at the same time with 2 strings, will they be written
sequentually or will it mix these strings depending on the O/S IO
buffer size.

2. While I am inserting this data into the database, I will have to
lock the file, dump them into the database and empty it. So, this
might make some users wait, which is something I am trying to avoid.
But, in anycase I will need to have a secondary lock object which
controls access to this log I guess, i.e. acquire secondary lock,
rename the file to .tmp or something, release the lock, and in the
meantime read from .tmp, parse it and put it in the db.

Any ideas?

Thanks...

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



Re: [PHP] Re: User Management

2005-04-13 Thread Eugene Voznesensky
Yoy can try this one:
http://pear.php.net/package/LiveUser

> > Hi!
> >
> > I am developing an applicaton in PHP where
> different users would have 
> > different permissions and access to different
> functions/pages of website. 
> > Now whats the best way to do tht?
> >
> > One way I can think of is keep all permissions in
> a table and divide 
> > everyting on site into functions..and when every
> function is called, check 
> > whether thecurrent user has permission to
> particular function..
> >
> > But this method looks quiet complicated..is ther
> any other way to do this?
> >
> > Also if you can give me some links to
> articles/tutorials on user/levels 
> > management in PHP, it would be really helpful..
> >
> > Thanks in advance 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 

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



Re: [PHP] uploading file

2005-04-13 Thread Greg Donald
On 4/13/05, Joseph Connolly <[EMAIL PROTECTED]> wrote:
> I though you could limit it in the php.ini file.

You can.

> OR, you can determine
> it's length through php and then discard it.

You can.

> I remember reading
> something about limiting file size and overidding that limit in the
> script. If i find it i will post it here.

You can, but any settings you put in place will not take effect until
PHP gets the file.  PHP has no clue what is going on on the client
side so until the file is uploaded to the server it can't act on the
file one way or the other.  PHP is a server-side scripting language
not a client-side scripting language.


-- 
Greg Donald
Zend Certified Engineer
http://destiney.com/

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



Re: [PHP] uploading file

2005-04-13 Thread Joseph Connolly
Thanks for the info. That makes sense.
John Nichel wrote:
Joseph Connolly wrote:
I though you could limit it in the php.ini file. OR, you can 
determine it's length through php and then discard it. I remember 
reading something about limiting file size and overidding that limit 
in the script. If i find it i will post it here.

You can limit it with PHP.  However, for php to determine the filesize 
and check it against the limit, the file has to be uploaded first, ie 
on the server.  The OP wants to check the filesize while it's still on 
the client machine, and PHP can't do that.

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


Re: [PHP] database querying form in php

2005-04-13 Thread Marek Kilimajer
babu wrote:
HI,
I ilke to create user interface for a group of people for entering the queries and to see the results in a browser. The users have the knowledge of database. 
for example: the users will have a login check, and if successful they will see a window where they can enter the sql queries and can see the results.I also want to implement a history of queries where the user can use it when ever needed.
i have done the user authentication part. But i do not get an idea how the User interface can be?
I have seen PhpMyadmin.its nice , but lillte bit complex for me as i also need some code to know how it implemented.
can some one please point to some examples or so.
There are plenty of classes that can show results of queries in html 
table, just go to www.phpclasses.org

You should create a database user for each user and restrict the access 
for each user individualy to insert, select, delete etc.

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


[PHP] Re: php SMPP

2005-04-13 Thread Catalin Trifu
Hi,

   If you are into C programming try kannel (www.kannel.org); they fully 
implement
SMPP protocol into their gateway, so you could take a look at their code.

Catalin


Kyriacos Sakkas wrote:
> Hi all,
>   Just wondering if anybody has had experience using SMPP with php. I
> have used the one available class that has limited functionality for
> sending simple messages, but would like to do a little bit more
> (concatenated messages over 170 chars.).
>   Ipworks has some libraries, but I have not been able to compile the php
> side of them (keep getting compilation errors for on file), so now I am
> stuck.
>   Any pointers to existing scripts, or advice on how to create SMPP pdu's
> manually will be very appreciated.
>   
> thanks
>   Kyriacos

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



[PHP] Re: database querying form in php

2005-04-13 Thread Satyam
The following used to work, though I haven't used it for a while.  Please be 
carefull of who are you letting do what.  A little checking, for example, 
only 'select' statements with no semi-colons or any other trick to modify 
the database might be good.  Assumes there is a style sheet with a class 
'Listado' somewhere.

Satyam



$result = mysql_query($_REQUEST['Query']) or die("Query failed : " . 
mysql_error());
echo "" . $_REQUEST['Query'] . "";
/* Printing results in HTML */

echo "\n";

echo "\t\n";

for ($i=0;$i < mysql_num_fields($result);$i++) {
echo "\t\t" . mysql_field_name($result,$i) . "\n"  ;
}

echo "\t\n";

while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
   echo "\t\n";
   foreach ($line as $col_value) {
   echo "\t\t$col_value\n";
   }
   echo "\t\n";
}
echo "\n";

/* Free resultset */
mysql_free_result($result);

"Babu" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> HI,
>
> I ilke to create user interface for a group of people for entering the 
> queries and to see the results in a browser. The users have the knowledge 
> of database.
> for example: the users will have a login check, and if successful they 
> will see a window where they can enter the sql queries and can see the 
> results.I also want to implement a history of queries where the user can 
> use it when ever needed.
> i have done the user authentication part. But i do not get an idea how the 
> User interface can be?
> I have seen PhpMyadmin.its nice , but lillte bit complex for me as i also 
> need some code to know how it implemented.
> can some one please point to some examples or so.
>
> Thanks
> babu
>
>
> Send instant messages to your online friends http://uk.messenger.yahoo.com 

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



[PHP] Hosting - NoMonthlyFees

2005-04-13 Thread Miles Thompson
NoMonthlyFees has been spoken of highly on this list in the past.
Do they still have a good reputation? How's speed?
Client will be fetching news stores for display through Flash; MySQL and 
PHP (of course) back end.
May be some streaming audio in future.

If you don't want to clog the list with traffic, reply privately and I'll 
post a summary.

Tks in advance - Miles Thompson
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] uploading file

2005-04-13 Thread John Nichel
Joseph Connolly wrote:
I though you could limit it in the php.ini file. OR, you can determine 
it's length through php and then discard it. I remember reading 
something about limiting file size and overidding that limit in the 
script. If i find it i will post it here.
You can limit it with PHP.  However, for php to determine the filesize 
and check it against the limit, the file has to be uploaded first, ie on 
the server.  The OP wants to check the filesize while it's still on the 
client machine, and PHP can't do that.

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re[2]: [PHP] uploading file

2005-04-13 Thread Richard Davey
Hello Joseph,

Wednesday, April 13, 2005, 5:42:42 PM, you wrote:

JC> I though you could limit it in the php.ini file. OR, you can
JC> determine it's length through php and then discard it. I remember
JC> reading something about limiting file size and overidding that
JC> limit in the script. If i find it i will post it here.

Sure, you can discard the file if it's over the file size limit - but
ONLY after it has been uploaded, which is what the original poster
wanted to avoid. PHP, being server-side in nature, doesn't make this
possible.

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 "I do not fear computers. I fear the lack of them." - Isaac Asimov

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



Re: [PHP] uploading file

2005-04-13 Thread Joseph Connolly
I though you could limit it in the php.ini file. OR, you can determine 
it's length through php and then discard it. I remember reading 
something about limiting file size and overidding that limit in the 
script. If i find it i will post it here.

Richard Davey wrote:
Hello Marc,
Wednesday, April 13, 2005, 3:08:06 PM, you wrote:
ms> Hi, i want to create a form to upload a file on a server. My
ms> problem is that i want to check the filesize before sending it
ms> because if the filesize is superior than 2 MB it failed and i
ms> don't want to wait for a long time for uploading a file that will
ms> fail.
This isn't possible with PHP alone. You could do it by using some kind
of client-side uploader (Java applet, maybe a JavaScript post-back,
etc), but not PHP by itself.
Best regards,
Richard Davey
 

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


Re: [PHP] uploading file

2005-04-13 Thread Richard Davey
Hello Marc,

Wednesday, April 13, 2005, 3:08:06 PM, you wrote:

ms> Hi, i want to create a form to upload a file on a server. My
ms> problem is that i want to check the filesize before sending it
ms> because if the filesize is superior than 2 MB it failed and i
ms> don't want to wait for a long time for uploading a file that will
ms> fail.

This isn't possible with PHP alone. You could do it by using some kind
of client-side uploader (Java applet, maybe a JavaScript post-back,
etc), but not PHP by itself.

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 "I do not fear computers. I fear the lack of them." - Isaac Asimov

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



[PHP] uploading file

2005-04-13 Thread marc serra
Hi, i want to create a form to upload a file on a server. My problem is 
that i want to check the filesize before sending it because if the 
filesize is superior than 2 MB it failed and i don't want to wait for a 
long time for uploading a file that will fail.

Can you please give me a solution to check the filesize.
Marc.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: uploading files

2005-04-13 Thread Matthew Weier O'Phinney
* Marc Serra <[EMAIL PROTECTED]>:
> Hi, i want to create a form to upload a file on a server. My problem is 
> that i want to check the filesize before sending it because if the 
> filesize is superior than 2 MB it failed and i don't want to wait for a 
> long time for uploading a file that will fail.
>
> Can you please give me a solution to check the filesize.

See:
http://php.net/features.file-upload

Basically, you need a MAX_FILE_SIZE hidden attribute in your form:


However, the manual goes on to say:

 The MAX_FILE_SIZE hidden field (measured in bytes) must precede the
 file input field, and its value is the maximum filesize accepted. This
 is an advisory to the browser, PHP also checks it. Fooling this setting
 on the browser side is quite easy, so never rely on files with a
 greater size being blocked by this feature. The PHP settings for
 maximum-size, however, cannot be fooled. This form element should
 always be used as it saves users the trouble of waiting for a big file
 being transferred only to find that it was too big and the transfer
 failed.

So, adding the above input field is a good first step, but it's not
foolproof; you may still get some too large files uploaded that PHP will
reject after the fact.

-- 
Matthew Weier O'Phinney   | WEBSITES:
Webmaster and IT Specialist   | http://www.garden.org
National Gardening Association| http://www.kidsgardening.com
802-863-5251 x156 | http://nationalgardenmonth.org
mailto:[EMAIL PROTECTED] | http://vermontbotanical.org

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



Re: [PHP] PHP 4 to PHP 5 Migration shortcut

2005-04-13 Thread Rasmus Lerdorf
Vishal Kashyap @ [SaiHertz] wrote:
Dear PHP enlightened ,
I was planning to move my PHP 4.3.x based product t PHP 5.x and for
this I was looking for some kinda shortcut scripts or utility to
migrate the 4.3.x file to PHP 5.x .
Any pointers would be appreaciated.
Chances are pretty good that you won't have to change anything.  Step 1 
would be to simply try running your existing code under PHP5 and see 
what breaks.  Unless you have complicated OO code or you are using the 
domxml extension, you likely won't need to change anything.

For more info, read: http://php.net/migration5
-Rasmus
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] phpmyadmin blank screen.

2005-04-13 Thread Joseph Connolly
1- are you loading the mssql extensions or the mysql extensionsyou 
keep interchanging the two and they ARE NOT the same
2- in addition you may have to load the mysqli extension if you want to 
run phpMyAdmin.
3- re read the php manual and the phpMyAdmin

If the screen is blank trying to read the source code to see if there is 
anything at all there. Then make sure php is running correctly and your 
databases are running correctly...i have a feeling one or both might not 
be. THEN, you have to make sure your extensions are compatible with the 
new password authenticaiton method begin used by phpMyAdmin. (this is 
where mysqli come into play).
Ross wrote:

Thanks for the replies to my php_mssql problem.
I have a problem that when I try and run phpmyadmin locally the screen is 
just blank. Any ideas?

R.
 

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


[PHP] phpmyadmin blank screen.

2005-04-13 Thread Ross
Thanks for the replies to my php_mssql problem.

I have a problem that when I try and run phpmyadmin locally the screen is 
just blank. Any ideas?

R.

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



Re: [PHP] trying to load mysql extensions

2005-04-13 Thread Richard Davey
Hello Ross,

Wednesday, April 13, 2005, 4:16:07 PM, you wrote:

R> I get the following warning when trying to load this extension.
R> (php_mssql)

R> PHP Warning: PHP Startup: Unable to load dynamic library
R> 'c:\PHP\ext\php_msql.dll'

Well which of the two DLLs do you actually want to use? php_mssql.dll
is NOT the same as php_msql.dll

R> I am runnning php5 with IIS 5.1 and mysqlserver 4.1. The server
R> works fine and mysql server is running ok.

More to the point NEITHER of them are used for MySQL! They're for
Microsoft SQL Server. PHP5 + MySQL 4.1 should be using the
php_mysqli.dll ideally.

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 "I do not fear computers. I fear the lack of them." - Isaac Asimov

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



[PHP] uploading files

2005-04-13 Thread marc serra
Hi, i want to create a form to upload a file on a server. My problem is 
that i want to check the filesize before sending it because if the 
filesize is superior than 2 MB it failed and i don't want to wait for a 
long time for uploading a file that will fail.

Can you please give me a solution to check the filesize.
Marc.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] User Management

2005-04-13 Thread aznFETISH
I use something like this the numbers 1,2,3,4 are an array of member group 
ID's so it checks the users session to see if they are a member to one of 
those groups

$_product_id = array(1,2,3,4);
require_once("/home/blah/public_html/members/plugins/protect/php_include/check.inc.php");

<[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
>
>
> use an include file at the top of each page.
> in this include file you will check to see whether that user has access
> to see that page, if they dont then just redirect to the main menu page
> or an error page.
>
> hope this helps
>
> Angelo Zanetti
> Z Logic
>
> www.zlogic.co.za
>
> 
> This message was sent using IMP, the Internet Messaging Program. 

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



[PHP] database querying form in php

2005-04-13 Thread babu
HI,

I ilke to create user interface for a group of people for entering the queries 
and to see the results in a browser. The users have the knowledge of database. 
for example: the users will have a login check, and if successful they will see 
a window where they can enter the sql queries and can see the results.I also 
want to implement a history of queries where the user can use it when ever 
needed.
i have done the user authentication part. But i do not get an idea how the User 
interface can be?
I have seen PhpMyadmin.its nice , but lillte bit complex for me as i also need 
some code to know how it implemented.
can some one please point to some examples or so.

Thanks
babu


Send instant messages to your online friends http://uk.messenger.yahoo.com 

Re: [PHP] trying to load mysql extensions

2005-04-13 Thread Greg Donald
On 4/13/05, Ross <[EMAIL PROTECTED]> wrote:
> I get the following warning when trying to load this extension. (php_mssql)
> 
> PHP Warning: PHP Startup: Unable to load dynamic library
> 'c:\PHP\ext\php_msql.dll'
> 
> (All the other extensions load ok.)
> 
> I am runnning php5 with IIS 5.1 and mysqlserver 4.1. The server works fine
> and mysql server is running ok.


Check your php.ini and make sure c:\PHP\ext is included in your
extension_dir paths.


-- 
Greg Donald
Zend Certified Engineer
http://destiney.com/

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



[PHP] PHP 4 to PHP 5 Migration shortcut

2005-04-13 Thread Vishal Kashyap @ [SaiHertz]
Dear PHP enlightened ,

I was planning to move my PHP 4.3.x based product t PHP 5.x and for
this I was looking for some kinda shortcut scripts or utility to
migrate the 4.3.x file to PHP 5.x .
Any pointers would be appreaciated.

-- 
With Best Regards,
Vishal Kashyap.
Lead Software Developer,
http://saihertz.com,
http://vishalkashyap.tk

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



[PHP] trying to load mysql extensions

2005-04-13 Thread Ross
I get the following warning when trying to load this extension. (php_mssql)


PHP Warning: PHP Startup: Unable to load dynamic library 
'c:\PHP\ext\php_msql.dll'

(All the other extensions load ok.)


I am runnning php5 with IIS 5.1 and mysqlserver 4.1. The server works fine 
and mysql server is running ok.

Ross 

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



[PHP] Re: User Management

2005-04-13 Thread chris
Use an $_SESSION array variable to contain the pages they can access.

"Dasmeet Singh" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Hi!
>
> I am developing an applicaton in PHP where different users would have 
> different permissions and access to different functions/pages of website. 
> Now whats the best way to do tht?
>
> One way I can think of is keep all permissions in a table and divide 
> everyting on site into functions..and when every function is called, check 
> whether thecurrent user has permission to particular function..
>
> But this method looks quiet complicated..is ther any other way to do this?
>
> Also if you can give me some links to articles/tutorials on user/levels 
> management in PHP, it would be really helpful..
>
> Thanks in advance 

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



[PHP] Re: [NOVICE] error handling

2005-04-13 Thread John DeSoi
On Apr 13, 2005, at 1:46 AM, Cima wrote:
im working with php 4 and postgresql 8 and i would like to know how to
handle certain errors generated. in postgresql,  i've written a stored
function that selects a record from a table and in case no record is 
found i
'raise an exception'. fine, now in my php script  i call that the 
stored
function which works properly when there is a record but when the 
record
doesnt exist, i would like to be able to place my own error message 
and not
e.g  'fatal error, .'. how do i capture(in php)  the exception i 
raised
in postgres so that i know the record doesnt exist?

You don't say what php library you are using, but perhaps this is what 
you need:

http://www.php.net/manual/en/function.pg-result-error.php
The only problem with using raise exception for this is that I don't 
think there is a way for you to assign an error code so you end up 
parsing a string. This is bad if you want to work in multiple 
languages. If PostgreSQL is going to generate an error anyway, you 
might want to let it do that since it should return an error code. See 
also

http://www.php.net/manual/en/function.pg-result-error-field.php
John DeSoi, Ph.D.
http://pgedit.com/
Power Tools for PostgreSQL
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: scripting workflow

2005-04-13 Thread chris
I hand code everything I do in php. I separate functions and class in 
referenced files that are grouped by function in the site(i.e. - all queries 
are in queries.php, the db connection is done in dbconn.php, etc...). This 
will allow a project to grow without having to rewrite everything. Also 
debugging is easy. If you know a query is failing, open the queries.php 
file.

The structure I use is to build the entire page as a variable, usually 
called $page, that I print after it has been completed. So from the html 
doctype tag to the closing html tag I simply append to one variable and 
print.

CJ


"DuSTiN KRySaK" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
>I just have a few questions regarding workflow when producing scripts.
>
> First off, do people prefer to have all their code in one file? Or 
> multiple separate files? I know functions and classes are good to keep in 
> separate files, but i am talking about say for example a news system, etc.
>
> Next off, how about when actually assembling the files? Do you produce all 
> of your html output, then say build all of your functions - then say build 
> the logic?
>
> Does that make sense?
>
> I had in the past use DW for building php apps, and as an exercise to 
> myself I am forcing myself to hand code to learn better. But I do however 
> want to increase my productivity.
>
> If anyone has any pointers on this type of stuff - it would be much 
> appreciated!
>
> Thanks!
>
> d 

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



[PHP] Re: HELP! HELP !

2005-04-13 Thread chris
Read in the manual about the $_GET variable

"Justin Joe" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
>
>
>
>
> HI,
>
> Any body give me any hinder I would be very appreciated!
>
> I want to use a parameter of the second page in the first page, how can I
> realize it.
>
> For example, there is a segment in the first page:
>
> "
>
>  com href='/cgi-bin/english/E_new_domain_list.cgi?domainType=1'> $num_com;?>
>
>   $buy_com_num;?>
>
> "
>
> But I want to use the parameter  "$result_id" which in the second
> page(autorenew.php) :
>
>  "switch($result_id){
>
>  case "1" :
>
>   ;
>
>   Break;
>
> case "2" :
>
>   ;
>
>   Break;
>
> Can the parameter "$result_id" pass from the second page(autorennew.php) 
> to
> the first page?
>
> Sincerely yours,
>
> justin
>
> E-mail/MSN: [EMAIL PROTECTED]
>
>
>
> 

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



[PHP] OT - Blank subject lines!!!

2005-04-13 Thread Miles Thompson
I assume others are seeing these as well - infrequent postings with blank 
subject lines. Always throws me for a bit of a loop, forcing a "pause and 
adjust".

For those replying to them, or hijacking them, please stop.
Regards - Miles Thompson
PS Truly Canadian - note the "please"! /mt
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Selectively Extract Sub-Array from an Array

2005-04-13 Thread Tom Rawson
On PHP 4.3.x ... (not using PHP 5)

Say I have two arrays, the first has keys 'key1' ... 'key20'.  The 
second has some other keys with different names (i.e. they do not 
overlap those in the first array).  I want to add certain elements from 
array1 to array2.  I can do it like this:

$array2['key3'] = $array1['key3'];
$array2['key8'] = $array1['key8'];
$array2['key17'] = $array1['key17'];

or like this:

$array2 += array('key3' => $array1['key3'], 'key8' => $array1['key8'],
'key17' => $array1['key17']);

What would be nicer is something like:

$array2 += array_select($array1, 'key3', 'key8', 'key17');

In other words ... a way to create an array that is a selected subset 
of another.

Is there a function that does this that I'm missing?  I realize I could 
write one but I was looking for something built-in.  Nothing I can see 
under array functions in the manual seems to do it.

Thanks,

--
Tom

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



Re: [PHP] Drop down list - persistant value

2005-04-13 Thread Peter H. Lemieux
I use a function to create select boxes:
function make_select($fieldname,$options,$selected,$opt="") {
# make a select box with option text $opt
# $fieldname = name of html field
# $options = associative array of select options
# $selected = field key of selected item
# $opt = optional attributes, e.g., styles, etc.
$output.="\n";
foreach ($options as $key=>$val) {
$output.="\n
$output.="\n\n";
return $output;
}
By passing the previously selected item as $selected it will 
automatically reselect the chosen item.  For instance,


I've written similar functions for check boxes and radio buttons. 
They've made form creation and handling enormously easier.

Peter
Jacques wrote:
I am using PHP. I have a registration page where the user has to select his 
country form a drop down list. If the username that the user selected for 
himself exists in the database I am sending him back to the registration 
form with all the fields completed with the values he previously entered. 
This is easy to do for a textfield but how do I indicate on the drop down 
list which country he originally selected?

Please help.
Jacques 

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


Re: [PHP] Re: Index of /base-1.1

2005-04-13 Thread Mark Sargent
David Robley wrote:
Mark Sargent wrote:
 

Hi All,
typing localhost/bse-1.1 gives me access, but, in this format,
Index of /base-1.1
Icon  Name Last
modified   Size
  Description


[DIR] Parent Directory 
-   [DIR] admin/ 
04-Apr-2005 05:27-   [   ] base_ag_common.php
  04-Apr-2005 05:26 
3.5K

a listing of the dir, which, I guess, is not too good. What have I done
wrong here..?
   

Forgotten to add appropriate information for DirectoryIndex in your Apache
configuration maybe?
David
 

Hi All,
thanx, David, will check tomorrow at work. Cheers.
Mark Sargent.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] User Management

2005-04-13 Thread Dasmeet Singh
Thanks I checked fusebox.. its really nice and interesting.. Still I 
wasnt able to find anything related to managing users on its site..

or I have to seperately built a user authentication system?
Stephen March wrote:
This is one of the many reasons I've been using Fusebox for the past few
years.  http://www.fusebox.org
It's an open sourced framework that provides you with an interesting way to
do includes, to break your application out into MVC (Model View Controller)
and allows you to provide a better granular security. You then control the
users permissions to a series of circuits and fuses (much like folders and
functions) - rather than to specific code pages.
For my purposes I find it more beneficial to diagram out my UML Use Cases (A
user will do 'x', whereas an administrator will do 'y').  Eventually you
will need a mechanism to store that information - whether it be a MySQL
table or a directory server accessible via LDAP.
I generally try to develop a table for roles (or groups), for users,
permissions.  Assign the permissions to the roles, and assign a user to
role.
I haven't found an "easy" solution per-se, but this is effective for me.
Cheers,
~Stephen March, CIS, BSc

-Original Message-
From: Dasmeet Singh [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, April 13, 2005 4:15 AM
To: php-general@lists.php.net; [EMAIL PROTECTED]
Subject: Re: [PHP] User Management

Thanks..
And how to manage user and their permissions.. should I store each page 
name in a table and then store permissions of each and every user to 
individual pages in another table?

Is there any other way to do this?
[EMAIL PROTECTED] wrote:

use an include file at the top of each page.
in this include file you will check to see whether that user has access 
to see that page, if they dont then just redirect to the main menu page 
or an error page.

hope this helps
Angelo Zanetti
Z Logic
www.zlogic.co.za

This message was sent using IMP, the Internet Messaging Program.

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


Re: [PHP] User Management

2005-04-13 Thread Satyam
One of the most flexible ways to do this is to have one table with each user 
information, then a table of groups and group members.  Users, per se, don't 
have permissions, they acquire them from the groups they belong to, it is 
easier that way than to assign permissions to each individual user, you just 
have a group of, say, administrators, receptionists, cashiers, purchasing, 
whatever and then assign people to one or more groups.

Then, you can have a third level which allows you to assign permissions to 
each group.  As I said, you may have this level or not.

Then, in each page you can say which group can use it (if you didn't use the 
third level) or which permission is required to see it.

Satyam


"Dasmeet Singh" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Thanks..
>
> And how to manage user and their permissions.. should I store each page 
> name in a table and then store permissions of each and every user to 
> individual pages in another table?
>
> Is there any other way to do this?
>
>
> [EMAIL PROTECTED] wrote:
>
>>
>> use an include file at the top of each page.
>> in this include file you will check to see whether that user has access 
>> to see that page, if they dont then just redirect to the main menu page 
>> or an error page.
>>
>> hope this helps
>>
>> Angelo Zanetti
>> Z Logic
>>
>> www.zlogic.co.za
>>
>> 
>> This message was sent using IMP, the Internet Messaging Program. 

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



RE: [PHP] User Management

2005-04-13 Thread Stephen March
This is one of the many reasons I've been using Fusebox for the past few
years.  http://www.fusebox.org

It's an open sourced framework that provides you with an interesting way to
do includes, to break your application out into MVC (Model View Controller)
and allows you to provide a better granular security. You then control the
users permissions to a series of circuits and fuses (much like folders and
functions) - rather than to specific code pages.

For my purposes I find it more beneficial to diagram out my UML Use Cases (A
user will do 'x', whereas an administrator will do 'y').  Eventually you
will need a mechanism to store that information - whether it be a MySQL
table or a directory server accessible via LDAP.

I generally try to develop a table for roles (or groups), for users,
permissions.  Assign the permissions to the roles, and assign a user to
role.

I haven't found an "easy" solution per-se, but this is effective for me.

Cheers,
~Stephen March, CIS, BSc



-Original Message-
From: Dasmeet Singh [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, April 13, 2005 4:15 AM
To: php-general@lists.php.net; [EMAIL PROTECTED]
Subject: Re: [PHP] User Management

Thanks..

And how to manage user and their permissions.. should I store each page 
name in a table and then store permissions of each and every user to 
individual pages in another table?

Is there any other way to do this?


[EMAIL PROTECTED] wrote:

> 
> use an include file at the top of each page.
> in this include file you will check to see whether that user has access 
> to see that page, if they dont then just redirect to the main menu page 
> or an error page.
> 
> hope this helps
> 
> Angelo Zanetti
> Z Logic
> 
> www.zlogic.co.za
> 
> 
> This message was sent using IMP, the Internet Messaging Program.

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

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



Re: [PHP] User Management

2005-04-13 Thread Dasmeet Singh
Thanks..
And how to manage user and their permissions.. should I store each page 
name in a table and then store permissions of each and every user to 
individual pages in another table?

Is there any other way to do this?
[EMAIL PROTECTED] wrote:
use an include file at the top of each page.
in this include file you will check to see whether that user has access 
to see that page, if they dont then just redirect to the main menu page 
or an error page.

hope this helps
Angelo Zanetti
Z Logic
www.zlogic.co.za

This message was sent using IMP, the Internet Messaging Program.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: Index of /base-1.1

2005-04-13 Thread David Robley
Mark Sargent wrote:

> Hi All,
> 
> typing localhost/bse-1.1 gives me access, but, in this format,
> 
> 
>  Index of /base-1.1
> 
> Icon  Name Last
> modified   Size
>   Description
> 
> 
> [DIR] Parent Directory 
> -   [DIR] admin/ 
> 04-Apr-2005 05:27-   [   ] base_ag_common.php
>   04-Apr-2005 05:26 
> 3.5K
>  
> a listing of the dir, which, I guess, is not too good. What have I done
> wrong here..?

Forgotten to add appropriate information for DirectoryIndex in your Apache
configuration maybe?


David

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



Re: [PHP] collect2: ld returned 1 exit status, make: *** [sapi/cli/php] Error 1

2005-04-13 Thread Marek Kilimajer
Mark Sargent wrote:
Mark Sargent wrote:
Hi All,
keep getting this error with make on Fedora 3, home machine. 
Successfully installed on work FC3 machine earlier today. I did make 
twice, to no avail, and then redid the configure then another make, 
with the same results.

collect2: ld returned 1 exit status
make: *** [sapi/cli/php] Error 1
Let me know if you need me to post more info from the make. Cheers.
php=5.0.3
apache=2.0.53 (apache installed fine)
Mark Sargent.
Hi All,
php-5.0.4 installed without a hitch..oh well, can't really complain
about that, now can I..? cheers.
Great, but next time post more output from the make command. The message 
says only that linking failed, the reason was above it.

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


Re: [PHP] User Management

2005-04-13 Thread angelo


use an include file at the top of each page.
in this include file you will check to see whether that user has access 
to see that page, if they dont then just redirect to the main menu page 
or an error page.

hope this helps

Angelo Zanetti
Z Logic

www.zlogic.co.za


This message was sent using IMP, the Internet Messaging Program.

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



[PHP] php SMPP

2005-04-13 Thread kyriacos sakkas
Hi all,
Just wondering if anybody has had experience using SMPP with php. I
have used the one available class that has limited functionality for
sending simple messages, but would like to do a little bit more
(concatenated messages over 170 chars.).
Ipworks has some libraries, but I have not been able to compile the php
side of them (keep getting compilation errors for on file), so now I am
stuck.
Any pointers to existing scripts, or advice on how to create SMPP pdu's
manually will be very appreciated.

thanks
Kyriacos
-- 
Kyriacos Sakkas  Netsmart Development Team
Tel: + 357 22 452565  Fax: + 357 22 452566
kyriacos(at)netsmart.com.cy http://www.netsmart.com.cy
Taking Business to a New Level!

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



[PHP] How get words on a webpage

2005-04-13 Thread Ken
On 4/13/05, issin <[EMAIL PROTECTED]> wrote:
> Ken,
> 
> Echo and printf can't get words on other webpage. I want get words,
> no only show.
> Thanks!
> 
> Issin
> 
> -Original Message-
> From: Ken [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, April 12, 2005 3:16 PM
> To: issin
> Subject: Re: [PHP] How get words on a webpage
> 
> Man
> 
> one thing: RTFM
> 
> http://www.php.net/echo/
> http://www.php.net/printf/
> 
> On Apr 12, 2005 9:07 AM, issin <[EMAIL PROTECTED]> wrote:
> > Dear all,
> >
> >I want get words include "today ** tonight" on
> > www.XXX.com/index.html, and then show on my webpage.
> >
> >Please advise, thanks!
> >
> > issin
> >
> >  Information from NOD32 
> > This message was checked by NOD32 Antivirus System for Linux Mail Server.
> > http://www.nod32.com
> >
> >
> 
>  Information from NOD32 
> This message was checked by NOD32 Antivirus System for Linux Mail Server.
> http://www.nod32.com
> 

ahhh! I get your drift now.
you can do so by using fopen

$fp = fopen("http://www.XXX.com/index.html";, r);
$contents = fread($fp, 1000);
fclose($fp);'

then use string functions or regexp to search $contents for what you want.

HTH.

Ken

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



[PHP] User Management

2005-04-13 Thread Dasmeet Singh
Hi!
I am developing an applicaton in PHP where different users would have 
different permissions and access to different functions/pages of 
website. Now whats the best way to do tht?

One way I can think of is keep all permissions in a table and divide 
everyting on site into functions..and when every function is called, 
check whether thecurrent user has permission to particular function..

But this method looks quiet complicated..is ther any other way to do this?
Also if you can give me some links to articles/tutorials on user/levels 
management in PHP, it would be really helpful..

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


[PHP] Problem with recorset

2005-04-13 Thread kioto
Hi all sorry for the newbie's question but i want understand the problem.
I have use a simple command with sqlite to get a data from a table.
$dbFile = realpath("./")."/data.db";
$db = sqlite_open($dbFile);
if (!(is_resource($db))) {
  
   die("Impossibile aprire uno stream: ".
   sqlite_error_string(sqlite_last_error($db)));
}   

$query = "SELECT id, file, time FROM file";
$res = sqlite_unbuffered_query($db, $query);
while (list($id, $file, $time) = sqlite_fetch_array($res)) {
  
   echo $id.$file.$time."\n";
}   
   
I i want use a OOP to get a data from a a table i get for every execution
of loop while the first record.

include("./classdb.php");
class DbData extends SqliteDbConnect
{
   function GetQueryResult($query)
   {
   $res = sqlite_unbuffered_query($this->dbLink, $query);
   return $rows = sqlite_fetch_array($res);
   }
}
$db =& new DbData("./", "data.db");
$query = "SELECT id, filem time FROM file";
while (list($id, $file, $time) = $db->GetQueryResult($query)) {
  
   echo $id.$file.$time."\n";   
}   

I have tested the script with CLI on PHP4/Win.
Thanks so much to all.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] error handling

2005-04-13 Thread Stephen March
Personally, I create a custom error handler for all my apps (currently 4.3.*
compliant).  While I normally use Smarty and have separate error templates,
here is a quick example.

function errorHandler($errno, $errstr, $errfile, $errline )
{
print "Error #: $errno Error Message: $error_Message";
}  

set_error_handler("errorHandler");

call_some_pgsql_function();


-Original Message-
From: Cima [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, April 12, 2005 11:46 PM
To: php
Subject: [PHP] error handling

hi,

im working with php 4 and postgresql 8 and i would like to know how to
handle certain errors generated. in postgresql,  i've written a stored
function that selects a record from a table and in case no record is found i
'raise an exception'. fine, now in my php script  i call that the stored
function which works properly when there is a record but when the record
doesnt exist, i would like to be able to place my own error message and not
e.g  'fatal error, .'. how do i capture(in php)  the exception i raised
in postgres so that i know the record doesnt exist?


thanx.

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


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



[PHP] Index of /base-1.1

2005-04-13 Thread Mark Sargent
Hi All,
typing localhost/bse-1.1 gives me access, but, in this format,
Index of /base-1.1
Icon  Name Last 
modified   Size 
  Description 


[DIR] Parent Directory  
-   [DIR] admin/   
04-Apr-2005 05:27-   [   ] base_ag_common.php 
  04-Apr-2005 05:26  3.5K

a listing of the dir, which, I guess, is not too good. What have I done 
wrong here..?
Cheers.

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