Re: [PHP] Php coding help - Newbie question

2007-01-22 Thread Chris



Sorry for troubling all again.
I am trying to use the Pear DB_ldap for the above scripts.

Does any one have any sample code for ldap_connect () ldap_search etc.


http://php.net/ldap_connect

http://php.net/ldap_search

Both pages have examples.

If you have a specific problem then post it.

--
Postgresql  php tutorials
http://www.designmagick.com/

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



Re: [PHP] Php coding help - Newbie question

2007-01-22 Thread Ramdas

On 1/23/07, Chris [EMAIL PROTECTED] wrote:


 Sorry for troubling all again.
 I am trying to use the Pear DB_ldap for the above scripts.

 Does any one have any sample code for ldap_connect () ldap_search etc.

http://php.net/ldap_connect

http://php.net/ldap_search

Both pages have examples.

If you have a specific problem then post it.

--
Postgresql  php tutorials
http://www.designmagick.com/


Thanx for replying Chris.

I am in process to modify my existing php scripts to a more neater/compact code.

In current scripts certain code ( ldap_connect , ldap_bind , if connet
error show error page etc ) is repeated many times.

This makes the scripts very bulky and even small changes that need to
be done are very difficult to implement.

That's why I am looking for some thing with a ready functions for the
above which I can use. I believe PEAR DB_ldap has it. But very little
documentation is avaliable.

So I was searching for any sample scripts.

-
My current script:
user edit page
?php
require 'validate.php' // included on every page to check logged in user.

bind to ldap else error..

show a form to user to edit user details.

post to update script.

disconnect ldap.

?

on update
?php
validate user

bind to ldap else .

check if any changes need to be done to the user .( compare before 
after values in the POST variables )
create the array for modfiy
do ldap_modify
in case error shout , else tell all is ok.

ldap_disconnect.
?

The problem is, for separate edit pages I have written separate update
pages. Any new object to edit needs a new edit page  a relevent
update page.

I believe if I can use functions this can be reduced to just one
update page with fewer edit pages.

Very sorry for this long mail.

Thanx  Regards
Ram

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



Re: [PHP] Php coding help - Newbie question

2007-01-20 Thread Ramdas

On 1/18/07, Ramdas [EMAIL PROTECTED] wrote:

On 1/17/07, Jochem Maas [EMAIL PROTECTED] wrote:
 Ramdas wrote:
  Hi Group,
 
  A very newbie question. Might be discussed earlier, please forgive.

 Are so much of a noob that STFW is not within your capabilities?
 (just thought I'd ask, given that you admit to realising the info *might*
 be out there already)

 
  I am having a site in PHP ( not very great design ) which I need to
  convert/modify to use functions. Such the code for connecting /
  binding to Ldap is not repeated  scripts are more readable.
 
  The site deals with modifying / adding / deleting entries in a LDAP dir.
 
  In each of the pages following is done:
 
  ?php
 
  require 'validate.php' ;// validate.php checks if the user is loged in
 
  $connect = ldap_connect(ldapserver);
  if ($connect) {
 
  bind ...
  do the things
 
  }else { echo erro..}
 
  ?
 
 
  Also please advice what is a correct method of checking the user's
  session. Currenlty I use a HTTP_SESSION_VARS variable to store the

 recommended to use the $_SESSION superglobal instead and stuff values
 directly into (after having called session_start()) instead of using 
session_register()
 et al.

  user's login  passwd . Each time the user hits the page these vars

 you only need to store *whether* they are logged in - and set that value when 
you
 actually handle a login attempt (obviously storing their username could be 
handy)

 I don't see any reason to store the passwd and validate against ldap on
 every request ... in fact I believe that storing the pwd in such a way is 
