Example #1
0
function migrate_old_content()
{
    $content = array();
    $tmp = array();
    $files = array();
    $draft = array();
    $dtmp = array();
    $dfiles = array();
    $tmp = glob('content/*/blog/*.md', GLOB_NOSORT);
    if (is_array($tmp)) {
        foreach ($tmp as $file) {
            $content[] = $file;
        }
    }
    if (!empty($content)) {
        foreach ($content as $c => $v) {
            $arr = explode('/', $v);
            $string = file_get_contents($v);
            $image = get_content_tag('image', $string);
            $video = get_youtube_id(get_content_tag('video', $string));
            $audio = get_content_tag('audio', $string);
            $link = get_content_tag('link', $string);
            $quote = get_content_tag('quote', $string);
            if (!empty($image)) {
                $files[] = array($v, 'content/' . $arr[1] . '/blog/uncategorized/image/' . $arr[3]);
                $dir = 'content/' . $arr[1] . '/blog/uncategorized/image/';
                if (!is_dir($dir)) {
                    mkdir($dir, 0775, true);
                }
            }
            if (!empty($video)) {
                $files[] = array($v, 'content/' . $arr[1] . '/blog/uncategorized/video/' . $arr[3]);
                $dir = 'content/' . $arr[1] . '/blog/uncategorized/video/';
                if (!is_dir($dir)) {
                    mkdir($dir, 0775, true);
                }
            }
            if (!empty($audio)) {
                $files[] = array($v, 'content/' . $arr[1] . '/blog/uncategorized/audio/' . $arr[3]);
                $dir = 'content/' . $arr[1] . '/blog/uncategorized/audio/';
                if (!is_dir($dir)) {
                    mkdir($dir, 0775, true);
                }
            }
            if (!empty($link)) {
                $files[] = array($v, 'content/' . $arr[1] . '/blog/uncategorized/link/' . $arr[3]);
                $dir = 'content/' . $arr[1] . '/blog/uncategorized/link/';
                if (!is_dir($dir)) {
                    mkdir($dir, 0775, true);
                }
            }
            if (!empty($quote)) {
                $files[] = array($v, 'content/' . $arr[1] . '/blog/uncategorized/quote/' . $arr[3]);
                $dir = 'content/' . $arr[1] . '/blog/uncategorized/quote/';
                if (!is_dir($dir)) {
                    mkdir($dir, 0775, true);
                }
            }
            if (empty($image) && empty($video) && empty($audio) && empty($link) && empty($quote)) {
                $files[] = array($v, 'content/' . $arr[1] . '/blog/uncategorized/post/' . $arr[3]);
                $dir = 'content/' . $arr[1] . '/blog/uncategorized/post/';
                if (!is_dir($dir)) {
                    mkdir($dir, 0775, true);
                }
            }
        }
        foreach ($files as $f) {
            rename($f[0], $f[1]);
        }
    }
    $dir = 'content/data/';
    if (!is_dir($dir)) {
        mkdir($dir, 0775, true);
    }
    if (file_exists('content/tags.lang')) {
        rename('content/tags.lang', 'content/data/tags.lang');
        unlink('content/views.json');
    }
    $dtmp = glob('content/*/draft/*.md', GLOB_NOSORT);
    $old = array();
    if (is_array($dtmp)) {
        foreach ($dtmp as $dfile) {
            $draft[] = $dfile;
        }
    }
    if (!empty($draft)) {
        foreach ($draft as $d => $val) {
            $arr = explode('/', $val);
            $old[] = 'content/' . $arr[1] . '/draft/';
            $dir = 'content/' . $arr[1] . '/blog/uncategorized/draft/';
            $new = 'content/' . $arr[1] . '/blog/uncategorized/draft/' . $arr[3];
            if (!is_dir($dir)) {
                mkdir($dir, 0775, true);
            }
            $dfiles[] = array($val, $new);
        }
        foreach ($dfiles as $fd) {
            rename($fd[0], $fd[1]);
        }
        $tt = array();
        $tt = array_unique($old, SORT_REGULAR);
        foreach ($tt as $t) {
            rmdir($t);
        }
    }
    rebuilt_cache('all');
}
Example #2
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]);
Example #3
0
<?php

