function edit_actions($act, $log) { global $mos; global $nav_modules; if (!isset($_REQUEST['mod'])) { return; } if (!isset($_REQUEST['edit_text'])) { return; } if ($act == "editsave") { $s = $_REQUEST['edit_text']; if (get_magic_quotes_gpc()) { $s = stripslashes($s); } $s = str_replace("\r", '', $s); $mod = $_REQUEST['mod']; $m = array(); $m = parse_ini_file($mos . '/etc/pm/installed', true); $opts = $m[$mod]; if (loadModuleOptions($mod, $opts)) { $conf = "{$mos}/" . $opts['config_edit']; file_put_contents($conf, $s); if (($st = $opts['_status']) != 'disable') { if (isset($opts['config_after'])) { exec("{$mos}/etc/init/" . $opts['init'] . ' ' . $opts['config_after']); } if ($st != 'stop') { doAction($mod, 'restart', $log); } } } } }
function rss_services_actions_content() { global $mos; if (!isset($_REQUEST['mod'])) { return; } $mod = $_REQUEST['mod']; $page = 'xml_services'; if (isset($_REQUEST['ret'])) { $page = $_REQUEST['ret']; } $packs = parse_ini_file($mos . '/etc/pm/packages', true); $installed = parse_ini_file($mos . '/etc/pm/installed', true); $opts = $installed[$mod]; if (loadModuleOptions($mod, $opts) === false) { if (isset($packs[$mod])) { $opts = array('title' => $packs[$mod]['title'], '_actions' => array()); $irev = ''; } else { return; } } else { $irev = $opts['revision']; } if ($opts['role'] == 'core') { $opts['_actions'] = array(); } if (isset($packs[$mod])) { $arev = $packs[$mod]['revision']; if ($irev == '') { $opts['_actions'][] = 'install'; } elseif ($arev != $irev) { $opts['_actions'][] = 'update'; } } // -------------------------- // send RSS include 'rss_view_popup.php'; $view = new rssSkinPopupView(); $view->topTitle = $opts['title']; foreach ($opts['_actions'] as $act) { $view->items[] = array('title' => getMsg('coreCm_' . $act), 'action' => 'ret', 'link' => getMosUrl() . "?page={$page}&mod={$mod}&act={$act}"); } $view->items[] = array('title' => getMsg('coreCmCancel'), 'action' => 'ret', 'link' => ''); $view->showRss(); }
function doAction($mod, $act, $log = false) { global $mos; if ($mod == '') { return; } $m = array(); $m = parse_ini_file($mos . '/etc/pm/installed', true); $opts = $m[$mod]; if (loadModuleOptions($mod, $opts) !== false) { $st = $opts['_status']; $init = $mos . '/etc/init/' . $opts['init']; $haveInit = is_file($init); } else { $st = 'noinstall'; $init = ''; $haveInit = false; } if ($act == 'start') { if ($haveInit) { doCommand("{$init} start", $log); } } elseif ($act == 'stop') { if ($haveInit) { if ($st == 'start' or $st == 'enable') { doCommand("{$init} stop", $log); } } } elseif ($act == 'restart') { if ($haveInit) { doCommand("{$init} stop", $log); doCommand("{$init} start", $log); } } elseif ($act == 'enable') { if ($haveInit) { chmod($init, 0755); doCommand("{$init} enable", $log); } } elseif ($act == 'disable') { if ($haveInit) { if (is_executable("{$init}")) { if ($st != 'stop') { doCommand("{$init} stop", $log); } doCommand("{$init} disable", $log); chmod($init, 0644); } } } elseif ($act == 'delete') { if ($haveInit) { if (is_executable("{$init}")) { if ($st != 'stop') { doCommand("{$init} stop", $log); } } chmod($init, 0755); doCommand("{$init} disable", $log); } removeMod($mod, $log); getPagesMsgs(); } elseif ($act == 'install') { if (installMod($mod, $log)) { doAction($mod, 'enable', $log); doAction($mod, 'start', $log); getPagesMsgs(); } } elseif ($act == 'update') { // store status, activity if ($st != 'disable') { if (($s = $opts['config_before']) != '') { doCommand("{$init} {$s}", $log); } // stopping, disable module doAction($mod, 'disable', $log); } // store backup if (($bc = $opts['backup']) != '') { doCommand("tar -cf /tmp/backup_{$mod}.tar -C {$mos}/ {$bc}", $log); $bc = "backup_{$mod}.tar"; } // update package if (doCommand("{$mos}/bin/pm update {$mod}", $log) == 0) { // restore backup if ($bc != '') { doCommand("tar -xf /tmp/{$bc} -C {$mos}/", $log); doCommand("rm -Rf /tmp/{$bc}", $log); } } // restore status if ($st != 'disable') { doAction($mod, 'enable', $log); if ($st != 'stop') { doAction($mod, 'start', $log); } getPagesMsgs(); } else { if ($haveInit) { chmod($init, 0644); } } } else { if (strpos($opts['actions'], $act) !== false) { if ($haveInit) { if (is_executable("{$init}")) { doCommand("{$init} " . $act, $log); } } } } }
<?php $nav_installed = parse_ini_file($mos . '/etc/pm/installed', true); $nav_rss = array(); $d = opendir('modules'); while ($m = readdir($d)) { $w = "modules/{$m}"; if (is_dir($w)) { $f = "{$w}/def_rss.php"; if (file_exists($f)) { $opt = $nav_installed[$m]; if (loadModuleOptions($m, $opt) !== false) { if ($opt['_show']) { include $f; } } } } } ksort($nav_rss); // // ------------------------------------ function rss_menu_content() { class rssSkinMainMenuView extends rssSkinHTile { public $itemImage = ' <script> getStringArrayAt(imgArray, idx); </script> ';
function loadOptions() { global $mos; global $nav_modules; global $nav_installed; $nav_modules = array(); $nav_installed = array(); $nav_installed = parse_ini_file($mos . '/etc/pm/installed', true); foreach ($nav_installed as $mod => $item) { if (loadModuleOptions($mod, $item) !== false) { $nav_modules[$mod] = $item; } } ksort($nav_modules); }