Exemplo n.º 1
0
function daoUpdateArticle($articleArray)
{
    $articleArray['body'] = makeSafeForDAO($articleArray['body']);
    $articleArray['title'] = makeSafeForDAO($articleArray['title']);
    if ($articleArray['is_draft'] != "NULL") {
        $isdraft = 1;
    } else {
        $isdraft = "NULL";
    }
    $query = "UPDATE articles SET " . "title='" . $articleArray['title'] . "'," . "body='" . $articleArray['body'] . "'," . "category=" . $articleArray['category'] . "," . "date_posted='" . $articleArray['date_posted'] . "'," . "time_posted='" . $articleArray['time_posted'] . "'," . "language=" . $articleArray['language'] . "," . "is_draft=" . $articleArray['is_draft'] . " WHERE articleid = " . $articleArray['articleid'] . ";";
    debug($query);
    $result = insertRow($query);
    if ($result) {
        return 1;
    } else {
        return false;
    }
}
Exemplo n.º 2
0
function textSearchService($text, $partialmatch, $author, $checkcomments)
{
    if (strlen($text) < 3) {
        return NULL;
    }
    $text = makeSafeForDAO($text);
    $selectfrom = "SELECT * FROM articles ";
    $where = "WHERE body LIKE '%" . $text . "%' AND is_deleted IS NULL AND is_draft IS NULL ";
    $orderby = " ORDER BY date_posted DESC, time_posted DESC;";
    $findWordAlone = "| " . $text . "[ !?,.:;'/)]|i";
    $findWordAnywhere = "|" . $text . "|i";
    if ($partialmatch == 0) {
        $pattern = $findWordAlone;
    } else {
        $pattern = $findWordAnywhere;
    }
    if ($author == "0") {
    } else {
        $where .= " AND author_username = '******' ";
    }
    if ($checkcomments == "0") {
        $where .= " AND comment_to IS NULL";
    }
    $query = $selectfrom . $where . $orderby;
    $newtable = array();
    $table = getTable($query);
    $num_rows = getRowsAffected($table);
    if ($table && $num_rows > 0) {
        while ($row = getNextRow($table)) {
            if (preg_match($pattern, $row['body'])) {
                $newtable[] = $row;
                // Add row to array
            }
        }
        return $newtable;
    } else {
        return NULL;
    }
}