[PHP] fscanf syntax

2001-03-30 Thread Patrick Brown

I want to parse a file with the following syntax.

hostname|protocol|number|severity|description

Each record is on it's own line and have the fields delimited by the pipe
character |. The file may have thousands of records and I would like to
bring them into a database for reporting.

Some of you may recognize this a the file format of a Nessus security scan
file.

What function should I use and what would the syntax be?

Thanks,
Pat



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] fscanf syntax

2001-03-30 Thread Patrick Brown

Thanks Chris,

That worked great. I didn't know that a file could be read directly into an
array.

--Pat

"Chris Fry" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Pat,
>
> You could read the file into an array;
>
> $aryNessus = file("/pathtofile/filename", "r");
>
> Each row of the array then has one line from the file;
> Get the record count;
> $intNumRecs = count($aryNessus);
>
> Now read through the array and extract the values;
>
> for($i=0;$i<=$intNumRecs;$i++) {
> $aryNessusFields = explode("|", $aryNessus[$i]);
> $hostname = $aryNessusFields[0];
> $protocol = $aryNessusFields[1];
> $number = $aryNessusFields[2];
> $severity = $aryNessusFields[3];
> $description + $aryNessusFields[4];
> // Save the data into the database here
> }
>
>
> Regards
>
> Chris
>
> Patrick Brown wrote:
>
> > I want to parse a file with the following syntax.
> >
> > hostname|protocol|number|severity|description
> >
> > Each record is on it's own line and have the fields delimited by the
pipe
> > character |. The file may have thousands of records and I would like to
> > bring them into a database for reporting.
> >
> > Some of you may recognize this a the file format of a Nessus security
scan
> > file.
> >
> > What function should I use and what would the syntax be?
> >
> > Thanks,
> > Pat
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
> --
> Chris Fry
> Quillsoft Pty Ltd
> Specialists in Secure Internet Services and E-Commerce Solutions
> 10 Gray Street
> Kogarah
> NSW  2217
> Australia
>
> Phone: +61 2 9553 1691
> Fax: +61 2 9553 1692
> Mobile: 0419 414 323
> eMail: [EMAIL PROTECTED]
> http://www.quillsoft.com.au
>
> You can download our Public CA Certificate from:-
> https://ca.secureanywhere.com/htdocs/cacert.crt
>
> **
>
> This information contains confidential information intended only for
> the use of the authorised recipient.  If you are not an authorised
> recipient of this e-mail, please contact Quillsoft Pty Ltd by return
> e-mail.
> In this case, you should not read, print, re-transmit, store or act
> in reliance on this e-mail or any attachments, and should destroy all
> copies of them.
> This e-mail and any attachments may also contain copyright material
> belonging to Quillsoft Pty Ltd.
> The views expressed in this e-mail or attachments are the views of
> the author and not the views of Quillsoft Pty Ltd.
> You should only deal with the material contained in this e-mail if
> you are authorised to do so.
>
> This notice should not be removed.
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Form submision probs with Javascript and PHP

2001-02-09 Thread Patrick Brown

Here's my script. This is a known working script when I use ASP. Why won't
is wotj with PHP.

function submitForm(f, strPage) {
 errormsg = "";
 if (f.login.value.length == 0) {
  errormsg = errormsg + "Please enter a login name.\n";
 }
 if (f.email.value.search("@") == -1 || f.email.value.search("[.*]") == -1)
{
  errormsg = errormsg + "Please enter a valid email address.";
 }

 if (errormsg != ""){
  alert(errormsg);
  }
  else {
  f.action = strPage;
  f.method = "post";
  f.submit();
 }
}

Here's the button.



Any help would be great.

Thanks,
Pat



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] error handling

2001-02-14 Thread Patrick Brown

How can I disable the display of error to the browser window from within the
script? I want to do a redirect based on the error and cannot because header
info has already been sent.

Thanks,
Pat



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] error handling

2001-02-14 Thread Patrick Brown

