1
I'm using "My Tutorials" for my site as a recpes book.
Now I would like to know:
Is there a way to make annomynous users submit their recipes?
Because now you first have to register.
What do I need to change to this script to get annomynus users submitting their recipes?
//-------------------------------------------------------------------------- //
// Tutorials Version 2.1 User Submit Functions //
// //
// Author: Thomas (Todi) Wolf //
// Mail: todi@dark-side.de //
// Homepage: http://www.mytutorials.info //
// //
// for XOOPS RC3 //
// ------------------------------------------------------------------------- //
// This program 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA //
// ------------------------------------------------------------------------- //
include "header.php";
include_once XOOPS_ROOT_PATH."/class/xoopstree.php";
include_once XOOPS_ROOT_PATH."/include/xoopscodes.php";
include_once XOOPS_ROOT_PATH."/class/module.errorhandler.php";
$myts =& MyTextSanitizer::getInstance();
$eh = new ErrorHandler;
$mytree = new XoopsTree($xoopsDB->prefix("tutorials_categorys"),"cid","scid");
define("IMAGE_PATH",XOOPS_ROOT_PATH."/modules/tutorials/images");
define("IMAGE_URL",XOOPS_URL."/modules/tutorials/images");
if(!$xoopsUser){
redirect_header (XOOPS_URL."/user.php",2,_MD_MUSTREGFIRST);
exit();
}
// -----------------------------------------------------------------------------------------------------------//
function Tutorials(){
global $xoopsDB, $xoopsConfig, $xoopsTheme, $mytree, $useruploads, $xoopsUser, $xoopsLogger, $xoopsMF;
include XOOPS_ROOT_PATH."/header.php";
OpenTable();
$result=$xoopsDB->query("select count(*) from ".$xoopsDB->prefix("tutorials_categorys")."");
list($numrows)=$xoopsDB->fetchRow($result);
if ($numrows>0) {
// Add new Tutorial ------------------//
echo "._MD_TUTORIAL."
";
echo _MD_CHOICECATEGORY."
";
echo _MD_INCATEGORY;
$mytree->makeMySelBox("cname", "cname");
if ($useruploads == 1){
echo "";
} else {
echo "";
}
echo "._MD_GO.">n";
echo "";
} else {
echo _MD_NOCATEGORY;
}
CloseTable();
include XOOPS_ROOT_PATH."/footer.php";
}
// -----------------------------------------------------------------------------------------------------------//
function questForPics() {
global $HTTP_POST_VARS, $xoopsConfig, $xoopsTheme, $xoopsUser, $xoopsLogger, $xoopsMF;
include(XOOPS_ROOT_PATH."/header.php");
$cid = $HTTP_POST_VARS["cid"];
OpenTable();
echo "center">"._MD_QUESTPIC."
";
echo "center">"; echo TextForm("submit.php?op=addTutorial&createdir=1&cid=$cid",_MD_YES); echo " | "; echo TextForm("submit.php?op=addTutorial&createdir=0&cid=$cid",_MD_NO); echo " |
";
CloseTable();
include(XOOPS_ROOT_PATH."/footer.php");
}
// -----------------------------------------------------------------------------------------------------------//
function addTutorial(){
global $xoopsDB, $xoopsConfig, $xoopsUser, $xoopsLogger, $xoopsMF, $HTTP_GET_VARS, $HTTP_POST_VARS, $myts, $xoopsTheme, $useruploads, $imgwidth, $imgheight;
include(XOOPS_ROOT_PATH."/header.php");
if ($useruploads == 1) {
$cid = $HTTP_GET_VARS["cid"];
$createdir = $HTTP_GET_VARS["createdir"];
} else {
$cid = $HTTP_POST_VARS["cid"];
$createdir = 0;
}
// Add new Tutorial ------------------//
$result=$xoopsDB->query("select scid, cname, cdesc, cimg from ".$xoopsDB->prefix("tutorials_categorys")." where cid=$cid");
list($scid,$cname,$cdesc,$cimg) = $xoopsDB->fetchRow($result);
$cname=$myts->makeTboxData4Show($cname);
$cdesc=$myts->makeTareaData4Show($cdesc);
OpenTable();
$time = time();
$dir = $time;
echo ""
._MD_ADDTUTORIAL."
";
if (file_exists(IMAGE_PATH."/$cid")) {
$imgdirexists = 1;
if ($createdir == 1) {
$path = IMAGE_PATH."/$cid/$dir";
if(mkdir($path,0777) == false){
echo "center">red">"._MD_ERRCREATEDIR."
";
$imgsubdirexists = 0;
} else {
# echo ""._MD_DIRCREATED."";
$imgsubdirexists = 1;
}
}
} else {
$imgdirexists = 0;
$imgsubdirexists = 0;
}
$status = 0;
$img_path = "$cid/";
$img_path2 = "$cid/$dir/";
$scriptname = "submit.php";
$hits = 0;
$rating = 0;
$votes = 0;
$framebrowse = 0;
$submitter = $xoopsUser->uid();
$tauthor = XoopsUser::getUnameFromId($submitter);
include_once XOOPS_ROOT_PATH."/modules/tutorials/include/form.php";
CloseTable();
include(XOOPS_ROOT_PATH."/footer.php");
}
// -----------------------------------------------------------------------------------------------------------//
function PreviewTutorial() {
global $xoopsDB,$xoopsConfig, $xoopsTheme, $HTTP_POST_VARS, $myts, $mytree, $content_visdefault, $content_default, $content_visualize, $imgwidth, $imgheight, $useruploads, $xoopsUser, $xoopsLogger, $xoopsMF;
include(XOOPS_ROOT_PATH."/header.php");
if($HTTP_POST_VARS["tid"]) {
$tid = $HTTP_POST_VARS["tid"];
}
$cid = $HTTP_POST_VARS["cid"];
$gid = $HTTP_POST_VARS["gid"];
$tname = $HTTP_POST_VARS["tname"];
$tauthor = $HTTP_POST_VARS["tauthor"];
$submitter = $HTTP_POST_VARS["submitter"];
$timg = $HTTP_POST_VARS["timg"];
$tdesc = $HTTP_POST_VARS["tdesc"];
$tlink = $HTTP_POST_VARS["tlink"];
$dir = $HTTP_POST_VARS["dir"];
$time = $HTTP_POST_VARS["time"];
$status = $HTTP_POST_VARS["status"];
$hits = $HTTP_POST_VARS["hits"];
$rating = $HTTP_POST_VARS["rating"];
$votes = $HTTP_POST_VARS["votes"];
$framebrowse = $HTTP_POST_VARS["framebrowse"];
$timgwidth = $HTTP_POST_VARS["timgwidth"];
$timgheight = $HTTP_POST_VARS["timgheight"];
if ($HTTP_POST_VARS["maketdir"] == 1) {
if (file_exists(IMAGE_PATH."/$cid")) {
$imgdirexists = 1;
$path = IMAGE_PATH."/$cid/$dir";
if(mkdir($path,0777) == false){
echo "center">red">"._MD_ERRCREATEDIR."
";
$imgsubdirexists = 0;
} else {
echo "center">red">"._MD_DIRCREATED."
";
$imgsubdirexists = 1;
}
} else {
$imgdirexists = 0;
$imgsubdirexists = 0;
}
}
if (ereg("http://",$timg)) {
$timgwidth = "";
$timgheight = "";
}
// ShowPreview ---------------------//
if ($tlink == "") {
if ( !empty($HTTP_POST_VARS['xsmiley']) && !empty($HTTP_POST_VARS['xhtml']) ){
$content = $myts->makeTareaData4Preview($HTTP_POST_VARS['tcont'],0,0,1);
$tcont = $myts->makeTareaData4PreviewInForm($HTTP_POST_VARS["tcont"],0,0,1);
} elseif ( !empty($HTTP_POST_VARS['xhtml']) ) {
$content = $myts->makeTareaData4Preview($HTTP_POST_VARS['tcont'],0,1,1);
$tcont = $myts->makeTareaData4PreviewInForm($HTTP_POST_VARS["tcont"],0,1,1);
} elseif ( !empty($HTTP_POST_VARS['xsmiley']) ) {
$content = $myts->makeTareaData4Preview($HTTP_POST_VARS['tcont'],1,0,1);
$tcont = $myts->makeTareaData4PreviewInForm($HTTP_POST_VARS["tcont"],1,0,1);
} else {
$content = $myts->makeTareaData4Preview($HTTP_POST_VARS['tcont'],1,1,1);
$tcont = $myts->makeTareaData4PreviewInForm($HTTP_POST_VARS["tcont"],1,1,1);
}
$content = str_replace("_IMGURL_",IMAGE_URL,$content);
$content = str_replace("[pagebreak]","",$content);
$date = formatTimestamp($time,"m");
if(get_magic_quotes_gpc()){
$content = stripslashes($content);
}
OpenTable();
echo "Preview
";
if ($content_visdefault == 1) {
$preview = $content_visualize;
} else {
$preview = $content_default;
}
if ($timg != "") {
if (ereg("http://",$timg)) {
$imgpath = $timg;
} else {
$imgpath = "".IMAGE_URL."/$timg";
}
if ($timgwidth > 0 && $timgheight > 0){
$setsize = "width=".$timgwidth." height=".$timgheight;
} else {
$setsize = "";
}
$preview = str_replace("[image]","$imgpath."" name=timage ".$setsize." border=1>",$preview);
} else {
$preview = str_replace("[image]","",$preview);
}
$preview = str_replace("[title]","$tname",$preview);
$preview = str_replace("[content]",$content,$preview);
$preview = str_replace("[author]",sprintf(_MD_WRITTENBY,$tauthor),$preview);
$preview = str_replace("[hits]","0"._MD_HITS,$preview);
$preview = str_replace("[rating]",_MD_RATING.": 0",$preview);
$preview = str_replace("[votes]","0"._MD_VOTES,$preview);
$preview = str_replace("[date]","$date",$preview);
echo "$preview";
} else {
OpenTable();
if ($framebrowse == 1) {
echo "";
} else {
$content=$tlink;
echo ""._MD_EXTLINK."$tlink -> $tlink" target="_blank">"._MD_SHOWLINK."
";
}
}
// ShowForm ----------------------//
$xsmiley = intval($HTTP_POST_VARS["xsmiley"]);
$xhtml = intval($HTTP_POST_VARS["xhtml"]);
$tdesc = $myts->makeTareaData4PreviewInForm($tdesc);
$result=$xoopsDB->query("select scid, cname, cdesc, cimg from ".$xoopsDB->prefix("tutorials_categorys")." where cid=$cid");
list($scid,$cname,$cdesc,$cimg) = $xoopsDB->fetchRow($result);
$cname=$myts->makeTboxData4Show($cname);
$cdesc=$myts->makeTareaData4Show($cdesc);
if (file_exists(IMAGE_PATH."/$cid")) {
$imgdirexists = 1;
} else {
$imgdirexists = 0;
}
if (file_exists(IMAGE_PATH."/$cid/$dir")) {
$imgsubdirexists = 1;
} else {
$imgsubdirexists = 0;
}
$img_path = "$cid/";
$img_path2 = "$cid/$dir/";
$scriptname = "submit.php";
include (XOOPS_ROOT_PATH."/modules/tutorials/include/form.php");
CloseTable();
include(XOOPS_ROOT_PATH."/footer.php");
}
// -----------------------------------------------------------------------------------------------------------//
function SaveTutorial() {
global $xoopsDB,$xoopsConfig, $HTTP_POST_VARS, $myts, $eh, $xoopsUser, $xoopsLogger, $xoopsMF;
if($HTTP_POST_VARS["tid"]) {
$tid = $HTTP_POST_VARS["tid"];
} else {
$tid = 0;
}
$cid = $HTTP_POST_VARS["cid"];
$smiley = intval($HTTP_POST_VARS["xsmiley"]);
$html = intval($HTTP_POST_VARS["xhtml"]);
$status = $HTTP_POST_VARS["status"];
$dir = $HTTP_POST_VARS["dir"];
$time = $HTTP_POST_VARS["time"];
$hits = $HTTP_POST_VARS["hits"];
$rating = $HTTP_POST_VARS["rating"];
$votes = $HTTP_POST_VARS["votes"];
$framebrowse = $HTTP_POST_VARS["framebrowse"];
if (($html == 0) && ($smiley == 0)) {
$codes = 0;
} elseif (($html == 1) && ($smiley == 0)) {
$codes = 1;
} elseif (($html == 0) && ($smiley == 1)) {
$codes = 2;
} else {
$codes = 3;
}
if ($framebrowse == 1) {
$codes += 10;
}
if($HTTP_POST_VARS["gid"]) {
$gid = $HTTP_POST_VARS["gid"];
} else {
$gid = 0;
}
$tname = $myts->makeTboxData4Save($HTTP_POST_VARS["tname"]);
$tauthor = $myts->makeTboxData4Save($HTTP_POST_VARS["tauthor"]);
$timg = $myts->makeTboxData4Save($HTTP_POST_VARS["timg"]);
if (ereg("http://",$timg) || $timg == "") {
$timgwidth = 0;
$timgheight = 0;
} else {
$timgwidth = $HTTP_POST_VARS["timgwidth"];
$timgheight = $HTTP_POST_VARS["timgheight"];
}
$tdesc = $myts->makeTboxData4Save($HTTP_POST_VARS["tdesc"]);
$tcont = $myts->makeTareaData4Save($HTTP_POST_VARS["tcont"],$html,$smiley,1);
$submitter = $HTTP_POST_VARS["submitter"];
$message ="";
if (!empty($HTTP_POST_VARS["tlink"])) {
$tlink = $myts->makeTboxData4Save($HTTP_POST_VARS["tlink"]);
}
// Check if Title exist
if ($tname=="") {
$message .= "#ff0000">";
$message .= _MD_ERRORNAME."
";
$error =1;
}
// Check if Description exist
if ($tdesc=="") {
$message .= "#ff0000">";
$message .= _MD_ERRORDESC."
";
$error =1;
}
// Check if Content exist
if (($tcont=="") && ($tlink=="")) {
$message .= "#ff0000">";
$message .= _MD_ERRORCONT."
";
$error =1;
}
if($error == 1) {
include(XOOPS_ROOT_PATH."/header.php");
OpenTable();
echo $message;
echo "button" value=""._MD_GOBACK."" onclick="javascript:history.go(-1)">";
CloseTable();
include(XOOPS_ROOT_PATH."/footer.php");
exit();
}
if($tid == 0) {
$newid = $xoopsDB->genId("tutorials_tid_seq");
$xoopsDB->query("INSERT INTO ".$xoopsDB->prefix("tutorials")." (tid, cid, gid, tname, tdesc, timg, tcont, tlink, tauthor, status, codes, hits, rating, votes, date, submitter, dir, timgwidth, timgheight) VALUES ($newid, $cid, $gid, '$tname', '$tdesc', '$timg', '$tcont', '$tlink', '$tauthor', $status, $codes, 0, 0, 0, $time, $submitter, $dir, $timgwidth, $timgheight)") or $eh->show("0013");
} elseif ($status == 0) {
$xoopsDB->query("UPDATE ".$xoopsDB->prefix("tutorials")." set tid=$tid, cid=$cid, gid=$gid, tname='$tname', tdesc='$tdesc', timg='$timg', tcont='$tcont', tlink='$tlink', tauthor='$tauthor', status=$status, codes=$codes, hits=$hits, rating=$rating, votes=$votes, date=$time, timgwidth=$timgwidth, timgheight=$timgheight where tid=$tid") or $eh->show("0013");
} elseif ($tid > 0 && $status >= 1) {
$time = time();
$xoopsDB->query("UPDATE ".$xoopsDB->prefix("tutorials")." set tid=$tid, cid=$cid, gid=$gid, tname='$tname', tdesc='$tdesc', timg='$timg', tcont='$tcont', tlink='$tlink', tauthor='$tauthor', status=$status, codes=$codes, hits=$hits, rating=$rating, votes=$votes, date=$time, timgwidth=$timgwidth, timgheight=$timgheight where tid=$tid") or $eh->show("0013");
}
redirect_header("index.php",1,_MD_RECEIVED."
"._MD_WHENAPPROVED."");
}
// -----------------------------------------------------------------------------------------------------------//
function editTutorial() {
global $xoopsDB,$xoopsConfig, $HTTP_GET_VARS, $myts, $eh, $mytree, $useruploads, $imgwidth, $imgheight, $xoopsUser, $xoopsLogger, $xoopsMF;
include(XOOPS_ROOT_PATH."/header.php");
$tid = $HTTP_GET_VARS['tid'];
$result=$xoopsDB->query("select tid, cid, gid, tname,tdesc, timg, tcont, tlink, tauthor, status, codes, hits, rating, votes, date, submitter, dir, timgwidth, timgheight from ".$xoopsDB->prefix("tutorials")." where tid=$tid");
list($tid,$cid,$gid,$tname,$tdesc,$timg,$tcont,$tlink,$tauthor,$status,$codes,$hits,$rating,$votes,$time,$submitter,$dir,$timgwidth,$timgheight) = $xoopsDB->fetchRow($result);
if ($codes >= 10) {
$codes -= 10;
$framebrowse = 1;
} else {
$framebrowse = 0;
}
if ($codes == 0) {
$xhtml = 0;
$xsmiley = 0;
} elseif ($codes == 1) {
$xhtml = 1;
$xsmiley = 0;
} elseif ($codes == 2) {
$xhtml = 0;
$xsmiley = 1;
} else {
$xhtml = 1;
$xsmiley = 1;
}
$tname = $myts->makeTboxData4PreviewInForm($tname);
$tauthor = $myts->makeTboxData4PreviewInForm($tauthor);
$timg = $myts->makeTboxData4PreviewInForm($timg);
$tdesc = $myts->makeTboxData4PreviewInForm($tdesc);
$tlink = $myts->makeTboxData4PreviewInForm($tlink);
$tcont = $myts->makeTareaData4PreviewInForm($tcont,$html,$smiley,1);
$result=$xoopsDB->query("select scid, cname, cdesc, cimg from ".$xoopsDB->prefix("tutorials_categorys")." where cid=$cid");
list($scid,$cname,$cdesc,$cimg) = $xoopsDB->fetchRow($result);
$cname=$myts->makeTboxData4Show($cname);
$cdesc=$myts->makeTareaData4Show($cdesc);
OpenTable();
echo ""
._MD_EDITTUTORIAL."
";
if (file_exists(IMAGE_PATH."/$cid")) {
$imgdirexists = 1;
} else {
$imgdirexists = 0;
}
if (file_exists(IMAGE_PATH."/$cid/$dir")) {
$imgsubdirexists = 1;
} else {
$imgsubdirexists = 0;
}
$status = 2;
$img_path = "$cid/";
$img_path2 = "$cid/$dir/";
$scriptname = "submit.php";
include XOOPS_ROOT_PATH."/modules/tutorials/include/form.php";
CloseTable();
include XOOPS_ROOT_PATH."/footer.php";
}
// -----------------------------------------------------------------------------------------------------------//
switch ($op) {
default:
Tutorials();
break;
case "questForPics":
questForPics();
break;
case "addTutorial":
addTutorial();
break;
case "PreviewTutorial":
PreviewTutorial();
break;
case "SaveTutorial":
SaveTutorial();
break;
case "editTutorial":
editTutorial();
break;
}
?>
Quote:
My point is: Everybody who comes on the site can post hir/her recipes, but now they have to make an user account first.
How can I trick that, because this submit.php is keep asking it's "xoops::username" and "uid"