Example #1
0
 function go()
 {
     shitbugs($this->pageTheme);
     shitbugs($this->pageTitle);
     $this->setTemplate = 'staticPage.php';
     $this->doHeader();
     echo "PAGE CONTENT!<br>";
     $this->doFooter();
 }
Example #2
0
 function getPostsFromDB($params)
 {
     $theQuery = "SELECT post_id, section_id, category_id, status, date_format(date, '%W, %M %e, %Y') as date, unix_timestamp(date) AS sort_date, TIME_FORMAT(time, '%l:%i %p') as time, time AS sort_time, plug, title, content FROM posts " . $this->genSQLFilterFromParam($params);
     shitbugs("getPosts SQL is: " . $theQuery);
     $dbResult = $this->dbSelect($theQuery);
     while ($row = mysql_fetch_assoc($dbResult)) {
         $this->dbResultArray[$row['post_id']] = $row;
     }
     return $this->dbResultArray;
 }
Example #3
0
function __autoload($class)
{
    $file = MODULE_PATH . str_replace('_', '/', $class) . '.php';
    if (is_readable($file)) {
        require_once $file;
    } else {
        shitbugs("I'd love to run {$file} for you, however, it does not exist!");
        exit;
    }
}
Example #4
0
 function __construct($reqPosts)
 {
     $this->reqPosts = $reqPosts;
     $this->setTitle();
     if ($reqPosts) {
         shitbugs(__FILE__ . ' is processing $reqPosts');
         $this->posts = new postHandler();
         $this->posts->getReqPosts($reqPosts);
     } else {
         echo "NO POSTS?!";
     }
 }
Example #5
0
 function viewAction()
 {
     shitbugs("Welcome to indexAction!");
     // If no filter is set, set one.
     $params = $this->registry->params ? $this->registry->params : array('limit' => '0,3');
     $params['status'] = 2;
     // Get an array containing selected posts
     $postModel = new postModel();
     $view = new viewView();
     $view->selectedPosts = $postModel->getPostsFromDB($params);
     $view->setTitleFromParams($params);
     $view->setTemplate('showPosts.php');
     $view->go();
 }
Example #6
0
 function makelink($field, $value, $text)
 {
     $linklink = '';
     $linktext = '';
     $additionally = '';
     shitbugs("makelink: f=" . $field . ' v=' . $value . ' t=' . $text);
     if (!is_array($field)) {
         $linklink = sprintf('%s-%s', $field, $value);
         $linktext = $text;
     } else {
         foreach ($field as $key => $value) {
             $linklink = sprintf('%s%s%s-%s', $linklink, $additionally, $key, $value);
             $additionally = '/';
         }
         $linktext = $text;
     }
     $thelink = sprintf('<a href="%s">%s</a>', $linklink, $linktext);
     return $thelink;
 }
Example #7
0
<?php

shitbugs(__FILE__ . " loaded!");
define("DB_HOST", "192.168.1.1");
define("DB_USER", "phux0red");
define("DB_PASSWORD", "");
define("DB_NAME", "phux0red");
date_default_timezone_set("America/New_York");
Example #8
0
 function viewAction()
 {
     shitbugs("Welcome to viewAction!");
     $view = new pageView();
     $view->go();
 }
Example #9
0
 public function __set($index, $value)
 {
     shitbugs('<b>baseRegistry::__set</b> ' . $index . ' = ' . $value);
     $this->rVar[$index] = $value;
 }
Example #10
0
<?php

shitbugs("Loading " . __FILE__);
class pageView extends baseView
{
    function go()
    {
        // Overrides
        //$this->pageTemplate = '';
        //$this->pageTitle = "Some idiot forgot to set a page title";
        //$this->pageTheme = DEFAULT_THEME;
        //$this->headerFile = 'siteHeader.php';
        //$this->footerFile = 'siteFooter.php';
        $this->doHeader();
        $this->doFooter();
    }
}
Example #11
0
 public function genSQLFilterFromParam($criteria)
 {
     if (!is_array($criteria)) {
         echo 'genSQLFilterFromParam: Malformed criteria!';
     }
     $where = "WHERE ";
     $whereclause = "";
     $orderclause = "ORDER BY sort_date DESC, sort_time DESC";
     $limitclause = "";
     foreach ($criteria as $key => $value) {
         if ($value) {
             switch ($key) {
                 case 'post':
                     $whereclause = sprintf('%s %s post_id = %s', $whereclause, $where, $value);
                     $where = "AND";
                     break;
                 case 'section':
                     $whereclause = sprintf('%s %s section_id = %s', $whereclause, $where, $value);
                     $where = "AND";
                     break;
                 case 'category':
                     $whereclause = sprintf('%s %s category_id = %s', $whereclause, $where, $value);
                     $where = "AND";
                     break;
                 case 'month':
                     $whereclause = sprintf('%s %s MONTH(date) = %s', $whereclause, $where, $value);
                     $where = "AND";
                     break;
                 case 'year':
                     $whereclause = sprintf('%s %s YEAR(date) = %s', $whereclause, $where, $value);
                     $where = "AND";
                     break;
                 case 'status':
                     $whereclause = sprintf('%s %s status = %s', $whereclause, $where, $value);
                     $where = "AND";
                     break;
                 case 'offset':
                     $limitclause = sprintf('LIMIT %s,10', $value);
                     break;
                 case 'limit':
                     $limitclause = sprintf('LIMIT %s', $value);
                 default:
                     break;
             }
         }
     }
     $theQuery = sprintf('%s %s %s', $whereclause, $orderclause, $limitclause);
     shitbugs("genSQLFilterFromParam is returning: " . $theQuery);
     return $theQuery;
 }