OK, I tried the @ symbol. It seemed to just disable error checking
altogether. I have this in my code that I'd like to use.

if (!$php_errormsg) {
 header("Location: http://www.domain.com/admin/index.php");
}
else {
 header("Location: http://www.domain.com/admin/error.html");
}

"CC Zona" <[EMAIL PROTECTED]> wrote in message
96fcv5$2o0$[EMAIL PROTECTED]">news:96fcv5$2o0$[EMAIL PROTECTED]...
> In article <96faad$h9k$[EMAIL PROTECTED]>, [EMAIL PROTECTED] ("Patrick
> Brown") wrote:
>
> > How can I disable the display of error to the browser window from within
the
> > script? I want to do a redirect based on the error and cannot because
header
> > info has already been sent.
>
> Use the "@" sign. Example
>
> @some_function()
>
> --
> CC
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] add user to ldap using php

2001-02-20 Thread Patrick Brown

This is code from a working script to add a user account to a Novell NDS
database via Novell's LDAPv3.

Hope this helps.

//connect to LDAP
$ds=ldap_connect("172.17.20.10");  // must be a valid LDAP server!
if (!$ds) {
 echo "Connection to LDAP server failed";
 exit();
}

//bind to LDAP
$r=ldap_bind($ds,"cn=ftpadmin, ou=Corp, o=PMX", "engineer");
if (!$r) {
 echo "LDAP bind failed";
 exit();
}

//prepare the data to be added
$info1["cn"]=$login;
$info1["sn"]=$login;
$info1["objectclass"]="inetOrgPerson";

// add data to directory
$r=ldap_add($ds, "cn=$login, ou=SomeOU, o=Org", $info1);

//Close the LDAP connection.
ldap_close($ds);


""Richard Lynch"" <[EMAIL PROTECTED]> wrote in message
02c401c09a4c$98a7ce20$[EMAIL PROTECTED]">news:02c401c09a4c$98a7ce20$[EMAIL PROTECTED]...
> > $a=ldap_add($ds, "uid=beau, dc=graduate, dc=com", $info);
> > but it's an error
> > Waring LDAP: add operation could not be complete in. 
>
> I don't know much about LDAP:
>
> Have you checked that $ds is a valid LDAP connection?
> Can you get your own record out of LDAP using it?
> Presumably LDAP has some notion of who can add records (or whatever they
> called them) and who can't.
> Are you sure the user connected in ldap_open() is empowered to add records
> at that level in the LDAP space?
>
> --
> Visit the Zend Store at http://www.zend.com/store/
> Wanna help me out?  Like Music?  Buy a CD: http://l-i-e.com/artists.htm
> Volunteer a little time: http://chatmusic.com/volunteer.htm
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Getting LDAP attribute values

2001-02-20 Thread Patrick Brown

I'm trying to read some LDAP entries from a Novell LDAPv3 server on NetWare
5.1.

Here's a piece of my code.


$base = "ou=Corp, o=PMX";
$filter = "sn=*";
$attrib = array("lastLoginTime", "sn", "mail", "telephoneNumber",
"homeDirectory");

// Search surname entry
$sr=ldap_search($ds, $base, $filter, $attrib);
$info = ldap_get_entries($ds, $sr);


I can get the values for sn and mail but can't get lastLoginTime,
telephoneNumber, or homeDirectory. These are valid LDAP attributes as
defined by Novell. Novell developer support told me this.

"These are operational attributes.  For a list of operational attributes see
http://developer.novell.com/ndk/doc/docui/index.htm#../ndslib/schm_enu/data/
hotadinr.htm

Operational attributes are not automatically returned in search results;
they
must be requested by name in the search operation."

Does anyone have any ideas? I'm doing an authenticated bind and am using an
account with full rights to the tree.

Thanks,
Pat





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Novell LDAP and PHP?

2001-02-20 Thread Patrick Brown

Has anyone done any LDAP work with Novell's LDAPv3 server?

--Pat






-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]