PDA

View Full Version : PHP script to c++



smaakage
10-21-2005, 04:35 PM
Hello..

I have this php code that i user on my server, but i wont it to be a c++ code.

So if there is anyone that will make this code for me i will be very happy.


<?
$mysql_host = "localhost";
$mysql_user = "root";
$mysql_pw = "d64";
$mysql_db = "test";

$indbakkefolder = "/home/in/";
$readfolder = "/home/read";
$tb = "inbox";

$conn = mysql_connect("$mysql_host","$mysql_user","$mysql_pw");
mysql_select_db("$mysql_db");

$folder = "".$indbakkefolder."";
if ($handle = opendir($folder)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
if (is_dir($file)) {
} else {
$files[] = $file;
}
}
}
}
$antal = 0;
$count = count($files);
$tal = -1;
while($tal < $count-1) {
$tal++;
$filename = $folder."/".$files[$tal];
$handle = fopen($filename, "r");
$contents = fread($handle, filesize($filename));
fclose($handle);

$date = explode("Date/time: ", $contents);
$date2 = explode(" ", $date[1]);
$dato = $date2[0];
$tid = $date2[1];
if($debug == 1) {
echo "Dato: $dato<br>";
echo "Tid: $tid<br>";
}

$sender = explode("Sender: ", $contents);
$sender1 = explode(" ", $sender[1]);
$afsender = $sender1[0];
$afsender = str_replace("+45", "", $afsender);
if($debug == 1) {
echo "Afsender: $afsender<br>";
}
$class = explode(" ", $tekst);
if($class[0] == "Web") {
$tekst = ereg_replace("web ", "", $tekst);
$setclasse = "web";
}
$text = explode("Text:", $contents);
$tekst = ereg_replace("\n", "", $text[1]);
if($debug == 1) {
echo "Tekst: $tekst<br>";
}

if(mysql_query("INSERT INTO $tb (dato, tid, message, class, fra) VALUES ('$dato','$tid','$tekst','$setclase','$afsender')") OR DIE("FEJL ".mysql_error()."")) {

$filename2 = "".$readfolder."/".$files[$tal]."";
touch($filename2);
if (is_writable($filename2)) {

if (!$handle = fopen($filename2, 'a')) {
if($debug == 1) {
echo "Kunne ikke åbne filen ($filename)";
}
exit;
}
if (fwrite($handle, $contents) === FALSE) {
if($debug == 1) {
echo "Kunne ikke skrive til filen ($filename)";
}
exit;
}

fclose($handle);
unlink($filename);

} else {
if($debug == 1) {
echo "Der kunne ikke skrives til den nye fil";
}
}

}
$antal++;

}
echo "Done".$antal." add.";

?>

loko
10-21-2005, 07:04 PM
You want a cgi version of that or you want a stand alone app? Will this be free? PM me.

smaakage
10-23-2005, 12:24 PM
Hi..

I will like if the php to be translate to a c++ code.

hartwork
10-28-2005, 04:40 PM
i think converting this to c/c++ is no good idea: php has the means to make this job simple but it is much more complex in c/c++. why do you want to have it converted?

italiano40
11-06-2005, 01:11 PM
tell me what you want the program to do i think i could make it from their, because i don't know PHP