Пример #1
0
<?php 
require_once '../includes/initialize.php';
if (empty($_GET['id']) && $_GET['comid']) {
    $session->message("No Photograph ID was provided");
    redirect_to('list_photos.php');
}
$photo = Main_pictures::find_by_id($_GET['id']);
if ($photo && $photo->destroy()) {
    /////////////////////////////////////////////////////////
    $foto = Com_pictures::find_by_id_and_comid($_GET['id'], $_GET['comid']);
    global $database;
    $sql = "DELETE FROM com_pictures WHERE comid='" . $database->escape_value($_GET['comid']) . "'";
    $work = $database->query($sql);
    $sql2 = "DELETE FROM comments WHERE comid='" . $database->escape_value($_GET['comid']) . "'";
    $work2 = $database->query($sql2);
    if ($foto && $work && $work2) {
        $target_path = SITE_ROOT . DS . 'public' . DS . $foto->image_path();
        return unlink($target_path) ? true : false;
    }
    ////////////////////////////////////////////////////////////////
    $session->message("The photo {$photo->filename} was deleted");
    redirect_to("list_photos.php");
} else {
    $session->message("The photo could not be deleted.");
    redirect_to('list_photos.php');
}
if (isset($database)) {
    $database->close_connection();
}
Пример #2
0
<?php 
require_once "../includes/initialize.php";
//if (!$session->is_logged_in()) { redirect_to("login.php"); }
$message = "";
$max_file_size = 1048576;
// expressed in bytes
//     10240 =  10 KB
//    102400 = 100 KB
//   1048576 =   1 MB
//  10485760 =  10 MB
if (isset($_POST['submit'])) {
    $photo = new Main_pictures();
    $photo->head = $_POST['head'];
    $photo->readmore = $_POST['readmore'];
    $photo->comid = $_POST['comid'];
    $photo->attach_file($_FILES['file_upload']);
    if ($photo->save()) {
        // Success
        $session->message("Photograph uploaded successfully.");
        redirect_to('list_photos.php');
    } else {
        // Failure
        $message = join("<br />", $photo->errors);
    }
}
$coms = Main_pictures::find_com();
?>

<h2>Photo Upload</h2>

<?php 
Пример #3
0
<div id="content">

<!--Pagination -->

<?php 
require_once "../includes/initialize.php";
?>
<!--End Pagination -->


<div id="content_left">
<div id="pic_and_news">
<?php 
if (isset($_GET['comid'])) {
    //find all photos
    $photos = Main_pictures::find_by_comid($_GET['comid']);
    ?>


<?php 
    echo output_message($message);
    ?>

<?php 
    foreach ($photos as $photo) {
        ?>
<h2><?php 
        echo $photo->head;
        ?>
 </h2>
<img src="<?php 
//  10485760 =  10 MB
if (isset($_POST['submit'])) {
    $photo = new Com_pictures();
    $photo->comid = $_POST['comid'];
    $photo->photodesc = $_POST['photodesc'];
    $photo->attach_file($_FILES['file_upload']);
    if ($photo->save()) {
        // Success
        $session->message("Photograph uploaded successfully.");
        redirect_to('list_photos.php');
    } else {
        // Failure
        $message = join("<br />", $photo->errors);
    }
}
$coms = Main_pictures::find_com();
?>

<h2>Photo Upload</h2>

<?php 
echo output_message($message);
?>
<form action="photo_upload_read_more.php" enctype="multipart/form-data" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="<?php 
echo $max_file_size;
?>
" />
<p><input type="file" name="file_upload" /></p>
<p><input type="text" name="photodesc" /></p>
<input type="hidden" name="comid" value="<?php 
Пример #5
0
// 1. the current page number ($current_page)
$page = !empty($_GET['page']) ? (int) $_GET['page'] : 1;
// 2. records per page ($per_page)
$per_page = 3;
// 3. total record count ($total_count)
$total_count = Main_pictures::count_all();
// Find all photos
// use pagination instead
//$photos = Photograph::find_all();
$pagination = new Pagination($page, $per_page, $total_count);
// Instead of finding all records, just find the records
// for this page
$sql = "SELECT * FROM main_pictures ORDER BY comid DESC ";
$sql .= "LIMIT {$per_page} ";
$sql .= "OFFSET {$pagination->offset()}";
$photos = Main_pictures::find_by_sql($sql);
// Need to add ?page=$page to all links we want to
// maintain the current page (or store $page in $session)
?>



<!--End Pagination -->


<div id="content_left">
<div id="pic_and_news">
<?php 
foreach ($photos as $photo) {
    ?>
<h2><?php 
Пример #6
0
<?php 
require_once '../includes/initialize.php';
?>

<?php 
//find all photos
$photos = Main_pictures::find_all();
?>


<h2>Photographs</h2>

<?php 
echo output_message($message);
?>
<table class="bordered">
  <tr>
    <th>Image</th>
    <th>Filename</th>
    <th>head</th>
    <th>comid</th>
    <th>Type</th>
		
		<th>&nbsp;</th>
  </tr>
<?php 
foreach ($photos as $photo) {
    ?>
  <tr>
    <td><img src="../public/<?php 
    echo $photo->image_path();