Ejemplo n.º 1
0
<?php 
require_once '../includes/initialize.php';
?>

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


<h2>Photographs</h2>

<?php 
echo output_message($message);
?>
<table class="bordered">
  <tr>
    <th>Image</th>
    <th>Filename</th>
 		<th>&nbsp;</th>
  </tr>
<?php 
foreach ($photos as $photo) {
    ?>
  <tr>
    <td><img src="../public/<?php 
    echo $photo->image_path();
    ?>
" width="100" /></td>
    <td><?php 
    echo $photo->filename;
Ejemplo n.º 2
0
<h2><?php 
        echo $photo->head;
        ?>
 </h2>
<img src="<?php 
        echo $photo->image_path();
        ?>
" width="500" height="400" />
<p><?php 
        echo $photo->readmore;
        ?>
</p>
<?php 
    }
    //find all photos
    $coms = Com_pictures::find_by_comid($_GET['comid']);
    ?>

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

<?php 
    foreach ($coms as $com) {
        ?>
<img src="<?php 
        echo $com->image_path();
        ?>
" width="500" height="400" />
<?php 
    }
Ejemplo n.º 3
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();
}
<?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 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);