Example #1
0
        foreach ($state_fields as $k => $discard) {
            if ($k === 'body') {
                $modified_state[$k] = $post->rawBody();
            } else {
                $v = $post->{$k};
                if ($v instanceof GBDateTime) {
                    $v = strval($v);
                }
                $modified_state[$k] = $v;
            }
        }
    }
    # commit?
    if ($input['commit']) {
        git::add($post->name);
        git::commit(($created ? 'Created' : 'Updated') . ' post ' . r($post->title), gb::$authorized, $post->name);
    }
    # build response entity
    $rsp = array('name' => $post->name, 'version' => $post->id, 'exists' => $post->exists(), 'isTracked' => $post->isTracked(), 'isDirty' => $post->isDirty(), 'state' => $modified_state);
    # status
    $status = '200 OK';
    if ($created) {
        $status = '201 Created';
    }
    # send JSON response
    gb_admin::json_rsp($rsp, $status);
    gb::log('saved post %s', $post->name);
} catch (Exception $e) {
    gb::log('failed to save post: %s', GBException::format($e, true, false, null, 0));
    gb_admin::json_rsp($e->getMessage(), '400 Bad Request');
}
Example #2
0
					title="Hide this message"><span>X</span></a>
				<div class="icon"></div>
				<ul>
					<li class="title">
						<?php 
echo count(gb::$errors) === 1 ? 'An error occured' : counted(count(gb::$errors), '', 'errors occured');
?>
					</li>
				<?php 
foreach (gb::$errors as $error) {
    ?>
					<li><?php 
    echo h($error);
    ?>
</li>
				<?php 
}
?>
				</ul>
			</div>
		</div>
		<div id="menu" <?php 
if ($integrity == 2) {
    echo 'class="disabled"';
}
?>
>
			<?php 
echo gb_admin::render_menu($integrity == 2);
?>
		</div>
Example #3
0
 function render_menu($menu_disabled = false, $items = null, $baseurl = null, $currurlpath = null, $liststart = '<ul>', $listend = '</ul>')
 {
     if ($items === null) {
         $items = self::$menu;
     }
     if ($baseurl === null) {
         $baseurl = gb_admin::$url;
     }
     if ($currurlpath === null) {
         $currurlpath = gb::url()->path;
     }
     $accesskey_prefix = '';
     $is_osx = isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'], 'Mac OS X') !== false;
     if (isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'], 'Safari') !== false) {
         if ($is_osx) {
             $accesskey_prefix = '&#x2303;&#x2325;';
         }
     }
     $s = $liststart;
     foreach ($items as $k => $item) {
         $uri = $url = '';
         $is_curr = $is_todo = false;
         $accesskey = is_string($k) ? strtoupper($k) : '';
         if (isset($item[1]) && is_string($item[1])) {
             $uri = $item[1];
             $url = $uri && ($uri[0] === '/' || strpos($uri, '://') !== false) ? $uri : $baseurl . $uri;
             $url_st = GBURL::parse($url);
             $actual_currpath = $url_st->path;
             $is_todo = strpos($url_st->fragment, 'todo:') === 0;
             $is_curr = !$is_todo && $actual_currpath === substr($currurlpath, 0, strlen($actual_currpath));
             if ($uri === '') {
                 $is_curr = gb::url()->path === GBURL::parse(gb_admin::$url)->path;
             }
         }
         $dom_id = $uri ? gb_strtodomid(gb_filenoext($item[1])) : $k;
         $s .= '<li id="menu-item-' . $dom_id . '"';
         $css_class = '';
         if ($is_curr) {
             $css_class .= 'selected';
             self::$current_domid = $dom_id;
         }
         if ($is_todo) {
             $css_class .= ' todo';
         }
         if ($css_class) {
             $s .= ' class="' . $css_class . '"';
         }
         $s .= '><a';
         if ($url && !$is_todo && !$menu_disabled) {
             $s .= ' href="' . h($url) . '"';
         }
         if ($accesskey && !$menu_disabled) {
             $s .= ' accesskey="' . $accesskey . '"';
         }
         $s .= '><span class="title">' . h($item[0]) . '</span>';
         if ($accesskey && !$menu_disabled) {
             $s .= '<span class="accesskey-hint">' . $accesskey_prefix . $accesskey . '</span>';
         }
         $s .= '</a>';
         if (isset($item[2]) && $item[2]) {
             $s .= self::render_menu($menu_disabled, $item[2], $baseurl, $currurlpath, $liststart, $listend);
         }
         $s .= '</li>';
     }
     $s .= $listend;
     return $s;
 }
Example #4
0
 function writeExposedContent(GBExposedContent $obj)
 {
     gb_admin::write_content($obj);
     git::add($obj->name);
     if ($this->includeComments) {
         $this->writeComments($obj);
     }
     return true;
 }
Example #5
0
    if (!empty($action) && !empty($tbl) && !empty($id)) {
        $adminVariables = htmlspecialchars('?action=' . $action . '&tbl=' . $tbl . '&id=' . intval($id));
    }
    $EMAILJS = '';
    $enter_html = '';
    eval("\$enter_html  = \"" . $template->get_template('header') . "\";");
    eval("\$enter_html .= \"" . $template->get_template('admin_enter') . "\";");
    eval("\$enter_html .= \"" . $template->get_template('footer') . "\";");
    echo $enter_html;
} else {
    // This is an array of some generic variables common to most forms
    $postVars = array('gbsession', 'uid', 'action', 'panel', 'section', 'tbl');
    create_variable($postVars);
    $action = !isset($action) ? '' : $action;
    $rid = !isset($rid) ? '' : $rid;
    $admin = new gb_admin($AUTH['session'], $AUTH['uid']);
    $admin->VARS =& $VARS;
    $admin->db =& $gb_auth;
    switch ($action) {
        case 'accept':
            $admin->accept_entry($id, $tbl);
            $admin->show_entry($tbl, $rid, $LANG['AdminTopMessAcc']);
            break;
        case 'unaccept':
            $admin->unaccept_entry($id, $tbl);
            $admin->show_entry($tbl, $rid, $LANG['AdminTopMessUnacc']);
            break;
        case 'show':
            $postVars = array('record', 'table');
            create_variable($postVars);
            $admin->show_entry($tbl, $rid);
Example #6
0
if (isset($_COOKIE['lang']) && !empty($_COOKIE['lang'])) {
    $template->set_lang($_COOKIE['lang']);
} else {
    $template->set_lang($VARS['lang']);
}
$LANG = $template->get_content();
$enter_html = "";
if (!$AUTH) {
    $message = isset($username) || isset($password) ? $LANG["PassMess2"] : $LANG["PassMess1"];
    eval("\$enter_html = \"" . $template->get_template($GB_TPL['header']) . "\";");
    eval("\$enter_html .= \"" . $template->get_template($GB_TPL['adm_enter']) . "\";");
    eval("\$enter_html .= \"" . $template->get_template($GB_TPL['footer']) . "\";");
    echo $enter_html;
} else {
    $action = !isset($action) ? "" : $action;
    $admin = new gb_admin($AUTH["session"], $AUTH["uid"]);
    $admin->VARS =& $VARS;
    $admin->db =& $gb_auth;
    $admin->table =& $GB_TBL;
    switch ($action) {
        case "show":
            $admin->show_entry($tbl);
            break;
        case "del":
            $admin->del_entry($id, $tbl);
            $admin->show_entry($tbl);
            break;
        case "edit":
            $admin->show_form($id, $tbl);
            break;
        case "info":