Beispiel #1
0
<?php

if (isset($p->file)) {
    $url = $p->file;
} else {
    $url = $oldfile;
}
$desc = get_category_info(null);
$content = file_get_contents($url);
$oldtitle = get_content_tag('t', $content, 'Untitled');
$olddescription = get_content_tag('d', $content);
$oldtag = get_content_tag('tag', $content);
$oldimage = get_content_tag('image', $content);
$oldcontent = remove_html_comments($content);
$dir = substr($url, 0, strrpos($url, '/'));
$isdraft = explode('/', $dir);
$oldurl = explode('_', $url);
if (empty($oldtag)) {
    $oldtag = $oldurl[1];
}
$oldmd = str_replace('.md', '', $oldurl[2]);
if (isset($_GET['destination'])) {
    $destination = $_GET['destination'];
} else {
    $destination = 'admin';
}
$replaced = substr($oldurl[0], 0, strrpos($oldurl[0], '/')) . '/';
// Category string
$cat = explode('/', $replaced);
$category = $cat[count($cat) - 3];
$dt = str_replace($replaced, '', $oldurl[0]);
Beispiel #2
0
function get_posts($posts, $page = 1, $perpage = 0)
{
    if (empty($posts)) {
        $posts = get_post_sorted();
    }
    $tmp = array();
    // Extract a specific page with results
    $posts = array_slice($posts, ($page - 1) * $perpage, $perpage);
    foreach ($posts as $index => $v) {
        $post = new stdClass();
        $filepath = $v['dirname'] . '/' . $v['basename'];
        // Extract the date
        $arr = explode('_', $filepath);
        // Replaced string
        $replaced = substr($arr[0], 0, strrpos($arr[0], '/')) . '/';
        // Author string
        $str = explode('/', $replaced);
        $author = $str[count($str) - 5];
        if ($str[count($str) - 3] == 'uncategorized') {
            $category = default_category();
            $post->category = '<a href="' . $category->url . '">' . $category->title . '</a>';
            $post->categoryb = '<a property="v:title" rel="v:url" href="' . $category->url . '">' . $category->title . '</a>';
        } else {
            $category = get_category_info($str[count($str) - 3]);
            $post->category = '<a href="' . $category[0]->url . '">' . $category[0]->title . '</a>';
            $post->categoryb = '<a property="v:title" rel="v:url" href="' . $category[0]->url . '">' . $category[0]->title . '</a>';
        }
        $type = $str[count($str) - 2];
        // The post author + author url
        $post->author = $author;
        $post->authorUrl = site_url() . 'author/' . $author;
        $post->type = $type;
        $dt = str_replace($replaced, '', $arr[0]);
        $t = str_replace('-', '', $dt);
        $time = new DateTime($t);
        $timestamp = $time->format("Y-m-d H:i:s");
        // The post date
        $post->date = strtotime($timestamp);
        // The archive per day
        $post->archive = site_url() . 'archive/' . date('Y-m', $post->date);
        if (config('permalink.type') == 'post') {
            $post->url = site_url() . 'post/' . str_replace('.md', '', $arr[2]);
        } else {
            $post->url = site_url() . date('Y/m', $post->date) . '/' . str_replace('.md', '', $arr[2]);
        }
        $post->file = $filepath;
        $content = file_get_contents($filepath);
        // Extract the title and body
        $post->title = get_content_tag('t', $content, 'Untitled: ' . date('l jS \\of F Y', $post->date));
        $post->image = get_content_tag('image', $content);
        $post->video = get_youtube_id(get_content_tag('video', $content));
        $post->link = get_content_tag('link', $content);
        $post->quote = get_content_tag('quote', $content);
        $post->audio = get_content_tag('audio', $content);
        $tag = array();
        $url = array();
        $bc = array();
        $rel = array();
        $tagt = get_content_tag('tag', $content);
        $t = explode(',', rtrim($arr[1], ','));
        if (!empty($tagt)) {
            $tl = explode(',', rtrim($tagt, ','));
            $tCom = array_combine($t, $tl);
            foreach ($tCom as $key => $val) {
                if (!empty($val)) {
                    $tag[] = array($val, site_url() . 'tag/' . strtolower($key));
                } else {
                    $tag[] = array($key, site_url() . 'tag/' . strtolower($key));
                }
            }
        } else {
            foreach ($t as $tt) {
                $tag[] = array($tt, site_url() . 'tag/' . strtolower($tt));
            }
        }
        foreach ($tag as $a) {
            $url[] = '<a rel="tag" href="' . $a[1] . '">' . $a[0] . '</a>';
            $bc[] = '<span typeof="v:Breadcrumb"><a property="v:title" rel="v:url" href="' . $a[1] . '">' . $a[0] . '</a></span>';
        }
        $post->tag = implode(' ', $url);
        $post->tagb = implode(' » ', $bc);
        $post->related = rtrim($arr[1], ',');
        // Get the contents and convert it to HTML
        $post->body = MarkdownExtra::defaultTransform(remove_html_comments($content));
        if (config('views.counter') == 'true') {
            $post->views = get_views($post->file);
        }
        $post->description = get_content_tag("d", $content, get_description($post->body));
        $tmp[] = $post;
    }
    return $tmp;
}
Beispiel #3
0
<?php

