function demoExecuteNanoSite()
{
    global $indexTemplateAreas, $indexTemplateLL;
    $sett = getDetails('settings');
    $catt = getDetails('cats');
    $indexLastModified = filemtime(NANO_CMS_PAGE);
    if ($sett['index-last-modified'] >= $indexLastModified) {
        return;
    }
    $removeFunctionList = array('show_sidebar', 'show_content_slug', 'show_title', 'require_once');
    $replaceFunction = 'dummyFunction';
    $demoContentToRun = file_get_contents(NANO_CMS_PAGE);
    $demoContentToRun = str_replace('show_content_area', 'readIntoAreaList', $demoContentToRun);
    $demoContentToRun = str_replace('show_links', 'readIntoLinksList', $demoContentToRun);
    $demoContentToRun = str_replace($removeFunctionList, $replaceFunction, $demoContentToRun);
    ob_start();
    eval(" ?> " . $demoContentToRun . " <?php ");
    $cont = ob_get_contents();
    ob_end_clean();
    MsgBox(lt("Template Changes Detected! Config & Settings updated!", 'template-changes-detected'));
    $newcatt = array_diff($indexTemplateLL, array_keys($catt));
    foreach ($newcatt as $newcatname) {
        $catt[$newcatname] = array();
    }
    foreach ($indexTemplateAreas as $k => $v) {
        $indexTemplateAreas[$k] = strtolower($v);
    }
    $sett['index-last-modified'] = $indexLastModified;
    $sett['def-template-areas'] = array_unique($indexTemplateAreas);
    $sett['def-template-links'] = array_unique($indexTemplateLL);
    setDetails('settings', $sett);
    setDetails('cats', $catt);
    savepages();
}
Example #2
0
function showpageslist()
{
    global $nc;
    demoExecuteNanoSite();
    $cdt = getDetails('cats');
    $sett = getDetails('settings');
    $slugs = getDetails('slugs');
    $titles = getDetails('titles');
    $templateCats = $sett['def-template-links'];
    $defaultCats = explode(',', NANO_MUSTHAVE_CATS);
    $musthaveCats = array_unique(array_merge($templateCats, $defaultCats));
    $selectedCat = 1;
    $toggStat = 'false';
    if (isset($_GET[addcat])) {
        $newCatName = strtolower(stripslashes($_POST[catname]));
        if (in_array($newCatName, array_keys($cdt))) {
            $msg = sprintf(lt("Cannot add new Links Category : %s already exists", 'cat-add-fail-already-exists'), "<b>{$newCatName}</b>");
            MsgBox($msg);
        } else {
            $cdt[$newCatName] = array();
            $msg = sprintf(lt("Pages Category %s Added Successfully", 'cat-add-success'), "<b>{$newCatName}</b>");
            MsgBox($msg, 'greenbox');
            setDetails('cats', $cdt);
            savepages();
        }
    }
    if (isset($_GET[removecat])) {
        $catN = $_GET[removecat];
        if (!in_array($catN, array_keys($cdt))) {
            MsgBox(lt("Category to be deleted does not exist", 'cat-to-del-not-exists'), 'redbox');
        } else {
            if (in_array($catN, $musthaveCats)) {
                MsgBox("<b>{$catN}</b> : " . lt('Cannot be deleted'), 'redbox');
            } else {
                unset($cdt[$catN]);
                $msg = sprintf(lt("Pages Category %s was removed Successfully", 'cat-remove-success'), "<b>{$catN}</b>");
                MsgBox($msg, 'greenbox');
                setDetails('cats', $cdt);
                savepages();
            }
        }
    }
    if (isset($_GET[addtocat])) {
        $slug2add = $_POST[page];
        $cat2add = $_POST[cat];
        if (in_array($slug2add, $cdt[$cat2add])) {
            $msg = sprintf(lt("The page %s is already listed in %s", 'page-already-listed'), "<b>{$titles[$slug2add]}</b>", "<b>{$cat2add}</b>");
            MsgBox($msg);
        } else {
            array_push($cdt[$cat2add], $slug2add);
            $msg = sprintf(lt("The page %s was added successfully under %s", 'page-to-cat-add-success'), "<b>{$titles[$slug2add]}</b>", "<b>{$cat2add}</b>");
            MsgBox($msg);
            setDetails('cats', $cdt);
            savepages();
            $selectedCat = $cat2add;
            $toggStat = 'true';
        }
    }
    $catSelectList = array();
    foreach ($cdt as $cN => $cSC) {
        $catSelectList[$cN] = $cN;
    }
    $pagesAndOpt = lt('Pages & Category Options', 'page-and-cat-opt');
    $pagesListing = lt('Pages & Category Listing', 'page-and-cat-list');
    $addNewCat = lt('Add new Category');
    $addToAnotherCat = lt('Add page to another category', 'add-page-to-another-cat');
    $addLabel = lt('Add');
    $useUrlLabel = lt('Url you can use');
    $moveLabel = lt('Move');
    $optLabel = lt('Options');
    $pageLabel = lt('Page');
    echo "<a href='#nogo' class='nodeco'><h2 id='cat_anchor' class='cattitle'><span id='toggCon'></span>{$pagesAndOpt}</h2></a>\r\n\t\t\t<table id='cat_options'>\r\n\t\t\t <tr>\r\n\t\t\t \t<form action='?action=showpages&addcat=true' method='post'>\r\n\t\t\t\t<td>{$addNewCat} : </td><td><input type='text' name='catname'> <input type='submit' value='{$addLabel}'></td>\r\n\t\t\t\t</form>\r\n\t\t\t </tr>\r\n\t\t\t <tr>\r\n\t\t\t\t<form action='?action=showpages&addtocat=true' method='post'>\r\n\t\t\t\t<td>{$addToAnotherCat}</td><td>" . pagesList('page', $titles, 0) . " to " . pagesList('cat', $catSelectList, $selectedCat) . "\r\n\t\t\t\t\t <input type='submit' value='{$addLabel}'>\r\n\t\t\t\t</td>\r\n\t\t\t\t</form>\r\n\t\t\t </tr>\r\n\t\t\t</table>";
    $js = "catopt = new Toggle('cat_options',{$toggStat},'cat_anchor');catopt.setToggleContent( 'toggCon', '+', '-' );";
    $v = 0;
    echo "<h2>&raquo; {$pagesListing}</h2>";
    echo "<div class='linkcats-div'>";
    foreach ($cdt as $catname => $catslugs) {
        $v++;
        $slugids = array_values($catslugs);
        $n = count($slugids) - 1;
        if (!in_array($catname, $musthaveCats)) {
            $removeOpt = "( <a href='?action=showpages&removecat={$catname}'>remove</a> )";
        } else {
            $removeOpt = '';
        }
        //just user interface stuff
        $toggStat = $catname == $_SESSION[opencat] ? 'true' : 'false';
        if (!isset($_SESSION[opencat]) and $catname == 'sidebar') {
            $toggStat = true;
        }
        if ($catname == $_SESSION[opencat]) {
            $toggStat = 'true';
            unset($_SESSION[opencat]);
        } else {
            $toggStat == 'false';
        }
        $js .= "catopt{$v} = new Toggle('t{$v}',{$toggStat},'h2{$v}'); catopt{$v}.setToggleContent( 'co{$v}', '+', '-' );";
        echo "<a href='#nogo'><h2 class='cattitle noborder' id='h2{$v}'><span id='co{$v}' class='togg'>&raquo;</span> {$catname} {$removeOpt}</h2></a>";
        echo "<div class='borderWrap'>";
        echo "<table cellpadding='5px' cellspacing='2px'  width='100%' id='t{$v}' class='pageListTable'>";
        echo "<tr class='th'><th>{$pageLabel}</th><th>{$optLabel}</th><th colspan=2>{$moveLabel}</th><th>{$useUrlLabel}</th></tr>";
        if (count($slugids) == 0) {
            echo "<tr><td colspan='10' class='center'>" . lt('No pages are added under this category', 'no-pages-added') . "</td></tr></table>";
            continue;
        }
        foreach ($slugids as $pos => $ids) {
            $delTxt = lt('Delete');
            $editTxt = lt('Edit');
            $upTxt = lt('Up');
            $downTxt = lt('Down');
            $ul = makeLink("?action=reorder&cat={$catname}&param=" . $pos . ',' . ($pos - 1), '<img src="stuff/icons/arrow_up.png" alt="up" title="Move up"/>');
            $dl = makeLink("?action=reorder&cat={$catname}&param=" . $pos . ',' . ($pos + 1), '<img src="stuff/icons/arrow_down.png" alt="down" title="Move Down" />');
            if ($pos == 0) {
                $ul = '<img src="stuff/icons/arrow_up_d.png" alt="$upTxt" />';
            }
            if ($pos == $n) {
                $dl = '<img src="stuff/icons/arrow_down_d.png" alt="$downTxt" />';
            }
            $deleteConfirmMsg = lt("Are you sure you want to delete this page!! Remember Once you delete you cannot retreive again!! Proceed???", 'page-delete-confirm-msg');
            $s = "<tr>\r\n\t\t\t\t\t<td><b>" . $titles[$ids] . "</b></td>\r\n\t\t\t\t\t<td class='center'>\r\n\t\t\t\t\t\t<a href='?action=edit&slug=" . $slugs[$ids] . "'><img src='stuff/icons/page_edit.png' alt='{$editTxt}' title='{$editTxt}' /></a> |\r\n\t\t\t\t\t\t<a href='?action=delete&slug=" . $slugs[$ids] . "' onclick='return confirm(\"{$deleteConfirmMsg}\");'><img src='stuff/icons/cross.png' alt='{$delTxt}' title='{$delTxt}' /></a>\r\n\t\t\t\t\t</td>\r\n\t\t\t\t\t<td>{$ul}</td>\r\n\t\t\t\t\t<td>{$dl}</td>\r\n\t\t\t\t\t<td>" . makeLink((NANO_SEFURL ? '../' : '') . slugUrl($slugs[$ids]), slugUrl($slugs[$ids])) . "</td>\r\n\t\t\t\t  </tr>";
            echo $s;
        }
        echo "</table>";
        echo "</div>";
    }
    echo "</div>";
    echo "\t<script language='javascript'>\r\n\t\t\t\t{$js}\r\n\t\t\t</script>";
}
Example #3
0
function webpagesDispatch($op)
{
    if (isset($_POST['undo'])) {
        $op = 'webpages';
    }
    switch ($op) {
        case "webpages":
            webpages();
            break;
        case "addpages":
            editpages();
            break;
        case "savepages":
            savepages();
            break;
        case "publish":
            publish($_GET['id_page'], true);
            break;
        case "unpublish":
            publish($_GET['id_page'], false);
            break;
        case "movedown":
            movepages('down');
            break;
        case "moveup":
            movepages('up');
            break;
        case "modpages":
            editpages(true);
            break;
        case "delpages":
            delpages();
            break;
    }
}
Example #4
0
function doDelete()
{
    global $WebPagesList;
    if (isset($_GET[action]) and $_GET[action] == 'delete') {
        $slug = $_GET[slug];
        foreach ($WebPagesList as $k => $pg) {
            //if( !inSidebar( $pg ) ) continue;
            if (getSlug($pg) == $slug) {
                if ($k == 0) {
                    echo "cannot delete the Top page";
                    return;
                }
                // how can we possibly move the topmost one up :)
                unset($WebPagesList[$k]);
                unlink(sitedir(getSlug($pg)));
                $WebPagesList = msort($WebPagesList);
                savepages();
                echo 'success fully deleted';
                break;
            }
        }
    }
}
Example #5
0
function doDelete()
{
    global $WebPagesList;
    if (isset($_GET[action]) and $_GET[action] == 'delete') {
        $slug = $_GET[slug];
        foreach ($WebPagesList as $k => $pg) {
            if (getSlug($pg) == $slug) {
                if ($k == 0) {
                    echo "cannot delete the Top page";
                    return;
                }
                // we cannot delete the topmost one as it is the homepage
                unset($WebPagesList[$k]);
                unlink(pageDataDir(getSlug($pg)));
                $WebPagesList = msort($WebPagesList);
                savepages();
                echo 'success fully deleted';
                break;
            }
        }
    }
}
function nanoadmin_showsettings()
{
    $home = getDetails('homepage');
    $pages = getDetails('titles');
    $slugs = getDetails('slugs');
    $username = getDetails('username');
    $seourl_stat = (bool) getDetails('seourl');
    $seourl = array(lt('Disabled'), lt('Enabled'));
    $is_modrewrite_available = true;
    if (isset($_POST['save'])) {
        runTweak('save-settings');
        $_POST = array_map('stripslashes', $_POST);
        $home = $_POST['homepage'];
        $seourl_stat = $_POST['seourls'];
        $seourl_stat = $is_modrewrite_available ? $seourl_stat : 0;
        if ($seourl_stat == 1) {
            file_put_contents(NANO_INDEX_LOCATION . '.htaccess', NANO_HTACCESS_FORMAT);
        } else {
            unlink(NANO_INDEX_LOCATION . '.htaccess');
        }
        $username = $_POST['username'];
        $password = $_POST['password'];
        setDetails('homepage', $home);
        setDetails('seourl', $seourl_stat);
        if (!empty($username)) {
            setDetails('username', $username);
        }
        if (!empty($password)) {
            setDetails('password', md5($password));
            //reset the logged session variable
            $_SESSION[NANO_CMS_ADMIN_LOGGED] = md5(md5($password) . $_SESSION[LOGIN_TIME_STAMP]);
        }
        if (savepages()) {
            MsgBox(lt('Settings were saved successfully'), 'greenbox');
        }
    }
    $word_homepage = lt('Home Page');
    $word_sefurl = lt('Search Engine Friendly URL\'s');
    $word_new = lt('New');
    $word_username = lt('Username');
    $word_password = lt('Password');
    $word_leaveitemtpy = lt("Leave empty if you don't want to change", 'leave-empty-for-no-change');
    $word_loginsettings = lt("Login Settings");
    $word_save = lt("Save Changes");
    $word_settings = lt("NanoCMS Settings");
    if ($is_modrewrite_available) {
        $select_seourl = html_select('seourls', $seourl, $seourl_stat);
        $word_modrewrite = lt("mod_rewrite is required and is available");
    } else {
        $select_seourl = html_select('seourls', $seourl, $seourl_stat, ' disabled="disabled"');
        $word_modrewrite = lt("mod_rewrite is <b>not available</b>, please contact your host or enable it via httpd.conf", 'modrewrite-not-available');
    }
    $select_homepage = html_select('homepage', $pages, $home);
    echo $output = <<<NANO_SETTINGS
\t<h2>{$word_settings}</h2>
\t<form action="#" method="POST" accept-charset="utf-8">
\t\t<table width="100%" cellpadding="5">
\t\t\t<tr>
\t\t\t\t<td>{$word_homepage}</td><td>{$select_homepage}</td>
\t\t\t</tr>
\t\t\t<tr>
\t\t\t\t<td>{$word_sefurl} <br /><small>[ {$word_modrewrite} ]</small></td><td>{$select_seourl}</td>
\t\t\t</tr>
\t\t\t<tr><td>&nbsp;</td></tr>
\t\t\t<tr>
\t\t\t\t<td colspan="2"><h2>{$word_loginsettings}</h2></td>
\t\t\t</tr>
\t\t\t<tr>
\t\t\t\t<td colspan="2">{$word_leaveitemtpy}</td>
\t\t\t</tr>
\t\t\t<tr>
\t\t\t\t<td>{$word_new} {$word_username}</td><td><input type="text" value="{$username}" name="username" /></td>
\t\t\t</tr>
\t\t\t<tr>
\t\t\t\t<td>{$word_new} {$word_password}</td><td><input type="text" name="password" value="" /></td>
\t\t\t</tr>
\t\t\t<tr>
\t\t\t\t<td><br /><input type="submit" value="{$word_save}" name="save" /></td>
\t\t\t</tr>
NANO_SETTINGS;
    runTweak('admin-settings');
    echo "\r\n\t\t</table>\r\n\t</form>";
}