This repository has been archived by the owner on Oct 24, 2018. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Bruno Bernardino
committed
Feb 9, 2012
0 parents
commit 97ef107
Showing
29 changed files
with
6,081 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
## AUTHOR ## | ||
|
||
Bruno Bernardino @ http://www.brunobernardino.com | ||
|
||
## REQUIREMENTS ## | ||
|
||
Connections to the servers are made through SFTP, and you need ssh2 for PHP. | ||
|
||
On Debian, the installation is like this: | ||
|
||
# apt-get install libssh2-1-dev && pecl install ssh2 channel://pecl.php.net/ssh2-0.11.3 | ||
|
||
That should be enough. | ||
|
||
## SETUP/INSTALL ## | ||
|
||
All the settings you need to change/setup to get this working are on inc/functions.php and are commented with "//-- Change This" (except quotes). | ||
|
||
The database structure is on bb_code.sql | ||
|
||
## NOTES ## | ||
|
||
In the add/edit form: | ||
- Clown = Username | ||
- Joke = Password | ||
|
||
Though this is optimized to work on a Chromebook, some commented code on js/editor.js will make it work better on Chrome for Mac, for example. | ||
|
||
There is no password protection (I'm assuming .htpasswd is enough). | ||
|
||
You can add/edit/delete servers on the simple back-office at /admin.php | ||
|
||
The usernames and passwords are encrypted in the database. | ||
|
||
## CREDITS ## | ||
|
||
The Highlighter/Editor is CodeMirror ( http://codemirror.net/ ) and only editing modes for CSS, HTML, JS, MySQL, PHP and XML are included (there are a lot more, as well as themes, etc.). | ||
|
||
I use Twitter's Bootstrap 2.0 ( http://twitter.github.com/bootstrap/index.html ), and everything about it is available in the app. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<?php | ||
include 'inc/functions.php'; | ||
?> | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>BB Code Editor Admin</title> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<meta name="description" content=""> | ||
<meta name="author" content="Bruno Bernardino"> | ||
|
||
<!--[if lt IE 9]> | ||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> | ||
<![endif]--> | ||
|
||
<link href="css/bootstrap.css" rel="stylesheet"> | ||
<link href="css/bootstrap.responsive.css" rel="stylesheet"> | ||
<link href="http://fonts.googleapis.com/css?family=Droid+Sans" rel="stylesheet"> | ||
<link href="css/global.css" rel="stylesheet"> | ||
|
||
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> | ||
<script src="js/bootstrap.js"></script> | ||
<script src="js/global.js"></script> | ||
<script src="js/admin.js"></script> | ||
</head> | ||
|
||
<body> | ||
<div class="container"> | ||
<div id="alert-area"> | ||
</div> | ||
<div class="row"> | ||
<div class="admin-content span12"> | ||
<h1>Servers <small><a href="/">« Go Back to Front-end</a></small></h1> | ||
<?php Helper::getAdminServerListing(); ?> | ||
<br /> | ||
<div id="edit-server" style="display: none"> | ||
<legend>Edit Server</legend> | ||
<form class="well form-inline" id="update-server"> | ||
<input id="srvu_server" type="hidden"> | ||
<input id="srvu_name" type="text" class="input-small" placeholder="Name"> | ||
<input id="srvu_host" type="text" placeholder="Host"> | ||
<input id="srvu_clown" type="text" class="input-small" placeholder="Clown"> | ||
<input id="srvu_joke" type="password" placeholder="Joke"> | ||
<input id="srvu_initial_path" type="text" class="input-small" placeholder="Initial Path"> | ||
<input id="srvu_position" type="number" class="input-small" placeholder="Position"> | ||
<select id="srvu_status" class="span1"> | ||
<option value="1">Active</option> | ||
<option value="0">Inactive</option> | ||
</select> | ||
<br /><br /> | ||
<button type="submit" class="btn btn-success">Update Server</button> | ||
<button type="reset" class="btn">Cancel</button> | ||
</form> | ||
<br /> | ||
</div> | ||
<legend>Add New Server</legend> | ||
<form class="well form-inline" id="add-server"> | ||
<input id="srv_name" type="text" class="input-small" placeholder="Name"> | ||
<input id="srv_host" type="text" placeholder="Host"> | ||
<input id="srv_clown" type="text" class="input-small" placeholder="Clown"> | ||
<input id="srv_joke" type="password" placeholder="Joke"> | ||
<input id="srv_initial_path" type="text" class="input-small" placeholder="Initial Path"> | ||
<input id="srv_position" type="number" class="input-small" placeholder="Position"> | ||
<select id="srv_status" class="span1"> | ||
<option value="1">Active</option> | ||
<option value="0">Inactive</option> | ||
</select> | ||
<br /><br /> | ||
<button type="submit" class="btn btn-success">Add Server</button> | ||
<button type="reset" class="btn">Clear</button> | ||
</form> | ||
</div> | ||
</div> <!-- /row --> | ||
</div> <!-- /container --> | ||
</body> | ||
</html> | ||
<?php | ||
DB::end(); | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
<?php | ||
include 'inc/functions.php'; | ||
|
||
$return = new stdClass(); | ||
$return->error = "Something's up..."; | ||
$return->data = ''; | ||
|
||
switch ($_POST['action']) { | ||
case 'list-directory': | ||
$serverID = (int) $_POST['server']; | ||
$serverPath = $_POST['path']; | ||
|
||
$return->error = false; | ||
$return->data = Helper::getDirectoryListing($serverID, $serverPath); | ||
|
||
if (empty($return->data)) { | ||
$return->error = "Sorry, I wasn't able to get that listing for you..."; | ||
} | ||
break; | ||
case 'open-file': | ||
$serverID = (int) $_POST['server']; | ||
$serverFile = $_POST['file']; | ||
|
||
$return->error = false; | ||
$return->data = new stdClass(); | ||
$return->data->contents = Helper::getServerFile($serverID, $serverFile); | ||
$return->data->editMode = 'htmlmixed'; | ||
|
||
$fileExtension = strtolower(substr(strrchr($serverFile,'.'),1)); | ||
|
||
switch ($fileExtension) { | ||
case 'js': | ||
case 'json': | ||
$return->data->editMode = 'javascript'; | ||
break; | ||
case 'css': | ||
case 'responsive': | ||
$return->data->editMode = 'css'; | ||
break; | ||
case 'xml': | ||
$return->data->editMode = 'xml'; | ||
break; | ||
case 'php': | ||
case 'inc': | ||
$return->data->editMode = 'php'; | ||
break; | ||
case 'sql': | ||
$return->data->editMode = 'mysql'; | ||
break; | ||
} | ||
|
||
if (empty($return->data->contents)) { | ||
$return->error = "Sorry, I wasn't able to get that file for you..."; | ||
} | ||
break; | ||
case 'save-file': | ||
$serverID = (int) $_POST['server']; | ||
$serverFile = $_POST['file']; | ||
$fileContents = $_POST['contents']; | ||
|
||
$return->error = false; | ||
$return->data = Helper::saveServerFile($serverID, $serverFile, $fileContents); | ||
|
||
if (empty($return->data)) { | ||
$return->error = "Sorry, I wasn't able to save that file for you..."; | ||
} | ||
break; | ||
//-- Admin functions | ||
case 'get-server': | ||
$serverID = (int) $_POST['server']; | ||
|
||
$return->error = false; | ||
$return->data = Helper::getServerForEdition($serverID); | ||
|
||
if (empty($return->data)) { | ||
$return->error = "Sorry, I wasn't able to get that server for you..."; | ||
} | ||
break; | ||
case 'add-server': | ||
$serverData = array( | ||
'name' => $_POST['name'], | ||
'host' => $_POST['host'], | ||
'clown' => Helper::encrypt($_POST['clown']), | ||
'joke' => Helper::encrypt($_POST['joke']), | ||
'initial_path' => $_POST['initial_path'], | ||
'position' => (int) $_POST['position'], | ||
'status' => (int) $_POST['status'] | ||
); | ||
|
||
$return->error = false; | ||
$return->data = Helper::addServer($serverData); | ||
|
||
if (empty($return->data)) { | ||
$return->error = "Sorry, I wasn't able to add that server for you..."; | ||
} | ||
break; | ||
case 'update-server': | ||
$serverID = (int) $_POST['server']; | ||
$serverData = array( | ||
'name' => $_POST['name'], | ||
'host' => $_POST['host'], | ||
'clown' => Helper::encrypt($_POST['clown']), | ||
'joke' => Helper::encrypt($_POST['joke']), | ||
'initial_path' => $_POST['initial_path'], | ||
'position' => (int) $_POST['position'], | ||
'status' => (int) $_POST['status'] | ||
); | ||
|
||
$return->error = false; | ||
$return->data = Helper::updateServer($serverID, $serverData); | ||
|
||
if (empty($return->data)) { | ||
$return->error = "Sorry, I wasn't able to add that server for you..."; | ||
} | ||
break; | ||
case 'delete-server': | ||
$serverID = (int) $_POST['server']; | ||
|
||
$return->error = false; | ||
$return->data = Helper::deleteServer($serverID); | ||
|
||
if (empty($return->data)) { | ||
$return->error = "Sorry, I wasn't able to delete that server for you..."; | ||
} | ||
break; | ||
} | ||
|
||
echo json_encode($return); | ||
DB::end(); | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
-- phpMyAdmin SQL Dump | ||
-- version 3.3.7deb6 | ||
-- http://www.phpmyadmin.net | ||
-- | ||
-- Máquina: localhost | ||
-- Data de Criação: 09-Fev-2012 às 11:30 | ||
-- Versão do servidor: 5.1.58 | ||
-- versão do PHP: 5.3.9-1~dotdeb.3 | ||
|
||
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; | ||
|
||
|
||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; | ||
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; | ||
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; | ||
/*!40101 SET NAMES utf8 */; | ||
|
||
-- | ||
-- Base de Dados: `bb_code` | ||
-- | ||
|
||
-- -------------------------------------------------------- | ||
|
||
-- | ||
-- Estrutura da tabela `tbl_servers` | ||
-- | ||
|
||
CREATE TABLE IF NOT EXISTS `tbl_servers` ( | ||
`id` int(11) NOT NULL AUTO_INCREMENT, | ||
`name` varchar(128) COLLATE utf8_unicode_ci NOT NULL, | ||
`host` varchar(128) COLLATE utf8_unicode_ci NOT NULL, | ||
`clown` text COLLATE utf8_unicode_ci NOT NULL, | ||
`joke` text COLLATE utf8_unicode_ci NOT NULL, | ||
`initial_path` varchar(128) COLLATE utf8_unicode_ci NOT NULL DEFAULT '/', | ||
`position` tinyint(4) NOT NULL, | ||
`status` tinyint(1) NOT NULL, | ||
PRIMARY KEY (`id`) | ||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ; |
Oops, something went wrong.