if (isset($_SESSION[config("site.url")]['user'])) {
    $user = $_SESSION[config("site.url")]['user'];
}
$filename = 'content/' . $user . '/author.md';
if (file_exists($filename)) {
    $content = file_get_contents($filename);
    $oldtitle = get_content_tag('t', $content, 'user');
    $oldcontent = remove_html_comments($content);
} else {
    $oldtitle = $user;
    $oldcontent = 'Just another HTMLy user.';
}
?>
<link rel="stylesheet" type="text/css" href="<?php 
echo site_url();
?>
system/admin/editor/css/editor.css"/>
<script src="<?php 
echo site_url();
?>
system/resources/js/jquery.min.js"></script> 
<script src="<?php 
echo site_url();
?>
system/resources/js/jquery-ui.min.js"></script>
<script type="text/javascript" src="<?php 
echo site_url();
?>
system/admin/editor/js/Markdown.Converter.js"></script>
Example #4
0
<?php

if (isset($p->file)) {
    $url = $p->file;
} else {
    $url = $oldfile;
}
$content = file_get_contents($url);
$oldtitle = get_content_tag('t', $content, 'Untitled');
$olddescription = get_content_tag('d', $content);
$oldcontent = remove_html_comments($content);
if (isset($_GET['destination'])) {
    $destination = $_GET['destination'];
} else {
    $destination = 'admin';
}
$dir = substr($url, 0, strrpos($url, '/'));
$oldurl = str_replace($dir . '/', '', $url);
$oldmd = str_replace('.md', '', $oldurl);
if (isset($p->url)) {
    $delete = $p->url . '/delete?destination=' . $destination;
} else {
    if (empty($sub)) {
        $delete = site_url() . $oldmd . '/delete?destination=' . $destination;
    } else {
        $delete = site_url() . $static . '/' . $sub . '/delete?destination=' . $destination;
    }
}
?>
<link rel="stylesheet" type="text/css" href="<?php 
echo site_url();
Example #5
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);
$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]);
$t = str_replace('-', '', $dt);
Example #6
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);
$oldquote = get_content_tag('quote', $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]);
Example #7
0
<?php

if (isset($p->file)) {
    $url = $p->file;
} else {
    $url = $oldfile;
}
$content = file_get_contents($url);
$oldtitle = get_content_tag('t', $content, 'Untitled');
$olddescription = get_content_tag('d', $content);
$oldlink = get_content_tag('link', $content);
$oldcontent = remove_html_comments($content);
$dir = substr($url, 0, strrpos($url, '/'));
$isdraft = explode('/', $dir);
$oldurl = explode('_', $url);
$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], '/')) . '/';
$dt = str_replace($replaced, '', $oldurl[0]);
$t = str_replace('-', '', $dt);
$time = new DateTime($t);
$timestamp = $time->format("Y-m-d");
// The post date
$postdate = strtotime($timestamp);
// The post URL
$delete = site_url() . date('Y/m', $postdate) . '/' . $oldmd . '/delete?destination=' . $destination;
Example #8
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);
$oldaudio = get_content_tag('audio', $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]);
Example #9
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);
$oldvideo = get_content_tag('video', $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]);
Example #10
0
function get_title_from_file($v)
{
    // Get the contents and convert it to HTML
    $content = MarkdownExtra::defaultTransform(file_get_contents($v));
    $replaced = substr($v, 0, strrpos($v, '/')) . '/';
    $base = str_replace($replaced, '', $v);
    // Extract the title and body
    return get_content_tag('t', $content, str_replace('-', ' ', str_replace('.md', '', $base)));
}