Jump to content

tanveer

Members
  • Posts

    50
  • Joined

  • Last visited

    Never

Everything posted by tanveer

  1. hi thanks.. Yes thats the reason I was trying to know .. at line 80 is that function to show the message that XML file created successfully. Before that I am also closing the file handler but it's thinking it as a continuation of creating that xml file. Thats the problem actually.
  2. Anyone has any idea why this is happening ? It's giving error if I want to show any message after creating the file. class SocialNetXML extends SystemConfig { public $sqlQuery = ""; public $resultID = ""; public function setQuery($query){ $dbConnect = new DBConnect(); $dbConnect->Connection("localhost", "dbname", "user", ""); $resultID = mysql_query($query) or die("Data not found."); return $resultID; } public function generateXML($empIDList, $relationList){ header("Content-type: text/xml"); $xml_output = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; $xml_output .= "<graphml xmlns=\"http://graphml.graphdrawing.org/xmlns\">\n"; $xml_output .= "<graph edgedefault=\"directed\">\n"; $xml_output .= "<key id=\"name\" for=\"node\" attr.name=\"sender\" attr.type=\"string\"/>\n"; for($x = 1 ; $x <= mysql_num_rows($empIDList) ; $x++){ $row = mysql_fetch_assoc($empIDList); $xml_output .= "\t<node id=\"$x\">\n"; $xml_output .= "\t\t<data key=\"name\">" . $row['emp_addr'] . "</data>\n"; $xml_output .= "\t</node>\n"; } for($x = 1 ; $x <= mysql_num_rows($relationList) ; $x++){ $row = mysql_fetch_array($relationList); $xml_output .= "\t<edge source=\"" . $row[0] . "\" target=\"" . $row[1] . "\"></edge>\n"; } $xml_output .= "</graph>\n"; $xml_output .= "</graphml>\n"; return $xml_output; } public function createXMLFile ($xml_output){ print $xml_output; $file_handle = fopen('/tmp/authorNetwork.xml','w'); fwrite($file_handle,$xml_output); fclose($file_handle); } public function confirmationMsg(){ print "<h1> XML File Has Been Successfully Created </h1> <br /> <h2> XML File Location: /tmp </h2> "; } } $enxml = new SocialNetworkXML; // Finding the Author's who sent mail. //$empIDList = $enxml->setQuery ("SELECT emp_name FROM emplist WHERE emp_name IS NOT NULL"); $empIDList = $enxml->setQuery (" SELECT emp_addr FROM emplist "); // Finding the Author's recipients whom they sent mail to generate the XML $relationList = $enxml->setQuery ("SELECT emp_id, receiver_id FROM message, rcptinfo WHERE message.mail_id = rcptinfo.mail_id"); $xml_output = $enxml->generateXML($empIDList, $relationList ); $enxml->createXMLFile($xml_output); $enxml->confirmationMsg(); ?>
  3. This page contains the following errors: error on line 80 at column 1: Extra content at the end of the document Below is a rendering of the page up to the first error.
  4. Hi, I am creating an XML file from the mysql database and it's creating fine. But after creating it and writing it to a file I just want to show the output as "File creation is successful" that sort of message. But it gives me error if I call the function to show that message. Below is the code: public function generateXML($resultID){ header("Content-type: text/xml"); $xml_output = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; $xml_output .= "<graphml xmlns=\"http://graphml.graphdrawing.org/xmlns\">\n"; $xml_output .= "<graph edgedefault=\"directed\">\n"; $xml_output .= "<key id=\"name\" for=\"node\" attr.name=\"sender\" attr.type=\"string\"/>\n"; for($x = 1 ; $x < mysql_num_rows($resultID) ; $x++){ $row = mysql_fetch_assoc($resultID); $xml_output .= "\t<node id=\"$x\">\n"; $xml_output .= "\t\t<data key=\"name\">" . $row['sender'] . "</data>\n"; $xml_output .= "\t</node>\n"; } $xml_output .= "</graph>\n"; $xml_output .= "</graphml>\n"; return $xml_output; } public function createXMLFile ($xml_output){ // print $xml_output; $file_handle = fopen('/tmp/socialNetwork.xml','w'); fwrite($file_handle,$xml_output); fclose($file_handle); } // It gives an error if I call this function for showing the file creation status. public function showMessage (){ echo "<H1> File Successfully Created </H1>"; } } $snxml = new SocialNetworkXML; $holdResult = $snxml->setQuery("select distinct sender from message1"); $xml_output = $snxml->generateXML($holdResult); $snxml->createXMLFile($xml_output); $snxml->showMessage(); ?>
  5. Found it ... in Email I forgot to sanitize the variable .. Now after removing spaces from email it's working as there was a space in front an email .. Thanks all.
  6. Thanks for the reply. I changed to while loop but still same. public function tblRcptInfo($rtype, $hValue ){ /* * Fetch Last mail_id Value from `message` table */ $mail_id = PopulateTables::findLastMailId(); $headerValue = explode(",", $hValue); $i = 0 ; while ($i < count($headerValue)){ $receiverID = PopulateTables::getReceiverID($headerValue[$i]); PopulateTables::populateRcptInfo( $rtype, $receiverID, $mail_id ); $i ++; } } public function getReceiverID ($rEmail){ $dbConnect = new DBConnect(); $dbConnect->Connection("localhost", "dbname", "uname", ""); $findIdQuery = "SELECT emp_id FROM emplist WHERE emp_addr='$rEmail'"; $resultQuery = mysql_query($findIdQuery) or die ("Error: Select Query Failed for emp_list Table "); echo "QUery:".$findIdQuery; $countRows = mysql_num_rows($resultQuery); $rID = mysql_fetch_array($resultQuery); return $rID[0]; } public function populateRcptInfo ( $rtype, $receiverID, $mail_id ){ $dbConnect = new DBConnect(); $dbConnect->Connection("localhost", "dbname", "uname", ""); $insertQuery= "INSERT INTO rcptinfo (reply_type, receiver_id, mail_id) VALUES ('$rtype', $receiverID, $mail_id )"; echo $insertQuery; mysql_query($insertQuery) or die("Error: Insert Query Failed for `RcptInfo` Table"); } here is the output of query where it's showing in 2nd time it's not getting the result ... QUery:SELECT emp_id FROM emplist WHERE emp_addr='h..lewis@enron.com' INSERT INTO rcptinfo (reply_type, receiver_id, mail_id) VALUES ('TO', 2, 1 ) QUery:SELECT emp_id FROM emplist WHERE emp_addr=' dutch.quigley@enron.com' INSERT INTO rcptinfo (reply_type, receiver_id, mail_id) VALUES ('TO', , 1 ) Error: Insert Query Failed for `RcptInfo` Table
  7. Hi, I am facing a weird problem.. table `getReceiverID` was supposed to return all the empid values by running the query which it's not doing. It works only for the first time and after that the output of mysql_num_rows() gets zero. But it shouldn't be.. I am stuck .. What I am doing wrong ? Thank you. public function tblRcptInfo($rtype, $hValue ){ /* * Fetch Last mail_id Value from `message` table */ $mail_id = PopulateTables::findLastMailId(); $headerValue = explode(",", $hValue); foreach ($headerValue as $value){ $receiverID = PopulateTables::getReceiverID($value); } } public function getReceiverID ($rEmail){ $dbConnect = new DBConnect(); $dbConnect->Connection("localhost", "dbanme", "uname", ""); $findIdQuery = "SELECT emp_id FROM emplist WHERE emp_addr='$rEmail'"; $resultQuery = mysql_query($findIdQuery) or die ("Error: Select Query Failed for emp_list Table "); $countRows = mysql_num_rows($resultQuery); echo "rows ret:".$countRows; $rID = mysql_fetch_array($resultQuery); return $rID[0]; }
  8. Hi, I wanted to know is there any class or functions which will parse the mail body and find all the features like how many sentences, how many stop words, how many paragraphs, how many punctuation chars, etc. I haven't find anything good in my searching so far. I have parsed the whole body of email and separated the headers and body in variables. Now I want to perform these operations in only in the body. Thank you in advance.
  9. Thanks, it solved as u said the problem was on Quoting.
  10. Hi, I am using php to generate an xml file of the following structure <?xml version="1.0" encoding="UTF-8"?> <!-- An excerpt of an egocentric social network --> <graphml xmlns="http://graphml.graphdrawing.org/xmlns"> <graph edgedefault="directed"> <!-- data schema --> <key id="name" for="node" attr.name="name" attr.type="string"/> <key id="gender" for="node" attr.name="gender" attr.type="string"/> <!-- nodes --> <node id="1"> <data key="name">Jeff</data> <data key="gender">M</data> </node> <node id="2"> <data key="name">Ed</data> <data key="gender">M</data> </node> <node id="3"> <data key="name">Christiaan</data> <data key="gender">M</data> </node> <node id="4"> <data key="name">Emily</data> <data key="gender">F</data> </node> <node id="5"> <data key="name">Adam</data> <data key="gender">M</data> </node> <!-- emily's friends --> <edge source="1" target="2"></edge> <!-- adam's friends --> <edge source="2" target="3"></edge> <!-- cynthia's friends --> <edge source="3" target="4"></edge> <!-- joylette's friends --> <edge source="4" target="5"></edge> <!-- amanda's friends --> <edge source="5" target="1"></edge> <edge source="5" target="2"></edge> <edge source="5" target="3"></edge> <edge source="5" target="4"></edge> </graph> </graphml> and below is my code: public function createXML($resultID){ header("Content-type: text/xml"); $xml_output = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; $xml_output .= "<graphml xmlns=\"http://graphml.graphdrawing.org/xmlns\">\n"; $xml_output .= "<graph edgedefault=\"directed\">\n"; $xml_output .= "<key id=\"name\" for=\"node\" attr.name=\"sender\" attr.type=\"string\"/>\n"; for($x = 1 ; $x < mysql_num_rows($resultID) ; $x++){ $row = mysql_fetch_assoc($resultID); $xml_output .= "\t<node id=$x>\n"; $xml_output .= "\t\t<data key=\"name\">" . $row['sender'] . "</data>\n"; $xml_output .= "\t</node>\n"; } $xml_output .= "</graph>\n"; $xml_output .= "</graphml>"; echo $xml_output; } } $snxml = new SocialNetworkXML; $holdResult = $snxml->setQuery("select sender from message1"); $snxml->createXML($holdResult); But in browser its giving me this message: XML Parsing Error: not well-formed Location: http://localhost/........./SocialNetXML.class.php Line Number 5, Column 11: <node id=1> -----------------^ What am I doing wrong here ? thanks in advance.
  11. Hi, After a long time I start php again to do some stuff and using OOP concept for the first time and getting this below error PHP Fatal error: Class 'SystemConfig' not found in /home/tanveer/Workspace/EmailTest/webapp/classes/MailParser.class.php on line 12, referer: http://localhost/EmailTest/public_html/index.php My project directory structure is as follows: \webapp: |- classes |- MailParser.class.php |-DatabaseConnect.class.php |-SystemConfig.class.php \public_html: |-header.php |-footer.php |-gencsv.php |-stat.php \css |-style.css \images index.php And the php code file that I am trying to make work is as follows: class MailParser extends SystemConfig { /* Reads the files passed line-by-line * @param $fileName */ public function readFiles($fileName){ $fileHandler = fopen($fileName,'r'); while ($line = fgets($fileHandler)) { echo $line."<br />"; } fclose($fileHandler); } /* Traverse the user specified directory * @param $dirPath */ public function traverseDirectory($dirPath) { echo $dirPath; $sentFolderPath = new SystemConfig(); $sentFolderPath->getSentMailFolder(); $totalDirPath = $dirPath."/".$sentFolderPath; echo $totalDirPath; $io=0; if ($handle = @opendir($dirPath)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { $newdir = ""; $filetext = ""; if (!is_file($dirPath."/".$file) or is_dir($dirPath) ) { $io++; $newdir.= $dirPath."/".$file."/"; print $newdir."<br />"; $this->traverseDirectory($newdir); if(is_file($dirPath.$file)) { $text = str_replace('//','/',"".$dirPath.$file."\n"); } } } } closedir($handle); } } } $rmf = new MailParser(); $rmf->traverseDirectory($_POST["dirpath"]); ?>
  12. No the back tick doesn't work. This is my script: just 2 lines to create a file in /tmp for testing #!/bin/bash sudo touch /tmp/abc in /etc/sudoers I also have an entry apache ALL=(ALL) ALL <?php $res=`/var/www/cgi-bin/newuser.sh`; echo "<br><br>File Created"; ?> And safe_mode if off in php.ini
  13. Hi all, I am trying to create a user in linux with php but its not getting created. I also added apache user in sudoers file in linux. <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <form name="form1" method="post" action="newuser.php"> <p>Login: <input name="login" type="text" id="login"> </p> <p>Nombre Completo: <input name="nombre" type="text" id="nombre"> </p> <p>Password: <input name="pwd" type="password" id="pwd"> </p> <p> <input type="submit" name="Submit" value="Crear"> </p> </form> </body> </html> <?php if (isset($_POST['login'])) { $login=$_POST['login']; $nombre=$_POST['nombre']; $passwd_crypt=crypt($_POST['pwd']); #$res='/bin/bash /var/www/cgi-bin/newuser $login "$nombre" $passwd_crypt'; $res='/var/www/cgi-bin/newuser'; echo $res; exec ("$res"); echo "<br><br>User Created"; } ?> Then I changed the code to make sure whether its really working or not by this below just to create a file but still it doesn't work. /var/www/cgi-bin/newuser sudo touch /tmp/abc Any help.
  14. Hi Currently I am doing some coding in php to match a client certifcate with an openldap certificate of that same user just to verify. I mean the user stored one copy of this certficate in openldap previously and now when he shows his certificate to server the server will then fetch that users certificate from ldap and match. and later I want to do hash. Now in ldap its stored in .der format and in browser its in .p12 So what I am doing is as below: <?php $HASH_ALG='md5'; include_once '../ldapconnect.php'; ////////////////////////////////////////////////////////////////////////////////// //Reading the client certificate from web server $loginCert = openssl_x509_read ($_SERVER["SSL_CLIENT_CERT"]); //convert the certificate into string $pemb = chunk_split(base64_encode($loginCert), 64, "\n"); $pemb = "-----BEGIN CERTIFICATE-----\n".$pemb."-----END CERTIFICATE-----\n"; openssl_x509_export($pemb,$cert_pemb_string); $login_cert_hash = hash ($HASH_ALG, $cert_pemb_string); echo "Browser HASH= ". $login_cert_hash; echo "<br />"; /////////////////////////////////////////////////////////////////////////////////// $userName=$_SERVER["SSL_CLIENT_S_DN_CN"]; $filter="(cn=$userName)"; $justthese = array ("userCertificate;binary"); $result=ldap_search ($ldapconnect,"ou=people,dc=example,dc=com", $filter); $entry = ldap_first_entry($ldapconnect,$result); $attributes= ldap_get_attributes($ldapconnect,$entry); $cert_der =$attributes["userCertificate;binary"][0]; // converting der to pem $pem = chunk_split(base64_encode($cert_der), 64, "\n"); $pem = "-----BEGIN CERTIFICATE-----\n".$pem."-----END CERTIFICATE-----\n"; openssl_x509_export($pem,$cert_pem_string); $ldap_cert_hash = hash($HASH_ALG, $cert_pem_string); Now finally I will match $login_cert_hash and $ldap_cert_hash but problem is its always giving me the same output of hash even if I manually change the certificate of client to make sure. I don't get it. Thank in advance.
  15. this should be echo "URL = ". $info[$i]["labeleduri"][0] . "<br>";
  16. Hello all, I didn't know under which topic to post the problem in this forum so posted here. If u feel to move it to any other section then please. THe problem is I have implemented a test ldap server and can communicating with it with PHP. I can fetch all data from openldap except one which is labelURI under objectClass inetOrgPerson. I dont know why. In errro log its giving me this error: PHP Notice: Undefined index: labeledURI in /var/www/html/peer2/test.php on line 17 and below is my code and ldif file of openldap: ## DEFINE DIT ROOT/BASE/SUFFIX #### ## uses RFC 2377 format ## dcObject is an AUXILLIARY objectclass and MUST ## have a STRUCTURAL objectclass (organization in this case) ## this is an ENTRY sequence and is preceded by a BLANK line dn: dc=example,dc=com dc: example description: test domain objectClass: dcObject objectClass: organization o: example, Inc. ## FIRST Level hierarchy - people ## uses mixed upper and lower case for objectclass ## this is an ENTRY sequence and is preceded by a BLANK line dn: ou=people, dc=example,dc=com ou: people description: All people in organisation objectclass: organizationalunit ## SECOND Level hierarchy ## ADD a single entry under FIRST (people) level ## this is an ENTRY sequence and is preceded by a BLANK line ## the ou: Project Management is the department name dn: cn=J Stefan,ou=people,dc=example,dc=com objectclass: inetOrgPerson cn: J Stefan homephone: 514-111-2222 mail: j_stefan@example.com labeledURI: http://p2.example.com/~j_stefan description: Group Owner ou: Project Management dn: cn=John Abrus,ou=people,dc=example,dc=com objectclass: inetOrgPerson cn: John Abrus homephone: 514-443-1163 mail: jabrus@example.com labeledURI: http://p1.example.com/~jabrus description: Group Member PHP coding part: <?php $conn= ldap_connect ("ldapserver-ip-here") or die ("cant connect"); $r = ldap_bind($conn) or die ("could not bind"); $result=ldap_search ($conn,"ou=people,dc=example,dc=com", "(cn=*)") or die ("sorry"); $info = ldap_get_entries($conn,$result); for ($i=0;$i<$info["count"];$i++) { echo "CN = ". $info[$i]["cn"][0] . "<br>"; echo "Desc = ". $info[$i]["description"][0] . "<br>"; echo "Mail= ". $info[$i]["mail"][0] . "<br>"; echo "URL = ". $info[$i]["labeledURI"][0] . "<br>"; echo "phone = ". $info[$i]["homephone"][0] . "<br>"; } echo "number of entries found=" . ldap_count_entries($conn,$result) . "<p>"; ldap_close($conn); ?> Any suggestions. Thanks in advance.
  17. Thanks a lot for all the support. Its solved now. What I did was first set the ORACLE_HOME environment variable and then recompile the PHP again with that ORACLE_HOME and set the ORACLE_HOME variable in /etc/profile for all users. The DBA team did some tweaking on tnsnames.ora and it started working.
  18. It displays nothing. It doesn't even echo the word 'ORACLE_HOME='
  19. HI, I used your code and now its showing no warnings or error in browser. But in apache log I am getting this: [Tue Jun 30 18:06:06 2009] [error] [client 10.10.x.xx] PHP Warning: ocilogon() [<a href='function.ocilogon'>function.ocilogon</a>]: OCIEnvNlsCreate() failed. There is something wrong with your system - please check that ORACLE_HOME is set and points to the right directory in /usr/local/apache/htdocs/test.php on line 13 Code: <?php $db = " (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP) (HOST = 10.10.xx.xx) // your serverIP (PORT = 1521) ) (CONNECT_DATA =(SID = PRODQC)) )"; $conn = OCILogon("user", "password", $db) or die (ocierror()); What is difference between SID and SERVICE_NAME in CONNECT_DATE section?
  20. And my test code: <?php $user="user"; $password="passwd"; $conn =OCILogon($user, $password, "10.10.xx.xx/testms"); if ($conn) { echo "Success"; }else{ $e = oci_error(); echo $e; } ?>
  21. Yes, I restarted the service but still same. From browser it gives message like: Warning: ocilogon() [function.ocilogon]: OCIEnvNlsCreate() failed. There is something wrong with your system - please check that ORACLE_HOME is set and points to the right directory in /usr/local/apache/htdocs/oratest.php on line 7 And if run from shell then it gives this: Warning: ocilogon(): ORA-12154: TNS:could not resolve the connect identifier specified in /usr/local/apache/htdocs/oratest.php on line 7 Now what is this TNS and does this means anything needs to be done like database settings in some oracle files? Further I can't download the instant client as its giving me errors every time. One more thing, what the diff between OCILogon and oci_pconnect?
  22. Hello, Thanks for your replies. I already set the apache user under oracle group. [root@localhost ~]# groups daemon daemon : daemon bin adm lp oinstall [root@localhost ~]# groups oracle oracle : oinstall dba Oracle users .bash_profile sample export ORACLE_BASE=/opt/oracle export ORACLE_HOME=/opt/oracle/product/client export LD_LIBRARY_PATH=$ORACLE_HOME/lib alias cls='clear' PATH=$PATH:$ORACLE_HOME/bin export PATH
  23. Ok I am confused. The oracle team of ours installed the client and my part was to compile apache,php with mysql and oracle support which I did as my post. Now what is instant client and how to use that to connect to oracle server? Whats the prob with the below fucntion in code? I also made daemon user a member of group oinstall but still doesn't work.
  24. One more thing. If I run it from shell then it gives me this message Warning: ocilogon(): ORA-12162: TNS:net service name is incorrectly specified in /usr/local/apache/htdocs/oratest.php on line 2 The code is: <?php $conn=OCILogon("",""); ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.