<?php
//v1.0.4 www.bcoos.net 2006/10 GPL
// www.bcoos.net 2006-09 1.0.2 GPL
//v1.2 www.exoops.info 2006/03 
// $Id: submit.php,v 1.1 2003/08/31 12:16:29 half-dead Exp $
// ------------------------------------------------------------------------- //
//               E-Xoops: Content Management for the Masses                  //
//                       < http://www.e-xoops.com >                          //
// ------------------------------------------------------------------------- //
// Original Author: James Knickelbein
// Author Website : http://www.journeymilwaukee.com
// License Type   : GPL: See /manual/LICENSES/GPL.txt
// ------------------------------------------------------------------------- //
include_once("header.php");
include_once(XOOPS_ROOT_PATH."/class/module.errorhandler.php");
include_once(XOOPS_ROOT_PATH."/class/xoopsform/formdhtmltextarea.php");
$eh     = new ErrorHandler();
$mytree = new XoopsTree($db->prefix("mylinks_cat"), "cid", "pid");
if ( !empty($_POST['submit']) ) {
        if ( !$xoopsUser && empty($mylinksConfig['anon_add']) ) {
                redirect_header(XOOPS_URL."/user.php", 2, _MUSTREGISTERFIRST);
                exit();
        }
if ( empty($_POST['submitter']) ) {
        if (!$xoopsUser) {
                $submitter = 0;
                } else {
                        $submitter = $xoopsUser->uid();
                }
        }
$cid         = intval($_POST['cid']);
$url         = formatURL($myts->makeTboxData4Save($_POST['url']));
$title       = $myts->makeTboxData4Save($_POST['title']);
$email       = $myts->makeTboxData4Save($_POST['email']);
$description = $myts->makeTboxData4Save($_POST['linkdesc']);
$date        = time();
// Check if Title exist
if ( empty($title) ) {
        $eh->show("1001");
}
// Check if URL exist
if ( empty($url) ) {
        $eh->show("1016");
}
// Check if Description exist
if ( empty($description) ) {
        $eh->show("1008");
}
        if ( $mylinksConfig['autoapprove'] == 1 ) {
                $approve = 1;
                $thanks = _THANKSSUBMIT;
                
        }else{
                $approve = 0;
                $thanks = _THANKSSUBMIT."<br />"._WHENAPPROVED."";
        }
        
$newid = $db->genId($db->prefix("mylinks_links")."_lid_seq");
$sql   = "INSERT INTO ".$db->prefix("mylinks_links")." SET
        lid=$newid,
        cid=$cid,
        title='$title',
        description='$description',
        url='$url',
        email='$email',
        submitter=$submitter,
        status=$approve,
        date=$date,
        hits=0,
        rating=0,
        votes=0";
$db->query($sql) or $eh->show("0013");
redirect_header("index.php", 2, $thanks);
exit();
} else {
        if ( !$xoopsUser && empty($mylinksConfig['anon_add']) ) {
                redirect_header(XOOPS_URL."/user.php", 2, _MUSTREGISTERFIRST);
                exit();
        }
include_once(XOOPS_ROOT_PATH."/header.php");
OpenTable();
mainheader();
if (!$xoopsUser) {
        $uid   = 0;
        $email = '';
        $lock  = 'text';
        } else {
                $uid   = $xoopsUser->uid();
                $email = $xoopsUser->getVar("email");
                $lock  = 'hidden';
        }
$disclaimer = join('', file("./cache/disclaimer.txt"));
$myts->setType('admin');
echo $myts->makeTareaData4Show($disclaimer, 1, 1, 1)."<br /><br />";
OpenTable();
?>
<h3><?php echo _MD_ADDNEWLINK;?></h3>
<form action="submit.php" method="post">
<table width="80%"><tr>
<td align="right" nowrap>*<b><?php echo _SITETITLE;?></b></td>
<td><input type="text" class="text" name="title" size="50" maxlength="100" /></td>
</tr><tr>
<td align="right" nowrap>*<b><?php echo _SITEURL;?></b></td>
<td><input type="text" class="text" name="url" size="50" maxlength="255" value="http://" /></td>
</tr><tr>
<td align="right" nowrap><b><?php echo _CATEGORY.': ';?></b></td>
<td><?php echo $mytree->makeMySelBox("title", "title");?></td>
</tr><tr>
<td align="right" nowrap><b><?php echo _CONTACTEMAIL;?></b></td>
<td><input type="<?php echo $lock;?>" name="email" value="<?php echo $email;?>" size="50" maxlength="60" /><?php echo $email;?></td>
</tr><tr>
<td align="right" valign="top" nowrap>*<b><?php echo _DESCRIPTION.':';?></b></td>
<td>
<?php
$desc = new XoopsFormDhtmlTextArea('', 'linkdesc', '', 10, 50);
echo $desc->render();
?>
</td>
</tr>
</table>
<div align="center">
<input type="hidden" name="submitter" value="<?php echo $uid;?>" />
<input type="submit" class="button" name="submit" value="<?php echo _SUBMIT;?>" />
<input type="button" class="button" value="<?php echo _CANCEL;?>" onclick="javascript:history.go(-1)" />
</div>
</form>
<?php
CloseTable();
CloseTable();
}
include_once("footer.php");
?>