essentially less
 secure.

  are checked with the existing values in the LDAP (this is done by
  validate.php).
 
  Please suggest me some good starting point where I can start a fresh
  with more compact/cleaner Code.

 that question is about as vague as 'how long is a chinaman?'
 (the answer to that question being 'yes he is')

 here are some very vague ideas/functions:

 an include file ...
 === 8 =
 ?php
 function sessionCheck()
 {
if (!isset($_SESSION['loggedin']) || !$_SESSION['loggedin']) {
/* show login page then .. */
exit;
}
 }

 function doLogin($username, $passwd)
 {
$_SESSION['loggedin'] = false;
if (/* given $username+$passwd check outs in ldap*/)
$_SESSION['loggedin'] = true;

return $_SESSION['loggedin'];
 }
 ?

 an 'init' include file
 === 8 =
 ?php

 require 'your-include-file.php'; // see above


 session_start();

 if (isset($_POST['uname'], $_POST['pwd'])) {
doLogin($_POST['uname'], $_POST['pwd']);
 }

 sessionCheck();

 ?

 any other file (other than the login 'page')
 === 8 =
 ?php

 require 'your-init-file.php';

 // we are logged in - it's magic

 // do some shit

 // the end, congrats go get laid :-)

 ?


Thanx for the all responses.

Regards
Ram



Hi all,

Sorry for troubling all again.
I am trying to use the Pear DB_ldap for the above scripts.

Does any one have any sample code for ldap_connect () ldap_search etc.

Thanx once again.

Regards
Ram

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



Re: [PHP] Php coding help - Newbie question

2007-01-18 Thread Ramdas

On 1/17/07, Jochem Maas [EMAIL PROTECTED] wrote:

Ramdas wrote:
 Hi Group,

 A very newbie question. Might be discussed earlier, please forgive.

Are so much of a noob that STFW is not within your capabilities?
(just thought I'd ask, given that you admit to realising the info *might*
be out there already)


 I am having a site in PHP ( not very great design ) which I need to
 convert/modify to use functions. Such the code for connecting /
 binding to Ldap is not repeated  scripts are more readable.

 The site deals with modifying / adding / deleting entries in a LDAP dir.

 In each of the pages following is done:

 ?php

 require 'validate.php' ;// validate.php checks if the user is loged in

 $connect = ldap_connect(ldapserver);
 if ($connect) {

 bind ...
 do the things

 }else { echo erro..}

 ?


 Also please advice what is a correct method of checking the user's
 session. Currenlty I use a HTTP_SESSION_VARS variable to store the

recommended to use the $_SESSION superglobal instead and stuff values
directly into (after having called session_start()) instead of using 
session_register()
et al.

 user's login  passwd . Each time the user hits the page these vars

you only need to store *whether* they are logged in - and set that value when 
you
actually handle a login attempt (obviously storing their username could be 
handy)

I don't see any reason to store the passwd and validate against ldap on
every request ... in fact I believe that storing the pwd in such a way is 
essentially less
secure.

 are checked with the existing values in the LDAP (this is done by
 validate.php).

 Please suggest me some good starting point where I can start a fresh
 with more compact/cleaner Code.

that question is about as vague as 'how long is a chinaman?'
(the answer to that question being 'yes he is')

here are some very vague ideas/functions:

an include file ...
=== 8 =
?php
function sessionCheck()
{
   if (!isset($_SESSION['loggedin']) || !$_SESSION['loggedin']) {
   /* show login page then .. */
   exit;
   }
}

function doLogin($username, $passwd)
{
   $_SESSION['loggedin'] = false;
   if (/* given $username+$passwd check outs in ldap*/)
   $_SESSION['loggedin'] = true;

   return $_SESSION['loggedin'];
}
?

an 'init' include file
=== 8 =
?php

require 'your-include-file.php'; // see above


session_start();

if (isset($_POST['uname'], $_POST['pwd'])) {
   doLogin($_POST['uname'], $_POST['pwd']);
}

sessionCheck();

?

any other file (other than the login 'page')
=== 8 =
?php

require 'your-init-file.php';

// we are logged in - it's magic

// do some shit

// the end, congrats go get laid :-)

?



Thanx for the all responses.

Regards
Ram

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



Re: [PHP] Php coding help - Newbie question

2007-01-17 Thread Jim Lucas

Ramdas wrote:

