public function changePassword($password) { $_SESSION["password"] = $password; foreach ($this->data as $key => $user) { if ($user['user'] == $_SESSION["user"]) { $json[$key]['password'] = password_hash($password, PASSWORD_DEFAULT); } } $logsData = new LogsData(); $logsData->addToLog('has changed', 'his/her password', null); }
public function updateData($data) { $changeLog = array(); foreach ($data as $key => $datum) { if ($key != 'key' && isset($this->data[$key]) && $this->data[$key][$this->data[$key]['type']] != trim($datum)) { $changeLog[] = array('key' => $key, 'change' => array('original' => $this->data[$key][$this->data[$key]['type']], 'new' => trim($datum))); $this->data[$key][$this->data[$key]['type']] = trim($datum); } } if (count($changeLog) > 0) { $logsData = new LogsData(); $logsData->addToLog('has updated', ' the settings', $changeLog); } }
function post($action = null) { $users = new UsersData(); if ($action == 'process' && $users->checkPass() && !$users->authNeeded()) { DashboardUtils::backupFiles($_POST['files']); MinimizeTools::minimizeHTMLFiles($_POST['files']); new AnalyticsData(); new MediaData(); new SettingsData(); $rss = new RSSData(); $rss->buildDataFile($_POST['files']); $nav = new NavigationData(); $nav->buildDataFile($_POST['files']); $blog = new BlogData(); $blog->buildDataFile($_POST['files']); $footer = new FooterData(); $footer->buildDataFile($_POST['files']); $pages = new PagesData(); $pages->buildDataFile($_POST['files']); DashboardUtils::renameFiles($_POST['files']); DashboardUtils::copyApacheConfig(); DashboardUtils::createXMLSiteMap(); $logsData = new LogsData(); $logsData->addToLog('has initiated the CMS on the following files:', implode(" ", $_POST['files'])); header('Location: /admin/'); } else { include_once '401.html'; } }
public static function deleteRepeat($page, $key, $num) { $dataFile = 'data/page-' . $page . '.json'; $json = json_decode(file_get_contents($dataFile), true); foreach ($json as $jsonKey => $datum) { if ($key != 'key' && $jsonKey == $key && isset($json[$key]) && $json[$key]['type'] == 'repeat' && count($json[$key]['repeat']) > $num && isset($json[$key]['repeat'][$num])) { $logsData = new LogsData(); $logsData->addToLog('has deleted repeat on', $page . ' page', array('key' => $key, 'change' => array('deleted' => $json[$key]['repeat'][$num]))); array_splice($json[$key]['repeat'], $num, 1); } } $fp = fopen($dataFile, 'w'); fwrite($fp, json_encode($json)); fclose($fp); }
<?php include_once 'header.php'; $getUserLogs = null; if (isset($_GET['user-logs'])) { $getUserLogs = $_GET['user-logs']; } $logsData = new LogsData(); $logs = $logsData->getLogData(0, null, $getUserLogs); ?> <div class="container"> <div class="row"> <div class="col-lg-12"> <h2 class="page-header"><?php if (!is_null($getUserLogs)) { print $getUserLogs . '\'s '; } ?> Logs for CMS Recent History</h2> </div> <!-- /.col-lg-12 --> </div> <div class="row"> <div class="col-lg-12"> <?php foreach ($logs as $log) { ?> <div class="media"> <div class="media-left"> <div style="position:relative;">
public function updateBlogPost($post_id, $data, $publish = false) { $dataFile = $this->blogDataLocation . 'blog-' . $post_id . '.json'; $changeLog = array(); $isNew = false; $updateTime = time(); $creationTime = time(); if (file_exists($dataFile)) { $json = json_decode(file_get_contents($dataFile), true); } else { $isNew = true; $json = array('title' => null, 'keywords' => null, 'description' => null, 'author' => null, 'image' => null, 'image-alt-text' => null, 'short-blog' => null, 'full-blog' => null, 'link-text' => null, 'link-href' => null); } foreach ($data as $key => $datum) { if (DashboardUtils::endsWith($key, '-loaded') && trim($datum) != '') { $key = str_replace('-loaded', '', $key); } if ($key != 'save' && $key != 'publish') { $changeLog[] = array('key' => $key, 'change' => array('original' => $json[$key], 'new' => trim($datum))); $json[$key] = trim($datum); } } $json['published'] = $updateTime; $logsData = new LogsData(); if (count($changeLog) > 0 && !$isNew) { $logsData->addToLog('has updated', $data['title'] . ' blog', $changeLog); } else { if (count($changeLog) > 0 && $isNew) { $logsData->addToLog('has created', $data['title'] . ' blog', $changeLog); } } $externalTitle = preg_replace('/[^a-z0-9-]/i', '', str_replace(' ', '-', strtolower(trim($json['title'])))); if ($isNew || isset($this->data['posts'][$post_id]['external']) && $this->data['posts'][$post_id]['external'] != $externalTitle) { $externalTitleOriginal = $externalTitle; $count = 0; foreach ($this->data['posts'] as $key => $data) { while ($data['external'] == $externalTitle) { $externalTitle = $externalTitleOriginal . '-' . $count++; } } if ($isNew) { $this->data['posts'][$post_id] = array('external' => $externalTitle, 'title' => $json['title'], 'creator' => $_SESSION["user"], 'created' => $creationTime); } else { $this->data['posts'][$post_id]['title'] = $json['title']; $this->data['posts'][$post_id]['external'] = $externalTitle; $this->data['posts'][$post_id]['last-updated'] = $updateTime; } } else { $this->data['posts'][$post_id]['last-updated'] = $updateTime; } if ($publish) { $this->data['posts'][$post_id]['published'] = $updateTime; } $settingsData = new SettingsData(); $postPage = $this->data['post-page']; $json['link-href'] = $settingsData->getHost() . $postPage . '/' . $externalTitle . '/'; $fp = fopen($dataFile, 'w'); fwrite($fp, json_encode($json)); fclose($fp); DashboardUtils::createXMLSitemap(); }
<?php include_once 'header.php'; $files = DashboardUtils::scanFiles('.html'); $logsData = new LogsData(); $logs = $logsData->getLogData(-5); ?> <div class="container"> <div class="row"> <div class="col-lg-12"> <h2 class="page-header">Dashboard</h2> </div> </div> <div class="row"> <?php if (count($files) > 0) { ?> <div class="col-xs-12 col-sm-6 col-md-4"> <div class="panel panel-red"> <div class="panel-heading"> Unprocessed Files </div> <div class="panel-body"> <ul> <?php foreach ($files as $file) { ?> <li><?php echo $file; ?>