Initial commit
This commit is contained in:
7
includes/admin/dashboard.php
Normal file
7
includes/admin/dashboard.php
Normal file
@ -0,0 +1,7 @@
|
||||
<h1>{locale:dashboard}</h1>
|
||||
|
||||
<ul>
|
||||
<li><a href='/admin/entry'>{locale:entry_editor}</a></li>
|
||||
<li><a href='/admin/plugins'>{locale:plugin_manager}</a></li>
|
||||
<li><a href='/admin/page'>{locale:page_editor}</a></li>
|
||||
</ul>
|
149
includes/admin/entry.php
Normal file
149
includes/admin/entry.php
Normal file
@ -0,0 +1,149 @@
|
||||
<?php
|
||||
|
||||
if (isset($_GET['status']))
|
||||
switch ($_GET['status'])
|
||||
{
|
||||
case 'added':
|
||||
array_push($info, $_locale['entry_added']);
|
||||
break;
|
||||
|
||||
case 'updated':
|
||||
array_push($info, $_locale['entry_updated']);
|
||||
break;
|
||||
}
|
||||
|
||||
if (isset($_POST['entryContent']) && $user['userLevel'] > 2)
|
||||
{
|
||||
|
||||
if (isset($_POST['entryAdd']))
|
||||
{
|
||||
if (blog::add($_POST['entryHeader'], $_POST['entryTitle'], $_POST['entrySlug'], $_POST['entryContent'], $_POST['entryPublished'], (isset($_POST['entryHidden']) ? true : false), $_POST['entryPIN']))
|
||||
redirect(get_entry_link($_POST['entrySlug']), 'added');
|
||||
else
|
||||
array_push($error, $_locale['entry_not_added']);
|
||||
} elseif (isset($_POST['entryUpdate']))
|
||||
{
|
||||
if (blog::update($_POST['entryUpdate'], $_POST['entryHeader'], $_POST['entryTitle'], $_POST['entryContent'], $_POST['entryPublished'], (isset($_POST['entryHidden']) ? true : false), $_POST['entryPIN']))
|
||||
redirect(get_current_link(), 'updated');
|
||||
else
|
||||
array_push($error, $_locale['entry_not_updated']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (isset($_POST['entryTag']) && $user['userLevel'] > 2)
|
||||
{
|
||||
if (isset($_POST['tagIdRemove']))
|
||||
{
|
||||
if (blog::tagRemove($_POST['tagIdRemove'], $_POST['entryId']))
|
||||
array_push($info, $_locale['entry_tag_removed']);
|
||||
else
|
||||
array_push($error, $_locale['entry_tag_not_removed']);
|
||||
} elseif (blog::tag($_POST['tagId'], $_POST['entryId']))
|
||||
array_push($info, $_locale['entry_tag_added']);
|
||||
else
|
||||
array_push($error, $_locale['entry_tag_not_added']);
|
||||
}
|
||||
|
||||
if (isset($seo[2]) && $user['userLevel'] > 2)
|
||||
{
|
||||
$entry = new blog($seo[2]);
|
||||
if ($entry->entries)
|
||||
{
|
||||
$entryData = $entry->entry();
|
||||
if (isset($seo[3]) && $user['userLevel'] > 3)
|
||||
switch ($seo[3])
|
||||
{
|
||||
case 'delete':
|
||||
if ($entry->delete($entryData['entryId']))
|
||||
redirect('/admin/entry');
|
||||
else
|
||||
array_push($error, $_locale['entry_not_deleted']);
|
||||
break;
|
||||
|
||||
case 'pin':
|
||||
if ($entry->pin($entryData['entryId']))
|
||||
redirect();
|
||||
else
|
||||
array_push($error, $_locale['entry_not_pinned']);
|
||||
break;
|
||||
|
||||
case 'unpin':
|
||||
if ($entry->unpin($entryData['entryId']))
|
||||
redirect();
|
||||
else
|
||||
array_push($error, $_locale['entry_not_unpinned']);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else
|
||||
{
|
||||
$timedQuery = $_sql->query("SELECT entrySlug, entryTitle, entryCreated, entryPublished FROM entries WHERE entryPublished > ".time()."");
|
||||
if ($timedQuery->num_rows)
|
||||
{
|
||||
echo "<h1>{locale:timed_entries}</h1>";
|
||||
echo "<table class='designed timed'><tr><td>{locale:entry_title}</td><td>{locale:created_on}</td><td>{locale:timed_pub_date}</td></tr>";
|
||||
while ($data = $timedQuery->fetch_assoc())
|
||||
echo "<tr><td><a href='".get_entry_link($data['entrySlug'])."'>$data[entryTitle]</a></td><td>".show_date($data['entryCreated'])."</td><td>".show_date($data['entryPublished'])."</td></tr>";
|
||||
echo "</table>";
|
||||
}
|
||||
|
||||
$hiddenQuery = $_sql->query("SELECT entrySlug, entryTitle, entryCreated, entryPublished FROM entries WHERE entryHidden IS NOT NULL");
|
||||
if ($hiddenQuery->num_rows)
|
||||
{
|
||||
echo "<h1>{locale:hidden_entries}</h1>";
|
||||
echo "<table class='designed timed'><tr><td>{locale:entry_title}</td><td>{locale:created_on}</td><td>{locale:timed_pub_date}</td></tr>";
|
||||
while ($data = $hiddenQuery->fetch_assoc())
|
||||
echo "<tr><td><a href='".get_entry_link($data['entrySlug'], null, true)."'>$data[entryTitle]</a></td><td>".show_date($data['entryCreated'])."</td><td>".show_date($data['entryPublished'])."</td></tr>";
|
||||
echo "</table>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
<h1>{locale:entry_editor}</h1>
|
||||
<form action="<?=get_current_link()?>" method="post" name="entry-edit">
|
||||
|
||||
<?php if (isset($entryData)) : addTitle($entryData['entryTitle']); headerImage($entryData['entryHeader']); ?>
|
||||
<input type="text" name="entryHeader" value="<?=htmlentities($entryData['entryHeader'])?>" placeholder="{locale:entry_header}" maxlength="255" />
|
||||
<input type="text" name="entryTitle" value="<?=htmlentities($entryData['entryTitle'])?>" placeholder="{locale:entry_title}" maxlength="250" />
|
||||
<textarea id="entry-textarea" name="entryContent" rows="30"><?=htmlspecialchars($entryData['entryContent'])?></textarea>
|
||||
<input id="entry-date" type="text" name="entryPublished" value="<?=date(DATE_FORMAT_DEFAULT, $entryData['entryPublished'])?>" placeholder="{locale:entry_pub_date}" maxlength="50" />
|
||||
<label><input type="checkbox" name="entryHidden" value="1" <?=($entryData['entryHidden'] ? 'checked ' : '')?> /> {locale:entry_hide}</label>
|
||||
<input type="text" name="entryPIN" value="<?=htmlentities($entryData['entryPIN'])?>" placeholder="{locale:entry_pin}" maxlength="6" />
|
||||
<input type="hidden" name="entryUpdate" value="<?=$entryData['entryId']?>" />
|
||||
<?php else: ?>
|
||||
<input type="text" name="entryHeader" id="entryHeader" placeholder="{locale:entry_header}" maxlength="255" />
|
||||
<input type="text" name="entryTitle" id="entryTitle" placeholder="{locale:entry_title}" maxlength="250" />
|
||||
<textarea id="entry-textarea" name="entryContent" rows="30"></textarea>
|
||||
<input id="entry-date" type="text" name="entryPublished" placeholder="{locale:entry_pub_date}" maxlength="50" />
|
||||
<input type="text" name="entrySlug" id="entrySlug" placeholder="{locale:entry_slug}" maxlength="100" />
|
||||
<label><input type="checkbox" name="entryHidden" value="1" /> {locale:entry_hide}</label>
|
||||
<input type="text" name="entryPIN" placeholder="{locale:entry_pin}" maxlength="6" />
|
||||
<input type="hidden" name="entryAdd" value="true" />
|
||||
<?php endif ?>
|
||||
|
||||
<button type="submit">{locale:save}</button>
|
||||
|
||||
</form>
|
||||
|
||||
<?php
|
||||
if (isset($entryData))
|
||||
{
|
||||
$tags = $_sql->query("SELECT * FROM tags");
|
||||
if ($tags->num_rows)
|
||||
{
|
||||
echo "<h3>{locale:tags}</h3>";
|
||||
echo "<table class='designed'><tr><td>{locale:tag_name}</td><td>{locale:add}</td></tr>"
|
||||
."<form action='".get_current_link()."' method='post' name='tagentry'>"
|
||||
."<input type='hidden' name='entryId' value='$entryData[entryId]' />"
|
||||
."<input type='hidden' name='entryTag' value='true' />";
|
||||
|
||||
while ($tag = $tags->fetch_assoc())
|
||||
echo "<tr><td>$tag[tagName]</td><td>".($_sql->query("SELECT taggedId FROM tagged WHERE taggedEntry = $entryData[entryId] AND taggedTag = $tag[tagId]")->num_rows ? "<button type='submit' name='tagIdRemove' value='$tag[tagId]'>{locale:remove}</button>":"<button type='submit' name='tagId' value='$tag[tagId]'>{locale:add}</button>")."</td></tr>";
|
||||
|
||||
echo "</form>"
|
||||
."</table>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<script>$("#entry-date").datepicker({ minDate: 0, maxDate: "+48M" });</script>
|
36
includes/admin/main.php
Normal file
36
includes/admin/main.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
addTitle($_locale['admin']);
|
||||
|
||||
if (!isset($seo[1])) $seo[1] = '';
|
||||
|
||||
switch ($seo[1])
|
||||
{
|
||||
|
||||
case 'upload':
|
||||
include 'data/upload.php';
|
||||
exit;
|
||||
break;
|
||||
|
||||
case 'plugins':
|
||||
if ($user['userLevel'] < 3) redirect();
|
||||
addTitle($_locale['plugin_manager']);
|
||||
include 'includes/admin/plugins.php';
|
||||
break;
|
||||
|
||||
case $_set['subEntry']:
|
||||
if ($user['userLevel'] < 2) redirect();
|
||||
addTitle($_locale['entry_editor']);
|
||||
include 'includes/admin/entry.php';
|
||||
break;
|
||||
|
||||
case $_set['subPage']:
|
||||
if ($user['userLevel'] < 3) redirect();
|
||||
addTitle($_locale['page_editor']);
|
||||
include 'includes/admin/page.php';
|
||||
break;
|
||||
|
||||
default:
|
||||
include 'includes/admin/dashboard.php';
|
||||
break;
|
||||
}
|
55
includes/admin/page.php
Normal file
55
includes/admin/page.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
if (isset($_POST['pageContent']) && isset($_POST['pageSlug']) && $user['userLevel'] > 3)
|
||||
{
|
||||
$page = new page($_POST['pageSlug']);
|
||||
if (isset($_POST['pageAdd']))
|
||||
{
|
||||
if ($page->create($_POST['pageTitle'], $_POST['pageContent']))
|
||||
array_push($info, $_locale['page_added']);
|
||||
else
|
||||
array_push($error, $_locale['page_not_added']);
|
||||
} elseif (isset($_POST['pageUpdate']))
|
||||
{
|
||||
if ($page->update($_POST['pageTitle'], $_POST['pageContent']))
|
||||
array_push($info, $_locale['page_updated']);
|
||||
else
|
||||
array_push($error, $_locale['page_not_updated']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (isset($seo[2]))
|
||||
$page = new page($seo[2]);
|
||||
else
|
||||
{
|
||||
$pagesQuery = $_sql->query("SELECT pageSlug, pageTitle FROM pages");
|
||||
if ($pagesQuery->num_rows)
|
||||
{
|
||||
echo "<h1>{locale:pages}</h1>";
|
||||
echo "<table class='designed pages'><tr><td>{locale:page_title}</td></tr>";
|
||||
while ($data = $pagesQuery->fetch_assoc())
|
||||
echo "<tr><td><a href='/admin/page/$data[pageSlug]'>$data[pageTitle]</a></td></tr>";
|
||||
echo "</table>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
<h1>{locale:page_editor}</h1>
|
||||
<form action="<?=get_current_link()?>" method="post" name="entry-edit">
|
||||
|
||||
<?php if (isset($page->data)) : addTitle($page->data['pageTitle']); ?>
|
||||
<input type="text" name="pageTitle" value="<?=$page->data['pageTitle']?>" placeholder="{locale:page_title}" maxlength="250" />
|
||||
<textarea name="pageContent"><?=htmlspecialchars($page->data['pageContent'])?></textarea>
|
||||
<input type="hidden" name="pageSlug" value="<?=$page->data['pageSlug']?>" />
|
||||
<input type="hidden" name="pageUpdate" value="true" />
|
||||
<button type="button" onclick="window.location.href='/admin/page'">{locale:cancel}</button>
|
||||
<?php else: ?>
|
||||
<input type="text" id="pageTitle" name="pageTitle" value="" placeholder="{locale:page_title}" maxlength="250" />
|
||||
<textarea name="pageContent"></textarea>
|
||||
<input type="text" id="pageSlug" name="pageSlug" value="" placeholder="{locale:page_slug}" />
|
||||
<input type="hidden" name="pageAdd" value="true" />
|
||||
<?php endif ?>
|
||||
|
||||
<button type="submit">{locale:save}</button>
|
||||
|
||||
</form>
|
51
includes/admin/plugins.php
Normal file
51
includes/admin/plugins.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
if (isset($_POST['pluginId']) && isnum($_POST['pluginId']))
|
||||
{
|
||||
if ($_sql->query("UPDATE plugins SET pluginStatus = ".(isset($_POST['pluginEnable']) ? 1 : 0)." WHERE pluginId = $_POST[pluginId]"))
|
||||
redirect(get_current_link());
|
||||
else
|
||||
array_push($error, $_locale['plugin_not_updated']);
|
||||
}
|
||||
|
||||
echo "<h1>$_locale[plugins]</h1>";
|
||||
|
||||
$pluginsQuery = $_sql->query("SELECT * FROM plugins ORDER BY pluginStatus DESC");
|
||||
$plugins = array();
|
||||
if ($pluginsQuery->num_rows)
|
||||
{
|
||||
echo "<table class='designed plugins'>";
|
||||
echo "<tr><td>{locale:plugin_name}</td><td>{locale:description}</td><td>{locale:scope}</td><td>{locale:status}</td></tr>";
|
||||
while ($data = $pluginsQuery->fetch_assoc())
|
||||
{
|
||||
$pinfo = './plugins/'.$data['pluginLib'].'/info.json';
|
||||
if (file_exists($pinfo))
|
||||
{
|
||||
$pinfo = (array)json_decode(file_get_contents($pinfo));
|
||||
|
||||
if ($data['pluginStatus'])
|
||||
$button = "<button name='pluginDisable' class='orange'>{locale:disable}</button>";
|
||||
else $button = "<button name='pluginEnable'>{locale:enable}</button>";
|
||||
|
||||
echo "<tr><td>$pinfo[name]</td><td>$pinfo[description]<td>$pinfo[paths]</td><td><form action='".get_current_link()."' method='post'><input type='hidden' name='pluginId' value='$data[pluginId]'/>$button</form></td></tr>";
|
||||
}
|
||||
array_push($plugins, $data['pluginLib']);
|
||||
}
|
||||
echo "</table>";
|
||||
} else
|
||||
echo "<p>$_locale[plugins_empty]</p>";
|
||||
|
||||
|
||||
if ($handle = opendir('./plugins')) {
|
||||
|
||||
while (false !== ($entry = readdir($handle)))
|
||||
{
|
||||
if (!in_array($entry, $plugins) && file_exists('./plugins/'.$entry.'/info.json'))
|
||||
if ($_sql->query("INSERT INTO plugins (pluginLib, pluginStatus) VALUES ('$entry', 0)"))
|
||||
array_push($info, $_locale['plugin_added'].$entry);
|
||||
else
|
||||
array_push($error, $_locale['plugin_not_added'].$entry);
|
||||
}
|
||||
|
||||
closedir($handle);
|
||||
}
|
0
includes/admin/tags.php
Normal file
0
includes/admin/tags.php
Normal file
Reference in New Issue
Block a user