Example #12
0
function do_page($reqPosts)
{
    //global $selectedposts, $onepost;
    echo '<div class="container"><!-- Page -->';
    // If, posting is required, then do it.
    if (isset($_POST['doit'])) {
        if (!$_POST['post_id']) {
            awfuck('Post submitted with no post_id!');
        }
        switch ($_POST['doit']) {
            case "Submit Edit":
                $thequery = sprintf('UPDATE posts SET section_id = %s, category_id = %s, status = %s, title = "%s", content = "%s", date = "%s", time = "%s" WHERE post_id = %s', mysql_real_escape_string($_POST['section_id']), mysql_real_escape_string($_POST['category_id']), mysql_real_escape_string($_POST['status']), mysql_real_escape_string($_POST['title']), mysql_real_escape_string($_POST['content']), mysql_real_escape_string($_POST['sort_date']), mysql_real_escape_string($_POST['sort_time']), mysql_real_escape_string($_POST['post_id']));
                shitbugs(sprintf('<b>Query is:</b><br />%s', $thequery));
                if (mysql_query($thequery)) {
                    happymsg('<h4>Post has been updated</h4>', $_POST['post_id']);
                } else {
                    awfuck(mysql_error());
                }
                display_posts(array('post' => $_POST['post_id']), "display");
                break;
            case "Submit New":
                echo "- NEWPOST<br>";
                $thequery = sprintf('INSERT INTO posts (section_id, category_id, status, title, content, date, time) VALUES (%s, %s, %s, "%s", "%s", "%s", "%s")', mysql_real_escape_string($_POST['section_id']), mysql_real_escape_string($_POST['category_id']), mysql_real_escape_string($_POST['status']), mysql_real_escape_string($_POST['title']), mysql_real_escape_string($_POST['content']), mysql_real_escape_string($_POST['sort_date']), mysql_real_escape_string($_POST['sort_time']));
                if (mysql_query($thequery)) {
                    printf('Post #%s has been created. <a href="phux0red.php?page=dostuff&edit&post=%s">Edit it again?</a>', mysql_insert_id(), mysql_insert_id());
                }
                display_posts(array('post' => mysql_insert_id()), "display");
                break;
            case "Attach Image":
                echo "- ATTACH IMAGE<br>";
                foreach ($_FILES as $file) {
                    print_r($file);
                    echo '<br><br>';
                    if ($file['tmp_name'] > '') {
                        list($filebase, $fileext) = explode(".", strtolower($file['name']), 2);
                        $small_filename = sprintf('gallery/small/%s-s.%s', $filebase, $fileext);
                        $medium_filename = sprintf('gallery/medium/%s-m.%s', $filebase, $fileext);
                        switch ($fileext) {
                            case "dll":
                                echo "F**K YOU!";
                                break;
                            case "jpg":
                                echo "Type is JPEG<br>";
                                $imagetoprocess = imagecreatefromjpeg($file['tmp_name']);
                                imagejpeg(process_image($imagetoprocess, 200, 200), $small_filename, 100);
                                imagejpeg(process_image($imagetoprocess, 800, 600), $medium_filename, 100);
                                $thequery = sprintf('INSERT INTO post_img (post_id, filename, caption, description) VALUES (%s, "%s", "%s", "%s")', mysql_real_escape_string($_POST['post_id']), mysql_real_escape_string($filebase), mysql_real_escape_string($_POST['caption']), mysql_real_escape_string($_POST['description']));
                                if (mysql_query($thequery)) {
                                    printf('Image has been uploaded. <a href="phux0red.php?post=%s">View post</a>', $_POST['post_id']);
                                }
                                break;
                        }
                    }
                }
                move_uploaded_file($_FILES['image_to_upload']['tmp_name'], "gallery/large/{$_FILES['image_to_upload']['name']}");
                break;
            default:
                echo "- " . $_post['doit'];
                break;
        }
    } else {
        echo "NOT POSTING ANYTHING, SO...<br>";
    }
    // End posting stuff.
    echo "FINISHED DECIDING WHAT TO DO<br>";
    if (isset($_GET['edit'])) {
        if (isset($_GET['post'])) {
            edit_post($onepost['0']);
        }
    } elseif (isset($_GET['newpost'])) {
        edit_post(0);
    } elseif (isset($_GET['addimg'])) {
        if (isset($_GET['post'])) {
            edit_images($onepost['0']);
        }
    } else {
        echo "<h3>Drafts:</h3>";
        display_posts(array('status' => '1'), "list");
        echo "<h3>Published Posts:</h3>";
        display_posts(array('status' => '2'), "list");
        echo "<h3>Deleted Posts:</h3>";
        display_posts(array('status' => '3'), "list");
    }
    ?>
</div><!-- Page -->
<?php 
}