<?php
require_once "../../maincore.php";
require_once THEMES."templates/header.php";
require_once INFUSIONS."ds_board_panel/infusion_db.php";
if (file_exists(INFUSIONS."ds_board_panel/locale/".$settings['locale'].".php")) {
include INFUSIONS."ds_board_panel/locale/".$settings['locale'].".php";
} else {
include INFUSIONS."ds_board_panel/locale/Russian.php";
}
if (!iMEMBER) { redirect("../../index.php"); }
$submit_info = "";
if (isset($_GET['status']) && !isset($message)) {
if ($_GET['status'] == "del") {
$message = $locale['dsb612'];
}
if ($message) { echo "<div class='admin-message'>".$message."</div>\n"; }
}
if (isset($_POST['delete_ds_board']) && isset($_POST['ds_board_id']) && isnum($_POST['ds_board_id'])) {
$result = dbquery("DELETE FROM ".DB_DS_BOARD." WHERE ds_board_id='".$_POST['ds_board_id']."'");
$result = dbquery("DELETE FROM ".DB_COMMENTS." WHERE comment_item_id='".$_POST['ds_board_id']."' and comment_type='B'");
$result = dbquery("DELETE FROM ".DB_RATINGS." WHERE rating_item_id='".$_POST['ds_board_id']."' and rating_type='B'");
redirect(FUSION_SELF."?status=del");
}
if (isset($_POST['submit_ds_board']) && $_POST['ds_board_subject'] != "" && $_POST['ds_board_snippet'] != "") {
if (isset($_POST['ds_board_id'])) {$submit_info['ds_board_id'] = $_POST['ds_board_id'];}
$submit_info['ds_board_cat'] = isnum($_POST['ds_board_cat']) ? $_POST['ds_board_cat'] : "0";
$submit_info['ds_board_subject'] = stripinput($_POST['ds_board_subject']);
$submit_info['ds_board_snippet'] = descript($_POST['ds_board_snippet']);
$submit_info['ds_board_body'] = stripinput($_POST['ds_board_body']);
$submit_info['ds_board_email'] = trim(stripinput($_POST['ds_board_email']));
$submit_info['ds_board_tel'] = stripinput($_POST['ds_board_tel']);
$ds_board_valid_day = isNum($_POST['ds_board_valid_day']) ? $_POST['ds_board_valid_day'] : 0;
$ds_board_valid_month = isNum($_POST['ds_board_valid_month']) ? $_POST['ds_board_valid_month'] : 0;
$ds_board_valid_year = isNum($_POST['ds_board_valid_year']) ? $_POST['ds_board_valid_year'] : 0;
$ds_board_valid_till = mktime(0, 0, 0, $ds_board_valid_month, $ds_board_valid_day, $ds_board_valid_year);
if ($ds_board_valid_till < time()) {$ds_board_valid_till = 0;}
$submit_info['ds_board_valid_till'] = $ds_board_valid_till;
$submit_info['ds_board_breaks'] = (isset($_POST['line_breaks']) ? "y" : "n");
$result = dbquery("INSERT INTO ".DB_SUBMISSIONS." (submit_type, submit_user, submit_datestamp, submit_criteria) VALUES ('b', '".$userdata['user_id']."', '".time()."', '".addslashes(serialize($submit_info))."')");
add_to_title($locale['global_200'].$locale['dsb225']);
opentable($locale['dsb225']);
if (isset($_POST['ds_board_id']))
{echo "<div style='text-align:center'><br />\n".$locale['dsb219']." ".$locale['dsb611']."<br /><br />\n";
} else {
echo "<div style='text-align:center'><br />\n".$locale['dsb219']." ".$locale['dsb610']."<br /><br />\n";}
echo "<a href='ds_board_submit.php'>".$locale['dsb220']."</a><br /><br />\n";
echo "<a href='../../index.php'>".$locale['dsb204']."</a><br /><br />\n</div>\n";
closetable();
} else {
if (isset($_POST['preview_ds_board'])) {
$ds_board_cat = isnum($_POST['ds_board_cat']) ? $_POST['ds_board_cat'] : "0";
$ds_board_subject = stripinput($_POST['ds_board_subject']);
$ds_board_snippet = stripslash($_POST['ds_board_snippet']);
$ds_board_body = stripinput($_POST['ds_board_body']);
$ds_board_email = trim(stripinput($_POST['ds_board_email']));
$ds_board_tel = stripinput($_POST['ds_board_tel']);
$ds_board_valid_day = isNum($_POST['ds_board_valid_day']) ? $_POST['ds_board_valid_day'] : 0;
$ds_board_valid_month = isNum($_POST['ds_board_valid_month']) ? $_POST['ds_board_valid_month'] : 0;
$ds_board_valid_year = isNum($_POST['ds_board_valid_year']) ? $_POST['ds_board_valid_year'] : 0;
$ds_board_valid_till = mktime(0, 0, 0, $ds_board_valid_month, $ds_board_valid_day, $ds_board_valid_year);
if ($ds_board_valid_till < time()) {
$ds_board_valid_till = 0;
}
if ($ds_board_valid_till == 0) {
$valid_till = $locale['dsb430'];
} else {
$valid_till = date("d.m.Y", $ds_board_valid_till);
};
$breaks = (isset($_POST['line_breaks']) ? " checked='checked'" : "");
opentable($ds_board_subject);
echo (isset($_POST['line_breaks']) ? nl2br($ds_board_snippet) : $ds_board_snippet);
closetable();
opentable($locale['dsb457']);
echo "<table><tr>";
if ($ds_board_body) {echo "<td class='tbl'><b>".$locale['dsb435']."</b> ".$ds_board_body."</td>\n";}
echo "<td class='tbl'><b>".$locale['dsb429']."</b> ".$valid_till."</td></tr><tr>\n";
if ($ds_board_email) {echo "<td class='tbl'><b>".$locale['dsb436']."</b> ".hide_email($ds_board_email)."</td>\n";}
if ($ds_board_tel) {echo "<td class='tbl'><b>".$locale['dsb437']."</b> ".$ds_board_tel."</td>\n";}
echo "</tr></table>\n";
closetable();
tablebreak();
} else {
if ((isset($_GET['action']) && $_GET['action'] == "edit") && (isset($_POST['ds_board_id']) && isnum($_POST['ds_board_id'])) || (isset($_GET['ds_board_id']) && isnum($_GET['ds_board_id']))) {
$result = dbquery("SELECT * FROM ".DB_DS_BOARD." WHERE ds_board_id='".(isset($_POST['ds_board_id']) ? $_POST['ds_board_id'] : $_GET['ds_board_id'])."' && ds_board_name='".$userdata['user_id']."'");
if (dbrows($result)) {
$data = dbarray($result);
$ds_board_cat = $data['ds_board_cat'];
$ds_board_subject = $data['ds_board_subject'];
$ds_board_snippet = stripslash($data['ds_board_snippet']);
$ds_board_body = $data['ds_board_article'];
$ds_board_email = $data['ds_board_email'];
$ds_board_tel = $data['ds_board_tel'];
$ds_board_valid_till = $data['ds_board_valid_till'];
$ds_board_valid_day = date("d", $ds_board_valid_till);
$ds_board_valid_month = date("m", $ds_board_valid_till);
$ds_board_valid_year = date("Y", $ds_board_valid_till);
$breaks = $data['ds_board_breaks'] == "y" ? " checked='checked'" : "";
} else {
redirect(FUSION_SELF);
}
} else {
if (!isset($_POST['preview_ds_board'])) {
$ds_board_cat = "0";
$ds_board_subject = "";
$ds_board_snippet = "";
$ds_board_body = "";
$ds_board_email = "";
$ds_board_tel = "";
$ds_board_valid_till = "0";
$breaks = " checked='checked'";
}
}
}
if ((isset($_POST['ds_board_id']) && isnum($_POST['ds_board_id'])) || (isset($_GET['ds_board_id']) && isnum($_GET['ds_board_id'])))
{
add_to_title($locale['global_200'].$locale['dsb224']);
opentable($locale['dsb224']);
}
else
{
add_to_title($locale['global_200'].$locale['dsb225']);
opentable($locale['dsb225']);
}
$cat_list = ""; $sel = "";
$result = dbquery("SELECT * FROM ".DB_DS_BOARD_CATS." WHERE ".groupaccess("ds_board_cat_access")." ORDER BY ds_board_cat_name");
if (dbrows($result)) {
while ($data = dbarray($result)) {
if (isset($ds_board_cat)) { $sel = $ds_board_cat == $data['ds_board_cat_id'] ? " selected" : ""; }
$cat_list .= "<option value='".$data['ds_board_cat_id']."'".$sel.">".$data['ds_board_cat_name']."</option>\n";
}
echo $locale['dsb520']."<br /><br />\n";
echo "<form name='submit_form' method='post' action='".FUSION_SELF."' onsubmit='return validateBoard(this);'>\n";
echo "<table cellpadding='0' cellspacing='0' class='center'>\n<tr>\n";
echo "<td width='100' class='tbl'>".$locale['dsb440']."</td>\n";
echo "<td class='tbl'><select name='ds_board_cat' class='textbox'>\n$cat_list</select></td>\n";
echo "</tr>\n<tr>\n";
echo "<td class='tbl'>".$locale['dsb522']."</td>\n";
echo "<td class='tbl'><input type='text' name='ds_board_subject' value='$ds_board_subject' maxlength='64' class='textbox' style='width:300px;' /></td>\n";
echo "</tr>\n<tr>\n";
echo "<td valign='top' class='tbl'>".$locale['dsb523']."</td>\n";
echo "<td class='tbl'><textarea name='ds_board_snippet' cols='60' rows='8' class='textbox' style='width:300px;'>$ds_board_snippet</textarea></td>\n";
echo "</tr>\n";
echo "<tr>\n<td valign='top' width='100' class='tbl'>".$locale['dsb435']."</td>\n";
echo "<td class='tbl'><input type='text' name='ds_board_body' value='$ds_board_body' maxlength='38' class='textbox' style='width:250px;' /></td>\n";
echo "</tr><tr>\n";
echo "<td width='100' class='tbl'>".$locale['dsb436']."</td>\n";
echo "<td class='tbl'><input type='text' name='ds_board_email' value='$ds_board_email' maxlength='38' class='textbox' style='width:250px;' /></td>\n";
echo "</tr>\n<tr>\n";
echo "<td width='100' class='tbl'>".$locale['dsb437']."</td>\n";
echo "<td class='tbl'><input type='text' name='ds_board_tel' value='$ds_board_tel' maxlength='30' class='textbox' style='width:250px;' /></td>\n";
echo "</tr>\n<tr>\n";
echo "<td valign='top' class='tbl'>".$locale['dsb429']."</td>\n";
echo "<td class='tbl'>".$locale['dsb431']." <select name='ds_board_valid_day' id='ds_board_valid_day' class='textbox'>\n";
if ($ds_board_valid_day && $ds_board_valid_till) {echo "<option value='$ds_board_valid_day'>$ds_board_valid_day</option>\n";}
echo "<option value='0'>--</option>\n";
for ($i = 1; $i <= 31; $i++) {
echo "<option value='$i'>".$i."</option>\n";
};
echo "</select>\n";
echo $locale['dsb432']." <select name='ds_board_valid_month' id='ds_board_valid_month' class='textbox'>\n";
if ($ds_board_valid_month && $ds_board_valid_till) {echo "<option value='$ds_board_valid_month'>$ds_board_valid_month</option>\n";}
echo "<option value='0'>--</option>\n";
for ($i = 1; $i <= 12; $i++) {
echo "<option value='$i'>".$i."</option>\n";
};
echo "</select>\n";
echo $locale['dsb434']." <select name='ds_board_valid_year' id='ds_board_valid_year' class='textbox'>\n";
if ($ds_board_valid_year && $ds_board_valid_till) {echo "<option value='$ds_board_valid_year'>$ds_board_valid_year</option>\n";}
echo "<option value='0'>----</option>\n";
$year = date("Y", time());
for ($i = $year; $i <= $year + 5; $i++) {
echo "<option value='$i'>".$i."</option>\n";
};
echo "</select></td>\n";
echo "</tr>\n<tr>\n";
echo "<td align='center' colspan='2' class='tbl'><br />\n";
echo "<input type='checkbox' name='line_breaks' value='yes'".$breaks." />".$locale['dsb207']."<br /><br />\n";
if ((isset($_POST['ds_board_id']) && isnum($_POST['ds_board_id'])) || (isset($_GET['ds_board_id']) && isnum($_GET['ds_board_id'])))
{
echo "<input type='hidden' name='ds_board_id' value='".(isset($_POST['ds_board_id']) ? $_POST['ds_board_id'] : $_GET['ds_board_id'])."'>";
echo "<input type='submit' name='preview_ds_board' value='".$locale['dsb200']."' class='button' />\n";
echo "<input type='submit' name='submit_ds_board' value='".$locale['dsb205']."' class='button' />\n";
echo "<input type='submit' name='delete_ds_board' value='".$locale['dsb214']."' onclick='return Deleteds_board();' class='button' />\n";
}
else
{
echo "<input type='submit' name='preview_ds_board' value='".$locale['dsb200']."' class='button' />\n";
echo "<input type='submit' name='submit_ds_board' value='".$locale['dsb225']."' class='button' />\n";
}
echo "</td>\n</tr>\n</table>\n</form>\n";
} else {
echo "<div style='text-align:center'><br />\n".$locale['dsb551']."<br /><br />\n</div>\n";
}
closetable();
}
echo "<script type='text/javascript'>
function validateBoard(frm) {
if (frm.ds_board_subject.value==\"\" || frm.ds_board_snippet.value==\"\") {
alert(\"".$locale['dsb550']."\");
return false;
}
}
function Deleteds_board() {
return confirm('".$locale['dsb451']."');}
</script>\n";
require_once THEMES."templates/footer.php";
?>
<form method="post" enctype="multipart/form-data">
File<input type="file" name="image">
<input TYPE="submit" name="upload" title="Add data to the Database" value="send"/>
</form>
<?php
// Start a session for error reporting
session_start();
// Call our connection file
require("maincore.php");
// Create connection
mysql_select_db("phpfusion") or die(mysql_error());
// Check to see if the type of file uploaded is a valid image type
function is_valid_type($file)
{
// This is an array that holds all the valid image MIME types
$valid_types = array("image/jpg", "image/jpeg", "image/bmp", "image/gif");
if (in_array($file['type'], $valid_types))
return 1;
return 0;
}
// Just a short function that prints out the contents of an array in a manner that's easy to read
// I used this function during debugging but it serves no purpose at run time for this example
function showContents($array)
{
echo "<pre>";
print_r($array);
echo "</pre>";
}
// Set some constants
// This variable is the path to the image folder where all the images are going to be stored
// Note that there is a trailing forward slash
$TARGET_PATH = "upload/";
// Get our POSTed variables
$image = $_FILES['image'];
// Sanitize our inputs
//$fname = mysql_real_escape_string($fname);
//$lname = mysql_real_escape_string($lname);
$image['name'] = mysql_real_escape_string($image['name']);
// Build our target path full string. This is where the file will be moved do
// i.e. images/picture.jpg
//$TARGET_PATH .= $image['name'];
// Make sure all the fields from the form have inputs
if ( $image['name'] == "" )
{
$_SESSION['error'] = "All fields are required";
echo "All fields are required";
exit;
}
// Check to make sure that our file is actually an image
// You check the file type instead of the extension because the extension can easily be faked
if (!is_valid_type($image))
{
$_SESSION['error'] = "You must upload a jpeg, gif, or bmp";
echo"You must upload a jpeg, gif, or bmp";
exit;
}
// Here we check to see if a file with that name already exists
// You could get past filename problems by appending a timestamp to the filename and then continuing
if (file_exists($TARGET_PATH))
{
$image['name']=time() . $image['name'];
$image['name']=str_replace(' ', '_', $image['name']);
echo $image['name'];
$TARGET_PATH .= $image['name'];
}
// Lets attempt to move the file from its temporary directory to its new home
if (move_uploaded_file($image['tmp_name'], $TARGET_PATH))
{
// NOTE: This is where a lot of people make mistakes.
// We are *not* putting the image into the database; we are putting a reference to the file's location on the server
$sql = "insert into photo_upload (photo_filename) values ('" . $image['name'] . "')";
$result = mysql_query($sql) or die ("Could not insert data into DB: " . mysql_error());
echo"Image uploaded successfully";
exit;
}
else
{
// A common cause of file moving failures is because of bad permissions on the directory attempting to be written to
// Make sure you chmod the directory to be writeable
$_SESSION['error'] = "Could not upload file. Check read/write persmissions on the directory";
exit;
}
?>
Category Forum
Modifications and Requests - 8Labels
None yet
Statistics
2 participants
Notifications
You are not receiving notifications from this thread.
Related Questions