Пример #1
0
function initialize_page()
{
    $post_action = isset($_POST['submit']) ? $_POST['submit'] : "";
    if ($post_action == "Add Image" || $post_action == "Add and Return to List") {
        $title = cleanupSpecialChars($_POST['title']);
        $description = cleanupSpecialChars($_POST['description']);
        if (ALLOW_SHORT_PAGE_NAMES) {
            $name = $_POST['name'] == "" ? slug($_POST['title']) : slug($_POST['name']);
        } else {
            $name = slug($_POST['title']);
        }
        // Was a file uploaded?
        if (is_uploaded_file($_FILES["image"]["tmp_name"])) {
            $mimeType = $_FILES["image"]["type"];
            $filetype = getFileExtension($_FILES["image"]["name"]);
            list($width) = getimagesize($_FILES["image"]["tmp_name"]);
            $max_width = 0;
            $max_height = 0;
            if (defined("MAX_IMAGE_HEIGHT")) {
                $max_height = MAX_IMAGE_HEIGHT;
            }
            if (defined("MAX_IMAGE_WIDTH")) {
                $max_width = MAX_IMAGE_WIDTH;
            }
            resizeToMultipleMaxDimensions($_FILES["image"]["tmp_name"], $max_width, $max_height, $filetype);
            // Open the uploaded file
            $file = fopen($_FILES["image"]["tmp_name"], "r");
            // Read in the uploaded file
            $fileContents = fread($file, filesize($_FILES["image"]["tmp_name"]));
            // Escape special characters in the file
            $fileContents = AddSlashes($fileContents);
            /*if( copy($_FILES["image"]["tmp_name"], $_FILES["image"]["tmp_name"] . "_thumb") ) {
            					
            					resizeToMultipleMaxDimensions($_FILES["image"]["tmp_name"] . "_thumb", 200, 0);
            	
            					$image = open_image($_FILES["image"]["tmp_name"] . "_thumb");
            					if ( $image === false ) { die ('Unable to open image for resizing'); }
            					$width = imagesx($image);
            	
            					// Open the thumbnail file
            					$thumb_file = fopen($_FILES["image"]["tmp_name"] . "_thumb", "r");
            					// Read in the thumbnail file
            					$thumb_fileContents = fread($thumb_file, filesize($_FILES["image"]["tmp_name"] . "_thumb")); 
            					// Escape special characters in the file
            					$thumb_fileContents = AddSlashes($thumb_fileContents);
            				}*/
            $thumb_fileContents = NULL;
        } else {
            $fileContents = $thumb_fileContents = NULL;
        }
        $insertQuery = "INSERT INTO images VALUES (NULL, \"{$title}\", \"{$description}\", \"{$fileContents}\", \"{$thumb_fileContents}\", \"{$mimeType}\", \"{$name}\")";
        $result = mysql_Query($insertQuery, MyActiveRecord::Connection());
        if (empty($result)) {
            //die( $updateQuery );
            setFlash("<h3>FAILURE &ndash; Please notify HCd of this error: " . mysql_error() . "</h3>");
        }
        setFlash("<h3>Image uploaded</h3>");
        if ($post_action == "Add and Return to List") {
            redirect("/admin/list_images");
        }
    }
}
Пример #2
0
 function display_gal($galType = "gallery", $tabs = "", $prevnext = true, $shuffle = false, $link = false)
 {
     $photosFromGal = $this->get_photos();
     if ($shuffle) {
         shuffle($photosFromGal);
     }
     $gal = $tabs . "<div class=\"{$galType}\">\n{$tabs}\t<ul>\n";
     foreach ($photosFromGal as $photo) {
         if ($link) {
             $gal .= $tabs . "\t\t<li><a class=\"image\" href=\"{$photo->getPublicUrl()}\" title='" . cleanupSpecialChars($photo->caption) . "' ><img src=\"{$photo->getPublicUrl()}\" alt=\"slideshow\" /></a></li>\n";
         } else {
             $gal .= $tabs . "\t\t<li><img src=\"{$photo->getPublicUrl()}\" alt=\"slideshow\" /></li>\n";
         }
     }
     $gal .= $tabs . "\t</ul>\n";
     if ($galType == "carousel" && $prevnext) {
         $gal .= $tabs . "\t<a href=\"javascipt:;\" class=\"next\">&gt;</a>\n{$tabs}\t<a href=\"javascipt:;\" class=\"previous\">&lt;</a>\n";
     }
     $gal .= $tabs . "</div>\n";
     return $gal;
 }
