Browse code

reformatting code

Jimako authored on 2023/09/06 05:56:29
Showing 1 changed files
... ...
@@ -23,76 +23,86 @@
23 23
 // To read the license please visit http://www.gnu.org/copyleft/gpl.html
24 24
 // ----------------------------------------------------------------------
25 25
 
26
-if(!defined("_CHARSET")) exit( );
27
-if(uLEVEL > 3) accessDenied();
28
-		$output .= "<div id=\"pagetitle\">"._NEWS."</div>";
29
-		if(isset($_POST['submit'])) {
30
-			$title = addslashes(strip_tags(descript($_POST['title']), $allowed_tags));
31
-			$author = addslashes(strip_tags(descript($_POST['author']), $allowed_tags));
32
-			$story = addslashes(strip_tags(descript($_POST['story']), $allowed_tags));
33
-			if($_GET['form'] == "new") $result = dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_news (title, author, story, time) VALUES ('$title', '$author', '$story', now())");
34
-			else $result = dbquery("UPDATE ".TABLEPREFIX."fanfiction_news SET title = '$title', author = '$author', story = '$story' WHERE nid = '$_POST[nid]'");
35
-			if($result) {
36
-				$output .= write_message(_ACTIONSUCCESSFUL);
37
-				unset($_GET['form']);
38
-			}
39
-			else $output .= write_error(_ERROR." ".TRYAGAIN);
26
+if (!defined("_CHARSET")) exit();
27
+if (uLEVEL > 3) accessDenied();
28
+$output .= "<div id=\"pagetitle\">" . _NEWS . "</div>";
29
+if (isset($_POST['submit']))
30
+{
31
+	$title = addslashes(strip_tags(descript($_POST['title']), $allowed_tags));
32
+	$author = addslashes(strip_tags(descript($_POST['author']), $allowed_tags));
33
+	$story = addslashes(strip_tags(descript($_POST['story']), $allowed_tags));
34
+	if ($_GET['form'] == "new") $result = dbquery("INSERT INTO " . TABLEPREFIX . "fanfiction_news (title, author, story, time) VALUES ('$title', '$author', '$story', now())");
35
+	else $result = dbquery("UPDATE " . TABLEPREFIX . "fanfiction_news SET title = '$title', author = '$author', story = '$story' WHERE nid = '$_POST[nid]'");
36
+	if ($result)
37
+	{
38
+		$output .= write_message(_ACTIONSUCCESSFUL);
39
+		unset($_GET['form']);
40
+	}
41
+	else $output .= write_error(_ERROR . " " . TRYAGAIN);
42
+}
43
+if (isset($_GET['delete']) && isNumber($_GET['delete']))
44
+{
45
+	if (isset($_GET['confirm']))
46
+	{
47
+		if ($_GET['confirm'] == "yes")
48
+		{
49
+			dbquery("DELETE FROM " . TABLEPREFIX . "fanfiction_news where nid = '" . $_GET['delete'] . "'");
50
+			$output .= write_message(_ACTIONSUCCESSFUL);
40 51
 		}
41
-		if(isset($_GET['delete']) && isNumber($_GET['delete'])) {
42
-			if($_GET['confirm'] == "yes") {
43
-				dbquery("DELETE FROM ".TABLEPREFIX."fanfiction_news where nid = '".$_GET['delete']."'");
44
-				$output .= write_message(_ACTIONSUCCESSFUL);
45
-			}
46
-			else if ($_GET['confirm'] == "no") $output .= write_message(_ACTIONCANCELLED);
47
-			else {
48
-			$output .= write_message(_CONFIRMDELETE."<br /><br />
49
-[ <a href=\"admin.php?action=news&confirm=yes&delete=$_GET[delete]\">"._YES."</a> | <a href=\"admin.php?action=news&confirm=no&delete=$_GET[delete]\">"._NO."</a> ]");
50
-			}
51
-		}
52
-		else if(isset($_GET["form"])) {
53
-			if($_GET["form"] != "new" && isNumber($_GET["form"])) {
54
-				$result = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_news WHERE nid = '".$_GET['form']."' LIMIT 1");
55
-				$newsitem = dbassoc($result);
56
-			}
57
-			else $newsitem = array("title" => "", "author" => "", "story" => "");
58
-			$output .= "<form method=\"POST\" enctype=\"multipart/form-data\" action=\"admin.php?action=news&form=$_GET[form]\">
59
-				<table align=\"center\"><tr><td colspan=\"2\" align=\"center\"><b>".($_GET["form"] == "new" ? _ADDNEWS : _EDITNEWS)."</b></td></tr>
60
-			<tr><td>"._AUTHOR.": </td><td><INPUT  type=\"text\" class=\"textbox=\" name=\"author\" value=\"".stripslashes($newsitem['author'])."\"></td></tr>
61
-			<tr><td>"._TITLE.": </td><td><INPUT  type=\"text\" class=\"textbox=\" name=\"title\" value=\"".stripslashes($newsitem['title'])."\"></td></tr>
62
-			<tr><td>"._TEXT.": </td><td><textarea class=\"textbox\" name=\"story\" id=\"story\" COLS=\"45\" ROWS=\"6\">".stripslashes($newsitem['story'])."</TEXTAREA>";
63
-			if($tinyMCE) 
64
-				$output .= "<div class='tinytoggle'><input type='checkbox' name='toggle' onclick=\"toogleEditorMode('story');\" checked><label for='toggle'>"._TINYMCETOGGLE."</label></div>";
52
+		else if ($_GET['confirm'] == "no") $output .= write_message(_ACTIONCANCELLED);
53
+	}
54
+	else
55
+	{
56
+		$output .= write_message(_CONFIRMDELETE . "<br /><br />
57
+	[ <a href=\"admin.php?action=news&confirm=yes&delete=$_GET[delete]\">" . _YES . "</a> | <a href=\"admin.php?action=news&confirm=no&delete=$_GET[delete]\">" . _NO . "</a> ]");
58
+	}
59
+}
60
+else if (isset($_GET["form"]))
61
+{
62
+	if ($_GET["form"] != "new" && isNumber($_GET["form"]))
63
+	{
64
+		$result = dbquery("SELECT * FROM " . TABLEPREFIX . "fanfiction_news WHERE nid = '" . $_GET['form'] . "' LIMIT 1");
65
+		$newsitem = dbassoc($result);
66
+	}
67
+	else $newsitem = array("title" => "", "author" => "", "story" => "");
68
+	$output .= "<form method=\"POST\" enctype=\"multipart/form-data\" action=\"admin.php?action=news&form=$_GET[form]\">
69
+				<table align=\"center\"><tr><td colspan=\"2\" align=\"center\"><b>" . ($_GET["form"] == "new" ? _ADDNEWS : _EDITNEWS) . "</b></td></tr>
70
+			<tr><td>" . _AUTHOR . ": </td><td><INPUT  type=\"text\" class=\"textbox=\" name=\"author\" value=\"" . stripslashes($newsitem['author']) . "\"></td></tr>
71
+			<tr><td>" . _TITLE . ": </td><td><INPUT  type=\"text\" class=\"textbox=\" name=\"title\" value=\"" . stripslashes($newsitem['title']) . "\"></td></tr>
72
+			<tr><td>" . _TEXT . ": </td><td><textarea class=\"textbox\" name=\"story\" id=\"story\" COLS=\"45\" ROWS=\"6\">" . stripslashes($newsitem['story']) . "</TEXTAREA>";
73
+	if ($tinyMCE)
74
+		$output .= "<div class='tinytoggle'><input type='checkbox' name='toggle' onclick=\"toogleEditorMode('story');\" checked><label for='toggle'>" . _TINYMCETOGGLE . "</label></div>";
65 75
 
66
-			$output .= "</td></tr><tr><td colspan=\"2\" align=\"center\">".($_GET["form"] != "new" ? "<INPUT type=\"hidden\" name=\"nid\" value=\"".$_GET['form']."\">" : "")."<INPUT type=\"submit\" class=\"button\" name=\"submit\" value=\""._SUBMIT."\"></td></tr></table></form>";
67
-		}
68
-		else {
69
-			$output .= "<p align=\"center\"><a href=\"admin.php?action=news&form=new\">"._ADDNEWS."</a></p>";
70
-			$count = dbquery("SELECT COUNT(nid) FROM ".TABLEPREFIX."fanfiction_news");
71
-			list($numrows)= dbrow($count);
72
-	
73
-			$result = dbquery("SELECT n.*, n.time as date, count(c.cid) as comments FROM ".TABLEPREFIX."fanfiction_news as n LEFT JOIN ".TABLEPREFIX."fanfiction_comments as c ON  n.nid = c.nid GROUP BY n.nid ORDER BY time DESC LIMIT $offset, $itemsperpage");
74
-			if(file_exists("$skindir/newsbox.tpl")) $news = new TemplatePower( "$skindir/newsbox.tpl" );
75
-			else $news = new TemplatePower( "default_tpls/newsbox.tpl" );
76
-			$news->prepare();
77
-			$count = 0;
78
-			while($stories = dbassoc($result)) {
79
-				$news->newBlock("newsbox");
80
-		
81
-				//assign values
82
-				$news->assign("newstitle"   , $stories['title'] );
83
-				$news->assign("newsstory"   , $stories['story'] );
84
-				$news->assign("newsauthor", $stories['author'] );
85
-				$news->assign("newsdate", date("$dateformat $timeformat", $stories['date']) );
86
-				$news->assign("oddeven", ($count % 2 ? "even" : "odd"));
87
-				if($newscomments == "1")
88
-					$news->assign("newscomments", "<a href=\"news.php?action=newsstory&amp;nid=".$stories['nid']."\">".$stories['comments']." "._COMMENTS."</a>");
89
-				if(isADMIN) 
90
-					$news->assign("adminoptions", "<a href=\"admin.php?action=news&amp;form=".$stories['nid']."\">"._EDIT."</a> | <a href=\"admin.php?action=news&amp;delete=".$stories['nid']."\">"._DELETE."</a>");
91
-				$count++;
92
-			}
93
-			$news->gotoBlock("_ROOT");
94
-			$output .= $news->getOutputContent( );
95
-			if($numrows > $itemsperpage) $output .= build_pagelinks("admin.php?action=news&amp;", $numrows, $offset);
96
-		}
76
+	$output .= "</td></tr><tr><td colspan=\"2\" align=\"center\">" . ($_GET["form"] != "new" ? "<INPUT type=\"hidden\" name=\"nid\" value=\"" . $_GET['form'] . "\">" : "") . "<INPUT type=\"submit\" class=\"button\" name=\"submit\" value=\"" . _SUBMIT . "\"></td></tr></table></form>";
77
+}
78
+else
79
+{
80
+	$output .= "<p align=\"center\"><a href=\"admin.php?action=news&form=new\">" . _ADDNEWS . "</a></p>";
81
+	$count = dbquery("SELECT COUNT(nid) FROM " . TABLEPREFIX . "fanfiction_news");
82
+	list($numrows) = dbrow($count);
83
+
84
+	$result = dbquery("SELECT n.*, n.time as date, count(c.cid) as comments FROM " . TABLEPREFIX . "fanfiction_news as n LEFT JOIN " . TABLEPREFIX . "fanfiction_comments as c ON  n.nid = c.nid GROUP BY n.nid ORDER BY time DESC LIMIT $offset, $itemsperpage");
85
+	if (file_exists("$skindir/newsbox.tpl")) $news = new TemplatePower("$skindir/newsbox.tpl");
86
+	else $news = new TemplatePower("default_tpls/newsbox.tpl");
87
+	$news->prepare();
88
+	$count = 0;
89
+	while ($stories = dbassoc($result))
90
+	{
91
+		$news->newBlock("newsbox");
97 92
 
98
-?>
99 93
\ No newline at end of file
94
+		//assign values
95
+		$news->assign("newstitle", $stories['title']);
96
+		$news->assign("newsstory", $stories['story']);
97
+		$news->assign("newsauthor", $stories['author']);
98
+		$news->assign("newsdate", date("$dateformat $timeformat", $stories['date']));
99
+		$news->assign("oddeven", ($count % 2 ? "even" : "odd"));
100
+		if ($newscomments == "1")
101
+			$news->assign("newscomments", "<a href=\"news.php?action=newsstory&amp;nid=" . $stories['nid'] . "\">" . $stories['comments'] . " " . _COMMENTS . "</a>");
102
+		if (isADMIN)
103
+			$news->assign("adminoptions", "<a href=\"admin.php?action=news&amp;form=" . $stories['nid'] . "\">" . _EDIT . "</a> | <a href=\"admin.php?action=news&amp;delete=" . $stories['nid'] . "\">" . _DELETE . "</a>");
104
+		$count++;
105
+	}
106
+	$news->gotoBlock("_ROOT");
107
+	$output .= $news->getOutputContent();
108
+	if ($numrows > $itemsperpage) $output .= build_pagelinks("admin.php?action=news&amp;", $numrows, $offset);
109
+}