Exemplo n.º 1
0
 public static function singleton()
 {
     if (!isset(self::$instance)) {
         self::$instance = new contentClass();
     }
     if (self::$conn == false) {
         self::openconnection();
     }
     return self::$instance;
 }
Exemplo n.º 2
0
     $templates[] = array('name' => 'post.form', 'vars' => array('types' => $contentTypes, 'auth' => $auth, 'error' => $status));
     renderPage($templates);
 } else {
     if ("comment" == $action) {
         // check to see if user is allowed to make posts
         if ($_user->getPrivileges($_SESSION['user']['id'], CAN_MAKE_COMMENTS)) {
             $auth = 1;
             if ("POST" == $_SERVER['REQUEST_METHOD']) {
                 if (!@empty($_POST['body'])) {
                     if (isset($_POST['thread']) && is_numeric(@$_POST['thread'])) {
                         if (!isset($_POST['parent']) || !is_numeric(@$_POST['parent'])) {
                             $parent = 0;
                         } else {
                             $parent = $_POST['parent'];
                         }
                         $content = new contentClass();
                         if (FALSE != ($pid = $content->newComment($_SESSION['user']['id'], $_POST['thread'], $parent, $_POST['body']))) {
                             doRedirect('?module=post&id=' . $_POST['thread'] . '#comment-' . $pid, TRUE);
                         } else {
                             doRedirect('?module=post&id=' . $_POST['thread'] . '#comment-' . $parent, TRUE);
                         }
                     } else {
                         $status = "Invalid post id.";
                     }
                 } else {
                     $status = "You must enter some text.";
                 }
             }
         } else {
             $status = "You are not allowed to make this kind of contribution.";
         }
Exemplo n.º 3
0
 *        notice, this list of conditions and the following disclaimer.
 *      * Redistributions in binary form must reproduce the above
 *        copyright notice, this list of conditions and the following disclaimer
 *        in the documentation and/or other materials provided with the
 *        distribution.
 *      * Neither the name of the  nor the names of its
 *        contributors may be used to endorse or promote products derived from
 *        this software without specific prior written permission.
 *      
 *      THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 *      "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 *      LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 *      A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 *      OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 *      SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 *      LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 *      DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 *      THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 *      (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 *      OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *      
 *      
 */
if (!defined('IN_RECOVERY')) {
    die;
}
$content = new contentClass();
$posts = $content->getFrontPage(MAX_NEWS_POSTS, USE_CACHING ? CACHE_DIR : NULL);
$contentTemplate = new h2o(TEMPLATES_DIR . 'post/main.html');
$index = new h2o(TEMPLATES_DIR . 'index.html');
echo $index->render(array('content' => $contentTemplate->render(compact('posts')), 'user' => $_SESSION['user']));
Exemplo n.º 4
0
header("Access-Control-Allow-Origin: *");
if (!class_exists('contentClass')) {
    include 'dbConnector.php';
}
if (empty($_REQUEST["page_id"])) {
    $q = '1';
} else {
    $q = $_REQUEST["page_id"];
}
$hint = "";
// lookup all hints from array if $q is different from ""
if ($q == "") {
    $q = 1;
}
$connection = contentClass::singleton();
function createContent()
{
    global $connection;
    global $q;
    global $language;
    $sql = "select content,option_a,option_b,option_c,option_d from project_one.questions;";
    $result = $connection->conn->query($sql);
    if ($result->num_rows > 0) {
        while ($row = $result->fetch_assoc()) {
            echo $row["content"] . "<br/><br/>";
            echo "A> " . $row["option_a"] . "&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp" . "&nbsp&nbsp&nbsp&nbsp&nbsp";
            echo "B> " . $row["option_b"] . "<br/>";
            echo "C> " . $row["option_c"] . "&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp" . "&nbsp&nbsp&nbsp&nbsp&nbsp";
            echo "D> " . $row["option_d"] . "<br/><hr/><hr/><br/>";
        }