function userlist() { if (!F3::get('SESSION.asid')) { F3: reroute('/admin'); } $user = new Axon('tbl_user'); $users = array(); $user_list = $user->find(); if ($user_list != NULL) { foreach ($user_list as $ul) { $users[] = array($ul->email, $ul->username, '<img src="' . $ul->image . '" width="20px" height="20px" /> ' . $ul->fullname, $ul->active == 'y' ? 'Yes' : 'No', '<center><a href="#" class="blockLink" data-id="' . $ul->id . '">' . ($ul->active == 'y' ? 'Block' : 'Unblock') . '</a><br/><a href="#" class="deleteLink" data-id="' . $ul->id . '">Delete</a></center>'); } $i = 0; foreach ($user_list as $user) { $user_id[] = $user_list[$i]->id; $i++; } } else { $users = 0; $user_id = 0; } $this->set('identity', $user_id); $this->set('userList', $users); $this->set('title', 'User'); if (Snippets::_isAjax()) { echo Template::serve("template/admin/user.htm"); } else { $this->set('template', 'user'); echo Template::serve("template/admin/layout.htm"); } }
function test() { echo $_SERVER['SERVER_PORT']; $user = new Axon('tbl_user'); $user->load(array("id=:id", array(":id" => 1537994726))); $this->set('SESSION.user', $user); $this->set('SESSION.sid', Snippets::_getRN()); }
function adminLogin() { $admin = new Axon('tbl_admin'); $username = F3::get('POST.usr'); $password = F3::get('POST.pwd'); if ($admin->found(array('username=:username and password=:password', array(':username' => $username, ':password' => md5($password)))) == 1) { $admin->load(array('username=:username and password=:password', array(':username' => $username, ':password' => md5($password)))); F3::set('SESSION.admin', $admin); F3::set('SESSION.asid', Snippets::_getRN()); echo json_encode(array('message' => "You have been logged in ")); } else { echo json_encode(array('mes' => "Either password or usernaem is wrong")); } }
public static function _showError($message = "") { if (Snippets::_isAjax()) { if (Snippets::_isPost()) { $ret = array('error' => true); if ($message == "") { $message = F3::get('ERROR.text'); } $ret['message'] = $message; echo json_encode($ret); } else { $ret = 'error'; if ($message == "") { $message = F3::get('ERROR.text'); } $ret .= " [{$message}]"; echo $ret; } } else { F3::set('title', 'Page Not Found'); F3::set('template', 'error'); echo Template::serve("template/layout.htm"); } }
<?php $error = false; $data['snippetsList'] = ''; $data['totalSnippets'] = ''; $data['returnMsg'] = ''; $data['returnDangerMsg'] = ''; if (file_exists('../langs/' . $_POST['language'] . '.php')) { $lang = $_POST['language']; } else { // default $lang = 'en_EN'; } require_once '../langs/' . $lang . '.php'; require_once 'Snippets.php'; $snippets = new Snippets('snippets.xml', true); $snippets->getSnippets(); if (!isset($_POST['index']) || !is_numeric($_POST['index']) || !isset($_POST['title']) || !isset($_POST['code']) || !preg_match('`[a-zA-Z0-9_ -]{1,150}`', $_POST['title'])) { $error = true; if (!preg_match('`[a-zA-Z0-9_ -]{1,150}`', $_POST['title'])) { $return_msg = '<div class="alert alert-danger alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>' . TITLE_MUST_MATCH . '</div>'; } else { $return_msg = '<div class="alert alert-danger alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>' . WRONG_DATA . '</div>'; } } else { $out = $snippets->editSnippet($_POST['index'], utf8_decode(urldecode($_POST['title'])), utf8_decode(urldecode($_POST['code']))); $return_msg = '<div class="alert alert-success alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>' . SNIPPET_UPDATED . '</div>'; $return_danger_msg = ''; if ($out === 'script_forbidden') { $return_danger_msg = '<div class="alert alert-danger alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>' . SCRIPT_FORBIDDEN . '</div>'; } elseif ($out === 'php_forbidden') {
{ $protocol = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443 ? "https://" : "http://"; $domainName = $_SERVER['HTTP_HOST']; return $protocol . $domainName; } define('SITE_URL', siteURL()); /* language */ if (file_exists('langs/' . $_GET['language'] . '.php')) { $lang = $_GET['language']; } else { // default $lang = 'en_EN'; } require_once 'langs/' . $lang . '.php'; require_once 'snippets/Snippets.php'; $snippets = new Snippets('snippets/snippets.xml', $allowEdit); $snippets->getSnippets(); ?> <!DOCTYPE html> <html lang="fr"> <head> <link rel="stylesheet" href="<?php echo $bootstrap_css_path; ?> "> <link rel="stylesheet" href="css/plugin.min.css"> <link href="google-code-prettify/prettify.css" type="text/css" rel="stylesheet" /> <link href='http://fonts.googleapis.com/css?family=Source+Code+Pro' rel='stylesheet' type='text/css'> </head> <body> <div class="container">
$lang = $_GET['language']; } else { // default $lang = 'en_EN'; } require_once '../langs/' . $lang . '.php'; if (!isset($_GET['title']) || !isset($_GET['code']) || !preg_match('`[a-zA-Z0-9_ -]{1,150}`', $_GET['title'])) { $error = true; if (!preg_match('`[a-zA-Z0-9_ -]{1,150}`', $_GET['title'])) { $return_msg = '<div class="alert alert-danger alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>' . TITLE_MUST_MATCH . '</div>'; } else { $return_msg = '<div class="alert alert-danger alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>' . WRONG_DATA . '</div>'; } } else { require_once 'Snippets.php'; $snippets = new Snippets('snippets.xml', true); $snippets->getSnippets(); $out = $snippets->addNewSnippet(utf8_decode(urldecode($_GET['title'])), utf8_decode(urldecode($_GET['code']))); $return_msg = '<div class="alert alert-success alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>' . SNIPPET_ADDED . '</div>'; $return_danger_msg = ''; if ($out === 'script_forbidden') { $return_danger_msg = '<div class="alert alert-danger alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>' . SCRIPT_FORBIDDEN . '</div>'; } elseif ($out === 'php_forbidden') { $return_danger_msg = '<div class="alert alert-danger alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>' . PHP_FORBIDDEN . '</div>'; } } if ($error == false) { $data['snippetsList'] = $snippets->render(); $data['totalSnippets'] = $snippets->total_snippets; } $data['returnMsg'] = $return_msg;
function __construct() { $this->snips = new stdClass(); } public function add($name, $short, $lang, $url) { end($this->snips); count($this->snips) == 0 ? $id = 0 : ($id = key($this->snips) + 1); $this->snips->{$id} = new stdClass(); $this->snips->{$id}->name = $name; $this->snips->{$id}->short = $short; $this->snips->{$id}->lang = $lang; $this->snips->{$id}->url = $url; } } $snips = new Snippets(); $snips->add("Basic Reddit Reader in PHP", "PHP Reddit Reader", "php", "https://gist.github.com/3105963.js?file=redditReaderBasic.php"); $snips->add("Recursively Convert a Multi-Dimentional PHP Array to an Object", "Array to Object", "php", "https://gist.github.com/3107841.js?file=arrayToObject.php"); $snips->add("Function Recursion within a Class / Object", "Recursion in a Class", "php", "https://gist.github.com/2292935.js?file=gistfile1.aw"); $snips->add("Unlimited / Variable Number Function Arguments", "Variable Function Arguments", "php", "https://gist.github.com/2253239.js?file=gistfile1.aw"); $snips->add("Keep the Footer at the Bottom of the Page with jQuery", "jQuery Footer Placement", "js", "https://gist.github.com/1969584.js?file=placefooter.jquery.js"); $snips->add("Add and Loop Through All Snippets on this Page", "This Page's Snippet Loop", "php", "https://gist.github.com/3825556.js?file=pm_codepage.php"); $snips->add("Recurse through an object and display formatted contents", "Formatted Object Recursion Display", "php", "https://gist.github.com/4005418.js?file=zngine_feedback.php"); $snips->add("Mongoose Schema to store GitHub Issues", "Mongoose Schema - GitHub Issues", "js", "https://gist.github.com/4005413.js?file=feedback.js"); ?> <script> $(window).load( function() { $(".snippetButton").click( function( e ) { e.preventDefault(); var href = $(this).attr("href");
function __construct() { parent::__construct(); $this->table = 'grid_snippets_groups'; }
<?php $error = false; $data['snippetsList'] = ''; $data['totalSnippets'] = ''; if (file_exists('../langs/' . $_GET['language'] . '.php')) { $lang = $_GET['language']; } else { // default $lang = 'en_EN'; } require_once '../langs/' . $lang . '.php'; if (!isset($_GET['index']) || !is_numeric($_GET['index'])) { $error = true; $return_msg = '<div class="alert alert-danger alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>' . WRONG_DATA . '</div>'; } else { require_once 'Snippets.php'; $snippets = new Snippets('snippets.xml', true); $snippets->getSnippets(); $out = $snippets->deleteSnippet($_GET['index']); $return_msg = '<div class="alert alert-success alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>' . SNIPPET_DELETED . '</div>'; } if ($error == false) { $data['snippetsList'] = $snippets->render(); $data['totalSnippets'] = $snippets->total_snippets; } $data['returnMsg'] = $return_msg; echo json_encode($data);