Пример #1
0
 public function action_SetSortDate()
 {
     $item = Model::factory('kwalbum_item')->load((int) $_POST['item']);
     $this->_testPermission($item);
     $date = Kwalbum_Helper::replaceBadDate($_POST['value']);
     $item->sort_date = $date;
     $item->save();
     echo $item->sort_date;
 }
Пример #2
0
 * @package kwalbum
 * @since 3.0 Jun 30, 2009
 */
// create page links
$page_links = '';
for ($i = 1; $i <= $total_pages; $i++) {
    if ($i == $page_number) {
        $page_links .= "<span class='kwalbumCurrentIndex'>{$i}</span> ";
    } else {
        $page_links .= html::anchor($kwalbum_url . '/~browse/comments/page/' . $i, $i) . ' ';
    }
}
$page_links = "<div class='kwalbumPageNumbers'>pages: {$page_links}</div>";
// show page
//echo $page_links;
if (count($items) == 0) {
    echo '<div class="kwalbumBox"><h2>No items were found that have comments.</h2></div>';
}
foreach ($items as $item) {
    $item['item']->hide_if_needed($user);
    //$thumbview = new View('kwalbum/item/thumbnail');
    echo "<div class='kwalbumBox'>";
    // show thumbnail based on file type
    echo '<table><tr><td>';
    echo Kwalbum_Helper::getThumbnailLink($item['item'], $kwalbum_url, $kwalbum_url_params);
    echo '</td><td style="vertical-align:text-top;text-align:left;width:600px;">';
    echo '<h2>' . $item['comment']->date . '<small> : ' . $item['comment']->name . '</small></h2>' . $item['comment']->text;
    echo '</td></tr></table>';
    echo "</div>";
}
//echo $page_links;
Пример #3
0
 /**
  * Save file in proper location and save information to database
  *
  * Check if it has an acceptable file extension, determine the filetype
  * based on the extension, move the file into the necessary directory,
  * create thumbnail and resized versions if necessary, then insert into the
  * database if there have not been any errors.
  *
  * Return the id of the new item if successful
  * @since 3.0
  */
 private function save()
 {
     $item = $this->_item;
     $item->sort_date = Kwalbum_Helper::replaceBadDate($_POST['date'] . ' ' . $_POST['time']);
     $item->visible_date = $item->sort_date;
     // get exif data from jpeg files
     if ($item->type == 'jpeg') {
         $fullpath = $item->path . $item->filename;
         $import_caption = false;
         $import_keywords = false;
         if (isset($_POST['import_caption']) and $_POST['import_caption'] == 1) {
             $import_caption = true;
         }
         if (isset($_POST['import_keywords']) and $_POST['import_keywords'] == 1) {
             $import_keywords = true;
         }
         if ($import_caption || $import_keywords) {
             $info = null;
             $size = getimagesize($fullpath, $info);
             if (isset($info['APP13'])) {
                 $iptc = iptcparse($info['APP13']);
                 foreach ($iptc as $key => $data) {
                     if ($key == '2#120' and $import_caption) {
                         $item->description = trim($data[0]);
                     }
                     if ($key == '2#025' and $import_keywords) {
                         if (!is_array($data)) {
                             $data = array($data);
                         }
                         foreach ($data as $keyword) {
                             $item->addTag(htmlspecialchars($keyword));
                         }
                     }
                 }
             }
         }
         $exif = @exif_read_data($fullpath);
         if ($exif) {
             //Kohana::$log->add('var', Kohana::debug($exif));
             /*
             				if ($irb = get_Photoshop_IRB($jpeg_header_data)) {
             				    $xmp = Read_XMP_array_from_text(get_XMP_text($jpeg_header_data));
             				    $pinfo = get_photoshop_file_info($exif, $xmp, $irb);
             				    foreach ($pinfo['keywords'] as $keyword) {
             						$item->addTag(trim($keyword));
             				    }
             				    //echo '<pre>'.Kohana::debug( $pinfo );exit;
             				}*/
             // replace the set date if one is found in the picture's exif data
             if (isset($exif['DateTimeOriginal'])) {
                 $item->sort_date = Kwalbum_Helper::replaceBadDate($exif['DateTimeOriginal']);
                 $item->visible_date = $item->sort_date;
             }
             if (!empty($exif['GPSLatitude'])) {
                 $latitude = $exif['GPSLatitude'];
                 $sec = explode('/', $latitude[2]);
                 $lat = @((int) $latitude[0] + (int) $latitude[1] / 60 + (int) $sec[0] / (int) $sec[1] / 3600);
                 if (!empty($exif['GPSLatitudeRef']) && 'S' == $exif['GPSLatitudeRef']) {
                     $lat = -$lat;
                 }
                 $item->latitude = $lat;
             }
             if (!empty($data['GPSLongitude'])) {
                 $longitude = $data['GPSLongitude'];
                 $sec = explode('/', $longitude[2]);
                 $lon = @((int) $longitude[0] + (int) $longitude[1] / 60 + (int) $sec[0] / (int) $sec[1] / 3600);
                 if (!empty($data['GPSLongitudeRef']) && 'W' == $data['GPSLongitudeRef']) {
                     $lon = -$lon;
                 }
                 $item->longitude = $lon;
             }
         }
     }
     if ($item->type == 'jpeg' or $item->type == 'png' or $item->type == 'gif') {
         $this->resizeImage($item->path, $item->filename);
         if (!empty($exif['Orientation'])) {
             switch ($exif['Orientation']) {
                 case 8:
                     $item->rotate(270);
                     break;
                 case 3:
                     $item->rotate(180);
                     break;
                 case 6:
                     $item->rotate(90);
                     break;
             }
         }
     }
     if (isset($_POST['group_option']) and $_POST['group_option'] == 'existing') {
         $result = DB::query(Database::SELECT, "SELECT update_dt\n\t\t\tFROM kwalbum_items\n\t\t\tORDER BY id DESC\n\t\t\tLIMIT 1")->execute();
         $item->update_date = $result[0]['update_dt'];
         $item->save(false);
     } else {
         $item->save();
     }
     return $item->id;
 }
