function getLocalModuleList() { $fsmods = getmods_fs(); $dbmods = getmods_db(); foreach (array_keys($dbmods) as $moddir) { if (isset($fsmods[$moddir])) { $fsmods[$moddir]['position'] = $dbmods[$moddir]['position']; $fsmods[$moddir]['hidden'] = $dbmods[$moddir]['hidden']; } } # sorting function in the common.php module uasort($fsmods, 'bypos'); header('Content-Type: application/json'); echo json_encode(array_values($fsmods)); # , JSON_PRETTY_PRINT); # this only works in 5.4+ -- RACHEL-PLUS has 5.3.10 exit; }
echo "<li><a href=\"http://{$_SERVER['SERVER_ADDR']}:8090/\" target=\"_self\">LOCAL CONTENT</a></li>"; } ?> </ul> </div> <div id="content"> <?php $modcount = 0; $fsmods = getmods_fs(); # if there were any modules found in the filesystem if ($fsmods) { # get a list from the databases (where the sorting # and visibility is stored) $dbmods = getmods_db(); # populate the module list from the filesystem # with the visibility/sorting info from the database foreach (array_keys($dbmods) as $moddir) { if (isset($fsmods[$moddir])) { $fsmods[$moddir]['position'] = $dbmods[$moddir]['position']; $fsmods[$moddir]['hidden'] = $dbmods[$moddir]['hidden']; } } # custom sorting function in common.php uasort($fsmods, 'bypos'); # whether or not we were able to get anything # from the DB, we show what we found in the filesystem foreach (array_values($fsmods) as $mod) { if ($mod['hidden'] || !$mod['fragment']) { continue;
function syncmods_fs2db() { # get info on the modules in the filesystem $fsmods = getmods_fs(); # get info on the modules in the database $dbmods = getmods_db(); $db = getdb(); if ($db) { $db->exec("BEGIN"); # insert anything we found in the fs that wasn't in the db foreach (array_keys($fsmods) as $moddir) { if (!isset($dbmods[$moddir])) { $db_moddir = $db->escapeString($moddir); $db_title = $db->escapeString($fsmods[$moddir]['title']); $db_position = $db->escapeString($fsmods[$moddir]['position']); $db->exec("INSERT into modules (moddir, title, position, hidden) " . "VALUES ('{$db_moddir}', '{$db_title}', '{$db_position}', '0')"); #error_log("INSERT into modules (moddir, title, position, hidden) " . # "VALUES ('$db_moddir', '$db_title', '$db_position', '0')"); } } # delete anything from the db that wasn't in the fs foreach (array_keys($dbmods) as $moddir) { if (!isset($fsmods[$moddir])) { $db_moddir = $db->escapeString($moddir); $db->exec("DELETE FROM modules WHERE moddir = '{$db_moddir}'"); #error_log("DELETE FROM modules WHERE moddir = '$db_moddir'"); } } $db->exec("COMMIT"); } }