Browse code

Fixed/improved backup, added with and without UTF-8

Rainer Volkrodt authored on 2016/05/18 08:52:49
Showing 1 changed files
... ...
@@ -208,7 +208,7 @@ else {
208 208
 	<li><a href='admin.php?action=maintenance&amp;maint=panels'>"._PANELORDER."</a> <A HREF=\"#\" class=\"pophelp\">[?]<span>"._HELP_PANELORDER."</span></A></li>
209 209
 	<li><a href='admin.php?action=maintenance&amp;maint=optimize'>"._OPTIMIZE."</a> <A HREF=\"#\" class=\"pophelp\">[?]<span>"._HELP_OPTIMIZE."</span></A></li>
210 210
 	<li><a href='admin/backup.php' target='_new'>"._BACKUP."</a> <A HREF=\"#\" class=\"pophelp\">[?]<span>"._HELP_BACKUP."</span></A></li>
211
-	<li><a href='admin/backup_mk2.php' target='_new'>"._BACKUP."</a> (mk2) <A HREF=\"#\" class=\"pophelp\">[?]<span>"._HELP_BACKUP."</span></A></li>
211
+	<li><a href='admin/backup_utf8.php' target='_new'>"._BACKUP."</a> (UTF-8) <A HREF=\"#\" class=\"pophelp\">[?]<span>"._HELP_BACKUP."</span></A></li>
212 212
 	<li><a href='admin.php?action=maintenance&amp;maint=update'>"._UPDATE."</a>  <A HREF=\"#\" class=\"pophelp\">[?]<span>"._HELP_UPDATE."</span></A></li>
213 213
 </ul>";
214 214
 }
Browse code

Fixed/improved backup, added as mk2

Rainer Volkrodt authored on 2016/05/18 08:49:47
Showing 1 changed files
... ...
@@ -208,6 +208,7 @@ else {
208 208
 	<li><a href='admin.php?action=maintenance&amp;maint=panels'>"._PANELORDER."</a> <A HREF=\"#\" class=\"pophelp\">[?]<span>"._HELP_PANELORDER."</span></A></li>
209 209
 	<li><a href='admin.php?action=maintenance&amp;maint=optimize'>"._OPTIMIZE."</a> <A HREF=\"#\" class=\"pophelp\">[?]<span>"._HELP_OPTIMIZE."</span></A></li>
210 210
 	<li><a href='admin/backup.php' target='_new'>"._BACKUP."</a> <A HREF=\"#\" class=\"pophelp\">[?]<span>"._HELP_BACKUP."</span></A></li>
211
+	<li><a href='admin/backup_mk2.php' target='_new'>"._BACKUP."</a> (mk2) <A HREF=\"#\" class=\"pophelp\">[?]<span>"._HELP_BACKUP."</span></A></li>
211 212
 	<li><a href='admin.php?action=maintenance&amp;maint=update'>"._UPDATE."</a>  <A HREF=\"#\" class=\"pophelp\">[?]<span>"._HELP_UPDATE."</span></A></li>
212 213
 </ul>";
213 214
 }
Browse code

Initial uplad w/ php7 fixes