Hi Group,

A very newbie question. Might be discussed earlier, please forgive.

I am having a site in PHP ( not very great design ) which I need to
convert/modify to use functions. Such the code for connecting /
binding to Ldap is not repeated  scripts are more readable.

The site deals with modifying / adding / deleting entries in a LDAP dir.

In each of the pages following is done:

?php

require 'validate.php' ;// validate.php checks if the user is loged in

$connect = ldap_connect(ldapserver);
if ($connect) {

Change the previous lines to this and then move it to the bottom of the 
file called validate.php
Since you include that on each page, it will then be executed and upon 
failure, stop the script and display a connection error


if ( $connect = ldap_connect(ldapserver) === FALSE ) {
   //display error message and die();
   die(Internal problem, please try back later.);
}

bind ...
do the things

}else { echo erro..}

?


Also please advice what is a correct method of checking the user's
session. Currenlty I use a HTTP_SESSION_VARS variable to store the
user's login  passwd . Each time the user hits the page these vars
are checked with the existing values in the LDAP (this is done by
validate.php).
I would be using the Super Globals for this:  $_SESSION, and don't store 
the password, just the username and something the say that he/she has 
already authenticated and is valid.


Jim Lucas


Please suggest me some good starting point where I can start a fresh
with more compact/cleaner Code.

Many thanx in advance.

Regards
Ram



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



Re: [PHP] Php coding help - Newbie question

2007-01-17 Thread Jochem Maas
Ramdas wrote:
 Hi Group,
 
 A very newbie question. Might be discussed earlier, please forgive.

Are so much of a noob that STFW is not within your capabilities?
(just thought I'd ask, given that you admit to realising the info *might*
be out there already)

 
 I am having a site in PHP ( not very great design ) which I need to
 convert/modify to use functions. Such the code for connecting /
 binding to Ldap is not repeated  scripts are more readable.
 
 The site deals with modifying / adding / deleting entries in a LDAP dir.
 
 In each of the pages following is done:
 
 ?php
 
 require 'validate.php' ;// validate.php checks if the user is loged in
 
 $connect = ldap_connect(ldapserver);
 if ($connect) {
 
 bind ...
 do the things
 
 }else { echo erro..}
 
 ?
 
 
 Also please advice what is a correct method of checking the user's
 session. Currenlty I use a HTTP_SESSION_VARS variable to store the

recommended to use the $_SESSION superglobal instead and stuff values
directly into (after having called session_start()) instead of using 
session_register()
et al.

 user's login  passwd . Each time the user hits the page these vars

you only need to store *whether* they are logged in - and set that value when 
you
actually handle a login attempt (obviously storing their username could be 
handy)

I don't see any reason to store the passwd and validate against ldap on
every request ... in fact I believe that storing the pwd in such a way is 
essentially less
secure.

 are checked with the existing values in the LDAP (this is done by
 validate.php).
 
 Please suggest me some good starting point where I can start a fresh
 with more compact/cleaner Code.

that question is about as vague as 'how long is a chinaman?'
(the answer to that question being 'yes he is')

here are some very vague ideas/functions:

an include file ...
=== 8 =
?php
function sessionCheck()
{
if (!isset($_SESSION['loggedin']) || !$_SESSION['loggedin']) {
/* show login page then .. */   
exit;
}   
}

function doLogin($username, $passwd)
{
$_SESSION['loggedin'] = false;
if (/* given $username+$passwd check outs in ldap*/)
$_SESSION['loggedin'] = true;

return $_SESSION['loggedin'];
}
?

an 'init' include file
=== 8 =
?php

require 'your-include-file.php'; // see above


session_start();

if (isset($_POST['uname'], $_POST['pwd'])) {
doLogin($_POST['uname'], $_POST['pwd']);
}

sessionCheck();

?

any other file (other than the login 'page')
=== 8 =
?php

require 'your-init-file.php';

// we are logged in - it's magic

// do some shit

// the end, congrats go get laid :-)

?

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



Re: [PHP] PHP Coding HELP

