Location: PHPKode > scripts > OekakiPoteto > oekakipoteto/getoekakibbs.php
<?
//OekakiBBS parse code by Marcello (http://www.cellosoft.com). Modified by RanmaGuy. Used with permission. This file is not to be used with any other script other than OekakiPoteto.

include('dbconn.php');

$buffer = $HTTP_RAW_POST_DATA;

$thecheck = "0";

$i=0;
 
$start = strpos( $buffer, "Content-type:");
 
$middle=0;$end=0;
 
while ($start) {
 

$end = strpos( $buffer, "Content-type:", $start+1);
 

$middle = strpos( $buffer, "\r", $start);
 
$type = substr( $buffer, $start+13, $middle-$start-13 );
 
$middle = strpos( $buffer, "\r", $middle+1);
 



	if ($end===false) {
 

		$end=null;
 

		$data = substr( $buffer, $middle+2);


		} else $data = substr( $buffer, $middle+2, $end-$middle-2);
 

		$start=$end;

 include('config.php');

	//get the current picture number
			if($thecheck == "0"){
			$result = mysql_query("UPDATE ".$OekakiPoteto_Prefix."oekakimisc set miscvalue=miscvalue+1 where miscname='piccount'");
			$result = mysql_query("SELECT miscname, miscvalue FROM ".$OekakiPoteto_Prefix."oekakimisc where miscname='piccount'");
			$row = mysql_fetch_array($result);
			$resno = $row[miscvalue];	

				$thecheck = 1;		

				//check if the picture is archived or not before saving
				$awrite = "false";
				while($awrite == "false"){

					$result = mysql_query("SELECT * FROM ".$OekakiPoteto_Prefix."oekakidta WHERE PIC_ID=".$resno);
					$row = mysql_fetch_array($result);
					if($row[archive] == "1"){
						//go to the next number
			$result = mysql_query("UPDATE ".$OekakiPoteto_Prefix."oekakimisc set miscvalue=miscvalue+1 where miscname='piccount'");
			$result = mysql_query("SELECT miscname, miscvalue FROM ".$OekakiPoteto_Prefix."oekakimisc where miscname='piccount'");
			$row = mysql_fetch_array($result);
			$resno = $row[miscvalue];
 	 				} else {
						$awrite = "true";
					}
				}
			}

		if($type=='image/0'){    		
			$image_filenamejpg = $OPpics.'/'.$resno.".jpg";
			$image_filename = $OPpics.'/'.$resno.".png";
				//delete existing file
				unlink($image_filename);
				if ($fp = fopen($image_filename,'wb')) {
					// Write main file
					fwrite($fp,$data);
					fclose($fp);

				if($jpgcompression == "yes"){

					//convert to JPEG
		
					$img = imagecreatefrompng($image_filename);

					imagejpeg($img,$image_filenamejpg, $jpgcompressqual);

				}
				}
		}

		if($type=='animation/'){    		
			$image_filename = $OPpics.'/'.$resno.".oeb";
				//delete existing file
				unlink($image_filename);
				if ($fp = fopen($image_filename,'wb')) {
				// Write main file
				fwrite($fp,$data);
				fclose($fp);
			}
		}

	

		
}

	if($mode=="norm"){
			$result = mysql_query("DELETE from ".$OekakiPoteto_Prefix."oekakicmt where PIC_ID='$resno'");
			$result = mysql_query("DELETE from ".$OekakiPoteto_Prefix."oekakidta where PIC_ID='$resno'");
			$thetime = time() - $edittimes;
			//database insertion
			$insert = "false";
			while($insert == "false"){

			$result = mysql_query("INSERT into ".$OekakiPoteto_Prefix."oekakidta SET usrname='$username',postdate=NOW(),hostname='$hostname', PIC_ID='$resno', IP='$REMOTE_ADDR',datatype='1', edittime='$thetime'");
			$result = mysql_query("SELECT count(*) as rowcount FROM ".$OekakiPoteto_Prefix."oekakidta WHERE PIC_ID='$resno'");
				$therow = mysql_fetch_array($result);
				if($therow[rowcount] == 1){
					$insert = "true";
				}
			}

			mysql_close();
		}


	if($mode=="ani"){
			$result = mysql_query("DELETE from ".$OekakiPoteto_Prefix."oekakicmt where PIC_ID='$resno'");
			$result = mysql_query("DELETE from ".$OekakiPoteto_Prefix."oekakidta where PIC_ID='$resno'");
			$thetime = time() - $edittimes;
			//database insertion
			$insert = "false";
			while($insert == "false"){
				$result = mysql_query("INSERT into ".$OekakiPoteto_Prefix."oekakidta SET usrname='$username',postdate=NOW(),hostname='$hostname', PIC_ID='$resno', IP='$REMOTE_ADDR',datatype='1', animation='1', edittime='$thetime'");
				$result = mysql_query("SELECT count(*) as rowcount FROM ".$OekakiPoteto_Prefix."oekakidta WHERE PIC_ID='$resno'");
				$therow = mysql_fetch_array($result);
				if($therow[rowcount] == 1){
					$insert = "true";
				}
			}
				
			
			mysql_close();
		}
?>
Return current item: OekakiPoteto