Wed Jan 30, 2013 11:47 pm
<?php
$html_title ="PHPBB3 Styles database";
include '../head_handler.php';
?>
<script language="javascript" type="text/javascript">
function validateForm()
{
document.getElementById('errorDiv').innerHTML="";
var file = document.getElementById('file').value;
var name = document.getElementById('STYLE_NAME').value;
var author = document.getElementById('AUOTHER').value;
var largeimage = document.getElementById('largeimage').value;
var styleTypeIndex = document.getElementById('STYLE_TYPE').selectedIndex;
var styleimage = document.getElementById('styleimage').value;
var type_vr = document.getElementById('TYPE_VR').value;
var template_category = document.getElementById('template_category_id').selectedIndex;
//alert(template_category);
var style_ver = document.getElementById('STYLE_VR').value;
var errorDiv = document.getElementById('errorDiv');
if(name== null || name=="")
{
//alert("Please enter your name");
errorDiv.innerHTML = "<li><font color='red'>Please enter style name</font></li>";
return false;
}
/* if(template_category==0)
{
//alert("Please enter the message");
errorDiv.innerHTML = "<li><font color='red'>Please specify your style category</font></li>";
return false;
}*/
if(type_vr== null || type_vr=="")
{
//alert("Please enter the message");
errorDiv.innerHTML = "<li><font color='red'>Please specify style type version.</font></li>";
return false;
}
if(style_ver== null || style_ver=="")
{
//alert("Please enter the message");
errorDiv.innerHTML = "<li><font color='red'>Please specify your style version.</font></li>";
return false;
}
if(author == null || author == "" )
{
errorDiv.innerHTML = "<li><font color='red'>Please enter author name</font></li>";
return false ;
}
if(file == null || file =="")
{
//alert("Please enter email address");
errorDiv.innerHTML = "<li><font color='red'>Please specify your style file location</font></li>";
return false;
}
if(styleimage == null || styleimage=="")
{
//alert("Please enter the subject");
errorDiv.innerHTML = "<li><font color='red'>Please specify your style screenshot location</font></li>";
return false;
}
if(largeimage== null || largeimage=="")
{
//alert("Please enter the message");
errorDiv.innerHTML = "<li><font color='red'>Please specify your style large screenshot location</font></li>";
return false;
}
}
</script>
<div>
<div id="errorDiv"></div>
<form action="#" name="PHPBB3_UPLOAD" method="post" ENCTYPE="multipart/form-data" onsubmit="return validateForm();">
<b>Style Name:</b> <input type="text" maxlength="40" size="40" name="STYLE_NAME" id="STYLE_NAME" /><br/>
<b>Style Type:</b>
<select name="STYLE_TYPE" id="STYLE_TYPE" >
<?php
include 'Controllers/typeshowcontrol.php';
echo $typescontent;
?>
</select><br/>
<b>Style Category:</b>
<?php
include 'Categoryselector.php'; ?><br />
<b>Type Version (mm.x):</b> <input type="text" maxlength="10" size="10" id="TYPE_VR" name="TYPE_VR" /><br/>
<b>Style Version (mm.x):</b> <input type="text" maxlength="10" size="10" id="STYLE_VR" name="STYLE_VR" /><br/>
<b>Auother:</b> <br/><textarea rows="6" cols="20" name="AUOTHER" id="AUOTHER"></textarea><br/>
Style File: <input type="file" id="file" name="file" size="40"> <br/>
Style Screenshot: <input type="file" id="styleimage" name="styleimage" size="40"><br />
Large Screenshot: <input type="file" name="largeimage" id="largeimage" size="40"><br/><input type="submit" value="Upload">
<input type="hidden" name="booleaninsert" value="yes"/>
</form>
<?php
if(isset($_POST['booleaninsert']))
{
$flag=$_POST['booleaninsert'];
if($flag=="yes")
{
include('Controllers/styleinsertcontrol.php');
}
}
?>
</div>
</HTML>
if(isset($_POST['booleaninsert']))
{
$flag=$_POST['booleaninsert'];
if($flag=="yes")
{
include('Controllers/styleinsertcontrol.php');
}
}
<?php
$typescontent=" ";
$currentType="";
if(!isset($TYPE_ID))
{
$TYPE_ID="-1";
}
$alltypes=GetAllTypes();
$num=mysql_num_rows( $alltypes);
if($num>0)
{
while($num>0)
{
$newoption=mysql_result($alltypes,$num-1,"TYPE_NAME");
$id=mysql_result($alltypes,$num-1,"ID");
if($id==$TYPE_ID)
{
$currentType=$newoption;
$typescontent.="<option value='$id' selected='selected'>$newoption</option>";
}
else
{
$typescontent.="<option value='$id' >$newoption</option>";
}
$num--;
}
}
?>
<?php
include('model/stylesinsert.php');
?>
<?php
$STYLE_NAME=$_POST['STYLE_NAME'];
$STYLE_TYPE=$_POST['STYLE_TYPE'];
$STYLE_VR=$_POST['STYLE_VR'];
$AUOTHER=$_POST['AUOTHER'];
$TYPE_VR=$_POST['TYPE_VR'];
$category=$_POST['template_category_id'];
if(isset($_POST['insertype']))
{
$STYLE_ID=$_POST['STYLE_ID'];
UpdateStyle($STYLE_ID,$STYLE_NAME,$STYLE_TYPE,$STYLE_VR,$TYPE_VR,$AUOTHER,$category);
}
else
{
$result=GetTypeByID($STYLE_TYPE);
$TYPE_NAME=mysql_result($result,0,"TYPE_NAME");
$allowed_ext = "png";
$max_size = "50000";
$max_height = "200";
$max_width = "200";
$stylepath="../stylesdata/".$TYPE_NAME."/uploads";
$imagespath="../stylesdata/".$TYPE_NAME."/images";
$filecheck="";
$imagecheck="";
if(is_uploaded_file($_FILES['file']['tmp_name']))
{
$filecheck="ok";
}
$ok = checkExtension(pathinfo($_FILES['styleimage']['name']),$allowed_ext);
$large = checkExtension(pathinfo($_FILES['largeimage']['name']),$allowed_ext);
print "Your file has been uploaded successfully! Yay!";
if ($ok == "1"&& $large=="1") {
if($_FILES['styleimage']['size'] > $max_size)
{
print "File size is too big!";
die('50KB is the max size');
exit;
}
// Check Height & Width
if ($max_width && $max_height) {
list($width, $height, $type, $w) = getimagesize($_FILES['styleimage']['tmp_name']);
if($width > $max_width || $height > $max_height)
{
print "Image height and/or width are too big!";
die('mage height and/or width are too big!');
exit;
}
}
// The Upload Part
if(is_uploaded_file($_FILES['styleimage']['tmp_name'])&&is_uploaded_file($_FILES['largeimage']['tmp_name']))
{
$imagecheck="ok";
}
if($imagecheck=="ok"&&$filecheck=="ok")
{
InsertStyle($STYLE_NAME,$STYLE_TYPE,$STYLE_VR,$TYPE_VR,$AUOTHER,$category);
$STYLE_ID=GetMaxStyleID();
$extension = pathinfo($_FILES['file']['name']);
$extension = strtolower($extension['extension']);
move_uploaded_file($_FILES['file']['tmp_name'],$stylepath.'/'.$STYLE_NAME."_".$STYLE_ID.".".$extension);
include ('lib/pear/zip.php');
// Create instance of Archive_Zip class, and pass the name of our zipfile
$zipfile = New Archive_Zip($stylepath.'/zips/'.$STYLE_NAME."_".$STYLE_ID.'.zip');
// Create a list of files and directories
$list = array($stylepath.'/'.$STYLE_NAME."_".$STYLE_ID.".".$extension);
// Create the zip file
$zipfile->create($list);
$extension = pathinfo($_FILES['styleimage']['name']);
$extension = strtolower($extension['extension']);
move_uploaded_file($_FILES['styleimage']['tmp_name'],$imagespath.'/'.$STYLE_ID.".".$extension);
move_uploaded_file($_FILES['largeimage']['tmp_name'],$imagespath.'/'.$STYLE_ID."_2.".$extension);
print "Your Image has been uploaded successfully! Yay!";
}
# $STYLE_ID=GetMaxStyleID()-1;
# mysql_select_db("three",$link);
# InsertIntoPhpbb3demos($STYLE_ID,$STYLE_NAME);
}
else {
print "Incorrect file extension (RAR,or ZIP only) !";
print "Image should be PNG format !";
}
}
function checkExtension($extension,$allowed_ext){
//$extension = pathinfo($_FILES['styleimage']['name']);
$ok ="0";
$extension = strtolower($extension['extension']);
$allowed_paths = explode(", ", $allowed_ext);
for($i = 0; $i < count($allowed_paths); $i++) {
if ($allowed_paths[$i] == "$extension") {
$ok = "1";
}
}
return $ok;
}
?>
<?php
function InsertStyle($STYLE_NAME,$STYLE_TYPE,$STYLE_VR,$TYPE_VR,$AUOTHER,$category)
{
$date = date("Y-m-d");
$sqlQuery="insert into styles VALUES (0,'$STYLE_TYPE','$STYLE_NAME','$STYLE_VR',0,0,'$date','$TYPE_VR','$AUOTHER','$date','$category');" ;
$result=mysql_query($sqlQuery);
echo mysql_error();
}
function UpdateStyle($STYLE_ID,$STYLE_NAME,$TYPE_ID,$STYLE_VR,$TYPE_VR,$AUOTHER,$category)
{
$date = date("Y-m-d");
$sqlQuery="update styles set STYLE_NAME='$STYLE_NAME', ID=$TYPE_ID , STYLE_VR='$STYLE_VR',TYPE_VR='$TYPE_VR', AUOTHER='$AUOTHER'
, UPDATE_DATE=$date ,CATEGORY='$category' where STYLE_ID=$STYLE_ID;";
mysql_query($sqlQuery);
echo mysql_error();
}
function GetMaxStyleID()
{
$sqlQuery="select max(STYLE_ID) from styles;" ;
$result=mysql_query($sqlQuery) or die("Error in database get Max ID of phpbb3styles");
echo mysql_error();
$STYLE_ID= mysql_result($result,0,0);
return $STYLE_ID;
}
function InsertIntodemos($STYLE_ID,$STYLE_NAME)
{
$sqlQuery="Insert into styles values($STYLE_ID,'$STYLE_NAME','$STYLE_NAME',1,'$STYLE_ID',$STYLE_ID,$STYLE_ID);" ;
mysql_query($sqlQuery) ;
echo mysql_error();
}
function InsertType($TYPE)
{ $sqlQuery="Insert into type values(0,'$TYPE');" ;
mysql_query($sqlQuery) or die("error in new type insertion");
echo mysql_error();
echo "<br><b>New style type inserted and it is $TYPE</b>";
}
function GetTypeByID($ID)
{
$query="Select * from type where ID=$ID;";
$results=mysql_query($query);
echo mysql_error();
return $results;
}
?>
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.