function parse_rows($db)
{
    $stmt = $db->prepare("SELECT * FROM comments WHERE comment ~ '.*>>[0-9]+#c?[0-9]+.*' AND posted > now() - interval '3 months'");
    $stmt->execute();
    while ($row = $stmt->fetch()) {
        $matches = array();
        if (preg_match_all("/>>(\\d+)(#c?)(\\d+)/", $row['comment'], $matches)) {
            for ($i = 0; $i < count($matches[0]); $i++) {
                $image_id = $matches[1][$i];
                $sep = $matches[2][$i];
                $comment_id = $matches[3][$i];
                $user = get_user_from_comment($db, $comment_id);
                $base = $row['comment'];
                if (!is_null($user)) {
                    $new = str_replace(">>{$image_id}{$sep}{$comment_id}", "[url=site://post/view/{$image_id}#c{$comment_id}]@{$user}[/url]", $base);
                    print "\n\n----\n{$row['id']}\n--\n{$base}\n--\n{$new}";
                    update_comment($db, $row['id'], $new);
                }
            }
        }
    }
}
Example #2
0
<?php

$app->get('/comments/unit/:id', function ($id) {
    include_once 'libs/comment.php';
    echo json_encode(fetch_comments_unit($id));
});
$app->post('/comments/unit/', function ($id) {
    include_once 'libs/comment.php';
    $request = get_request_json();
    echo json_encode(insert_comment($userId, $request['comment'], $request['unit']));
});
$app->put('/comments/unit/', function ($id) {
    include_once 'libs/comment.php';
    $request = get_request_json();
    echo json_encode(update_comment($userId, $request['comment'], $request['unit']));
});
$app->post('/comments/unit/response', function ($id) {
    include_once 'libs/comment.php';
    $request = get_request_json();
    echo json_encode(insert_response($userId, $request['comment'], $request['unit']));
});
$app->post('/comments/rate', function ($id) {
    include_once 'libs/comment.php';
    $request = get_request_json();
    echo json_encode(rate_comment($userId, $request['comment'], $request['unit']));
});
     case 'update-album':
         // Update the album information
         if (!isset($_REQUEST['cancel'])) {
             $action_result = update_album($_POST['pid'], $_POST['name'], $_POST['description'], $_POST['thumbnail_id']);
         }
         break;
     case 'update-collection':
         // Update the collection information
         if (!isset($_REQUEST['cancel'])) {
             $action_result = update_collection($_POST['pid'], $_POST['name'], $_POST['description'], $_POST['thumbnail_id']);
         }
         break;
     case 'update-comment':
         // Update the comment information
         if (!isset($_REQUEST['cancel'])) {
             $action_result = update_comment($_POST['pid'], $_POST['author'], $_POST['email'], $_POST['url'], $_POST['comment']);
         }
         break;
     case 'add-collection':
         // Add a new collection
         $action_result = add_collection($_POST['name'], $_POST['description']);
         break;
     case 'add-album':
         // Add a new album
         $action_result = add_album($_POST['name'], $_POST['description'], $_POST['parent_collection']);
         break;
 }
 if (!empty($action_result['errors'])) {
     // If there are any errors from the actions above, display the errors for the user
     $output .= "\n\t" . '<p class="errors">' . $action_result['errors'] . '</p>' . "\n";
 } elseif (!empty($action_result['output'])) {
Example #4
0
                 //adding
                 $SCION->path = array(ACCOUNT_DISP, EVENT_DISP, DATE_DISP, COMMENTS_DISP);
             }
             $SCION->path[] = SESSIONS_DISP;
             break;
         case "AC":
             //account
             $SCION->path[] = ACCOUNT_DISP;
             break;
         case "EV":
             //event
             $SCION->path[] = EVENT_DISP;
             break;
         case "CM":
             //comment
             update_comment($SCION, $response);
             echo $response;
             break 3;
             //break out of here and the SCION state gate
     }
     $SCION->path[] = BUTTON_DISP;
     $response .= "document.getElementById('BN_" . $SCION->row . "')";
     $response .= ".innerHTML = \"<button type='button' name='btnReset' onclick='Reset()'>Cancel</button>\";\n";
     $SCION->status = array_shift($SCION->path);
     break 1;
     //go back around
 //go back around
 case ACCOUNT_DISP:
     if (account_send($SCION, $response) == 1) {
         account_select($SCION, $response, $SCION->account_id);
         $SCION->status = array_shift($SCION->path);
Example #5
0
                if ($performanceId != -1) {
                    $redirect_page = "performance.php?action=details&id=" . $performanceId;
                } else {
                    $redirect_page = 'artists.php?action=list';
                }
            }
            if ($commentId == -1) {
                if ($artistId != -1) {
                    $ret = add_comment_for_artist($_SESSION['username'], $artistId, $comment, $postDate);
                } else {
                    if ($performanceId != -1) {
                        $ret = add_comment_for_performance($_SESSION['username'], $performanceId, $comment, $postDate);
                    }
                }
            } else {
                $ret = update_comment($commentId, $artistId, $performanceId, $comment);
            }
            if (!$has_error) {
                header('Location: ' . $redirect_page, true);
                die;
            }
        }
    }
    ?>
	<form action="" method="post" style="display: block;">
		<div class="form-group">
			<div class="input-group">
				<span class="input-group-addon" id="basic-addon3">Comment</span>
				<textarea name="comment" id="comment" tabindex="1" class="form-control" placeholder="Comment Text"><?php 
    echo $comment;
    ?>
Example #6
0
<?php

include "../model/commentdb.php";
if ($_POST['method'] == "insert") {
    insert_comment();
}
if ($_POST['method'] == "getall") {
    get_comment();
}
if ($_POST['method'] == "getImgComm") {
    get_imgComment();
}
if ($_POST['method'] == "getUserComm") {
    get_userComment();
}
if ($_POST['method'] == "deleteComment") {
    delete_comment();
}
if ($_POST['method'] == "updateComment") {
    update_comment();
}
Example #7
0
            $result = run_query($query);
            $num_items++;
        }
        $output .= "<p class=\"actions\">" . sprintf(plog_tr('You have approved %d comment(s) successfully.'), $num_items) . "</p>";
    } else {
        $output .= "<p class=\"errors\">" . plog_tr('Nothing selected to approve!') . "</p>";
    }
}
if (isset($_REQUEST["action"])) {
    if ($_REQUEST["action"] == "edit-comment") {
        // show the edit form
        $output .= edit_comment_form($_REQUEST["pid"]);
    } else {
        if ($_REQUEST["action"] == "update-comment") {
            // update comment in database
            $result = update_comment($_POST["pid"], $_POST["author"], $_POST["email"], $_POST["url"], $_POST["comment"]);
            if (isset($result['errors'])) {
                $output .= '<p class="errors">' . $result['errors'] . '</p>';
            } elseif (isset($result['output'])) {
                $output .= '<p class="actions">' . $result['output'] . '</p>';
            }
        }
    }
}
$output .= '<form id="contentList" action="' . $_SERVER["PHP_SELF"] . '" method="get">';
$allowedCommentKeys = array("unix_date", "author", "email", "url", "comment");
// lets iterate through all the content and build a table
// set the default level if nothing is specified
// handle pagination
// lets determine the limit filter based on current page and number of results per page
if (!isset($_REQUEST["plog_page"])) {