Exemple #1
0
function blog_admin_module_settings_beforepost()
{
    global $lang;
    echo '<span class="kop2">' . $lang['blog']['title'] . '</span>
		<table>
			<tr>
				<td><input type="checkbox" name="allow_reactions" id="allow_reactions" value="true" ';
    if (module_get_setting('blog', 'allow_reactions') == 'true') {
        echo 'checked="checked" ';
    }
    echo '/></td>
				<td><label for="allow_reactions">&emsp;' . $lang['blog']['allow_reactions'] . '</label></td>
			</tr>
			<tr>
				<td><input name="truncate_posts" id="truncate_posts" type="text" size="2" value="' . module_get_setting('blog', 'truncate_posts') . '" /></td>
				<td><label for="truncate_posts">&emsp;' . $lang['blog']['truncate_posts'] . '</label></td>
			</tr>
			<tr>
				<td><input name="posts_per_page" id="posts_per_page" type="text" size="2" value="' . module_get_setting('blog', 'posts_per_page') . '" /></td>
				<td><label for="posts_per_page">&emsp;' . $lang['blog']['posts_per_page'] . '</label></td>
			</tr>
			<tr>
				<td>
					<select name="post_date" id="post_date" />';
    $date_options = array('d/m/Y', 'd-m-Y', 'd.m.Y', 'm/d/Y', 'm-d-Y', 'm.d.Y', 'Y/m/d', 'd-m-y', 'F j, Y');
    foreach ($date_options as $option) {
        echo '<option value="' . $option . '"';
        if (module_get_setting('blog', 'post_date') == $option) {
            echo ' selected="selected"';
        }
        echo '>' . date($option) . '</option>' . "\n";
    }
    unset($option);
    echo '</select>
				</td>
				<td><label for="post_date">&emsp;' . $lang['blog']['post_date'] . '</label></td>
			</tr>
			<tr>
				<td>
					<select name="post_time" id="post_time" />';
    $time_options = array('G:i', 'H:i:s', 'g:i a', 'g:i A', 'g:i:s a', 'g:i:s A');
    foreach ($time_options as $option) {
        echo '<option value="' . $option . '"';
        if (module_get_setting('blog', 'post_time') == $option) {
            echo ' selected="selected"';
        }
        echo '>' . date($option) . '</option>' . "\n";
    }
    unset($option);
    echo '</select>
				</td>
				<td><label for="post_time">&emsp;' . $lang['blog']['post_time'] . '</label></td>
			</tr>
	</table><br />';
}
Exemple #2
0
function albums_admin_module_settings_beforepost()
{
    global $lang;
    echo '<span class="kop2">' . $lang['albums']['title'] . '</span>
		<table>
			<tr>
				<td><input name="image_width" id="image_width" type="text" size="2" value="' . module_get_setting('albums', 'resize_image_width') . '" /></td>
				<td><label for="image_width">&emsp;' . $lang['albums']['image_width'] . '</label></td>
			</tr>
			<tr>
				<td><input name="thumb_width" id="thumb_width" type="text" size="2" value="' . module_get_setting('albums', 'resize_thumb_width') . '" /></td>
				<td><label for="thumb_width">&emsp;' . $lang['albums']['thumb_width'] . '</label></td>
			</tr>
	</table><br />';
}
Exemple #3
0
function albums_page_admin_editalbum()
{
    global $cont1, $cont2, $cont3, $lang, $var1;
    //Let's process the image...
    if (isset($_POST['submit'])) {
        //If file is jpeg, pjpeg, png or gif: Accept.
        if (in_array($_FILES['imagefile']['type'], array('image/jpeg', 'image/pjpeg', 'image/png', 'image/gif'))) {
            //Define some variables
            $extpos = strrpos($_FILES['imagefile']['name'], '.');
            if ($extpos === false) {
                $extpos = strlen($_FILES['imagefile']['name']);
            }
            $image_filename = substr($_FILES['imagefile']['name'], 0, $extpos);
            $ext = substr($_FILES['imagefile']['name'], $extpos + 1);
            $image_filename = seo_url($image_filename);
            $fullimage = ALBUMS_DIR . '/' . $var1 . '/' . $image_filename . '.' . strtolower($ext);
            $thumbimage = ALBUMS_DIR . '/' . $var1 . '/thumb/' . $image_filename . '.' . strtolower($ext);
            //Check if the image name already exists.
            $images = read_dir_contents(ALBUMS_DIR . '/' . $var1 . '/thumb', 'files');
            if ($images) {
                foreach ($images as $image) {
                    $extpos = strrpos($image, '.');
                    if ($extpos === false) {
                        $extpos = strlen($image);
                    }
                    $namepart = substr($image, 0, $extpos);
                    if ($namepart == $image_filename) {
                        $name_exist = true;
                        break;
                    }
                }
            }
            //Don't do anything, if the name already exists.
            if (isset($name_exist)) {
                $error = show_error($lang['albums']['image_exist'], 1, true);
            } elseif (!copy($_FILES['imagefile']['tmp_name'], $fullimage) || !copy($_FILES['imagefile']['tmp_name'], $thumbimage)) {
                $error = show_error($lang['general']['upload_failed'], 1, true);
            } else {
                //Compress the big image.
                $image_width = module_get_setting('albums', 'resize_image_width');
                $image = new SmartImage($fullimage);
                //Only resize if resize_image_width is not disabled (or set to 1, which would produce errors).
                if ($image_width != '0' && $image_width != '1') {
                    list($width, $height) = getimagesize($fullimage);
                    $imgratio = $width / $height;
                    if ($imgratio > 1) {
                        $newwidth = $image_width;
                        $newheight = $image_width / $imgratio;
                    } else {
                        $newheight = $image_width;
                        $newwidth = $image_width * $imgratio;
                    }
                    $image->resize($newwidth, $newheight);
                }
                $image->saveImage($fullimage, $cont3);
                $image->close();
                chmod($fullimage, 0777);
                //Then make a thumb from the image.
                $thumb_width = module_get_setting('albums', 'resize_thumb_width');
                //If resize_thumb_width is set to 0 or 1, we need to grab the default width (otherwise it would produce errors).
                if ($thumb_width == '0' || $thumb_width == '1') {
                    $albums_default_settings = albums_settings_default();
                    $thumb_width = $albums_default_settings['resize_thumb_width'];
                }
                //Resize thumb.
                $thumb = new SmartImage($thumbimage);
                list($width, $height) = getimagesize($thumbimage);
                $imgratio = $width / $height;
                if ($imgratio > 1) {
                    $newwidth = $thumb_width;
                    $newheight = $thumb_width / $imgratio;
                } else {
                    $newheight = $thumb_width;
                    $newwidth = $thumb_width * $imgratio;
                }
                $thumb->resize($newwidth, $newheight);
                $thumb->saveImage($thumbimage, $cont3);
                $thumb->close();
                chmod($thumbimage, 0777);
                //Find the number.
                $images = read_dir_contents(ALBUMS_DIR . '/' . $var1 . '/thumb', 'files');
                if ($images) {
                    $number = count($images);
                } else {
                    $number = 1;
                }
                //Sanitize data.
                $cont1 = sanitize($cont1);
                $cont2 = sanitize($cont2);
                $cont2 = nl2br($cont2);
                //Compose the data.
                $data['name'] = $cont1;
                $data['info'] = $cont2;
                //Then save the image information.
                save_file(ALBUMS_DIR . '/' . $var1 . '/' . $number . '.' . $image_filename . '.' . strtolower($ext) . '.php', $data);
            }
        } else {
            //FIXME: Maybe a better error message?
            $error = show_error($lang['general']['upload_failed'], 1, true);
        }
    }
    //Check if album exists.
    if (file_exists(ALBUMS_DIR . '/' . $var1)) {
        //Introduction text.
        ?>
			<p>
				<strong><?php 
        echo $lang['albums']['album_message1'];
        ?>
</strong>
			</p>
			<p>
				<span class="kop2"><?php 
        echo $lang['albums']['new_image'];
        ?>
</span>
				<span class="kop4"><?php 
        echo $lang['albums']['album_message2'];
        ?>
</span>
			</p>
			<?php 
        if (isset($error)) {
            echo $error;
        }
        ?>
			<form method="post" action="" enctype="multipart/form-data">
				<p>
					<label class="kop2" for="cont1"><?php 
        echo $lang['general']['title'];
        ?>
</label>
					<input required='required' name="cont1" id="cont1" type="text" />
				</p>
				<p>
					<label class="kop2" for="cont2"><?php 
        echo $lang['general']['description'];
        ?>
</label>
					<textarea required='required' cols="50" rows="5" name="cont2" id="cont2"></textarea>
				</p>
				<p>
					<input type="file" name="imagefile" id="imagefile" />
					<label class="kop4" for="cont3"><?php 
        echo $lang['albums']['quality'];
        ?>
</label>
					<input name="cont3" id="cont3" type="text" size="3" value="85" />
				</p>
				<input type="submit" name="submit" value="<?php 
        echo $lang['general']['save'];
        ?>
" />
			</form>
			<br />
		<?php 
        //Edit images.
        ?>
		<span class="kop2"><?php 
        echo $lang['albums']['edit_images'];
        ?>
</span>
		<?php 
        albums_admin_show_images($var1);
    }
    ?>
		<br />
		<p>
			<a href="?module=albums">&lt;&lt;&lt; <?php 
    echo $lang['general']['back'];
    ?>
</a>
		</p>
	<?php 
}
Exemple #4
0
/**
 * Counts the number of pages we need for pagination of all blog posts.
 * @param mixed $category Optional, if we need a number of pages for posts in one category.
 */
