PCCS MySQLDatabase Admin Tool version 1.3.4


/ -> mysqldb_create_newssystem.php

1  <?php
2  /************************************************************************
3  PCCS MySQLDatabase Admin Tool
4  Copyright (C) Chauncey Thorn
5 
6  This program is free software; you can redistribute it and/or
7  modify it under the terms of the GNU General Public License
8  as published by the Free Software Foundation; either version 2
9  of the License, or (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program; if not, write to the Free Software
18  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA , USA.
19  **************************************************************************/
20 
21  ///////////////////////////////////////////////////////////////////////////////
22  // Create testnews.php
23  // no need to modify unless you like hacking
24  // bugs report to cthorn
25  ///////////////////////////////////////////////////////////////////////////////
26     $newsystemdir = "newssystem/";
27 
28  if(!@mkdir($appfiledir . $newsystemdir,0777)) {
29     echo "Failed to Make Directory";
30  } else {
31    $newsysdir = $appfiledir . $newsystemdir;
32  }
33 
34  $testnews_filename="testnews.php";
35 
36  $testnews = fopen($newsysdir . $testnews_filename,"w");
37  fputs($testnews,"<?php\n//** Generated by PCCS-MyAppGen $today\n");
38  fputs($testnews,"/////////////////////////////////////////////////////////////////////////////////////\n");
39  fputs($testnews,"// coder: cthorn\n");
40  fputs($testnews,"////////////////////////////////////////////////////////////////////////////\n");
41  fputs($testnews,"//\n");
42  fputs($testnews,"//\n");
43  fputs($testnews,"require('newsfunction.php');\n");
44  fputs($testnews,"\n");
45  fputs($testnews,"displayNewsStories(10,\"440\");\n");
46  fputs($testnews,"\n");
47  fputs($testnews,"\n");
48 
49  fputs($testnews,"//\n");
50  fputs($testnews,"//////////////////////////////////////////////////////////////////////////\n");
51  fputs($testnews,"?>\n");
52  fclose($testnews);
53 
54 
55 
56  ///////////////////////////////////////////////////////////////////////////////
57  // Create newsfunction.php
58  // no need to modify unless you like hacking
59  // bugs report to cthorn
60  ///////////////////////////////////////////////////////////////////////////////
61 
62  $newsfunction_filename="newsfunction.php";
63 
64  $newsfunction = fopen($newsysdir . $newsfunction_filename,"w");
65  fputs($newsfunction,"<?php\n//** Generated by PCCS-MyAppGen $today\n");
66  fputs($newsfunction,"/////////////////////////////////////////////////////////////////////////////////////\n");
67  fputs($newsfunction,"// coder: cthorn\n");
68  fputs($newsfunction,"////////////////////////////////////////////////////////////////////////////\n");
69  fputs($newsfunction,"//\n");
70  fputs($newsfunction,"//\n");
71  fputs($newsfunction,"function displayNewsStories(\$MAX_NUM_STORIES_TO_SHOW = \"\",\$tbl_width=\"\")\n");
72  fputs($newsfunction,"{\n");
73  fputs($newsfunction,"// global \$dbhandle,\$bgcolor,\$bgtext,\$tcolor,\$ttext,\$fcolor,\$ftext,\$link;\n");
74  fputs($newsfunction,"\n");
75  fputs($newsfunction," if (\$tbl_width == \"\"){\n");
76  fputs($newsfunction," \$tbl_width = 300 ;\n");
77  fputs($newsfunction," }\n");
78  fputs($newsfunction," if (\$MAX_NUM_STORIES_TO_SHOW == \"\"){\n");
79  fputs($newsfunction," \$MAX_NUM_STORIES_TO_SHOW = 6 ;\n");
80  fputs($newsfunction," }\n");
81  fputs($newsfunction,"?> \n");
82  fputs($newsfunction,"\n");
83  fputs($newsfunction,"<?php\n");
84  fputs($newsfunction,"require('../dbinclude.php');\n");
85  fputs($newsfunction,"\n");
86  fputs($newsfunction," \$SQLText = \"SELECT news_id, news_story_date, news_story_title,\n");
87  fputs($newsfunction," news_story_active, news_story_test,\n");
88  fputs($newsfunction," news_story_author, news_story_html\n");
89  fputs($newsfunction," FROM news \n");
90  fputs($newsfunction," WHERE news_story_active = 1 order by\n");
91  fputs($newsfunction," news_story_date desc\";\n");
92  fputs($newsfunction,"\n");
93  fputs($newsfunction,"\n");
94  fputs($newsfunction,"\n");
95  fputs($newsfunction,"\$news_query = mysql_query(\$SQLText, \$dbhandle);\n");
96  fputs($newsfunction,"\n");
97  fputs($newsfunction,"if (\$news_query == 0 ) {\n");
98  fputs($newsfunction," \$error=1;\n");
99  fputs($newsfunction,"}\n");
100  fputs($newsfunction,"\n");
101  fputs($newsfunction,"if (\$error != 1){\n");
102  fputs($newsfunction," \$num_rows = mysql_num_rows(\$news_query);\n");
103  fputs($newsfunction," if (\$num_rows > \$MAX_NUM_STORIES_TO_SHOW){\n");
104  fputs($newsfunction," \$num_rows = \$MAX_NUM_STORIES_TO_SHOW;\n");
105  fputs($newsfunction," }\n");
106  fputs($newsfunction,"} \n");
107  fputs($newsfunction," \n");
108  fputs($newsfunction,"?>\n");
109 
110  fputs($newsfunction,"<? if (\$test_view == 1) {?><a href=\"newsadmin.php\">\n");
111  fputs($newsfunction,"<font color=\"#FF0000\" face=\"arial,helvetica\" size=2>Testing - Go Back To\n");
112  fputs($newsfunction,"News Admin</font></a><br><?}?>\n");
113  fputs($newsfunction,"<?\n");
114  fputs($newsfunction,"if (\$error != 1){\n");
115  fputs($newsfunction," for (\$i=0; \$i < \$num_rows; \$i++){\n");
116  fputs($newsfunction," \$row = mysql_fetch_array(\$news_query);\n");
117  fputs($newsfunction," \$datetime = \$row[\"news_story_date\"];\n");
118  fputs($newsfunction," \$year = strtok(\$datetime, \"- :\");\n");
119  fputs($newsfunction," \$month = strtok(\"- :\");\n");
120  fputs($newsfunction," \$day = strtok(\"- :\");\n");
121  fputs($newsfunction," \$hour = strtok(\"- :\");\n");
122  fputs($newsfunction," \$minute = strtok(\"- :\");\n");
123  fputs($newsfunction," \$second = strtok(\"- :\");\n");
124  fputs($newsfunction," \$timestamp = mktime((int)\$hour, (int)\$minute, (int)\$second, (int)\$month,
125  (int)\$day, (int)\$year);\n");
126  fputs($newsfunction,"?>\n");
127  fputs($newsfunction,"\n");
128  fputs($newsfunction,"<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"<?echo $tbl_width;?>\">\n");
129  fputs($newsfunction,"<tr bgcolor=#<?echo \$bgcolor;?>>\n");
130  fputs($newsfunction,"<td width=\"<?echo \$tbl_width;?>\" height=\"20\" align=\"LEFT\" valign=\"TOP\">\n");
131  fputs($newsfunction,"<font face=\"arial,helvetica\" size=\"2\" >\n");
132  fputs($newsfunction,"<b> &nbsp;&nbsp;<? echo \$row[\"news_story_title\"] ?> </font></b>\n");
133  fputs($newsfunction,"<b><i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Posted by <?
134  echo \$row[\"news_story_author\"] ?></i></b>\n");
135  fputs($newsfunction,"</td>\n");
136  fputs($newsfunction,"<td>\n");
137  fputs($newsfunction,"<font face=\"arial,helvetica\" size=\"-1\" >\n");
138  fputs($newsfunction,"\n");
139  fputs($newsfunction,"<b><i><? echo date(\"m.d.Y H:i\", \$timestamp) ?></i></b><br>\n");
140  fputs($newsfunction,"</font>\n");
141  fputs($newsfunction,"</td>\n");
142  fputs($newsfunction,"</tr>\n");
143  fputs($newsfunction,"</table>\n");
144  fputs($newsfunction,"<table border=\"0\" cellpadding=\"7\" cellspacing=\"0\" width=\"<?echo \$tbl_width;?>\">\n");
145  fputs($newsfunction,"<tr>\n");
146  fputs($newsfunction,"<td background=\"images/index_news_content.gif\">\n");
147  fputs($newsfunction,"<font face=\"arial,helvetica\" size=\"2\" >\n");
148  fputs($newsfunction,"<? echo \$row[\"news_story_html\"] ?>\n");
149  fputs($newsfunction,"<p>\n");
150  fputs($newsfunction,"</td>\n");
151  fputs($newsfunction,"</font></tr>\n");
152  fputs($newsfunction,"</table>\n");
153  fputs($newsfunction,"<?\n");
154  fputs($newsfunction," }\n");
155  fputs($newsfunction,"}\n");
156  fputs($newsfunction,"?>\n");
157  fputs($newsfunction,"\n");
158  fputs($newsfunction,"<?\n");
159  fputs($newsfunction,"} // End of displayNewsStories\n");
160  fputs($newsfunction,"//\n");
161  fputs($newsfunction,"//////////////////////////////////////////////////////////////////////////\n");
162  fputs($newsfunction,"?>\n");
163  fclose($newsfunction);
164  ///
165 
166  ///////////////////////////////////////////////////////////////////////////////
167  // Create editnews.php
168  // no need to modify unless you like hacking
169  // bugs report to cthorn
170  ///////////////////////////////////////////////////////////////////////////////
171 
172 
173  $editnews_filename="editnews.php";
174 
175  $editnews = fopen($newsysdir . $editnews_filename,"w");
176  fputs($editnews,"<?php\n//** Generated by PCCS-MyAppGen $today\n");
177  fputs($editnews,"/////////////////////////////////////////////////////////////////////////////////////\n");
178  fputs($editnews,"// coder: cthorn\n");
179  fputs($editnews,"////////////////////////////////////////////////////////////////////////////\n");
180  fputs($editnews,"//\n");
181  fputs($editnews,"require('../dbinclude.php');\n");
182  fputs($editnews,"\n");
183  fputs($editnews,"\$LIST_STORIES_PAGE = \"newsadmin.php\";\n");
184  fputs($editnews,"\n");
185  fputs($editnews,"\n");
186  fputs($editnews,"if (\$running_form != \"\") {\n");
187  fputs($editnews," if (\$story_id == \"\"){\n");
188  fputs($editnews," \$story_id = 0;\n");
189  fputs($editnews," }\n");
190  fputs($editnews," \$strTitle = ereg_replace(\"'\", \"''\", \$strTitle);\n");
191  fputs($editnews," \$strHTML = ereg_replace(\"'\", \"''\", \$strHTML);\n");
192  fputs($editnews," \$strAuthor = ereg_replace(\"'\", \"''\", \$strAuthor);\n");
193  fputs($editnews,"\n");
194  fputs($editnews," //see if new record\n");
195  fputs($editnews," if (\$story_id > 0){\n");
196  fputs($editnews," //'Update current Story\n");
197  fputs($editnews," \$SQLText = \"Update news set news_story_title = '\" . \$strTitle . \"',
198  news_story_author = '\" . \$strAuthor . \"' , news_story_date = '\" . date(\"Y-m-d H:i:s\") . \"',
199  news_story_html = '\" . \$strHTML . \"' where news_id = \" . \$story_id;\n");
200  fputs($editnews," }\n");
201  fputs($editnews," else {\n");
202  fputs($editnews," //Insert New Story\n");
203  fputs($editnews," \$SQLText = \"Insert into news (news_story_title, news_story_active, news_story_test, news_story_author, news_story_date, news_story_html) \" .\n");
204  fputs($editnews," \"values ('\" . \$strTitle . \"',0,0,'\" . \$strAuthor . \"','\" . date(\"Y-m-d H:i:s\") . \"','\" . \$strHTML . \"')\";\n");
205  fputs($editnews,"\n");
206  fputs($editnews," }\n");
207  fputs($editnews,"\n");
208  fputs($editnews,"\n");
209  fputs($editnews," \$rs_handle = mysql_query(\$SQLText, \$dbhandle) or\n");
210  fputs($editnews," die(\"Query Failed\");\n");
211  fputs($editnews," \$num_affected = mysql_affected_rows(\$dbhandle);\n");
212  fputs($editnews,"\n");
213  fputs($editnews,"\n");
214  fputs($editnews,"\n");
215  fputs($editnews," if (\$num_affected != 1) {\n");
216  fputs($editnews," print \"There was an Error\";\n");
217  fputs($editnews," print mysql_error();\n");
218  fputs($editnews," exit;\n");
219  fputs($editnews," }\n");
220  fputs($editnews," else {\n");
221  fputs($editnews," header(\"Location: \$LIST_STORIES_PAGE\");\n");
222  fputs($editnews," exit;\n");
223  fputs($editnews," }\n");
224  fputs($editnews,"}\n");
225  fputs($editnews,"\n");
226  fputs($editnews,"else{\n");
227  fputs($editnews," if ((\$story_id != \"\") or (\$story_id > 0)) {\n");
228  fputs($editnews," //Edit Curtent Story\n");
229  fputs($editnews," \$SQLText = \"Select news_id, news_story_title, news_story_active, news_story_test,
230  news_story_author, news_story_html from news where news_id = \" . \$story_id;\n");
231  fputs($editnews,"\n");
232  fputs($editnews," \$rs_handle = mysql_query(\$SQLText, \$dbhandle);\n");
233  fputs($editnews,"\n");
234  fputs($editnews," if (\$rs_handle == 0) {\n");
235  fputs($editnews," header(\"Location: \$ERROR_PAGE\");\n");
236  fputs($editnews," exit;\n");
237  fputs($editnews," }\n");
238  fputs($editnews," \$num_affected = mysql_num_rows(\$rs_handle);\n");
239  fputs($editnews," if (\$num_affected == 0 ) {\n");
240  fputs($editnews," header(\"Location: \$ERROR_PAGE\");\n");
241  fputs($editnews," exit;\n");
242  fputs($editnews," }\n");
243  fputs($editnews," \$rs = mysql_fetch_array(\$rs_handle);\n");
244  fputs($editnews," if (\$rs[\"news_story_active\"] == 1) {\n");
245  fputs($editnews," header(\"Location: \" . \$LIST_STORIES_PAGE . \"?errortype=active\");\n");
246  fputs($editnews," exit;\n");
247  fputs($editnews," }\n");
248  fputs($editnews,"\n");
249  fputs($editnews," \$story_id = \$rs[\"news_id\"];\n");
250  fputs($editnews," \$strTitle = \$rs[\"news_story_title\"];\n");
251  fputs($editnews," \$strHTML = \$rs[\"news_story_html\"];\n");
252  fputs($editnews," \$strAuthor = \$rs[\"news_story_author\"];\n");
253  fputs($editnews," }\n");
254  fputs($editnews," else {\n");
255  fputs($editnews," \$story_id = \"\";\n");
256  fputs($editnews," \$strTitle = \"\";\n");
257  fputs($editnews," \$strHTML = \"\";\n");
258  fputs($editnews," \$strAuthor = \"\";\n");
259  fputs($editnews," }\n");
260  fputs($editnews,"}\n");
261  fputs($editnews,"?>\n");
262  fputs($editnews,"<?\n");
263  // fputs($editnews,"/* Read in constants used over the whole site */\n");
264  // fputs($editnews,"require('site_const.phi');\n");
265  fputs($editnews,"?>\n");
266  fputs($editnews,"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n");
267  fputs($editnews,"\n");
268  fputs($editnews,"<html>\n");
269  fputs($editnews,"<head>\n");
270  fputs($editnews," <title>News - <? If (\$strTitle ==\"\") {?>Untitled<? }else{ ?><?echo \$strTitle ?><? } ?></title>\n");
271  fputs($editnews,"</head>\n");
272  fputs($editnews,"\n");
273  fputs($editnews," <BODY BGCOLOR= \"#<?echo \$bgcolor;?>\"\n");
274  fputs($editnews," TEXT=\"#<?echo \$bgtext;?>\"\n");
275  fputs($editnews," LINK=\"#<?echo \$link;?>\"\n");
276  fputs($editnews," VLINK=\"#<?echo \$link;?>\"\n");
277  fputs($editnews," ALINK=\"#ffffff\">\n");
278  fputs($editnews,"<div align=\"center\">\n");
279  fputs($editnews,"\n");
280  fputs($editnews,"<table border=\"4\" cellpadding=\"7\" cellspacing=\"0\" width=\"581\">\n");
281  fputs($editnews,"<tr bgcolor=#<?echo \$tcolor;?>>\n");
282  fputs($editnews,"<td>&nbsp;</td>\n");
283  fputs($editnews,"</tr>\n");
284  fputs($editnews,"<tr bgcolor=#<?echo \$fcolor;?>>\n");
285  fputs($editnews,"<td><font face=\"arial,helvetica\" size=\"2\">\n");
286  fputs($editnews,"<form action=\"editnews.php\" method=\"POST\">\n");
287  fputs($editnews,"<input type=\"Hidden\" name=\"running_form\" value=\"true\">\n");
288  fputs($editnews,"<input type=\"Hidden\" name=\"story_id\" value=\"<? echo \$story_id ?>\">\n");
289  fputs($editnews,"<table border=0 cellpadding=3 cellspacing=0 background=\"\">\n");
290  fputs($editnews,"<tr>\n");
291  fputs($editnews,"<td align=\"RIGHT\" bgcolor=#<?echo \$fcolor;?>><font face=\"arial,helvetica\" size=\"2\" >Title</font></td>\n");
292  fputs($editnews,"<td bgcolor=#<?echo \$fcolor;?>><input type=\"Text\" name=\"strTitle\" value=\"<? echo \$strTitle ?>\"
293  size=\"58\" maxlength=\"80\"><font face=\"arial,helvetica\" size=\"1\">&nbsp;</font></td>\n");
294  fputs($editnews,"</tr>\n");
295  fputs($editnews,"<tr>\n");
296  fputs($editnews,"<td bgcolor=#<?echo \$fcolor;?> align=\"right\"><font face=\"arial,helvetica\" size=\"2\" >Author</font></td>\n");
297  fputs($editnews,"<td bgcolor=#<?echo \$fcolor;?>><input type=\"Text\" name=\"strAuthor\" value=\"<? echo \$strAuthor
298  ?>\" size=\"20\" maxlength=\"20\"><font face=\"arial,helvetica\" size=\"1\">&nbsp;</font></td>\n");
299  fputs($editnews,"</tr>\n");
300  fputs($editnews,"<tr>\n");
301  fputs($editnews,"<td bgcolor=#<?echo \$fcolor;?> align=\"right\" valign=\"top\">\n");
302  fputs($editnews,"<font face=\"arial,helvetica\" size=\"2\" ><br><br>News in HTML</font></td>\n");
303  fputs($editnews,"<td bgcolor=#<?echo \$fcolor;?>><TEXTAREA NAME=\"strHTML\" ROWS=25 COLS=88><?echo \$strHTML ?></TEXTAREA></td>\n");
304  fputs($editnews,"</tr>\n");
305  fputs($editnews,"</table><center>\n");
306  fputs($editnews,"<input type=submit value=\"Post News Story\" border=0>\n");
307  fputs($editnews,"</center>\n");
308  fputs($editnews,"</form>\n");
309  fputs($editnews,"</td>\n");
310  fputs($editnews,"</font></tr>\n");
311  fputs($editnews,"<tr bgcolor=#<?echo \$tcolor;?>>\n");
312  fputs($editnews,"<td>&nbsp;</td>\n");
313  fputs($editnews,"</tr>\n");
314  fputs($editnews,"</table>\n");
315  fputs($editnews,"\n");
316  fputs($editnews,"</div>\n");
317  fputs($editnews,"</body>\n");
318  fputs($editnews,"</html>\n");
319  fputs($editnews,"//\n");
320  fputs($editnews,"//////////////////////////////////////////////////////////////////////////\n");
321  fputs($editnews,"?>\n");
322  fclose($editnews);
323 
324 
325  ///////////////////////////////////////////////////////////////////////////////
326  // Create movenews.php
327  // no need to modify unless you like hacking
328  // bugs report to cthorn
329  ///////////////////////////////////////////////////////////////////////////////
330 
331 
332  $movenews_filename="movenews.php";
333 
334  $movenews = fopen($newsysdir . $movenews_filename,"w");
335  fputs($movenews,"<?php\n//** Generated by PCCS-MyAppGen $today\n");
336  fputs($movenews,"/////////////////////////////////////////////////////////////////////////////////////\n");
337  fputs($movenews,"// coder: cthorn\n");
338  fputs($movenews,"////////////////////////////////////////////////////////////////////////////\n");
339  fputs($movenews,"//\n");
340  fputs($movenews,"\n");
341  fputs($movenews,"\$ERROR_PAGE = \"site_admin_error.html\";\n");
342  fputs($movenews,"\$LIST_STORIES_PAGE = \"newsadmin.php\";\n");
343  fputs($movenews,"\n");
344  fputs($movenews,"\n");
345  fputs($movenews,"require('../dbinclude.php');\n");
346  fputs($movenews,"\n");
347  fputs($movenews,"\n");
348  fputs($movenews,"/*Move Story from active to test*/\n");
349  fputs($movenews,"if (\$active_to_test > 0) {\n");
350  fputs($movenews," \$SQLText = \"Update news set news_story_active = 0 where news_id =\" . \$active_to_test;\n");
351  fputs($movenews," \$atot_query_handle = mysql_query(\$SQLText, \$dbhandle);\n");
352  fputs($movenews," header(\"Location: \$LIST_STORIES_PAGE\");\n");
353  fputs($movenews," if (\$atot_query_handle > 0){\n");
354  fputs($movenews," \$error=0;\n");
355  fputs($movenews," }\n");
356  fputs($movenews," else {\n");
357  fputs($movenews," \$error=1;\n");
358  fputs($movenews," }\n");
359  fputs($movenews,"}\n");
360  fputs($movenews,"/* Move Story From test to Active */\n");
361  fputs($movenews,"if (\$test_to_active > 0) {\n");
362  fputs($movenews," \$SQLText = \"Update news set news_story_active = 1 where news_id =\" . \$test_to_active;\n");
363  fputs($movenews," \$ttoa_query_handle = mysql_query(\$SQLText, \$dbhandle);\n");
364  fputs($movenews," if (\$ttoa_query_handle > 0){\n");
365  fputs($movenews," \$error=0;\n");
366  fputs($movenews," }\n");
367  fputs($movenews," else {\n");
368  fputs($movenews," \$error=1;\n");
369  fputs($movenews," }\n");
370  fputs($movenews,"}\n");
371  fputs($movenews,"\n");
372  fputs($movenews,"/*Move Story From test to working*/\n");
373  fputs($movenews,"if (\$test_to_working > 0) {\n");
374  fputs($movenews," \$SQLText = \"Update news set news_story_test = 0 where news_id =\" . \$test_to_working;\n");
375  fputs($movenews," \$ttow_query_handle = mysql_query(\$SQLText, \$dbhandle);\n");
376  fputs($movenews," if (\$ttow_query_handle > 0){\n");
377  fputs($movenews," \$error=0;\n");
378  fputs($movenews," }\n");
379  fputs($movenews," else {\n");
380  fputs($movenews," \$error=1;\n");
381  fputs($movenews," }\n");
382  fputs($movenews,"}\n");
383  fputs($movenews,"\n");
384  fputs($movenews,"\n");
385  fputs($movenews,"/*'Move Story from working to test*/\n");
386  fputs($movenews,"if (\$working_to_test > 0) {\n");
387  fputs($movenews," \$SQLText = \"Update news set news_story_test = 1 where news_id =\" . \$working_to_test;\n");
388  fputs($movenews," \$wtot_query_handle = mysql_query(\$SQLText, \$dbhandle);\n");
389  fputs($movenews," if (\$wtot_query_handle > 0){\n");
390  fputs($movenews," \$error=0;\n");
391  fputs($movenews," }\n");
392  fputs($movenews," else {\n");
393  fputs($movenews," \$error=1;\n");
394  fputs($movenews," }\n");
395  fputs($movenews,"}\n");
396  fputs($movenews,"\n");
397  fputs($movenews,"/*'Move Story from working to test*/\n");
398  fputs($movenews,"if (\$delete > 0) {\n");
399  fputs($movenews," \$SQLText = \"delete from news where news_story_active=0 and news_id=\" . \$delete;\n");
400  fputs($movenews," \$delete_query_handle = mysql_query(\$SQLText, \$dbhandle);\n");
401  fputs($movenews," if (\$delete_query_handle > 0){\n");
402  fputs($movenews," \$error=0;\n");
403  fputs($movenews," }\n");
404  fputs($movenews," else {\n");
405  fputs($movenews," \$error=1;\n");
406  fputs($movenews," }\n");
407  fputs($movenews,"}\n");
408  fputs($movenews,"if (\$error == 0){\n");
409  fputs($movenews," header(\"Location: \$LIST_STORIES_PAGE\");\n");
410  fputs($movenews,"}\n");
411  fputs($movenews,"else {\n");
412  fputs($movenews," header(\"Location: \$ERROR_PAGE\");\n");
413  fputs($movenews,"}\n");
414  fputs($movenews,"\n");
415  fputs($movenews,"//\n");
416  fputs($movenews,"//////////////////////////////////////////////////////////////////////////\n");
417  fputs($movenews,"?>\n");
418  fclose($movenews);
419 
420 
421  ///////////////////////////////////////////////////////////////////////////////
422  // Create newsadmin.php
423  // no need to modify unless you like hacking
424  // bugs report to cthorn
425  ///////////////////////////////////////////////////////////////////////////////
426 
427  $newsadmin_filename="newsadmin.php";
428  $newsadmin = fopen($newsysdir . $newsadmin_filename,"w");
429  fputs($newsadmin,"<?php\n//** Generated by PCCS-MyAppGen $today\n");
430  fputs($newsadmin,"/////////////////////////////////////////////////////////////////////////////////////\n");
431  fputs($newsadmin,"// coder: cthorn\n");
432  fputs($newsadmin,"////////////////////////////////////////////////////////////////////////////\n");
433  fputs($newsadmin,"//\n");
434  fputs($newsadmin,"require('../dbinclude.php');\n");
435  fputs($newsadmin,"\n");
436  fputs($newsadmin,"\$MAX_NUM_STORIES_TO_SHOW = 10;\n");
437  fputs($newsadmin,"\n");
438  fputs($newsadmin,"//Active Stories.....\n");
439  fputs($newsadmin,"\$SQLText = \"Select news_id, news_story_title, news_story_active, news_story_test, news_story_author,
440  news_story_html from news where news_story_active = 1 order by news_story_date desc\";\n");
441  fputs($newsadmin,"\$active_query_handle = mysql_query(\$SQLText, \$dbhandle);\n");
442  fputs($newsadmin,"if (\$active_query_handle > 0){\n");
443  fputs($newsadmin," \$num_active_stories = mysql_num_rows(\$active_query_handle);\n");
444  fputs($newsadmin,"}\n");
445  fputs($newsadmin,"\n");
446  fputs($newsadmin,"// Test Stories\n");
447  fputs($newsadmin,"\$testsql = \"Select news_id, news_story_title, news_story_active, news_story_test, news_story_author
448  from news where news_story_test = 1 and news_story_active = 0 order by news_id\";\n");
449  fputs($newsadmin,"\$test_query_handle = mysql_query(\$testsql, \$dbhandle);\n");
450  fputs($newsadmin,"if (\$test_query_handle >0){\n");
451  fputs($newsadmin," \$num_test_stories = mysql_num_rows(\$test_query_handle);\n");
452  fputs($newsadmin,"}\n");
453  fputs($newsadmin,"\n");
454  fputs($newsadmin,"// Working Stories\n");
455  fputs($newsadmin,"\n");
456  fputs($newsadmin,"\$worksql = \"Select news_id, news_story_title, news_story_active, news_story_test, news_story_author,
457  news_story_html from news where news_story_test = 0 and news_story_active = 0 order by news_story_date\";\n");
458  fputs($newsadmin,"\$working_query_handle = mysql_query(\$worksql, \$dbhandle);\n");
459  fputs($newsadmin,"if (\$working_query_handle >0){\n");
460  fputs($newsadmin," \$num_working_stories = mysql_num_rows(\$working_query_handle);\n");
461  fputs($newsadmin,"}\n");
462  fputs($newsadmin,"\n");
463  fputs($newsadmin,"?>\n");
464  fputs($newsadmin,"\n");
465  fputs($newsadmin,"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n");
466  fputs($newsadmin,"\n");
467  fputs($newsadmin,"<html>\n");
468  fputs($newsadmin,"<head>\n");
469  fputs($newsadmin," <title>Site News -> Admin -> News Admin</title>\n");
470  fputs($newsadmin,"</head>\n");
471  fputs($newsadmin,"\n");
472  fputs($newsadmin," <BODY BGCOLOR= \"#<?echo \$bgcolor;?>\" \n");
473  fputs($newsadmin," TEXT=\"#<?echo \$bgtext;?>\"\n");
474  fputs($newsadmin," LINK=\"#<?echo \$link;?>\"\n");
475  fputs($newsadmin," VLINK=\"#<?echo \$link;?>\"\n");
476  fputs($newsadmin," ALINK=\"#ffffff\">\n");
477  fputs($newsadmin,"\n");
478  fputs($newsadmin,"<div align=\"center\">\n");
479  fputs($newsadmin,"\n");
480  fputs($newsadmin," <table border=\"4\" cellpadding=\"0\" cellspacing=\"0\" width=\"500\"\n");
481  fputs($newsadmin,"bgcolor=\"#FFFFFF\">\n");
482  fputs($newsadmin," <tr bgcolor=#<?echo \$tcolor;?>>\n");
483  fputs($newsadmin," <td>&nbsp;</td>\n");
484  fputs($newsadmin," </tr>\n");
485  fputs($newsadmin," <tr valign=\"TOP\" bgcolor=#<?echo \$fcolor;?>>\n");
486  fputs($newsadmin,"\n");
487  fputs($newsadmin," <!-- Top of left menu -->\n");
488  fputs($newsadmin," <!-- Bottom of left menu -->\n");
489  fputs($newsadmin," <!-- Begin Content Area -->\n");
490  fputs($newsadmin," <td valign=\"TOP\" align=\"CENTER\">\n");
491  fputs($newsadmin," [ <a href=\"newsadmin.php\">News Admin</a>&nbsp;\n");
492  fputs($newsadmin," - <a href=\"editnews.php\">Add New Story</a>&nbsp;\n");
493  fputs($newsadmin," - <a href=\"testnews.php?test_view=1\">News Test</a> ]\n");
494  fputs($newsadmin,"\n");
495  fputs($newsadmin," <center>\n");
496  fputs($newsadmin," <font face=\"arial,helvetica\" color=\"#ffffff\"><strong> NEWS ADMIN</strong></font><br>\n");
497  fputs($newsadmin,"\n");
498  fputs($newsadmin,"<? if (\$errortype != \"\"){ ?>\n");
499  fputs($newsadmin,"\n");
500  fputs($newsadmin," <? If (\$errortype == \"active\") { ?>\n");
501  fputs($newsadmin," <table cellpadding=2 cellspacing=1 border=0>\n");
502  fputs($newsadmin,"\n");
503  fputs($newsadmin," <tr bgcolor=#<?echo \$fcolor;?>>\n");
504  fputs($newsadmin," <td><font face=\"arial,helvetica\" color=\"#000000\">\n");
505  fputs($newsadmin," <strong>Error: Cannot Edit an Active Story - Move it Back to Test</strong></font></td>\n");
506  fputs($newsadmin," </tr>\n");
507  fputs($newsadmin," </table>\n");
508  fputs($newsadmin," <? } ?>\n");
509  fputs($newsadmin,"<? } ?>\n");
510  fputs($newsadmin,"\n");
511  fputs($newsadmin," <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n");
512  fputs($newsadmin,"\n");
513  fputs($newsadmin," <!-- Begin Content -->\n");
514  fputs($newsadmin," <tr>\n");
515  fputs($newsadmin,"\n");
516  fputs($newsadmin," <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"640\">\n");
517  fputs($newsadmin," <tr bgcolor=#<?echo \$tcolor;?>>\n");
518  fputs($newsadmin," <td>&nbsp;</td>\n");
519  fputs($newsadmin," </tr>\n");
520  fputs($newsadmin," <tr bgcolor=#<?echo \$fcolor;?>>\n");
521  fputs($newsadmin," <td width=\"581\" height=\"20\" align=\"LEFT\" valign=\"MIDDLE\" >\n");
522  fputs($newsadmin," <font face=\"arial,helvetica\" size=\"2\"><b>&nbsp;&nbsp;Active Stories</b></font></td>\n");
523  fputs($newsadmin," </tr>\n");
524  fputs($newsadmin," </table>\n");
525  fputs($newsadmin,"\n");
526  fputs($newsadmin," <table border=\"0\" cellpadding=\"7\" cellspacing=\"0\" width=\"581\">\n");
527  fputs($newsadmin," <tr bgcolor=#<?echo \$fcolor;?>>\n");
528  fputs($newsadmin," <td><font face=\"arial,helvetica\" size=\"2\">\n");
529  fputs($newsadmin," <!-- Title Font -->\n");
530  fputs($newsadmin," <font face=\"arial,helvetica\" size=\"2\">Note: Only the Latest <? echo \$MAX_NUM_STORIES_TO_SHOW ?> stories are available</font><br>\n");
531  fputs($newsadmin," <center>\n");
532  fputs($newsadmin," <table width=\"550\" border=\"0\" cellspacing=\"0\" cellpadding=\"3\" >\n");
533  fputs($newsadmin,"<? if (\$num_active_stories == 0 ) {?>\n");
534  fputs($newsadmin,"\n");
535  fputs($newsadmin," <tr bgcolor=\"#000000\">\n");
536  fputs($newsadmin," <td colspan=5 bgcolor=\"white\">\n");
537  fputs($newsadmin," <font face=\"arial,helvetica\" size=\"1\" color=\"#000000\"><b>Warning!! No Current Active Stories</b></font></td>\n");
538  fputs($newsadmin," </tr>\n");
539  fputs($newsadmin,"<?}\n");
540  fputs($newsadmin," else {\n");
541  fputs($newsadmin," ?>\n");
542  fputs($newsadmin," <tr bgcolor=#<?echo \$fcolor;?>>\n");
543  fputs($newsadmin," <td align=\"CENTER\" ><font face=\"arial,helvetica\" size=\"1\"><b>Story ID</b></font></td>\n");
544  fputs($newsadmin," <td ><font face=\"arial,helvetica\" size=\"1\" ><b>Title</b></font></td>\n");
545  fputs($newsadmin," <td ><font face=\"arial,helvetica\" size=\"1\"><b>Author</b></font></td>\n");
546  fputs($newsadmin," <td ><font face=\"arial,helvetica\" size=\"1\"><b>Status</b></font></td>\n");
547  fputs($newsadmin," <td align=\"CENTER\" bgcolor=#<?echo \$fcolor;?>>\n");
548  fputs($newsadmin," <font face=\"arial,helvetica\" size=\"1\" color=\"RED\"><b>Demote to Test</b></font></td>\n");
549  fputs($newsadmin," </tr>\n");
550  fputs($newsadmin,"<?\n");
551  fputs($newsadmin," if (\$num_active_stories >= \$MAX_NUM_STORIES_TO_SHOW){\n");
552  fputs($newsadmin," \$num_active_stories = \$MAX_NUM_STORIES_TO_SHOW;\n");
553  fputs($newsadmin," }\n");
554  fputs($newsadmin," for (\$i=0; \$i < \$num_active_stories; \$i++){\n");
555  fputs($newsadmin," \$row = mysql_fetch_array(\$active_query_handle);\n");
556  fputs($newsadmin,"?>\n");
557  fputs($newsadmin," <tr bgcolor=\"White\">\n");
558  fputs($newsadmin," <td align=\"CENTER\"><font face=\"arial,helvetica\" size=\"1\"><? echo \$row[\"news_id\"] ?></font></td>\n");
559  fputs($newsadmin," <td><font face=\"arial,helvetica\" size=\"1\"><? echo \$row[\"news_story_title\"] ?></td>\n");
560  fputs($newsadmin," <td><font face=\"arial,helvetica\" size=\"1\"><? echo \$row[\"news_story_author\"] ?></font></td>\n");
561  fputs($newsadmin," <td><font face=\"arial,helvetica\" size=\"1\"><b>ACTIVE</b></font></td>\n");
562  fputs($newsadmin," <td align=\"CENTER\"><font face=\"arial,helvetica\" size=\"1\">\n");
563  fputs($newsadmin," <a href=\"movenews.php?active_to_test=<? echo \$row[\"news_id\"] ?>\">\n");
564  fputs($newsadmin," Demote to Test</a></font></td>\n");
565  fputs($newsadmin," </tr>\n");
566  fputs($newsadmin,"<?\n");
567  fputs($newsadmin," } // end of active story for loop\n");
568  fputs($newsadmin,"} // end of else statement for # of active stories\n");
569  fputs($newsadmin,"?>\n");
570  fputs($newsadmin," </table>\n");
571  fputs($newsadmin," </center>\n");
572  fputs($newsadmin," </td>\n");
573  fputs($newsadmin," </font></tr>\n");
574  fputs($newsadmin," </table>\n");
575  fputs($newsadmin," </tr>\n");
576  fputs($newsadmin," <tr bgcolor=#<?echo \$tcolor;?>>\n");
577  fputs($newsadmin," <td>&nbsp;</td>\n");
578  fputs($newsadmin," </tr>\n");
579  fputs($newsadmin," <!-- End Item -->\n");
580  fputs($newsadmin," <tr bgcolor=#<?echo \$fcolor;?>>\n");
581  fputs($newsadmin," <td>\n");
582  fputs($newsadmin," <center>\n");
583  fputs($newsadmin," <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"640\">\n");
584  fputs($newsadmin," <tr>\n");
585  fputs($newsadmin," <td width=\"640\" height=\"20\" align=\"LEFT\" valign=\"MIDDLE\" \"><font
586  face=\"arial,helvetica\" size=\"2\">\n");
587  fputs($newsadmin," <b>&nbsp;&nbsp;Test Stories</b></font></td>\n");
588  fputs($newsadmin," </tr>\n");
589  fputs($newsadmin," </table>\n");
590  fputs($newsadmin," <table border=\"0\" cellpadding=\"7\" cellspacing=\"0\" width=\"581\">\n");
591  fputs($newsadmin," <tr>\n");
592  fputs($newsadmin," <td><font face=\"arial,helvetica\" size=\"2\">\n");
593  fputs($newsadmin," <!-- Title Font -->\n");
594  fputs($newsadmin," <font face=\"arial,helvetica\" size=\"2\">[ <a\n");
595  fputs($newsadmin,"href=\"testnews.php?test_view=1\">Access Test Page</a> ] Note: The Test Page show active stories as well as test stories</font><br>\n");
596  fputs($newsadmin," <center>\n");
597  fputs($newsadmin," <table width=\"550\" border=\"0\" cellspacing=\"0\" cellpadding=\"3\" background=\"\">\n");
598  fputs($newsadmin,"<? \n");
599  fputs($newsadmin,"\n");
600  fputs($newsadmin," if (\$num_test_stories == 0) {?>\n");
601  fputs($newsadmin," <tr bgcolor=\"white\">\n");
602  fputs($newsadmin," <td colspan=5 bgcolor=\"white\"><font face=\"arial,helvetica\" size=\"1\"><b>Warning!! No Current Test Stories</b></font></td>\n");
603  fputs($newsadmin," </tr>\n");
604  fputs($newsadmin,"<?}\n");
605  fputs($newsadmin," else {\n");
606  fputs($newsadmin," ?>\n");
607  fputs($newsadmin," <tr bgcolor=#<?echo \$fcolor;?>>\n");
608  fputs($newsadmin," <td align=\"CENTER\" bgcolor=#<?echo \$fcolor;?>><font face=\"arial,helvetica\" size=\"1\"
609  color=\"#000000\"><b>Story ID</b></font></td>\n");
610  fputs($newsadmin," <td bgcolor=#<?echo \$fcolor;?>><font face=\"arial,helvetica\" size=\"1\" color=\"#000000\"><b>Title</b></font></td>\n");
611  fputs($newsadmin," <td bgcolor=#<?echo \$fcolor;?>><font face=\"arial,helvetica\" size=\"1\" color=\"#000000\"><b>Author</b></font></td>\n");
612  fputs($newsadmin," <td align=\"CENTER\" bgcolor=#<?echo \$fcolor;?>><font face=\"arial,helvetica\" size=\"1\"
613  color=\"#000000\"><b>Promote to Active</b></font></td>\n");
614  fputs($newsadmin," <td align=\"CENTER\" bgcolor=#<?echo \$fcolor;?>><font face=\"arial,helvetica\" size=\"1\"
615  color=\"#000000\"><b>Demote to Draft</b></font></td>\n");
616  fputs($newsadmin," </tr>\n");
617  fputs($newsadmin,"<?php\n");
618  fputs($newsadmin," if (\$num_test_stories >= \$MAX_NUM_STORIES_TO_SHOW){\n");
619  fputs($newsadmin," \$num_test_stories = \$MAX_NUM_STORIES_TO_SHOW;\n");
620  fputs($newsadmin," }\n");
621  fputs($newsadmin," for (\$i=0; \$i < \$num_test_stories; \$i++){\n");
622  fputs($newsadmin," \$rstest = mysql_fetch_array(\$test_query_handle);\n");
623  fputs($newsadmin,"?>\n");
624  fputs($newsadmin," <tr bgcolor=\"white\">\n");
625  fputs($newsadmin," <td align=\"CENTER\"><font face=\"arial,helvetica\" size=\"1\"><? echo \$rstest[\"news_id\"] ?></font></td>\n");
626  fputs($newsadmin," <td><font face=\"arial,helvetica\" size=\"1\"><a href=\"editnews.php?story_id=<? echo
627  \$rstest[\"news_id\"] ?>\">\n");
628  fputs($newsadmin," <? echo \$rstest[\"news_story_title\"] ?></a></font></td>\n");
629  fputs($newsadmin," <td><font face=\"arial,helvetica\" size=\"1\"><? echo \$rstest[\"news_story_author\"] ?></font></td>\n");
630  fputs($newsadmin," <td align=\"CENTER\"><a href=\"movenews.php?test_to_active=<? echo \$rstest[\"news_id\"] ?>\">\n");
631  fputs($newsadmin," Promote Active</a></td>\n");
632  fputs($newsadmin," <td align=\"CENTER\"><a href=\"movenews.php?test_to_working=<? echo \$rstest[\"news_id\"] ?>\">\n");
633  fputs($newsadmin," Demote Draft</a></td>\n");
634  fputs($newsadmin," </tr>\n");
635  fputs($newsadmin,"<?php\n");
636  fputs($newsadmin," } // end of test story for loop\n");
637  fputs($newsadmin,"} // end of else statement for # of test stories\n");
638  fputs($newsadmin,"?>\n");
639  fputs($newsadmin," </table>\n");
640  fputs($newsadmin," </center>\n");
641  fputs($newsadmin," </td>\n");
642  fputs($newsadmin," </font></tr>\n");
643  fputs($newsadmin," </table>\n");
644  fputs($newsadmin," </tr>\n");
645  fputs($newsadmin," <tr bgcolor=#<?echo $tcolor;?>>\n");
646  fputs($newsadmin," <td>&nbsp;</td>\n");
647  fputs($newsadmin," </tr>\n");
648  fputs($newsadmin," <!-- End Item -->\n");
649  fputs($newsadmin," <tr>\n");
650  fputs($newsadmin," <td>\n");
651  fputs($newsadmin," <center>\n");
652  fputs($newsadmin," <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"640\">\n");
653  fputs($newsadmin," <tr bgcolor=#<?echo \$fcolor;?>>\n");
654  fputs($newsadmin," <td width=\"581\" height=\"20\" align=\"LEFT\" valign=\"MIDDLE\">\n");
655  fputs($newsadmin," <font face=\"arial,helvetica\" size=\"2\"><b>&nbsp;&nbsp;Draft Stories</b></font></td>\n");
656  fputs($newsadmin," </tr>\n");
657  fputs($newsadmin," </table>\n");
658  fputs($newsadmin," <table border=\"0\" cellpadding=\"7\" cellspacing=\"0\" width=\"640\">\n");
659  fputs($newsadmin," <tr bgcolor=#<?echo \$fcolor;?>>\n");
660  fputs($newsadmin," <td><font face=\"arial,helvetica\" size=\"2\">\n");
661  fputs($newsadmin," <center>\n");
662  fputs($newsadmin," <table width=\"550\" border=\"0\" cellspacing=\"0\" cellpadding=\"3\" background=\"\">\n");
663  fputs($newsadmin,"\n");
664  fputs($newsadmin,"<? if (\$num_working_stories == 0) {?>\n");
665  fputs($newsadmin," <tr bgcolor=\"#000000\">\n");
666  fputs($newsadmin," <td colspan=5 bgcolor=\"White\"><font face=\"arial,helvetica\" size=\"1\" ><b>No Current Draft Stories</b></font></td>\n");
667  fputs($newsadmin," </tr>\n");
668  fputs($newsadmin,"<?}\n");
669  fputs($newsadmin," else {\n");
670  fputs($newsadmin," ?>\n");
671  fputs($newsadmin," <tr bgcolor=#<?echo \$fcolor;?>>\n");
672  fputs($newsadmin," <td align=\"CENTER\" bgcolor=#<?echo \$fcolor;?>><font face=\"arial,helvetica\" size=\"1\"><b>Story ID</b></font></td>\n");
673  fputs($newsadmin," <td bgcolor=#<?echo \$fcolor;?>><font face=\"arial,helvetica\" size=\"1\"><b>Title</b></font></td>\n");
674  fputs($newsadmin," <td bgcolor=#<?echo \$fcolor;?>><font face=\"arial,helvetica\" size=\"1\"><b>Author</b></font></td>\n");
675  fputs($newsadmin," <td align=\"CENTER\" bgcolor=#<?echo \$fcolor;?>><font face=\"arial,helvetica\" size=\"1\"><b>Promote to Test</b></font></td>\n");
676  fputs($newsadmin," <td align=\"CENTER\" bgcolor=#<?echo \$fcolor;?>><font face=\"arial,helvetica\" size=\"1\"
677  color=\"RED\"><b>Delete Story</b></font></td>\n");
678  fputs($newsadmin," </tr>\n");
679  fputs($newsadmin,"<?php\n");
680  fputs($newsadmin," if (\$num_working_stories >= \$MAX_NUM_STORIES_TO_SHOW){\n");
681  fputs($newsadmin," \$num_working_stories = \$MAX_NUM_STORIES_TO_SHOW;\n");
682  fputs($newsadmin," }\n");
683  fputs($newsadmin," for (\$i=0; \$i < \$num_working_stories; \$i++){\n");
684  fputs($newsadmin," \$rsgeneral = mysql_fetch_array(\$working_query_handle);\n");
685  fputs($newsadmin,"?>\n");
686  fputs($newsadmin," <tr bgcolor=\"white\">\n");
687  fputs($newsadmin," <td align=\"CENTER\"><font face=\"verdana,arial,helvetica\" size=\"1\"><? echo
688  \$rsgeneral[\"news_id\"]?></font></td>\n");
689  fputs($newsadmin," <td><font face=\"verdana,arial,helvetica\" size=\"1\"><a href=\"editnews.php?story_id=<? echo
690  \$rsgeneral[\"news_id\"]?>\">\n");
691  fputs($newsadmin," <?echo \$rsgeneral[\"news_story_title\"] ?></a></font></td>\n");
692  fputs($newsadmin," <td><font face=\"verdana,arial,helvetica\" size=\"1\"><?echo \$rsgeneral[\"news_story_author\"] ?></font></td>\n");
693  fputs($newsadmin," <td align=\"CENTER\"><a href=\"movenews.php?working_to_test=<?echo \$rsgeneral[\"news_id\"]?>\">\n");
694  fputs($newsadmin," Promote to Test</a></td>\n");
695  fputs($newsadmin," <td align=\"CENTER\"><a href=\"movenews.php?delete=<? echo \$rsgeneral[\"news_id\"]?>\">Delete</a></td>\n");
696  fputs($newsadmin," </tr>\n");
697  fputs($newsadmin,"<?php\n");
698  fputs($newsadmin," } // end of draft story for loop\n");
699  fputs($newsadmin,"} // end of else statement for # of draft stories\n");
700  fputs($newsadmin,"?>\n");
701  fputs($newsadmin," </table>\n");
702  fputs($newsadmin," </center>\n");
703  fputs($newsadmin," </td>\n");
704  fputs($newsadmin," </font></tr>\n");
705  fputs($newsadmin," </table>\n");
706  fputs($newsadmin," </tr>\n");
707  fputs($newsadmin," <tr bgcolor=#<?echo \$tcolor;?>>\n");
708  fputs($newsadmin," <td>&nbsp;</td>\n");
709  fputs($newsadmin," </tr>\n");
710  fputs($newsadmin," <!-- End Item -->\n");
711  fputs($newsadmin," </table>\n");
712  fputs($newsadmin," </td>\n");
713  fputs($newsadmin,"\n");
714  fputs($newsadmin,"\n");
715  fputs($newsadmin," <td>&nbsp;</td>\n");
716  fputs($newsadmin,"</tr>\n");
717  fputs($newsadmin,"\n");
718  fputs($newsadmin,"</table>\n");
719  fputs($newsadmin,"</div>\n");
720  fputs($newsadmin,"</body>\n");
721  fputs($newsadmin,"</html>\n");
722  fputs($newsadmin,"\n");
723  fputs($newsadmin,"\n");
724  fclose($newsadmin);
725 
726 
727  $news_table_query = "
728  CREATE TABLE news (
729    news_id int(11) DEFAULT '0' NOT NULL auto_increment,
730    news_story_title varchar(80) DEFAULT '' NOT NULL,
731    news_story_html text,
732    news_story_active int(11) DEFAULT '0' NOT NULL,
733    news_story_test int(11) DEFAULT '0' NOT NULL,
734    news_story_author varchar(20),
735    news_story_date datetime DEFAULT ':00:00' NOT NULL,
736    news_story_order int(11),
737    news_story_arch int(11) DEFAULT '0' NOT NULL,
738    PRIMARY KEY (news_id)
739  )";
740 
741  $lockquery = "LOCK TABLES news WRITE";
742  $test_data = "INSERT INTO news VALUES (1,'Testing This App','Web News
743  System',1,1,'your@email',':11:18',NULL,0),(2,'You News System','Welcome to Your New Web
744  News System...',1,1,'Put your email here',':12:02',NULL,0)";
745  $unlocltablequery = "UNLOCK TABLES";
746 
747  if(!mysql_db_query($webdatabase,$news_table_query)) {
748   print "Unable to create news table:" . mysql_error() ."<p>\n";
749  }
750 
751  if(!mysql_db_query($webdatabase,$lockquery)) {
752   print "Unable to lock tables:" . mysql_error() ."<p>\n";
753  }
754 
755  if(!mysql_db_query($webdatabase,$test_data)) {
756   print "Unable to Insert Test Data:" . mysql_error() ."<p>\n";
757  }
758 
759  if(!mysql_db_query($webdatabase,$unlocltablequery)) {
760   print "Unable to unlock tables:" . mysql_error() ."<p>\n";
761  }
762  ?>


Generated: Sat Jan 27 15:40:36 2001 Generated by PHPXref 0.1.2
PCCS-Linux.COM ::ource Advocate Articles catalogue
2000 2002