mirror of
https://github.com/Codiad/Codiad.git
synced 2026-03-24 18:06:50 +01:00
Merge pull request #122 from pataquets/master
Remove trailing whitespace
This commit is contained in:
32
common.php
32
common.php
@@ -2,14 +2,14 @@
|
||||
|
||||
/*
|
||||
* Copyright (c) Codiad & Kent Safranski (codiad.com), distributed
|
||||
* as-is and without warranty under the MIT License. See
|
||||
* as-is and without warranty under the MIT License. See
|
||||
* [root]/license.txt for more. This information must remain intact.
|
||||
*/
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Check Session / Key
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
function checkSession(){
|
||||
// Set any API keys
|
||||
$api_keys = array();
|
||||
@@ -24,31 +24,31 @@
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Get JSON
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
function getJSON($file){
|
||||
$json = file_get_contents(BASE_PATH . "/data/" . $file);
|
||||
$json = str_replace("|*/?>","",str_replace("<?php/*|","",$json));
|
||||
$json = json_decode($json,true);
|
||||
return $json;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Save JSON
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
function saveJSON($file,$data){
|
||||
$data = "<?php/*|" . json_encode($data) . "|*/?>";
|
||||
$write = fopen(BASE_PATH . "/data/" . $file, 'w') or die("can't open file");
|
||||
fwrite($write, $data);
|
||||
fclose($write);
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Format JSEND Response
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
function formatJSEND($status,$data=false){
|
||||
|
||||
|
||||
function formatJSEND($status,$data=false){
|
||||
|
||||
// Success ///////////////////////////////////////////////
|
||||
if($status=="success"){
|
||||
if($data){
|
||||
@@ -56,21 +56,21 @@
|
||||
}else{
|
||||
$jsend = '{"status":"success","data":null}';
|
||||
}
|
||||
|
||||
|
||||
// Error /////////////////////////////////////////////////
|
||||
}else{
|
||||
$jsend = '{"status":"error","message":"'.$data.'"}';
|
||||
}
|
||||
|
||||
|
||||
// Return ////////////////////////////////////////////////
|
||||
return $jsend;
|
||||
|
||||
return $jsend;
|
||||
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Check Function Availability
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
function isAvailable($func) {
|
||||
if (ini_get('safe_mode')) return false;
|
||||
$disabled = ini_get('disable_functions');
|
||||
@@ -82,4 +82,4 @@
|
||||
return true;
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
||||
@@ -26,7 +26,7 @@ class Filemanager {
|
||||
public $controller = "";
|
||||
public $upload_json = "";
|
||||
public $search_string = "";
|
||||
|
||||
|
||||
public $query = "";
|
||||
public $foptions = "";
|
||||
|
||||
@@ -147,7 +147,7 @@ class Filemanager {
|
||||
$output = shell_exec($cmd);
|
||||
$file_arr = explode("\n", $output);
|
||||
$output_arr = array();
|
||||
|
||||
|
||||
error_reporting(0);
|
||||
|
||||
foreach ($file_arr as $i => $fentry) {
|
||||
@@ -372,7 +372,7 @@ class Filemanager {
|
||||
//DEBUG : file_put_contents($this->path.".orig",$fileContents );
|
||||
//DEBUG : file_put_contents($this->path.".patch", $this->patch);
|
||||
}
|
||||
|
||||
|
||||
$writeSuccess = fwrite($file, $this->content);
|
||||
fclose($file);
|
||||
if (! $writeSuccess){
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
/*
|
||||
* Copyright (c) Codiad & Kent Safranski (codiad.com), distributed
|
||||
* as-is and without warranty under the MIT License. See
|
||||
* as-is and without warranty under the MIT License. See
|
||||
* [root]/license.txt for more. This information must remain intact.
|
||||
*/
|
||||
|
||||
@@ -17,30 +17,30 @@ class Project {
|
||||
public $projects = '';
|
||||
public $no_return = false;
|
||||
public $assigned = false;
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// METHODS
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
// -----------------------------||----------------------------- //
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Construct
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
public function __construct(){
|
||||
$this->projects = getJSON('projects.php');
|
||||
if(file_exists(BASE_PATH . "/data/" . $_SESSION['user'] . '_acl.php')){
|
||||
$this->assigned = getJSON($_SESSION['user'] . '_acl.php');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Get First (Default, none selected)
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
public function GetFirst(){
|
||||
|
||||
|
||||
$projects_assigned = false;
|
||||
if($this->assigned){
|
||||
foreach($this->projects as $project=>$data){
|
||||
@@ -56,16 +56,16 @@ class Project {
|
||||
}
|
||||
// Set Sessions
|
||||
$_SESSION['project'] = $this->path;
|
||||
|
||||
|
||||
if(!$this->no_return){
|
||||
echo formatJSEND("success",array("name"=>$this->name,"path"=>$this->path));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Get Name From Path
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
public function GetName(){
|
||||
foreach($this->projects as $project=>$data){
|
||||
if($data['path']==$this->path){
|
||||
@@ -74,11 +74,11 @@ class Project {
|
||||
}
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Open Project
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
public function Open(){
|
||||
$pass = false;
|
||||
foreach($this->projects as $project=>$data){
|
||||
@@ -94,11 +94,11 @@ class Project {
|
||||
echo formatJSEND("error","Error Opening Project");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Create
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
public function Create(){
|
||||
$this->path = $this->SanitizePath();
|
||||
$pass = $this->checkDuplicate();
|
||||
@@ -111,11 +111,11 @@ class Project {
|
||||
echo formatJSEND("error","A Project With the Same Name or Path Exists");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Delete Project
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
public function Delete(){
|
||||
$revised_array = array();
|
||||
foreach($this->projects as $project=>$data){
|
||||
@@ -128,12 +128,12 @@ class Project {
|
||||
// Response
|
||||
echo formatJSEND("success",null);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Check Duplicate
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
public function CheckDuplicate(){
|
||||
$pass = true;
|
||||
foreach($this->projects as $project=>$data){
|
||||
@@ -143,14 +143,14 @@ class Project {
|
||||
}
|
||||
return $pass;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Sanitize Path
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
public function SanitizePath(){
|
||||
$sanitized = str_replace(" ","_",$this->name);
|
||||
return preg_replace('/[^\w-]/', '', $sanitized);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
/*
|
||||
* Copyright (c) Codiad & Kent Safranski (codiad.com), distributed
|
||||
* as-is and without warranty under the MIT License. See
|
||||
* as-is and without warranty under the MIT License. See
|
||||
* [root]/license.txt for more. This information must remain intact.
|
||||
*/
|
||||
|
||||
@@ -36,4 +36,4 @@ session_start();
|
||||
|
||||
require_once("common.php");
|
||||
|
||||
?>
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user