Exemple #1
0
     }
     header('Location:index.php?p=' . PAGE_ID_USERS);
     break;
     //////// EDIT USER
 //////// EDIT USER
 case 'edituser':
     $u = array('user_id' => @$_POST['user_id'], 'user_name' => @$_POST['user_name'], 'user_password' => @$_POST['user_password'], 'user_email' => @$_POST['user_email']);
     $error = null;
     if (!empty($u['user_name'])) {
         // if new user then password must be set
         if (!($u['user_id'] > 0) && empty($u['user_password'])) {
             $error = 'You must specify a password !';
         } else {
             $result = DBHelper::updateUser($u['user_id'] > 0 ? $u['user_id'] : null, $u['user_name'], $u['user_password'], $u['user_email']);
             if (!$result) {
                 $error = 'Unable to update user ! ' . DBHelper::getLastError();
             }
         }
     } else {
         $error = 'Username can not be empty !';
     }
     if ($error != null) {
         Helper::pushAlert(ALERT_ERROR, $error);
     } else {
         Helper::pushAlert(ALERT_SUCCESS, 'User updated with success !');
     }
     header('Location:index.php?p=' . PAGE_ID_USERS);
     break;
     //////// GET NEW ISSUES BOX
 //////// GET NEW ISSUES BOX
 case 'getnewreports':
Exemple #2
0
            break;
        }
    }
}
// if data not empty then store into DB
if (!empty($data)) {
    Debug::logi("Seems to be a valid request... Try to decode JSON and save to DB.", 'REPORT');
    $json = json_decode($data, true);
    // check if device is in exception list
    if (isset($json['device_id']) && !empty($json['device_id']) && $cfg->isInReportExceptionDevices($json['device_id'])) {
        Debug::logi("Report ignored, device " . $json['device_id'] . " is in exception list.");
        exit;
    }
    // open db connection
    DBHelper::open();
    $values = ReportHelper::buildMySQLValuesArr($json);
    $result = DBHelper::insertReport($values);
    if (!$result) {
        Debug::loge('Inserting report data failed ! ' . DBHelper::getLastError(), 'REPORT');
        Debug::loge('Report content ' . print_r($values, true), 'REPORT');
    } else {
        Debug::logi('Report inserted with success !', 'REPORT');
    }
    if ($cfg->sendMailOnReportReceived()) {
        $package = explode('.', $json['PACKAGE_NAME']);
        MailHelper::sendMail($cfg->getReportMailRecipients(), '[MABL] New ' . (isset($json['IS_SILENT']) && $json['IS_SILENT'] > 0 ? 'SILENT ' : '') . 'report received for ' . $package[count($package) - 1] . ' !', ReportHelper::createMailContent(!$result, $package, $json));
    }
    DBHelper::close();
} else {
    Debug::loge('Invalid report request data ! ' . print_r($_REQUEST, true), 'REPORT');
}
Exemple #3
0
        }
        // insert new issue
        echo '<i style="padding-left:30px;" >|_ Insert issue ' . $k . ' ... </i>';
        $issueId = DBHelper::insertIssue($values);
        // update reports
        if ($issueId > 0) {
            echo '<i>OK</i><br/>';
            echo '<i style="padding-left:30px;" >|_ Update reports in (' . implode(', ', $issue['reports']) . ') with issue id ' . $issueId . ' ... </i>';
            if (DBHelper::updateReportsIssue($issue['reports'], $issueId)) {
                echo '<i>OK</i><br/>';
            } else {
                echo '<i style="color:red" >FAILED</i><br/>';
            }
        } else {
            echo '<i style="color:red" >FAILED</i><br/>';
            echo '<i style="padding-left:30px; color:red; font-weight:bold;" >' . DBHelper::getLastError() . '</i><br/>';
        }
    }
} catch (Exception $e) {
    echo '<b style="padding-left:30px; color:red;" >' . $e->getMessage() . '</b><br/>';
    exit;
}
echo '<b>Step 5.</b> ... OK<br/>';
echo '<b>Step 6.</b> Create database triggers ... ';
$res = DBHelper::exec($sql[1], true);
if ($res != null) {
    echo '<br/><b style="padding-left:30px; color:red;" >' . $res . '</b>';
    exit;
}
DBHelper::clearStoredResults();
// count triggers
Exemple #4
0
}
$mUpdateHelper->exitOnError();
$mUpdateHelper->printStartNextStepMsg('Insert issues');
try {
    foreach ($issues as $k => $issue) {
        $values = array(ISSUE_KEY => $k, ISSUE_DATETIME => $issue['datetime'], ISSUE_CAUSE => $issue['cause'], ISSUE_STATE => $issue['state']);
        // check cause length (<255)
        if (strlen($values[ISSUE_CAUSE]) > 254) {
            $values[ISSUE_CAUSE] = substr($values[ISSUE_CAUSE], 0, 250) . '...';
        }
        // insert new issue
        $mUpdateHelper->printStartSubStepMsg('Insert issue ' . $k);
        $issueId = DBHelper::insertIssue($values);
        // update reports
        if ($issueId > 0) {
            $mUpdateHelper->printEndSubStepMsg(true);
            $mUpdateHelper->printStartSubStepMsg('Update reports in (' . implode(', ', $issue['reports']) . ') with issue id ' . $issueId);
            if (DBHelper::updateReportsIssue($issue['reports'], $issueId)) {
                $mUpdateHelper->printEndSubStepMsg(true);
            } else {
                $mUpdateHelper->printEndSubStepMsg(false);
            }
        } else {
            $mUpdateHelper->printEndSubStepMsg(false, DBHelper::getLastError());
        }
    }
} catch (Exception $e) {
    $mUpdateHelper->printStepMsg($e->getMessage(), true);
}
$mUpdateHelper->printEndStepMsg(true, null, true);
$mUpdateHelper->end();
Exemple #5
0
         if (!empty($issueIds)) {
             if (DBHelper::updateIssuesState(explode(',', $issueIds), $state)) {
                 echo 'O:';
                 $state = new IssueState($state);
                 $priority = new IssuePriority();
                 $label = $state->getLabel(true);
                 $issueIds = explode(',', $issueIds);
                 $sep = '';
                 foreach ($issueIds as $issueId) {
                     $res = DbHelper::selectRow(TBL_ISSUES, ISSUE_ID . '=' . $issueId, ISSUE_PRIORITY);
                     $priority->setPriority($res[0][0]);
                     echo $sep, $label, '|', IssueHelper::getHiliteBgColorClass($state, $priority), '|', strtolower($state->getName());
                     $sep = '||';
                 }
             } else {
                 echo "K:Error occured while trying to update issue(s) state :\n\n" . DBHelper::getLastError();
             }
         } else {
             echo 'K:Issue id(s) is not valid !';
         }
     } else {
         echo 'K:This state is not valid and can\'t be applyed !';
     }
     break;
     //////// UPDATE ISSUES PRIORITY
 //////// UPDATE ISSUES PRIORITY
 case 'setissuespriority':
     $issueIds = @$_POST['issueIds'];
     $priority = new IssuePriority(@$_POST['priority']);
     if (!empty($issueIds)) {
         DBHelper::updateIssuesPriority(explode(',', $issueIds), $priority->getId());