Пример #4
0
	<div>
		<div class="box box-thumbnail">
		Previous Item:<br/>
		<?php 
if ($previous_item->id) {
    echo Kwalbum_Helper::getThumbnailLink($previous_item, $kwalbum_url, $kwalbum_url_params);
} else {
    echo 'Viewing First Item';
}
?>
		</div>
		<div class="box box-thumbnail">
		Next Item:<br/>
		<?php 
if ($next_item->id) {
    echo Kwalbum_Helper::getThumbnailLink($next_item, $kwalbum_url, $kwalbum_url_params);
} else {
    echo 'Viewing Last Item';
}
?>
		</div>
	</div>

</div></div>

<div class="box">
	<div id="mapCanvas" class="kwalbumItemMapCanvas"></div>
</div>

<div class="box box-comments">
<a name='comments'><b>Comments:</b></a><br/>
Пример #5
0
 public function action_resetpassword()
 {
     $this->template->content = new View('kwalbum/user/resetpassword');
     $this->template->title = 'Reset Password';
     if (isset($_GET['h'])) {
         $temp = explode('.', $_GET['h']);
         if (!isset($temp[1])) {
             $this->template->content->message = '<span class="errors">This address is no longer valid for changing your password.</span>';
             return;
         }
         $hash = $temp[0];
         $id = (int) $temp[1];
         $user = Model::factory('Kwalbum_User')->load($id);
         if (!$user->reset_code or $user->reset_code != $hash) {
             $user->reset_code = '';
             $user->save();
             $this->template->content->message = '<span class="errors">This address is no longer valid for changing your password.</span>';
         } elseif (isset($_POST['act'])) {
             $pw = $_POST['pw'];
             if (strlen($pw) > 5) {
                 $user->password = $pw;
                 $user->reset_code = '';
                 $user->save();
                 $this->template->content->message = 'Your password has been changed and you can now <a href="' . $this->url . '/~user/login">log in</a>.';
             } else {
                 $this->template->content->message2 = '<div class="errors">New password must be at least 6 characters long.</div>';
             }
         }
         $user->permission_level = 0;
         $this->template->set_global('user', $user);
     } elseif (isset($_POST['act'])) {
         $login = $_POST['name'];
         $email = $_POST['email'];
         $user = Model::factory('Kwalbum_User')->load($login, 'login_name');
         if ($user->email == $email) {
             if (!$user->reset_code) {
                 $user->reset_code = Kwalbum_Helper::getRandomHash();
                 $user->save();
             }
             $host = $_SERVER['SERVER_NAME'];
             $emailMessage = "A password change has been requested for {$login} at {$host}.  To change it go to\n{$this->url}/~user/resetpassword/?h={$user->reset_code}.{$user->id}\n\nAutomatic email from\nKwalbum \n\n";
             if (!mail($email, 'Lost Password on ' . $host, $emailMessage, 'From: "do_not_reply.' . '" <kwalbum@' . $host . '>')) {
                 $this->template->content->message = '<span class="errors">Email with further instructions was not sent.  Please contact the website administrator.</span>';
             }
         }
         $this->template->content->message = 'If the login name and email address match, then an email has been sent with further instructions.  If you do not recieve the email within a few hours, check your junk mail folder then contact the website administrator if you still can not find it.  If you are unsure which email address or name you registered with, try them all until you get an email or contact the administrator and ask for help.';
     }
 }
Пример #6
0
 /**
  *
  * @param string $username
  * @param string $password
  * @param int $length length for cookie if using a cookie
  * @return Model_Kwalbum_User if login was successful
  */
 public static function login($username, $password, $length = 0)
 {
     $user = Model::factory('Kwalbum_User')->load($username, 'login_name');
     if (!$user->password_equals($password)) {
         session_start();
         unset($_SESSION['kwalbum_id']);
         unset($_SESSION['kwalbum_edit']);
         setcookie('kwalbum', '', time() - 36000, '/');
         session_write_close();
         return null;
     }
     $loginLength = (int) $length;
     $user->visit_date = date('Y-m-d H:i:s');
     $user->token = Kwalbum_Helper::getRandomHash();
     $user->save();
     if ($loginLength > 0) {
         setcookie('kwalbum', $user->id . ':' . $user->token, time() + $loginLength, '/');
     }
     session_start();
     $_SESSION['kwalbum_id'] = $user->id;
     session_write_close();
     return $user;
 }