PageRenderTime 54ms CodeModel.GetById 25ms RepoModel.GetById 1ms app.codeStats 0ms

/control/populate.php

https://github.com/altatof/altashop
PHP | 633 lines | 431 code | 72 blank | 130 comment | 71 complexity | 9e3ba3800df9c6b781f38a1d7ba13a92 MD5 | raw file
  1. <?php
  2. /**
  3. * populate the database
  4. *
  5. * This script helps to create default records in the database.
  6. *
  7. * Creates following sections for web management purposes:
  8. * - 'covers' - the most recent article is displayed at the front page of the site
  9. * - 'default' - the default place to post new content
  10. * - 'extra_boxes' - boxes only displayed at the front page, in the extra panel
  11. * - 'gadget_boxes' - boxes only displayed at the front page, as gadgets
  12. * - 'global' - global pages
  13. * - 'navigation_boxes' - displayed at every page of the site, in the navigation panel
  14. * - 'processed_queries' - the archive of old queries
  15. * - 'queries' - pages sent by surfers to submit their queries to the webmaster
  16. * - 'templates' - models for new articles
  17. * - 'threads' - private pages
  18. *
  19. * Additional sections may be created directly from within the content assistant, in [script]control/populate.php[/script].
  20. *
  21. * Moreover, some sections may be created by other scripts, namely:
  22. * - 'clicks' - to put orphan links when clicked - created automatically in [script]links/links.php[/script]
  23. * - 'external_news' - for links gathered from feeding servers in [script]feeds/feeds.php[/script] and [script]servers/edit.php[/script]
  24. * - 'letters' - pages sent by e-mail to subscribers - created automatically in [script]letters/new.php[/script]
  25. *
  26. * @see letters/new.php
  27. * @see links/links.php
  28. * @see query.php
  29. *
  30. * Creates following categories for web management purposes:
  31. * - 'featured' - the articles to display at the front page
  32. * - 'monthly' - for articles published each month
  33. * - 'weekly' - for articles published each week
  34. *
  35. * Creates articles with following nick names:
  36. * - 'about' - a page providing an overview of this site
  37. * - 'cover' - a cover article for the front page
  38. * - 'extra_rss' - a sample extra box to link to our XML RSS feed
  39. * - 'menu' - a sample general menu displayed on all pages
  40. * - 'privacy' - to provide clear statements to community members
  41. *
  42. * If there is no [code]parameters/switch.on[/code] nor [code]parameters/switch.off[/code] file, the script
  43. * asks for a user name and password to create an associate user profile.
  44. * This is usually what happen on first installation.
  45. *
  46. * This can be used also if one webmaster losts his password.
  47. * In this case, delete the switch file (normally, [code]parameters/switch.on[/code])
  48. * and trigger this script to recreate a new associate user profile.
  49. *
  50. * This script also invokes a hook to populate additional tables:
  51. * - id: 'control/populate.php'
  52. * - type: 'include'
  53. *
  54. * Only associates can use this script, except if no switch file is present.
  55. * Invocations are also accepted if the user table is missing or empty.
  56. *
  57. * If an associate user profile is created, apply it to the current surfing session.
  58. *
  59. * @author Bernard Paques
  60. * @author GnapZ
  61. * @tester Christian Loubechine
  62. * @reference
  63. * @license http://www.gnu.org/copyleft/lesser.txt GNU Lesser General Public License
  64. */
  65. // common libraries
  66. include_once '../shared/global.php';
  67. // force the creation of a user profile if the user table does not exists, or is empty
  68. $query = "SELECT count(*) FROM ".SQL::table_name('users');
  69. if(!SQL::query_scalar($query, FALSE, $context['users_connection']))
  70. $permitted = TRUE;
  71. // force the creation of a user profile if there is no switch file
  72. elseif(!(file_exists('../parameters/switch.on') || file_exists('../parameters/switch.off')))
  73. $permitted = TRUE;
  74. // associates can do what they want
  75. elseif(Surfer::is_associate())
  76. $permitted = TRUE;
  77. // the default is to disallow access
  78. else
  79. $permitted = FALSE;
  80. // load localized strings
  81. i18n::bind('control');
  82. // load the skin
  83. load_skin('control');
  84. // the path to this page
  85. $context['path_bar'] = array( 'control/' => i18n::s('Control Panel') );
  86. // default page title
  87. $context['page_title'] = i18n::s('Content Assistant');
  88. // permission denied
  89. if(!$permitted) {
  90. // anonymous users are invited to log in or to register
  91. if(!Surfer::is_logged())
  92. Safe::redirect($context['url_to_home'].$context['url_to_root'].'users/login.php?url='.urlencode('control/populate.php?action='.$action));
  93. // permission denied to authenticated user
  94. Safe::header('Status: 401 Unauthorized', TRUE, 401);
  95. Logger::error(i18n::s('You are not allowed to perform this operation.'));
  96. // forward to the control panel
  97. $menu = array('control/' => i18n::s('Control Panel'));
  98. $context['text'] .= Skin::build_list($menu, 'menu_bar');
  99. // ask for parameters on first installation
  100. } elseif((!isset($_REQUEST['nick_name']) || !$_REQUEST['nick_name']) && (!file_exists('../parameters/switch.on') && !file_exists('../parameters/switch.off'))) {
  101. // splash message
  102. $context['text'] .= '<p>'.i18n::s('Please indicate below the name and password you will use to authenticate to this server.').'</p>'
  103. .'<p>'.i18n::s('DO NOT FORGET THIS LOGIN!! There is no default administrative login created when YACS is installed, so if you lose your login, you will have to purge the database and trigger the setup script again.').'</p>'."\n";
  104. // the form to get user attributes
  105. $context['text'] .= '<form method="post" action="'.$context['script_url'].'" onsubmit="return validateDocumentPost(this)" name="main_form"><div>'."\n"
  106. .'<input type="hidden" name="action" value="associate" />';
  107. // the nick name
  108. $label = i18n::s('Nick name');
  109. $input = '<input type="text" id="nick_name" name="nick_name" size="40" />';
  110. $hint = i18n::s('Please carefully select a meaningful nick name.');
  111. $fields[] = array($label, $input, $hint);
  112. // the password
  113. $label = i18n::s('Password');
  114. $input = '<input type="password" name="password" size="20" />';
  115. $hint = i18n::s('We recommend at least 4 letters, two digits, and a punctuation sign - in any order');
  116. $fields[] = array($label, $input, $hint);
  117. // the password has to be repeated for confirmation
  118. $label = i18n::s('Password confirmation');
  119. $input = '<input type="password" name="confirm" size="20" />';
  120. $fields[] = array($label, $input);
  121. // build the form
  122. $context['text'] .= Skin::build_form($fields);
  123. $fields = array();
  124. // the submit button
  125. $context['text'] .= '<p class="assistant_bar">'.Skin::build_submit_button(i18n::s('Submit'), i18n::s('Press [s] to submit data'), 's').'</p>'."\n";
  126. // end of the form
  127. $context['text'] .= '</div></form>';
  128. // append the script used for data checking on the browser
  129. $context['text'] .= JS_PREFIX
  130. .'// check that main fields are not empty'."\n"
  131. .'func'.'tion validateDocumentPost(container) {'."\n"
  132. ."\n"
  133. .' // name is mandatory'."\n"
  134. .' if(!container.nick_name.value) {'."\n"
  135. .' alert("'.i18n::s('You must provide a nick name.').'");'."\n"
  136. .' Yacs.stopWorking();'."\n"
  137. .' return false;'."\n"
  138. .' }'."\n"
  139. ."\n"
  140. .' // password is mandatory'."\n"
  141. .' if(!container.password.value) {'."\n"
  142. .' alert("'.i18n::s('You must provide a password.').'");'."\n"
  143. .' Yacs.stopWorking();'."\n"
  144. .' return false;'."\n"
  145. .' }'."\n"
  146. ."\n"
  147. .' // password should be confirmed'."\n"
  148. .' if(container.password.value != container.confirm.value) {'."\n"
  149. .' alert("'.i18n::s('You must confirm the password.').'");'."\n"
  150. .' Yacs.stopWorking();'."\n"
  151. .' return false;'."\n"
  152. .' }'."\n"
  153. ."\n"
  154. .' // successful check'."\n"
  155. .' return true;'."\n"
  156. .'}'."\n"
  157. ."\n"
  158. .'// set the focus on first form field'."\n"
  159. .'$("nick_name").focus();'."\n"
  160. .JS_SUFFIX;
  161. // this may take some time
  162. $context['text'] .= '<p>'.i18n::s('When you will click on the button the server will be immediately requested to proceed. However, because of the so many things to do on the back-end, you may have to wait for minutes before getting a response displayed. Thank you for your patience.')."</p>\n";
  163. // actual data creation
  164. } else {
  165. // on first installation
  166. if(!file_exists('../parameters/switch.on') && !file_exists('../parameters/switch.off')) {
  167. $context['text'] .= '<p>'.i18n::s('Review provided information and go to the bottom of the page to move forward.')."</a></p>\n";
  168. // create an associate user account
  169. if(isset($_REQUEST['nick_name']))
  170. $user['nick_name'] = $_REQUEST['nick_name'];
  171. else
  172. $user['nick_name'] = 'admin';
  173. if(isset($_REQUEST['password'])) {
  174. $user['password'] = $_REQUEST['password'];
  175. $user['confirm'] = $_REQUEST['confirm'];
  176. } else {
  177. list($usec, $sec) = explode(' ', microtime(), 2);
  178. srand((float) $sec + ((float) $usec * 100000));
  179. $user['password'] = 'az'.rand(1000, 9999);
  180. $user['confirm'] = $user['password'];
  181. }
  182. $user['with_newsletters'] = 'Y';
  183. $user['capability'] = 'A'; // make this user profile an associate
  184. $user['active'] = 'Y';
  185. $user['create_name'] = 'setup';
  186. $user['create_date'] = gmstrftime('%Y-%m-%d %H:%M:%S');
  187. $user['edit_name'] = 'setup';
  188. $user['edit_date'] = gmstrftime('%Y-%m-%d %H:%M:%S');
  189. $user['interface'] = 'C'; // access all configuration panels
  190. $user['login_date'] = gmstrftime('%Y-%m-%d %H:%M:%S');
  191. // display error, if any
  192. if(!Users::post($user)) {
  193. // but do not mention that admin already exists...
  194. if($user['nick_name'] == 'admin')
  195. $context['error'] = array();
  196. // remember the new user profile
  197. } elseif($user =& Users::get($_REQUEST['nick_name'])) {
  198. // we will create additional items on first installation
  199. if(!file_exists('../parameters/switch.on') && !file_exists('../parameters/switch.off'))
  200. $context['text'] .= Skin::build_block(i18n::s('Users'), 'subtitle');
  201. $context['text'] .= '<p>'.sprintf(i18n::s('One associate profile "%s" has been created.'), $user['nick_name'])."</p>\n";
  202. // impersonate the new created user profile on first installation
  203. if(!file_exists('../parameters/switch.on') && !file_exists('../parameters/switch.off'))
  204. Surfer::set($user);
  205. }
  206. }
  207. // create reference sections
  208. $text = '';
  209. // 'covers' section
  210. if(!Sections::get('covers')) {
  211. $fields = array();
  212. $fields['nick_name'] = 'covers';
  213. $fields['title'] = i18n::c('Covers');
  214. $fields['introduction'] = i18n::c('The top page here is also displayed at the front page');
  215. $fields['home_panel'] = 'none'; // special processing at the front page -- see index.php
  216. $fields['index_map'] = 'N'; // listed with special sections
  217. $fields['locked'] = 'Y'; // only associates can contribute
  218. $fields['content_options'] = 'auto_publish'; // ease the job of newbies
  219. if(Sections::post($fields))
  220. $text .= sprintf(i18n::s('A section "%s" has been created.'), $fields['title']).BR."\n";
  221. else
  222. $text .= Logger::error_pop().BR."\n";
  223. }
  224. // 'default' section
  225. if(!Sections::get('default')) {
  226. $fields = array();
  227. $fields['nick_name'] = 'default';
  228. $fields['title'] = i18n::c('Pages');
  229. $fields['introduction'] = i18n::c('The default place for new pages');
  230. $fields['description'] = '';
  231. if(Sections::post($fields))
  232. $text .= sprintf(i18n::s('A section "%s" has been created.'), $fields['title']).BR."\n";
  233. else
  234. $text .= Logger::error_pop().BR."\n";
  235. }
  236. // 'extra_boxes' section
  237. if(!Sections::get('extra_boxes')) {
  238. $fields = array();
  239. $fields['nick_name'] = 'extra_boxes';
  240. $fields['title'] = i18n::c('Extra boxes');
  241. $fields['introduction'] = i18n::c('Boxes displayed aside the front page');
  242. $fields['description'] = i18n::c('All [link=codes]codes/[/link] are available to format boxes. Keep the content as compact as possible because of the small size of any single box. When ready, publish pages to actually show boxes to everybody.');
  243. $fields['home_panel'] = 'extra_boxes'; // one extra box per article at the front page
  244. $fields['index_map'] = 'N'; // listed with special sections
  245. $fields['locked'] = 'Y'; // only associates can contribute
  246. if(Sections::post($fields))
  247. $text .= sprintf(i18n::s('A section "%s" has been created.'), $fields['title']).BR."\n";
  248. else
  249. $text .= Logger::error_pop().BR."\n";
  250. }
  251. // 'gadget_boxes' section
  252. if(!Sections::get('gadget_boxes')) {
  253. $fields = array();
  254. $fields['nick_name'] = 'gadget_boxes';
  255. $fields['title'] = i18n::c('Gadget boxes');
  256. $fields['introduction'] = i18n::c('Boxes displayed in the middle of the front page');
  257. $fields['description'] = i18n::c('All [link=codes]codes/[/link] are available to format boxes. Keep the content as compact as possible because of the small size of any single box. When ready, publish pages to actually show boxes to everybody.');
  258. $fields['home_panel'] = 'gadget_boxes'; // one gadget box per article at the front page
  259. $fields['index_map'] = 'N'; // listed with special sections
  260. $fields['locked'] = 'Y'; // only associates can contribute
  261. if(Sections::post($fields))
  262. $text .= sprintf(i18n::s('A section "%s" has been created.'), $fields['title']).BR."\n";
  263. else
  264. $text .= Logger::error_pop().BR."\n";
  265. }
  266. // 'global' section
  267. if(!Sections::get('global')) {
  268. $fields = array();
  269. $fields['nick_name'] = 'global';
  270. $fields['title'] = i18n::c('Global pages');
  271. $fields['home_panel'] = 'none'; // special processing at the front page -- see index.php
  272. $fields['index_map'] = 'N'; // listed with special sections
  273. $fields['locked'] = 'Y'; // only associates can contribute
  274. $fields['rank'] = '1000'; // before other special sections
  275. $fields['content_options'] = 'auto_publish'; // these will be reviewed anyway
  276. if(Sections::post($fields))
  277. $text .= sprintf(i18n::s('A section "%s" has been created.'), $fields['title']).BR."\n";
  278. else
  279. $text .= Logger::error_pop().BR."\n";
  280. }
  281. // 'navigation_boxes' section
  282. if(!Sections::get('navigation_boxes')) {
  283. $fields = array();
  284. $fields['nick_name'] = 'navigation_boxes';
  285. $fields['title'] = i18n::c('Navigation boxes');
  286. $fields['introduction'] = i18n::c('Boxes displayed aside all pages');
  287. $fields['description'] = i18n::c('All [link=codes]codes/[/link] are available to format boxes. Keep the content as compact as possible because of the small size of any single box. When ready, publish pages to actually show boxes to everybody.');
  288. $fields['home_panel'] = 'none'; // special processing everywhere -- see skins/<skin>/template.php
  289. $fields['index_map'] = 'N'; // listed with special sections
  290. $fields['locked'] = 'Y'; // only associates can contribute
  291. if(Sections::post($fields))
  292. $text .= sprintf(i18n::s('A section "%s" has been created.'), $fields['title']).BR."\n";
  293. else
  294. $text .= Logger::error_pop().BR."\n";
  295. }
  296. // 'processed_queries' section
  297. if($section = Sections::get('processed_queries')) {
  298. $processed_id = $section['id'];
  299. } else {
  300. $fields = array();
  301. $fields['nick_name'] = 'processed_queries';
  302. $fields['title'] = i18n::c('Processed queries');
  303. $fields['introduction'] =& i18n::c('Saved for history');
  304. $fields['active_set'] = 'N'; // only associates can access these pages
  305. $fields['home_panel'] = 'none'; // special processing everywhere -- see skins/<skin>/template.php
  306. $fields['index_map'] = 'N'; // listed with special sections
  307. $fields['locked'] = 'Y'; // only associates can contribute
  308. $fields['rank'] = '20000'; // pushed at the end
  309. if($processed_id = Sections::post($fields))
  310. $text .= sprintf(i18n::s('A section "%s" has been created.'), $fields['title']).BR."\n";
  311. else
  312. $text .= Logger::error_pop().BR."\n";
  313. }
  314. // 'queries' section --after processed_queries
  315. if(!Sections::get('queries')) {
  316. $fields = array();
  317. $fields['nick_name'] = 'queries';
  318. $fields['title'] = i18n::c('Queries');
  319. $fields['introduction'] =& i18n::c('Submitted by any surfer');
  320. $fields['description'] =& i18n::c('Add comments to provide support.');
  321. $fields['active_set'] = 'N'; // only associates can access these pages
  322. $fields['home_panel'] = 'none'; // special processing everywhere -- see skins/<skin>/template.php
  323. $fields['index_map'] = 'N'; // listed with special sections
  324. $fields['locked'] = 'Y'; // only associates can contribute
  325. if($processed_id)
  326. $fields['behaviors'] = 'move_on_article_access '.$processed_id; // a basic workflow
  327. $fields['content_options'] = 'auto_publish'; // these will be reviewed anyway
  328. if(Sections::post($fields))
  329. $text .= sprintf(i18n::s('A section "%s" has been created.'), $fields['title']).BR."\n";
  330. else
  331. $text .= Logger::error_pop().BR."\n";
  332. }
  333. // 'templates' section
  334. if(!Sections::get('templates')) {
  335. $fields = array();
  336. $fields['nick_name'] = 'templates';
  337. $fields['title'] = i18n::c('Templates');
  338. $fields['introduction'] = i18n::c('Models to be duplicated');
  339. $fields['active_set'] = 'N'; // only associates can access these pages
  340. $fields['home_panel'] = 'none'; // special processing everywhere -- see skins/<skin>/template.php
  341. $fields['index_map'] = 'N'; // listed with special sections
  342. $fields['locked'] = 'Y'; // only associates can contribute
  343. $fields['content_options'] = 'auto_publish'; // these will be reviewed anyway
  344. if(Sections::post($fields))
  345. $text .= sprintf(i18n::s('A section "%s" has been created.'), $fields['title']).BR."\n";
  346. else
  347. $text .= Logger::error_pop().BR."\n";
  348. }
  349. // 'threads' section
  350. if(!Sections::get('threads')) {
  351. $fields = array();
  352. $fields['nick_name'] = 'threads';
  353. $fields['title'] =& i18n::c('Threads');
  354. $fields['introduction'] =& i18n::c('For on-demand conversations');
  355. $fields['locked'] = 'Y'; // no direct contributions
  356. $fields['home_panel'] = 'none'; // content is not pushed at the front page
  357. $fields['index_map'] = 'N'; // this is a special section
  358. $fields['articles_layout'] = 'yabb'; // these are threads
  359. $fields['content_options'] = 'with_export_tools auto_publish with_comments_as_wall';
  360. $fields['maximum_items'] = 20000; // limit the overall number of threads
  361. if(Sections::post($fields))
  362. $text .= sprintf(i18n::s('A section "%s" has been created.'), $fields['title']).BR."\n";
  363. else
  364. $text .= Logger::error_pop().BR."\n";
  365. }
  366. // nothing added
  367. if(!$text)
  368. $text = i18n::s('No item has been added');
  369. // report to surfer
  370. $context['text'] .= Skin::build_box(i18n::s('Sections'), $text);
  371. // create reference categories
  372. $text = '';
  373. // 'featured' category
  374. if(!Categories::get(i18n::c('featured'))) {
  375. $fields = array();
  376. $fields['nick_name'] = i18n::c('featured');
  377. $fields['title'] = i18n::c('Featured');
  378. $fields['introduction'] = i18n::c('Pages to display at the front page');
  379. $fields['description'] = i18n::c('Pages attached to this category are featured at the front page in a compact list aside.');
  380. $fields['active_set'] = 'N';
  381. $fields['active'] = 'N';
  382. $fields['options'] = 'no_links';
  383. if(Categories::post($fields))
  384. $text .= sprintf(i18n::s('A category "%s" has been created.'), $fields['title']).BR."\n";
  385. }
  386. // 'monthly' category
  387. if(!Categories::get(i18n::c('monthly'))) {
  388. $fields = array();
  389. $fields['nick_name'] = i18n::c('monthly');
  390. $fields['title'] = i18n::c('Publications by month');
  391. $fields['introduction'] = '';
  392. $fields['rank'] = 22000;
  393. $fields['options'] = 'no_links';
  394. if(Categories::post($fields))
  395. $text .= sprintf(i18n::s('A category "%s" has been created.'), $fields['title']).BR."\n";
  396. }
  397. // 'weekly' category
  398. if(!Categories::get(i18n::c('weekly'))) {
  399. $fields = array();
  400. $fields['nick_name'] = i18n::c('weekly');
  401. $fields['title'] = i18n::c('Publications by week');
  402. $fields['introduction'] = '';
  403. $fields['rank'] = 21000;
  404. $fields['options'] = 'no_links';
  405. if(Categories::post($fields))
  406. $text .= sprintf(i18n::s('A category "%s" has been created.'), $fields['title']).BR."\n";
  407. }
  408. // nothing added
  409. if(!$text)
  410. $text = i18n::s('No item has been added');
  411. // report to surfer
  412. $context['text'] .= Skin::build_box(i18n::s('Categories'), $text);
  413. // create reference articles
  414. $text = '';
  415. // 'about' article
  416. if(!Articles::get('about') && ($anchor = Sections::lookup('global'))) {
  417. $fields = array();
  418. $fields['anchor'] = $anchor;
  419. $fields['nick_name'] = 'about';
  420. $fields['title'] = i18n::c('About this site');
  421. $fields['description'] = '[toc]'."\n"
  422. .'[title]'.i18n::c('What is [parameter=site_name] about?').'[/title]'."\n"
  423. .'<p>'.i18n::c('Welcome to this server! Here are attributes transmitted in the header of each page:').'</p>'."\n"
  424. .'<table class="wide">'."\n"
  425. .'<tr><td>'.i18n::c('Site name').'</td><td>[parameter=site_name]</td></tr>'."\n"
  426. .'<tr><td>'.i18n::c('Description').'</td><td>[parameter=site_description]</td></tr>'."\n"
  427. .'<tr><td>'.i18n::c('Keywords').'</td><td>[parameter=site_keywords]</td></tr>'."\n"
  428. .'<tr><td>'.i18n::c('Geographical position').'</td><td>[parameter=site_position]</td></tr>'."\n"
  429. .'<tr><td>'.i18n::c('Copyright').'</td><td>[parameter=site_copyright]</td></tr>'."\n"
  430. .'<tr><td>'.i18n::c('Owner').'</td><td>[parameter=site_owner]</td></tr>'."\n"
  431. .'</table>'."\n"
  432. .'<p>'.i18n::c('This site is powered by [link=YACS]http://www.yacs.fr/[/link], [link=PHP]http://www.php.net/[/link], and [link=MySQL]http://www.mysql.com/[/link] - a fast, easy-to-use site that lets you access, review, and download information that matters for you.').'</p>'."\n"
  433. .'[title]'.i18n::c('Contact').'[/title]'."\n"
  434. .'<p>'.i18n::c('The preferred mean to join us is to use the general-purpose query form. This is a convenient tool for you and for us, because your request and related answers will be listed at a single place accessible from your web browser. Moreover, you will be informed by e-mail of any progressing step to your query.').'</p>'."\n"
  435. .'<p class="indent">'.i18n::c('Query: [link=Use the on-line form]query.php[/link]').'</p>'."\n"
  436. .'<p>'.i18n::c('If you have something vitally important to tell us, send a message at the following address.').'</p>'."\n"
  437. .'<p class="indent">'.i18n::c('Webmaster: [parameter=site_email]').'</p>'."\n"
  438. .'[note]'.i18n::c('Due to the large amount of e-mail that we get, we can NOT guarantee a response! This is especially true if your e-mail concerns issues we can\'t really help you with.').'[/note]'."\n"
  439. .'[title]'.i18n::c('How you can help').'[/title]'."\n"
  440. .'<p>'.i18n::c('We are proud of this server, but it certainly isn\'t perfect. We\'re always looking for ways to improve the site. So, if you\'ve got any great ideas, then please let us know about them. Or, if you know of some important information that isn\'t listed here, email the author and tell them you want it listed on this site! It\'ll help make this server a better site for the whole community - and that\'s who we\'re here to serve.').'</p>'."\n"
  441. .'[title]'.i18n::c('Legal Stuff').'[/title]'."\n"
  442. .'<p>'.i18n::c('Be nice to other people, don\'t spam them, and don\'t do anything bad with any information you might get from this site.').'</p>'."\n"
  443. .'<p>'.i18n::c('All content, including but not limited to user reviews, application listings and information contained therein, is owned by [parameter=site_owner] and may not be copied without permission. However, the above content my be freely modified and/or removed by the person or persons responsible for submitting it.').'</p>'."\n"
  444. .'<p>'.i18n::c('[parameter=site_owner] is not responsible for the content of information submitted to the site. [parameter=site_owner] is not responsible for any content contained on other sites that may link to or be linked to [parameter=site_name]. As such, the existence of a link to another site on [parameter=site_name] does not express endorsement by [parameter=site_owner] of said site or its contents.').'</p>'."\n"
  445. .'<p>'.i18n::c('All other trademarks, icons, and logos, shown or mentioned, are the property of their respective owners, including those associated with any solutions listed in [parameter=site_name]. Although [parameter=site_owner] does not own and is not responsible for all of the content on the site, we reserve the right to edit or remove any content at any time in any way we deem necessary, without any notification whatselver to the owner(s) of that content, to keep it better in line with our stated and/or unstated policies. [parameter=site_owner] is not responsible for any copyright laws violated by the applications listed herein, although we will do everything we can do resolve any disputes that may arise in this area.').'</p>'."\n";
  446. $fields['locked'] = 'Y'; // only associates can change this page
  447. $fields['publish_date'] = gmstrftime('%Y-%m-%d %H:%M:%S');
  448. if(Articles::post($fields))
  449. $text .= sprintf(i18n::s('A page "%s" has been created.'), $fields['title']).BR."\n";
  450. else
  451. $text .= Logger::error_pop().BR."\n";
  452. }
  453. // 'cover' article - basic data
  454. if(!Articles::get('cover') && ($anchor = Sections::lookup('covers'))) {
  455. $fields = array();
  456. $fields['anchor'] = $anchor;
  457. $fields['nick_name'] = 'cover';
  458. $fields['title'] = i18n::c('Welcome!');
  459. $fields['locked'] = 'Y'; // only associates can change this page
  460. $fields['publish_date'] = gmstrftime('%Y-%m-%d %H:%M:%S');
  461. if(Articles::post($fields))
  462. $text .= sprintf(i18n::s('A page "%s" has been created.'), $fields['title']).BR."\n";
  463. else
  464. $text .= Logger::error_pop().BR."\n";
  465. }
  466. // 'extra_rss' article - basic data
  467. if(!Articles::get('extra_rss') && ($anchor = Sections::lookup('extra_boxes'))) {
  468. $fields = array();
  469. $fields['anchor'] = $anchor;
  470. $fields['nick_name'] = 'extra_rss';
  471. $fields['title'] = i18n::c('Information channels');
  472. $fields['introduction'] = '';
  473. $fields['description'] = Skin::build_link('feeds/rss.php', i18n::c('Recent pages'), 'xml')
  474. .BR.Skin::build_link('feeds/', i18n::c('Information channels'), 'shortcut');
  475. $fields['locked'] = 'Y'; // only associates can change this page
  476. $fields['publish_date'] = gmstrftime('%Y-%m-%d %H:%M:%S');
  477. if(Articles::post($fields))
  478. $text .= sprintf(i18n::s('A page "%s" has been created.'), $fields['title']).BR."\n";
  479. else
  480. $text .= Logger::error_pop().BR."\n";
  481. }
  482. // 'menu' article - basic data
  483. if(!Articles::get('menu') && ($anchor = Sections::lookup('global'))) {
  484. $fields = array();
  485. $fields['anchor'] = $anchor;
  486. $fields['nick_name'] = 'menu';
  487. $fields['title'] = i18n::c('Menu');
  488. $fields['active_set'] = 'N'; // this page is integrated into every page anyway
  489. $fields['introduction'] = '';
  490. $fields['description'] = '[menu='.i18n::c('Home').']'.$context['url_to_root'].'[/menu]'."\n"
  491. .'[search]'."\n"
  492. .'[submenu='.i18n::c('Site map').']sections/[/submenu]'."\n"
  493. .'[submenu='.i18n::c('Categories').']categories/[/submenu]'."\n"
  494. .'[submenu='.i18n::c('Help').']help/[/submenu]'."\n";
  495. $fields['locked'] = 'Y'; // only associates can change this page
  496. $fields['publish_date'] = gmstrftime('%Y-%m-%d %H:%M:%S');
  497. if(Articles::post($fields))
  498. $text .= sprintf(i18n::s('A page "%s" has been created.'), $fields['title']).BR."\n";
  499. else
  500. $text .= Logger::error_pop().BR."\n";
  501. }
  502. // 'privacy' article
  503. if(!Articles::get('privacy') && ($anchor = Sections::lookup('global'))) {
  504. $fields = array();
  505. $fields['anchor'] = $anchor;
  506. $fields['nick_name'] = 'privacy';
  507. $fields['title'] = i18n::c('Privacy statement');
  508. $fields['description'] = '[toc]'."\n"
  509. .'<p>'.i18n::c('We respect your privacy! Any and all information collected at this site will be kept strictly confidential and will not be sold, reused, rented, loaned or otherwise disclosed. Any information you give to us will be held with the utmost care, and will not be used in ways that you have not consented to. Read on for more specific information.').'</p>'."\n"
  510. .'[title]'.i18n::c('User Information').'[/title]'."\n"
  511. .'<p>'.i18n::c('In order to make certain parts of this server work, some sections of the site require you to give us your e-mail address and/or other types of personal information (or may do so in the future). We do not sell, rent, loan, trade, or lease any personal information collected at our site, including survey forms or email lists. In other words, your information is safe with us.').'</p>'."\n"
  512. .'[title]'.i18n::c('Mailings').'[/title]'."\n"
  513. .'<p>'.i18n::c('In some cases we will use your email address internally, both for identification purposes and to email you updates related to your pages. Your explicit approval is required to mail you our periodic newsletter. At any time you can easily configure your account to enable or to disable such mailings. We <i>may</i>, in certain cases, send you email updates you haven\'t specifically requested to receive; if and when we do this, we won\'t do it without a good reason (and this certainly won\'t serve as our excuse to spam you.)').'</p>'."\n"
  514. .'[title]'.i18n::c('Web Logs').'[/title]'."\n"
  515. .'<p>'.i18n::c('We occasionally analyzes our website logs to constantly improve the value of the content available on our website. Our website logs are not personally identifiable, and we make no attempt to link them with the individuals that actually browse the site.').'</p>'."\n"
  516. .'[title]'.i18n::c('Cookies').'[/title]'."\n"
  517. .'<p>'.i18n::c('Although some Internet users think cookies are a serious privacy issue, as web designers we think that they come in darned handy. This site uses cookies for basic account identification purposes, but that\'s as far as we go. We won\'t use any information from cookies to track your browsing sessions, attempt to extract personal information from them that we wouldn\'t otherwise have access to, or do any other naughty things with your cookies. If you don\'t agree with our use of cookies, you can configure most web browsers not to accept them. Even without a cookie, a significant part of this server will still be accessible to you (although you will lose the ability to do anything that requires you to be logged into the server).').'</p>'."\n"
  518. .'[title]'.i18n::c('Passwords').'[/title]'."\n"
  519. .'<p>'.i18n::c('This server requires you to define and enter passwords to access certain areas of the site. In case this conjures up images of crackers breaking into our databases and getting your passwords, you don\'t have to worry about it. Passwords are stored in an encrypted format, so that <i>we</i> can\'t even look at them. This encryption <i>is</i> breakable, but it takes a lot of effort and computing time (days or weeks to crack a single password) so for all intents and purposes, your passwords are safe here. The downside to this, of course, is that if you lose or forget your password we can\'t get it back for you. We\'ve provided a method to reset your password if this happens, but as with any other password, it\'s best not to forget in the first place.').'</p>'."\n"
  520. .'[title]'.i18n::c('Posted material').'[/title]'."\n"
  521. .'<p>'.i18n::c('Posted material is, of course, not private; several persons can look at them. But this is as good a time as any to point out that we own and retain control of whatever records you enter into the system. This means that we reserve the right to view and modify your articles, files, links, comments, etc. and we exercise this right. Most of the time we do this to fix trivial things; for example, if you post a page into an incorrect section, made a really obvious typo, or put in something really inappropriate, then we might modify it. But in any case, you should be aware that this could happen. FYI, <i>we</i> get to decide what\'s inappropriate, but you should all know your netiquette by now, right? :-)').'</p>'."\n"
  522. .'<hr/><p>'.i18n::c('If you have any questions or comments about our privacy policy, or would like more information about a particular category, please [article=about, get in touch] with us.').'</p>'."\n";
  523. $fields['locked'] = 'Y'; // only associates can change this page
  524. $fields['publish_date'] = gmstrftime('%Y-%m-%d %H:%M:%S');
  525. if(Articles::post($fields))
  526. $text .= sprintf(i18n::s('A page "%s" has been created.'), $fields['title']).BR."\n";
  527. else
  528. $text .= Logger::error_pop().BR."\n";
  529. }
  530. // nothing added
  531. if(!$text)
  532. $text = i18n::s('No item has been added');
  533. // report to surfer
  534. $context['text'] .= Skin::build_box(i18n::s('Pages'), $text);
  535. // the populate hook
  536. if(is_callable(array('Hooks', 'include_scripts')) && ($text = Hooks::include_scripts('control/populate.php')))
  537. $context['text'] .= Skin::build_box(i18n::s('Extensions'), $text);
  538. // configure the interface on first installation
  539. if(!file_exists('../parameters/switch.on') && !file_exists('../parameters/switch.off')) {
  540. $context['text'] .= Skin::build_block('<form method="get" action="../skins/configure.php">'."\n"
  541. .'<p class="assistant_bar">'.Skin::build_submit_button(i18n::s('Configure the page factory')).'</p>'."\n"
  542. .'</form>', 'bottom');
  543. // or back to the control panel
  544. } else {
  545. // follow-up commands
  546. $context['text'] .= '<h3>'.i18n::s('What do you want to do now?').'</h3>';
  547. // follow-up commands
  548. $menu = array();
  549. $menu = array_merge($menu, array('sections/' => i18n::s('Check the updated Site Map')));
  550. $menu = array_merge($menu, array('help/populate.php' => i18n::s('Launch the Content Assistant again')));
  551. $menu = array_merge($menu, array('control/' => i18n::s('Control Panel')));
  552. $context['text'] .= Skin::build_list($menu, 'menu_bar');
  553. }
  554. // an associate account has been created
  555. Logger::remember('control/populate.php', 'database has been populated');
  556. }
  557. // flush the cache
  558. Cache::clear();
  559. // render the skin
  560. render_skin();
  561. ?>