Rainer Volkrodt authored on 2016/03/12 15:54:02
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,214 @@
1
+<?php
2
+// ----------------------------------------------------------------------
3
+// eFiction 3.0
4
+// Copyright (c) 2007 by Tammy Keefer
5
+// Valid HTML 4.01 Transitional
6
+// Based on eFiction 1.1
7
+// Copyright (C) 2003 by Rebecca Smallwood.
8
+// http://efiction.sourceforge.net/
9
+// ----------------------------------------------------------------------
10
+// LICENSE
11
+//
12
+// This program is free software; you can redistribute it and/or
13
+// modify it under the terms of the GNU General Public License (GPL)
14
+// as published by the Free Software Foundation; either version 2
15
+// of the License, or (at your option) any later version.
16
+//
17
+// This program is distributed in the hope that it will be useful,
18
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
19
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
+// GNU General Public License for more details.
21
+//
22
+// To read the license please visit http://www.gnu.org/copyleft/gpl.html
23
+// ----------------------------------------------------------------------
24
+
25
+if(!defined("_CHARSET")) exit( );
26
+
27
+$maint = isset($_GET['maint']) ? $_GET['maint'] : false;
28
+$output .= "<div id='pagetitle'>"._ARCHIVEMAINT."</div>";
29
+if($maint == "update") {
30
+	if(file_exists("admin/update.php")) include_once("admin/update.php");
31
+}
32
+if($maint == "reviews") {
33
+	dbquery("UPDATE ".TABLEPREFIX."fanfiction_stories SET rating = '0', reviews = '0'"); // Set them all to 0 before we re-insert.
34
+	$stories = dbquery("SELECT AVG(rating) as average, item FROM ".TABLEPREFIX."fanfiction_reviews WHERE type = 'ST' AND rating != '-1' GROUP BY item");
35
+	while($s = dbassoc($stories)) {
36
+		dbquery("UPDATE ".TABLEPREFIX."fanfiction_stories SET rating = '".round($s['average'])."' WHERE sid = '".$s['item']."'");
37
+	}
38
+	$stories = dbquery("SELECT COUNT(reviewid) as count, item FROM ".TABLEPREFIX."fanfiction_reviews WHERE type = 'ST' AND review != 'No Review' GROUP BY item");
39
+	while($s = dbassoc($stories)) {
40
+		dbquery("UPDATE ".TABLEPREFIX."fanfiction_stories SET reviews = '".$s['count']."' WHERE sid = '".$s['item']."'");
41
+	}
42
+	dbquery("UPDATE ".TABLEPREFIX."fanfiction_chapters SET rating = '0', reviews = '0'");
43
+	$chapters = dbquery("SELECT AVG(rating) as average, chapid FROM ".TABLEPREFIX."fanfiction_reviews WHERE type = 'ST' AND rating != '-1' GROUP BY chapid");
44
+	while($c = dbassoc($chapters)) {
45
+		dbquery("UPDATE ".TABLEPREFIX."fanfiction_chapters SET rating = '".round($c['average'])."' WHERE chapid = '".$c['chapid']."'");
46
+	}
47
+	$chapters = dbquery("SELECT COUNT(reviewid) as count, chapid FROM ".TABLEPREFIX."fanfiction_reviews WHERE type = 'ST' AND review != 'No Review' GROUP BY chapid");
48
+	while($c = dbassoc($chapters)) {
49
+		dbquery("UPDATE ".TABLEPREFIX."fanfiction_chapters SET reviews = '".$c['count']."' WHERE chapid = '".$c['chapid']."'");
50
+	}
51
+	dbquery("UPDATE ".TABLEPREFIX."fanfiction_series SET rating = '0', reviews = '0'");
52
+	$series = dbquery("SELECT seriesid FROM ".TABLEPREFIX."fanfiction_series");
53
+	while($s = dbassoc($series)) {
54
+		$thisseries = $s['seriesid'];
55
+		include("includes/seriesreviews.php");
56
+	}
57
+	// For modules which may allow reviews.
58
+	$codequery = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_codeblocks WHERE code_type = 'revfix'");
59
+	while($code = dbassoc($codequery)) {
60
+		$eval($code['code_text']);
61
+	}
62
+	if($logging) dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_log (`log_action`, `log_uid`, `log_ip`, `log_type`) VALUES('".escapestring(sprintf(_LOG_RECALCREVIEWS, USERPENNAME, USERUID))."', '".USERUID."', INET_ATON('".$_SERVER['REMOTE_ADDR']."'), 'AM')");
63
+	$output .= write_message(_ACTIONSUCCESSFUL);
64
+}
65
+else if($maint == "stories") {
66
+		$authors = dbquery("SELECT uid, count(uid) AS count FROM ".TABLEPREFIX."fanfiction_stories WHERE validated > 0 GROUP BY uid");
67
+		while($a = dbassoc($authors)) {
68
+			$alist[$a['uid']] = $a['count'];
69
+		}
70
+		$coauthors = dbquery("SELECT uid, count(sid) AS count FROM ".TABLEPREFIX."fanfiction_coauthors GROUP BY uid");
71
+		while($ca = dbassoc($coauthors)) {
72
+			if(isset($alist[$ca['uid']])) $alist[$ca['uid']] = $alist[$ca['uid']] + $ca['count'];
73
+			else $alist[$ca['uid']] = $ca['count'];
74
+		}
75
+		foreach($alist AS $a => $s) {
76
+			dbquery("UPDATE ".TABLEPREFIX."fanfiction_authorprefs SET stories = '$s' WHERE uid = '$a' LIMIT 1");
77
+		}
78
+		$count =  dbquery("SELECT SUM(wordcount) as count, sid FROM ".TABLEPREFIX."fanfiction_chapters WHERE validated = '1' GROUP BY sid");
79
+		while($c = dbassoc($count)) {
80
+			dbquery("UPDATE ".TABLEPREFIX."fanfiction_stories SET wordcount = '".$c['count']."' WHERE sid = '".$c['sid']."'");
81
+		}
82
+	$output .= write_message(_ACTIONSUCCESSFUL);
83
+}
84
+else if($maint == "categories") {
85
+	dbquery("UPDATE ".TABLEPREFIX."fanfiction_categories SET numitems = '0'");
86
+	$cats = dbquery("SELECT catid FROM ".TABLEPREFIX."fanfiction_categories ORDER BY leveldown DESC");
87
+	while($cat = dbrow($cats)) {
88
+		unset($subcats);
89
+		$subs = dbquery("SELECT catid FROM ".TABLEPREFIX."fanfiction_categories WHERE parentcatid = $cat[0]");
90
+		$subcats = array( );
91
+		while($sub = dbrow($subs)) {
92
+			$subcats[] = $sub[0];
93
+			if($categories[$sub[0]]) $subcats = array_merge($subcats, $categories[$sub[0]]);
94
+		}
95
+		$categories[$cat[0]] = $subcats;
96
+		$countquery = dbquery("SELECT count(sid) FROM ".TABLEPREFIX."fanfiction_stories WHERE FIND_IN_SET('$cat[0]', catid) ".(count($subcats) > 0 ? " OR FIND_IN_SET(". implode(", catid) OR FIND_IN_SET(",$subcats).", catid)" : "")." AND validated > 0");
97
+		list($count) = dbrow($countquery);
98
+		dbquery("UPDATE ".TABLEPREFIX."fanfiction_categories SET numitems = $count WHERE catid = $cat[0]");
99
+	}
100
+	if($logging) dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_log (`log_action`, `log_uid`, `log_ip`, `log_type`) VALUES('".escapestring(sprintf(_LOG_CATCOUNTS, USERPENNAME, USERUID))."', '".USERUID."', INET_ATON('".$_SERVER['REMOTE_ADDR']."'), 'AM')");
101
+	$output .= write_message(_CATCOUNTSUPDATED);
102
+}
103
+else if($maint == "categories2") {
104
+	$selectA = "SELECT category, catid FROM ".TABLEPREFIX."fanfiction_categories WHERE parentcatid = -1 ORDER BY displayorder";
105
+	$resultA = dbquery($selectA);
106
+	$countA = 1;
107
+	while($cat = dbassoc($resultA)) {
108
+		$count = 1;
109
+		if($cat['parentcatid'] = -1) {
110
+			dbquery("UPDATE ".TABLEPREFIX."fanfiction_categories SET displayorder = $countA WHERE catid = $cat[catid]");
111
+			$countA++;
112
+		}
113
+		$selectB = "SELECT category, catid FROM ".TABLEPREFIX."fanfiction_categories WHERE parentcatid = '$cat[catid]' ORDER BY displayorder";
114
+		$resultB = dbquery($selectB);
115
+		while($sub = dbassoc($resultB)) {
116
+			dbquery("UPDATE ".TABLEPREFIX."fanfiction_categories SET displayorder = $count WHERE catid = $sub[catid]");
117
+			$count++;
118
+		}
119
+	}
120
+	$output .= write_message(_ACTIONSUCCESSFUL);
121
+}
122
+else if($maint == "stats") {
123
+	// check that the statisics is working before doing anything else
124
+	$check = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_stats WHERE sitekey = '".SITEKEY."' LIMIT 1");
125
+	if(dbnumrows($check) < 1) dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_stats(`sitekey`) VALUES('".SITEKEY."')");
126
+
127
+	$serieslist = dbquery("SELECT seriesid FROM ".TABLEPREFIX."fanfiction_series");
128
+	$totalseries = dbnumrows($serieslist);
129
+	while($s = dbassoc($serieslist)) {
130
+		$numstories = count(storiesInSeries($s['seriesid']));
131
+		dbquery("UPDATE ".TABLEPREFIX."fanfiction_series SET numstories = '$numstories' WHERE seriesid = ".$s['seriesid']." LIMIT 1");
132
+	}
133
+
134
+	$newslist = dbquery("SELECT count(cid) as count, nid FROM ".TABLEPREFIX."fanfiction_comments GROUP BY nid");
135
+	while($n = dbassoc($newslist)) {
136
+		dbquery("UPDATE ".TABLEPREFIX."fanfiction_news SET comments = '".$n['count']."' WHERE nid = ".$n['nid']);
137
+	}
138
+
139
+	$storiesquery =dbquery("SELECT COUNT(sid) as totals, SUM(wordcount) as totalwords FROM ".TABLEPREFIX."fanfiction_stories WHERE validated > 0 ");
140
+
141
+	list($stories, $words) = dbrow($storiesquery);
142
+	list($authors) = dbrow(dbquery("SELECT count(uid) FROM ".TABLEPREFIX."fanfiction_authorprefs WHERE stories > 0"));
143
+	dbquery("UPDATE ".TABLEPREFIX."fanfiction_stats SET stories = '$stories', authors = '$authors', wordcount = '$words' WHERE sitekey = '".SITEKEY."'"); 
144
+
145
+	$chapterquery = dbquery("SELECT COUNT(chapid) as chapters FROM ".TABLEPREFIX."fanfiction_chapters where validated > 0");
146
+	list($chapters) = dbrow($chapterquery);
147
+
148
+	$authorquery = dbquery("SELECT COUNT("._UIDFIELD.") as totalm FROM "._AUTHORTABLE);
149
+	list($members) = dbrow($authorquery);
150
+
151
+	list($newest) = dbrow(dbquery("SELECT "._UIDFIELD." as uid FROM "._AUTHORTABLE." ORDER BY "._UIDFIELD." DESC LIMIT 1"));
152
+	$reviewquery = dbquery("SELECT COUNT(reviewid) as totalr FROM ".TABLEPREFIX."fanfiction_reviews WHERE review != 'No Review'");
153
+	list($reviews) = dbrow($reviewquery);
154
+	$reviewquery = dbquery("SELECT COUNT(DISTINCT uid) FROM ".TABLEPREFIX."fanfiction_reviews WHERE review != 'No Review' AND uid != 0");
155
+	list($reviewers) = dbrow($reviewquery);
156
+	dbquery("UPDATE ".TABLEPREFIX."fanfiction_stats SET series = '$totalseries', chapters = '$chapters', members = '$members', newestmember = '$newest', reviews = '$reviews', reviewers = '$reviewers' WHERE sitekey = '".SITEKEY."'"); 
157
+	$news = dbquery("SELECT count(nid) as count, nid FROM ".TABLEPREFIX."fanfiction_comments GROUP BY nid");
158
+	while($n = dbassoc($news)) {
159
+		dbquery("UPDATE ".TABLEPREFIX."fanfiction_news SET comments = '".$n['count']."' WHERE nid = '".$n['nid']."' LIMIT 1");
160
+	}
161
+	$output .= write_message(_ACTIONSUCCESSFUL);
162
+}
163
+else if($maint == "panels") {
164
+	$ptypes = dbquery("SELECT panel_type FROM ".TABLEPREFIX."fanfiction_panels GROUP BY panel_type");
165
+	while($ptype = dbassoc($ptypes)) {
166
+		if($ptype['panel_type'] == "A") {
167
+			for($x = 1; $x < 5; $x++) {
168
+				$count = 1;
169
+				$plist = dbquery("SELECT panel_name, panel_id FROM ".TABLEPREFIX."fanfiction_panels WHERE panel_hidden = '0' AND panel_type = '".$ptype['panel_type']."' AND panel_level = '$x' ORDER BY panel_level, panel_order");
170
+				while($p = dbassoc($plist)) {
171
+					dbquery("UPDATE ".TABLEPREFIX."fanfiction_panels SET panel_order = '$count' WHERE panel_id = '".$p['panel_id']."' LIMIT 1");
172
+					$count++;
173
+				}
174
+			}
175
+		}
176
+		else {
177
+			$count = 1;
178
+			$plist = dbquery("SELECT panel_name, panel_id FROM ".TABLEPREFIX."fanfiction_panels WHERE panel_hidden = '0' AND panel_type = '".$ptype['panel_type']."' ORDER BY ".($ptype['panel_type'] == "A" ? "panel_level," : "")."panel_order");
179
+			while($p = dbassoc($plist)) {
180
+				dbquery("UPDATE ".TABLEPREFIX."fanfiction_panels SET panel_order = '$count' WHERE panel_id = '".$p['panel_id']."' LIMIT 1");
181
+				$count++;
182
+			}
183
+		}
184
+	}
185
+	$output .= write_message(_ACTIONSUCCESSFUL);
186
+}
187
+else if($maint == "optimize") {
188
+	$alltables = dbquery("SHOW TABLES");
189
+
190
+	while ($table = dbassoc($alltables)) {
191
+		foreach ($table as $db => $tablename) {
192
+			dbquery("OPTIMIZE TABLE `".$tablename."`");
193
+		}
194
+	}
195
+ 	if($logging) dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_log (`log_action`, `log_uid`, `log_ip`, `log_type`) VALUES('".escapestring(sprintf(_LOG_OPTIMIZE, USERPENNAME, USERUID))."', '".USERUID."', INET_ATON('".$_SERVER['REMOTE_ADDR']."'), 'AM')");
196
+	$output .= write_message(_ACTIONSUCCESSFUL);
197
+}
198
+else if($maint == "backup") {
199
+}
200
+else {
201
+	$output .= "
202
+<ul>
203
+	<li><a href='admin.php?action=maintenance&amp;maint=reviews'>"._RECALCREVIEWS."</a> <A HREF=\"#\" class=\"pophelp\">[?]<span>"._HELP_RECALCREVIEWS."</span></A></li>
204
+	<li><a href='admin.php?action=maintenance&amp;maint=stories'>"._RECALCSTORIES."</a> <A HREF=\"#\" class=\"pophelp\">[?]<span>"._HELP_RECALCSTORIES."</span></A></li>
205
+	<li><a href='admin.php?action=maintenance&amp;maint=categories'>"._COUNTCATS."</a> <A HREF=\"#\" class=\"pophelp\">[?]<span>"._HELP_CATCOUNTS."</span></A></li>
206
+	<li><a href='admin.php?action=maintenance&amp;maint=categories2'>"._CATORDER."</a> <A HREF=\"#\" class=\"pophelp\">[?]<span>"._HELP_CATORDER."</span></A></li>
207
+	<li><a href='admin.php?action=maintenance&amp;maint=stats'>"._STATS."</a> <A HREF=\"#\" class=\"pophelp\">[?]<span>"._HELP_STATS."</span></A></li>
208
+	<li><a href='admin.php?action=maintenance&amp;maint=panels'>"._PANELORDER."</a> <A HREF=\"#\" class=\"pophelp\">[?]<span>"._HELP_PANELORDER."</span></A></li>
209
+	<li><a href='admin.php?action=maintenance&amp;maint=optimize'>"._OPTIMIZE."</a> <A HREF=\"#\" class=\"pophelp\">[?]<span>"._HELP_OPTIMIZE."</span></A></li>
210
+	<li><a href='admin/backup.php' target='_new'>"._BACKUP."</a> <A HREF=\"#\" class=\"pophelp\">[?]<span>"._HELP_BACKUP."</span></A></li>
211
+	<li><a href='admin.php?action=maintenance&amp;maint=update'>"._UPDATE."</a>  <A HREF=\"#\" class=\"pophelp\">[?]<span>"._HELP_UPDATE."</span></A></li>
212
+</ul>";
213
+}
214
+?>
0 215
\ No newline at end of file