Re: [PHP-DB] How can I solve this?

2006-01-19 Thread Jeremy Peterson
A friend of mine updated your regular expression...  Check it out if your 
interested.


Jeremy




Dear Jeremy,

Thanks for writing!

 I saw this regular expression and thought you might like it... :)

 preg_replace(/^\/?(.*)\/[\w]+\.php$/,$1,$PHP_SELF)
 
 that strips that leading forward slash too ;-)

  \w is a PCRE (Perl-Compatible Regular Expression) that matches any
word character: a-z, A-Z, 0-9 and the underscore _. sed and awk do
not support \w, although ssed (super-sed) supports \w if an -R switch
is added on the command line.

   Back to PHP and \w : Putting \w by itself inside a character class
[...] does absolutely nothing, just as [a] and [9] does nothing
special. It could be more efficiently written as:

/^\/?(.*)\/\w+\.php$/

   One additional problem is that the characters defined by \w does
not include the hyphen, the pound sign, or other punctuation marks
that sometimes find their way into filenames, like:

four-to-go.php
page#10.php
convert$toDM.php

so in this case, a character set should be used:

/^\/?(.*)\/[EMAIL PROTECTED]*+=-]+\.php$/

Keep 'em coming!

--
Eric Pement - [EMAIL PROTECTED]
Educational Technical Services, MBI




Jeremy Peterson, MACS
Automation Systems Administrator
Crowell Library
Moody Bible Institute
820 N. LaSalle Drive
Chicago, IL, 60610

Email:  [EMAIL PROTECTED]
Phone:  312.329.8081
Fax:312.329.8959


[PHP-DB] Sybase Query- Problems with Pound Sign

2003-08-14 Thread Jeremy Peterson
I am having a problem with a query that has a pound sign in it.  The 
results are quite puzzling, it seems like the page doesn't load if the 
query is present.  I have tested this on other tables without the pound 
sign and they work beautifully, seems like the pound sign is the 
troublemaker to me.

Printing $sql returns the proper sql statement, so what is the sybase_query 
function doing to the variable?

My code is at the bottom of this page.

Thanks,

Jeremy



?php
include $DOCUMENT_ROOT/include/sybase.inc;
$syb_connect = syb_connect($syb_server, $syb_user, $syb_pw);

$sql = select * from item where bib# = 300;
print sql=$sql;
$result = sybase_query($sql);
//print someting;
while($row = Sybase_Fetch_Assoc($result)){
extract($row);
print $tag $textbr;
}

?

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


Re: [PHP-DB] Authenticating through a php script

2003-01-09 Thread Jeremy Peterson
=example,dc=com; // change to the dn you want 
to authenticate

$connect_result = ldap_connect( $ldap_server, $ldap_port );

// Did we connect?
if( ! $connect_result )
{
echo Could not connect to '$server_name' on port '$server_port';
}

$bind_result = ldap_bind( $connect_result, $admin_dn, $admin_pw );

// Did we bind?
if( ! $bind_result )
{
echo Bad username/password;
}
else
{
echo Correct username/password!;
}

?

Here's some good documentation on the topic:
http://www.php.net/manual/en/ref.ldap.php

Let us know how it goes.

--Dave



On Thu, 2003-01-09 at 10:01, Jeremy Peterson wrote:
 I am working on a script that will authenticate on a central system my
 company has devised for us to use (LDAP) and then authenticate them to
 other sites that I want them to access (Online Databases and other
 electronic resources I do not control but pay lots of money for all
 students to access).

 I have seen this done on a product produced by Epixtech called RPA
 (Remote Patron Authentication).  This is an authentication system that
 avoids using a proxy server. It basically handles the authentication
 (LDAP) and sends the appropriate information to the other secure
 source (Online Database, Electronic Resources, or my online catalog's
 patron information.)  Typically there are multiple ways it will
 authenticate for the user to other resources.  URL referer, ip
 authentication, fill in an user/password form for the user.  I just
 can't get the user/password portion to work on a protected site.  My tests
 of sending post information to another one of my scripts works fine.  But
 it doesn't work as of yet.

 I have worked a bit with scripts that send post information through
 sendToHost function (fsockopen and fputs).  But nothing is really
 working here.  Does anyone know how I should go about this?  All
 suggestions will be great!


 Thanks a bunch,

 Jeremy


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




Re: [PHP-DB] Authenticating through a php script

2003-01-09 Thread Jeremy Peterson
Dave,

I am afraid I am not communicating what I am trying to do.

I have multiple databases that my library purchases.  FirstSearch, 
Ebscohost, etc.  These company's have there own authentication systems that 
I have no control over.  A lot of them give user names and passwords that 
can access their secure database; however I will not give out this 
information to students.  I want to design a system that will log the 
students on directly without them ever seeing the log in screen.

A)  Does this make sense in what I am trying to do?
B)  How can I do it?

Jeremy

At 12:38 PM 1/9/2003 -0700, David Smith wrote:
I haven't looked over all your code in detail, but the problem you
describe seems to be best solved using PHP Sessions. Sessions store data
between browser refreshes. You could store whether a user has been
authenticated via LDAP, and then on a subsequent page, you can reference
that information to determine how to proceed.

