Exemplo n.º 1
0
<?php

if ($_POST) {
    $changeStatusRecord = isset($_POST['changeStatusRecord']) ? $_POST['changeStatusRecord'] : false;
    if ($changeStatusRecord) {
        checkInOrOut($mysqli, $_POST['changeStatusRecord']);
        showResult($mysqli, "ShowAll");
    }
    $deleteAllRecords = isset($_POST['deleteAllRecords']) ? $_POST['deleteAllRecords'] : false;
    if ($deleteAllRecords) {
        clearTable($mysqli);
        showResult($mysqli, "ShowAll");
    }
    $filterResult = isset($_POST['filterResult']) ? $_POST['filterResult'] : false;
    if ($filterResult) {
        showResult($mysqli, $_POST['filterSelectOption']);
    }
    $addRecord = isset($_POST['addRecord']) ? $_POST['addRecord'] : false;
    if ($addRecord) {
        $missing = "";
        if (empty($_POST["media_title"]) || !isset($_POST["media_title"])) {
            $missing = $missing . " [title] ";
        }
        /*if(empty($_POST["media_category"]) || !isset($_POST["media_category"]) ){
        			$missing = $missing . " [category] ";
        		}*/
        if (empty($_POST["media_length"]) || !isset($_POST["media_length"])) {
            $missing = $missing . " [length] ";
        }
        if (!is_numeric($_POST["media_length"]) || $_POST["media_length"] < 1) {
            $missing = $missing . " [length must be a positive number]";
    $sql = "DELETE FROM wiki_dailychanges";
    wfQuery($sql, DB_MASTER);
}
function getUsers()
{
    $users = array();
    $sql = "SELECT user_name, user_real_name, user_email from user";
    $res = wfQuery($sql, DB_SLAVE);
    while ($line = wfFetchObject($res, DB_SLAVE)) {
        if (strlen($line->user_email) == 0) {
            continue;
        }
        if (strlen($line->user_real_name) > 0) {
            $users[$line->user_real_name] = $line->user_email;
        } else {
            $users[$line->user_name] = $line->user_email;
        }
    }
    wfFreeResult($res, DB_SLAVE);
    return $users;
}
$numberOfRows = 0;
$content = createMailContent($numberOfRows);
if ($numberOfRows > 0) {
    $users = getUsers();
    foreach ($users as $key => $value) {
        $sendContent = str_replace('%USER_NAME%', $key, $content);
        sendMail($value, $from, $subject, $sendContent);
    }
    clearTable();
}
Exemplo n.º 3
0
function clearDb($tableList)
{
    foreach ($tableList as $table) {
        clearTable($table);
    }
}