示例#1
0
 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);
    }
    $data['error'] = 'OK';
示例#2
0
	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'];
    }
示例#3
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);
示例#4
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;
 }
示例#5
0
}
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');
    $iC->loadInfos('nom', 'language');
示例#6
0
                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) {
    $data['error'] = $e->getMessage();
}