2002-11-22 Thread Vicky
Thank you very much for everyone's help ^_^

I'm very much a novice in PHP, so whether I can actually figure out what I
have to do'll be another thing *L*

Thanks again ^_^

-Vicky

-Original Message-
From: Vicky [mailto:[EMAIL PROTECTED]]
Sent: Friday, November 22, 2002 9:56 AM
To: [EMAIL PROTECTED]
Subject: [PHP] PHP Coding HELP

Hello!

I am looking to find or code a script that does the following. If anyone
could help I'd be extremely greatful.

Users can upload their files, but the files they upload can only be
downloaded X amount of times. After they've been downloaded so many
times in
an ideal world they'd be automatically removed, though just to be made
so
people couldn't download them anymore would be great.

Please help! Thanks!

Vicky

--
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] PHP Coding HELP

2002-11-22 Thread Per Lundkvist
Ok, make a form for upload with maybe fields as well where the user can
write how many time that file is supposed to be downloaded.
After submit you store that information in a database (MySQL) and when
downloading files you do it through another PHP-file where you can check how
many times it has been downloaded, if it reach the amount, delete it,
otherwise update the database with one more download for this file!

How to upload files can be read in the PHP-Manual.
For database use: www.mysql.com


Per L.


Vicky [EMAIL PROTECTED] wrote in message
016801c2922c$71472720$0200a8c0@omnibook">news:016801c2922c$71472720$0200a8c0@omnibook...
 Thank you very much for everyone's help ^_^

 I'm very much a novice in PHP, so whether I can actually figure out what I
 have to do'll be another thing *L*

 Thanks again ^_^

 -Vicky

 -Original Message-
 From: Vicky [mailto:[EMAIL PROTECTED]]
 Sent: Friday, November 22, 2002 9:56 AM
 To: [EMAIL PROTECTED]
 Subject: [PHP] PHP Coding HELP

 Hello!

 I am looking to find or code a script that does the following. If anyone
 could help I'd be extremely greatful.

 Users can upload their files, but the files they upload can only be
 downloaded X amount of times. After they've been downloaded so many
 times in
 an ideal world they'd be automatically removed, though just to be made
 so
 people couldn't download them anymore would be great.

 Please help! Thanks!

 Vicky

 --
 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] PHP Coding HELP

2002-11-21 Thread Ray Hunter
If you have a database this would be easier...

Here is what u can do:

1. Create a form that allows them to upload files to your php server.
2. Then you can store the files in a database and have a field that has
a value that is how many times it can be downloaded.
3. Then a page that allows users to download.
4. For each download you can decrement that download field by one.
5. When you display the link for all the download files you can display
all the downloads that do not have your available download field = 0...

This would be a great start for ya...


On Thu, 2002-11-21 at 15:55, Vicky wrote:
 Hello!
 
 I am looking to find or code a script that does the following. If anyone
 could help I'd be extremely greatful.
 
 Users can upload their files, but the files they upload can only be
 downloaded X amount of times. After they've been downloaded so many times in
 an ideal world they'd be automatically removed, though just to be made so
 people couldn't download them anymore would be great.
 
 Please help! Thanks!
 
 Vicky
-- 

Ray Hunter
email:  [EMAIL PROTECTED]
www:http://venticon.com


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




RE: [PHP] PHP Coding HELP

2002-11-21 Thread John W. Holmes
 Users can upload their files, but the files they upload can only be
 downloaded X amount of times. After they've been downloaded so many
times
 in
 an ideal world they'd be automatically removed, though just to be made
so
 people couldn't download them anymore would be great.

You need a download manager.

This can be a simple PHP script. You simply route all of your download
requests to a URL like

download.php?fileid=45

download.php will grab the $fileid and look in a database or file to see
how many times fileid 45 has been downloaded. If it's below your
threshold, then download.php will send the appropriate headers for the
file that's requested, and then send the data of the file. Store the
files outside of the web root for the best protection. If the file has
already been downloaded X times, then just show an HTML page that says
the limit is up.

---John Holmes...



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