示例#1
0
            break;
        case 'short':
            $oBrick->value = htmlspecialchars(post('value'));
            break;
        case 'rich':
            $oBrick->value = clean_html(post('value'));
            break;
    }
    if (!$oBrick->save()) {
        die("Can't save !");
    }
    DomParser::destroyCache();
    $app->redirect(str_replace('http://' . $utils->globals->server('server_name') . '/', '/', $utils->globals->server('http_referer')));
});
$app->post('/admin/save/infos/:ref/', 'admin_middleware', function ($sRef) use($app) {
    $oInfos = new Infos($sRef);
    $oInfos->title = post('title');
    $oInfos->description = post('description');
    $oInfos->keywords = post('keywords');
    if (!$oInfos->save()) {
        die("Can't save !");
    }
    DomParser::destroyCache();
    $app->redirect(str_replace('http://' . $utils->globals->server('server_name') . '/', '/', $utils->globals->server('http_referer')));
});
$app->get('/admin/revert/:ref/:time/', 'admin_middleware', function ($sRef, $iTime) use($app) {
    // trace( $sRef ); die();
    $oBrick = Brick::get($sRef);
    switch ($oBrick->type) {
        case 'gallery':
            $oBrick->alt = $oBrick->getVersion('alt', $iTime, false);
示例#2
0
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU Affero General Public License for more details.

 You should have received a copy of the GNU Affero General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
error_reporting(E_ERROR);
require '../init.php';
$data['error'] = "error";
$data['message'] = "Unknown error";
try {
    if (!$authAdmin) {
        throw new Exception("Access denied. Please login as an Admin to continue.");
    }
    $bdd->query("TRUNCATE `t_bugs`; TRUNCATE `t_comments`;");
    $iC = new Infos('t_config');
    $iC->loadInfos('nom', 'project_name');
    $iC->setInfo('value', 'Your project');
    $iC->save('id', 'this', false, false);
    $iC->loadInfos('nom', 'git_repo');
    $iC->setInfo('value', 'git://your/git/repo/url.git');
    $iC->save('id', 'this', false, false);
    $iC->loadInfos('nom', 'project_type');
    $iC->setInfo('value', 'open-source');
    $iC->save('id', 'this', false, false);
    foreach (glob(DATA_PATH . '*') as $screen) {
        if (is_dir($screen)) {
            continue;
        }
        unlink($screen);
    }
示例#3
0
		<h2>Listing</h2>
		<?php 
$table = "users";
?>
		<h4>Table "<?php 
echo $table;
?>
"</h4>
		<pre><?php 
try {
    $l = new Listing();
    $liste = $l->getList($table);
    $liste = $l->reindexList('id');
    //			Listing::array_reindex_by($liste, 'ref');
    print_r($liste);
    var_dump(Infos::colExists($table, 'name'));
} catch (Exception $e) {
    echo '<span class="red"><b>' . $e->getMessage() . '</b></span><br />';
    echo $e->getTraceAsString();
}
?>
</pre>
	</section>
	<section style="max-width: 50%;">
		<h2>Infos</h2>
		<h4>Table "users", action : update entry</h4>
		<pre><?php 
try {
    //			$i = new Infos("users");
    //			$i->loadInfos('id', 6);
    //			$newInfos = Array("name"=>"Alex", "pseudo"=>"AKtsuki", "age"=>29 );
 /**
  * Renvoie un tableau où l'index est $wantedIndex au lieu de 0,1,2,3,...
  * @param STRING $wantedIndex Le nom du champ à utiliser comme index
  * @return ARRAY Le nouveau tableau avec l'index remplacé, FALSE si erreur
  */
 public function reindexList($wantedIndex = 'id')
 {
     if ($this->result == null || empty($this->result)) {
         return false;
     }
     if (!Infos::colIndex_isUnique($this->table, $wantedIndex)) {
         throw new Exception("Listing::reindexList() : '{$wantedIndex}' is not an unique index for table '{$this->table}'");
     }
     $newTableau = $this->result;
     Listing::array_reindex_by($newTableau, $wantedIndex);
     return $newTableau;
 }
示例#5
0
	published by the Free Software Foundation, either version 3 of the
	License, or (at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU Affero General Public License for more details.

	You should have received a copy of the GNU Affero General Public License
	along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
require '../init.php';
$data['auth'] = 'error';
$data['message'] = '';
try {
    $iC = new Infos('t_config');
    $iC->loadInfos('nom', 'password_access');
    $pw = $iC->getInfos('value');
    $post = json_decode(file_get_contents("php://input"), true);
    if (!is_array($post)) {
        throw new Exception("Missing password postData.");
    }
    extract($post);
    if (md5(PASSWORD_SALT . $passw) == $pw) {
        $_SESSION['authAdmin'] = PASSWORD_SALT . $pw;
        setcookie('catch_bug', PASSWORD_SALT . $pw, time() + 15 * 24 * 3600, "/", null, false, false);
        // Durée du cookie : 15 jours
        $data['auth'] = 'OK';
        $data['message'] = $LANG['Welcome'];
    } else {
        $data['message'] = $LANG['Err_connect_password'];
示例#6
0
 /**
  * Send an email notification to devs
  * @param STRING $type The type of notification to send ('new', 'close', 'comment', or 'assign')
  * @return INt Number of email actually sent
  */
 public function notify($type)
 {
     global $LANG;
     $iC = new Infos('t_config');
     $iC->loadInfos('nom', 'enable_notify');
     if ($iC->getInfos('value') == 0) {
         return 0;
     }
     $iC->loadInfos('nom', 'project_name');
     $project_name = $iC->getInfos('value');
     $iC->loadInfos('nom', 'language');
     $language = $iC->getInfos('value');
     $mail = new PHPMailer(true);
     $mail->isMail();
     if ($language === 'Francais') {
         $mail->setLanguage('fr', INSTALL_PATH . 'language/phpMailer/');
     }
     $mail->CharSet = 'UTF-8';
     $mail->From = "*****@*****.**";
     $mail->FromName = "Bughunter {$project_name}";
     $mail->isHTML(true);
     switch ($type) {
         case "new":
             $subject = $LANG['Notify_newBug_subject'];
             $bodyTxt = $LANG['Notify_newBug_body'];
             break;
         case "close":
             $subject = $LANG['Notify_killBug_subject'];
             $bodyTxt = $LANG['Notify_killBug_body'];
             break;
         case "comment":
             $subject = $LANG['Notify_comment_subject'];
             $bodyTxt = $LANG['Notify_comment_body'];
             break;
         case "assign":
             $subject = $LANG['Notify_assign_subject'];
             $bodyTxt = $LANG['Notify_assign_body'];
             break;
         default:
             throw new Exception("Notification type unknown.");
     }
     $bugData = $this->getBugData(true);
     $subject = preg_replace('/\\{\\{BUG_ID\\}\\}/', $bugData['id'], $subject);
     $mail->Subject = $subject;
     $template = file_get_contents(INSTALL_PATH . 'mails/template.html');
     $html = preg_replace('/\\{\\{SUBJECT\\}\\}/', $subject, $template);
     $html = preg_replace('/\\{\\{BODY\\}\\}/', $bodyTxt, $html);
     $html = preg_replace('/\\{\\{DATE\\}\\}/', date('Y-m-d'), $html);
     $html = preg_replace('/\\{\\{PROJECT\\}\\}/', $project_name, $html);
     $html = preg_replace('/\\{\\{URL_BH\\}\\}/', preg_replace('/\\/actions$/', '', get_url()), $html);
     $html = preg_replace('/\\{\\{REPORTER\\}\\}/', $bugData['author'], $html);
     $html = preg_replace('/\\{\\{BUG_ID\\}\\}/', $bugData['id'], $html);
     $html = preg_replace('/\\{\\{BUG_TITLE\\}\\}/', $bugData['title'], $html);
     $html = preg_replace('/\\{\\{BUG_DESCR\\}\\}/', $bugData['description'], $html);
     $html = preg_replace('/\\{\\{BUG_LABEL\\}\\}/', $bugData['label']['name'], $html);
     if ($type === "comment") {
         $comm = end($bugData['comment']);
         $html = preg_replace('/\\{\\{COMM_AUTHOR\\}\\}/', $comm['dev']['pseudo'], $html);
         $html = preg_replace('/\\{\\{COMM_MESSAGE\\}\\}/', nl2br($comm['message']), $html);
     }
     $l = new Liste();
     $l->addFiltre('id', '>', '0');
     $l->addFiltre('notify', '=', '1');
     $l->getListe('t_devs');
     $devs = $l->simplifyList();
     if (!$devs) {
         return 0;
     }
     $countSent = 0;
     foreach ($devs as $dev) {
         if ($type === "assign" && $bugData['FK_dev_ID'] != $dev['id']) {
             continue;
         }
         $mail->Body = $html;
         $mail->addAddress($dev['mail']);
         if ($mail->send()) {
             $countSent++;
         }
         $mail->clearAddresses();
         //			file_put_contents(INSTALL_PATH.'data/debugMail_'.$dev['pseudo'].'.html', $html);
     }
     return $countSent;
 }
示例#7
0
        }
        if (strlen($newPW) < 4) {
            throw new Exception($LANG['Err_PW_too_short']);
        }
        $newPass = md5(PASSWORD_SALT . $newPW);
        $iC = new Infos('t_config');
        $iC->loadInfos('nom', 'password_access');
        $iC->setInfo('value', $newPass);
        $iC->save('id', 'this', false, false);
        $data['error'] = "OK";
        $data['message'] = $LANG['Password_change_OK'];
    }
    if ($action === 'updateLanguage') {
        if (!isset($newLang)) {
            throw new Exception("Missing language to change!");
        }
        $iC = new Infos('t_config');
        $iC->loadInfos('nom', 'language');
        $iC->setInfo('value', $newLang);
        $iC->save('id', 'this', false, false);
        $data['error'] = "OK";
        $data['message'] = $LANG['Language_change_OK'];
    }
} catch (Exception $e) {
    $data['message'] = $e->getMessage();
}
header('HTTP/1.1 200 OK');
header('Content-type: application/json; charset=UTF-8');
echo ")]}',\n";
// Pour sécu anti injection JSONP
echo json_encode($data, JSON_UNESCAPED_UNICODE);
示例#8
0
 public function __construct()
 {
     /// Execute stuff automagically
     new Admin();
     if (isset($_GET['j'])) {
         switch ($_GET['j']) {
             case "Pag":
                 $m = new Menu();
                 $p = new Board();
                 $ap = new AdminPanel();
                 echo "<div id='menu' class='menu'>\n";
                 $m->toHTML();
                 echo "</div>\n";
                 echo "<div class='panel'>\n";
                 $p->toHTML();
                 echo "</div>\n";
                 echo "<div class='image_panel hidden'>\n";
                 echo "</div>\n";
                 if (CurrentUser::$admin) {
                     echo "<div class='infos'>\n";
                     $ap->toHTML();
                     echo "</div>\n";
                 }
                 break;
             case "Log":
                 $p = new LoginPage();
                 $p->toHTML();
                 break;
             case "Reg":
                 $p = new RegisterPage();
                 $p->toHTML();
                 break;
             case "Pan":
                 if (is_file(CurrentUser::$path)) {
                     $b = new ImagePanel(CurrentUser::$path);
                     $b->toHTML();
                 } else {
                     $b = new Board(CurrentUser::$path);
                     $b->toHTML();
                 }
                 break;
             case "Men":
                 $m = new Menu();
                 $m->toHTML();
                 break;
             case "Pan":
                 $f = new AdminPanel();
                 $f->toHTML();
                 break;
             case "Inf":
                 $f = new Infos();
                 $f->toHTML();
                 break;
             case "Jud":
                 $j = new Judge(CurrentUser::$path);
                 $j->toHTML();
                 break;
             case "Acc":
                 $f = new Group();
                 $f->toHTML();
                 break;
             case "Comm":
                 $f = new Comments(CurrentUser::$path);
                 $f->toHTML();
                 break;
             default:
                 break;
         }
     }
 }
 /**
  * Ajoute une colonne dans une table de la base de données
  * @param STRING $table Le nom de la table
  * @param STRING $colName Le nom de la nouvelle colonne
  * @param STRING $colType Le type de colonne à créer (default "VARCHAR(64)")
  * @param STRING $defaultVal La valeur par défaut pour la colonne (optionnel, et inutile pour le type "TEXT")
  * @return BOOLEAN TRUE si succès, FALSE si erreur.
  */
 public static function addNewCol($table = '', $colName = '', $colType = 'VARCHAR(64)', $defaultVal = "")
 {
     if ($table == '') {
         throw new Exception("Infos::addNewCol() : Missing table name");
     }
     if ($colName == '') {
         throw new Exception("Infos::addNewCol() : Missing column name");
     }
     if (Infos::colExists($table, $colName)) {
         throw new Exception("Infos::addNewCol() : This column already exists");
     }
     $pdoTmp = Listing::newPDO();
     $pdoDriver = $pdoTmp->getAttribute(PDO::ATTR_DRIVER_NAME);
     $extraReq = "";
     if (preg_match('/CHAR|TEXT/i', $colType) && $pdoDriver !== 'sqlite') {
         $extraReq = "CHARACTER SET utf8 COLLATE utf8_general_ci ";
     }
     $extraReq .= "NOT NULL";
     if (!preg_match('/TEXT/i', $colType)) {
         $extraReq .= " DEFAULT '{$defaultVal}'";
     }
     $sqlAlter = "ALTER TABLE `{$table}` ADD `{$colName}` {$colType} {$extraReq}";
     $a = $pdoTmp->prepare($sqlAlter);
     return $a->execute();
 }
示例#10
0
    require_once $classname . '.class.php';
}
spl_autoload_register('autoload');
// PDO INIT
define("DSN", 'mysql:dbname=' . BASE . ';host=' . HOST);
try {
    $bdd = new PDO(DSN, USER, PASS, array(PDO::ATTR_PERSISTENT => true));
    $bdd->query("SET NAMES 'utf8'");
    $bdd->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    global $bdd;
} catch (Exception $e) {
    die('{"error":"PDO connection error: ' . $e->getMessage() . '"}');
}
// CHECK IF ADMIN SESSION STILL ACTIVE
try {
    $iC = new Infos('t_config');
    $iC->loadInfos('nom', 'password_access');
    $pw = $iC->getInfos('value');
    $authAdmin = false;
    if (isset($_SESSION['authAdmin'])) {
        if ($_SESSION['authAdmin'] === PASSWORD_SALT . $pw) {
            $authAdmin = true;
        }
    } elseif (isset($_COOKIE['catch_bug'])) {
        if ($_COOKIE['catch_bug'] === PASSWORD_SALT . $pw) {
            $_SESSION['authAdmin'] = PASSWORD_SALT . $pw;
            $authAdmin = true;
        }
    }
    $iC->loadInfos('nom', 'api_access');
    $api_access = $iC->getInfos('value');
示例#11
0
 /**
  * Ajoute une colonne dans une table de la base de données
  * @param STRING $table Le nom de la table
  * @param STRING $row Le nom de la nouvelle colonne
  * @param STRING $typeRow Le type de colonne à créer (default "VARCHAR(64)"
  * @param STRING $defaultVal La valeur par défaut pour la colonne (optionnel, et inutile pour le type "TEXT")
  * @return BOOLEAN TRUE si succès, FALSE si erreur.
  */
 public static function addNewCol($table = '', $row = '', $typeRow = 'VARCHAR(64)', $defaultVal = "")
 {
     if ($table == '') {
         throw new Exception("Infos::addNewCol() : Il manque le nom de la table");
     }
     if ($row == '') {
         throw new Exception("Infos::addNewCol() : Il manque le nom de la colonne");
     }
     if (Infos::colExiste($table, $row)) {
         throw new Exception("Infos::addNewCol() : Cette colonne existe déjà");
     }
     $extraReq = "";
     if (preg_match('/CHAR|TEXT/i', $typeRow)) {
         $extraReq = "CHARACTER SET utf8 COLLATE utf8_general_ci ";
     }
     $extraReq .= "NOT NULL";
     if (!preg_match('/TEXT/i', $typeRow)) {
         $extraReq .= " DEFAULT '{$defaultVal}'";
     }
     $pdoTmp = new PDO(DSN, USER, PASS, array(PDO::ATTR_PERSISTENT => false));
     $pdoTmp->query("SET NAMES 'utf8'");
     $pdoTmp->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
     $sqlAlter = "ALTER TABLE `{$table}` ADD `{$row}` {$typeRow} {$extraReq}";
     $a = $pdoTmp->prepare($sqlAlter);
     return $a->execute();
 }
示例#12
0
            $resp = shell_exec($command);
            if ($resp) {
                throw new Exception("SQL import failed. Please do it manually.");
            }
        }
        $data['nextStep'] = 3;
        $data['message'] = "Database created.";
        if ($DBexists && $DBstructOk) {
            $data['message'] = "The database '" . BASE . "' already exists!";
        }
    } elseif ($step === 3) {
        if (!is_array($infos)) {
            throw new Exception("Missing SQL connection informations.");
        }
        require '../init.php';
        $iC = new Infos('t_config');
        foreach ($infos as $k => $v) {
            $iC->loadInfos('nom', $k);
            if ($k === 'password_access') {
                $iC->setInfo('value', md5(PASSWORD_SALT . $v));
            } else {
                $iC->setInfo('value', $v);
            }
            $iC->save('id', 'this', false, false);
        }
        $data['nextStep'] = 4;
        $data['message'] = "Project informations saved.";
    } else {
        throw new Exception("Unkown installation step!");
    }
} catch (Exception $e) {