$php_root_path = "..";
$privilege_root_path = "/admin";
require_once "includes/include_all_fns.inc";
session_start();
// extract ( $_SESSION , EXTR_REFS ) ;
$err_message = " Unable to process your request due to the follow problems: <br>\n";
do_html_header("Edit Category");
$catID =& $_GET["catID"];
//Call the funtion to get the category information
$editCatInfo = get_category_info($catID);
?>
<form name="form1" method="post" action="process_edit_category.php">
  <table width="100%" border="0" cellpadding="1" cellspacing="0">
    <tr> 
      <td width="20%">&nbsp;</td>
      <td width="80%">&nbsp;</td>
      <input type="hidden" name="catID" value="<?php 
echo $editCatInfo->CategoryID;
?>
">
    </tr>
    <tr> 
      <td>Category Name:</td>
      <td> <input name="catName" type="text" id="catname" size="40" maxlength="50" value="<?php 
echo $editCatInfo->CategoryName;
?>
"> 
      </td>
    </tr>
                 $adv_qry = "&amp;adv=1";
             }
             if ($type != "") {
                 $type_qry = "&amp;type={$type}";
             }
             //      display links to more result pages
             include "" . $template_dir . "/html/070_more-results.html";
         }
     }
     break;
 default:
     if (!$cat_sel) {
         //  if not multiple category selection
         if ($show_categories) {
             if ($_REQUEST['catid'] && is_numeric($catid)) {
                 $cat_info = get_category_info($catid);
             } else {
                 $cat_info = get_categories_view();
             }
         }
         //  get name of current category
         $sql_query = "SELECT category from " . $mysql_table_prefix . "categories where category_id = '{$catid}'";
         $result = $db_con->query($sql_query);
         if ($debug && $db_con->errno) {
             $err_row = __LINE__ - 2;
             printf("<p><span class='red'>&nbsp;MySQL failure: %s&nbsp;\n<br /></span></p>", $db_con->error);
             if (__FUNCTION__) {
                 printf("<p><span class='red'>&nbsp;Found in script: " . __FILE__ . "&nbsp;&nbsp;row: {$err_row}&nbsp;&nbsp;in function():&nbsp;" . __FUNCTION__ . "&nbsp;<br /></span></p>");
             } else {
                 printf("<p><span class='red'>&nbsp;Found in script: " . __FILE__ . "&nbsp;&nbsp;row: {$err_row}&nbsp;<br /></span></p>");
             }
Beispiel #5
0
        }
        if (empty($content)) {
            $message['error'] .= '<li>Content field is required.</li>';
        }
        if (!$proper) {
            $message['error'] .= '<li>CSRF Token not correct.</li>';
        }
        config('views.root', 'system/admin/views');
        render('edit-page', array('title' => 'Edit category - ' . blog_title(), 'description' => blog_description(), 'canonical' => site_url(), 'error' => '<ul>' . $message['error'] . '</ul>', 'oldfile' => $oldfile, 'postTitle' => $title, 'postUrl' => $url, 'postContent' => $content, 'type' => 'is_category', 'bodyclass' => 'editcategory', 'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> &#187; Edit category'));
    }
});
// Delete category
get('/category/:category/delete', function ($category) {
    if (login()) {
        config('views.root', 'system/admin/views');
        $post = get_category_info($category);
        if (!$post) {
            not_found();
        }
        $post = $post[0];
        render('delete-category', array('title' => 'Delete category - ' . blog_title(), 'description' => blog_description(), 'canonical' => site_url(), 'bodyclass' => 'editpage', 'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> &#187; ' . $post->title, 'p' => $post, 'type' => 'categoryPage'));
    } else {
        $login = site_url() . 'login';
        header("location: {$login}");
    }
});
// Get deleted category data
post('/category/:category/delete', function () {
    $proper = is_csrf_proper(from($_REQUEST, 'csrf_token'));
    if ($proper && login()) {
        $file = from($_REQUEST, 'file');
Beispiel #6
0
function category_list($custom = null)
{
    $dir = "cache/widget";
    $filename = "cache/widget/category.list.cache";
    $tmp = array();
    $cat = array();
    $list = array();
    if (is_dir($dir) === false) {
        mkdir($dir, 0775, true);
    }
    if (file_exists($filename)) {
        $cat = unserialize(file_get_contents($filename));
    } else {
        $arr = get_category_info(null);
        foreach ($arr as $a) {
            $cat[] = array($a->md, $a->title);
        }
        array_push($cat, array('uncategorized', 'Uncategorized'));
        asort($cat);
        $tmp = serialize($cat);
        file_put_contents($filename, print_r($tmp, true));
    }
    if (!empty($custom)) {
        return $cat;
    }
    echo '<ul>';
    foreach ($cat as $k => $v) {
        if (get_categorycount($v['0']) !== 0) {
            echo '<li><a href="' . site_url() . 'category/' . $v['0'] . '">' . $v['1'] . '</a></li>';
        }
    }
    echo '</ul>';
}
Beispiel #7
0
   get_all_themes();
   break;
 case 'getThemeInfo':
   get_theme_info();
   break;
 case 'saveThemeInfo':
   save_theme_info();
   break;
 case 'deleteTheme':
   delete_theme();
   break;
 case 'getAllCategoriesList':
   get_all_categories_list();
   break;
 case 'getCategoryInfo':
   get_category_info();
   break;
 case 'saveCategoryInfo':
   save_category_info();
   break;
 case 'deleteCategory':
   delete_category();
   break;
 case 'getAllLayersList':
   get_all_layers_list();
   break;
 case 'getThemeLayerMapping':
   get_theme_layer_mapping();
   break;
 case 'saveThemeLayerMapping':
   save_theme_layer_mapping();