Here's the doc: http://www.php.net/manual/en/ref.session.php

--Dave

On Thu, 2003-01-09 at 11:29, Jeremy Peterson wrote:
 David,

 I have ldap working, my problem is the second half of my question.

 The problem script workflow:
 1. Authenticate on LDAP (Resolved)
 2. Connect to different authenticated site for the user  (Not sure 
where to
 go now.)

 My guess was to send the post information to where the form action points
 to.  Having done this, all I get is a blank page.  I guess if  PHP sends
 the post information then the client will be out of the authentication
 loop.  There must be a better way.  But I don't think I have enough
 information to know how to proceed.

 Somehow I have to get the browser to send the http post rather than
 PHP.  Is this possible.

 Jeremy

 P.S.

 The script I am using right now incorporates Chris Alsop's class:

 !-- CLASS START --

 ?php
## Archive:c_http.class
## Description:Basic http class functions (only post right now)
## Author: Chris Alsop - [EMAIL PROTECTED] (rumblefiz)
## Property Of:Everyone
## Date Created:   07/01/2001
## Mod History:07/01/2001   Chris Alsop - Initial Coding
##
 ==
   class c_http {
  ## DECLARE CLASS VARIABLES 
 var $QUERY_STRING;
 var $TARGET_DOMAIN;
 var $TARGET_FILE;
 var $RESPONSE;
  ## END CLASS VARIABLE DECLARATION -

  ## FUNCTION: c_http()
  ## ARGS: $psQueryString : String
  ##   $psTargetDomain : String
  ##   $psTargetFile : String
  ## 
 function c_http($psQueryString,
$psTargetDomain,$psTargetFile) {

$this-QUERY_STRING  = $psQueryString;
$this-TARGET_DOMAIN = $psTargetDomain;
$this-TARGET_FILE   = $psTargetFile;
 }
  ## END FUNCTION: c_http() *

  ## FUNCTION: post()
  ## ARGS: None
  ## RETURNS:  Boolean
  ## 
 function post() {
$qs  = $this-QUERY_STRING;
$domain  = $this-TARGET_DOMAIN;
$thefile = $this-TARGET_FILE;
if(!$fp = fsockopen($domain,80)) {
   print Socket not openbr;
   return false;
   exit();
}
$postData  = POST http://$domain/$thefile HTTP/1.0\r\n;
$postData .= Content-type:
 application/x-www-form-urlencoded\r\n;
$postData .= Content-length: .strlen($qs).\r\n\r\n;
$postData .= $qs;

if(!fputs($fp,$postData)) {
   return false;
   exit();
}

$data = ;
while(!feof($fp)) $data .= fgets($fp,32000);
$pos = 0;
for($i=0; $i2000; $i++) {
   if(strtoupper(substr($data,$i,4)) == \r\n\r\n) {
  $pos = $i+4; $i = 2000;
   }
}
$data = substr($data,$pos);

$base = base href ;
$base = $base . =;
$base = $base .  'http://$domain/' ;
$base = $base . ;

if (eregi(body,$data)) {
   $data = eregi_replace(body,$base.BODY,$data);
} else {
   $data = $base . $data;
}
$this-RESPONSE = $data;
fclose($fp);
return true;
 }
  ## END FUNCTION: post() ***
  }
 ?

 !-- CLASS END --
 !-- Test Script --

 ?php



 /*Form information I am trying to send to- example only
 form name=MyForm action=login.php method=post
 Please log into MyMBI
 ID INPUT

Re: [PHP-DB] string

2002-05-17 Thread Jeremy Peterson

Sure-

$test = text1;

if(substr($test, -1) == 1){
 print do something;
}
else{
 print didn't equal 1 ;


At 08:00 AM 5/17/2002 -0400, Natividad Castro wrote:
Hi to all,
how can I evaluate a variable?
For example
$test = test1;
then I want to evaluate if $test contains 1 at the end.
Is there any way to evaluate that variable to see if the number 1 is at the
end?
Thanks
Nato


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


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




Re: [PHP-DB] Query with numbers like 1, 3, 5..........

2002-02-07 Thread Jeremy Peterson

select * from table where id in (1,3,5,10,'etc')

At 08:22 PM 2/7/2002 +0100, Raymond Lilleodegard wrote:
Hi!

Is there a way to get the rows with id's like 1, 3, 5, and so on or 2, 4, 6,
...?


Best regards Raymond



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


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




Re: [PHP-DB] Update

2002-02-04 Thread Jeremy Peterson

Hello,

I am not sure why you want to do this.  Wouldn't it be better to use 
calculate the days from the date signed up, rather than through updating 
your database every day.  Try using datediff.

Jeremy

At 01:51 PM 2/4/2002 -0800, Jennifer Downey wrote:
Hi,

I am having problems with this code. I want to update a members number of
days they have been a member can anyone help?

$query[days]=(UPDATE users set days_member VALUES = ('days_member' +
'1'));
$result=mysql_query($query[days]);

Thanks in advance
JD



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


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