function blog_count_pages($category = false)
{
    if (!$category) {
        $number_posts = count(blog_get_posts());
    } else {
        $posts = blog_get_posts();
        $number_posts = 0;
        foreach ($posts as $post) {
            if ($post['category'] == $category) {
                $number_posts++;
            }
        }
        unset($post);
    }
    $number_pages = ceil($number_posts / module_get_setting('blog', 'posts_per_page'));
    return $number_pages;
}
Exemple #5
0
function blog_page_site_viewpost()
{
    //Global language variables.
    global $lang;
    //Load blog post.
    if (isset($_GET['post']) && blog_get_post($_GET['post'])) {
        $post = blog_get_post($_GET['post']);
        ?>
		<div id="blog_post">
			<span id="blog_post_info">
				<?php 
        echo $post['date'] . ' ' . $lang['blog']['at'] . ' ' . $post['time'] . ' ' . $lang['blog']['in'] . ' ' . $post['category'];
        ?>
			</span>
			<div id="blog_post_content">
			<?php 
        run_hook('theme_content', array(&$post['content']));
        echo $post['content'];
        ?>
			</div>
		</div>

		<?php 
        //Check if reactions are enabled
        if (module_get_setting('blog', 'allow_reactions') == 'true') {
            ?>
			<div id="blog_reactions">
				<p>
					<?php 
            $number = blog_get_reactions($post['seoname']);
            if ($number) {
                $number = count($number);
                if ($number == 1) {
                    echo $number . ' ' . $lang['blog']['reaction'];
                } else {
                    echo $number . ' ' . $lang['blog']['reactions'];
                }
            } else {
                echo $lang['blog']['no_reactions'];
            }
            ?>
				</p>
				<?php 
            $reactions = blog_get_reactions($_GET['post']);
            if ($reactions) {
                foreach ($reactions as $reaction) {
                    ?>
						<div class="blog_reaction" id="reaction<?php 
                    echo $reaction['id'];
                    ?>
">
							<p class="blog_reaction_name">
								<?php 
                    if (isset($reaction['website'])) {
                        echo '<a href="' . $reaction['website'] . '">' . $reaction['name'] . '</a>:';
                    } else {
                        echo $reaction['name'] . ':';
                    }
                    ?>
							</p>
							<span class="blog_reaction_info">
								<a href="#reaction<?php 
                    echo $reaction['id'];
                    ?>
"><?php 
                    echo $reaction['date'] . ' ' . $lang['blog']['at'] . ' ' . $reaction['time'];
                    ?>
</a>
						</span>
							<p class="blog_reaction_message"><?php 
                    echo $reaction['message'];
                    ?>
</p>
						</div>
					<?php 
                }
            }
            //If form is posted...
            if (isset($_POST['submit'])) {
                //Check if everything has been filled in.
                if (empty($_POST['blog_reaction_name']) || filter_input(INPUT_POST, 'blog_reaction_email', FILTER_VALIDATE_EMAIL) == false || $_POST['blog_reaction_website'] != 'http://' && !empty($_POST['blog_reaction_website']) && filter_input(INPUT_POST, 'blog_reaction_website', FILTER_VALIDATE_URL, FILTER_FLAG_HOST_REQUIRED) == false || empty($_POST['blog_reaction_message'])) {
                    echo '<p class="error">' . $lang['contactform']['fields'] . '</p>';
                } else {
                    blog_save_reaction($_GET['post'], $_POST['blog_reaction_name'], $_POST['blog_reaction_email'], $_POST['blog_reaction_website'], $_POST['blog_reaction_message']);
                    //Redirect user.
                    redirect(SITE_URI . '/' . PAGE_URL_PREFIX . CURRENT_PAGE_SEONAME . BLOG_URL_PREFIX . $_GET['post'], 0);
                }
            }
            ?>
				<form id="blog_post_form" method="post" action="">
					<div>
						<label for="blog_reaction_name"><?php 
            echo $lang['general']['name'];
            ?>
</label>
						<br />
						<input name="blog_reaction_name" id="blog_reaction_name" type="text" />
						<br />
						<label for="blog_reaction_email"><?php 
            echo $lang['general']['email'];
            ?>
</label>
						<br />
						<input name="blog_reaction_email" id="blog_reaction_email" type="text" />
						<br />
						<label for="blog_reaction_website"><?php 
            echo $lang['general']['website'];
            ?>
</label>
						<br />
						<input name="blog_reaction_website" id="blog_reaction_website" type="text" value="http://" />
						<br />
						<label for="blog_reaction_message"><?php 
            echo $lang['general']['message'];
            ?>
</label>
						<br />
						<textarea name="blog_reaction_message" id="blog_reaction_message" rows="7" cols="45"></textarea>
						<br />
						<input type="submit" name="submit" value="<?php 
            echo $lang['general']['send'];
            ?>
" />
					</div>
				</form>
			</div>

		<?php 
            //End of commenting check.
        }
    } else {
        echo $lang['general']['not_found'];
    }
    ?>
	<p>
		<a href="javascript: history.go(-1)" title="<?php 
    echo $lang['general']['back'];
    ?>
">&lt;&lt;&lt; <?php 
    echo $lang['general']['back'];
    ?>
</a>
	</p>
	<?php 
}