Skip to content
This repository has been archived by the owner on May 8, 2020. It is now read-only.

Commit

Permalink
v0.2.
Browse files Browse the repository at this point in the history
  • Loading branch information
Skyost committed Apr 2, 2015
1 parent defa061 commit 75661c7
Show file tree
Hide file tree
Showing 11 changed files with 307 additions and 125 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Projectpot
*Projectpot is a simple project repository written in PHP and it does not need any database (uses JSON).*
*Projectpot is just like a honeypot, but for your projects.
It is a simple project repository written in PHP and it does not need any database (uses JSON).*

## Instructions
Download the latest release [here](https://github.com/Skyost/Projectpot/releases) and uncompress it on your server. That's all !
Expand Down
11 changes: 7 additions & 4 deletions admin.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
require('include/config.php');
require('include/functions.php');
$settings = load_settings();
include('include/languages/' . $settings['metaLanguage'] . '.php');
/*if(PP_TRANSLATION_VERSION < 1) {
die('Please update your translation !');
}*/
if(isset($_COOKIE['pp_logout'])) {
delete_cookie('pp_logout');
}
Expand All @@ -21,7 +24,7 @@
<!DOCTYPE html>
<html>
<head>
<title>Admin Area</title>
<title><?=PP_ADMINAREA?></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="generator" content="<?=PP_APP_NAME?>">
Expand All @@ -38,7 +41,7 @@
include('include/adminarea.php');
}
else {
echo message('Wrong username or password !', 'alert-danger');
echo message(PP_LOGIN_ERROR, 'alert-danger');
delete_cookie('pp_username');
delete_cookie('pp_password');
include('include/loginform.php');
Expand Down
19 changes: 1 addition & 18 deletions assets/js/adminarea.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// EVERYTHING NEEDED BY THE ADMIN PANEL :

$(document).ready(function() {
$('.jquery-te').jqte();
$('#projects-edit-oldname').change(function() {
Expand All @@ -15,20 +13,6 @@ $('#logout-link').click(function() {
location.reload();
});

$('.expander').click(function() {
if($(this).attr('collapsed') == 1) {
$(this).text('Collapse');
$(this).attr('collapsed', 0);
$(this).prepend('<img src="assets/img/collapse.png"/> ');
}
else {
$(this).text('Expand');
$(this).attr('collapsed', 1);
$(this).prepend('<img src="assets/img/expand.png"/> ');
}
$('#' + $(this).attr('for')).toggleClass('hidden');
});

function updateEditAreas() {
var project = $.parseJSON(projects[$('#projects-edit-oldname').val()]);
$('#projects-edit-newname').val(project['name']);
Expand All @@ -37,8 +21,7 @@ function updateEditAreas() {
$('#projects-edit-newdescription').jqteVal(project['description']);
}

// CHECKING FOR UPDATES : (http://stackoverflow.com/a/7717160/3608831)

// Comparing versions (http://stackoverflow.com/a/7717160/3608831).
function cmpVersion(a, b) {
var i, cmp, len, re = /(\.0)+[^\.]*$/;
a = (a + '').replace(re, '').split('.');
Expand Down
203 changes: 118 additions & 85 deletions include/adminarea.php

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion include/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
DON'T EDIT ANYTHING AFTER THIS LINE !
*/
define('PP_APP_NAME', 'Projectpot');
define('PP_APP_VERSION', '0.1');
define('PP_APP_VERSION', '0.2');
define('PP_APP_AUTHOR', 'Skyost');
?>
20 changes: 18 additions & 2 deletions include/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,22 @@ function load_settings() {
}
if(file_exists('json/settings.json')) {
$settings = json_decode(file_get_contents('json/settings.json'), true);
if($settings['configVersion'] < 2) {
$settings = array_merge($settings, array(
'configVersion' => 2,
'metaLanguage' => 'en_US'
));
file_put_contents('json/settings.json', json_encode($settings));
}
}
else {
$settings = array(
'configVersion' => 1,
'configVersion' => 2,
'metaTitle' => 'My Projectpot',
'metaDescription' => 'This is my Projectpot.',
'metaKeywords' => 'project,pot,projectpot',
'metaAuthor' => 'Skyost',
'metaLanguage' => 'en_US',
'adflyUse' => true,
'adflyId' => 549897
);
Expand All @@ -68,10 +76,18 @@ function delete_cookie($cookie) {
}

function title($title) {
return '<h1><img class="title" src="assets/img/HoneyPot.png"/> ' . $title . ' <img class="title" src="assets/img/HoneyPot.png"/></h1>';
return '<h1><img class="title" src="assets/img/HoneyPot.png"/> ' . $title . ' <img class="title" src="assets/img/HoneyPot.png"/></h1>' . PHP_EOL;
}

function message($message, $type) {
return '<div class="container alert ' . $type . ' alert-dismissible" role="alert"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>' . $message . '</div>' . PHP_EOL;
}

function str_endswith($haystack, $needle) {
$length = strlen($needle);
if($length == 0) {
return true;
}
return(substr($haystack, -$length) === $needle);
}
?>
71 changes: 71 additions & 0 deletions include/languages/en_US.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php
// Main page :

define('PP_PROJECT_NAME', 'Project\'s name');
define('PP_PROJECT_LINK', 'Link');
define('PP_NOPROJECT', 'Nothing here.');
define('PP_NOLINK', 'Here either.');
define('PP_NOCATEGORY', 'No category.');
define('PP_POWEREDBY', 'Powered by ' . PP_APP_NAME . ' v' . PP_APP_VERSION . ' by ' . PP_APP_AUTHOR);
define('PP_ADMIN', 'Admin');
define('PP_ENABLE_ADFLY', 'Enable adf.ly links');
define('PP_DISABLE_ADFLY', 'Disable adf.ly links');

// Admin page :

define('PP_ADMINAREA', 'Admin Area');
define('PP_LOGINPAGE_TITLE', 'Login');
define('PP_USERNAME', 'Username');
define('PP_PASSWORD', 'Password');
define('PP_LOGIN', 'Login !');
define('PP_LOGIN_ERROR', 'Wrong username or password !');
define('PP_WEBSITE_CONFIGURATION', 'Website configuration');
define('PP_WEBSITE_META', 'Site meta');
define('PP_WEBSITE_TITLE', 'Title');
define('PP_WEBSITE_DESCRIPTION', 'Description');
define('PP_WEBSITE_KEYWORDS', 'Keywords');
define('PP_WEBSITE_AUTHOR', 'Author');
define('PP_WEBSITE_LANGUAGE', 'Language');
define('PP_WEBSITE_ADFLY', 'AdfLy');
define('PP_WEBSITE_ADFLY_ENABLE', 'Enable adf.ly links (the user is still able to choose if he wants to disable it)');
define('PP_WEBSITE_ADFLY_ID', 'ID');
define('PP_CATEGORIES', 'Categories');
define('PP_CATEGORIES_ADD', 'Add a category');
define('PP_CATEGORIES_NAME', 'Name');
define('PP_CATEGORIES_REMOVE', 'Remove a category');
define('PP_CATEGORIES_RENAME', 'Rename a category');
define('PP_CATEGORIES_RENAME_NEWNAME', 'New name');
define('PP_CATEGORIES_CATEGORY', 'Category');
define('PP_PROJECTS', 'Projects');
define('PP_PROJECTS_ADD', 'Add a project');
define('PP_PROJECTS_NAME', 'Name');
define('PP_PROJECTS_CATEGORY', 'Category');
define('PP_PROJECTS_LINK', 'Link');
define('PP_PROJECTS_DESCRIPTION', 'Description');
define('PP_PROJECTS_REMOVE', 'Remove a project');
define('PP_PROJECTS_EDIT', 'Edit a project');
define('PP_PROJECTS_PROJECT', 'Project');
define('PP_ADD', 'Add !');
define('PP_REMOVE', 'Remove !');
define('PP_UPDATE', 'Update !');
define('PP_EXPAND', 'Expand');
define('PP_COLLAPSE', 'Collapse');
define('PP_LOGOUT', 'Logout');
define('PP_UPDATE_CHECKING', 'Checking for updates...');
define('PP_UPDATE_AVAILABLE', 'An update is available (v/version/)');
define('PP_UPDATE_NOUPDATE', 'You have the latest version (v/version/)');
define('PP_UPDATE_ERROR', 'An error occurred while checking for updates');
define('PP_MESSAGE_METACHANGED', 'Successfully changed website\'s meta ! If you changed your website\'s language, you have to refresh this page ;)');
define('PP_MESSAGE_ADFLYCHANGED', 'Successfully changed adf.ly preferences !');
define('PP_MESSAGE_CATEGORYADDED', 'Category added !');
define('PP_MESSAGE_CATEGORYREMOVED', 'Category removed.');
define('PP_MESSAGE_CANNOTREMOVE', 'You cannot delete the last category !');
define('PP_MESSAGE_CATEGORYRENAMED', 'Category renamed.');
define('PP_MESSAGE_PROJECTADDED', 'Project added !');
define('PP_MESSAGE_PROJECTREMOVED', 'Project removed.');
define('PP_MESSAGE_PROJECTUPDATED', 'Project updated !');

// Do not edit this line !

define('PP_TRANSLATION_VERSION', 1);
?>
71 changes: 71 additions & 0 deletions include/languages/fr_FR.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php
// Page principale :

define('PP_PROJECT_NAME', 'Nom du projet');
define('PP_PROJECT_LINK', 'Lien');
define('PP_NOPROJECT', 'Rien ici.');
define('PP_NOLINK', 'Ici non plus.');
define('PP_NOCATEGORY', 'Pas de catégorie.');
define('PP_POWEREDBY', 'Propulsé par ' . PP_APP_NAME . ' v' . PP_APP_VERSION . ' by ' . PP_APP_AUTHOR);
define('PP_ADMIN', 'Admin');
define('PP_ENABLE_ADFLY', 'Activer les liens adf.ly');
define('PP_DISABLE_ADFLY', 'Désactiver les liens adf.ly');

// Zone d'administration :

define('PP_ADMINAREA', 'Zone d\'Administration');
define('PP_LOGINPAGE_TITLE', 'Connexion');
define('PP_USERNAME', 'Nom d\'utilisateur');
define('PP_PASSWORD', 'Mot de passe');
define('PP_LOGIN', 'Connexion !');
define('PP_LOGIN_ERROR', 'Nom d\'utilisateur ou mot de passe incorrect !');
define('PP_WEBSITE_CONFIGURATION', 'Configuration du site web');
define('PP_WEBSITE_META', 'Métadonnées du site');
define('PP_WEBSITE_TITLE', 'Titre');
define('PP_WEBSITE_DESCRIPTION', 'Description');
define('PP_WEBSITE_KEYWORDS', 'Mots clés');
define('PP_WEBSITE_AUTHOR', 'Auteur');
define('PP_WEBSITE_LANGUAGE', 'Langage');
define('PP_WEBSITE_ADFLY', 'AdfLy');
define('PP_WEBSITE_ADFLY_ENABLE', 'Activer les liens adf.ly (l\'utilisateur peut encore choisir de les désactiver)');
define('PP_WEBSITE_ADFLY_ID', 'ID');
define('PP_CATEGORIES', 'Catégories');
define('PP_CATEGORIES_ADD', 'Ajouter une catégorie');
define('PP_CATEGORIES_NAME', 'Nom');
define('PP_CATEGORIES_REMOVE', 'Supprimer une catégorie');
define('PP_CATEGORIES_RENAME', 'Renommer une catégorie');
define('PP_CATEGORIES_RENAME_NEWNAME', 'Nouveau nom');
define('PP_CATEGORIES_CATEGORY', 'Catégorie');
define('PP_PROJECTS', 'Projets');
define('PP_PROJECTS_ADD', 'Ajouter un projet');
define('PP_PROJECTS_NAME', 'Nom');
define('PP_PROJECTS_CATEGORY', 'Catégorie');
define('PP_PROJECTS_LINK', 'Lien');
define('PP_PROJECTS_DESCRIPTION', 'Description');
define('PP_PROJECTS_REMOVE', 'Supprimer un projet');
define('PP_PROJECTS_EDIT', 'Éditer un projet');
define('PP_PROJECTS_PROJECT', 'Projet');
define('PP_ADD', 'Ajouter !');
define('PP_REMOVE', 'Supprimer !');
define('PP_UPDATE', 'Mettre à jour !');
define('PP_EXPAND', 'Étendre');
define('PP_COLLAPSE', 'Réduire');
define('PP_LOGOUT', 'Déconnexion');
define('PP_UPDATE_CHECKING', 'Vérification des mises à jour...');
define('PP_UPDATE_AVAILABLE', 'Une mise à jour est disponible (v/version/)');
define('PP_UPDATE_NOUPDATE', 'Vous avez la dernière version (v/version/)');
define('PP_UPDATE_ERROR', 'Une erreur est survenue pendant la vérification de mises à jour');
define('PP_MESSAGE_METACHANGED', 'Métadonnées changées avec succès ! Si vous avez changé de language, veuillez rafraichier la page ;)');
define('PP_MESSAGE_ADFLYCHANGED', 'Paramètres adf.ly changés avec succès !');
define('PP_MESSAGE_CATEGORYADDED', 'Catégorie ajoutée !');
define('PP_MESSAGE_CATEGORYREMOVED', 'Catégorie supprimée.');
define('PP_MESSAGE_CANNOTREMOVE', 'Vous ne pouvez pas supprimer la dernière catégorie !');
define('PP_MESSAGE_CATEGORYRENAMED', 'Catégorie renommée.');
define('PP_MESSAGE_PROJECTADDED', 'Projet ajouté !');
define('PP_MESSAGE_PROJECTREMOVED', 'Projet supprimé.');
define('PP_MESSAGE_PROJECTUPDATED', 'Projet mis à jour !');

// Ne modifiez pas cette ligne !

define('PP_TRANSLATION_VERSION', 1);
?>
10 changes: 5 additions & 5 deletions include/loginform.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
<div class="container">
<form action="admin.php" method="post">
<div class="form-group">
<label for="username">Username</label>
<input name="username" type="text" class="form-control" placeholder="Username">
<label for="username"><?=PP_USERNAME?></label>
<input name="username" type="text" class="form-control" placeholder="<?=htmlspecialchars(PP_USERNAME)?>">
</div>
<div class="form-group">
<label for="password">Password</label>
<input name="password" type="password" class="form-control" placeholder="Password">
<label for="password"><?=PP_PASSWORD?></label>
<input name="password" type="password" class="form-control" placeholder="<?=htmlspecialchars(PP_PASSWORD)?>">
</div>
<input name="method" type="hidden" value="0">
<button type="submit" class="btn btn-primary">Login !</button>
<button type="submit" class="btn btn-primary"><?=PP_LOGIN?></button>
</form>
</div>
20 changes: 12 additions & 8 deletions index.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
<?php
require('include/config.php');
require('include/functions.php');
$settings = load_settings();
include('include/languages/' . $settings['metaLanguage'] . '.php');
/*if(PP_TRANSLATION_VERSION < 1) {
die('Please update your translation !');
}*/
$categories = load_categories();
$categories_num = count($categories);
if($categories_num == 0) {
die('No category.');
die(PP_NOCATEGORY);
}
$projects = load_projects();
$settings = load_settings();
$adfly = $settings['adflyUse'] && (isset($_COOKIE['pp_adfly']) ? $_COOKIE['pp_adfly'] : true);
?>
<!DOCTYPE html>
<html>
<html lang="<?=$settings['metaLanguage']?>">
<head>
<title><?=$settings['metaTitle']?></title>
<meta name="description" content="<?=$settings['metaDescription']?>">
Expand Down Expand Up @@ -44,7 +48,7 @@
<div class="container" id="project-container">
<table class="table table-bordered table-hover">
<thead>
<tr><th>Project's name</th><th>Link</th></tr>
<?='<tr><th>' . PP_PROJECT_NAME . '</th><th>' . PP_PROJECT_LINK . '</th></tr>' . PHP_EOL?>
</thead>
<?php
for($i = 0; $i < $categories_num; $i++) {
Expand All @@ -57,7 +61,7 @@
}
}
if($projects_in_category++ == 0) {
echo ' <tr><td>Nothing here.</td><td>Here either.</td></tr>' . PHP_EOL;
echo ' <tr><td>' . PP_NOPROJECT . '</td><td>' . PP_NOLINK . '</td></tr>' . PHP_EOL;
}
echo ' </tbody>' . PHP_EOL;
}
Expand All @@ -75,8 +79,8 @@
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li><a target="_blank" href="<?='https://github.com/' . PP_APP_AUTHOR . '/' . PP_APP_NAME?>"><img src="assets/favicon.ico"/> <strong>Powered by <?=PP_APP_NAME . ' v' . PP_APP_VERSION . ' by ' . PP_APP_AUTHOR?></strong></a></li>
<li><a href="admin.php"><span class="glyphicon glyphicon-cog" aria-hidden="true"></span> Admin</a></li>
<li><a target="_blank" href="<?='https://github.com/' . PP_APP_AUTHOR . '/' . PP_APP_NAME?>"><img src="assets/favicon.ico"/> <strong><?=PP_POWEREDBY?></strong></a></li>
<li><a href="admin.php"><span class="glyphicon glyphicon-cog" aria-hidden="true"></span> <?=PP_ADMIN?></a></li>
<?=$settings['adflyUse'] ? '<li><a id="toggle-adfly" href="#"></a></li>' . PHP_EOL : PHP_EOL?>
</ul>
</div>
Expand All @@ -99,7 +103,7 @@
$.cookie('pp_adfly', '1');
}
adflyEnabled = $.cookie('pp_adfly') == '1';
toggleAdfly.html('<span class="glyphicon ' + (adflyEnabled ? 'glyphicon-minus" aria-hidden="true"></span> Disable' : 'glyphicon-plus" aria-hidden="true"></span> Enable') + ' adf.ly links');
toggleAdfly.html('<span class="glyphicon ' + (adflyEnabled ? 'glyphicon-minus" aria-hidden="true"></span> <?=htmlspecialchars(PP_DISABLE_ADFLY)?>' : 'glyphicon-plus" aria-hidden="true"></span> <?=PP_ENABLE_ADFLY?>'));
});

toggleAdfly.click(function() {
Expand Down
2 changes: 1 addition & 1 deletion version.update
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1
0.2

0 comments on commit 75661c7

Please sign in to comment.