示例#1
0
	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'];
    }
} catch (Exception $e) {
示例#2
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;
 }
示例#3
0
     $iL->setInfo('name', $label['name']);
     $iL->setInfo('color', $label['color']);
     $iL->save('id', 'this', false, false);
     $data['newLabel'] = $iL->getInfos();
     $data['error'] = "OK";
     $data['message'] = $LANG['New_label_OK'];
 }
 if ($action === 'addDev') {
     if (!is_array($dev)) {
         throw new Exception("addDev: Dev must be an array!");
     }
     $iD = new Infos('t_devs');
     $iD->setInfo('pseudo', $dev['pseudo']);
     $iD->setInfo('mail', $dev['mail']);
     $iD->save('id', 'this', false, false);
     $data['newDev'] = $iD->getInfos();
     $data['error'] = "OK";
     $data['message'] = $LANG['New_dev_OK'];
 }
 if ($action === 'updateSetting') {
     if (!isset($type)) {
         throw new Exception("Missing the type of setting to update (labels, devs, projectInfo?)");
     }
     if ($type === "projectInfo") {
         $iC = new Infos('t_config');
         foreach ($item as $pInfK => $pInfV) {
             if ($pInfK === "password_access") {
                 continue;
             }
             if ($pInfK === "api_access") {
                 continue;
示例#4
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');
    $language = $iC->getInfos('value');