function MotpList() { $this->app->Tpl->Set(UEBERSCHRIFT, "mOTP Generator"); $submit = $this->app->Secure->GetPOST("submit"); if ($submit != "") { $pin = $this->app->Secure->GetPOST("pin"); $secret = $this->app->Secure->GetPOST("secret"); $this->app->Tpl->Set(MESSAGE, '<div class="ui-state-highlight ui-corner-all" style="padding: 0 .7em;"> <p><span class="ui-icon ui-icon-info" style="float: left; margin-right: .3em;"></span> <strong>Hinweis:</strong>Die neue PIN und das neue Secret wurden gespeichert!</p> </div>'); $tmp = new INI(); $arr = $tmp->read("/opt/fred/apps/motp/motp.ini"); $arr[motp][secret] = $secret; $arr[motp][pin] = $pin; $tmp->write("/opt/fred/apps/motp/motp.ini", $arr); // exec("echo '$pin' > /root/otppin"); // exec("echo '$secret' > /root/otpsecret"); } $tmp = new INI(); $arr = $tmp->read("/opt/fred/apps/motp/motp.ini"); //$pin = shell_exec("cat /root/otppin"); $this->app->Tpl->Set(PIN, $arr[motp][pin]); //$secret = shell_exec("cat /root/otpsecret"); $this->app->Tpl->Set(SECRET, $arr[motp][secret]); date_default_timezone_set('UTC'); $uhrzeit = date('d.m.Y H:i:s'); $this->app->Tpl->Set(UHRZEIT, $uhrzeit); $this->app->Tpl->Parse(UEBERSCHRIFT, "mOTP"); $this->app->Tpl->Parse(PAGE, "motp.tpl"); }
function setPackagesInactive() { global $db; require_once '../classes/class.ini.php'; $myini = new INI(); $result = $db->query("SELECT id, internal FROM {$db->pre}packages"); $data = array(); $disable = array(); $dependencies = array(); $assoc = array(); while ($row = $db->fetch_assoc($result)) { $ini = $myini->read("../modules/{$row['id']}/package.ini"); if (!isset($ini['dependency']) || !is_array($ini['dependency'])) { $ini['dependency'] = array(); } $min_compatible = !empty($ini['min_version']) && version_compare(VISCACHA_VERSION, $ini['min_version'], '>=') || empty($ini['min_version']); $max_compatible = !empty($ini['max_version']) && version_compare(VISCACHA_VERSION, $ini['max_version'], '<=') || empty($ini['max_version']); $data[$row['id']] = array('min_version' => !empty($ini['min_version']) ? $ini['min_version'] : '', 'max_version' => !empty($ini['max_version']) ? $ini['max_version'] : '', 'id' => $row['id'], 'internal' => $row['internal'], 'dependency' => isset($ini['dependency']) && is_array($ini['dependency']) ? $ini['dependency'] : array(), 'compatible' => $min_compatible && $max_compatible); if ($data[$row['id']]['compatible'] == false) { $disable[$row['id']] = $row['internal']; } $dependencies = array_merge($dependencies, $ini['dependency']); if (isset($assoc[$row['internal']])) { $assoc[$row['internal']][] = $row['id']; } else { $assoc[$row['internal']] = array($row['id']); } } $n = 0; while (count($dependencies) > 0) { reset($dependencies); $value = current($dependencies); $key = key($dependencies); if (isset($assoc[$value])) { foreach ($assoc[$value] as $id) { if (isset($data[$id]['dependency']) && is_array($data[$id]['dependency'])) { foreach ($data[$id]['dependency'] as $int) { if (!in_array($int, $disable) && !in_array($int, $dependencies)) { $dependencies[] = $int; } } } if (!isset($disable[$id])) { $disable[$id] = $value; } } } unset($dependencies[$key]); $n++; if ($n > 10000) { trigger_error("setPackagesInactive(): Your database is inconsistent - Please ask the Viscacha support for help.", E_USER_ERROR); // Break loop, Database seems to be inconsistent (or thousands of packages are installed) } } if (count($disable) > 0) { $in = implode(',', array_keys($disable)); $db->query("UPDATE {$db->pre}packages SET active = '0' WHERE id IN ({$in})"); } }
echo head(); $result = $db->query("\n\t\tSELECT c.id, c.package, p.title\n\t\tFROM {$db->pre}component AS c\n\t\t\tLEFT JOIN {$db->pre}packages AS p ON c.package = p.id\n\t\tWHERE p.active = '1' AND c.active = '1'\n\t"); ?> <table class="border" border="0" cellspacing="0" cellpadding="4" align="center"> <tr> <td class="obox"><?php echo $lang->phrase('admin_cms_existing_documents'); ?> </td> </tr> <tr> <td class="mbox"> <?php while ($row = $db->fetch_assoc($result)) { $head = array(); $ini = $myini->read('modules/' . $row['package'] . '/component.ini'); ?> <input type="radio" name="data" onclick="insert_doc('components.php?cid=<?php echo $row['id']; ?> ','<?php echo htmlentities($ini['info']['title']); ?> ')"> <?php echo $ini['info']['title']; ?> (Package: <?php echo $row['title']; ?> )<br /> <?php
</td> <td class="mbox center"><?php echo noki($row['core']); ?> </td> <td class="mbox"> <a class="button" href="admin.php?action=packages&job=package_info&id=<?php echo $row['id']; ?> "><?php echo $lang->phrase('admin_packages_package_details'); ?> </a> <?php if (file_exists("modules/{$row['id']}/component.ini")) { $com = $myini->read("modules/{$row['id']}/component.ini"); if (!empty($com['admin']['frontpage']) == true) { ?> <a class="button" href="admin.php?action=packages&job=package_admin&cid=<?php echo $row['id']; ?> "><?php echo $lang->phrase('admin_packages_administration'); ?> </a> <?php } } if ($row['config'] > 0) { ?> <a class="button" href="admin.php?action=settings&job=custom&id=<?php
ok('admin.php?action=settings&job=custom&id=' . $id . '&package=' . $package); } elseif ($job == 'delete') { echo head(); $name = $gpc->get('name', str); $id = $gpc->get('id', int); $package = $gpc->get('package', int); $db->query("DELETE FROM {$db->pre}settings WHERE name = '{$name}' AND sgroup = '{$id}' LIMIT 1"); $upd = $db->affected_rows(); if ($upd == 1) { $result = $db->query("SELECT name FROM {$db->pre}settings_groups WHERE id = '{$id}'"); $row = $db->fetch_assoc($result); $c->getdata(); $c->delete(array($row['name'], $name)); $c->savedata(); if ($package > 0) { $ini = $myini->read("modules/{$package}/package.ini"); unset($ini['setting_' . $name]); $myini->write("modules/{$package}/package.ini", $ini); } ok('admin.php?action=settings&job=custom&id=' . $id . '&package=' . $package, $lang->phrase('admin_setting_deleted')); } else { error('admin.php?action=settings&job=custom&id=' . $id . '&package=' . $package, $lang->phrase('admin_setting_not_available')); } } elseif ($job == 'delete_group') { echo head(); $id = $gpc->get('id', int); $package = $gpc->get('package', int); $result = $db->query("\n\tSELECT s.name, g.name AS groupname\n\tFROM {$db->pre}settings AS s\n\t\tLEFT JOIN {$db->pre}settings_groups AS g ON s.sgroup = g.id\n\tWHERE s.sgroup = '{$id}'"); if ($package > 0) { $ini = $myini->read("modules/{$package}/package.ini"); }
$i = 0; while (false !== ($entry = $d->read())) { if (@getimagesize($tempdir . $entry) != false) { $i++; $package[] = array('search' => ':smiley' . $i . ':', 'replace' => '{folder}/' . $entry, 'desc' => ''); } } $d->close(); break; default: // viscacha_ini if (!file_exists($tempdir . '/smileys.ini')) { error('admin.php?action=bbcodes&job=smileys_import', $lang->phrase('admin_bbc_smileys_ini_missing')); } $myini = new INI(); $package = $myini->read($tempdir . '/smileys.ini'); break; } // Delete old smileys $codes = array(); if ($truncate == 1) { $result = $db->query('SELECT * FROM ' . $db->pre . 'smileys'); while ($row = $db->fetch_assoc($result)) { $row['replace'] = str_replace('{folder}', $config['smileypath'], $row['replace']); if (file_exists($row['replace'])) { $filesystem->unlink($row['replace']); } } $db->query('TRUNCATE TABLE ' . $db->pre . 'smileys'); } else { // Get existing smiley codes from database
require_once 'classes/class.zip.php'; $archive = new PclZip($file); $failure = $archive->extract($tempdir); if ($failure < 1) { rmdirr($tempdir); unset($archive); if ($del > 0) { $filesystem->unlink($file); } error('admin.php?action=designs&job=design_import', $lang->phrase('admin_design_zip_archive_error')); } else { if (!file_exists($tempdir . 'design.ini')) { error('admin.php?action=designs&job=design_import', $lang->phrase('admin_design_zip_archive_missing_design_ini')); } $myini = new INI(); $ini = $myini->read($tempdir . 'design.ini'); $result = $db->query("SELECT * FROM `{$db->pre}designs` WHERE id = '{$config['templatedir']}' LIMIT 1"); $row = $db->fetch_assoc($result); if (!empty($ini['template'])) { $tplid = 1; while (is_dir('templates/' . $tplid)) { $tplid++; if ($tplid > 10000) { error('admin.php?action=designs&job=design_import', $lang->phrase('admin_design_buffer_overflow_templates')); } } $tpldir = 'templates/' . $tplid; } else { $tplid = $row['template']; } if (!empty($ini['stylesheet'])) {
if (count($inserterrors) > 0) { error('admin.php?action=designs&job=package_update', $inserterrors); } else { $c = new manageconfig(); $tdir = "temp/" . md5(microtime()) . '/'; $filesystem->mkdir($tdir, 0777); if (!is_dir($tdir)) { error('admin.php?action=packages&job=package_update', $lang->phrase('admin_packages_err_temporary_directory_could_not_be_created')); } include 'classes/class.zip.php'; $archive = new PclZip($sourcefile); if ($archive->extract(PCLZIP_OPT_PATH, $tdir) == 0) { error('admin.php?action=packages&job=package_update', $archive->errorInfo(true)); } if (file_exists($tdir . 'modules/package.ini')) { $package = $myini->read($tdir . 'modules/package.ini'); if ($versioncheck != 1) { if (!empty($package['info']['min_version']) && version_compare($config['version'], $package['info']['min_version'], '<')) { error('admin.php?action=packages&job=package_update', $lang->phrase('admin_packages_err_required_min_version')); } if (!empty($package['info']['max_version']) && version_compare($config['version'], $package['info']['max_version'], '>')) { error('admin.php?action=packages&job=package_update', $lang->phrase('admin_packages_err_required_max_version')); } } $package = $gpc->save_str($package); if (!isset($package['core'])) { $package['info']['core'] = 0; } } else { error('admin.php?action=packages&job=package_update', $lang->phrase('admin_packages_err_package_ini_does_not_exist')); }
function _build_code($pos) { global $db, $filesystem; $group = $this->_group($pos); $file = 'cache/modules/' . $group . '.php'; if ($this->sqlcache == null) { $this->sqlcache = array(); $this->sqlcache[$group] = array(); $result = $db->query("\n\t \tSELECT m.id, m.module, m.position\n\t \tFROM {$db->pre}plugins AS m\n\t \t\tLEFT JOIN {$db->pre}packages AS p ON m.module = p.id\n\t \tWHERE p.active = '1' AND m.active = '1'\n\t \tORDER BY m.ordering\n\t ", __LINE__, __FILE__); while ($row = $db->fetch_assoc($result)) { $row['group'] = $this->_group($row['position']); $this->sqlcache[$row['group']][$row['position']][$row['id']] = $row['module']; } } if (!isset($this->sqlcache[$group])) { $this->sqlcache[$group] = array(); } $myini = new INI(); $cfgdata = array(); $code = array(); foreach ($this->sqlcache[$group] as $position => $mods) { $code[$position] = ''; foreach ($mods as $id => $plugin) { if (!isset($cfgdata[$plugin])) { $inifile = $this->plugdir . $plugin . '/plugin.ini'; $cfgdata[$plugin] = $myini->read($inifile); } if (isset($cfgdata[$plugin]['php'])) { foreach ($cfgdata[$plugin]['php'] as $phpposition => $phpfile) { if ($position == $phpposition) { $sourcefile = $this->plugdir . $plugin . '/' . $phpfile; if (file_exists($sourcefile)) { $source = file_get_contents($sourcefile); if (!isset($code[$position][$id])) { $code[$position][$id] = ''; } $code[$position][$id] .= '$pluginid = "' . $plugin . '";' . "\r\n" . $source . "\r\n"; } } } } } } $save = serialize($code); $filesystem->file_put_contents($file, $save); return $code; }
error_reporting(E_ALL); define('SCRIPTNAME', 'components'); define('VISCACHA_CORE', '1'); include "data/config.inc.php"; include "classes/function.viscacha_frontend.php"; $my->p = $slog->Permissions(); $cid = $gpc->get('cid', int); $com = $scache->load('components'); $cache = $com->get(); ($code = $plugins->load('components_start')) ? eval($code) : null; if (isset($cache[$cid])) { DEFINE('COM_CID', $cid); DEFINE('COM_ID', $cache[$cid]['package']); DEFINE('COM_DIR', 'modules/' . COM_ID . '/'); $myini = new INI(); $ini = $myini->read(COM_DIR . 'component.ini'); $mod = $gpc->get('file', str, 'frontpage'); if (!isset($ini['module'][$mod])) { DEFINE('COM_MODULE', 'frontpage'); } else { DEFINE('COM_MODULE', $mod); } DEFINE('COM_MODULE_FILE', $ini['module'][COM_MODULE]); DEFINE('COM_FILE', $ini['module']['frontpage']); if (!file_exists(COM_DIR . COM_FILE)) { error($lang->phrase('section_not_available')); } else { define('COM_LANG_OLD_DIR', $lang->getdir(true)); $lang->setdir(COM_LANG_OLD_DIR . DIRECTORY_SEPARATOR . COM_DIR); ($code = $plugins->load('components_prepared')) ? eval($code) : null; if (COM_MODULE == 'frontpage') {
static function convert($iniPath, $extension) { ob_start(); $privNS = "https://github.com/AKSW/{$extension}/raw/master/doap.n3#"; //!!!!REMOVE THIS LINE AFTER YOU HAVE REVIEWED/FIXED THIS FILE!!!! echo <<<EOT @prefix xsd: <http://www.w3.org/2001/XMLSchema#>. @prefix doap: <http://usefulinc.com/ns/doap#> . @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . @prefix owconfig: <http://ns.ontowiki.net/SysOnt/ExtensionConfig/> . @prefix extension: <http://ns.ontowiki.net/Extensions/> . @prefix foaf: <http://xmlns.com/foaf/0.1/> . @prefix event: <http://ns.ontowiki.net/SysOnt/Events/> . @prefix : <{$privNS}> . EOT; require_once __DIR__ . '/../../libraries/Zend/Config.php'; require_once __DIR__ . '/../../libraries/Zend/Config/Ini.php'; $config = INI::read($iniPath); //var_dump($config); if (!isset($config['default'])) { $config['default'] = array(); } foreach ($config as $sectionname => $sectionconf) { if (!in_array($sectionname, array('default', 'events', 'private'))) { $config['default'][$sectionname] = $sectionconf; unset($config[$sectionname]); } } //var_dump($config); exit; $subject = ':' . $extension; $es = new ExtensionSerializer(); $es->printStatement('<>', 'foaf:primaryTopic', $subject); $es->printStatement($subject, 'a', 'doap:Project'); $es->printStatement($subject, 'doap:name', '"' . $extension . '"'); $es->printStatement($subject, 'owconfig:privateNamespace', '<' . $privNS . '>'); $mp = new NestedPropertyAndModuleHandler($es, $subject); foreach ($config as $sectionname => $sectionconf) { if ($sectionname == 'private') { $mp->properties = $sectionconf; continue; } if (is_array($sectionconf)) { foreach ($sectionconf as $property => $value) { if ($property == 'modules') { $mp->modules = array_merge_recursive($mp->modules, $value); continue; } else { if ($property == 'priority' || $property == 'contexts' || $property == 'caching' || $property == 'title') { $mp->modules = array_merge_recursive($mp->modules, array('default' => array($property => $value))); } else { if ($sectionname == 'default' && $property == 'helperEvents') { $predicate = 'owconfig:helperEvent'; if (is_array($value)) { foreach ($value as $v) { $object = 'event:' . $v; $es->printStatement($subject, $predicate, $object); } } else { $object = 'event:' . $value; $es->printStatement($subject, $predicate, $object); } } else { if ($sectionname == 'events') { $predicate = 'owconfig:pluginEvent'; if (is_array($value)) { foreach ($value as $v) { $object = 'event:' . $v; $es->printStatement($subject, $predicate, $object); } } else { $object = 'event:' . $value; $es->printStatement($subject, $predicate, $object); } } else { //this is not in global section and not in events $predicate = $es->getPredicate($property, $sectionname); if (is_array($value)) { //should never happen } else { $object = $es->getObject($property, $value); $es->printStatement($subject, $predicate, $object); } } } } } } } else { //parsing a property that has no section -> global section (the first lines until the first section) $property = $sectionname; $value = $sectionconf; $predicate = $es->getPredicate($property, $sectionname); $object = $es->getObject($property, $value); $es->printStatement($subject, $predicate, $object); } } $mp->printN3(); $version = ':v1-0'; $es->printStatement($subject, 'doap:release', $version); $es->printStatement($version, 'a', 'doap:Version'); $es->printStatement($version, 'doap:revision', '"1.0"'); //make sure the destructors are called $es = null; $mp = null; $res = ob_get_clean(); //some wtf fixes :) $res = str_replace(";;", ";", $res); $res = str_replace("[;", "[", $res); $res = str_replace("; ;", ";", $res); $res = str_replace("[ ;", "[", $res); $res = preg_replace("/\\]\\s*\\.?\n\\s*_:[0-9]*/", "];\n", $res); $res = preg_replace("/.\n\\s*_:[0-9]*/", ";\n", $res); return $res; }
<?php require_once 'php/ini.php'; $ini = INI::read('config.ini'); $stat = 0; if (@$_POST && $_POST['isIni']) { foreach ($_POST as $key => $value) { $pos = strpos($key, '|'); $key1 = substr($key, 0, $pos); $key2 = substr($key, $pos + 1); if (strlen($key1)) { $ini[$key1][$key2] = $value; } } is_writeable('config.ini') ? $stat = 1 : ($stat = -1); INI::write('config.ini', $ini); } echo "<form method='post' id='frm_settings'>\n"; echo "<input type=\"hidden\" name=\"isIni\" value=\"1\">"; echo "<table>\n"; foreach ($ini as $key => $value) { echo "<tr align=\"left\">\n"; echo "<td colspan=\"2\"><span id=\"{$key}\"><b>{$key}</b><span></td>\n"; echo "</tr>\n"; foreach ($value as $subkey => $subvalue) { echo "<tr align=\"left\">\n"; $ln = strlen($subvalue) + 5; echo "<td>{$subkey}:</td><td><input name=\"{$key}|{$subkey}\" id=\"{$key}|{$subkey}\" value=\"{$subvalue}\" size=\"" . ($ln < 60 ? $ln : 60) . "\"><br></td>\n"; echo "</tr>\n"; } }