PageRenderTime 68ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 1ms

/framework/modules/administration/controllers/administrationController.php

https://github.com/krazykelv/exponent-cms
PHP | 1360 lines | 1084 code | 110 blank | 166 comment | 198 complexity | 7198fcc333e12c4884e771a2a07d29aa MD5 | raw file

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. ##################################################
  3. #
  4. # Copyright (c) 2004-2013 OIC Group, Inc.
  5. #
  6. # This file is part of Exponent
  7. #
  8. # Exponent is free software; you can redistribute
  9. # it and/or modify it under the terms of the GNU
  10. # General Public License as published by the Free
  11. # Software Foundation; either version 2 of the
  12. # License, or (at your option) any later version.
  13. #
  14. # GPL: http://www.gnu.org/licenses/gpl.txt
  15. #
  16. ##################################################
  17. /**
  18. * @subpackage Controllers
  19. * @package Modules
  20. */
  21. /** @define "BASE" "../../../.." */
  22. class administrationController extends expController {
  23. public $basemodel_name = 'expRecord';
  24. public $add_permissions = array(
  25. // 'administrate'=>'Manage Administration', //FIXME is this used? old 1.0 permission
  26. 'clear'=>'Clear Caches',
  27. "fix"=>"Fix Database",
  28. "install"=>"Installation",
  29. "theme"=>"Manage Themes",
  30. 'test_smtp'=>'Test SMTP Server Settings',
  31. 'toggle'=>'Toggle Settings',
  32. 'mass'=>'Mass Mailing',
  33. );
  34. static function displayname() { return gt("Administration Controls"); }
  35. static function description() { return gt("This is the Administration Module"); }
  36. public function install_tables() {
  37. $tables = expDatabase::install_dbtables();
  38. ksort($tables);
  39. assign_to_template(array(
  40. 'status'=>$tables
  41. ));
  42. }
  43. public function delete_unused_columns() {
  44. $tables = expDatabase::install_dbtables(true);
  45. ksort($tables);
  46. assign_to_template(array(
  47. 'status'=>$tables
  48. ));
  49. }
  50. public function manage_unused_tables() {
  51. global $db;
  52. expHistory::set('manageable', $this->params);
  53. $unused_tables = array();
  54. $used_tables = array();
  55. $tables = $db->getTables();
  56. //eDebug($tables);
  57. // first the core and 1.0 definitions
  58. $coredefs = BASE.'framework/core/definitions';
  59. if (is_readable($coredefs)) {
  60. $dh = opendir($coredefs);
  61. while (($file = readdir($dh)) !== false) {
  62. if (is_readable("$coredefs/$file") && is_file("$coredefs/$file") && substr($file,-4,4) == ".php" && substr($file,-9,9) != ".info.php") {
  63. $used_tables[]= strtolower(substr($file,0,-4));
  64. }
  65. }
  66. }
  67. // then search for module definitions
  68. $moddefs = array(
  69. BASE.'themes/'.DISPLAY_THEME_REAL.'/modules', // we only want to do this for the set theme, NOT the preview theme
  70. BASE."framework/modules",
  71. );
  72. foreach ($moddefs as $moddef) {
  73. if (is_readable($moddef)) {
  74. $dh = opendir($moddef);
  75. while (($file = readdir($dh)) !== false) {
  76. if (is_dir($moddef.'/'.$file) && ($file != '..' && $file != '.')) {
  77. $dirpath = $moddef.'/'.$file.'/definitions';
  78. if (file_exists($dirpath)) {
  79. $def_dir = opendir($dirpath);
  80. while (($def = readdir($def_dir)) !== false) {
  81. if (is_readable("$dirpath/$def") && is_file("$dirpath/$def") && substr($def,-4,4) == ".php" && substr($def,-9,9) != ".info.php") {
  82. if ((!in_array(substr($def,0,-4), $used_tables))) {
  83. $used_tables[] = strtolower(substr($def,0,-4));
  84. }
  85. }
  86. }
  87. }
  88. }
  89. }
  90. }
  91. }
  92. foreach($tables as $table) {
  93. $basename = strtolower(str_replace(DB_TABLE_PREFIX.'_', '', $table));
  94. if (!in_array($basename, $used_tables) && !stristr($basename, 'forms')) {
  95. $unused_tables[$basename] = new stdClass();
  96. $unused_tables[$basename]->name = $table;
  97. $unused_tables[$basename]->rows = $db->countObjects($basename);
  98. }
  99. }
  100. assign_to_template(array(
  101. 'unused_tables'=>$unused_tables
  102. ));
  103. }
  104. public function delete_unused_tables() {
  105. global $db;
  106. $count = 0;
  107. foreach($this->params['tables'] as $del=>$table) {
  108. $basename = str_replace(DB_TABLE_PREFIX.'_', '', $table);
  109. $count += $db->dropTable($basename);
  110. }
  111. flash('message', gt('Deleted').' '.$count.' '.gt('unused tables').'.');
  112. expHistory::back();
  113. }
  114. public function fix_optimize_database() {
  115. global $db;
  116. $before = $db->databaseInfo();
  117. foreach (array_keys($before) as $table) {
  118. $db->optimize($table);
  119. }
  120. $after = $db->databaseInfo();
  121. assign_to_template(array(
  122. 'before'=>$before,
  123. 'after'=>$after
  124. ));
  125. }
  126. public function fixsessions() {
  127. global $db;
  128. // $test = $db->sql('CHECK TABLE '.DB_TABLE_PREFIX.'sessionticket');
  129. $fix = $db->sql('REPAIR TABLE '.DB_TABLE_PREFIX.'sessionticket');
  130. flash('message', gt('Sessions Table was Repaired'));
  131. expHistory::back();
  132. }
  133. public function fix_database() {
  134. global $db;
  135. // upgrade sectionref's that have lost their originals
  136. // $no_origs = array();
  137. // $sectionrefs = $db->selectObjects('sectionref',"is_original=0");
  138. // if (count($sectionrefs)) {
  139. // print_r(gt("Found").": ".count($sectionrefs)." ".gt("copies (not originals)")."<br>");
  140. // foreach ($sectionrefs as $sectionref) {
  141. // if ($db->selectObject('sectionref',"module='".$sectionref->module."' AND source='".$sectionref->source."' AND is_original='1'") == null) {
  142. // // There is no original for this sectionref so change it to the original
  143. // $sectionref->is_original = 1;
  144. // $db->updateObject($sectionref,"sectionref");
  145. // $no_origs[] = gt("Fixed").": ".$sectionref->module." - ".$sectionref->source;
  146. // }
  147. // }
  148. // }
  149. // assign_to_template(array(
  150. // 'no_origs'=>$no_origs,
  151. // ));
  152. // upgrade sectionref's that point to missing sections (pages)
  153. $sectionrefs = $db->selectObjects('sectionref',"refcount!=0");
  154. $no_sections = array();
  155. foreach ($sectionrefs as $sectionref) {
  156. if ($db->selectObject('section',"id='".$sectionref->section."'") == null) {
  157. // There is no section/page for sectionref so change the refcount
  158. $sectionref->refcount = 0;
  159. $db->updateObject($sectionref,"sectionref");
  160. $no_sections[] = gt("Fixed").": ".$sectionref->module." - ".$sectionref->source;
  161. }
  162. }
  163. assign_to_template(array(
  164. 'no_sections'=>$no_sections,
  165. ));
  166. // delete sectionref's that have empty sources since they are dead
  167. $sectionrefs = $db->selectObjects('sectionref','source=""');
  168. $no_assigns = array();
  169. if ($sectionrefs != null) {
  170. $no_assigns[] = gt("Removing").": ".count($sectionrefs)." ".gt("empty sectionrefs (no source)");
  171. $db->delete('sectionref','source=""');
  172. }
  173. assign_to_template(array(
  174. 'no_assigns'=>$no_assigns,
  175. ));
  176. // add missing sectionrefs based on existing containers (fixes aggregation problem)
  177. $containers = $db->selectObjects('container',1);
  178. $missing_sectionrefs = array();
  179. foreach ($containers as $container) {
  180. $iloc = expUnserialize($container->internal);
  181. if ($db->selectObject('sectionref',"module='".$iloc->mod."' AND source='".$iloc->src."'") == null) {
  182. // There is no sectionref for this container. Populate sectionref
  183. if ($container->external != "N;") {
  184. $newSecRef = new stdClass();
  185. $newSecRef->module = $iloc->mod;
  186. $newSecRef->source = $iloc->src;
  187. $newSecRef->internal = '';
  188. $newSecRef->refcount = 1;
  189. // $newSecRef->is_original = 1;
  190. $eloc = expUnserialize($container->external);
  191. // $section = $db->selectObject('sectionref',"module='containermodule' AND source='".$eloc->src."'");
  192. $section = $db->selectObject('sectionref',"module='container' AND source='".$eloc->src."'");
  193. if (!empty($section)) {
  194. $newSecRef->section = $section->id;
  195. $db->insertObject($newSecRef,"sectionref");
  196. $missing_sectionrefs[] = gt("Missing sectionref for container replaced").": ".$iloc->mod." - ".$iloc->src." - PageID #".$section->id;
  197. } else {
  198. $db->delete('container','id="'.$container->id.'"');
  199. $missing_sectionrefs[] = gt("Cant' find the container page for container").": ".$iloc->mod." - ".$iloc->src.' - '.gt('deleted');
  200. }
  201. }
  202. }
  203. }
  204. assign_to_template(array(
  205. 'missing_sectionrefs'=>$missing_sectionrefs,
  206. ));
  207. }
  208. public function fix_tables() {
  209. $renamed = expDatabase::fix_table_names();
  210. assign_to_template(array(
  211. 'tables'=>$renamed,
  212. ));
  213. }
  214. public function install_ecommerce_tables() {
  215. global $db;
  216. $eql = BASE . "install/samples/ecommerce.eql";
  217. if (file_exists($eql)) {
  218. $errors = array();
  219. expFile::restoreDatabase($db,$eql,$errors);
  220. }
  221. if (DEVELOPMENT && count($errors)) {
  222. $msg = gt('Errors were encountered importing the e-Commerce data.').'<ul>';
  223. foreach ($errors as $e) $msg .= '<li>'.$e.'</li>';
  224. $msg .= '</ul>';
  225. flash('error',$msg);
  226. } else {
  227. flash('message',gt('e-Commerce data was added to your database.'));
  228. }
  229. expHistory::back();
  230. }
  231. public function toolbar() {
  232. // global $user;
  233. $menu = array();
  234. $dirs = array(
  235. BASE.'framework/modules/administration/menus',
  236. BASE.'themes/'.DISPLAY_THEME.'/modules/administration/menus'
  237. );
  238. foreach ($dirs as $dir) {
  239. if (is_readable($dir)) {
  240. $dh = opendir($dir);
  241. while (($file = readdir($dh)) !== false) {
  242. if (substr($file,-4,4) == '.php' && is_readable($dir.'/'.$file) && is_file($dir.'/'.$file)) {
  243. $menu[substr($file,0,-4)] = include($dir.'/'.$file);
  244. if (empty($menu[substr($file,0,-4)])) unset($menu[substr($file,0,-4)]);
  245. }
  246. }
  247. }
  248. }
  249. // sort the top level menus alphabetically by filename
  250. ksort($menu);
  251. $sorted = array();
  252. foreach($menu as $m) $sorted[] = $m;
  253. // slingbar position
  254. if (isset($_COOKIE['slingbar-top'])){
  255. $top = $_COOKIE['slingbar-top'];
  256. } else {
  257. $top = SLINGBAR_TOP;
  258. }
  259. assign_to_template(array(
  260. 'menu'=>json_encode($sorted),
  261. "top"=>$top
  262. ));
  263. }
  264. // public function index() {
  265. // redirect_to(array('controller'=>'administration', 'action'=>'toolbar'));
  266. //// $this->toolbar();
  267. // }
  268. public function update_SetSlingbarPosition() {
  269. expSession::set("slingbar_top",$this->params['top']);
  270. expHistory::back();
  271. }
  272. public function manage_lang() {
  273. global $default_lang, $cur_lang;
  274. // Available Languages
  275. $langs = expLang::langList();
  276. $num_missing = 0;
  277. foreach ($default_lang as $key => $value) {
  278. if (!array_key_exists($key,$cur_lang)) $num_missing++;
  279. }
  280. $num_untrans = 0;
  281. foreach ($cur_lang as $key => $value) {
  282. if ($key == $value) $num_untrans++;
  283. }
  284. assign_to_template(array(
  285. 'langs'=>$langs,
  286. 'missing'=>$num_missing,
  287. "count"=>count($cur_lang),
  288. 'untrans'=>$num_untrans
  289. ));
  290. }
  291. public function update_language() {
  292. expSettings::change('LANGUAGE', $this->params['newlang']);
  293. flash('message',gt('Display Language changed to').": ".$this->params['newlang']);
  294. redirect_to(array('controller'=>'administration', 'action'=>'manage_lang'));
  295. // $this->manage_lang();
  296. }
  297. public function manage_lang_await() {
  298. global $cur_lang;
  299. $awaiting_trans = array();
  300. foreach ($cur_lang as $key => $value) {
  301. if ($key == $value) {
  302. $awaiting_trans[$key] = stripslashes($value);
  303. }
  304. }
  305. assign_to_template(array(
  306. 'await'=>$awaiting_trans
  307. ));
  308. }
  309. public function save_newlangfile() {
  310. $result = expLang::createNewLangFile($this->params['newlang']);
  311. flash($result['type'],$result['message']);
  312. if ($result['type'] != 'error') {
  313. expSettings::change('LANGUAGE', $this->params['newlang']);
  314. expLang::createNewLangInfoFile($this->params['newlang'],$this->params['newauthor'],$this->params['newcharset'],$this->params['newlocale']);
  315. flash('message',gt('Display Language changed to').": ".$this->params['newlang']);
  316. }
  317. redirect_to(array('controller'=>'administration', 'action'=>'manage_lang'));
  318. // $this->manage_lang();
  319. }
  320. public function test_smtp() {
  321. $smtp = new expMail();
  322. $smtp->test();
  323. }
  324. public function toggle_minify() {
  325. $value = (MINIFY == 1) ? 0 : 1;
  326. expSettings::change('MINIFY', $value);
  327. $message = (MINIFY != 1) ? gt("Exponent is now minifying Javascript and CSS") : gt("Exponent is no longer minifying Javascript and CSS") ;
  328. flash('message',$message);
  329. expHistory::back();
  330. }
  331. public function toggle_dev() {
  332. $value = (DEVELOPMENT == 1) ? 0 : 1;
  333. expSettings::change('DEVELOPMENT', $value);
  334. expTheme::removeCss();
  335. $message = (DEVELOPMENT != 1) ? gt("Exponent is now in 'Development' mode") : gt("Exponent is no longer in 'Development' mode") ;
  336. flash('message',$message);
  337. expHistory::back();
  338. }
  339. public function toggle_log() {
  340. $value = (LOGGER == 1) ? 0 : 1;
  341. expSettings::change('LOGGER', $value);
  342. expHistory::back();
  343. }
  344. public function toggle_maintenance() {
  345. $value = (MAINTENANCE_MODE == 1) ? 0 : 1;
  346. expSettings::change('MAINTENANCE_MODE', $value);
  347. MAINTENANCE_MODE == 1 ? flash('message',gt("Exponent is no longer in 'Maintenance' mode")) : "" ;
  348. expHistory::back();
  349. }
  350. public function toggle_preview() {
  351. $level = 99;
  352. if (expSession::is_set('uilevel')) {
  353. $level = expSession::get('uilevel');
  354. }
  355. if ($level == UILEVEL_PREVIEW) {
  356. expSession::un_set('uilevel');
  357. } else { //edit mode
  358. expSession::set("uilevel",UILEVEL_PREVIEW);
  359. }
  360. $message = ($level == UILEVEL_PREVIEW) ? gt("Exponent is no longer in 'Preview' mode") : gt("Exponent is now in 'Preview' mode") ;
  361. flash('message',$message);
  362. expHistory::back();
  363. }
  364. public function manage_version() {
  365. expSession::un_set('update-check'); // reset the already checked flag
  366. if (!expVersion::checkVersion(true)) {
  367. flash('message', gt('Your version of Exponent CMS is current.'));
  368. }
  369. expHistory::back();
  370. }
  371. public function clear_smarty_cache() {
  372. expTheme::clearSmartyCache();
  373. expSession::clearAllUsersSessionCache();
  374. }
  375. public function clear_css_cache() {
  376. expTheme::removeCss();
  377. flash('message',gt("CSS/Minify Cache has been cleared"));
  378. expHistory::back();
  379. }
  380. public function clear_image_cache() {
  381. expFile::removeFilesInDirectory(BASE.'tmp/pixidou');
  382. if (file_exists(BASE.'tmp/img_cache')) expFile::removeFilesInDirectory(BASE.'tmp/img_cache');
  383. flash('message',gt("Image/Pixidou Cache has been cleared"));
  384. expHistory::back();
  385. }
  386. public function clear_rss_cache() {
  387. expFile::removeFilesInDirectory(BASE.'tmp/rsscache');
  388. flash('message',gt("RSS/Podcast Cache has been cleared"));
  389. expHistory::back();
  390. }
  391. public function clear_all_caches() {
  392. expTheme::removeSmartyCache();
  393. expSession::clearAllUsersSessionCache(); // clear the session cache for true 'clear all'
  394. expSession::un_set('framework');
  395. expSession::un_set('display_theme');
  396. expSession::un_set('theme_style');
  397. expTheme::removeCss();
  398. expFile::removeFilesInDirectory(BASE.'tmp/pixidou');
  399. if (file_exists(BASE.'tmp/img_cache')) expFile::removeFilesInDirectory(BASE.'tmp/img_cache');
  400. if (file_exists(BASE.'tmp/extensionuploads')) expFile::removeFilesInDirectory(BASE.'tmp/extensionuploads');
  401. expFile::removeFilesInDirectory(BASE.'tmp/rsscache');
  402. flash('message',gt("All the System Caches have been cleared"));
  403. expHistory::back();
  404. }
  405. public function install_extension() {
  406. $modsurl =array(
  407. 'themes'=>'http://www.exponentcms.org/rss/feed/title/exponentcms-themes',
  408. 'fixes'=>'http://www.exponentcms.org/rss/feed/title/exponentcms-fixes',
  409. 'mods'=>'http://www.exponentcms.org/rss/feed/title/exponentcms-mods'
  410. );
  411. $RSS = new SimplePie();
  412. $RSS->set_cache_location(BASE.'tmp/rsscache'); // default is ./cache
  413. // $RSS->set_cache_duration(3600); // default if 3600
  414. $RSS->set_timeout(20); // default is 10
  415. // $RSS->set_output_encoding('UTF-8'); // which is the default
  416. $items['themes'] = array();
  417. $items['fixes'] = array();
  418. $items['mods'] = array();
  419. foreach($modsurl as $type=>$url) {
  420. $RSS->set_feed_url($url);
  421. $feed = $RSS->init();
  422. if (!$feed) {
  423. // an error occurred in the rss.
  424. continue;
  425. }
  426. $RSS->handle_content_type();
  427. foreach ($RSS->get_items() as $rssItem) {
  428. $rssObject = new stdClass();
  429. $rssObject->title = $rssItem->get_title();
  430. $rssObject->body = $rssItem->get_description();
  431. $rssObject->rss_link = $rssItem->get_permalink();
  432. $rssObject->publish = $rssItem->get_date('U');
  433. $rssObject->publish_date = $rssItem->get_date('U');
  434. foreach ($rssItem->get_enclosures() as $enclosure) {
  435. $rssObject->enclosure = $enclosure->get_link();
  436. $rssObject->length = $enclosure->get_length();
  437. }
  438. $items[$type][] = $rssObject;
  439. }
  440. }
  441. // $form = new form();
  442. // $form->meta('module','administration');
  443. // $form->meta('action','install_extension_confirm');
  444. // $form->register(null,'',new htmlcontrol(expCore::maxUploadSizeMessage()));
  445. // $form->register('mod_archive','Extension Archive',new uploadcontrol());
  446. // $form->register('patch',gt('Patch Exponent CMS or Install Theme?'),new checkboxcontrol(false,false),null,null,gt('All extensions are normally placed within the CURRENT theme (folder)'));
  447. // $form->register('submit','',new buttongroupcontrol(gt('Upload Extension')));
  448. assign_to_template(array(
  449. 'themes'=>$items['themes'],
  450. 'fixes'=>$items['fixes'],
  451. 'mods'=>$items['mods'],
  452. // 'form_html'=>$form->toHTML()
  453. ));
  454. }
  455. public function install_extension_confirm() {
  456. if (!empty($this->params['files'])) {
  457. foreach ($this->params['files'] as $title=>$url) {
  458. $filename = tempnam("tmp/extensionuploads/",'tmp');
  459. expCore::saveData($url,$filename);
  460. $_FILES['mod_archive']['name'] = end(explode("/", $url));
  461. // $finfo = finfo_open(FILEINFO_MIME);
  462. // $mimetype = finfo_file($finfo, $filename);
  463. // finfo_close($finfo);
  464. // $_FILES['mod_archive']['type'] = $mimetype;
  465. $_FILES['mod_archive']['tmp_name'] = $filename;
  466. $_FILES['mod_archive']['error'] = 0;
  467. $_FILES['mod_archive']['size'] = filesize($filename);
  468. }
  469. }
  470. if ($_FILES['mod_archive']['error'] != UPLOAD_ERR_OK) {
  471. switch($_FILES['mod_archive']['error']) {
  472. case UPLOAD_ERR_INI_SIZE:
  473. case UPLOAD_ERR_FORM_SIZE:
  474. flash('error', gt('The file you uploaded exceeded the size limits for the server.'));
  475. break;
  476. case UPLOAD_ERR_PARTIAL:
  477. flash('error', gt('The file you uploaded was only partially uploaded.'));
  478. break;
  479. case UPLOAD_ERR_NO_FILE:
  480. flash('error', gt('No file was uploaded.'));
  481. break;
  482. }
  483. } else {
  484. $basename = basename($_FILES['mod_archive']['name']);
  485. // Check future radio buttons; for now, try auto-detect
  486. $compression = null;
  487. $ext = '';
  488. if (substr($basename,-4,4) == '.tar') {
  489. $compression = null;
  490. $ext = '.tar';
  491. } else if (substr($basename,-7,7) == '.tar.gz') {
  492. $compression = 'gz';
  493. $ext = '.tar.gz';
  494. } else if (substr($basename,-4,4) == '.tgz') {
  495. $compression = 'gz';
  496. $ext = '.tgz';
  497. } else if (substr($basename,-8,8) == '.tar.bz2') {
  498. $compression = 'bz2';
  499. $ext = '.tar.bz2';
  500. } else if (substr($basename,-4,4) == '.zip') {
  501. $compression = 'zip';
  502. $ext = '.zip';
  503. }
  504. if ($ext == '') {
  505. flash('error', gt('Unknown archive format. Archives must either be regular ZIP files, TAR files, Gzipped Tarballs, or Bzipped Tarballs.'));
  506. } else {
  507. // Look for stale sessid directories:
  508. $sessid = session_id();
  509. if (file_exists(BASE."tmp/extensionuploads/$sessid") && is_dir(BASE."tmp/extensionuploads/$sessid")) expFile::removeDirectory("tmp/extensionuploads/$sessid");
  510. $return = expFile::makeDirectory("tmp/extensionuploads/$sessid");
  511. if ($return != SYS_FILES_SUCCESS) {
  512. switch ($return) {
  513. case SYS_FILES_FOUNDFILE:
  514. case SYS_FILES_FOUNDDIR:
  515. flash('error', gt('Found a file in the directory path when creating the directory to store the files in.'));
  516. break;
  517. case SYS_FILES_NOTWRITABLE:
  518. flash('error', gt('Destination parent is not writable.'));
  519. break;
  520. case SYS_FILES_NOTREADABLE:
  521. flash('error', gt('Destination parent is not readable.'));
  522. break;
  523. }
  524. }
  525. $dest = BASE."tmp/extensionuploads/$sessid/archive$ext";
  526. if (is_uploaded_file($_FILES['mod_archive']['tmp_name'])) {
  527. move_uploaded_file($_FILES['mod_archive']['tmp_name'],$dest);
  528. } else {
  529. rename($_FILES['mod_archive']['tmp_name'],$dest);
  530. }
  531. if ($compression != 'zip') {// If not zip, must be tar
  532. include_once(BASE.'external/Tar.php');
  533. $tar = new Archive_Tar($dest,$compression);
  534. PEAR::setErrorHandling(PEAR_ERROR_PRINT);
  535. $return = $tar->extract(dirname($dest));
  536. if (!$return) {
  537. flash('error',gt('Error extracting TAR archive'));
  538. } else {
  539. // header('Location: ' . URL_FULL . 'index.php?module=administrationmodule&action=verify_extension&type=tar');
  540. // self::verify_extension('tar');
  541. }
  542. } else { // must be zip
  543. include_once(BASE.'external/Zip.php');
  544. $zip = new Archive_Zip($dest);
  545. PEAR::setErrorHandling(PEAR_ERROR_PRINT);
  546. if ($zip->extract(array('add_path'=>dirname($dest))) == 0) {
  547. flash('error',gt('Error extracting ZIP archive').': '.$zip->_error_code . ' : ' . $zip->_error_string . '<br />');
  548. } else {
  549. // header('Location: ' . URL_FULL . 'index.php?module=administrationmodule&action=verify_extension&type=zip');
  550. // self::verify_extension('zip');
  551. }
  552. }
  553. $sessid = session_id();
  554. $files = array();
  555. foreach (expFile::listFlat(BASE.'tmp/extensionuploads/'.$sessid,true,null,array(),BASE.'tmp/extensionuploads/'.$sessid) as $key=>$f) {
  556. if ($key != '/archive.tar' && $key != '/archive.tar.gz' && $key != '/archive.tar.bz2' && $key != '/archive.zip') {
  557. if (empty($this->params['patch']) || !$this->params['patch']) {
  558. $key = substr($key,1);
  559. if (substr($key,0,7)=='themes/') {
  560. $parts = explode('/',$key);
  561. $parts[1] = DISPLAY_THEME_REAL;
  562. $file = implode('/',$parts);
  563. } else {
  564. $file = 'themes/'.DISPLAY_THEME_REAL.'/'.str_replace("framework/", "", $key);
  565. }
  566. $file = str_replace("modules-1", "modules", $file);
  567. } else {
  568. $file = substr($key,1);
  569. }
  570. $files[] = array(
  571. 'absolute'=>$file,
  572. 'relative'=>$f,
  573. 'canCreate'=>expFile::canCreate(BASE.$file,1),
  574. 'ext'=>substr($f,-3,3)
  575. );
  576. }
  577. }
  578. assign_to_template(array(
  579. 'relative'=>'tmp/extensionuploads/'.$sessid,
  580. 'files'=>$files,
  581. 'patch'=>empty($this->params['patch'])?0:$this->params['patch']
  582. ));
  583. }
  584. }
  585. }
  586. public function install_extension_finish() {
  587. $patch =$this->params['patch']==1;
  588. $sessid = session_id();
  589. if (!file_exists(BASE."tmp/extensionuploads/$sessid") || !is_dir(BASE."tmp/extensionuploads/$sessid")) {
  590. $nofiles = 1;
  591. } else {
  592. $success = array();
  593. foreach (array_keys(expFile::listFlat(BASE."tmp/extensionuploads/$sessid",true,null,array(),BASE."tmp/extensionuploads/$sessid")) as $file) {
  594. if ($file != '/archive.tar' && $file != '/archive.tar.gz' && $file != 'archive.tar.bz2' && $file != '/archive.zip') {
  595. if ($patch) { // this is a patch/fix extension
  596. expFile::makeDirectory(dirname($file));
  597. $success[$file] = copy(BASE."tmp/extensionuploads/$sessid".$file,BASE.substr($file,1));
  598. if (basename($file) == 'views_c') chmod(BASE.substr($file,1),0777);
  599. } else {
  600. $newfile = substr($file,1);
  601. if (substr($newfile,0,7)=='themes/') { // this is a theme extension
  602. $parts = explode('/',$newfile);
  603. $parts[1] = DISPLAY_THEME_REAL;
  604. $newfile = implode('/',$parts);
  605. } else { // this is a mod extension
  606. $newfile = str_replace("framework/", "", $newfile);
  607. $newfile = 'themes/'.DISPLAY_THEME_REAL.'/'.str_replace("modules-1", "modules", $newfile);
  608. }
  609. expFile::makeDirectory(dirname($newfile));
  610. $success[$newfile] = copy(BASE."tmp/extensionuploads/$sessid".$file,BASE.$newfile);
  611. }
  612. }
  613. }
  614. $del_return = expFile::removeDirectory(BASE."tmp/extensionuploads/$sessid"); //FIXME shouldn't use echo
  615. // echo $del_return;
  616. $tables = expDatabase::install_dbtables();
  617. ksort($tables);
  618. assign_to_template(array(
  619. 'tables'=>$tables
  620. ));
  621. $nofiles = 0;
  622. }
  623. assign_to_template(array(
  624. 'nofiles'=>$nofiles,
  625. 'success'=>$success,
  626. 'redirect'=>expHistory::getLastNotEditable()
  627. ));
  628. }
  629. public function mass_mail() {
  630. // nothing we need to do except display view
  631. }
  632. public function mass_mail_out() {
  633. global $user;
  634. $emaillist = array();
  635. if (!empty($this->params['allusers'])) {
  636. foreach (user::getAllUsers() as $u) {
  637. $emaillist[] = $u->email;
  638. }
  639. } else {
  640. if(!empty($this->params['group_list'])) {
  641. foreach (listbuildercontrol::parseData($this->params,'grouplist') as $group_id) {
  642. $grpusers = group::getUsersInGroup($group_id);
  643. foreach ($grpusers as $u) {
  644. $emaillist[] = $u->email;
  645. }
  646. }
  647. }
  648. if(!empty($this->params['user_list'])) {
  649. foreach (listbuildercontrol::parseData($this->params,'user_list') as $user_id) {
  650. $u = user::getUserById($user_id);
  651. $emaillist[] = $u->email;
  652. }
  653. }
  654. if(!empty($this->params['address_list'])) {
  655. foreach (listbuildercontrol::parseData($this->params,'address_list') as $email) {
  656. $emaillist[] = $email;
  657. }
  658. }
  659. }
  660. //This is an easy way to remove duplicates
  661. $emaillist = array_flip(array_flip($emaillist));
  662. $emaillist = array_map('trim', $emaillist);
  663. if (empty($emaillist)) {
  664. $post = empty($_POST) ? array() : $_POST;
  665. expValidator::failAndReturnToForm(gt('No Mailing Recipients Selected!'), $post);
  666. }
  667. if (empty($this->params['subject']) && empty($this->params['body']) && empty($_FILES['attach']['size'])) {
  668. $post = empty($_POST) ? array() : $_POST;
  669. expValidator::failAndReturnToForm(gt('Nothing to Send!'), $post);
  670. }
  671. $emailText = $this->params['body'];
  672. $emailText = chop(strip_tags(str_replace(array("<br />","<br>","br/>"),"\n",$emailText)));
  673. $emailHtml = $this->params['body'];
  674. $from = $user->email;
  675. if (empty($from)) {
  676. $from = trim(SMTP_FROMADDRESS);
  677. }
  678. $from_name = $user->firstname." ".$user->lastname." (".$user->username.")";
  679. if (empty($from_name)) {
  680. $from_name = trim(ORGANIZATION_NAME);
  681. }
  682. $subject = $this->params['subject'];
  683. if (empty($subject)) {
  684. $subject = gt('Email from') . ' ' . trim(ORGANIZATION_NAME);
  685. }
  686. $headers = array(
  687. "MIME-Version" => "1.0",
  688. "Content-type" => "text/html; charset=" . LANG_CHARSET
  689. );
  690. if (count($emaillist)) {
  691. $mail = new expMail();
  692. if (!empty($_FILES['attach']['size'])) {
  693. $dir = 'tmp';
  694. $filename = expFile::fixName(time().'_'.$_FILES['attach']['name']);
  695. $dest = $dir.'/'.$filename;
  696. //Check to see if the directory exists. If not, create the directory structure.
  697. if (!file_exists(BASE.$dir)) expFile::makeDirectory($dir);
  698. // Move the temporary uploaded file into the destination directory, and change the name.
  699. expFile::moveUploadedFile($_FILES['attach']['tmp_name'],BASE.$dest);
  700. // $finfo = finfo_open(FILEINFO_MIME_TYPE);
  701. // $relpath = str_replace(PATH_RELATIVE, '', BASE);
  702. // $ftype = finfo_file($finfo, BASE.$dest);
  703. // finfo_close($finfo);
  704. $mail->attach_file_on_disk(BASE.$dest, expFile::getMimeType(BASE.$dest));
  705. }
  706. if ($this->params['batchsend']) {
  707. $mail->quickBatchSend(array(
  708. 'headers'=>$headers,
  709. 'html_message'=>$emailHtml,
  710. "text_message"=>$emailText,
  711. 'to'=>$emaillist,
  712. 'from'=>array(trim($from)=>$from_name),
  713. 'subject'=>$subject,
  714. ));
  715. } else {
  716. $mail->quickSend(array(
  717. 'headers'=>$headers,
  718. 'html_message'=>$emailHtml,
  719. "text_message"=>$emailText,
  720. 'to'=>$emaillist,
  721. 'from'=>array(trim($from)=>$from_name),
  722. 'subject'=>$subject,
  723. ));
  724. }
  725. if (!empty($dest)) unlink(BASE.$dest); // delete temp file attachment
  726. flash('message',gt('Mass Email was sent'));
  727. expHistory::back();
  728. }
  729. }
  730. /**
  731. * feature to run upgrade scripts outside of installation
  732. *
  733. */
  734. public function install_upgrades() {
  735. //display the upgrade scripts
  736. if (is_readable(BASE.'install/upgrades')) {
  737. $i = 0;
  738. if (is_readable(BASE.'install/include/upgradescript.php')) include_once(BASE.'install/include/upgradescript.php');
  739. // first build a list of valid upgrade scripts
  740. $oldscripts = array(
  741. 'install_tables.php',
  742. 'convert_db_trim.php',
  743. 'remove_exp1_faqmodule.php',
  744. 'remove_locationref.php',
  745. 'upgrade_attachableitem_tables.php',
  746. );
  747. $ext_dirs = array(
  748. BASE . 'install/upgrades',
  749. THEME_ABSOLUTE . 'modules/upgrades'
  750. );
  751. foreach ($ext_dirs as $dir) {
  752. if (is_readable($dir)) {
  753. $dh = opendir($dir);
  754. while (($file = readdir($dh)) !== false) {
  755. if (is_readable($dir . '/' . $file) && is_file($dir . '/' . $file) && substr($file, -4, 4) == '.php' && !in_array($file,$oldscripts)) {
  756. include_once($dir . '/' . $file);
  757. $classname = substr($file, 0, -4);
  758. /**
  759. * Stores the upgradescript object
  760. * @var \upgradescript $upgradescripts
  761. * @name $upgradescripts
  762. */
  763. $upgradescripts[] = new $classname;
  764. }
  765. }
  766. }
  767. }
  768. // next sort the list by priority
  769. usort($upgradescripts, array('upgradescript','prioritize'));
  770. // next run through the list
  771. $db_version = expVersion::dbVersion();
  772. $upgrade_scripts = array();
  773. foreach ($upgradescripts as $upgradescript) {
  774. if ($upgradescript->checkVersion($db_version) && $upgradescript->needed()) {
  775. $upgradescript->classname = get_class($upgradescript);
  776. $upgrade_scripts[] = $upgradescript;
  777. $i++;
  778. }
  779. }
  780. }
  781. assign_to_template(array(
  782. 'scripts'=>$upgrade_scripts,
  783. ));
  784. }
  785. /**
  786. * run selected upgrade scripts outside of installation
  787. *
  788. */
  789. public function install_upgrades_run() {
  790. $tables = expDatabase::install_dbtables();
  791. ksort($tables);
  792. // locate the upgrade scripts
  793. $upgrade_dir = BASE.'install/upgrades';
  794. if (is_readable($upgrade_dir)) {
  795. $i = 0;
  796. if (is_readable(BASE.'install/include/upgradescript.php')) include_once(BASE.'install/include/upgradescript.php');
  797. $dh = opendir($upgrade_dir);
  798. // first build a list of valid upgrade scripts
  799. $oldscripts = array(
  800. 'install_tables.php',
  801. 'convert_db_trim.php',
  802. 'remove_exp1_faqmodule.php',
  803. 'remove_locationref.php',
  804. 'upgrade_attachableitem_tables.php',
  805. );
  806. while (($file = readdir($dh)) !== false) {
  807. if (is_readable($upgrade_dir . '/' . $file) && is_file($upgrade_dir . '/' . $file) && substr($file, -4, 4) == '.php' && !in_array($file,$oldscripts)) {
  808. include_once($upgrade_dir . '/' . $file);
  809. $classname = substr($file, 0, -4);
  810. /**
  811. * Stores the upgradescript object
  812. * @var \upgradescript $upgradescripts
  813. * @name $upgradescripts
  814. */
  815. $upgradescripts[] = new $classname;
  816. }
  817. }
  818. // next sort the list by priority
  819. usort($upgradescripts, array('upgradescript','prioritize'));
  820. // next run through the list
  821. $db_version = expVersion::dbVersion();
  822. $upgrade_scripts = array();
  823. foreach ($upgradescripts as $upgradescript) {
  824. if ($upgradescript->checkVersion($db_version) && $upgradescript->needed()) {
  825. if (!empty($this->params[get_class($upgradescript)])) {
  826. $upgradescript->results = $upgradescript->upgrade();
  827. }
  828. $upgradescript->classname = get_class($upgradescript);
  829. $upgrade_scripts[] = $upgradescript;
  830. $i++;
  831. }
  832. }
  833. }
  834. assign_to_template(array(
  835. 'scripts'=>$upgrade_scripts,
  836. 'tables'=>$tables,
  837. ));
  838. }
  839. public function manage_themes() {
  840. expHistory::set('manageable', $this->params);
  841. $themes = array();
  842. if (is_readable(BASE.'themes')) {
  843. $dh = opendir(BASE.'themes');
  844. while (($file = readdir($dh)) !== false) {
  845. if ($file != '.' && $file != '..' && is_dir(BASE."themes/$file") && is_readable(BASE."themes/$file/class.php")) {
  846. include_once(BASE."themes/$file/class.php");
  847. $theme = new $file();
  848. $t = new stdClass();
  849. $t->user_configured = isset($theme->user_configured) ? $theme->user_configured : '';
  850. $t->stock_theme = isset($theme->stock_theme) ? $theme->stock_theme : '';
  851. $t->name = $theme->name();
  852. $t->description = $theme->description();
  853. $t->author = $theme->author();
  854. $t->style_variations = array();
  855. $sv = opendir(BASE.'themes/'.$file);
  856. while (($s = readdir($sv)) !== false) {
  857. if (substr($s,0,4) == "css_") {
  858. $t->style_variations[str_replace("css_","",$s)] = str_replace("css_","",$s);
  859. }
  860. }
  861. if(count($t->style_variations)>0){
  862. $t->style_variations = array_merge(array('Default'=>'Default'),$t->style_variations);
  863. }
  864. $t->preview = is_readable(BASE."themes/$file/preview.jpg") ? "themes/$file/preview.jpg" : "themes/" . DISPLAY_THEME . "/noprev.jpg";
  865. $t->mobile = is_readable(BASE."themes/$file/mobile/index.php") ? true : false;
  866. $themes[$file] = $t;
  867. }
  868. }
  869. }
  870. assign_to_template(array(
  871. 'themes'=>$themes
  872. ));
  873. }
  874. public function theme_switch() {
  875. expSettings::change('DISPLAY_THEME_REAL', $this->params['theme']);
  876. expSession::set('display_theme',$this->params['theme']);
  877. $sv = isset($this->params['sv'])?$this->params['sv']:'';
  878. if (strtolower($sv)=='default') {
  879. $sv = '';
  880. }
  881. expSettings::change('THEME_STYLE_REAL',$sv);
  882. expSession::set('theme_style',$sv);
  883. expDatabase::install_dbtables(); // update tables to include any custom definitions in the new theme
  884. // $message = (MINIFY != 1) ? "Exponent is now minifying Javascript and CSS" : "Exponent is no longer minifying Javascript and CSS" ;
  885. // flash('message',$message);
  886. $message = gt("You have selected the")." '".$this->params['theme']."' ".gt("theme");
  887. if ($sv != '') {
  888. $message .= ' '.gt('with').' '.$this->params['sv'].' '.gt('style variation');
  889. }
  890. flash('message',$message);
  891. expSession::un_set('framework');
  892. expTheme::removeSmartyCache();
  893. expSession::clearAllUsersSessionCache();
  894. expHistory::returnTo('manageable');
  895. }
  896. public function theme_preview() {
  897. expSession::set('display_theme',$this->params['theme']);
  898. $sv = isset($this->params['sv'])?$this->params['sv']:'';
  899. if (strtolower($sv)=='default') {
  900. $sv = '';
  901. }
  902. expSession::set('theme_style',$sv);
  903. $message = gt("You are previewing the")." '".$this->params['theme']."' ".gt("theme");
  904. if ($sv) {
  905. $message .= ' with '.$sv.' style variation';
  906. }
  907. if ($this->params['theme'] != DISPLAY_THEME_REAL || $this->params['sv'] != THEME_STYLE_REAL) {
  908. flash('notice',$message);
  909. }
  910. expSession::un_set('framework');
  911. expTheme::removeSmartyCache();
  912. expSession::clearAllUsersSessionCache();
  913. expHistory::back();
  914. }
  915. public function configure_theme() {
  916. if (is_readable(BASE."themes/".$this->params['theme']."/class.php")) {
  917. include_once(BASE."themes/".$this->params['theme']."/class.php");
  918. $themeclass = $this->params['theme'];
  919. $theme = new $themeclass();
  920. $theme->configureTheme();
  921. }
  922. }
  923. public function update_theme() {
  924. if (is_readable(BASE."themes/".$this->params['theme']."/class.php")) {
  925. include_once(BASE."themes/".$this->params['theme']."/class.php");
  926. $themeclass = $this->params['theme'];
  927. $theme = new $themeclass();
  928. $theme->saveThemeConfig($this->params);
  929. expTheme::removeSmartyCache();
  930. expSession::clearAllUsersSessionCache();
  931. }
  932. }
  933. public function export_theme() {
  934. include_once(BASE.'external/Tar.php');
  935. $themeclass = $this->params['theme'];
  936. $fname = tempnam(BASE.'/tmp','exporter_files_');
  937. $tar = new Archive_Tar($fname,'gz');
  938. $tar->createModify(BASE.'themes/'.$themeclass,'themes/',BASE.'themes/');
  939. $filename = preg_replace('/[^A-Za-z0-9_.-]/','-',$themeclass.'.tar.gz');
  940. ob_end_clean();
  941. // This code was lifted from phpMyAdmin, but this is Open Source, right?
  942. // 'application/octet-stream' is the registered IANA type but
  943. // MSIE and Opera seems to prefer 'application/octetstream'
  944. $mime_type = (EXPONENT_USER_BROWSER == 'IE' || EXPONENT_USER_BROWSER == 'OPERA') ? 'application/octetstream' : 'application/octet-stream';
  945. header('Content-Type: ' . $mime_type);
  946. header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
  947. // IE need specific headers
  948. if (EXPONENT_USER_BROWSER == 'IE') {
  949. header('Content-Disposition: inline; filename="' . $filename . '"');
  950. header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  951. header('Pragma: public');
  952. } else {
  953. header('Content-Disposition: attachment; filename="' . $filename . '"');
  954. header('Pragma: no-cache');
  955. }
  956. $fh = fopen($fname,'rb');
  957. while (!feof($fh)) {
  958. echo fread($fh,8192);
  959. }
  960. fclose($fh);
  961. unlink($fname);
  962. exit(''); // Exit, since we are exporting.
  963. }
  964. public function togglemobile() {
  965. if (!expSession::is_set('mobile')) { // account for FORCE_MOBILE initial state
  966. expSession::set('mobile',MOBILE);
  967. }
  968. expSession::set('mobile',!expSession::get('mobile'));
  969. expTheme::removeSmartyCache();
  970. expHistory::back();
  971. }
  972. public function configure_site () {
  973. expHistory::set('manageable',$this->params);
  974. // TYPES OF ANTISPAM CONTROLS... CURRENTLY ONLY ReCAPTCHA
  975. $as_types = array(
  976. '0'=>'-- '.gt('Please Select an Anti-Spam Control').' --',
  977. "recaptcha"=>'reCAPTCHA'
  978. );
  979. //THEMES FOR RECAPTCHA
  980. $as_themes = array(
  981. "red"=>gt('DEFAULT RED'),
  982. "white"=>gt('White'),
  983. "blackglass"=>gt('Black Glass'),
  984. "clean"=>gt('Clean (very generic)'),
  985. //"custom"=>'Custom' --> THIS MAY BE COOL TO ADD LATER...
  986. );
  987. // Available Themes
  988. $themes = array();
  989. if (is_readable(BASE.'themes')) {
  990. $theme_dh = opendir(BASE.'themes');
  991. while (($theme_file = readdir($theme_dh)) !== false) {
  992. if (is_readable(BASE.'themes/'.$theme_file.'/class.php')) {
  993. // Need to avoid the duplicate theme problem.
  994. if (!class_exists($theme_file)) {
  995. include_once(BASE.'themes/'.$theme_file.'/class.php');
  996. }
  997. if (class_exists($theme_file)) {
  998. // Need to avoid instantiating non-existent classes.
  999. $t = new $theme_file();
  1000. $themes[$theme_file] = $t->name();
  1001. }
  1002. }
  1003. }
  1004. }
  1005. uasort($themes,'strnatcmp');
  1006. // Available Languages
  1007. $langs = expLang::langList();
  1008. // ksort($langs);
  1009. // smtp protocol
  1010. $protocol = array('ssl'=>'SSL','tls'=>'TLS');
  1011. // Currency Format
  1012. $currency = expSettings::dropdownData('currency');
  1013. // attribution
  1014. $attribution = array('firstlast'=>'John Doe','lastfirst'=>'Doe, John','first'=>'John','username'=>'jdoe');
  1015. // These funcs need to be moved up in to new subsystems
  1016. // Date/Time Format
  1017. $datetime_format = expSettings::dropdownData('datetime_format');
  1018. // Date Format
  1019. $date_format = expSettings::dropdownData('date_format');
  1020. // Time Format
  1021. $time_format = expSettings::dropdownData('time_format');
  1022. // Start of Week
  1023. $start_of_week = glist(expSettings::dropdownData('start_of_week'));
  1024. // File Permissions
  1025. $file_permisions = glist(expSettings::dropdownData('file_permissions'));
  1026. // File Permissions
  1027. $dir_permissions = glist(expSettings::dropdownData('dir_permissions'));
  1028. // Homepage Dropdown
  1029. $section_dropdown = navigationController::levelDropdownControlArray(0, 0, array(), false, 'view', true);
  1030. // Timezone Dropdown
  1031. $list = DateTimeZone::listAbbreviations();
  1032. $idents = DateTimeZone::listIdentifiers();
  1033. $data = $offset = $added = array();
  1034. foreach ($list as $abbr => $info) {
  1035. foreach ($info as $zone) {
  1036. if (!empty($zone['timezone_id']) AND !in_array($zone['timezone_id'],$added) AND in_array($zone['timezone_id'],$idents)) {
  1037. try{
  1038. $z = new DateTimeZone($zone['timezone_id']);
  1039. $c = new DateTime(null, $z);
  1040. $zone['time'] = $c->format('H:i a');
  1041. $data[] = $zone;
  1042. $offset[] = $z->getOffset($c);
  1043. $added[] = $zone['timezone_id'];
  1044. } catch(Exception $e) {
  1045. flash('error', $e->getMessage());
  1046. }
  1047. }
  1048. }
  1049. }
  1050. array_multisort($offset, SORT_ASC, $data);
  1051. $tzoptions = array();
  1052. foreach ($data as $row) {
  1053. $tzoptions[$row['timezone_id']] = self::formatOffset($row['offset'])
  1054. . ' ' . $row['timezone_id'];
  1055. }
  1056. $expcat = new expCat();
  1057. $cats = $expcat->find('all','module="file"');
  1058. $catarray = array();
  1059. $catarray[] = 'Root Folder';
  1060. foreach ($cats as $cat) {
  1061. $catarray[$cat->id] = $cat->title;
  1062. }
  1063. // profiles
  1064. $profiles = expSettings::profiles();
  1065. if (empty($profiles)) {
  1066. $profiles = array('' => '(default)');
  1067. }
  1068. assign_to_template(array(
  1069. 'as_types'=>$as_types,
  1070. 'as_themes'=>$as_themes,
  1071. 'themes'=>$themes,
  1072. 'langs'=>$langs,
  1073. 'protocol'=>$protocol,
  1074. 'currency'=>$currency,
  1075. 'attribution'=>$attribution,
  1076. 'datetime_format'=>$datetime_format,
  1077. 'date_format'=>$date_format,
  1078. 'time_format'=>$time_format,
  1079. 'start_of_week'=>$start_of_week,
  1080. 'timezones'=>$tzoptions,
  1081. 'file_permisions'=>$file_permisions,
  1082. 'dir_permissions'=>$dir_permissions,
  1083. 'section_dropdown'=>$section_dropdown,
  1084. 'folders'=>$catarray,
  1085. 'profiles'=>$profiles
  1086. ));
  1087. }
  1088. // now you can use $options;
  1089. private function formatOffset($offset) {
  1090. $hours = $offset / 3600;
  1091. $remainder = $offset % 3600;
  1092. $sign = $hours > 0 ? '+' : '-';
  1093. $hour = (int) abs($hours);
  1094. $minutes = (int) abs($remainder / 60);
  1095. if ($hour == 0 AND $minutes == 0) {
  1096. $sign = ' ';
  1097. }
  1098. return 'GMT' . $sign . str_pad($hour, 2, '0', STR_PAD_LEFT)
  1099. .':'. str_pad($minutes,2, '0');
  1100. }
  1101. public function update_siteconfig () {
  1102. foreach ($this->params['sc'] as $key => $value) {
  1103. // expSettings::change($key, addslashes($value));
  1104. expSettings::change($key, $value);
  1105. }
  1106. flash('message', gt("Your Website Configuration has been updated"));
  1107. // expHistory::back();
  1108. expHistory::returnTo('viewable');
  1109. }
  1110. public function change_profile() {
  1111. if (empty($this->params['profile'])) return;
  1112. expSession::un_set('display_theme');
  1113. expSession::un_set('theme_style');
  1114. expSession::un_set('framework');
  1115. expSettings::activateProfile($this->params['profile']);
  1116. expTheme::removeSmartyCache();
  1117. expSession::clearAllUsersSessionCache();
  1118. flash('message', gt("New Configuration Profile Loaded"));
  1119. redirect_to(array('controller'=>'administration', 'action'=>'configure_site'));
  1120. }
  1121. public function save_profile() {
  1122. if (empty($this->params['profile'])) return;
  1123. expSettings::createProfile($this->params['profile']);
  1124. flash('message', gt("Configuration Profile Saved"));
  1125. redirect_to(array('controller'=>'administration', 'action'=>'configure_site'));
  1126. }
  1127. /**
  1128. * Routine to force launching exponent installer
  1129. */
  1130. public static function install_exponent() {
  1131. // we'll need the not_configured file to exist for install routine to work
  1132. // if (!@file_exists(BASE.'install/not_configured')) {
  1133. // $nc_file = fopen(BASE.'install/not_configured', "w");
  1134. // fclose($nc_file);
  1135. // }
  1136. // $page = "";
  1137. // if (@file_exists(BASE.'framework/conf/config.php')) {
  1138. // $page = "?page=upgrade-1";
  1139. // }
  1140. header('Location: '.URL_FULL.'install/index.php');
  1141. exit('Redirecting to the Exponent Install Wizard');
  1142. }
  1143. }
  1144. /**
  1145. * This is the base theme class
  1146. *
  1147. * @subpackage Core-Controllers
  1148. * @package Modules
  1149. */
  1150. class theme {
  1151. public $user_configured = false;
  1152. public $stock_theme = false;
  1153. function name() { return "theme"; }
  1154. function author() { return ""; }
  1155. function description() { return gt("The theme shell"); }
  1156. /**
  1157. * Method to Configure theme settings
  1158. * This generic routine parses the theme's config.php file
  1159. * and presents the values as text boxes.
  1160. */
  1161. function configureTheme () {
  1162. if (isset($this->params['sv']) && $_GET['sv'] != '') {
  1163. if (strtolower($_GET['sv'])=='default') {
  1164. $_GET['sv']='';
  1165. }
  1166. $settings = expSettings::parseFile(BASE."themes/".$_GET['theme']."/config_".$_GET['sv'].".php");
  1167. } else {
  1168. $settings = expSettings::parseFile(BASE."themes/".$_GET['theme']."/config.php");
  1169. }
  1170. $form = new form();
  1171. $form->meta('controller','administration');
  1172. $form->meta('action','update_theme');
  1173. $f

Large files files are truncated, but you can click here to view the full file