<?php
include ('header.php');
/**********************************************************************
* Copyright notice Ja2BU 1.1.
*
* (c) 2011 Predrag Rukavina - admin[at]phpform[dot]net
* All rights reserved
*
* This script is part of the Ja2BU project.
* The Ja2BU project is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
* This copyright notice MUST appear in all copies of the script!
************************************************************************/
?>
<div id=vforms>
<div id="cconfig">New Article</div>
<?php
if(isset($_POST['query'])) {
$cuniver = $_POST['bname'];
if(get_magic_quotes_gpc()) {
$main = stripslashes($_POST['main']);
$univer = stripslashes($_POST['univer']);
$bname = stripslashes($_POST['bname']);
$usercc = stripslashes($_POST['usercc']);
$amess = stripslashes($_POST['amess']);
$amess = htmlspecialchars($amess);
$hashtags = htmlspecialchars($hashtags);
} else {
$main = $_POST['main'];
$univer = $_POST['univer'];
$bname = $_POST['bname'];
$usercc = $_POST['usercc'];
$amess = $_POST['amess'];
$amess = htmlspecialchars($amess);
$hashtags = $_POST['hashtags'];
}
if(strlen($bname) < 3) {
echo "<center>Field must be at least 3 characters long:<a href='javascript:history.go(-1)'>Go Back</a></center></div>";
include ('footer.php');
die();
}
if(strlen($bname) > 150) {
echo "<center>Max Characters Field: 150<a href='javascript:history.go(-1)'>Go Back</a></center></div>";
include ('footer.php');
die();
}
if(strlen($amess) < 10) {
echo "<center>Field description must be at least 10 characters long:<a href='javascript:history.go(-1)'>Go Back</a></center></div>";
include ('footer.php');
die();
}
if(strlen($amess) > 25800) {
echo "<center>Max Characters Field Description.<a href='javascript:history.go(-1)'>Go Back</a></center></div>";
include ('footer.php');
die();
}
if(strlen($hashtags) < 3) {
echo "<div id='errorpost'>$lang[POSTERR0] </div>";
$error12 = "color:#cc0000";
include ('form.php');
$smarty->display('footer.php');
die();
}
$zero = '0';
$admin_image = 'admin.jpg';
$time = date("Y-m-d H:i:s");
$helper = preg_replace('/([?,\/,|,",:,%,*,(,),[,\,\],\,])/',"-",$btextyx);
$helper = urlencode($helper);
$commas = array(" ,",", ");
$replaced = array(",",",");
$hasher = str_replace($commas,$replaced,$hashtags);
$sql = $conn->Prepare('INSERT INTO article (main,univer,buserid,buser,btexty,tags,bhelper,bimgs,bdate,bamess) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)');
if($conn->Execute($sql,array($main,$univer,$zero,$usercc,$bname,$hasher,$helper,
$admin_image,$time,$amess)) === false) {
print '<br /><div id="error">error inserting[1]: '.$conn->ErrorMsg().'</div><br />';
}
$amess = htmlspecialchars_decode($amess);
$amess = strip_tags($amess);
$sql2 = $conn->Prepare('INSERT INTO onewse (oniver,otexty,ohelper,oamess,odate) VALUES (?, ?, ?, ?, ?)');
if($conn->Execute($sql2,array($univer,$bname,$helper,$amess,$time)) === false) {
print '<br /><div id="error">error inserting[1]: '.$conn->ErrorMsg().'</div><br />';
}
$getags = explode(',', $hashtags);
foreach ($getags as $value) {
$value = trim($value);
$sql1 = $conn->Prepare('INSERT INTO catags (hashtags,nofhash) VALUES (?, ?) on duplicate key UPDATE nofhash = nofhash + ?');
if($conn->Execute($sql1,array($value,'1','1')) === false) {
print '<br /><div id="error">error inserting[1]: '.$conn->ErrorMsg().'</div><br />';
}}
$conn->Close();
?>
<head>
<script type="text/javascript">
<!--
function delayer(){
window.location = "addarticle.php"
}
//-->
</script>
<link type="text/css" href="style.css" rel="stylesheet" />
</head>
<body onLoad="setTimeout('delayer()', 10000)">
<div class="redir">
<center><font style="font-family:verdana;font-size:13px;color:#555;">You will be automatically redirected to the "Submit Article" in 10 seconds<br /><br />
<a href="<?php echo $sitepath; ?>/article.php?name=<?php echo $univer ?>">View "<?php echo stripslashes($bname); ?>"</font></center>
</div>
<?php
} else {
$univer = date("Yhis");
?>
<h3>New Article [Admin Mode]</h3>
<form action="addarticle.php" method="post">
<input type="hidden" name="univer" value="<?php echo $univer; ?>" />
<?php
$brecordSet = &$conn->Execute('SELECT * FROM cpadmin LIMIT 1');
if(!$brecordSet) print $conn->ErrorMsg();
else
while(!$brecordSet->EOF) {
$ausername = $brecordSet->fields['ausername'];
echo " <input type='hidden' name='usercc' value='".$ausername."'>";
$brecordSet->MoveNext();
}
?>
Select:
<br />
<select name="main" id="incc" />
<option value="1">Question</option>
<option value="2">Snippet</option>
</select>
<br />
<br />
Title:
<br />
<input type="text" name="bname" id="incc" />
<br />
<br />
Description:
<br />
<textarea name="amess" style="width:564px;height:455px;"></textarea><br />
<br />
<br />
Tags: [separated by commas]
<br />
<input id="incc" type="text" name="hashtags" />
<br />
<br />
<input class="incc" type="submit" value="Submit" name="query" style="color:#555;border:1px solid #ccc;background:#f8f8f8" />
</form>
<?php
$conn->Close();
}
?>
</div>
<?php
include ('footer.php');
######################################
##addarticle.php 1.1.##
######################################
?>