Пример #3
0
function document_display($content_to_display)
{
    $documentPattern = "/{{2}(document:[A-Za-z0-9\\-\\_ \\.\\(\\)'\"]+){{2}/";
    $documentIds = getFilterIds($content_to_display, $documentPattern);
    $documents = array();
    foreach ($documentIds as $documentId) {
        $filename = end(explode(":", $documentId));
        $documents[] = Documents::FindByFilename($filename);
    }
    foreach ($documents as $document) {
        if (is_object($document)) {
            $replacement = "<a class=\"hcd-document " . getFileExtension($document->filename) . "\" href=\"{$document->getPublicUrl()}\">" . cleanupSpecialChars($document->name) . "</a> (" . getFileExtension($document->filename) . ")";
            $content_to_display = updateContent($content_to_display, "/{{2}document:" . str_replace(")", "\\)", str_replace("(", "\\(", $document->filename)) . "{{2}/", $replacement);
        } else {
            $content_to_display = "<span class=\"database_error\">HCd&gt;CMS Warning: Document &ldquo;{$filename}&rdquo; not found!</span> " . $content_to_display;
        }
    }
    return $content_to_display;
}
Пример #4
0
function initialize_page()
{
    $image_id = requestIdParam();
    $image = Images::FindById($image_id);
    $post_action = isset($_POST['submit']) ? $_POST['submit'] : "";
    if ($post_action == "Save Image" || $post_action == "Save and Return to List") {
        $success = '';
        if (isset($_POST['delete'])) {
            $image->delete(true);
            setFlash("<h3>Image deleted</h3>");
            redirect("/admin/list_images");
        } else {
            $old_name = $image->name;
            $image->title = cleanupSpecialChars($_POST['title']);
            $image->description = cleanupSpecialChars($_POST['description']);
            if (ALLOW_SHORT_PAGE_NAMES) {
                $image->name = $_POST['name'] == "" ? slug($_POST['title']) : slug($_POST['name']);
            } else {
                $image->name = slug($_POST['title']);
            }
            //$image->save();
            $updateQuery = "UPDATE images SET title='{$image->title}', name='{$image->name}', description='{$image->description}' WHERE id='{$image->id}';";
            if (mysql_Query($updateQuery, MyActiveRecord::Connection())) {
                if ($old_name != $image->name) {
                    Pages::UpdateImageReferences($old_name, $image->name);
                }
                $success .= "Image changes saved / ";
            } else {
                die($updateQuery);
                setFlash("<h3>FAILURE &ndash; Please notify HCd of this error: " . mysql_error() . "</h3>");
            }
            // Replace an existing image with a new one
            if (is_uploaded_file($_FILES["new_image"]["tmp_name"])) {
                $mimeType = $_FILES["new_image"]["type"];
                $filetype = getFileExtension($_FILES["new_image"]["name"]);
                //list($width) = getimagesize($_FILES["new_image"]["tmp_name"]);
                $max_width = 0;
                $max_height = 0;
                if (defined("MAX_IMAGE_WIDTH")) {
                    $max_width = MAX_IMAGE_WIDTH;
                }
                if (defined("MAX_IMAGE_HEIGHT")) {
                    $max_height = MAX_IMAGE_HEIGHT;
                }
                resizeToMultipleMaxDimensions($_FILES["new_image"]["tmp_name"], $max_width, $max_height, $filetype);
                // Open the uploaded file
                $file = fopen($_FILES["new_image"]["tmp_name"], "r");
                // Read in the uploaded file
                $fileContents = fread($file, filesize($_FILES["new_image"]["tmp_name"]));
                // Escape special characters in the file
                $fileContents = AddSlashes($fileContents);
                $updateQuery2 = "UPDATE images SET original='{$fileContents}', mime_type='{$mimeType}' WHERE id='{$image->id}';";
                if (mysql_Query($updateQuery2, MyActiveRecord::Connection())) {
                    $success .= "Image replaced / ";
                } else {
                    setFlash("FAILURE &ndash; Please notify HCd of this error: " . mysql_error() . "</h3>");
                    //die( $updateQuery2 );
                }
            }
        }
        if ($post_action == "Save and Return to List") {
            redirect("/admin/list_images");
        }
        setFlash("<h3>" . substr($success, 0, -3) . "</h3>");
    }
}
Пример #5
0
function display_page_content()
{
    error_reporting(E_ALL);
    // Set the Header! Important for compliance.
    header('Content-type: application/rss+xml');
    // Create additional parameters here, and edit the Channel info below for each site
    echo "<?xml version=\"1.0\"?>\n";
    ?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
	<channel>
		<title><?php 
    echo SITE_NAME;
    ?>
 RSS Feed</title>
		<link>http://<?php 
    echo SITE_URL;
    ?>
</link>
		<atom:link rel="self" type="application/rss+xml" href="http://<?php 
    echo SITE_URL . BASEHREF . getRequestVarAtIndex(0) . "/" . getRequestVarAtIndex(1);
    ?>
" />
		<description><?php 
    echo SITE_NAME;
    ?>
 RSS Feed</description>
		<language>en-us</language>	
<?php 
    /* We can feed this RSS loop any number of parameters, but for now we feed it a path and then we iterate on what is supplied. Customize and add to this as needed:
    	For example:
    		/feed/rss/
    		/events/rss/
    	*/
    if (getRequestVarAtIndex(0) == "feed" || getRequestVarAtIndex(0) == "blog") {
        // Default action = Blog Posts
        $the_blog = Blogs::FindByID(1);
        $entries = $the_blog->getEntries();
        //print_r($entries);
        $firstentry = $entries;
        $firstentry = array_shift($firstentry);
        $buildDate = date('r');
        $rss = "\t\t<pubDate>{$buildDate}</pubDate>\n";
        $rss .= "\t\t<lastBuildDate>{$buildDate}</lastBuildDate>\n\n";
        foreach ($entries as $entry) {
            $bloglink = "http://" . SITE_URL . get_link("blog/view/1/" . $entry->id);
            $rss .= "\t\t<item>\n";
            $rss .= "\t\t\t<title>" . cleanupSpecialChars($entry->title) . "</title>\n";
            $rss .= "\t\t\t<pubDate>" . date('r', strtotime($entry->date)) . "</pubDate>\n";
            $rss .= "\t\t\t<link>{$bloglink}</link>\n";
            $rss .= "\t\t\t<guid isPermaLink=\"true\">{$bloglink}</guid>\n";
            $rss .= "\t\t\t<description><![CDATA[";
            //$blogcontent = scrub_HCd_Tags( $entry->content );
            //$blogcontent = strip_tags( $blogcontent );
            $blogcontent = $entry->rss_getContent();
            $rss .= cleanupSpecialChars($blogcontent);
            $rss .= "]]></description>\n";
            if (RSS_AUTHOR) {
                $rss .= "\t\t\t<dc:creator>{$entry->user}</dc:creator>\n";
            }
            $rss .= "\t\t</item>\n";
        }
    } else {
        if (getRequestVarAtIndex(0) == "events") {
            $entries = Events::FindUpcomingWithinDateRange(12, "ASC", 90);
            $firstentry = $entries;
            $firstentry = array_shift($firstentry);
            $buildDate = date('r');
            $rss = "\t\t<pubDate>{$buildDate}</pubDate>\n";
            $rss .= "\t\t<lastBuildDate>{$buildDate}</lastBuildDate>\n\n";
            foreach ($entries as $entry) {
                $type = $entry->getEventType();
                if ($entry->time_start != "04:00:00") {
                    $entrydate = substr($entry->date_start, 0, 10) . " " . $entry->time_start;
                } else {
                    $entrydate = substr($entry->date_start, 0, 10) . " 12:00:00";
                }
                $dateLink = explode("/", $entry->getDateStart("date"));
                $eventlink = "http://" . SITE_URL . get_link("events/calendar/" . $dateLink[2] . "/" . $dateLink[0] . "/" . $dateLink[1] . "/" . $entry->id);
                $rss .= "\t\t<item>\n";
                $rss .= "\t\t\t<title>" . htmlentities($entry->title, ENT_QUOTES) . " (" . htmlentities($type->name, ENT_QUOTES) . ")</title>\n";
                date_default_timezone_set('EST');
                $rss .= "\t\t\t<pubDate>" . date('r', strtotime($entrydate)) . "</pubDate>\n";
                $rss .= "\t\t\t<link>{$eventlink}</link>\n";
                $rss .= "\t\t\t<guid isPermaLink=\"true\">{$eventlink}</guid>\n";
                $rss .= "\t\t\t<description>";
                if (RSS_IMAGE) {
                    if ($entry->hasImage()) {
                        $rss .= "&lt;img src=&quot;http://" . SITE_URL . get_link("/images/eventsimage/" . $entry->id) . "&quot; alt=&quot;" . htmlentities($entry->title, ENT_QUOTES) . "&quot; &gt;\n";
                    }
                }
                if (substr($entry->description, 0, 1) == "<") {
                    $rss .= htmlentities($entry->description, ENT_QUOTES) . "</description>\n";
                } else {
                    $rss .= $entry->description . "</description>\n";
                }
                if (RSS_AUTHOR) {
                    $rss .= "\t\t\t<dc:creator>{$entry->user}</dc:creator>\n";
                }
                $rss .= "\t\t</item>\n";
            }
        }
    }
    echo $rss;
    ?>

	</channel>
</rss>
<?php 
}