Jump to content

tanveer

Members
  • Posts

    50
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

tanveer's Achievements

Member

Member (2/5)

0

Reputation

  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.
×
×
  • 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.