Added : Photo EXIF Data in insert_photo()
Added : Make Avatar from any photo Added : Collection cover photo Added : An array for thumb creations. Includes, code, width, height, watermark, sharpit Added : Resizer class in common.php Added : jquery.Jcrop.js in edit_account Added : A common function called cb_filename. All filenames used in clipbucket follow a specific syntax Added : Four new function for photos. get_original_photo, insert_photo_colors, insert_exif_data & add_custom_photo_size Added : User Avatar collection functions. But they are not in use right now. This need proper thinking Added : New files: mobile-form-class.php, resizer.class.php, exif.php, makers files for exif, jquery.Jcrop plugin, some template files
This commit is contained in:
parent
aeb8a51330
commit
e0cca79526
30 changed files with 5009 additions and 232 deletions
72
upload/actions/photo_tagger.php
Normal file
72
upload/actions/photo_tagger.php
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @Author : Fawaz Tahir and Arslan Hassan
|
||||||
|
*/
|
||||||
|
|
||||||
|
include('../includes/config.inc.php');
|
||||||
|
$mode = mysql_clean($_POST['mode']);
|
||||||
|
|
||||||
|
switch ($mode) {
|
||||||
|
case 'a': case 'add': case 'add_tag': case 'addTag': {
|
||||||
|
/* ADDING NEW TAG
|
||||||
|
* First check if user is logged-in or not
|
||||||
|
* Yes, then check if value entered is actually a user or not.
|
||||||
|
* If it is a user then check if this user is a confirmed friend or not
|
||||||
|
* Yes it is confirmed friend, add tag with user profile link and remove link
|
||||||
|
* No it not a confirmed friend, add tag with remove link
|
||||||
|
*
|
||||||
|
* No entered value is not a user, add new tag with remove link
|
||||||
|
*
|
||||||
|
* THINGS TO UPDATE
|
||||||
|
* - IF VALUE IS USER
|
||||||
|
* --- update user column in which photo id's, in json format, reside which shows on what photos this user was tagged: COLUMN|
|
||||||
|
*/
|
||||||
|
if( !userid() ) {
|
||||||
|
echo json_encode( array('error' => true, 'error_message' => lang('login_to_add_tag') ) );
|
||||||
|
} else {
|
||||||
|
$clean_post = array();
|
||||||
|
foreach( $_POST as $key => $value ) {
|
||||||
|
if ( $key != 'label' ) {
|
||||||
|
$value = mysql_clean($value);
|
||||||
|
}
|
||||||
|
$clean_post[$key] = ($value);
|
||||||
|
}
|
||||||
|
$tag_id = $cbphoto->add_new_tag( $clean_post );
|
||||||
|
if(!error()) {
|
||||||
|
$tag = $cbphoto->get_tag_with_id( $tag_id , $clean_post['pid'] );
|
||||||
|
$clean_post['success'] = true;
|
||||||
|
$clean_post['id'] = $tag['ptag_id'];
|
||||||
|
$clean_post['canDelete'] = true;
|
||||||
|
if ( $tag['ptag_active'] == 'no' ) {
|
||||||
|
$clean_post['pending'] = true;
|
||||||
|
}
|
||||||
|
if ( $tag['ptag_isuser'] == 1 && $tag['ptag_isfriend'] == 1 ) {
|
||||||
|
$clean_post['link'] = $userquery->profile_link( $tag['ptag_userid'] ) ;
|
||||||
|
}
|
||||||
|
echo json_encode( $clean_post );
|
||||||
|
} else {
|
||||||
|
$msg = error_list();
|
||||||
|
$msg = $msg[0];
|
||||||
|
echo json_encode(array('error' => true, 'error_message' => $msg));
|
||||||
|
}
|
||||||
|
//echo json_encode( array('error' => true, 'error_message' => lang('unable_to_tag') ) );
|
||||||
|
}
|
||||||
|
}break;
|
||||||
|
|
||||||
|
case 'r': case 'remove': case 'remove_tag': case 'removeTag':{
|
||||||
|
$tag_id = mysql_clean($_POST['id']);
|
||||||
|
$return = $cbphoto->remove_photo_tag($tag_id);
|
||||||
|
if (!error()) {
|
||||||
|
echo json_encode(array('success' => true));
|
||||||
|
} else {
|
||||||
|
$msg = error_list();
|
||||||
|
$msg = $msg[0];
|
||||||
|
echo json_encode(array('error' => true, 'error_message' => $msg));
|
||||||
|
}
|
||||||
|
}break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
echo json_encode( array('error' => true, 'error_message' => lang('unable_to_tag_due_to_issue') ) );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
?>
|
|
@ -50,8 +50,109 @@ if(isset($_POST['block_users']))
|
||||||
$userquery->block_users($_POST['users']);
|
$userquery->block_users($_POST['users']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( mysql_clean($_GET['mode']) == 'make_avatar' ) {
|
||||||
|
|
||||||
|
$pid = mysql_clean( $_GET['pid'] );
|
||||||
|
$pid = $cbphoto->decode_key( $pid );
|
||||||
|
$pid = substr( $pid, 12, 12 );
|
||||||
|
$photo = $cbphoto->get_photo( $pid );
|
||||||
|
|
||||||
|
if ( !$photo ) {
|
||||||
|
e( lang('photo_not_exist') );
|
||||||
|
cb_show_page( false );
|
||||||
|
} else {
|
||||||
|
assign( 'photo', $photo );
|
||||||
|
if ( isset($_GET['set_avatar']) ) {
|
||||||
|
/* Run set avatar code */
|
||||||
|
} else if( isset( $_POST['set_avatar']) ) {
|
||||||
|
/* Run make avatar code */
|
||||||
|
include_once 'includes/classes/resizer.class.php';
|
||||||
|
$p = $cbphoto->get_image_file( $photo , 'o', false, null, false );
|
||||||
|
$source = PHOTOS_DIR.'/'.$p; $pd = json_decode( $photo['photo_details'] , true);
|
||||||
|
$r = new CB_Resizer( $source );
|
||||||
|
|
||||||
|
$x = mysql_clean( $_POST['start_x'] ); $x2 = mysql_clean( $_POST['end_x'] );
|
||||||
|
$y = mysql_clean( $_POST['start_y'] ); $y2 = mysql_clean( $_POST['end_y'] );
|
||||||
|
|
||||||
|
if (
|
||||||
|
( !is_numeric($x) || !is_numeric($x2) || !is_numeric($y) || !is_numeric($y2) )
|
||||||
|
) {
|
||||||
|
e('Unable to crop. Coordinates were unrealiable.');
|
||||||
|
} else {
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We will be using the original photo to crop the avatar.
|
||||||
|
* First we'll covert the posted pixels to percentage
|
||||||
|
* Second get pixels from original photo using percentage
|
||||||
|
* Using newly computed pixels crop from original photo
|
||||||
|
* Save it for temporary purpose, make it source and start making avatars
|
||||||
|
* Delete tempblock when all avatars are created
|
||||||
|
*/
|
||||||
|
|
||||||
|
$xx = ( ( $x / $pd['l']['width'] ) * 100 ); // compute percentage
|
||||||
|
$xx2 = ( ( $x2 / $pd['l']['width'] ) * 100 ); // compute percentage
|
||||||
|
$newX = ( ( $xx * $pd['o']['width'] ) / 100 ); // compute pixels
|
||||||
|
$newX2 = ( ( $xx2 * $pd['o']['width'] ) / 100 ); // compute pixels
|
||||||
|
|
||||||
|
$yy = ( ( $y / $pd['l']['height'] ) * 100 ); // compute percentage
|
||||||
|
$yy2 = ( ( $y2 / $pd['l']['height'] ) * 100 ); // compute percentage
|
||||||
|
$newY = ( ( $yy * $pd['o']['height'] ) / 100 ); // compute pixels
|
||||||
|
$newY2 = ( ( $yy2 * $pd['o']['height'] ) / 100 ); // compute pixels
|
||||||
|
|
||||||
|
/* We'll save temporary save the cropped photo. */
|
||||||
|
$tempblock = $r->target = USER_THUMBS_DIR.'/'.userid()."-tempblock.".$photo['ext'];
|
||||||
|
$r->_crop($newX, $newY, $newX2, $newY2 );
|
||||||
|
$r->save();
|
||||||
|
$exts = array('jpg','jpeg','png','gif');
|
||||||
|
|
||||||
|
/* Delete previous avatar */
|
||||||
|
foreach( $exts as $ext ) {
|
||||||
|
|
||||||
|
if ( file_exists( USER_THUMBS_DIR.'/'.userid().'.'.$ext ) ) {
|
||||||
|
unlink(USER_THUMBS_DIR.'/'.userid().'.'.$ext) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( file_exists(USER_THUMBS_DIR.'/'.userid().'-small.'.$ext) ) {
|
||||||
|
unlink( USER_THUMBS_DIR.'/'.userid().'-small.'.$ext );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Make $tempblock the source */
|
||||||
|
$r->source = $r->target;
|
||||||
|
|
||||||
|
/* Big Thumb */
|
||||||
|
$r->target = USER_THUMBS_DIR.'/'.userid().'.'.$photo['ext'];
|
||||||
|
$r->cropping = -1;
|
||||||
|
$r->_resize( AVATAR_SIZE );
|
||||||
|
$r->save();
|
||||||
|
|
||||||
|
/* Small Thumb */
|
||||||
|
$r->target = USER_THUMBS_DIR.'/'.userid().'-small.'.$photo['ext'];
|
||||||
|
$r->cropping = 1;
|
||||||
|
$r->_resize(AVATAR_SMALL_SIZE, AVATAR_SMALL_SIZE);
|
||||||
|
$r->save();
|
||||||
|
|
||||||
|
/* Remove $tempblock */
|
||||||
|
if ( file_exists($tempblock) ) {
|
||||||
|
unlink( $tempblock );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* go back to photo */
|
||||||
|
//redirect_to( $cbphoto->photo_links($photo, 'view_photo') );
|
||||||
|
|
||||||
|
/* go to user profile */
|
||||||
|
redirect_to( $userquery->profile_link(userid()) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
$mode = $_GET['mode'];
|
$mode = $_GET['mode'];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
switch($mode)
|
switch($mode)
|
||||||
{
|
{
|
||||||
case 'account':
|
case 'account':
|
||||||
|
@ -73,6 +174,11 @@ switch($mode)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'make_avatar': {
|
||||||
|
assign('mode', 'make_avatar');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case 'change_email':
|
case 'change_email':
|
||||||
{
|
{
|
||||||
assign('mode','change_email');
|
assign('mode','change_email');
|
||||||
|
|
|
@ -20,6 +20,7 @@ class Collections extends CBCategory
|
||||||
var $collection_delete_functions = array();
|
var $collection_delete_functions = array();
|
||||||
var $action = '';
|
var $action = '';
|
||||||
var $share_variables;
|
var $share_variables;
|
||||||
|
var $avatar_collection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setting variables of different thing which will
|
* Setting variables of different thing which will
|
||||||
|
@ -40,10 +41,12 @@ class Collections extends CBCategory
|
||||||
{
|
{
|
||||||
$this->cat_tbl = "collection_categories";
|
$this->cat_tbl = "collection_categories";
|
||||||
$this->section_tbl = "collections";
|
$this->section_tbl = "collections";
|
||||||
$this->types = array('videos' => lang("Videos"),'photos' => lang("Photos"));
|
$this->types = 'photos';
|
||||||
ksort($this->types);
|
$this->deprecated_types = array('videos' => lang("Videos"),'photos' => lang("Photos"));
|
||||||
|
//ksort($this->types);
|
||||||
|
|
||||||
$this->init_actions();
|
$this->init_actions();
|
||||||
|
$this->set_avatar_collection_id( 999 );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -433,7 +436,7 @@ class Collections extends CBCategory
|
||||||
$cond .= " AND ";
|
$cond .= " AND ";
|
||||||
$cond .= " ($title_tag) ";
|
$cond .= " ($title_tag) ";
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$p['count_only'])
|
if(!$p['count_only'])
|
||||||
{
|
{
|
||||||
if($cond != "")
|
if($cond != "")
|
||||||
|
@ -445,7 +448,7 @@ class Collections extends CBCategory
|
||||||
//echo $db->db_query;
|
//echo $db->db_query;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if($p['count_only'])
|
if($p['count_only'])
|
||||||
{
|
{
|
||||||
return $result = $db->count(tbl("collections"),"collection_id",$cond);
|
return $result = $db->count(tbl("collections"),"collection_id",$cond);
|
||||||
|
@ -1256,21 +1259,28 @@ class Collections extends CBCategory
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
$item = $this->get_collection_items($cid,'ci_id DESC',1);
|
$cover_photo = $cdetails['cover_photo'];
|
||||||
|
if ( $cover_photo != 0 && $ph = $this->object_in_collection( $cover_photo, $cid ) ) {
|
||||||
|
$item[0] = $ph;
|
||||||
|
} else {
|
||||||
|
$item = $this->get_collection_items($cid,'ci_id DESC',1);
|
||||||
|
}
|
||||||
|
|
||||||
$type = $item[0]['type'];
|
$type = $item[0]['type'];
|
||||||
switch($type)
|
switch($type)
|
||||||
{
|
{
|
||||||
case "v":
|
case "v":
|
||||||
{
|
{
|
||||||
global $cbvideo;
|
$thumb = $this->get_default_thumb( $size );
|
||||||
$thumb = get_thumb($cbvideo->get_video_details($item[0]['object_id']));
|
// global $cbvideo;
|
||||||
|
// $thumb = get_thumb($cbvideo->get_video_details($item[0]['object_id']));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "p":
|
case "p":
|
||||||
{
|
{
|
||||||
global $cbphoto;
|
global $cbphoto;
|
||||||
$thumb = $cbphoto->get_image_file($cbphoto->get_photo($item[0]['object_id']));
|
$thumb = $cbphoto->get_image_file( $cbphoto->get_photo( $item[0]['object_id'] ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1731,6 +1741,23 @@ class Collections extends CBCategory
|
||||||
.("type='".$type."'")." AND ".("object_id='".$objId."'"));
|
.("type='".$type."'")." AND ".("object_id='".$objId."'"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function set_avatar_collection_id( $id ) {
|
||||||
|
return $this->avatar_collection = $id;
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_avatar_collection_id () {
|
||||||
|
return $this->avatar_collection;
|
||||||
|
}
|
||||||
|
|
||||||
|
function set_cover_photo( $pid, $cid ) {
|
||||||
|
global $db;
|
||||||
|
$update = $db->update( tbl('collections'), array('cover_photo'),array($pid), " collection_id = '".$cid."' " );
|
||||||
|
if ( $update ) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
168
upload/includes/classes/mobile-form-class.php
Normal file
168
upload/includes/classes/mobile-form-class.php
Normal file
|
@ -0,0 +1,168 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class MobileForm
|
||||||
|
extends formObj {
|
||||||
|
|
||||||
|
function createCheckBox( $field, $multi = FALSE ) {
|
||||||
|
if ( $field['value'][0] == 'category' ) {
|
||||||
|
$values_array = $field['value'][1][0];
|
||||||
|
$type = $field['category_type'] ? $field['category_type'] : 'video';
|
||||||
|
$catArray = getCategoryList( array("type" => $type) );
|
||||||
|
if ( is_array( $catArray ) ) {
|
||||||
|
$params['categories'] = $catArray;
|
||||||
|
$params['field'] = $field;
|
||||||
|
$params['collapsed'] = false;
|
||||||
|
$this->listCategoryCheckBox( $params, $multi );
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
return "There is no category to select";
|
||||||
|
}
|
||||||
|
} /* Categories end */
|
||||||
|
|
||||||
|
$arrayName = $this->rmBrackets( $field['name'] );
|
||||||
|
$check = '%s'; $count = 0;
|
||||||
|
if($multi)
|
||||||
|
{
|
||||||
|
global $multi_cat_id;
|
||||||
|
@$multi_cat_id++;
|
||||||
|
}
|
||||||
|
foreach ( $field['value'] as $key => $value ) {
|
||||||
|
if ( is_array( $values_array ) ) {
|
||||||
|
foreach ( $values_array as $cat_val ) {
|
||||||
|
if ( $cat_val == $key || $field['checked'] == 'checked' ) {
|
||||||
|
$checked = sprintf($check,'checked="checked"');
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
$checked = sprintf($check,'');;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !$multi ) {
|
||||||
|
$field_name = $field['name'];
|
||||||
|
} else {
|
||||||
|
$field_name = $field['name'];
|
||||||
|
$field_name = $this->rmBrackets($field_name);
|
||||||
|
$field_name = $field_name.$multi_cat_id.'[]';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !empty($field['id']) ) {
|
||||||
|
$field_id = $field['id'].'_'.$count;
|
||||||
|
} else {
|
||||||
|
$field_id = $arrayName.'_'.$count;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($field['multi']) {
|
||||||
|
preg_match_all('/#([0-9]+)#/',$field['checked'],$m);
|
||||||
|
$multiVals = $m[1];
|
||||||
|
if(in_array($key,$multiVals)) {
|
||||||
|
$checked = sprintf($check,'checked="checked"');
|
||||||
|
} else {
|
||||||
|
$checked = sprintf($check,'');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ( $key == $field['checked'] ) {
|
||||||
|
$checked = sprintf($check,'checked="checked"');
|
||||||
|
} else {
|
||||||
|
$checked = sprintf($check,'');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
echo '<input name="' . $field_name . '" id="' . $field_id . '" type="checkbox" value="' . $key . '" ' . $checked . ' ' . $field['extra_tags'] . ' />';
|
||||||
|
echo '<label for="' . $field_id . '">' . $value . '</label>';
|
||||||
|
$count++;
|
||||||
|
} #foreach end
|
||||||
|
}
|
||||||
|
|
||||||
|
function listCategoryCheckBoxCollapsed( $in, $multi ) {
|
||||||
|
$this->listCategoryCheckBox( $in, $multi );
|
||||||
|
}
|
||||||
|
|
||||||
|
function listCategoryCheckBox ( $in, $multi ) {
|
||||||
|
$cats = $in['categories']; $field = $in['field'];
|
||||||
|
$count = 0; $check = '%s';
|
||||||
|
if ( $count == 0 && !$in['children_indent']) {
|
||||||
|
$field['sep'] = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !$mutli ) {
|
||||||
|
$field_name = $field['name'];
|
||||||
|
} else {
|
||||||
|
$field_name = $field['name'];
|
||||||
|
$field_name = $this->rmBrackets($field_name);
|
||||||
|
$field_name = $field_name.$this->multi_cat_id.'[]';
|
||||||
|
}
|
||||||
|
|
||||||
|
$values = $field['value'][1][0];
|
||||||
|
if(!empty($values)) {
|
||||||
|
foreach($values as $val) {
|
||||||
|
$newVals[] = '|'.$val.'|';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !empty($field['id']) ) {
|
||||||
|
$field_id = $field['id'].'_'.$count;
|
||||||
|
} else {
|
||||||
|
$field_id = strtolower( str_replace( '_', '', $field['name'] ) ) . '_' . $count;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $cats ) {
|
||||||
|
foreach ( $cats as $cat ) {
|
||||||
|
if(in_array('|'.$cat['category_id'].'|',$newVals)) {
|
||||||
|
$checked = sprintf($check,'checked="checked"');
|
||||||
|
} else {
|
||||||
|
$checked = sprintf($check,'');
|
||||||
|
}
|
||||||
|
$field_id .= '_'.$cat['category_id'];
|
||||||
|
echo '<input name="' . $field_name . '" id="' . $field_id . '" type="checkbox" value="' . $cat['category_id'] . '" ' . $checked . ' ' . $field['extra_tags'] . ' />';
|
||||||
|
echo '<label for="' . $field_id . '">' . $field['sep'] .' '. $cat['category_name'] . '</label>';
|
||||||
|
$count++;
|
||||||
|
if ( $cat['children'] ) {
|
||||||
|
$childField = $field;
|
||||||
|
$childField['sep'] = $field['sep'].str_repeat('–',1);
|
||||||
|
$this->listCategoryCheckBox(array('categories'=>$cat['children'],'field'=>$childField,'children_indent'=>true),$multi);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function createRadioButton( $field, $multi = FALSE ) {
|
||||||
|
$count = 0;
|
||||||
|
$arrayName = $this->rmBrackets( $field['name'] );
|
||||||
|
foreach ( $field['value'] as $key => $value ) {
|
||||||
|
if ( !empty( $_POST[$arrayName] ) || !empty( $field['checked'] ) ) {
|
||||||
|
if ( $_POST[$arrayName] == $key || $field['checked'] == $key ) {
|
||||||
|
$checked = 'checked = "checked "';
|
||||||
|
} else {
|
||||||
|
$checked = '';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ( $count == 0 ) {
|
||||||
|
$checked = 'checked = "checked "';
|
||||||
|
} else {
|
||||||
|
$checked = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !empty( $field['id'] ) ) {
|
||||||
|
$field_id = $field['id'] . '_' . $count;
|
||||||
|
} else {
|
||||||
|
$field_id = strtolower( str_replace( '_', '', $field['name'] ) ) . '_' . $count;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !$multi ) {
|
||||||
|
$field_name = $field['name'];
|
||||||
|
} else {
|
||||||
|
$field_name = $field['name'] . '[]';
|
||||||
|
}
|
||||||
|
|
||||||
|
echo '<input name="' . $field_name . '" id="' . $field_id . '" type="radio" value="' . $key . '" ' . $checked . ' ' . $field['extra_tags'] . ' />';
|
||||||
|
echo '<label for="' . $field_id . '">' . $value . '</label>';
|
||||||
|
$count++;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -35,6 +35,7 @@ class CBPhotos {
|
||||||
var $search;
|
var $search;
|
||||||
var $tagger_configs;
|
var $tagger_configs;
|
||||||
var $selector_id = 'photo';
|
var $selector_id = 'photo';
|
||||||
|
var $thumb_dimensions = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* __Constructor of CBPhotos
|
* __Constructor of CBPhotos
|
||||||
|
@ -55,6 +56,37 @@ class CBPhotos {
|
||||||
$this->photos_admin_menu();
|
$this->photos_admin_menu();
|
||||||
$this->setting_other_things();
|
$this->setting_other_things();
|
||||||
$this->set_photo_max_size();
|
$this->set_photo_max_size();
|
||||||
|
$this->thumb_dimensions = array(
|
||||||
|
't' => array(
|
||||||
|
'width' => config('photo_thumb_width'),
|
||||||
|
'height' => config('photo_thumb_height'),
|
||||||
|
'crop' => (config('photo_crop') == 0 ? -1 : 4 ),
|
||||||
|
'watermark' => false,
|
||||||
|
'shrapit' => true
|
||||||
|
),
|
||||||
|
'm' => array(
|
||||||
|
'width' => config('photo_med_width'),
|
||||||
|
'height' => config('photo_med_height'),
|
||||||
|
'crop' => (config('photo_crop') == 0 ? -1 : 4 ),
|
||||||
|
'watermark' => false,
|
||||||
|
'shrapit' => false
|
||||||
|
),
|
||||||
|
'l' => array(
|
||||||
|
'width' => config('photo_lar_width'),
|
||||||
|
'height' => 0,
|
||||||
|
'crop' => -1,
|
||||||
|
'watermark' => true,
|
||||||
|
'shrapit' => false
|
||||||
|
),
|
||||||
|
'o' => array(
|
||||||
|
'width' => 0,
|
||||||
|
'height' => 0,
|
||||||
|
'crop' => -1,
|
||||||
|
'watermark' => true,
|
||||||
|
'shrapit' => false
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
/* Following is a sample for custom thumbs. We will have a config called 'custom_thumbs'.
|
/* Following is a sample for custom thumbs. We will have a config called 'custom_thumbs'.
|
||||||
* This will be a json_encoded multi-dimensional associative array. It's will be following
|
* This will be a json_encoded multi-dimensional associative array. It's will be following
|
||||||
* $custom_thumbs = [type:'video|user|collection|photo|group'] => array(
|
* $custom_thumbs = [type:'video|user|collection|photo|group'] => array(
|
||||||
|
@ -1202,7 +1234,12 @@ class CBPhotos {
|
||||||
$insert_id = $db->insert( tbl( $this->p_tbl ), $query_field, $query_val );
|
$insert_id = $db->insert( tbl( $this->p_tbl ), $query_field, $query_val );
|
||||||
$photo = $this->get_photo( $insert_id );
|
$photo = $this->get_photo( $insert_id );
|
||||||
$this->collection->add_collection_item( $insert_id, $photo['collection_id'] );
|
$this->collection->add_collection_item( $insert_id, $photo['collection_id'] );
|
||||||
|
|
||||||
|
/*
|
||||||
|
* EXIF should be added here
|
||||||
|
*/
|
||||||
|
insert_exif_data( $photo );
|
||||||
|
|
||||||
if ( !$array['server_url'] || $array['server_url'] == 'undefined' )
|
if ( !$array['server_url'] || $array['server_url'] == 'undefined' )
|
||||||
$this->generate_photos( $photo );
|
$this->generate_photos( $photo );
|
||||||
|
|
||||||
|
@ -1679,7 +1716,7 @@ class CBPhotos {
|
||||||
|
|
||||||
$img = "<img ";
|
$img = "<img ";
|
||||||
$img .= "src = '" . $src . "'";
|
$img .= "src = '" . $src . "'";
|
||||||
if ( USE_PHOTO_TAGGING ) {
|
if ( USE_PHOTO_TAGGING && THIS_PAGE == 'view_item' ) {
|
||||||
$img .= " id = '".$this->get_selector_id()."_".$photo['photo_id']."' ";
|
$img .= " id = '".$this->get_selector_id()."_".$photo['photo_id']."' ";
|
||||||
} else {
|
} else {
|
||||||
if ( $p['id'] ) {
|
if ( $p['id'] ) {
|
||||||
|
@ -1959,13 +1996,22 @@ class CBPhotos {
|
||||||
case "download_photo":
|
case "download_photo":
|
||||||
case "download": {
|
case "download": {
|
||||||
return BASEURL . "/download_photo.php?download=" . $this->encode_key( $details['photo_key'] );
|
return BASEURL . "/download_photo.php?download=" . $this->encode_key( $details['photo_key'] );
|
||||||
}
|
} break;
|
||||||
|
|
||||||
case "view_item":
|
case "view_item":
|
||||||
case "view_photo": {
|
case "view_photo": {
|
||||||
return $this->collection->collection_links( $details, 'view_item' );
|
return $this->collection->collection_links( $details, 'view_item' );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case "make_avatar": case "ma": {
|
||||||
|
|
||||||
|
if ( $details['collection_id'] == 1) {
|
||||||
|
$set_avatar = '&set_avatar=1';
|
||||||
|
}
|
||||||
|
|
||||||
|
$link = BASEURL.'/edit_account.php?pid='.$this->encode_key(RandomString(12).$details['photo_key']).'&mode=make_avatar&u='.$details['userid'].$set_avatar;
|
||||||
|
}break;
|
||||||
}
|
}
|
||||||
return $link;
|
return $link;
|
||||||
}
|
}
|
||||||
|
|
911
upload/includes/classes/resizer.class.php
Normal file
911
upload/includes/classes/resizer.class.php
Normal file
|
@ -0,0 +1,911 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CB_Resizer
|
||||||
|
* Global Class for image resizing
|
||||||
|
*/
|
||||||
|
|
||||||
|
class CB_Resizer {
|
||||||
|
|
||||||
|
var $source; // filepath to source file
|
||||||
|
var $target; // complete filepath where file will be saved
|
||||||
|
var $quality; // image quality, for jpeg
|
||||||
|
var $png_quality; // image quality, for png
|
||||||
|
var $cropping;
|
||||||
|
var $preserve_aspect;
|
||||||
|
var $exact_dimensions;
|
||||||
|
var $bgcolor = "#FFFFFF";
|
||||||
|
var $watermark_placement;
|
||||||
|
var $watermark_padding = 10;
|
||||||
|
var $font = 'freeroad.ttf';
|
||||||
|
var $font_size = 48;
|
||||||
|
protected $fonts_dir = 'fonts/';
|
||||||
|
|
||||||
|
function __construct( $filepath = '' ) {
|
||||||
|
|
||||||
|
$this->quality = 90;
|
||||||
|
|
||||||
|
$this->png_quality = 9;
|
||||||
|
|
||||||
|
$this->cropping = 4;
|
||||||
|
|
||||||
|
$this->preserve_aspect = $this->auto_resource = true;
|
||||||
|
|
||||||
|
$this->exact_dimensions = false;
|
||||||
|
|
||||||
|
$this->source = $filepath;
|
||||||
|
|
||||||
|
$this->target = '';
|
||||||
|
|
||||||
|
$this->number_of_colors = 25;
|
||||||
|
|
||||||
|
$this->_setup_filters();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* resizing method
|
||||||
|
*/
|
||||||
|
function _resize( $width = 0, $height = 0, $background = null, $resource = null ) {
|
||||||
|
if ( $this->_check_resource( $resource ) ) {
|
||||||
|
if ( $width == 0 || $height == 0 ) {
|
||||||
|
$must_preserve_aspect = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $this->preserve_aspect == true || $must_preserve_aspect == true ) {
|
||||||
|
|
||||||
|
if ( $width > 0 && $height == 0 ) {
|
||||||
|
|
||||||
|
$aspect_ratio = $this->source_height / $this->source_width;
|
||||||
|
$target_width = $width;
|
||||||
|
$target_height = round( $width * $aspect_ratio );
|
||||||
|
} else if ( $width == 0 && $height > 0 ) {
|
||||||
|
|
||||||
|
$aspect_ratio = $this->source_width / $this->source_height;
|
||||||
|
$target_height = $height;
|
||||||
|
$target_width = round( $height * $aspect_ratio );
|
||||||
|
} else if ( $width > 0 && $height > 0 && $this->exact_dimensions == true ) {
|
||||||
|
|
||||||
|
$x_aspect_ratio = $this->source_width / $width;
|
||||||
|
$y_aspect_ratio = $this->source_height / $height;
|
||||||
|
|
||||||
|
if ( round( $this->source_height / $x_aspect_ratio ) < $height ) {
|
||||||
|
$target_width = $width;
|
||||||
|
$target_height = round( $this->source_height / $x_aspect_ratio );
|
||||||
|
} else {
|
||||||
|
$target_height = $height;
|
||||||
|
$target_width = round( $this->source_width / $y_aspect_ratio );
|
||||||
|
}
|
||||||
|
} else if ( $width > 0 && $height > 0 ) {
|
||||||
|
$x_aspect_ratio = $this->source_width / $width;
|
||||||
|
$y_aspect_ratio = $this->source_height / $height;
|
||||||
|
|
||||||
|
if ( $this->cropping != -1 ) {
|
||||||
|
$aspect_ratio = min( $x_aspect_ratio, $y_aspect_ratio );
|
||||||
|
} else {
|
||||||
|
$aspect_ratio = max( $x_aspect_ratio, $y_aspect_ratio );
|
||||||
|
}
|
||||||
|
|
||||||
|
$target_width = round( $this->source_width / $aspect_ratio );
|
||||||
|
$target_height = round( $this->source_height / $aspect_ratio );
|
||||||
|
} else {
|
||||||
|
$target_width = $this->source_width;
|
||||||
|
$target_height = $this->source_height;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$target_width = ( $width > 0 ? $width : $this->source_width );
|
||||||
|
$target_height = ( $height > 0 ? $height : $this->source_height );
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->target_width = $target_width;
|
||||||
|
$this->target_height = $target_height;
|
||||||
|
|
||||||
|
if ( ($this->preserve_aspect == true || $must_preserve_aspect == true ) && $this->exact_dimensions != true ) {
|
||||||
|
$canvas = $this->_create_canvas( $target_width, $target_height, -1 );
|
||||||
|
imagecopyresampled( $canvas, $this->resource, 0, 0, 0, 0, $target_width, $target_height, $this->source_width, $this->source_height );
|
||||||
|
if ( $this->cropping != -1 && $width > 0 && $height > 0 ) {
|
||||||
|
switch ( $this->cropping ) {
|
||||||
|
// TOP LEFT
|
||||||
|
case 0: {
|
||||||
|
$start_x = 0;
|
||||||
|
$start_y = 0;
|
||||||
|
$end_x = $width;
|
||||||
|
$end_y = $height;
|
||||||
|
}break;
|
||||||
|
// TOP CENTER
|
||||||
|
case 1: {
|
||||||
|
$start_x = ( $target_width - $width ) / 2;
|
||||||
|
$start_y = 0;
|
||||||
|
$end_x = ( ( $target_width - $width ) / 2 ) + $width;
|
||||||
|
$end_y = $height;
|
||||||
|
}break;
|
||||||
|
// TOP RIGHT
|
||||||
|
case 2 : {
|
||||||
|
$start_x = $target_width - $width;
|
||||||
|
$start_y = 0;
|
||||||
|
$end_x = $target_width;
|
||||||
|
$end_y = $height;
|
||||||
|
}break;
|
||||||
|
// LEFT
|
||||||
|
case 3 : {
|
||||||
|
$start_x = 0;
|
||||||
|
$start_y = ( $target_height - $height ) / 2;
|
||||||
|
$end_x = $width;
|
||||||
|
$end_y = ( ( $target_height - $height ) / 2 ) + $height;
|
||||||
|
}break;
|
||||||
|
// CENTER
|
||||||
|
case 4 : default : {
|
||||||
|
$start_x = ( $target_width - $width ) / 2;
|
||||||
|
$start_y = ( $target_height - $height ) / 2;
|
||||||
|
$end_x = ( ( $target_width - $width ) / 2 ) + $width;
|
||||||
|
$end_y = ( ( $target_height - $height ) / 2 ) + $height;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
// RIGHT
|
||||||
|
case 5 : {
|
||||||
|
$start_x = $target_width - $width;
|
||||||
|
$start_y = ( $target_height - $height ) / 2;
|
||||||
|
$end_x = $target_width;
|
||||||
|
$end_y = ( ( $target_height - $height ) / 2 ) + $height;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
// BOTTOM LEFT
|
||||||
|
case 6 : {
|
||||||
|
$start_x = 0;
|
||||||
|
$start_y = $target_height - $height;
|
||||||
|
$end_x = $width;
|
||||||
|
$end_y = $target_height;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
// BOTTOM CENTER
|
||||||
|
case 7 : {
|
||||||
|
$start_x = ( $target_width - $width ) / 2;
|
||||||
|
$start_y = $target_height - $height;
|
||||||
|
$end_x = ( ( $target_width - $width ) / 2 ) + $width;
|
||||||
|
$end_y = $target_height;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
// BOTTOM RIGHT
|
||||||
|
case 8: {
|
||||||
|
$start_x = $target_width - $width;
|
||||||
|
$start_y = $target_height - $height;
|
||||||
|
$end_x = $target_width;
|
||||||
|
$end_y = $target_height;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->_crop( $start_x, $start_y, $end_x, $end_y, $canvas );
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$canvas = $this->_create_canvas( ( $width > 0 && $height > 0 ? $width : $target_width ), ( $width > 0 && $height > 0 ? $height : $target_height ), $background );
|
||||||
|
imagecopyresampled(
|
||||||
|
$canvas, $this->resource, ( $width > 0 && $height > 0 ? ( $width - $target_width ) / 2 : 0 ), ( $width > 0 && $height > 0 ? ( $height - $target_height ) / 2 : 0 ), 0, 0, $target_width, $target_height, $this->source_width, $this->source_height );
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->final_image = $canvas;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* create resource from provided source method
|
||||||
|
*/
|
||||||
|
function _create_resource() {
|
||||||
|
if ( !function_exists( 'gd_info' ) ) {
|
||||||
|
echo 'no function';
|
||||||
|
return false;
|
||||||
|
} else if ( !is_file( $this->source ) ) {
|
||||||
|
echo 'no source file';
|
||||||
|
return false;
|
||||||
|
} else if ( !is_readable( $this->source ) ) {
|
||||||
|
echo 'no source readble';
|
||||||
|
return false;
|
||||||
|
} /*else if ( !is_writable( FOLDER ) ) {
|
||||||
|
echo 'no target writeable';
|
||||||
|
return false;
|
||||||
|
}*/ else {
|
||||||
|
list ( $this->source_width, $this->source_height, $this->source_type ) = getimagesize( $this->source );
|
||||||
|
$this->target_extension = $this->get_extension( $this->target );
|
||||||
|
|
||||||
|
switch ( $this->source_type ) {
|
||||||
|
// GIF
|
||||||
|
case 1: case IMAGETYPE_GIF: {
|
||||||
|
$resource = imagecreatefromgif( $this->source );
|
||||||
|
$this->gif_transparent_index = imagecolortransparent( $resource );
|
||||||
|
if ( $this->gif_transparent_index >= 0 ) {
|
||||||
|
$this->gif_transparent_color = imagecolorsforindex( $resource, $this->gif_transparent_index );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
// JPG
|
||||||
|
case 2: case IMAGETYPE_JPEG: {
|
||||||
|
$resource = imagecreatefromjpeg( $this->source );
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
//PNG
|
||||||
|
case 3: case IMAGETYPE_PNG: {
|
||||||
|
$resource = imagecreatefrompng( $this->source );
|
||||||
|
imagealphablending( $resource, false );
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->resource = $resource;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a blank canvas with provided width and height
|
||||||
|
*/
|
||||||
|
function _create_canvas( $width, $height, $background = null ) {
|
||||||
|
$canvas = imagecreatetruecolor( ($width <= 0 ? (int) 1 : (int) $width ), ( $height <= 0 ? (int) 1 : (int) $height ) );
|
||||||
|
if ( is_null( $background ) ) {
|
||||||
|
$background = $this->bgcolor;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $this->target_extension == 'png' && $background == -1 ) {
|
||||||
|
imagealphablending( $canvas, false );
|
||||||
|
$color = imagecolorallocatealpha( $canvas, 0, 0, 0, 127 );
|
||||||
|
imagefill( $canvas, 0, 0, $color );
|
||||||
|
imagesavealpha( $canvas, true );
|
||||||
|
} else if ( $this->target_extension == 'gif' && $this->gif_transparent_index >= 0 && $background == -1 ) {
|
||||||
|
$color = imagecolorallocate( $canvas, $this->gif_transparent_color['red'], $this->gif_transparent_color['green'], $this->gif_transparent_color['blue'] );
|
||||||
|
imagefill( $canvas, 0, 0, $color );
|
||||||
|
imagecolortransparent( $canvas, $color );
|
||||||
|
} else {
|
||||||
|
if ( $background == -1 ) {
|
||||||
|
$background = $this->bgcolor;
|
||||||
|
}
|
||||||
|
$color = $this->_hex2rgb( $background );
|
||||||
|
$color = imagecolorallocate( $canvas, $color['r'], $color['g'], $color['b'] );
|
||||||
|
imagefill( $canvas, 0, 0, $color );
|
||||||
|
}
|
||||||
|
|
||||||
|
return $canvas;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get extension of provided source or from global source
|
||||||
|
*/
|
||||||
|
function get_extension( $source = null ) {
|
||||||
|
if ( is_null( $source ) ) {
|
||||||
|
$source = $this->source;
|
||||||
|
}
|
||||||
|
|
||||||
|
return end( explode( ".", $source ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert HEX ( #FFF|#FFFFFF ) to rgb( red, green, blue )
|
||||||
|
*/
|
||||||
|
function _hex2rgb( $color ) {
|
||||||
|
if ( $color == -1 ) {
|
||||||
|
$color = $this->bgcolor;
|
||||||
|
}
|
||||||
|
|
||||||
|
$color = ltrim( $color, '#' );
|
||||||
|
if ( strlen( $color ) == 3 ) {
|
||||||
|
$tmp_code = '';
|
||||||
|
for ( $i = 0; $i < 3; $i++ ) {
|
||||||
|
$tmp_code .= str_repeat( $color[$i], 2 );
|
||||||
|
}
|
||||||
|
$color = $tmp_code;
|
||||||
|
}
|
||||||
|
|
||||||
|
list ( $r, $g, $b ) = str_split( $color, 2 );
|
||||||
|
$rgb = array('r' => hexdec( $r ), 'g' => hexdec( $g ), 'b' => hexdec( $b ));
|
||||||
|
return $rgb;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* crop method
|
||||||
|
*/
|
||||||
|
function _crop( $x_start, $y_start, $x_end, $y_end, $resource = null ) {
|
||||||
|
|
||||||
|
if ( $this->_check_resource( $resource ) ) {
|
||||||
|
// Difference of end and start point is area that needs to be cropped
|
||||||
|
$canvas = $this->_create_canvas( $x_end - $x_start, $y_end - $y_start );
|
||||||
|
imagecopyresampled(
|
||||||
|
$canvas, $this->resource, 0, 0, $x_start, $y_start, $x_end - $x_start, $y_end - $y_start, $x_end - $x_start, $y_end - $y_start );
|
||||||
|
|
||||||
|
return $this->final_image = $canvas;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* find sharpness method
|
||||||
|
* function from Ryan Rud (http://adryrun.com)
|
||||||
|
*/
|
||||||
|
function findSharp( $orig, $final ) {
|
||||||
|
$final = $final * (750.0 / $orig);
|
||||||
|
$a = 52;
|
||||||
|
$b = -0.27810650887573124;
|
||||||
|
$c = .00047337278106508946;
|
||||||
|
$result = $a + $b * $final + $c * $final * $final;
|
||||||
|
|
||||||
|
return max( round( $result ), 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* method used to display image in browser
|
||||||
|
*/
|
||||||
|
function display() {
|
||||||
|
$image = @$this->final_image;
|
||||||
|
if ( !is_resource( $image ) ) {
|
||||||
|
$image = $this->_check_resource();
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
switch ( $this->target_extension ? $this->target_extension : $this->get_extension($this->source) ) {
|
||||||
|
case "gif": {
|
||||||
|
header( 'Content-Type: image/gif' );
|
||||||
|
imagegif( $image );
|
||||||
|
$this->_destroy();
|
||||||
|
}break;
|
||||||
|
|
||||||
|
case "jpg": case "jpeg": {
|
||||||
|
header( 'Content-Type: image/jpeg' );
|
||||||
|
imagejpeg( $image, null, $this->quality );
|
||||||
|
$this->_destroy();
|
||||||
|
}break;
|
||||||
|
|
||||||
|
case "png" : {
|
||||||
|
header( 'Content-Type: image/png' );
|
||||||
|
imagepng( $image, null, $this->png_quality );
|
||||||
|
$this->_destroy();
|
||||||
|
}break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* method used to save image to provided $this->target
|
||||||
|
*/
|
||||||
|
function save() {
|
||||||
|
$image = @$this->final_image;
|
||||||
|
if ( !is_resource( $image ) ) {
|
||||||
|
$image = $this->_check_resource();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( is_resource( $image ) ) {
|
||||||
|
|
||||||
|
if ( (IMAGETYPE_PNG == $this->source_type || IMAGETYPE_GIF == $this->source_type ) && function_exists('imageistruecolor') && !imageistruecolor( $image ) && imagecolortransparent( $image ) > 0 ) {
|
||||||
|
imagetruecolortopalette( $image, false, imagecolorstotal( $image ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
switch ( $this->target_extension ) {
|
||||||
|
|
||||||
|
case "gif": {
|
||||||
|
if ( !imagegif( $image, $this->target ) ) {
|
||||||
|
echo 'GIF Error';
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
$this->_destroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "jpg": case "jpeg": {
|
||||||
|
if ( !imagejpeg( $image, $this->target, $this->quality ) ) {
|
||||||
|
echo 'JPG Error';
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
$this->_destroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "png": {
|
||||||
|
if ( !imageistruecolor($image) && function_exists('imageistruecolor') ) {
|
||||||
|
imagetruecolortopalette( $image, false, imagecolorstotal($image) );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !imagepng( $image, $this->target, $this->png_quality ) ) {
|
||||||
|
echo 'PNG Error';
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
$this->_destroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
echo 'Error Occured';
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* flipping the image
|
||||||
|
*/
|
||||||
|
function _flip( $side, $resource = null ) {
|
||||||
|
if ( $this->_check_resource( $resource ) ) {
|
||||||
|
$canvas = $this->_create_canvas( $this->source_width, $this->source_height . -1 );
|
||||||
|
|
||||||
|
switch ( $side ) {
|
||||||
|
case "vertical": {
|
||||||
|
imagecopyresampled(
|
||||||
|
$canvas, $this->resource, 0, 0, 0, ( $this->source_height - 1 ), $this->source_width, $this->source_height, $this->source_width, -$this->source_height );
|
||||||
|
}break;
|
||||||
|
case "horizontal": {
|
||||||
|
imagecopyresampled(
|
||||||
|
$canvas, $this->resource, 0, 0, ( $this->source_width - 1 ), 0, $this->source_width, $this->source_height, -$this->source_width, $this->source_height );
|
||||||
|
}break;
|
||||||
|
case "both": {
|
||||||
|
imagecopyresampled(
|
||||||
|
$canvas, $this->resource, 0, 0, ( $this->source_width - 1 ), ( $this->source_height - 1 ), $this->source_width, $this->source_height, -$this->source_width, -$this->source_height );
|
||||||
|
}break;
|
||||||
|
default: {
|
||||||
|
return false;
|
||||||
|
}break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->final_image = $canvas;
|
||||||
|
return $this->final_image;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* rotating the image
|
||||||
|
*/
|
||||||
|
function _rotate( $angle, $background = null, $resource = null) {
|
||||||
|
if ( is_null( $background ) ) {
|
||||||
|
$background = $this->bgcolor;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $this->_check_resource( $resource) ) {
|
||||||
|
$angle = -$angle;
|
||||||
|
|
||||||
|
if ( $this->source_type == IMAGETYPE_PNG && $background == -1 ) {
|
||||||
|
// Because PNG8 fails to rotate, fill with default background color
|
||||||
|
if ( !$this->final_image = imagerotate( $this->resource, $angle, -1 ) ) {
|
||||||
|
$color = $this->_hex2rgb( $this->bgcolor );
|
||||||
|
$background = imagecolorallocate( $this->resource, $color['r'], $color['g'], $color['b'] );
|
||||||
|
$this->final_image = imagerotate( $this->resource, $angle, $background );
|
||||||
|
}
|
||||||
|
} else if ( $this->source_type == IMAGETYPE_GIF && $this->gif_transparent_index >= 0 ) {
|
||||||
|
$c = $this->_hex2rgb( $background );
|
||||||
|
$background_color = imagecolorallocate( $this->resource, $c['r'], $c['g'], $c['g'] );
|
||||||
|
$this->resource = imagerotate( $this->resource, $angle, $background_color );
|
||||||
|
|
||||||
|
// Transpareney is messed-up, we will recreate photo with imagecopysampled to
|
||||||
|
// preserve transparency
|
||||||
|
$width = imagesx( $this->resource );
|
||||||
|
$height = imagesy( $this->resource );
|
||||||
|
|
||||||
|
$canvas = $this->_create_canvas( $width, $height, -1 );
|
||||||
|
$this->final_image = imagecopyresampled( $canvas, $this->resource, 0, 0, 0, 0, $width, $height, $width, $height );
|
||||||
|
} else {
|
||||||
|
$c = $this->_hex2rgb( $background );
|
||||||
|
$background_color = imagecolorallocate( $this->resource, $c['r'], $c['g'], $c['b'] );
|
||||||
|
$this->final_image = imagerotate( $this->resource, $angle, $background_color );
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->final_image;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* used to apply sharpness on image
|
||||||
|
*/
|
||||||
|
function _sharpit( $resource = null ) {
|
||||||
|
|
||||||
|
if ( !function_exists('imageconvolution') ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $this->_check_resource( $resource ) ) {
|
||||||
|
$sharpness = $this->findSharp( $this->source_width, $this->target_width );
|
||||||
|
$sharpenMatrix = array(
|
||||||
|
array(-1, -1, -1),
|
||||||
|
array(-1, $sharpness + 10, -2),
|
||||||
|
array(-1, -1, -1)
|
||||||
|
);
|
||||||
|
$divisor = $sharpness;
|
||||||
|
$offset = 0;
|
||||||
|
// apply the matrix
|
||||||
|
imageconvolution( $this->resource, $sharpenMatrix, $divisor, $offset );
|
||||||
|
$this->final_image = $this->resource;
|
||||||
|
return $this->final_image;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rotate left using _rotate method
|
||||||
|
*/
|
||||||
|
function rotate_left( $background = null, $resource = null ) {
|
||||||
|
return $this->_rotate( -90, $background, $resource );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rotate right using _rotate method
|
||||||
|
*/
|
||||||
|
function rotate_right( $background = null, $resource = null ) {
|
||||||
|
return $this->_rotate( 90, $background, $resource );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Flip the image vertically and horizontally
|
||||||
|
*/
|
||||||
|
function flip( $resource = null) {
|
||||||
|
return $this->_flip( "both" , $resource);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Flip the image vertically
|
||||||
|
*/
|
||||||
|
function flip_vertical( $resource = null ) {
|
||||||
|
return $this->_flip( "vertical" , $resource );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Flip the image horizontally
|
||||||
|
*/
|
||||||
|
function flip_horizontal( $resource = null ) {
|
||||||
|
return $this->_flip( "horizontal" , $resource );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method checks which resource to use
|
||||||
|
* 1 - If resource provided to function, used that else call _create_resource()
|
||||||
|
* 2 - If already has a resource and final_image, means we are working on some image
|
||||||
|
* apply all other methods to that resource
|
||||||
|
* 3 - _create_resource() from Source provided
|
||||||
|
*/
|
||||||
|
function _check_resource( $resource = null ) {
|
||||||
|
if ( !is_null( $resource) && is_resource($resource) ) {
|
||||||
|
$this->resource = $resource;
|
||||||
|
} else if (
|
||||||
|
$this->auto_resource == true &&
|
||||||
|
isset($this->resource) && is_resource( $this->resource) &&
|
||||||
|
isset( $this->final_image ) && is_resource( $this->final_image )
|
||||||
|
) {
|
||||||
|
$this->resource = $this->final_image;
|
||||||
|
$this->source_width = imagesx( $this->resource );
|
||||||
|
$this->source_height = imagesy( $this->resource );
|
||||||
|
} else {
|
||||||
|
$resource = $this->_create_resource();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( is_resource( $this->resource ) ) {
|
||||||
|
return $this->resource;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destroy the resources
|
||||||
|
*/
|
||||||
|
function _destroy() {
|
||||||
|
|
||||||
|
if ( isset($this->resource) ) {
|
||||||
|
is_resource( $this->resource ) ? imagedestroy($this->resource) : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( isset($this->final_image) ) {
|
||||||
|
is_resource($this->final_image) ? imagedestroy($this->final_image) : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
unset( $this->final_image );
|
||||||
|
unset( $this->resource );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setup filters, if we have correct php version
|
||||||
|
*/
|
||||||
|
function _setup_filters() {
|
||||||
|
/* Making sure imagefilter function exists */
|
||||||
|
$php5 = substr(phpversion(),0,1);
|
||||||
|
if
|
||||||
|
(
|
||||||
|
( $php5 == 5 || $php5 > 5 )
|
||||||
|
&& function_exists('imagefilter')
|
||||||
|
&& defined('IMG_FILTER_NEGATE')
|
||||||
|
) {
|
||||||
|
$this->filters = array(
|
||||||
|
/* array is filter name and number of args it accepts */
|
||||||
|
1 => array(IMG_FILTER_NEGATE,0),
|
||||||
|
2 => array(IMG_FILTER_GRAYSCALE,0),
|
||||||
|
3 => array(IMG_FILTER_BRIGHTNESS,1), // level,+/-
|
||||||
|
4 => array(IMG_FILTER_CONTRAST,1), // level,+/-
|
||||||
|
5 => array(IMG_FILTER_COLORIZE,4), // r-g-b-a
|
||||||
|
6 => array(IMG_FILTER_EDGEDETECT,0),
|
||||||
|
7 => array(IMG_FILTER_EMBOSS,0),
|
||||||
|
8 => array(IMG_FILTER_GAUSSIAN_BLUR,0),
|
||||||
|
9 => array(IMG_FILTER_SELECTIVE_BLUR,0),
|
||||||
|
10 => array(IMG_FILTER_MEAN_REMOVAL,0),
|
||||||
|
11 => array(IMG_FILTER_SMOOTH,1)
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->filters_alias = array(
|
||||||
|
'negative' => 1,
|
||||||
|
'grayscale' => 2,
|
||||||
|
'brightness' => 3,
|
||||||
|
'contrast' => 4,
|
||||||
|
'colorize' => 5,
|
||||||
|
'edgedetect' => 6,
|
||||||
|
'emboss' => 7,
|
||||||
|
'gaussian_blur' => 8,
|
||||||
|
'selective_blur' => 9,
|
||||||
|
'mean_removal' => 10,
|
||||||
|
'smooth' => 11
|
||||||
|
);
|
||||||
|
if ( phpversion() == '5.3.0' ) {
|
||||||
|
$this->filters[12] = array('IMG_FILTER_PIXELATE',2);
|
||||||
|
$this->filters_alias['pixelate'] = 12;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->filters;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Apply filter to image resource
|
||||||
|
*/
|
||||||
|
function apply_filter ( $filters, $resource = null ) {
|
||||||
|
if ( isset( $this->filters) ) {
|
||||||
|
if ( $this->_check_resource( $resource ) ) {
|
||||||
|
// explode filters
|
||||||
|
$usr_filters = explode( ":", $filters );
|
||||||
|
if ( $usr_filters ) {
|
||||||
|
foreach ( $usr_filters as $filter ) {
|
||||||
|
$fs = explode(",",$filter);
|
||||||
|
|
||||||
|
if ( !is_numeric( $fs[0] ) ) {
|
||||||
|
if ( isset( $this->filters_alias[ $fs[0] ]) ) {
|
||||||
|
$fs[0] = $this->filters_alias[ $fs[0] ];
|
||||||
|
} else {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( isset( $this->filters[$fs[0]] ) ) {
|
||||||
|
for( $i=1; $i <= 4; $i++ ) {
|
||||||
|
if ( isset( $fs[$i] ) ) {
|
||||||
|
$fs[$i] = (int)$fs[$i];
|
||||||
|
} else {
|
||||||
|
$fs[$i] = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// make number of args the switch
|
||||||
|
|
||||||
|
switch( $this->filters[$fs[0]][1] ) {
|
||||||
|
case 0: {
|
||||||
|
imagefilter( $this->resource, $this->filters[$fs[0]][0] );
|
||||||
|
}break;
|
||||||
|
|
||||||
|
case 1: {
|
||||||
|
imagefilter( $this->resource, $this->filters[$fs[0]][0], $fs[1] );
|
||||||
|
}break;
|
||||||
|
|
||||||
|
case 2: {
|
||||||
|
imagefilter( $this->resource, $this->filters[$fs[0]][0], $fs[1], $fs[2] );
|
||||||
|
}break;
|
||||||
|
|
||||||
|
case 3: {
|
||||||
|
imagefilter( $this->resource, $this->filters[$fs[0]][0], $fs[1], $fs[2], $fs[3] );
|
||||||
|
}break;
|
||||||
|
|
||||||
|
case 4: {
|
||||||
|
imagefilter( $this->resource, $this->filters[$fs[0]][0], $fs[1], $fs[2], $fs[3], $fs[4] );
|
||||||
|
}break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$this->final_image = $this->resource;
|
||||||
|
return $this->final_image;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract color palette from image
|
||||||
|
*/
|
||||||
|
function color_palette( $resource = null ) {
|
||||||
|
if ( $this->_check_resource( $resource ) ) {
|
||||||
|
|
||||||
|
if ( $this->source_width > 600 ) {
|
||||||
|
// Source is greater than 600, resize it to 600
|
||||||
|
$this->_resize( 600 );
|
||||||
|
$width = $this->target_width;
|
||||||
|
$height = $this->target_height;
|
||||||
|
} else {
|
||||||
|
$width = $this->source_width;
|
||||||
|
$height = $this->source_height;
|
||||||
|
}
|
||||||
|
|
||||||
|
$colors = array();
|
||||||
|
|
||||||
|
/* Thanks to NogDog: http://board.phpbuilder.com/board/showpost.php?p=10868783&postcount=2 */
|
||||||
|
for( $x = 0; $x < $width; $x+=12 ) {
|
||||||
|
for ($y=0; $y < $height; $y+=12 ) {
|
||||||
|
$thisColor = imagecolorat($this->resource, $x, $y);
|
||||||
|
$rgb = imagecolorsforindex($this->resource, $thisColor);
|
||||||
|
$red = round( round(($rgb['red'] / 0x33)) * 0x33 );
|
||||||
|
$green = round( round(($rgb['green'] / 0x33)) * 0x33 );
|
||||||
|
$blue = round( round(($rgb['blue'] / 0x33)) * 0x33 );
|
||||||
|
$thisRGB = sprintf('%02X%02X%02X', $red, $green, $blue);
|
||||||
|
if(array_key_exists($thisRGB, $colors))
|
||||||
|
{
|
||||||
|
$colors[$thisRGB]++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$colors[$thisRGB] = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
arsort($colors);
|
||||||
|
$this->_destroy(); // free the memory by destroying resource
|
||||||
|
$total_colors = array_sum($colors);
|
||||||
|
|
||||||
|
foreach( $colors as $color => $count ) {
|
||||||
|
$ccolors[ $color ] = array(
|
||||||
|
'color' => '#'.$color,
|
||||||
|
'rgb' => implode( ",", $this->_hex2rgb('#'.$color) ),
|
||||||
|
'count' => $count,
|
||||||
|
'percent' => round( ( $count / $total_colors ) * 100, 3 )
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $ccolors;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function watermark( $watermark = null, $resource = null ) {
|
||||||
|
if ( $this->_check_resource( $resource ) ) {
|
||||||
|
if ( !is_null($watermark) && file_exists( $watermark ) && is_file( $watermark ) && strtolower(end(explode(".",$watermark))) == 'png' ) {
|
||||||
|
$resource = $this->resource;
|
||||||
|
|
||||||
|
$this->watermark = $wresource = imagecreatefrompng( $watermark );
|
||||||
|
$this->watermark_width = $wrx = imagesx($wresource);
|
||||||
|
$this->watermark_height = $wry = imagesy($wresource);
|
||||||
|
|
||||||
|
list ( $destX, $destY ) = $this->watermark_placement();
|
||||||
|
|
||||||
|
$cut = imagecreatetruecolor($wrx, $wry);
|
||||||
|
|
||||||
|
imagecopy( $cut, $resource, 0, 0, $destX, $destY, $wrx, $wry );
|
||||||
|
imagecopy( $cut, $wresource, 0, 0, 0, 0, $wrx, $wry );
|
||||||
|
imagecopymerge( $resource, $cut, $destX, $destY, 0, 0, $wrx, $wry, 100 );
|
||||||
|
|
||||||
|
$this->final_image = $resource;
|
||||||
|
return $this->final_image;
|
||||||
|
} else {
|
||||||
|
/* Above contained failed, we will now use a string watermark */
|
||||||
|
//$this->string_watermark( $this->resource );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Thanks to fodybrabec: http://www.php.net/manual/en/function.imagettfbbox.php#105593 */
|
||||||
|
function calculate_font_box( $text ) {
|
||||||
|
$font = $this->fonts_dir.$this->font;
|
||||||
|
$rect = imageftbbox($this->font_size, 0, $font, $text );
|
||||||
|
|
||||||
|
$minX = min(array($rect[0],$rect[2],$rect[4],$rect[6]));
|
||||||
|
$maxX = max(array($rect[0],$rect[2],$rect[4],$rect[6]));
|
||||||
|
$minY = min(array($rect[1],$rect[3],$rect[5],$rect[7]));
|
||||||
|
$maxY = max(array($rect[1],$rect[3],$rect[5],$rect[7]));
|
||||||
|
|
||||||
|
return array(
|
||||||
|
"left" => abs($minX) - 1,
|
||||||
|
"top" => abs($minY) - 1,
|
||||||
|
"width" => $maxX - $minX,
|
||||||
|
"height" => $maxY - $minY,
|
||||||
|
"box" => $rect
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function string_watermark ( $resource = null ) {
|
||||||
|
if ( $this->_check_resource ( $resource ) ) {
|
||||||
|
$font_file = $this->fonts_dir.$this->font;
|
||||||
|
$this->font_size = round( ( ( $this->source_width + $this->source_height ) / 96 ) * 0.75 +14 );
|
||||||
|
$text = strtoupper( TITLE );
|
||||||
|
$color = imagecolorallocate($this->resource, 235, 235, 235 );
|
||||||
|
$shadow = imagecolorallocate($this->resource, 0, 0, 0 );
|
||||||
|
$return = $this->calculate_font_box( $text );
|
||||||
|
list ( $x, $y ) = $this->watermark_placement( $return );
|
||||||
|
|
||||||
|
imagefttext( $this->resource, $this->font_size, 0, $x, $y - 1, $shadow, $font_file, $text );
|
||||||
|
imagefttext( $this->resource, $this->font_size, 0, $x, $y, $color, $font_file, $text );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function watermark_placement( $string = false ) {
|
||||||
|
if ( !$this->watermark_placement ) {
|
||||||
|
$this->watermark_placement = "left:top";
|
||||||
|
}
|
||||||
|
|
||||||
|
list( $x, $y ) = explode(":", $this->watermark_placement );
|
||||||
|
|
||||||
|
if ( $string == false && !is_array( $string )) {
|
||||||
|
switch ( $x ) {
|
||||||
|
case "left":
|
||||||
|
default: {
|
||||||
|
$x = $this->watermark_padding;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "center": {
|
||||||
|
$x = ( $this->source_width - $this->watermark_width ) / 2;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "right": {
|
||||||
|
$x = ( $this->source_width - $this->watermark_width ) - $watermark_padding;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch ( $y ) {
|
||||||
|
case "top":
|
||||||
|
default: {
|
||||||
|
$y = $this->watermark_padding;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "center": {
|
||||||
|
$y = ( $this->source_height - $this->watermark_height ) / 2;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "bottom" : {
|
||||||
|
$y = ( $this->source_height - $this->watermark_height ) - $this->watermark_padding;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
switch( $x ) {
|
||||||
|
case "left":
|
||||||
|
default: {
|
||||||
|
$x = $string['left'] + $this->watermark_padding;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "center": {
|
||||||
|
$x = ( $this->source_width - $string['width'] ) / 2;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "right": {
|
||||||
|
$x = ( $this->source_width - $string['width'] ) - $this->watermark_padding;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
switch( $y ) {
|
||||||
|
case "top":
|
||||||
|
default: {
|
||||||
|
$y = $string['top'] + $this->watermark_padding;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "center": {
|
||||||
|
$y = ( $this->source_height + $string['height'] ) / 2;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "bottom": {
|
||||||
|
$y = ( $this->source_height - $string['height'] ) + $this->watermark_padding;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return array( round( $x ), round( $y ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -145,7 +145,7 @@ if(!@$in_bg_cron)
|
||||||
//Setting Time Zone date_default_timezone_set()
|
//Setting Time Zone date_default_timezone_set()
|
||||||
|
|
||||||
require_once('classes/search.class.php');
|
require_once('classes/search.class.php');
|
||||||
|
require_once('classes/resizer.class.php');
|
||||||
|
|
||||||
require_once('classes/calcdate.class.php');
|
require_once('classes/calcdate.class.php');
|
||||||
require_once('classes/signup.class.php');
|
require_once('classes/signup.class.php');
|
||||||
|
@ -661,7 +661,9 @@ include('admin.functions.php');
|
||||||
//Other settings
|
//Other settings
|
||||||
define("SEND_COMMENT_NOTIFICATION",config("send_comment_notification"));
|
define("SEND_COMMENT_NOTIFICATION",config("send_comment_notification"));
|
||||||
define("SEND_VID_APPROVE_EMAIL",config("approve_video_notification"));
|
define("SEND_VID_APPROVE_EMAIL",config("approve_video_notification"));
|
||||||
|
|
||||||
|
cb_create_user_avatar_collection();
|
||||||
|
|
||||||
define ('MOBILE_TEMPLATE','cb_iphone2');
|
define ('MOBILE_TEMPLATE','cb_iphone2');
|
||||||
|
|
||||||
if ( $Cbucket->template == MOBILE_TEMPLATE ) {
|
if ( $Cbucket->template == MOBILE_TEMPLATE ) {
|
||||||
|
|
|
@ -39,7 +39,7 @@ Assign('layout_dir',LAYOUT);
|
||||||
if ( USE_PHOTO_TAGGING == true ) {
|
if ( USE_PHOTO_TAGGING == true ) {
|
||||||
$Cbucket->addJS( array('jquery_plugs/jquery.cbtagger.js' => 'view_item') );
|
$Cbucket->addJS( array('jquery_plugs/jquery.cbtagger.js' => 'view_item') );
|
||||||
}
|
}
|
||||||
|
$Cbucket->addJS( array('jquery_plugs/jquery.Jcrop.js' => 'edit_account') );
|
||||||
//Assigning JS Files
|
//Assigning JS Files
|
||||||
Assign('jsArray',$Cbucket->JSArray);
|
Assign('jsArray',$Cbucket->JSArray);
|
||||||
//Assigning Module Files
|
//Assigning Module Files
|
||||||
|
|
1071
upload/includes/exif.php
Normal file
1071
upload/includes/exif.php
Normal file
File diff suppressed because it is too large
Load diff
|
@ -3156,6 +3156,13 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( !function_exists('cb_filename') ) {
|
||||||
|
function cb_filename() {
|
||||||
|
$filename = time().RandomString(6);
|
||||||
|
return $filename;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( !function_exists('cb_parse_args_string') ) {
|
if ( !function_exists('cb_parse_args_string') ) {
|
||||||
function cb_parse_args_string ( $string=null ) {
|
function cb_parse_args_string ( $string=null ) {
|
||||||
if ( is_null($string) )
|
if ( is_null($string) )
|
||||||
|
|
|
@ -71,6 +71,6 @@ function confirm_collection_type ( $type ) {
|
||||||
}
|
}
|
||||||
return $cbcollection->types;
|
return $cbcollection->types;
|
||||||
}
|
}
|
||||||
return $type;
|
return $cbcollection->types;
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -78,4 +78,120 @@ function load_photo_controls ( $args ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function get_original_photo( $photo ) {
|
||||||
|
global $cbphoto;
|
||||||
|
if ( !is_array($photo) ) {
|
||||||
|
$ph = $cbphoto->get_photo($photo);
|
||||||
|
} else {
|
||||||
|
$ph = $photo;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( is_array($ph) ) {
|
||||||
|
$files = $cbphoto->get_image_file( $ph, 'o', true, null, false, true);
|
||||||
|
$orig = $ph['filename'].'.'.$ph['ext'];
|
||||||
|
$file = array_find( $orig, $files );
|
||||||
|
return $file;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function insert_photo_colors( $photo ) {
|
||||||
|
global $db, $cbphoto;
|
||||||
|
|
||||||
|
if ( !is_array($photo) ) {
|
||||||
|
$ph = $cbphoto->get_photo( $photo );
|
||||||
|
} else {
|
||||||
|
$ph = $photo;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( is_array($ph) && isset($ph['photo_id']) ) {
|
||||||
|
|
||||||
|
if ( $id = $db->select( tbl('photosmeta'),'pmeta_id'," photo_id = '".$ph['photo_id']."' AND meta_name = 'colors' " ) ) {
|
||||||
|
return $id;
|
||||||
|
}
|
||||||
|
|
||||||
|
$dir = PHOTOS_DIR.'/';
|
||||||
|
$file = get_original_photo( $ph );
|
||||||
|
$path = $dir.$file;
|
||||||
|
|
||||||
|
if ( file_exists($path) ) {
|
||||||
|
$img = new CB_Resizer( $path );
|
||||||
|
$colors = $img->color_palette();
|
||||||
|
if ( $colors ) {
|
||||||
|
$jcolors = json_encode( $colors );
|
||||||
|
$insert_id = $db->insert( tbl('photosmeta'), array('photo_id','meta_name','meta_value'), array($ph['photo_id'],'colors','|no_mc|'.$jcolors) );
|
||||||
|
if ( $insert_id ) {
|
||||||
|
return $insert_id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function insert_exif_data( $photo ) {
|
||||||
|
global $db, $cbphoto;
|
||||||
|
|
||||||
|
if ( !is_array($photo) ) {
|
||||||
|
$ph = $cbphoto->get_photo( $photo );
|
||||||
|
} else {
|
||||||
|
$ph = $photo;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( is_array($ph) && isset($ph['photo_id']) ) {
|
||||||
|
$dir = PHOTOS_DIR.'/';
|
||||||
|
|
||||||
|
if ( strtolower($ph['ext']) != 'jpg' ) {
|
||||||
|
/* return if photo is not jpg */
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$file = get_original_photo( $ph );
|
||||||
|
$path = $dir.$file;
|
||||||
|
if ( file_exists($path) ) {
|
||||||
|
/* File exists. read the exif data. Thanks to CopperMine, Love you */
|
||||||
|
$data = exif_read_data_raw( $path, 0);
|
||||||
|
if ( isset($data['SubIFD']) ) {
|
||||||
|
$exif_to_include = array('IFD0','SubIFD','IFD1','InteroperabilityIFD');
|
||||||
|
foreach( $exif_to_include as $eti ) {
|
||||||
|
if ( isset( $data[$eti]) ) {
|
||||||
|
$exif[$eti] = $data[$eti];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$jexif = json_encode($exif);
|
||||||
|
/* add new meta of exif_data for current photo */
|
||||||
|
$insert_id = $db->insert( tbl('photosmeta'), array('photo_id','meta_name','meta_value'), array($ph['photo_id'],'exif_data','|no_mc|'.$jexif) );
|
||||||
|
if ( $insert_id ) {
|
||||||
|
/* update photo has_exif to yes, so we know that this photo has exif data */
|
||||||
|
$db->update( tbl($cbphoto->p_tbl), array('exif_data'), array('yes'), " photo_id = '".$ph['photo_id']."' " );
|
||||||
|
|
||||||
|
return $insert_id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function add_custom_photo_size( $code, $width = 0, $height = 0, $crop = 4, $watermark = false, $sharpit = false ) {
|
||||||
|
global $cbphoto;
|
||||||
|
$sizes = $cbphoto->thumb_dimensions;
|
||||||
|
$code = strtolower( $code );
|
||||||
|
|
||||||
|
if ( $code == 't' || $code == 'm' || $code == 'l' || $code == 'o' ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !is_numeric( $width ) || !is_numeric( $height ) ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$sizes [ $code ] = array(
|
||||||
|
'width' => abs( $width ),
|
||||||
|
'height' => abs( $height ),
|
||||||
|
'crop' => $crop,
|
||||||
|
'watermark' => $watermark,
|
||||||
|
'sharpit' => $sharpit
|
||||||
|
);
|
||||||
|
|
||||||
|
return $cbphoto->thumb_dimensions = $sizes;
|
||||||
|
}
|
||||||
?>
|
?>
|
|
@ -1,215 +1,282 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Id$
|
* $Id$
|
||||||
*
|
*
|
||||||
* @Since : 12/7/2011 - 2.7
|
* @Since : 12/7/2011 - 2.7
|
||||||
*
|
*
|
||||||
* All users related functions
|
* All users related functions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function used to get number of videos uploaded by user
|
* Function used to get number of videos uploaded by user
|
||||||
* @param INT userid
|
* @param INT userid
|
||||||
* @param Conditions
|
* @param Conditions
|
||||||
*/
|
*/
|
||||||
function get_user_vids($uid,$cond=NULL,$count_only=false)
|
function get_user_vids($uid,$cond=NULL,$count_only=false)
|
||||||
{
|
{
|
||||||
global $userquery;
|
global $userquery;
|
||||||
return $userquery->get_user_vids($uid,$cond,$count_only);
|
return $userquery->get_user_vids($uid,$cond,$count_only);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function used to return level name
|
* Function used to return level name
|
||||||
* @param levelid
|
* @param levelid
|
||||||
*/
|
*/
|
||||||
function get_user_level($id)
|
function get_user_level($id)
|
||||||
{
|
{
|
||||||
global $userquery;
|
global $userquery;
|
||||||
return $userquery->usr_levels[$id];
|
return $userquery->usr_levels[$id];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* function used to get vidos
|
* function used to get vidos
|
||||||
*/
|
*/
|
||||||
function get_users($param)
|
function get_users($param)
|
||||||
{
|
{
|
||||||
global $userquery;
|
global $userquery;
|
||||||
return $userquery->get_users($param);
|
return $userquery->get_users($param);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function used to check weather username already exists or not
|
* Function used to check weather username already exists or not
|
||||||
* @input USERNAME
|
* @input USERNAME
|
||||||
*/
|
*/
|
||||||
function user_exists($user)
|
function user_exists($user)
|
||||||
{
|
{
|
||||||
global $userquery;
|
global $userquery;
|
||||||
return $userquery->username_exists($user);
|
return $userquery->username_exists($user);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function used to validate username
|
* Function used to validate username
|
||||||
* @input USERNAME
|
* @input USERNAME
|
||||||
*/
|
*/
|
||||||
function username_check($username)
|
function username_check($username)
|
||||||
{
|
{
|
||||||
global $Cbucket;
|
global $Cbucket;
|
||||||
$banned_words = $Cbucket->configs['disallowed_usernames'];
|
$banned_words = $Cbucket->configs['disallowed_usernames'];
|
||||||
$banned_words = explode(',',$banned_words);
|
$banned_words = explode(',',$banned_words);
|
||||||
foreach($banned_words as $word)
|
foreach($banned_words as $word)
|
||||||
{
|
{
|
||||||
preg_match("/$word/Ui",$username,$match);
|
preg_match("/$word/Ui",$username,$match);
|
||||||
if(!empty($match[0]))
|
if(!empty($match[0]))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//Checking if its syntax is valid or not
|
//Checking if its syntax is valid or not
|
||||||
$multi = config('allow_unicode_usernames');
|
$multi = config('allow_unicode_usernames');
|
||||||
|
|
||||||
//Checking Spaces
|
//Checking Spaces
|
||||||
if(!config('allow_username_spaces'))
|
if(!config('allow_username_spaces'))
|
||||||
preg_match('/ /',$username,$matches);
|
preg_match('/ /',$username,$matches);
|
||||||
if(!is_valid_syntax('username',$username) && $multi!='yes' || $matches)
|
if(!is_valid_syntax('username',$username) && $multi!='yes' || $matches)
|
||||||
e(lang("class_invalid_user"));
|
e(lang("class_invalid_user"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FUnction used to get username from userid
|
* FUnction used to get username from userid
|
||||||
*/
|
*/
|
||||||
function get_username($uid)
|
function get_username($uid)
|
||||||
{
|
{
|
||||||
global $userquery;
|
global $userquery;
|
||||||
return $userquery->get_username($uid,'username');
|
return $userquery->get_username($uid,'username');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function used to get userid anywhere
|
* Function used to get userid anywhere
|
||||||
* if there is no user_id it will return false
|
* if there is no user_id it will return false
|
||||||
*/
|
*/
|
||||||
function user_id()
|
function user_id()
|
||||||
{
|
{
|
||||||
global $userquery;
|
global $userquery;
|
||||||
if($userquery->userid !='' && $userquery->is_login) return $userquery->userid; else false;
|
if($userquery->userid !='' && $userquery->is_login) return $userquery->userid; else false;
|
||||||
}
|
}
|
||||||
//alias
|
//alias
|
||||||
function userid(){return user_id();}
|
function userid(){return user_id();}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function used to get username anywhere
|
* Function used to get username anywhere
|
||||||
* if there is no usern_name it will return false
|
* if there is no usern_name it will return false
|
||||||
*/
|
*/
|
||||||
function user_name()
|
function user_name()
|
||||||
{
|
{
|
||||||
global $userquery;
|
global $userquery;
|
||||||
if($userquery->user_name)
|
if($userquery->user_name)
|
||||||
return $userquery->user_name;
|
return $userquery->user_name;
|
||||||
else
|
else
|
||||||
return $userquery->get_logged_username();
|
return $userquery->get_logged_username();
|
||||||
}
|
}
|
||||||
function username(){return user_name();}
|
function username(){return user_name();}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function used to check weather user access or not
|
* Function used to check weather user access or not
|
||||||
*/
|
*/
|
||||||
function has_access($access,$check_only=TRUE,$verify_logged_user=true)
|
function has_access($access,$check_only=TRUE,$verify_logged_user=true)
|
||||||
{
|
{
|
||||||
global $userquery;
|
global $userquery;
|
||||||
|
|
||||||
return $userquery->login_check($access,$check_only,$verify_logged_user);
|
return $userquery->login_check($access,$check_only,$verify_logged_user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function used to get user avatar
|
* Function used to get user avatar
|
||||||
* @param ARRAY $userdetail
|
* @param ARRAY $userdetail
|
||||||
* @param SIZE $int
|
* @param SIZE $int
|
||||||
*/
|
*/
|
||||||
function avatar($param)
|
function avatar($param)
|
||||||
{
|
{
|
||||||
global $userquery;
|
global $userquery;
|
||||||
$udetails = $param['details'];
|
$udetails = $param['details'];
|
||||||
$size = $param['size'];
|
$size = $param['size'];
|
||||||
$uid = $param['uid'];
|
$uid = $param['uid'];
|
||||||
return $userquery->avatar($udetails,$size,$uid);
|
return $userquery->avatar($udetails,$size,$uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function used to check weather email already exists or not
|
* Function used to check weather email already exists or not
|
||||||
* @input email
|
* @input email
|
||||||
*/
|
*/
|
||||||
function email_exists($user)
|
function email_exists($user)
|
||||||
{
|
{
|
||||||
global $userquery;
|
global $userquery;
|
||||||
return $userquery->duplicate_email($user);
|
return $userquery->duplicate_email($user);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function used to count age from date
|
* Function used to count age from date
|
||||||
*/
|
*/
|
||||||
function get_age($input)
|
function get_age($input)
|
||||||
{
|
{
|
||||||
$time = strtotime($input);
|
$time = strtotime($input);
|
||||||
$iMonth = date("m",$time);
|
$iMonth = date("m",$time);
|
||||||
$iDay = date("d",$time);
|
$iDay = date("d",$time);
|
||||||
$iYear = date("Y",$time);
|
$iYear = date("Y",$time);
|
||||||
|
|
||||||
$iTimeStamp = (mktime() - 86400) - mktime(0, 0, 0, $iMonth, $iDay, $iYear);
|
$iTimeStamp = (mktime() - 86400) - mktime(0, 0, 0, $iMonth, $iDay, $iYear);
|
||||||
$iDays = $iTimeStamp / 86400;
|
$iDays = $iTimeStamp / 86400;
|
||||||
$iYears = floor($iDays / 365 );
|
$iYears = floor($iDays / 365 );
|
||||||
return $iYears;
|
return $iYears;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function update_user_voted($array,$userid=NULL)
|
function update_user_voted($array,$userid=NULL)
|
||||||
{
|
{
|
||||||
global $userquery;
|
global $userquery;
|
||||||
return $userquery->update_user_voted($array,$userid);
|
return $userquery->update_user_voted($array,$userid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function used to check username is disallowed or not
|
* Function used to check username is disallowed or not
|
||||||
* @param USERNAME
|
* @param USERNAME
|
||||||
*/
|
*/
|
||||||
function check_disallowed_user($username)
|
function check_disallowed_user($username)
|
||||||
{
|
{
|
||||||
global $Cbucket;
|
global $Cbucket;
|
||||||
$disallowed_user = $Cbucket->configs['disallowed_usernames'];
|
$disallowed_user = $Cbucket->configs['disallowed_usernames'];
|
||||||
$censor_users = explode(',',$disallowed_user);
|
$censor_users = explode(',',$disallowed_user);
|
||||||
if(in_array($username,$censor_users))
|
if(in_array($username,$censor_users))
|
||||||
return false;
|
return false;
|
||||||
else
|
else
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get user menu links
|
* get user menu links
|
||||||
*
|
*
|
||||||
* these links are listed on user menu found on right top on default template
|
* these links are listed on user menu found on right top on default template
|
||||||
* you can move the menu however.
|
* you can move the menu however.
|
||||||
*
|
*
|
||||||
* @param NULL
|
* @param NULL
|
||||||
* @return Array of links
|
* @return Array of links
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function get_user_menu_links()
|
function get_user_menu_links()
|
||||||
{
|
{
|
||||||
$array = array(
|
$array = array(
|
||||||
'videos' =>
|
'videos' =>
|
||||||
array('name'=> lang('Videos'), 'link'=> cblink(array('name'=>'videos')))
|
array('name'=> lang('Videos'), 'link'=> cblink(array('name'=>'videos')))
|
||||||
);
|
);
|
||||||
|
|
||||||
$new_array = apply_filters($array,'user_menu_links');
|
$new_array = apply_filters($array,'user_menu_links');
|
||||||
|
|
||||||
return $new_array;
|
return $new_array;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
function cb_upload_avatar ( $file, $uid = null) {
|
||||||
|
global $db, $userquery;
|
||||||
|
if ( is_null($uid) ) {
|
||||||
|
$uid = userid();
|
||||||
|
}
|
||||||
|
if ( !$uid ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$user = $userquery->get_user_details($uid);
|
||||||
|
if ( $user ) {
|
||||||
|
$collection = $user['avatar_collection'];
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create user avatar collection
|
||||||
|
*/
|
||||||
|
function cb_create_user_avatar_collection( $uid = null) {
|
||||||
|
global $db, $userquery, $cbcollection;
|
||||||
|
|
||||||
|
if ( is_null($uid) ) {
|
||||||
|
$uid = userid();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !$uid ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( is_array($uid) ) {
|
||||||
|
$user = $uid;
|
||||||
|
} else {
|
||||||
|
$user = $userquery->get_user_details( $uid );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !empty($user) ) {
|
||||||
|
if ( $user['avatar_collection'] == 0 ) {
|
||||||
|
/* User has no avatar collection. Create one */
|
||||||
|
$details = array(
|
||||||
|
'collection_name' => 'User Avatars',
|
||||||
|
'collection_description' => 'Collection of user avatars',
|
||||||
|
'collection_tags' => ' ',
|
||||||
|
//'category' => array('category', $cbcollection->get_avatar_collection_id() ),
|
||||||
|
'category' => '#'.$cbcollection->get_avatar_collection_id().'#',
|
||||||
|
'userid' => $user['userid'],
|
||||||
|
'date_added' => NOW(),
|
||||||
|
'is_avatar_collection' => 'yes',
|
||||||
|
'type' => 'photos',
|
||||||
|
'active' => 'yes',
|
||||||
|
'public_upload' => 'no',
|
||||||
|
'broadcast' => 'public',
|
||||||
|
'allow_comments' => 'yes'
|
||||||
|
);
|
||||||
|
|
||||||
|
/* Insert collection */
|
||||||
|
$insert_id = $db->insert( tbl($cbcollection->section_tbl), array_keys($details), array_values($details) );
|
||||||
|
if ( $insert_id ) {
|
||||||
|
/* update user column avatar_collection */
|
||||||
|
$db->update( tbl('users'), array('avatar_collection'), array($insert_id), " userid = '".$user['userid']."' " );
|
||||||
|
return $insert_id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
437
upload/includes/makers/canon.php
Normal file
437
upload/includes/makers/canon.php
Normal file
|
@ -0,0 +1,437 @@
|
||||||
|
<?php
|
||||||
|
/*************************
|
||||||
|
Coppermine Photo Gallery
|
||||||
|
************************
|
||||||
|
Copyright (c) 2003-2012 Coppermine Dev Team
|
||||||
|
v1.0 originally written by Gregory Demar
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License version 3
|
||||||
|
as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
********************************************
|
||||||
|
Coppermine version: 1.5.18
|
||||||
|
$HeadURL: https://coppermine.svn.sourceforge.net/svnroot/coppermine/trunk/cpg1.5.x/include/makers/canon.php $
|
||||||
|
$Revision: 8304 $
|
||||||
|
**********************************************/
|
||||||
|
/*
|
||||||
|
Exifer
|
||||||
|
Extracts EXIF information from digital photos.
|
||||||
|
|
||||||
|
Copyright © 2003 Jake Olefsky
|
||||||
|
http://www.offsky.com/software/exif/index.php
|
||||||
|
jake@olefsky.com
|
||||||
|
|
||||||
|
Please see exif.php for the complete information about this software.
|
||||||
|
|
||||||
|
------------
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify it under the terms of
|
||||||
|
the GNU General Public License as published by the Free Software Foundation; either version 2
|
||||||
|
of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
See the GNU General Public License for more details. http://www.gnu.org/copyleft/gpl.html
|
||||||
|
*/
|
||||||
|
//================================================================================================
|
||||||
|
//================================================================================================
|
||||||
|
//================================================================================================
|
||||||
|
|
||||||
|
|
||||||
|
//=================
|
||||||
|
// Looks up the name of the tag for the MakerNote (Depends on Manufacturer)
|
||||||
|
//====================================================================
|
||||||
|
function lookup_Canon_tag($tag) {
|
||||||
|
|
||||||
|
switch($tag) {
|
||||||
|
case "0001": $tag = "Settings 1";break;
|
||||||
|
case "0004": $tag = "Settings 4";break;
|
||||||
|
case "0006": $tag = "ImageType";break;
|
||||||
|
case "0007": $tag = "FirmwareVersion";break;
|
||||||
|
case "0008": $tag = "ImageNumber";break;
|
||||||
|
case "0009": $tag = "OwnerName";break;
|
||||||
|
case "000c": $tag = "CameraSerialNumber";break;
|
||||||
|
case "000f": $tag = "CustomFunctions";break;
|
||||||
|
|
||||||
|
default: $tag = "unknown:".$tag;break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $tag;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=================
|
||||||
|
// Formats Data for the data type
|
||||||
|
//====================================================================
|
||||||
|
function formatCanonData($type,$tag,$intel,$data,$exif,&$result) {
|
||||||
|
$place = 0;
|
||||||
|
|
||||||
|
|
||||||
|
if($type=="ASCII") {
|
||||||
|
$result = $data = str_replace("\0", "", $data);
|
||||||
|
} else if($type=="URATIONAL" || $type=="SRATIONAL") {
|
||||||
|
$data = bin2hex($data);
|
||||||
|
if($intel==1) $data = intel2Moto($data);
|
||||||
|
$top = hexdec(substr($data,8,8));
|
||||||
|
$bottom = hexdec(substr($data,0,8));
|
||||||
|
if($bottom!=0) $data=$top/$bottom;
|
||||||
|
else if($top==0) $data = 0;
|
||||||
|
else $data=$top."/".$bottom;
|
||||||
|
|
||||||
|
if($tag=="0204") { //DigitalZoom
|
||||||
|
$data=$data."x";
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if($type=="USHORT" || $type=="SSHORT" || $type=="ULONG" || $type=="SLONG" || $type=="FLOAT" || $type=="DOUBLE") {
|
||||||
|
|
||||||
|
$data = bin2hex($data);
|
||||||
|
$result['RAWDATA'] = $data;
|
||||||
|
|
||||||
|
if($tag=="0001") { //first chunk
|
||||||
|
$result['Bytes']=hexdec(intel2Moto(substr($data,$place,4)));$place+=4;//0
|
||||||
|
if ($result['Bytes'] != strlen($data) / 2) return $result; //Bad chunk
|
||||||
|
$result['Macro']=hexdec(intel2Moto(substr($data,$place,4)));$place+=4;//1
|
||||||
|
switch($result['Macro']) {
|
||||||
|
case 1: $result['Macro'] = "Macro"; break;
|
||||||
|
case 2: $result['Macro'] = "Normal"; break;
|
||||||
|
default: $result['Macro'] = "Unknown";
|
||||||
|
}
|
||||||
|
$result['SelfTimer']=hexdec(intel2Moto(substr($data,$place,4)));$place+=4;//2
|
||||||
|
switch($result['SelfTimer']) {
|
||||||
|
case 0: $result['SelfTimer'] = "Off"; break;
|
||||||
|
default: $result['SelfTimer'] .= "/10s";
|
||||||
|
}
|
||||||
|
$result['Quality']=hexdec(intel2Moto(substr($data,$place,4)));$place+=4;//3
|
||||||
|
switch($result['Quality']) {
|
||||||
|
case 2: $result['Quality'] = "Normal"; break;
|
||||||
|
case 3: $result['Quality'] = "Fine"; break;
|
||||||
|
case 5: $result['Quality'] = "Superfine"; break;
|
||||||
|
default: $result['Quality'] = "Unknown";
|
||||||
|
}
|
||||||
|
$result['Flash']=hexdec(intel2Moto(substr($data,$place,4)));$place+=4;//4
|
||||||
|
switch($result['Flash']) {
|
||||||
|
case 0: $result['Flash'] = "Off"; break;
|
||||||
|
case 1: $result['Flash'] = "Auto"; break;
|
||||||
|
case 2: $result['Flash'] = "On"; break;
|
||||||
|
case 3: $result['Flash'] = "Red Eye Reduction"; break;
|
||||||
|
case 4: $result['Flash'] = "Slow Synchro"; break;
|
||||||
|
case 5: $result['Flash'] = "Auto + Red Eye Reduction"; break;
|
||||||
|
case 6: $result['Flash'] = "On + Red Eye Reduction"; break;
|
||||||
|
case 16: $result['Flash'] = "External Flash"; break;
|
||||||
|
default: $result['Flash'] = "Unknown";
|
||||||
|
}
|
||||||
|
$result['DriveMode']=hexdec(intel2Moto(substr($data,$place,4)));$place+=4;//5
|
||||||
|
switch($result['DriveMode']) {
|
||||||
|
case 0: $result['DriveMode'] = "Single/Timer"; break;
|
||||||
|
case 1: $result['DriveMode'] = "Continuous"; break;
|
||||||
|
default: $result['DriveMode'] = "Unknown";
|
||||||
|
}
|
||||||
|
$result['Unknown']=hexdec(intel2Moto(substr($data,$place,4)));$place+=4;//6
|
||||||
|
$result['FocusMode']=hexdec(intel2Moto(substr($data,$place,4)));$place+=4;//7
|
||||||
|
switch($result['FocusMode']) {
|
||||||
|
case 0: $result['FocusMode'] = "One-Shot"; break;
|
||||||
|
case 1: $result['FocusMode'] = "AI Servo"; break;
|
||||||
|
case 2: $result['FocusMode'] = "AI Focus"; break;
|
||||||
|
case 3: $result['FocusMode'] = "Manual Focus"; break;
|
||||||
|
case 4: $result['FocusMode'] = "Single"; break;
|
||||||
|
case 5: $result['FocusMode'] = "Continuous"; break;
|
||||||
|
case 6: $result['FocusMode'] = "Manual Focus"; break;
|
||||||
|
default: $result['FocusMode'] = "Unknown";
|
||||||
|
}
|
||||||
|
$result['Unknown']=hexdec(intel2Moto(substr($data,$place,4)));$place+=4;//8
|
||||||
|
$result['Unknown']=hexdec(intel2Moto(substr($data,$place,4)));$place+=4;//9
|
||||||
|
$result['ImageSize']=hexdec(intel2Moto(substr($data,$place,4)));$place+=4;//10
|
||||||
|
switch($result['ImageSize']) {
|
||||||
|
case 0: $result['ImageSize'] = "Large"; break;
|
||||||
|
case 1: $result['ImageSize'] = "Medium"; break;
|
||||||
|
case 2: $result['ImageSize'] = "Small"; break;
|
||||||
|
default: $result['ImageSize'] = "Unknown";
|
||||||
|
}
|
||||||
|
$result['EasyShooting']=hexdec(intel2Moto(substr($data,$place,4)));$place+=4;//11
|
||||||
|
switch($result['EasyShooting']) {
|
||||||
|
case 0: $result['EasyShooting'] = "Full Auto"; break;
|
||||||
|
case 1: $result['EasyShooting'] = "Manual"; break;
|
||||||
|
case 2: $result['EasyShooting'] = "Landscape"; break;
|
||||||
|
case 3: $result['EasyShooting'] = "Fast Shutter"; break;
|
||||||
|
case 4: $result['EasyShooting'] = "Slow Shutter"; break;
|
||||||
|
case 5: $result['EasyShooting'] = "Night"; break;
|
||||||
|
case 6: $result['EasyShooting'] = "Black & White"; break;
|
||||||
|
case 7: $result['EasyShooting'] = "Sepia"; break;
|
||||||
|
case 8: $result['EasyShooting'] = "Portrait"; break;
|
||||||
|
case 9: $result['EasyShooting'] = "Sport"; break;
|
||||||
|
case 10: $result['EasyShooting'] = "Macro/Close-Up"; break;
|
||||||
|
case 11: $result['EasyShooting'] = "Pan Focus"; break;
|
||||||
|
default: $result['EasyShooting'] = "Unknown";
|
||||||
|
}
|
||||||
|
$result['DigitalZoom']=hexdec(intel2Moto(substr($data,$place,4)));$place+=4;//12
|
||||||
|
switch($result['DigitalZoom']) {
|
||||||
|
case 0:
|
||||||
|
case 65535: $result['DigitalZoom'] = "None"; break;
|
||||||
|
case 1: $result['DigitalZoom'] = "2x"; break;
|
||||||
|
case 2: $result['DigitalZoom'] = "4x"; break;
|
||||||
|
default: $result['DigitalZoom'] = "Unknown";
|
||||||
|
}
|
||||||
|
$result['Contrast']=hexdec(intel2Moto(substr($data,$place,4)));$place+=4;//13
|
||||||
|
switch($result['Contrast']) {
|
||||||
|
case 0: $result['Contrast'] = "Normal"; break;
|
||||||
|
case 1: $result['Contrast'] = "High"; break;
|
||||||
|
case 65535: $result['Contrast'] = "Low"; break;
|
||||||
|
default: $result['Contrast'] = "Unknown";
|
||||||
|
}
|
||||||
|
$result['Saturation']=hexdec(intel2Moto(substr($data,$place,4)));$place+=4;//14
|
||||||
|
switch($result['Saturation']) {
|
||||||
|
case 0: $result['Saturation'] = "Normal"; break;
|
||||||
|
case 1: $result['Saturation'] = "High"; break;
|
||||||
|
case 65535: $result['Saturation'] = "Low"; break;
|
||||||
|
default: $result['Saturation'] = "Unknown";
|
||||||
|
}
|
||||||
|
$result['Sharpness']=hexdec(intel2Moto(substr($data,$place,4)));$place+=4;//15
|
||||||
|
switch($result['Sharpness']) {
|
||||||
|
case 0: $result['Sharpness'] = "Normal"; break;
|
||||||
|
case 1: $result['Sharpness'] = "High"; break;
|
||||||
|
case 65535: $result['Sharpness'] = "Low"; break;
|
||||||
|
default: $result['Sharpness'] = "Unknown";
|
||||||
|
}
|
||||||
|
$result['ISO']=hexdec(intel2Moto(substr($data,$place,4)));$place+=4;//16
|
||||||
|
switch($result['ISO']) {
|
||||||
|
case 32767:
|
||||||
|
case 0: $result['ISO'] = isset($exif['SubIFD']['ISOSpeedRatings'])
|
||||||
|
? $exif['SubIFD']['ISOSpeedRatings'] : 'Unknown'; break;
|
||||||
|
case 15: $result['ISO'] = "Auto"; break;
|
||||||
|
case 16: $result['ISO'] = "50"; break;
|
||||||
|
case 17: $result['ISO'] = "100"; break;
|
||||||
|
case 18: $result['ISO'] = "200"; break;
|
||||||
|
case 19: $result['ISO'] = "400"; break;
|
||||||
|
default: $result['ISO'] = "Unknown";
|
||||||
|
}
|
||||||
|
$result['MeteringMode']=hexdec(intel2Moto(substr($data,$place,4)));$place+=4;//17
|
||||||
|
switch($result['MeteringMode']) {
|
||||||
|
case 3: $result['MeteringMode'] = "Evaluative"; break;
|
||||||
|
case 4: $result['MeteringMode'] = "Partial"; break;
|
||||||
|
case 5: $result['MeteringMode'] = "Center-weighted"; break;
|
||||||
|
default: $result['MeteringMode'] = "Unknown";
|
||||||
|
}
|
||||||
|
$result['FocusType']=hexdec(intel2Moto(substr($data,$place,4)));$place+=4;//18
|
||||||
|
switch($result['FocusType']) {
|
||||||
|
case 0: $result['FocusType'] = "Manual"; break;
|
||||||
|
case 1: $result['FocusType'] = "Auto"; break;
|
||||||
|
case 3: $result['FocusType'] = "Close-up (Macro)"; break;
|
||||||
|
case 8: $result['FocusType'] = "Locked (Pan Mode)"; break;
|
||||||
|
default: $result['FocusType'] = "Unknown";
|
||||||
|
}
|
||||||
|
$result['AFPointSelected']=hexdec(intel2Moto(substr($data,$place,4)));$place+=4;//19
|
||||||
|
switch($result['AFPointSelected']) {
|
||||||
|
case 12288: $result['AFPointSelected'] = "Manual Focus"; break;
|
||||||
|
case 12289: $result['AFPointSelected'] = "Auto Selected"; break;
|
||||||
|
case 12290: $result['AFPointSelected'] = "Right"; break;
|
||||||
|
case 12291: $result['AFPointSelected'] = "Center"; break;
|
||||||
|
case 12292: $result['AFPointSelected'] = "Left"; break;
|
||||||
|
default: $result['AFPointSelected'] = "Unknown";
|
||||||
|
}
|
||||||
|
$result['ExposureMode']=hexdec(intel2Moto(substr($data,$place,4)));$place+=4;//20
|
||||||
|
switch($result['ExposureMode']) {
|
||||||
|
case 0: $result['ExposureMode'] = "EasyShoot"; break;
|
||||||
|
case 1: $result['ExposureMode'] = "Program"; break;
|
||||||
|
case 2: $result['ExposureMode'] = "Tv"; break;
|
||||||
|
case 3: $result['ExposureMode'] = "Av"; break;
|
||||||
|
case 4: $result['ExposureMode'] = "Manual"; break;
|
||||||
|
case 5: $result['ExposureMode'] = "Auto-DEP"; break;
|
||||||
|
default: $result['ExposureMode'] = "Unknown";
|
||||||
|
}
|
||||||
|
$result['Unknown']=hexdec(intel2Moto(substr($data,$place,4)));$place+=4;//21
|
||||||
|
$result['Unknown']=hexdec(intel2Moto(substr($data,$place,4)));$place+=4;//22
|
||||||
|
$result['LongFocalLength']=hexdec(intel2Moto(substr($data,$place,4)));$place+=4;//23
|
||||||
|
$result['LongFocalLength'] .= " focal units";
|
||||||
|
$result['ShortFocalLength']=hexdec(intel2Moto(substr($data,$place,4)));$place+=4;//24
|
||||||
|
$result['ShortFocalLength'] .= " focal units";
|
||||||
|
$result['FocalUnits']=hexdec(intel2Moto(substr($data,$place,4)));$place+=4;//25
|
||||||
|
$result['FocalUnits'] .= " per mm";
|
||||||
|
$result['Unknown']=hexdec(intel2Moto(substr($data,$place,4)));$place+=4;//26
|
||||||
|
$result['Unknown']=hexdec(intel2Moto(substr($data,$place,4)));$place+=4;//27
|
||||||
|
$result['FlashActivity']=hexdec(intel2Moto(substr($data,$place,4)));$place+=4;//28
|
||||||
|
switch($result['FlashActivity']) {
|
||||||
|
case 0: $result['FlashActivity'] = "Flash Did Not Fire"; break;
|
||||||
|
case 1: $result['FlashActivity'] = "Flash Fired"; break;
|
||||||
|
default: $result['FlashActivity'] = "Unknown";
|
||||||
|
}
|
||||||
|
$result['FlashDetails']=str_pad(base_convert(intel2Moto(substr($data,$place,4)), 16, 2), 16, "0", STR_PAD_LEFT);$place+=4;//29
|
||||||
|
$flashDetails = array();
|
||||||
|
if (substr($result['FlashDetails'], 1, 1) == 1) { $flashDetails[] = 'External E-TTL'; }
|
||||||
|
if (substr($result['FlashDetails'], 2, 1) == 1) { $flashDetails[] = 'Internal Flash'; }
|
||||||
|
if (substr($result['FlashDetails'], 4, 1) == 1) { $flashDetails[] = 'FP sync used'; }
|
||||||
|
if (substr($result['FlashDetails'], 8, 1) == 1) { $flashDetails[] = '2nd(rear)-curtain sync used'; }
|
||||||
|
if (substr($result['FlashDetails'], 12, 1) == 1) { $flashDetails[] = '1st curtain sync'; }
|
||||||
|
$result['FlashDetails']=implode(",", $flashDetails);
|
||||||
|
$result['Unknown']=hexdec(intel2Moto(substr($data,$place,4)));$place+=4;//30
|
||||||
|
$result['Unknown']=hexdec(intel2Moto(substr($data,$place,4)));$place+=4;//31
|
||||||
|
$anotherFocusMode=hexdec(intel2Moto(substr($data,$place,4)));$place+=4;//32
|
||||||
|
if(strpos(strtoupper($exif['IFD0']['Model']), "G1") !== false) {
|
||||||
|
switch($anotherFocusMode) {
|
||||||
|
case 0: $result['FocusMode'] = "Single"; break;
|
||||||
|
case 1: $result['FocusMode'] = "Continuous"; break;
|
||||||
|
default: $result['FocusMode'] = "Unknown";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if($tag=="0004") { //second chunk
|
||||||
|
$result['Bytes']=hexdec(intel2Moto(substr($data,$place,4)));$place+=4;//0
|
||||||
|
if ($result['Bytes'] != strlen($data) / 2) return $result; //Bad chunk
|
||||||
|
$result['Unknown']=hexdec(intel2Moto(substr($data,$place,4)));$place+=4;//1
|
||||||
|
$result['Unknown']=hexdec(intel2Moto(substr($data,$place,4)));$place+=4;//2
|
||||||
|
$result['Unknown']=hexdec(intel2Moto(substr($data,$place,4)));$place+=4;//3
|
||||||
|
$result['Unknown']=hexdec(intel2Moto(substr($data,$place,4)));$place+=4;//4
|
||||||
|
$result['Unknown']=hexdec(intel2Moto(substr($data,$place,4)));$place+=4;//5
|
||||||
|
$result['Unknown']=hexdec(intel2Moto(substr($data,$place,4)));$place+=4;//6
|
||||||
|
$result['WhiteBalance']=hexdec(intel2Moto(substr($data,$place,4)));$place+=4;//7
|
||||||
|
switch($result['WhiteBalance']) {
|
||||||
|
case 0: $result['WhiteBalance'] = "Auto"; break;
|
||||||
|
case 1: $result['WhiteBalance'] = "Sunny"; break;
|
||||||
|
case 2: $result['WhiteBalance'] = "Cloudy"; break;
|
||||||
|
case 3: $result['WhiteBalance'] = "Tungsten"; break;
|
||||||
|
case 4: $result['WhiteBalance'] = "Fluorescent"; break;
|
||||||
|
case 5: $result['WhiteBalance'] = "Flash"; break;
|
||||||
|
case 6: $result['WhiteBalance'] = "Custom"; break;
|
||||||
|
default: $result['WhiteBalance'] = "Unknown";
|
||||||
|
}
|
||||||
|
$result['Unknown']=hexdec(intel2Moto(substr($data,$place,4)));$place+=4;//8
|
||||||
|
$result['SequenceNumber']=hexdec(intel2Moto(substr($data,$place,4)));$place+=4;//9
|
||||||
|
$result['Unknown']=hexdec(intel2Moto(substr($data,$place,4)));$place+=4;//10
|
||||||
|
$result['Unknown']=hexdec(intel2Moto(substr($data,$place,4)));$place+=4;//11
|
||||||
|
$result['Unknown']=hexdec(intel2Moto(substr($data,$place,4)));$place+=4;//12
|
||||||
|
$result['Unknown']=hexdec(intel2Moto(substr($data,$place,4)));$place+=4;//13
|
||||||
|
$result['AFPointUsed']=hexdec(intel2Moto(substr($data,$place,4)));$place+=4;//14
|
||||||
|
$afPointUsed = array();
|
||||||
|
if ($result['AFPointUsed'] & 0x0001) $afPointUsed[] = "Right"; //bit 0
|
||||||
|
if ($result['AFPointUsed'] & 0x0002) $afPointUsed[] = "Center"; //bit 1
|
||||||
|
if ($result['AFPointUsed'] & 0x0004) $afPointUsed[] = "Left"; //bit 2
|
||||||
|
if ($result['AFPointUsed'] & 0x0800) $afPointUsed[] = "12"; //bit 12
|
||||||
|
if ($result['AFPointUsed'] & 0x1000) $afPointUsed[] = "13"; //bit 13
|
||||||
|
if ($result['AFPointUsed'] & 0x2000) $afPointUsed[] = "14"; //bit 14
|
||||||
|
if ($result['AFPointUsed'] & 0x4000) $afPointUsed[] = "15"; //bit 15
|
||||||
|
$result['AFPointUsed'] = implode(",", $afPointUsed);
|
||||||
|
$result['FlashBias']=intel2Moto(substr($data,$place,4));$place+=4;//15
|
||||||
|
switch($result['FlashBias']) {
|
||||||
|
case 'ffc0': $result['FlashBias'] = "-2 EV"; break;
|
||||||
|
case 'ffcc': $result['FlashBias'] = "-1.67 EV"; break;
|
||||||
|
case 'ffd0': $result['FlashBias'] = "-1.5 EV"; break;
|
||||||
|
case 'ffd4': $result['FlashBias'] = "-1.33 EV"; break;
|
||||||
|
case 'ffe0': $result['FlashBias'] = "-1 EV"; break;
|
||||||
|
case 'ffec': $result['FlashBias'] = "-0.67 EV"; break;
|
||||||
|
case 'fff0': $result['FlashBias'] = "-0.5 EV"; break;
|
||||||
|
case 'fff4': $result['FlashBias'] = "-0.33 EV"; break;
|
||||||
|
case '0000': $result['FlashBias'] = "0 EV"; break;
|
||||||
|
case '000c': $result['FlashBias'] = "0.33 EV"; break;
|
||||||
|
case '0010': $result['FlashBias'] = "0.5 EV"; break;
|
||||||
|
case '0014': $result['FlashBias'] = "0.67 EV"; break;
|
||||||
|
case '0020': $result['FlashBias'] = "1 EV"; break;
|
||||||
|
case '002c': $result['FlashBias'] = "1.33 EV"; break;
|
||||||
|
case '0030': $result['FlashBias'] = "1.5 EV"; break;
|
||||||
|
case '0034': $result['FlashBias'] = "1.67 EV"; break;
|
||||||
|
case '0040': $result['FlashBias'] = "2 EV"; break;
|
||||||
|
default: $result['FlashBias'] = "Unknown";
|
||||||
|
}
|
||||||
|
$result['Unknown']=hexdec(intel2Moto(substr($data,$place,4)));$place+=4;//16
|
||||||
|
$result['Unknown']=hexdec(intel2Moto(substr($data,$place,4)));$place+=4;//17
|
||||||
|
$result['Unknown']=hexdec(intel2Moto(substr($data,$place,4)));$place+=4;//18
|
||||||
|
$result['SubjectDistance']=hexdec(intel2Moto(substr($data,$place,4)));$place+=4;//19
|
||||||
|
$result['SubjectDistance'] .= "/100 m";
|
||||||
|
|
||||||
|
} else if($tag=="0008") { //image number
|
||||||
|
if($intel==1) $data = intel2Moto($data);
|
||||||
|
$data=hexdec($data);
|
||||||
|
$result = round($data/10000)."-".$data%10000;
|
||||||
|
} else if($tag=="000c") { //camera serial number
|
||||||
|
if($intel==1) $data = intel2Moto($data);
|
||||||
|
$data=hexdec($data);
|
||||||
|
$result = "#".bin2hex(substr($data,0,16)).substr($data,16,16);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if($type=="UNDEFINED") {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$data = bin2hex($data);
|
||||||
|
if($intel==1) $data = intel2Moto($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//=================
|
||||||
|
// Cannon Special data section
|
||||||
|
// Useful: http://www.burren.cx/david/canon.html
|
||||||
|
// http://www.burren.cx/david/canon.html
|
||||||
|
// http://www.ozhiker.com/electronics/pjmt/jpeg_info/canon_mn.html
|
||||||
|
//====================================================================
|
||||||
|
function parseCanon($block,&$result,$seek, $globalOffset) {
|
||||||
|
$place = 0; //current place
|
||||||
|
|
||||||
|
if($result['Endien']=="Intel") $intel=1;
|
||||||
|
else $intel=0;
|
||||||
|
|
||||||
|
$model = $result['IFD0']['Model'];
|
||||||
|
|
||||||
|
//Get number of tags (2 bytes)
|
||||||
|
$num = bin2hex(substr($block,$place,2));$place+=2;
|
||||||
|
if($intel==1) $num = intel2Moto($num);
|
||||||
|
$result['SubIFD']['MakerNote']['MakerNoteNumTags'] = hexdec($num);
|
||||||
|
|
||||||
|
//loop thru all tags Each field is 12 bytes
|
||||||
|
for($i=0;$i<hexdec($num);$i++) {
|
||||||
|
|
||||||
|
//2 byte tag
|
||||||
|
$tag = bin2hex(substr($block,$place,2));$place+=2;
|
||||||
|
if($intel==1) $tag = intel2Moto($tag);
|
||||||
|
$tag_name = lookup_Canon_tag($tag);
|
||||||
|
|
||||||
|
//2 byte type
|
||||||
|
$type = bin2hex(substr($block,$place,2));$place+=2;
|
||||||
|
if($intel==1) $type = intel2Moto($type);
|
||||||
|
lookup_type($type,$size);
|
||||||
|
|
||||||
|
//4 byte count of number of data units
|
||||||
|
$count = bin2hex(substr($block,$place,4));$place+=4;
|
||||||
|
if($intel==1) $count = intel2Moto($count);
|
||||||
|
$bytesofdata = $size*hexdec($count);
|
||||||
|
|
||||||
|
if($bytesofdata<=0) {
|
||||||
|
return; //if this value is 0 or less then we have read all the tags we can
|
||||||
|
}
|
||||||
|
|
||||||
|
//4 byte value of data or pointer to data
|
||||||
|
$value = substr($block,$place,4);$place+=4;
|
||||||
|
|
||||||
|
if($bytesofdata<=4) {
|
||||||
|
$data = $value;
|
||||||
|
} else {
|
||||||
|
$value = bin2hex($value);
|
||||||
|
if($intel==1) $value = intel2Moto($value);
|
||||||
|
$v = fseek($seek,$globalOffset+hexdec($value)); //offsets are from TIFF header which is 12 bytes from the start of the file
|
||||||
|
if($v==0 && $bytesofdata < $GLOBALS['exiferFileSize']) {
|
||||||
|
$data = fread($seek, $bytesofdata);
|
||||||
|
} else if($v==-1) {
|
||||||
|
$result['Errors'] = $result['Errors']++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$formated_data = formatCanonData($type,$tag,$intel,$data,$result,$result['SubIFD']['MakerNote'][$tag_name]);
|
||||||
|
|
||||||
|
if($result['VerboseOutput']==1) {
|
||||||
|
//$result['SubIFD']['MakerNote'][$tag_name] = $formated_data;
|
||||||
|
if($type=="URATIONAL" || $type=="SRATIONAL" || $type=="USHORT" || $type=="SSHORT" || $type=="ULONG" || $type=="SLONG" || $type=="FLOAT" || $type=="DOUBLE") {
|
||||||
|
$data = bin2hex($data);
|
||||||
|
if($intel==1) $data = intel2Moto($data);
|
||||||
|
}
|
||||||
|
$result['SubIFD']['MakerNote'][$tag_name."_Verbose"]['RawData'] = $data;
|
||||||
|
$result['SubIFD']['MakerNote'][$tag_name."_Verbose"]['Type'] = $type;
|
||||||
|
$result['SubIFD']['MakerNote'][$tag_name."_Verbose"]['Bytes'] = $bytesofdata;
|
||||||
|
} else {
|
||||||
|
//$result['SubIFD']['MakerNote'][$tag_name] = $formated_data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
269
upload/includes/makers/fujifilm.php
Normal file
269
upload/includes/makers/fujifilm.php
Normal file
|
@ -0,0 +1,269 @@
|
||||||
|
<?php
|
||||||
|
/*************************
|
||||||
|
Coppermine Photo Gallery
|
||||||
|
************************
|
||||||
|
Copyright (c) 2003-2012 Coppermine Dev Team
|
||||||
|
v1.0 originally written by Gregory Demar
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License version 3
|
||||||
|
as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
********************************************
|
||||||
|
Coppermine version: 1.5.18
|
||||||
|
$HeadURL: https://coppermine.svn.sourceforge.net/svnroot/coppermine/trunk/cpg1.5.x/include/makers/fujifilm.php $
|
||||||
|
$Revision: 8304 $
|
||||||
|
**********************************************/
|
||||||
|
/*
|
||||||
|
Exifer
|
||||||
|
Extracts EXIF information from digital photos.
|
||||||
|
|
||||||
|
Copyright © 2003 Jake Olefsky
|
||||||
|
http://www.offsky.com/software/exif/index.php
|
||||||
|
jake@olefsky.com
|
||||||
|
|
||||||
|
Please see exif.php for the complete information about this software.
|
||||||
|
|
||||||
|
------------
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify it under the terms of
|
||||||
|
the GNU General Public License as published by the Free Software Foundation; either version 2
|
||||||
|
of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
See the GNU General Public License for more details. http://www.gnu.org/copyleft/gpl.html
|
||||||
|
*/
|
||||||
|
//================================================================================================
|
||||||
|
//================================================================================================
|
||||||
|
//================================================================================================
|
||||||
|
|
||||||
|
|
||||||
|
//=================
|
||||||
|
// Looks up the name of the tag for the MakerNote (Depends on Manufacturer)
|
||||||
|
//====================================================================
|
||||||
|
function lookup_Fujifilm_tag($tag) {
|
||||||
|
|
||||||
|
switch($tag) {
|
||||||
|
case "0000": $tag = "Version";break;
|
||||||
|
case "1000": $tag = "Quality";break;
|
||||||
|
case "1001": $tag = "Sharpness";break;
|
||||||
|
case "1002": $tag = "WhiteBalance";break;
|
||||||
|
case "1003": $tag = "Color";break;
|
||||||
|
case "1004": $tag = "Tone";break;
|
||||||
|
case "1010": $tag = "FlashMode";break;
|
||||||
|
case "1011": $tag = "FlashStrength";break;
|
||||||
|
case "1020": $tag = "Macro";break;
|
||||||
|
case "1021": $tag = "FocusMode";break;
|
||||||
|
case "1030": $tag = "SlowSync";break;
|
||||||
|
case "1031": $tag = "PictureMode";break;
|
||||||
|
case "1032": $tag = "Unknown";break;
|
||||||
|
case "1100": $tag = "ContinuousTakingBracket";break;
|
||||||
|
case "1200": $tag = "Unknown";break;
|
||||||
|
case "1300": $tag = "BlurWarning";break;
|
||||||
|
case "1301": $tag = "FocusWarning";break;
|
||||||
|
case "1302": $tag = "AEWarning";break;
|
||||||
|
|
||||||
|
default: $tag = "unknown:".$tag;break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $tag;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=================
|
||||||
|
// Formats Data for the data type
|
||||||
|
//====================================================================
|
||||||
|
function formatFujifilmData($type,$tag,$intel,$data) {
|
||||||
|
|
||||||
|
if($type=="ASCII") {
|
||||||
|
|
||||||
|
|
||||||
|
} else if($type=="URATIONAL" || $type=="SRATIONAL") {
|
||||||
|
$data = bin2hex($data);
|
||||||
|
if($intel==1) $data = intel2Moto($data);
|
||||||
|
$top = hexdec(substr($data,8,8));
|
||||||
|
$bottom = hexdec(substr($data,0,8));
|
||||||
|
if($bottom!=0) $data=$top/$bottom;
|
||||||
|
else if($top==0) $data = 0;
|
||||||
|
else $data=$top."/".$bottom;
|
||||||
|
|
||||||
|
if($tag=="1011") { //FlashStrength
|
||||||
|
$data=$data." EV";
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if($type=="USHORT" || $type=="SSHORT" || $type=="ULONG" || $type=="SLONG" || $type=="FLOAT" || $type=="DOUBLE") {
|
||||||
|
$data = bin2hex($data);
|
||||||
|
if($intel==1) $data = intel2Moto($data);
|
||||||
|
$data=hexdec($data);
|
||||||
|
|
||||||
|
if($tag=="1001") { //Sharpness
|
||||||
|
if($data == 1) $data = "Soft";
|
||||||
|
else if($data == 2) $data = "Soft";
|
||||||
|
else if($data == 3) $data = "Normal";
|
||||||
|
else if($data == 4) $data = "Hard";
|
||||||
|
else if($data == 5) $data = "Hard";
|
||||||
|
else $data = "Unknown: ".$data;
|
||||||
|
}
|
||||||
|
if($tag=="1002") { //WhiteBalance
|
||||||
|
if($data == 0) $data = "Auto";
|
||||||
|
else if($data == 256) $data = "Daylight";
|
||||||
|
else if($data == 512) $data = "Cloudy";
|
||||||
|
else if($data == 768) $data = "DaylightColor-fluorescence";
|
||||||
|
else if($data == 769) $data = "DaywhiteColor-fluorescence";
|
||||||
|
else if($data == 770) $data = "White-fluorescence";
|
||||||
|
else if($data == 1024) $data = "Incandenscense";
|
||||||
|
else if($data == 3840) $data = "Custom";
|
||||||
|
else $data = "Unknown: ".$data;
|
||||||
|
}
|
||||||
|
if($tag=="1003") { //Color
|
||||||
|
if($data == 0) $data = "Chroma Saturation Normal(STD)";
|
||||||
|
else if($data == 256) $data = "Chroma Saturation High";
|
||||||
|
else if($data == 512) $data = "Chroma Saturation Low(ORG)";
|
||||||
|
else $data = "Unknown: ".$data;
|
||||||
|
}
|
||||||
|
if($tag=="1004") { //Tone
|
||||||
|
if($data == 0) $data = "Contrast Normal(STD)";
|
||||||
|
else if($data == 256) $data = "Contrast High(HARD)";
|
||||||
|
else if($data == 512) $data = "Contrast Low(ORG)";
|
||||||
|
else $data = "Unknown: ".$data;
|
||||||
|
}
|
||||||
|
if($tag=="1010") { //FlashMode
|
||||||
|
if($data == 0) $data = "Auto";
|
||||||
|
else if($data == 1) $data = "On";
|
||||||
|
else if($data == 2) $data = "Off";
|
||||||
|
else if($data == 3) $data = "Red-Eye Reduction";
|
||||||
|
else $data = "Unknown: ".$data;
|
||||||
|
}
|
||||||
|
if($tag=="1020") { //Macro
|
||||||
|
if($data == 0) $data = "Off";
|
||||||
|
else if($data == 1) $data = "On";
|
||||||
|
else $data = "Unknown: ".$data;
|
||||||
|
}
|
||||||
|
if($tag=="1021") { //FocusMode
|
||||||
|
if($data == 0) $data = "Auto";
|
||||||
|
else if($data == 1) $data = "Manual";
|
||||||
|
else $data = "Unknown: ".$data;
|
||||||
|
}
|
||||||
|
if($tag=="1030") { //SlowSync
|
||||||
|
if($data == 0) $data = "Off";
|
||||||
|
else if($data == 1) $data = "On";
|
||||||
|
else $data = "Unknown: ".$data;
|
||||||
|
}
|
||||||
|
if($tag=="1031") { //PictureMode
|
||||||
|
if($data == 0) $data = "Auto";
|
||||||
|
else if($data == 1) $data = "Portrait";
|
||||||
|
else if($data == 2) $data = "Landscape";
|
||||||
|
else if($data == 4) $data = "Sports";
|
||||||
|
else if($data == 5) $data = "Night";
|
||||||
|
else if($data == 6) $data = "Program AE";
|
||||||
|
else if($data == 256) $data = "Aperture Prority AE";
|
||||||
|
else if($data == 512) $data = "Shutter Prority";
|
||||||
|
else if($data == 768) $data = "Manual Exposure";
|
||||||
|
else $data = "Unknown: ".$data;
|
||||||
|
}
|
||||||
|
if($tag=="1100") { //ContinuousTakingBracket
|
||||||
|
if($data == 0) $data = "Off";
|
||||||
|
else if($data == 1) $data = "On";
|
||||||
|
else $data = "Unknown: ".$data;
|
||||||
|
}
|
||||||
|
if($tag=="1300") { //BlurWarning
|
||||||
|
if($data == 0) $data = "No Warning";
|
||||||
|
else if($data == 1) $data = "Warning";
|
||||||
|
else $data = "Unknown: ".$data;
|
||||||
|
}
|
||||||
|
if($tag=="1301") { //FocusWarning
|
||||||
|
if($data == 0) $data = "Auto Focus Good";
|
||||||
|
else if($data == 1) $data = "Out of Focus";
|
||||||
|
else $data = "Unknown: ".$data;
|
||||||
|
}
|
||||||
|
if($tag=="1302") { //AEWarning
|
||||||
|
if($data == 0) $data = "AE Good";
|
||||||
|
else if($data == 1) $data = "Over Exposure";
|
||||||
|
else $data = "Unknown: ".$data;
|
||||||
|
}
|
||||||
|
} else if($type=="UNDEFINED") {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$data = bin2hex($data);
|
||||||
|
if($intel==1) $data = intel2Moto($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//=================
|
||||||
|
// Fujifilm Special data section
|
||||||
|
//====================================================================
|
||||||
|
function parseFujifilm($block,&$result) {
|
||||||
|
|
||||||
|
//if($result['Endien']=="Intel") $intel=1;
|
||||||
|
//else $intel=0;
|
||||||
|
$intel=1;
|
||||||
|
|
||||||
|
$model = $result['IFD0']['Model'];
|
||||||
|
|
||||||
|
$place=8; //current place
|
||||||
|
$offset=8;
|
||||||
|
|
||||||
|
|
||||||
|
$num = bin2hex(substr($block,$place,4));$place+=4;
|
||||||
|
if($intel==1) $num = intel2Moto($num);
|
||||||
|
$result['SubIFD']['MakerNote']['Offset'] = hexdec($num);
|
||||||
|
|
||||||
|
//Get number of tags (2 bytes)
|
||||||
|
$num = bin2hex(substr($block,$place,2));$place+=2;
|
||||||
|
if($intel==1) $num = intel2Moto($num);
|
||||||
|
$result['SubIFD']['MakerNote']['MakerNoteNumTags'] = hexdec($num);
|
||||||
|
|
||||||
|
//loop thru all tags Each field is 12 bytes
|
||||||
|
for($i=0;$i<hexdec($num);$i++) {
|
||||||
|
|
||||||
|
//2 byte tag
|
||||||
|
$tag = bin2hex(substr($block,$place,2));$place+=2;
|
||||||
|
if($intel==1) $tag = intel2Moto($tag);
|
||||||
|
$tag_name = lookup_Fujifilm_tag($tag);
|
||||||
|
|
||||||
|
//2 byte type
|
||||||
|
$type = bin2hex(substr($block,$place,2));$place+=2;
|
||||||
|
if($intel==1) $type = intel2Moto($type);
|
||||||
|
lookup_type($type,$size);
|
||||||
|
|
||||||
|
//4 byte count of number of data units
|
||||||
|
$count = bin2hex(substr($block,$place,4));$place+=4;
|
||||||
|
if($intel==1) $count = intel2Moto($count);
|
||||||
|
$bytesofdata = $size*hexdec($count);
|
||||||
|
|
||||||
|
//4 byte value of data or pointer to data
|
||||||
|
$value = substr($block,$place,4);$place+=4;
|
||||||
|
|
||||||
|
|
||||||
|
if($bytesofdata<=4) {
|
||||||
|
$data = $value;
|
||||||
|
} else {
|
||||||
|
$value = bin2hex($value);
|
||||||
|
if($intel==1) $value = intel2Moto($value);
|
||||||
|
$data = substr($block,hexdec($value)-$offset,$bytesofdata*2);
|
||||||
|
}
|
||||||
|
$formated_data = formatFujifilmData($type,$tag,$intel,$data);
|
||||||
|
|
||||||
|
if($result['VerboseOutput']==1) {
|
||||||
|
$result['SubIFD']['MakerNote'][$tag_name] = $formated_data;
|
||||||
|
if($type=="URATIONAL" || $type=="SRATIONAL" || $type=="USHORT" || $type=="SSHORT" || $type=="ULONG" || $type=="SLONG" || $type=="FLOAT" || $type=="DOUBLE") {
|
||||||
|
$data = bin2hex($data);
|
||||||
|
if($intel==1) $data = intel2Moto($data);
|
||||||
|
}
|
||||||
|
$result['SubIFD']['MakerNote'][$tag_name."_Verbose"]['RawData'] = $data;
|
||||||
|
$result['SubIFD']['MakerNote'][$tag_name."_Verbose"]['Type'] = $type;
|
||||||
|
$result['SubIFD']['MakerNote'][$tag_name."_Verbose"]['Bytes'] = $bytesofdata;
|
||||||
|
} else {
|
||||||
|
$result['SubIFD']['MakerNote'][$tag_name] = $formated_data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
259
upload/includes/makers/gps.php
Normal file
259
upload/includes/makers/gps.php
Normal file
|
@ -0,0 +1,259 @@
|
||||||
|
<?php
|
||||||
|
/*************************
|
||||||
|
Coppermine Photo Gallery
|
||||||
|
************************
|
||||||
|
Copyright (c) 2003-2012 Coppermine Dev Team
|
||||||
|
v1.0 originally written by Gregory Demar
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License version 3
|
||||||
|
as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
********************************************
|
||||||
|
Coppermine version: 1.5.18
|
||||||
|
$HeadURL: https://coppermine.svn.sourceforge.net/svnroot/coppermine/trunk/cpg1.5.x/include/makers/gps.php $
|
||||||
|
$Revision: 8304 $
|
||||||
|
**********************************************/
|
||||||
|
/*
|
||||||
|
Exifer
|
||||||
|
Extracts EXIF information from digital photos.
|
||||||
|
|
||||||
|
Copyright © 2003 Jake Olefsky
|
||||||
|
http://www.offsky.com/software/exif/index.php
|
||||||
|
jake@olefsky.com
|
||||||
|
|
||||||
|
Please see exif.php for the complete information about this software.
|
||||||
|
|
||||||
|
------------
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify it under the terms of
|
||||||
|
the GNU General Public License as published by the Free Software Foundation; either version 2
|
||||||
|
of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
See the GNU General Public License for more details. http://www.gnu.org/copyleft/gpl.html
|
||||||
|
*/
|
||||||
|
//================================================================================================
|
||||||
|
//================================================================================================
|
||||||
|
//================================================================================================
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//=================
|
||||||
|
// Looks up the name of the tag
|
||||||
|
//====================================================================
|
||||||
|
function lookup_GPS_tag($tag) {
|
||||||
|
|
||||||
|
switch($tag) {
|
||||||
|
case "0000": $tag = "Version";break;
|
||||||
|
case "0001": $tag = "Latitude Reference";break; //north or south
|
||||||
|
case "0002": $tag = "Latitude";break; //dd mm.mm or dd mm ss
|
||||||
|
case "0003": $tag = "Longitude Reference";break; //east or west
|
||||||
|
case "0004": $tag = "Longitude";break; //dd mm.mm or dd mm ss
|
||||||
|
case "0005": $tag = "Altitude Reference";break; //sea level or below sea level
|
||||||
|
case "0006": $tag = "Altitude";break; //positive rational number
|
||||||
|
case "0007": $tag = "Time";break; //three positive rational numbers
|
||||||
|
case "0008": $tag = "Satellite";break; //text string up to 999 bytes long
|
||||||
|
case "0009": $tag = "ReceiveStatus";break; //in progress or interop
|
||||||
|
case "000a": $tag = "MeasurementMode";break; //2D or 3D
|
||||||
|
case "000b": $tag = "MeasurementPrecision";break; //positive rational number
|
||||||
|
case "000c": $tag = "SpeedUnit";break; //KPH, MPH, knots
|
||||||
|
case "000d": $tag = "ReceiverSpeed";break; //positive rational number
|
||||||
|
case "000e": $tag = "MovementDirectionRef";break; //true or magnetic north
|
||||||
|
case "000f": $tag = "MovementDirection";break; //positive rational number
|
||||||
|
case "0010": $tag = "ImageDirectionRef";break; //true or magnetic north
|
||||||
|
case "0011": $tag = "ImageDirection";break; //positive rational number
|
||||||
|
case "0012": $tag = "GeodeticSurveyData";break; //text string up to 999 bytes long
|
||||||
|
case "0013": $tag = "DestLatitudeRef";break; //north or south
|
||||||
|
case "0014": $tag = "DestinationLatitude";break; //three positive rational numbers
|
||||||
|
case "0015": $tag = "DestLongitudeRef";break; //east or west
|
||||||
|
case "0016": $tag = "DestinationLongitude";break; //three positive rational numbers
|
||||||
|
case "0017": $tag = "DestBearingRef";break; //true or magnetic north
|
||||||
|
case "0018": $tag = "DestinationBearing";break; //positive rational number
|
||||||
|
case "0019": $tag = "DestDistanceRef";break; //km, miles, knots
|
||||||
|
case "001a": $tag = "DestinationDistance";break; //positive rational number
|
||||||
|
case "001b": $tag = "ProcessingMethod";break;
|
||||||
|
case "001c": $tag = "AreaInformation";break;
|
||||||
|
case "001d": $tag = "Datestamp";break; //text string 10 bytes long
|
||||||
|
case "001e": $tag = "DifferentialCorrection";break; //integer in range 0-65535
|
||||||
|
|
||||||
|
|
||||||
|
default: $tag = "unknown:".$tag;break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $tag;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=================
|
||||||
|
// Formats a rational number
|
||||||
|
//====================================================================
|
||||||
|
function GPSRational($data, $intel) {
|
||||||
|
|
||||||
|
if($intel==1) $top = hexdec(substr($data,8,8)); //intel stores them bottom-top
|
||||||
|
else $top = hexdec(substr($data,0,8)); //motorola stores them top-bottom
|
||||||
|
|
||||||
|
if($intel==1) $bottom = hexdec(substr($data,0,8)); //intel stores them bottom-top
|
||||||
|
else $bottom = hexdec(substr($data,8,8)); //motorola stores them top-bottom
|
||||||
|
|
||||||
|
if($bottom!=0) $data=$top/$bottom;
|
||||||
|
else if($top==0) $data = 0;
|
||||||
|
else $data=$top."/".$bottom;
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
//=================
|
||||||
|
// Formats Data for the data type
|
||||||
|
//====================================================================
|
||||||
|
function formatGPSData($type,$tag,$intel,$data) {
|
||||||
|
|
||||||
|
if($type=="ASCII") {
|
||||||
|
if($tag=="0001" || $tag=="0003"){ // Latitude Reference, Longitude Reference
|
||||||
|
$data = ($data{1} == $data{2} && $data{1} == $data{3}) ? $data{0} : $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if($type=="URATIONAL" || $type=="SRATIONAL") {
|
||||||
|
$data = bin2hex($data);
|
||||||
|
if($intel==1) $data = intel2Moto($data);
|
||||||
|
|
||||||
|
if($intel==1) $top = hexdec(substr($data,8,8)); //intel stores them bottom-top
|
||||||
|
else $top = hexdec(substr($data,0,8)); //motorola stores them top-bottom
|
||||||
|
|
||||||
|
if($intel==1) $bottom = hexdec(substr($data,0,8)); //intel stores them bottom-top
|
||||||
|
else $bottom = hexdec(substr($data,8,8)); //motorola stores them top-bottom
|
||||||
|
|
||||||
|
if($type=="SRATIONAL" && $top>2147483647) $top = $top - 4294967296; //this makes the number signed instead of unsigned
|
||||||
|
|
||||||
|
if($tag=="0002" || $tag=="0004") { //Latitude, Longitude
|
||||||
|
|
||||||
|
if($intel==1){
|
||||||
|
$seconds = GPSRational(substr($data,0,16),$intel);
|
||||||
|
$hour = GPSRational(substr($data,32,16),$intel);
|
||||||
|
} else {
|
||||||
|
$hour= GPSRational(substr($data,0,16),$intel);
|
||||||
|
$seconds = GPSRational(substr($data,32,16),$intel);
|
||||||
|
}
|
||||||
|
$minutes = GPSRational(substr($data,16,16),$intel);
|
||||||
|
|
||||||
|
$data = $hour+$minutes/60+$seconds/3600;
|
||||||
|
} else if($tag=="0007") { //Time
|
||||||
|
$seconds = GPSRational(substr($data,0,16),$intel);
|
||||||
|
$minutes = GPSRational(substr($data,16,16),$intel);
|
||||||
|
$hour = GPSRational(substr($data,32,16),$intel);
|
||||||
|
|
||||||
|
$data = $hour.":".$minutes.":".$seconds;
|
||||||
|
} else {
|
||||||
|
if($bottom!=0) $data=$top/$bottom;
|
||||||
|
else if($top==0) $data = 0;
|
||||||
|
else $data=$top."/".$bottom;
|
||||||
|
|
||||||
|
if($tag=="0006"){
|
||||||
|
$data .= 'm';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if($type=="USHORT" || $type=="SSHORT" || $type=="ULONG" || $type=="SLONG" || $type=="FLOAT" || $type=="DOUBLE") {
|
||||||
|
$data = bin2hex($data);
|
||||||
|
if($intel==1) $data = intel2Moto($data);
|
||||||
|
$data=hexdec($data);
|
||||||
|
|
||||||
|
|
||||||
|
} else if($type=="UNDEFINED") {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} else if($type=="UBYTE") {
|
||||||
|
$data = bin2hex($data);
|
||||||
|
if($intel==1) $num = intel2Moto($data);
|
||||||
|
|
||||||
|
|
||||||
|
if($tag=="0000") { // VersionID
|
||||||
|
$data = hexdec(substr($data,0,2)) .
|
||||||
|
".". hexdec(substr($data,2,2)) .
|
||||||
|
".". hexdec(substr($data,4,2)) .
|
||||||
|
".". hexdec(substr($data,6,2));
|
||||||
|
|
||||||
|
} else if($tag=="0005"){ // Altitude Reference
|
||||||
|
if($data == "00000000"){ $data = 'Above Sea Level'; }
|
||||||
|
else if($data == "01000000"){ $data = 'Below Sea Level'; }
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$data = bin2hex($data);
|
||||||
|
if($intel==1) $data = intel2Moto($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//=================
|
||||||
|
// GPS Special data section
|
||||||
|
// Useful websites
|
||||||
|
// http://drewnoakes.com/code/exif/sampleOutput.html
|
||||||
|
// http://www.geosnapper.com
|
||||||
|
//====================================================================
|
||||||
|
function parseGPS($block,&$result,$offset,$seek, $globalOffset) {
|
||||||
|
|
||||||
|
if($result['Endien']=="Intel") $intel=1;
|
||||||
|
else $intel=0;
|
||||||
|
|
||||||
|
$v = fseek($seek,$globalOffset+$offset); //offsets are from TIFF header which is 12 bytes from the start of the file
|
||||||
|
if($v==-1) {
|
||||||
|
$result['Errors'] = $result['Errors']++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$num = bin2hex(fread( $seek, 2 ));
|
||||||
|
if($intel==1) $num = intel2Moto($num);
|
||||||
|
$num=hexdec($num);
|
||||||
|
$result['GPS']['NumTags'] = $num;
|
||||||
|
|
||||||
|
$block = fread( $seek, $num*12 );
|
||||||
|
$place = 0;
|
||||||
|
|
||||||
|
//loop thru all tags Each field is 12 bytes
|
||||||
|
for($i=0;$i<$num;$i++) {
|
||||||
|
//2 byte tag
|
||||||
|
$tag = bin2hex(substr($block,$place,2));$place+=2;
|
||||||
|
if($intel==1) $tag = intel2Moto($tag);
|
||||||
|
$tag_name = lookup_GPS_tag($tag);
|
||||||
|
|
||||||
|
//2 byte datatype
|
||||||
|
$type = bin2hex(substr($block,$place,2));$place+=2;
|
||||||
|
if($intel==1) $type = intel2Moto($type);
|
||||||
|
lookup_type($type,$size);
|
||||||
|
|
||||||
|
//4 byte number of elements
|
||||||
|
$count = bin2hex(substr($block,$place,4));$place+=4;
|
||||||
|
if($intel==1) $count = intel2Moto($count);
|
||||||
|
$bytesofdata = $size*hexdec($count);
|
||||||
|
|
||||||
|
//4 byte value or pointer to value if larger than 4 bytes
|
||||||
|
$value = substr($block,$place,4);$place+=4;
|
||||||
|
|
||||||
|
if($bytesofdata<=4) {
|
||||||
|
$data = $value;
|
||||||
|
} else {
|
||||||
|
$value = bin2hex($value);
|
||||||
|
if($intel==1) $value = intel2Moto($value);
|
||||||
|
|
||||||
|
$v = fseek($seek,$globalOffset+hexdec($value)); //offsets are from TIFF header which is 12 bytes from the start of the file
|
||||||
|
if($v==0) {
|
||||||
|
$data = fread($seek, $bytesofdata);
|
||||||
|
} else if($v==-1) {
|
||||||
|
$result['Errors'] = $result['Errors']++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if($result['VerboseOutput']==1) {
|
||||||
|
$result['GPS'][$tag_name] = formatGPSData($type,$tag,$intel,$data);
|
||||||
|
$result['GPS'][$tag_name."_Verbose"]['RawData'] = bin2hex($data);
|
||||||
|
$result['GPS'][$tag_name."_Verbose"]['Type'] = $type;
|
||||||
|
$result['GPS'][$tag_name."_Verbose"]['Bytes'] = $bytesofdata;
|
||||||
|
} else {
|
||||||
|
$result['GPS'][$tag_name] = formatGPSData($type,$tag,$intel,$data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
343
upload/includes/makers/nikon.php
Normal file
343
upload/includes/makers/nikon.php
Normal file
|
@ -0,0 +1,343 @@
|
||||||
|
<?php
|
||||||
|
/*************************
|
||||||
|
Coppermine Photo Gallery
|
||||||
|
************************
|
||||||
|
Copyright (c) 2003-2012 Coppermine Dev Team
|
||||||
|
v1.0 originally written by Gregory Demar
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License version 3
|
||||||
|
as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
********************************************
|
||||||
|
Coppermine version: 1.5.18
|
||||||
|
$HeadURL: https://coppermine.svn.sourceforge.net/svnroot/coppermine/trunk/cpg1.5.x/include/makers/nikon.php $
|
||||||
|
$Revision: 8304 $
|
||||||
|
**********************************************/
|
||||||
|
/*
|
||||||
|
Exifer
|
||||||
|
Extracts EXIF information from digital photos.
|
||||||
|
|
||||||
|
Copyright © 2003 Jake Olefsky
|
||||||
|
http://www.offsky.com/software/exif/index.php
|
||||||
|
jake@olefsky.com
|
||||||
|
|
||||||
|
Please see exif.php for the complete information about this software.
|
||||||
|
|
||||||
|
------------
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify it under the terms of
|
||||||
|
the GNU General Public License as published by the Free Software Foundation; either version 2
|
||||||
|
of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
See the GNU General Public License for more details. http://www.gnu.org/copyleft/gpl.html
|
||||||
|
*/
|
||||||
|
//================================================================================================
|
||||||
|
//================================================================================================
|
||||||
|
//================================================================================================
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//=================
|
||||||
|
// Looks up the name of the tag for the MakerNote (Depends on Manufacturer)
|
||||||
|
//====================================================================
|
||||||
|
function lookup_Nikon_tag($tag,$model) {
|
||||||
|
|
||||||
|
if($model==0) {
|
||||||
|
switch($tag) {
|
||||||
|
case "0003": $tag = "Quality";break;
|
||||||
|
case "0004": $tag = "ColorMode";break;
|
||||||
|
case "0005": $tag = "ImageAdjustment";break;
|
||||||
|
case "0006": $tag = "CCDSensitivity";break;
|
||||||
|
case "0007": $tag = "WhiteBalance";break;
|
||||||
|
case "0008": $tag = "Focus";break;
|
||||||
|
case "0009": $tag = "Unknown2";break;
|
||||||
|
case "000a": $tag = "DigitalZoom";break;
|
||||||
|
case "000b": $tag = "Converter";break;
|
||||||
|
|
||||||
|
default: $tag = "unknown:".$tag;break;
|
||||||
|
}
|
||||||
|
} else if($model==1) {
|
||||||
|
switch($tag) {
|
||||||
|
case "0002": $tag = "ISOSetting";break;
|
||||||
|
case "0003": $tag = "ColorMode";break;
|
||||||
|
case "0004": $tag = "Quality";break;
|
||||||
|
case "0005": $tag = "Whitebalance";break;
|
||||||
|
case "0006": $tag = "ImageSharpening";break;
|
||||||
|
case "0007": $tag = "FocusMode";break;
|
||||||
|
case "0008": $tag = "FlashSetting";break;
|
||||||
|
case "0009": $tag = "FlashMode";break;
|
||||||
|
case "000b": $tag = "WhiteBalanceFine";break;
|
||||||
|
case "000f": $tag = "ISOSelection";break;
|
||||||
|
case "0013": $tag = "ISOSelection2";break;
|
||||||
|
case "0080": $tag = "ImageAdjustment";break;
|
||||||
|
case "0081": $tag = "ToneCompensation";break;
|
||||||
|
case "0082": $tag = "Adapter";break;
|
||||||
|
case "0083": $tag = "LensType";break;
|
||||||
|
case "0084": $tag = "LensInfo";break;
|
||||||
|
case "0085": $tag = "ManualFocusDistance";break;
|
||||||
|
case "0086": $tag = "DigitalZoom";break;
|
||||||
|
case "0087": $tag = "FlashUsed";break;
|
||||||
|
case "0088": $tag = "AFFocusPosition";break;
|
||||||
|
case "008d": $tag = "ColorMode";break;
|
||||||
|
case "0090": $tag = "LightType";break;
|
||||||
|
case "0094": $tag = "Saturation";break;
|
||||||
|
case "0095": $tag = "NoiseReduction";break;
|
||||||
|
case "0010": $tag = "DataDump";break;
|
||||||
|
|
||||||
|
default: $tag = "unknown:".$tag;break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $tag;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=================
|
||||||
|
// Formats Data for the data type
|
||||||
|
//====================================================================
|
||||||
|
function formatNikonData($type,$tag,$intel,$model,$data) {
|
||||||
|
|
||||||
|
if($type=="ASCII") {
|
||||||
|
|
||||||
|
|
||||||
|
} else if($type=="URATIONAL" || $type=="SRATIONAL") {
|
||||||
|
$data = bin2hex($data);
|
||||||
|
if($intel==1) $data = intel2Moto($data);
|
||||||
|
$top = hexdec(substr($data,8,8));
|
||||||
|
$bottom = hexdec(substr($data,0,8));
|
||||||
|
if($bottom!=0) $data=$top/$bottom;
|
||||||
|
else if($top==0) $data = 0;
|
||||||
|
else $data=$top."/".$bottom;
|
||||||
|
|
||||||
|
if($tag=="0085" && $model==1) { //ManualFocusDistance
|
||||||
|
$data=$data." m";
|
||||||
|
}
|
||||||
|
if($tag=="0086" && $model==1) { //DigitalZoom
|
||||||
|
$data=$data."x";
|
||||||
|
}
|
||||||
|
if($tag=="000a" && $model==0) { //DigitalZoom
|
||||||
|
$data=$data."x";
|
||||||
|
}
|
||||||
|
} else if($type=="USHORT" || $type=="SSHORT" || $type=="ULONG" || $type=="SLONG" || $type=="FLOAT" || $type=="DOUBLE") {
|
||||||
|
$data = bin2hex($data);
|
||||||
|
if($intel==1) $data = intel2Moto($data);
|
||||||
|
$data=hexdec($data);
|
||||||
|
|
||||||
|
if($tag=="0003" && $model==0) { //Quality
|
||||||
|
if($data == 1) $data = "VGA Basic";
|
||||||
|
else if($data == 2) $data = "VGA Normal";
|
||||||
|
else if($data == 3) $data = "VGA Fine";
|
||||||
|
else if($data == 4) $data = "SXGA Basic";
|
||||||
|
else if($data == 5) $data = "SXGA Normal";
|
||||||
|
else if($data == 6) $data = "SXGA Fine";
|
||||||
|
else $data = "Unknown: ".$data;
|
||||||
|
}
|
||||||
|
if($tag=="0004" && $model==0) { //Color
|
||||||
|
if($data == 1) $data = "Color";
|
||||||
|
else if($data == 2) $data = "Monochrome";
|
||||||
|
else $data = "Unknown: ".$data;
|
||||||
|
}
|
||||||
|
if($tag=="0005" && $model==0) { //Image Adjustment
|
||||||
|
if($data == 0) $data = "Normal";
|
||||||
|
else if($data == 1) $data = "Bright+";
|
||||||
|
else if($data == 2) $data = "Bright-";
|
||||||
|
else if($data == 3) $data = "Contrast+";
|
||||||
|
else if($data == 4) $data = "Contrast-";
|
||||||
|
else $data = "Unknown: ".$data;
|
||||||
|
}
|
||||||
|
if($tag=="0006" && $model==0) { //CCD Sensitivity
|
||||||
|
if($data == 0) $data = "ISO-80";
|
||||||
|
else if($data == 2) $data = "ISO-160";
|
||||||
|
else if($data == 4) $data = "ISO-320";
|
||||||
|
else if($data == 5) $data = "ISO-100";
|
||||||
|
else $data = "Unknown: ".$data;
|
||||||
|
}
|
||||||
|
if($tag=="0007" && $model==0) { //White Balance
|
||||||
|
if($data == 0) $data = "Auto";
|
||||||
|
else if($data == 1) $data = "Preset";
|
||||||
|
else if($data == 2) $data = "Daylight";
|
||||||
|
else if($data == 3) $data = "Incandescense";
|
||||||
|
else if($data == 4) $data = "Flourescence";
|
||||||
|
else if($data == 5) $data = "Cloudy";
|
||||||
|
else if($data == 6) $data = "SpeedLight";
|
||||||
|
else $data = "Unknown: ".$data;
|
||||||
|
}
|
||||||
|
if($tag=="000b" && $model==0) { //Converter
|
||||||
|
if($data == 0) $data = "None";
|
||||||
|
else if($data == 1) $data = "Fisheye";
|
||||||
|
else $data = "Unknown: ".$data;
|
||||||
|
}
|
||||||
|
} else if($type=="UNDEFINED") {
|
||||||
|
|
||||||
|
if($tag=="0001" && $model==1) { //Unknown (Version?)
|
||||||
|
$data=$data/100;
|
||||||
|
}
|
||||||
|
if($tag=="0088" && $model==1) { //AF Focus Position
|
||||||
|
$temp = "Center";
|
||||||
|
$data = bin2hex($data);
|
||||||
|
$data = str_replace("01","Top",$data);
|
||||||
|
$data = str_replace("02","Bottom",$data);
|
||||||
|
$data = str_replace("03","Left",$data);
|
||||||
|
$data = str_replace("04","Right",$data);
|
||||||
|
$data = str_replace("00","",$data);
|
||||||
|
if(strlen($data)==0) $data = $temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$data = bin2hex($data);
|
||||||
|
if($intel==1) $data = intel2Moto($data);
|
||||||
|
|
||||||
|
if($tag=="0083" && $model==1) { //Lens Type
|
||||||
|
$data = hexdec(substr($data,0,2));
|
||||||
|
if($data == 0) $data = "AF non D";
|
||||||
|
else if($data == 1) $data = "Manual";
|
||||||
|
else if($data == 2) $data = "AF-D or AF-S";
|
||||||
|
else if($data == 6) $data = "AF-D G";
|
||||||
|
else if($data == 10) $data = "AF-D VR";
|
||||||
|
else $data = "Unknown: ".$data;
|
||||||
|
}
|
||||||
|
if($tag=="0087" && $model==1) { //Flash type
|
||||||
|
$data = hexdec(substr($data,0,2));
|
||||||
|
if($data == 0) $data = "Did Not Fire";
|
||||||
|
else if($data == 4) $data = "Unknown";
|
||||||
|
else if($data == 7) $data = "External";
|
||||||
|
else if($data == 9) $data = "On Camera";
|
||||||
|
else $data = "Unknown: ".$data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//=================
|
||||||
|
// Nikon Special data section
|
||||||
|
//====================================================================
|
||||||
|
function parseNikon($block,&$result) {
|
||||||
|
|
||||||
|
if($result['Endien']=="Intel") $intel=1;
|
||||||
|
else $intel=0;
|
||||||
|
|
||||||
|
$model = $result['IFD0']['Model'];
|
||||||
|
|
||||||
|
//these 6 models start with "Nikon". Other models dont.
|
||||||
|
if($model=="E700\0" || $model=="E800\0" || $model=="E900\0" || $model=="E900S\0" || $model=="E910\0" || $model=="E950\0") {
|
||||||
|
$place=8; //current place
|
||||||
|
$model = 0;
|
||||||
|
|
||||||
|
//Get number of tags (2 bytes)
|
||||||
|
$num = bin2hex(substr($block,$place,2));$place+=2;
|
||||||
|
if($intel==1) $num = intel2Moto($num);
|
||||||
|
$result['SubIFD']['MakerNote']['MakerNoteNumTags'] = hexdec($num);
|
||||||
|
|
||||||
|
//loop thru all tags Each field is 12 bytes
|
||||||
|
for($i=0;$i<hexdec($num);$i++) {
|
||||||
|
//2 byte tag
|
||||||
|
$tag = bin2hex(substr($block,$place,2));$place+=2;
|
||||||
|
if($intel==1) $tag = intel2Moto($tag);
|
||||||
|
$tag_name = lookup_Nikon_tag($tag, $model);
|
||||||
|
|
||||||
|
//2 byte type
|
||||||
|
$type = bin2hex(substr($block,$place,2));$place+=2;
|
||||||
|
if($intel==1) $type = intel2Moto($type);
|
||||||
|
lookup_type($type,$size);
|
||||||
|
|
||||||
|
//4 byte count of number of data units
|
||||||
|
$count = bin2hex(substr($block,$place,4));$place+=4;
|
||||||
|
if($intel==1) $count = intel2Moto($count);
|
||||||
|
$bytesofdata = $size*hexdec($count);
|
||||||
|
|
||||||
|
//4 byte value of data or pointer to data
|
||||||
|
$value = substr($block,$place,4);$place+=4;
|
||||||
|
|
||||||
|
//if tag is 0002 then its the ASCII value which we know is at 140 so calc offset
|
||||||
|
//THIS HACK ONLY WORKS WITH EARLY NIKON MODELS
|
||||||
|
if($tag=="0002") $offset = hexdec($value)-140;
|
||||||
|
if($bytesofdata<=4) {
|
||||||
|
$data = $value;
|
||||||
|
} else {
|
||||||
|
$value = bin2hex($value);
|
||||||
|
if($intel==1) $value = intel2Moto($value);
|
||||||
|
$data = substr($block,hexdec($value)-$offset,$bytesofdata*2);
|
||||||
|
}
|
||||||
|
$formated_data = formatNikonData($type,$tag,$intel,$model,$data);
|
||||||
|
|
||||||
|
if($result['VerboseOutput']==1) {
|
||||||
|
$result['SubIFD']['MakerNote'][$tag_name] = $formated_data;
|
||||||
|
$result['SubIFD']['MakerNote'][$tag_name."_Verbose"]['RawData'] = $data;
|
||||||
|
$result['SubIFD']['MakerNote'][$tag_name."_Verbose"]['Type'] = $type;
|
||||||
|
$result['SubIFD']['MakerNote'][$tag_name."_Verbose"]['Bytes'] = $bytesofdata;
|
||||||
|
} else {
|
||||||
|
$result['SubIFD']['MakerNote'][$tag_name] = $formated_data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$place=0;//current place
|
||||||
|
$model = 1;
|
||||||
|
|
||||||
|
$nikon = substr($block,$place,8);$place+=8;
|
||||||
|
$endien = substr($block,$place,4);$place+=4;
|
||||||
|
|
||||||
|
//2 bytes of 0x002a
|
||||||
|
$tag = bin2hex(substr($block,$place,2));$place+=2;
|
||||||
|
|
||||||
|
//Then 4 bytes of offset to IFD0 (usually 8 which includes all 8 bytes of TIFF header)
|
||||||
|
$offset = bin2hex(substr($block,$place,4));$place+=4;
|
||||||
|
if($intel==1) $offset = intel2Moto($offset);
|
||||||
|
if(hexdec($offset)>8) $place+=$offset-8;
|
||||||
|
|
||||||
|
//Get number of tags (2 bytes)
|
||||||
|
$num = bin2hex(substr($block,$place,2));$place+=2;
|
||||||
|
if($intel==1) $num = intel2Moto($num);
|
||||||
|
|
||||||
|
//loop thru all tags Each field is 12 bytes
|
||||||
|
for($i=0;$i<hexdec($num);$i++) {
|
||||||
|
//2 byte tag
|
||||||
|
$tag = bin2hex(substr($block,$place,2));$place+=2;
|
||||||
|
if($intel==1) $tag = intel2Moto($tag);
|
||||||
|
$tag_name = lookup_Nikon_tag($tag, $model);
|
||||||
|
|
||||||
|
//2 byte type
|
||||||
|
$type = bin2hex(substr($block,$place,2));$place+=2;
|
||||||
|
if($intel==1) $type = intel2Moto($type);
|
||||||
|
lookup_type($type,$size);
|
||||||
|
|
||||||
|
//4 byte count of number of data units
|
||||||
|
$count = bin2hex(substr($block,$place,4));$place+=4;
|
||||||
|
if($intel==1) $count = intel2Moto($count);
|
||||||
|
$bytesofdata = $size*hexdec($count);
|
||||||
|
|
||||||
|
//4 byte value of data or pointer to data
|
||||||
|
$value = substr($block,$place,4);$place+=4;
|
||||||
|
|
||||||
|
if($bytesofdata<=4) {
|
||||||
|
$data = $value;
|
||||||
|
} else {
|
||||||
|
$value = bin2hex($value);
|
||||||
|
if($intel==1) $value = intel2Moto($value);
|
||||||
|
$data = substr($block,hexdec($value)+hexdec($offset)+2,$bytesofdata);
|
||||||
|
}
|
||||||
|
$formated_data = formatNikonData($type,$tag,$intel,$model,$data);
|
||||||
|
|
||||||
|
if($result['VerboseOutput']==1) {
|
||||||
|
$result['SubIFD']['MakerNote'][$tag_name] = $formated_data;
|
||||||
|
if($type=="URATIONAL" || $type=="SRATIONAL" || $type=="USHORT" || $type=="SSHORT" || $type=="ULONG" || $type=="SLONG" || $type=="FLOAT" || $type=="DOUBLE") {
|
||||||
|
$data = bin2hex($data);
|
||||||
|
if($intel==1) $data = intel2Moto($data);
|
||||||
|
}
|
||||||
|
$result['SubIFD']['MakerNote'][$tag_name."_Verbose"]['RawData'] = $data;
|
||||||
|
$result['SubIFD']['MakerNote'][$tag_name."_Verbose"]['Type'] = $type;
|
||||||
|
$result['SubIFD']['MakerNote'][$tag_name."_Verbose"]['Bytes'] = $bytesofdata;
|
||||||
|
} else {
|
||||||
|
$result['SubIFD']['MakerNote'][$tag_name] = $formated_data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
208
upload/includes/makers/olympus.php
Normal file
208
upload/includes/makers/olympus.php
Normal file
|
@ -0,0 +1,208 @@
|
||||||
|
<?php
|
||||||
|
/*************************
|
||||||
|
Coppermine Photo Gallery
|
||||||
|
************************
|
||||||
|
Copyright (c) 2003-2012 Coppermine Dev Team
|
||||||
|
v1.0 originally written by Gregory Demar
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License version 3
|
||||||
|
as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
********************************************
|
||||||
|
Coppermine version: 1.5.18
|
||||||
|
$HeadURL: https://coppermine.svn.sourceforge.net/svnroot/coppermine/trunk/cpg1.5.x/include/makers/olympus.php $
|
||||||
|
$Revision: 8304 $
|
||||||
|
**********************************************/
|
||||||
|
/*
|
||||||
|
Exifer
|
||||||
|
Extracts EXIF information from digital photos.
|
||||||
|
|
||||||
|
Copyright © 2003 Jake Olefsky
|
||||||
|
http://www.offsky.com/software/exif/index.php
|
||||||
|
jake@olefsky.com
|
||||||
|
|
||||||
|
Please see exif.php for the complete information about this software.
|
||||||
|
|
||||||
|
------------
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify it under the terms of
|
||||||
|
the GNU General Public License as published by the Free Software Foundation; either version 2
|
||||||
|
of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
See the GNU General Public License for more details. http://www.gnu.org/copyleft/gpl.html
|
||||||
|
*/
|
||||||
|
//================================================================================================
|
||||||
|
//================================================================================================
|
||||||
|
//================================================================================================
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//=================
|
||||||
|
// Looks up the name of the tag for the MakerNote (Depends on Manufacturer)
|
||||||
|
//====================================================================
|
||||||
|
function lookup_Olympus_tag($tag) {
|
||||||
|
switch($tag) {
|
||||||
|
case "0200": $tag = "SpecialMode";break;
|
||||||
|
case "0201": $tag = "JpegQual";break;
|
||||||
|
case "0202": $tag = "Macro";break;
|
||||||
|
case "0203": $tag = "Unknown1";break;
|
||||||
|
case "0204": $tag = "DigiZoom";break;
|
||||||
|
case "0205": $tag = "Unknown2";break;
|
||||||
|
case "0206": $tag = "Unknown3";break;
|
||||||
|
case "0207": $tag = "SoftwareRelease";break;
|
||||||
|
case "0208": $tag = "PictInfo";break;
|
||||||
|
case "0209": $tag = "CameraID";break;
|
||||||
|
case "0f00": $tag = "DataDump";break;
|
||||||
|
|
||||||
|
default: $tag = "unknown:".$tag;break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $tag;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=================
|
||||||
|
// Formats Data for the data type
|
||||||
|
//====================================================================
|
||||||
|
function formatOlympusData($type,$tag,$intel,$data) {
|
||||||
|
if($type=="ASCII") {
|
||||||
|
|
||||||
|
} else if($type=="URATIONAL" || $type=="SRATIONAL") {
|
||||||
|
$data = bin2hex($data);
|
||||||
|
if($intel==1) $data = intel2Moto($data);
|
||||||
|
$top = hexdec(substr($data,8,8));
|
||||||
|
$bottom = hexdec(substr($data,0,8));
|
||||||
|
if($bottom!=0) $data=$top/$bottom;
|
||||||
|
else if($top==0) $data = 0;
|
||||||
|
else $data=$top."/".$bottom;
|
||||||
|
|
||||||
|
if($tag=="0204") { //DigitalZoom
|
||||||
|
$data=$data."x";
|
||||||
|
}
|
||||||
|
if($tag=="0205") { //Unknown2
|
||||||
|
$data=$top."/".$bottom;
|
||||||
|
}
|
||||||
|
} else if($type=="USHORT" || $type=="SSHORT" || $type=="ULONG" || $type=="SLONG" || $type=="FLOAT" || $type=="DOUBLE") {
|
||||||
|
$data = bin2hex($data);
|
||||||
|
if($intel==1) $data = intel2Moto($data);
|
||||||
|
$data=hexdec($data);
|
||||||
|
|
||||||
|
if($tag=="0201") { //JPEGQuality
|
||||||
|
if($data == 1) $data = "SQ";
|
||||||
|
else if($data == 2) $data = "HQ";
|
||||||
|
else if($data == 3) $data = "SHQ";
|
||||||
|
else $data = "Unknown: ".$data;
|
||||||
|
}
|
||||||
|
if($tag=="0202") { //Macro
|
||||||
|
if($data == 0) $data = "Normal";
|
||||||
|
else if($data == 1) $data = "Macro";
|
||||||
|
else $data = "Unknown: ".$data;
|
||||||
|
}
|
||||||
|
} else if($type=="UNDEFINED") {
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$data = bin2hex($data);
|
||||||
|
if($intel==1) $data = intel2Moto($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//==============================================================================
|
||||||
|
// Olympus Special data section
|
||||||
|
// - Updated by Zenphoto for new header tag in E-410/E-510/E-3 cameras. 2/24/2008
|
||||||
|
//==============================================================================
|
||||||
|
function parseOlympus($block, &$result, $seek, $globalOffset) {
|
||||||
|
|
||||||
|
if($result['Endien']=="Intel") $intel = 1;
|
||||||
|
else $intel = 0;
|
||||||
|
|
||||||
|
$model = $result['IFD0']['Model'];
|
||||||
|
|
||||||
|
// New header for new DSLRs - Check for it because the
|
||||||
|
// number of bytes that count the IFD fields differ in each case.
|
||||||
|
// Fixed by Zenphoto 2/24/08
|
||||||
|
$new = false;
|
||||||
|
if (substr($block, 0, 8) == "OLYMPUS\x00") {
|
||||||
|
$new = true;
|
||||||
|
} else if (substr($block, 0, 7) == "OLYMP\x00\x01"
|
||||||
|
|| substr($block, 0, 7) == "OLYMP\x00\x02") {
|
||||||
|
$new = false;
|
||||||
|
} else {
|
||||||
|
// Header does not match known Olympus headers.
|
||||||
|
// This is not a valid OLYMPUS Makernote.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Offset of IFD entry after Olympus header.
|
||||||
|
$place = 8;
|
||||||
|
$offset = 8;
|
||||||
|
|
||||||
|
// Get number of tags (1 or 2 bytes, depending on New or Old makernote)
|
||||||
|
$countfieldbits = $new ? 1 : 2;
|
||||||
|
// New makernote repeats 1-byte value twice, so increment $place by 2 in either case.
|
||||||
|
$num = bin2hex(substr($block, $place, $countfieldbits)); $place += 2;
|
||||||
|
if ($intel == 1) $num = intel2Moto($num);
|
||||||
|
$ntags = hexdec($num);
|
||||||
|
$result['SubIFD']['MakerNote']['MakerNoteNumTags'] = $ntags;
|
||||||
|
|
||||||
|
//loop thru all tags Each field is 12 bytes
|
||||||
|
for($i=0; $i < $ntags; $i++) {
|
||||||
|
//2 byte tag
|
||||||
|
$tag = bin2hex(substr($block, $place,2));
|
||||||
|
$place += 2;
|
||||||
|
if ($intel == 1) $tag = intel2Moto($tag);
|
||||||
|
$tag_name = lookup_Olympus_tag($tag);
|
||||||
|
|
||||||
|
//2 byte type
|
||||||
|
$type = bin2hex(substr($block, $place,2));
|
||||||
|
$place += 2;
|
||||||
|
if ($intel == 1) $type = intel2Moto($type);
|
||||||
|
lookup_type($type,$size);
|
||||||
|
|
||||||
|
//4 byte count of number of data units
|
||||||
|
$count = bin2hex(substr($block, $place,4));
|
||||||
|
$place+=4;
|
||||||
|
if ($intel == 1) $count = intel2Moto($count);
|
||||||
|
$bytesofdata = $size * hexdec($count);
|
||||||
|
|
||||||
|
//4 byte value of data or pointer to data
|
||||||
|
$value = substr($block, $place,4);
|
||||||
|
$place += 4;
|
||||||
|
|
||||||
|
|
||||||
|
if ($bytesofdata <= 4) {
|
||||||
|
$data = $value;
|
||||||
|
} else {
|
||||||
|
$value = bin2hex($value);
|
||||||
|
if($intel==1) $value = intel2Moto($value);
|
||||||
|
$v = fseek($seek,$globalOffset+hexdec($value)); //offsets are from TIFF header which is 12 bytes from the start of the file
|
||||||
|
if($v == 0 && $bytesofdata < $GLOBALS['exiferFileSize']) {
|
||||||
|
$data = fread($seek, $bytesofdata);
|
||||||
|
} else {
|
||||||
|
$result['Errors'] = $result['Errors']++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$formated_data = formatOlympusData($type,$tag,$intel,$data);
|
||||||
|
|
||||||
|
if($result['VerboseOutput']==1) {
|
||||||
|
$result['SubIFD']['MakerNote'][$tag_name] = $formated_data;
|
||||||
|
if($type=="URATIONAL" || $type=="SRATIONAL" || $type=="USHORT" || $type=="SSHORT" || $type=="ULONG" || $type=="SLONG" || $type=="FLOAT" || $type=="DOUBLE") {
|
||||||
|
$data = bin2hex($data);
|
||||||
|
if($intel==1) $data = intel2Moto($data);
|
||||||
|
}
|
||||||
|
$result['SubIFD']['MakerNote'][$tag_name."_Verbose"]['RawData'] = $data;
|
||||||
|
$result['SubIFD']['MakerNote'][$tag_name."_Verbose"]['Type'] = $type;
|
||||||
|
$result['SubIFD']['MakerNote'][$tag_name."_Verbose"]['Bytes'] = $bytesofdata;
|
||||||
|
} else {
|
||||||
|
$result['SubIFD']['MakerNote'][$tag_name] = $formated_data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
307
upload/includes/makers/panasonic.php
Normal file
307
upload/includes/makers/panasonic.php
Normal file
|
@ -0,0 +1,307 @@
|
||||||
|
<?php
|
||||||
|
/*************************
|
||||||
|
Coppermine Photo Gallery
|
||||||
|
************************
|
||||||
|
Copyright (c) 2003-2012 Coppermine Dev Team
|
||||||
|
v1.0 originally written by Gregory Demar
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License version 3
|
||||||
|
as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
********************************************
|
||||||
|
Coppermine version: 1.5.18
|
||||||
|
$HeadURL: https://coppermine.svn.sourceforge.net/svnroot/coppermine/trunk/cpg1.5.x/include/makers/panasonic.php $
|
||||||
|
$Revision: 8304 $
|
||||||
|
**********************************************/
|
||||||
|
/*
|
||||||
|
Exifer
|
||||||
|
Extracts EXIF information from digital photos.
|
||||||
|
|
||||||
|
Copyright © 2003 Jake Olefsky
|
||||||
|
http://www.offsky.com/software/exif/index.php
|
||||||
|
jake@olefsky.com
|
||||||
|
|
||||||
|
Please see exif.php for the complete information about this software.
|
||||||
|
|
||||||
|
------------
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify it under the terms of
|
||||||
|
the GNU General Public License as published by the Free Software Foundation; either version 2
|
||||||
|
of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
See the GNU General Public License for more details. http://www.gnu.org/copyleft/gpl.html
|
||||||
|
*/
|
||||||
|
//================================================================================================
|
||||||
|
//================================================================================================
|
||||||
|
//================================================================================================
|
||||||
|
|
||||||
|
|
||||||
|
//=================
|
||||||
|
// Looks up the name of the tag for the MakerNote (Depends on Manufacturer)
|
||||||
|
//====================================================================
|
||||||
|
function lookup_Panasonic_tag($tag) {
|
||||||
|
|
||||||
|
switch($tag) {
|
||||||
|
case "0001": $tag = "Quality";break;
|
||||||
|
case "0002": $tag = "FirmwareVersion";break;
|
||||||
|
case "0003": $tag = "WhiteBalance";break;
|
||||||
|
case "0007": $tag = "FocusMode";break;
|
||||||
|
case "000f": $tag = "AFMode";break;
|
||||||
|
case "001a": $tag = "ImageStabilizer";break;
|
||||||
|
case "001c": $tag = "MacroMode";break;
|
||||||
|
case "001f": $tag = "ShootingMode";break;
|
||||||
|
case "0020": $tag = "Audio";break;
|
||||||
|
case "0021": $tag = "DataDump";break;
|
||||||
|
case "0023": $tag = "WhiteBalanceBias";break;
|
||||||
|
case "0024": $tag = "FlashBias";break;
|
||||||
|
case "0025": $tag = "SerialNumber";break;
|
||||||
|
case "0028": $tag = "ColourEffect";break;
|
||||||
|
case "002a": $tag = "BurstMode";break;
|
||||||
|
case "002b": $tag = "SequenceNumber";break;
|
||||||
|
case "002c": $tag = "Contrast";break;
|
||||||
|
case "002d": $tag = "NoiseReduction";break;
|
||||||
|
case "002e": $tag = "SelfTimer";break;
|
||||||
|
case "0030": $tag = "Rotation";break;
|
||||||
|
case "0032": $tag = "ColorMode";break;
|
||||||
|
case "0036": $tag = "TravelDay";break;
|
||||||
|
|
||||||
|
default: $tag = "unknown:".$tag;break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $tag;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=================
|
||||||
|
// Formats Data for the data type
|
||||||
|
//====================================================================
|
||||||
|
function formatPanasonicData($type,$tag,$intel,$data) {
|
||||||
|
|
||||||
|
if($type=="ASCII") {
|
||||||
|
|
||||||
|
} else if($type=="UBYTE" || $type=="SBYTE") {
|
||||||
|
$data = bin2hex($data);
|
||||||
|
if($intel==1) $data = intel2Moto($data);
|
||||||
|
$data=hexdec($data);
|
||||||
|
|
||||||
|
if($tag=="000f") { //AFMode
|
||||||
|
if($data == 256) $data = "9-area-focusing";
|
||||||
|
else if($data == 16) $data = "1-area-focusing";
|
||||||
|
else $data = "Unknown (".$data.")";
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if($type=="URATIONAL" || $type=="SRATIONAL") {
|
||||||
|
$data = bin2hex($data);
|
||||||
|
if($intel==1) $data = intel2Moto($data);
|
||||||
|
$top = hexdec(substr($data,8,8));
|
||||||
|
$bottom = hexdec(substr($data,0,8));
|
||||||
|
if($bottom!=0) $data=$top/$bottom;
|
||||||
|
else if($top==0) $data = 0;
|
||||||
|
else $data=$top."/".$bottom;
|
||||||
|
|
||||||
|
} else if($type=="USHORT" || $type=="SSHORT" || $type=="ULONG" || $type=="SLONG" || $type=="FLOAT" || $type=="DOUBLE") {
|
||||||
|
$data = bin2hex($data);
|
||||||
|
if($intel==1) $data = intel2Moto($data);
|
||||||
|
$data=hexdec($data);
|
||||||
|
|
||||||
|
if($tag=="0001") { //Image Quality
|
||||||
|
if($data == 2) $data = "High";
|
||||||
|
else if($data == 3) $data = "Standard";
|
||||||
|
else if($data == 6) $data = "Very High";
|
||||||
|
else if($data == 7) $data = "RAW";
|
||||||
|
else $data = "Unknown (".$data.")";
|
||||||
|
}
|
||||||
|
if($tag=="0003") { //White Balance
|
||||||
|
if($data == 1) $data = "Auto";
|
||||||
|
else if($data == 2) $data = "Daylight";
|
||||||
|
else if($data == 3) $data = "Cloudy";
|
||||||
|
else if($data == 4) $data = "Halogen";
|
||||||
|
else if($data == 5) $data = "Manual";
|
||||||
|
else if($data == 8) $data = "Flash";
|
||||||
|
else if($data == 10) $data = "Black and White";
|
||||||
|
else if($data == 11) $data = "Manual";
|
||||||
|
else $data = "Unknown (".$data.")";
|
||||||
|
}
|
||||||
|
if($tag=="0007") { //Focus Mode
|
||||||
|
if($data == 1) $data = "Auto";
|
||||||
|
else if($data == 2) $data = "Manual";
|
||||||
|
else if($data == 4) $data = "Auto, Focus button";
|
||||||
|
else if($data == 5) $data = "Auto, Continuous";
|
||||||
|
else $data = "Unknown (".$data.")";
|
||||||
|
}
|
||||||
|
if($tag=="001a") { //Image Stabilizer
|
||||||
|
if($data == 2) $data = "Mode 1";
|
||||||
|
else if($data == 3) $data = "Off";
|
||||||
|
else if($data == 4) $data = "Mode 2";
|
||||||
|
else $data = "Unknown (".$data.")";
|
||||||
|
}
|
||||||
|
if($tag=="001c") { //Macro mode
|
||||||
|
if($data == 1) $data = "On";
|
||||||
|
else if($data == 2) $data = "Off";
|
||||||
|
else $data = "Unknown (".$data.")";
|
||||||
|
}
|
||||||
|
if($tag=="001f") { //Shooting Mode
|
||||||
|
if($data == 1) $data = "Normal";
|
||||||
|
else if($data == 2) $data = "Portrait";
|
||||||
|
else if($data == 3) $data = "Scenery";
|
||||||
|
else if($data == 4) $data = "Sports";
|
||||||
|
else if($data == 5) $data = "Night Portrait";
|
||||||
|
else if($data == 6) $data = "Program";
|
||||||
|
else if($data == 7) $data = "Aperture Priority";
|
||||||
|
else if($data == 8) $data = "Shutter Priority";
|
||||||
|
else if($data == 9) $data = "Macro";
|
||||||
|
else if($data == 11) $data = "Manual";
|
||||||
|
else if($data == 13) $data = "Panning";
|
||||||
|
else if($data == 18) $data = "Fireworks";
|
||||||
|
else if($data == 19) $data = "Party";
|
||||||
|
else if($data == 20) $data = "Snow";
|
||||||
|
else if($data == 21) $data = "Night Scenery";
|
||||||
|
else if($data == 22) $data = "Food";
|
||||||
|
else if($data == 23) $data = "Baby";
|
||||||
|
else if($data == 27) $data = "High Sensitivity";
|
||||||
|
else if($data == 29) $data = "Underwater";
|
||||||
|
else if($data == 33) $data = "Pet";
|
||||||
|
else $data = "Unknown (".$data.")";
|
||||||
|
}
|
||||||
|
if($tag=="0020") { //Audio
|
||||||
|
if($data == 1) $data = "Yes";
|
||||||
|
else if($data == 2) $data = "No";
|
||||||
|
else $data = "Unknown (".$data.")";
|
||||||
|
}
|
||||||
|
if($tag=="0023") { //White Balance Bias
|
||||||
|
$data=$data." EV";
|
||||||
|
}
|
||||||
|
if($tag=="0024") { //Flash Bias
|
||||||
|
$data = $data;
|
||||||
|
}
|
||||||
|
if($tag=="0028") { //Colour Effect
|
||||||
|
if($data == 1) $data = "Off";
|
||||||
|
else if($data == 2) $data = "Warm";
|
||||||
|
else if($data == 3) $data = "Cool";
|
||||||
|
else if($data == 4) $data = "Black and White";
|
||||||
|
else if($data == 5) $data = "Sepia";
|
||||||
|
else $data = "Unknown (".$data.")";
|
||||||
|
}
|
||||||
|
if($tag=="002a") { //Burst Mode
|
||||||
|
if($data == 0) $data = "Off";
|
||||||
|
else if($data == 1) $data = "Low/High Quality";
|
||||||
|
else if($data == 2) $data = "Infinite";
|
||||||
|
else $data = "Unknown (".$data.")";
|
||||||
|
}
|
||||||
|
if($tag=="002c") { //Contrast
|
||||||
|
if($data == 0) $data = "Standard";
|
||||||
|
else if($data == 1) $data = "Low";
|
||||||
|
else if($data == 2) $data = "High";
|
||||||
|
else $data = "Unknown (".$data.")";
|
||||||
|
}
|
||||||
|
if($tag=="002d") { //Noise Reduction
|
||||||
|
if($data == 0) $data = "Standard";
|
||||||
|
else if($data == 1) $data = "Low";
|
||||||
|
else if($data == 2) $data = "High";
|
||||||
|
else $data = "Unknown (".$data.")";
|
||||||
|
}
|
||||||
|
if($tag=="002e") { //Self Timer
|
||||||
|
if($data == 1) $data = "Off";
|
||||||
|
else if($data == 2) $data = "10s";
|
||||||
|
else if($data == 3) $data = "2s";
|
||||||
|
else $data = "Unknown (".$data.")";
|
||||||
|
}
|
||||||
|
if($tag=="0030") { //Rotation
|
||||||
|
if($data == 1) $data = "Horizontal (normal)";
|
||||||
|
else if($data == 6) $data = "Rotate 90 CW";
|
||||||
|
else if($data == 8) $data = "Rotate 270 CW";
|
||||||
|
else $data = "Unknown (".$data.")";
|
||||||
|
}
|
||||||
|
if($tag=="0032") { //Color Mode
|
||||||
|
if($data == 0) $data = "Normal";
|
||||||
|
else if($data == 1) $data = "Natural";
|
||||||
|
else $data = "Unknown (".$data.")";
|
||||||
|
}
|
||||||
|
if($tag=="0036") { //Travel Day
|
||||||
|
$data=$data;
|
||||||
|
}
|
||||||
|
} else if($type=="UNDEFINED") {
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$data = bin2hex($data);
|
||||||
|
if($intel==1) $data = intel2Moto($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//=================
|
||||||
|
// Panasonic Special data section
|
||||||
|
//====================================================================
|
||||||
|
function parsePanasonic($block,&$result) {
|
||||||
|
|
||||||
|
//if($result['Endien']=="Intel") $intel=1;
|
||||||
|
//else $intel=0;
|
||||||
|
$intel=1;
|
||||||
|
|
||||||
|
$model = $result['IFD0']['Model'];
|
||||||
|
|
||||||
|
$place=8; //current place
|
||||||
|
$offset=8;
|
||||||
|
|
||||||
|
|
||||||
|
$num = bin2hex(substr($block,$place,4));$place+=4;
|
||||||
|
if($intel==1) $num = intel2Moto($num);
|
||||||
|
$result['SubIFD']['MakerNote']['Offset'] = hexdec($num);
|
||||||
|
|
||||||
|
//Get number of tags (2 bytes)
|
||||||
|
$num = bin2hex(substr($block,$place,2));$place+=2;
|
||||||
|
if($intel==1) $num = intel2Moto($num);
|
||||||
|
$result['SubIFD']['MakerNote']['MakerNoteNumTags'] = hexdec($num);
|
||||||
|
|
||||||
|
//loop thru all tags Each field is 12 bytes
|
||||||
|
for($i=0;$i<hexdec($num);$i++) {
|
||||||
|
|
||||||
|
//2 byte tag
|
||||||
|
$tag = bin2hex(substr($block,$place,2));$place+=2;
|
||||||
|
if($intel==1) $tag = intel2Moto($tag);
|
||||||
|
$tag_name = lookup_Panasonic_tag($tag);
|
||||||
|
|
||||||
|
//2 byte type
|
||||||
|
$type = bin2hex(substr($block,$place,2));$place+=2;
|
||||||
|
if($intel==1) $type = intel2Moto($type);
|
||||||
|
lookup_type($type,$size);
|
||||||
|
|
||||||
|
//4 byte count of number of data units
|
||||||
|
$count = bin2hex(substr($block,$place,4));$place+=4;
|
||||||
|
if($intel==1) $count = intel2Moto($count);
|
||||||
|
$bytesofdata = $size*hexdec($count);
|
||||||
|
|
||||||
|
//4 byte value of data or pointer to data
|
||||||
|
$value = substr($block,$place,4);$place+=4;
|
||||||
|
|
||||||
|
|
||||||
|
if($bytesofdata<=4) {
|
||||||
|
$data = $value;
|
||||||
|
} else {
|
||||||
|
$value = bin2hex($value);
|
||||||
|
if($intel==1) $value = intel2Moto($value);
|
||||||
|
$data = substr($block,hexdec($value)-$offset,$bytesofdata*2);
|
||||||
|
}
|
||||||
|
$formated_data = formatPanasonicData($type,$tag,$intel,$data);
|
||||||
|
|
||||||
|
if($result['VerboseOutput']==1) {
|
||||||
|
$result['SubIFD']['MakerNote'][$tag_name] = $formated_data;
|
||||||
|
if($type=="URATIONAL" || $type=="SRATIONAL" || $type=="USHORT" || $type=="SSHORT" || $type=="ULONG" || $type=="SLONG" || $type=="FLOAT" || $type=="DOUBLE") {
|
||||||
|
$data = bin2hex($data);
|
||||||
|
if($intel==1) $data = intel2Moto($data);
|
||||||
|
}
|
||||||
|
$result['SubIFD']['MakerNote'][$tag_name."_Verbose"]['RawData'] = $data;
|
||||||
|
$result['SubIFD']['MakerNote'][$tag_name."_Verbose"]['Type'] = $type;
|
||||||
|
$result['SubIFD']['MakerNote'][$tag_name."_Verbose"]['Bytes'] = $bytesofdata;
|
||||||
|
} else {
|
||||||
|
$result['SubIFD']['MakerNote'][$tag_name] = $formated_data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
180
upload/includes/makers/sanyo.php
Normal file
180
upload/includes/makers/sanyo.php
Normal file
|
@ -0,0 +1,180 @@
|
||||||
|
<?php
|
||||||
|
/*************************
|
||||||
|
Coppermine Photo Gallery
|
||||||
|
************************
|
||||||
|
Copyright (c) 2003-2012 Coppermine Dev Team
|
||||||
|
v1.0 originally written by Gregory Demar
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License version 3
|
||||||
|
as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
********************************************
|
||||||
|
Coppermine version: 1.5.18
|
||||||
|
$HeadURL: https://coppermine.svn.sourceforge.net/svnroot/coppermine/trunk/cpg1.5.x/include/makers/sanyo.php $
|
||||||
|
$Revision: 8304 $
|
||||||
|
**********************************************/
|
||||||
|
/*
|
||||||
|
Exifer
|
||||||
|
Extracts EXIF information from digital photos.
|
||||||
|
|
||||||
|
Copyright © 2003 Jake Olefsky
|
||||||
|
http://www.offsky.com/software/exif/index.php
|
||||||
|
jake@olefsky.com
|
||||||
|
|
||||||
|
Please see exif.php for the complete information about this software.
|
||||||
|
|
||||||
|
------------
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify it under the terms of
|
||||||
|
the GNU General Public License as published by the Free Software Foundation; either version 2
|
||||||
|
of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
See the GNU General Public License for more details. http://www.gnu.org/copyleft/gpl.html
|
||||||
|
*/
|
||||||
|
//================================================================================================
|
||||||
|
//================================================================================================
|
||||||
|
//================================================================================================
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//=================
|
||||||
|
// Looks up the name of the tag for the MakerNote (Depends on Manufacturer)
|
||||||
|
//====================================================================
|
||||||
|
function lookup_Sanyo_tag($tag) {
|
||||||
|
|
||||||
|
switch($tag) {
|
||||||
|
case "0200": $tag = "SpecialMode";break;
|
||||||
|
case "0201": $tag = "Quality";break;
|
||||||
|
case "0202": $tag = "Macro";break;
|
||||||
|
case "0203": $tag = "Unknown";break;
|
||||||
|
case "0204": $tag = "DigiZoom";break;
|
||||||
|
case "0f00": $tag = "DataDump";break;
|
||||||
|
default: $tag = "unknown:".$tag;break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $tag;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=================
|
||||||
|
// Formats Data for the data type
|
||||||
|
//====================================================================
|
||||||
|
function formatSanyoData($type,$tag,$intel,$data) {
|
||||||
|
|
||||||
|
if($type=="ASCII") {
|
||||||
|
|
||||||
|
|
||||||
|
} else if($type=="URATIONAL" || $type=="SRATIONAL") {
|
||||||
|
$data = bin2hex($data);
|
||||||
|
if($intel==1) $data = intel2Moto($data);
|
||||||
|
$top = hexdec(substr($data,8,8));
|
||||||
|
$bottom = hexdec(substr($data,0,8));
|
||||||
|
if($bottom!=0) $data=$top/$bottom;
|
||||||
|
else if($top==0) $data = 0;
|
||||||
|
else $data=$top."/".$bottom;
|
||||||
|
|
||||||
|
|
||||||
|
} else if($type=="USHORT" || $type=="SSHORT" || $type=="ULONG" || $type=="SLONG" || $type=="FLOAT" || $type=="DOUBLE") {
|
||||||
|
$data = bin2hex($data);
|
||||||
|
if($intel==1) $data = intel2Moto($data);
|
||||||
|
$data=hexdec($data);
|
||||||
|
|
||||||
|
if($tag=="0200") { //SpecialMode
|
||||||
|
if($data == 0) $data = "Normal";
|
||||||
|
else $data = "Unknown: ".$data;
|
||||||
|
}
|
||||||
|
if($tag=="0201") { //Quality
|
||||||
|
if($data == 2) $data = "High";
|
||||||
|
else $data = "Unknown: ".$data;
|
||||||
|
}
|
||||||
|
if($tag=="0202") { //Macro
|
||||||
|
if($data == 0) $data = "Normal";
|
||||||
|
else $data = "Unknown: ".$data;
|
||||||
|
}
|
||||||
|
} else if($type=="UNDEFINED") {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$data = bin2hex($data);
|
||||||
|
if($intel==1) $data = intel2Moto($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//=================
|
||||||
|
// Sanyo Special data section
|
||||||
|
//====================================================================
|
||||||
|
function parseSanyo($block,&$result,$seek, $globalOffset) {
|
||||||
|
|
||||||
|
if($result['Endien']=="Intel") $intel=1;
|
||||||
|
else $intel=0;
|
||||||
|
|
||||||
|
$model = $result['IFD0']['Model'];
|
||||||
|
|
||||||
|
$place=8; //current place
|
||||||
|
$offset=8;
|
||||||
|
|
||||||
|
//Get number of tags (2 bytes)
|
||||||
|
$num = bin2hex(substr($block,$place,2));$place+=2;
|
||||||
|
if($intel==1) $num = intel2Moto($num);
|
||||||
|
$result['SubIFD']['MakerNote']['MakerNoteNumTags'] = hexdec($num);
|
||||||
|
|
||||||
|
//loop thru all tags Each field is 12 bytes
|
||||||
|
for($i=0;$i<hexdec($num);$i++) {
|
||||||
|
|
||||||
|
//2 byte tag
|
||||||
|
$tag = bin2hex(substr($block,$place,2));$place+=2;
|
||||||
|
if($intel==1) $tag = intel2Moto($tag);
|
||||||
|
$tag_name = lookup_Sanyo_tag($tag);
|
||||||
|
|
||||||
|
//2 byte type
|
||||||
|
$type = bin2hex(substr($block,$place,2));$place+=2;
|
||||||
|
if($intel==1) $type = intel2Moto($type);
|
||||||
|
lookup_type($type,$size);
|
||||||
|
|
||||||
|
//4 byte count of number of data units
|
||||||
|
$count = bin2hex(substr($block,$place,4));$place+=4;
|
||||||
|
if($intel==1) $count = intel2Moto($count);
|
||||||
|
$bytesofdata = $size*hexdec($count);
|
||||||
|
|
||||||
|
//4 byte value of data or pointer to data
|
||||||
|
$value = substr($block,$place,4);$place+=4;
|
||||||
|
|
||||||
|
|
||||||
|
if($bytesofdata<=4) {
|
||||||
|
$data = $value;
|
||||||
|
} else {
|
||||||
|
$value = bin2hex($value);
|
||||||
|
if($intel==1) $value = intel2Moto($value);
|
||||||
|
$v = fseek($seek,$globalOffset+hexdec($value)); //offsets are from TIFF header which is 12 bytes from the start of the file
|
||||||
|
if($v==0) {
|
||||||
|
$data = fread($seek, $bytesofdata);
|
||||||
|
} else if($v==-1) {
|
||||||
|
$result['Errors'] = $result['Errors']++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$formated_data = formatSanyoData($type,$tag,$intel,$data);
|
||||||
|
|
||||||
|
if($result['VerboseOutput']==1) {
|
||||||
|
$result['SubIFD']['MakerNote'][$tag_name] = $formated_data;
|
||||||
|
if($type=="URATIONAL" || $type=="SRATIONAL" || $type=="USHORT" || $type=="SSHORT" || $type=="ULONG" || $type=="SLONG" || $type=="FLOAT" || $type=="DOUBLE") {
|
||||||
|
$data = bin2hex($data);
|
||||||
|
if($intel==1) $data = intel2Moto($data);
|
||||||
|
}
|
||||||
|
$result['SubIFD']['MakerNote'][$tag_name."_Verbose"]['RawData'] = $data;
|
||||||
|
$result['SubIFD']['MakerNote'][$tag_name."_Verbose"]['Type'] = $type;
|
||||||
|
$result['SubIFD']['MakerNote'][$tag_name."_Verbose"]['Bytes'] = $bytesofdata;
|
||||||
|
} else {
|
||||||
|
$result['SubIFD']['MakerNote'][$tag_name] = $formated_data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
28
upload/js/jquery_plugs/css/jquery.Jcrop.css
Normal file
28
upload/js/jquery_plugs/css/jquery.Jcrop.css
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
/* jquery.Jcrop.min.css v0.9.10 (build:20120429) */
|
||||||
|
.jcrop-holder{direction:ltr;text-align:left;}
|
||||||
|
.jcrop-vline,.jcrop-hline{background:#FFF url(Jcrop.gif) top left repeat;font-size:0;position:absolute;}
|
||||||
|
.jcrop-vline{height:100%;width:1px!important;}
|
||||||
|
.jcrop-hline{height:1px!important;width:100%;}
|
||||||
|
.jcrop-vline.right{right:0;}
|
||||||
|
.jcrop-hline.bottom{bottom:0;}
|
||||||
|
.jcrop-handle{background-color:#333;border:1px #eee solid;font-size:1px;}
|
||||||
|
.jcrop-tracker{-webkit-tap-highlight-color:transparent;-webkit-touch-callout:none;-webkit-user-select:none;height:100%;width:100%;}
|
||||||
|
.jcrop-handle.ord-n{left:50%;margin-left:-4px;margin-top:-4px;top:0;}
|
||||||
|
.jcrop-handle.ord-s{bottom:0;left:50%;margin-bottom:-4px;margin-left:-4px;}
|
||||||
|
.jcrop-handle.ord-e{margin-right:-4px;margin-top:-4px;right:0;top:50%;}
|
||||||
|
.jcrop-handle.ord-w{left:0;margin-left:-4px;margin-top:-4px;top:50%;}
|
||||||
|
.jcrop-handle.ord-nw{left:0;margin-left:-4px;margin-top:-4px;top:0;}
|
||||||
|
.jcrop-handle.ord-ne{margin-right:-4px;margin-top:-4px;right:0;top:0;}
|
||||||
|
.jcrop-handle.ord-se{bottom:0;margin-bottom:-4px;margin-right:-4px;right:0;}
|
||||||
|
.jcrop-handle.ord-sw{bottom:0;left:0;margin-bottom:-4px;margin-left:-4px;}
|
||||||
|
.jcrop-dragbar.ord-n,.jcrop-dragbar.ord-s{height:7px;width:100%;}
|
||||||
|
.jcrop-dragbar.ord-e,.jcrop-dragbar.ord-w{height:100%;width:7px;}
|
||||||
|
.jcrop-dragbar.ord-n{margin-top:-4px;}
|
||||||
|
.jcrop-dragbar.ord-s{bottom:0;margin-bottom:-4px;}
|
||||||
|
.jcrop-dragbar.ord-e{margin-right:-4px;right:0;}
|
||||||
|
.jcrop-dragbar.ord-w{margin-left:-4px;}
|
||||||
|
.jcrop-light .jcrop-vline,.jcrop-light .jcrop-hline{background:#FFF;filter:Alpha(opacity=70)!important;opacity:.70!important;}
|
||||||
|
.jcrop-light .jcrop-handle{-moz-border-radius:3px;-webkit-border-radius:3px;background-color:#000;border-color:#FFF;border-radius:3px;}
|
||||||
|
.jcrop-dark .jcrop-vline,.jcrop-dark .jcrop-hline{background:#000;filter:Alpha(opacity=70)!important;opacity:.7!important;}
|
||||||
|
.jcrop-dark .jcrop-handle{-moz-border-radius:3px;-webkit-border-radius:3px;background-color:#FFF;border-color:#000;border-radius:3px;}
|
||||||
|
.jcrop-holder img,img.jcrop-preview{max-width:none;}
|
BIN
upload/js/jquery_plugs/css/jquery.Jcrop.gif
Normal file
BIN
upload/js/jquery_plugs/css/jquery.Jcrop.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 329 B |
22
upload/js/jquery_plugs/jquery.Jcrop.js
Normal file
22
upload/js/jquery_plugs/jquery.Jcrop.js
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
/**
|
||||||
|
* jquery.Jcrop.min.js v0.9.10 (build:20120429)
|
||||||
|
* jQuery Image Cropping Plugin - released under MIT License
|
||||||
|
* Copyright (c) 2008-2012 Tapmodo Interactive LLC
|
||||||
|
* https://github.com/tapmodo/Jcrop
|
||||||
|
*/
|
||||||
|
(function(a){a.Jcrop=function(b,c){function h(a){return a+"px"}function i(a){return d.baseClass+"-"+a}function j(){return a.fx.step.hasOwnProperty("backgroundColor")}function k(b){var c=a(b).offset();return[c.left,c.top]}function l(a){return[a.pageX-e[0],a.pageY-e[1]]}function m(b){typeof b!="object"&&(b={}),d=a.extend(d,b),a.each(["onChange","onSelect","onRelease","onDblClick"],function(a,b){typeof d[b]!="function"&&(d[b]=function(){})})}function n(a,b){e=k(E),bd.setCursor(a==="move"?a:a+"-resize");if(a==="move")return bd.activateHandlers(p(b),u);var c=ba.getFixed(),d=q(a),f=ba.getCorner(q(d));ba.setPressed(ba.getCorner(d)),ba.setCurrent(f),bd.activateHandlers(o(a,c),u)}function o(a,b){return function(c){if(!d.aspectRatio)switch(a){case"e":c[1]=b.y2;break;case"w":c[1]=b.y2;break;case"n":c[0]=b.x2;break;case"s":c[0]=b.x2}else switch(a){case"e":c[1]=b.y+1;break;case"w":c[1]=b.y+1;break;case"n":c[0]=b.x+1;break;case"s":c[0]=b.x+1}ba.setCurrent(c),bc.update()}}function p(a){var b=a;return be.watchKeys(),function(
|
||||||
|
a){ba.moveOffset([a[0]-b[0],a[1]-b[1]]),b=a,bc.update()}}function q(a){switch(a){case"n":return"sw";case"s":return"nw";case"e":return"nw";case"w":return"ne";case"ne":return"sw";case"nw":return"se";case"se":return"nw";case"sw":return"ne"}}function r(a){return function(b){return d.disabled?!1:a==="move"&&!d.allowMove?!1:(e=k(E),X=!0,n(a,l(b)),b.stopPropagation(),b.preventDefault(),!1)}}function s(a,b,c){var d=a.width(),e=a.height();d>b&&b>0&&(d=b,e=b/a.width()*a.height()),e>c&&c>0&&(e=c,d=c/a.height()*a.width()),U=a.width()/d,V=a.height()/e,a.width(d).height(e)}function t(a){return{x:a.x*U,y:a.y*V,x2:a.x2*U,y2:a.y2*V,w:a.w*U,h:a.h*V}}function u(a){var b=ba.getFixed();b.w>d.minSelect[0]&&b.h>d.minSelect[1]?(bc.enableHandles(),bc.done()):bc.release(),bd.setCursor(d.allowSelect?"crosshair":"default")}function v(a){if(d.disabled)return!1;if(!d.allowSelect)return!1;X=!0,e=k(E),bc.disableHandles(),bd.setCursor("crosshair");var b=l(a);return ba.setPressed(b),bc.update(),bd.activateHandlers(w,u),be.watchKeys(),a.stopPropagation
|
||||||
|
(),a.preventDefault(),!1}function w(a){ba.setCurrent(a),bc.update()}function z(){var b=a("<div></div>").addClass(i("tracker"));return a.browser.msie&&b.css({opacity:0,backgroundColor:"white"}),b}function bf(a){H.removeClass().addClass(i("holder")).addClass(a)}function bg(a,b){function t(){window.setTimeout(u,l)}var c=a[0]/U,e=a[1]/V,f=a[2]/U,g=a[3]/V;if(Y)return;var h=ba.flipCoords(c,e,f,g),i=ba.getFixed(),j=[i.x,i.y,i.x2,i.y2],k=j,l=d.animationDelay,m=h[0]-j[0],n=h[1]-j[1],o=h[2]-j[2],p=h[3]-j[3],q=0,r=d.swingSpeed;x=k[0],y=k[1],f=k[2],g=k[3],bc.animMode(!0);var s,u=function(){return function(){q+=(100-q)/r,k[0]=x+q/100*m,k[1]=y+q/100*n,k[2]=f+q/100*o,k[3]=g+q/100*p,q>=99.8&&(q=100),q<100?(bi(k),t()):(bc.done(),typeof b=="function"&&b.call(bt))}}();t()}function bh(a){bi([a[0]/U,a[1]/V,a[2]/U,a[3]/V]),d.onSelect.call(bt,t(ba.getFixed())),bc.enableHandles()}function bi(a){ba.setPressed([a[0],a[1]]),ba.setCurrent([a[2],a[3]]),bc.update()}function bj(){return t(ba.getFixed())}function bk(){return ba.getFixed()}function bl
|
||||||
|
(a){m(a),bs()}function bm(){d.disabled=!0,bc.disableHandles(),bc.setCursor("default"),bd.setCursor("default")}function bn(){d.disabled=!1,bs()}function bo(){bc.done(),bd.activateHandlers(null,null)}function bp(){H.remove(),B.show(),a(b).removeData("Jcrop")}function bq(a,b){bc.release(),bm();var c=new Image;c.onload=function(){var e=c.width,f=c.height,g=d.boxWidth,h=d.boxHeight;E.width(e).height(f),E.attr("src",a),I.attr("src",a),s(E,g,h),F=E.width(),G=E.height(),I.width(F).height(G),N.width(F+M*2).height(G+M*2),H.width(F).height(G),bb.resize(F,G),bn(),typeof b=="function"&&b.call(bt)},c.src=a}function br(a,b,c){var e=b||d.bgColor;d.bgFade&&j()&&d.fadeTime&&!c?a.animate({backgroundColor:e},{queue:!1,duration:d.fadeTime}):a.css("backgroundColor",e)}function bs(a){d.allowResize?a?bc.enableOnly():bc.enableHandles():bc.disableHandles(),bd.setCursor(d.allowSelect?"crosshair":"default"),bc.setCursor(d.allowMove?"move":"default"),d.hasOwnProperty("trueSize")&&(U=d.trueSize[0]/F,V=d.trueSize[1]/G),d.hasOwnProperty("setSelect"
|
||||||
|
)&&(bh(d.setSelect),bc.done(),delete d.setSelect),bb.refresh(),d.bgColor!=O&&(br(d.shade?bb.getShades():H,d.shade?d.shadeColor||d.bgColor:d.bgColor),O=d.bgColor),P!=d.bgOpacity&&(P=d.bgOpacity,d.shade?bb.refresh():bc.setBgOpacity(P)),Q=d.maxSize[0]||0,R=d.maxSize[1]||0,S=d.minSize[0]||0,T=d.minSize[1]||0,d.hasOwnProperty("outerImage")&&(E.attr("src",d.outerImage),delete d.outerImage),bc.refresh()}var d=a.extend({},a.Jcrop.defaults),e,f,g=!1;a.browser.msie&&a.browser.version.split(".")[0]==="6"&&(g=!0),typeof b!="object"&&(b=a(b)[0]),typeof c!="object"&&(c={}),m(c);var A={border:"none",visibility:"visible",margin:0,padding:0,position:"absolute",top:0,left:0},B=a(b),C=!0;if(b.tagName=="IMG"){if(B[0].width!=0&&B[0].height!=0)B.width(B[0].width),B.height(B[0].height);else{var D=new Image;D.src=B[0].src,B.width(D.width),B.height(D.height)}var E=B.clone().removeAttr("id").css(A).show();E.width(B.width()),E.height(B.height()),B.after(E).hide()}else E=B.css(A).show(),C=!1,d.shade===null&&(d.shade=!0);s(E,d.boxWidth,d.
|
||||||
|
boxHeight);var F=E.width(),G=E.height(),H=a("<div />").width(F).height(G).addClass(i("holder")).css({position:"relative",backgroundColor:d.bgColor}).insertAfter(B).append(E);d.addClass&&H.addClass(d.addClass);var I=a("<div />"),J=a("<div />").width("100%").height("100%").css({zIndex:310,position:"absolute",overflow:"hidden"}),K=a("<div />").width("100%").height("100%").css("zIndex",320),L=a("<div />").css({position:"absolute",zIndex:600}).dblclick(function(){var a=ba.getFixed();d.onDblClick.call(bt,a)}).insertBefore(E).append(J,K);C&&(I=a("<img />").attr("src",E.attr("src")).css(A).width(F).height(G),J.append(I)),g&&L.css({overflowY:"hidden"});var M=d.boundary,N=z().width(F+M*2).height(G+M*2).css({position:"absolute",top:h(-M),left:h(-M),zIndex:290}).mousedown(v),O=d.bgColor,P=d.bgOpacity,Q,R,S,T,U,V,W=!0,X,Y,Z;e=k(E);var _=function(){function a(){var a={},b=["touchstart","touchmove","touchend"],c=document.createElement("div"),d;try{for(d=0;d<b.length;d++){var e=b[d];e="on"+e;var f=e in c;f||(c.setAttribute(e,"return;"
|
||||||
|
),f=typeof c[e]=="function"),a[b[d]]=f}return a.touchstart&&a.touchend&&a.touchmove}catch(g){return!1}}function b(){return d.touchSupport===!0||d.touchSupport===!1?d.touchSupport:a()}return{createDragger:function(a){return function(b){return b.pageX=b.originalEvent.changedTouches[0].pageX,b.pageY=b.originalEvent.changedTouches[0].pageY,d.disabled?!1:a==="move"&&!d.allowMove?!1:(X=!0,n(a,l(b)),b.stopPropagation(),b.preventDefault(),!1)}},newSelection:function(a){return a.pageX=a.originalEvent.changedTouches[0].pageX,a.pageY=a.originalEvent.changedTouches[0].pageY,v(a)},isSupported:a,support:b()}}(),ba=function(){function h(d){d=n(d),c=a=d[0],e=b=d[1]}function i(a){a=n(a),f=a[0]-c,g=a[1]-e,c=a[0],e=a[1]}function j(){return[f,g]}function k(d){var f=d[0],g=d[1];0>a+f&&(f-=f+a),0>b+g&&(g-=g+b),G<e+g&&(g+=G-(e+g)),F<c+f&&(f+=F-(c+f)),a+=f,c+=f,b+=g,e+=g}function l(a){var b=m();switch(a){case"ne":return[b.x2,b.y];case"nw":return[b.x,b.y];case"se":return[b.x2,b.y2];case"sw":return[b.x,b.y2]}}function m(){if(!d.aspectRatio
|
||||||
|
)return p();var f=d.aspectRatio,g=d.minSize[0]/U,h=d.maxSize[0]/U,i=d.maxSize[1]/V,j=c-a,k=e-b,l=Math.abs(j),m=Math.abs(k),n=l/m,r,s,t,u;return h===0&&(h=F*10),i===0&&(i=G*10),n<f?(s=e,t=m*f,r=j<0?a-t:t+a,r<0?(r=0,u=Math.abs((r-a)/f),s=k<0?b-u:u+b):r>F&&(r=F,u=Math.abs((r-a)/f),s=k<0?b-u:u+b)):(r=c,u=l/f,s=k<0?b-u:b+u,s<0?(s=0,t=Math.abs((s-b)*f),r=j<0?a-t:t+a):s>G&&(s=G,t=Math.abs(s-b)*f,r=j<0?a-t:t+a)),r>a?(r-a<g?r=a+g:r-a>h&&(r=a+h),s>b?s=b+(r-a)/f:s=b-(r-a)/f):r<a&&(a-r<g?r=a-g:a-r>h&&(r=a-h),s>b?s=b+(a-r)/f:s=b-(a-r)/f),r<0?(a-=r,r=0):r>F&&(a-=r-F,r=F),s<0?(b-=s,s=0):s>G&&(b-=s-G,s=G),q(o(a,b,r,s))}function n(a){return a[0]<0&&(a[0]=0),a[1]<0&&(a[1]=0),a[0]>F&&(a[0]=F),a[1]>G&&(a[1]=G),[a[0],a[1]]}function o(a,b,c,d){var e=a,f=c,g=b,h=d;return c<a&&(e=c,f=a),d<b&&(g=d,h=b),[e,g,f,h]}function p(){var d=c-a,f=e-b,g;return Q&&Math.abs(d)>Q&&(c=d>0?a+Q:a-Q),R&&Math.abs(f)>R&&(e=f>0?b+R:b-R),T/V&&Math.abs(f)<T/V&&(e=f>0?b+T/V:b-T/V),S/U&&Math.abs(d)<S/U&&(c=d>0?a+S/U:a-S/U),a<0&&(c-=a,a-=a),b<0&&(e-=b,b-=b),c<0&&
|
||||||
|
(a-=c,c-=c),e<0&&(b-=e,e-=e),c>F&&(g=c-F,a-=g,c-=g),e>G&&(g=e-G,b-=g,e-=g),a>F&&(g=a-G,e-=g,b-=g),b>G&&(g=b-G,e-=g,b-=g),q(o(a,b,c,e))}function q(a){return{x:a[0],y:a[1],x2:a[2],y2:a[3],w:a[2]-a[0],h:a[3]-a[1]}}var a=0,b=0,c=0,e=0,f,g;return{flipCoords:o,setPressed:h,setCurrent:i,getOffset:j,moveOffset:k,getCorner:l,getFixed:m}}(),bb=function(){function f(a,b){e.left.css({height:h(b)}),e.right.css({height:h(b)})}function g(){return i(ba.getFixed())}function i(a){e.top.css({left:h(a.x),width:h(a.w),height:h(a.y)}),e.bottom.css({top:h(a.y2),left:h(a.x),width:h(a.w),height:h(G-a.y2)}),e.right.css({left:h(a.x2),width:h(F-a.x2)}),e.left.css({width:h(a.x)})}function j(){return a("<div />").css({position:"absolute",backgroundColor:d.shadeColor||d.bgColor}).appendTo(c)}function k(){b||(b=!0,c.insertBefore(E),g(),bc.setBgOpacity(1,0,1),I.hide(),l(d.shadeColor||d.bgColor,1),bc.isAwake()?n(d.bgOpacity,1):n(1,1))}function l(a,b){br(p(),a,b)}function m(){b&&(c.remove(),I.show(),b=!1,bc.isAwake()?bc.setBgOpacity(d.bgOpacity
|
||||||
|
,1,1):(bc.setBgOpacity(1,1,1),bc.disableHandles()),br(H,0,1))}function n(a,e){b&&(d.bgFade&&!e?c.animate({opacity:1-a},{queue:!1,duration:d.fadeTime}):c.css({opacity:1-a}))}function o(){d.shade?k():m(),bc.isAwake()&&n(d.bgOpacity)}function p(){return c.children()}var b=!1,c=a("<div />").css({position:"absolute",zIndex:240,opacity:0}),e={top:j(),left:j().height(G),right:j().height(G),bottom:j()};return{update:g,updateRaw:i,getShades:p,setBgColor:l,enable:k,disable:m,resize:f,refresh:o,opacity:n}}(),bc=function(){function k(b){var c=a("<div />").css({position:"absolute",opacity:d.borderOpacity}).addClass(i(b));return J.append(c),c}function l(b,c){var d=a("<div />").mousedown(r(b)).css({cursor:b+"-resize",position:"absolute",zIndex:c}).addClass("ord-"+b);return _.support&&d.bind("touchstart.jcrop",_.createDragger(b)),K.append(d),d}function m(a){var b=d.handleSize;return l(a,c++).css({opacity:d.handleOpacity}).width(b).height(b).addClass(i("handle"))}function n(a){return l(a,c++).addClass("jcrop-dragbar")}function o
|
||||||
|
(a){var b;for(b=0;b<a.length;b++)g[a[b]]=n(a[b])}function p(a){var b,c;for(c=0;c<a.length;c++){switch(a[c]){case"n":b="hline";break;case"s":b="hline bottom";break;case"e":b="vline right";break;case"w":b="vline"}e[a[c]]=k(b)}}function q(a){var b;for(b=0;b<a.length;b++)f[a[b]]=m(a[b])}function s(a,b){d.shade||I.css({top:h(-b),left:h(-a)}),L.css({top:h(b),left:h(a)})}function u(a,b){L.width(a).height(b)}function v(){var a=ba.getFixed();ba.setPressed([a.x,a.y]),ba.setCurrent([a.x2,a.y2]),w()}function w(a){if(b)return x(a)}function x(a){var c=ba.getFixed();u(c.w,c.h),s(c.x,c.y),d.shade&&bb.updateRaw(c),b||A(),a?d.onSelect.call(bt,t(c)):d.onChange.call(bt,t(c))}function y(a,c,e){if(!b&&!c)return;d.bgFade&&!e?E.animate({opacity:a},{queue:!1,duration:d.fadeTime}):E.css("opacity",a)}function A(){L.show(),d.shade?bb.opacity(P):y(P,!0),b=!0}function B(){F(),L.hide(),d.shade?bb.opacity(1):y(1),b=!1,d.onRelease.call(bt)}function C(){j&&K.show()}function D(){j=!0;if(d.allowResize)return K.show(),!0}function F(){j=!1,K.hide(
|
||||||
|
)}function G(a){Y===a?F():D()}function H(){G(!1),v()}var b,c=370,e={},f={},g={},j=!1;d.dragEdges&&a.isArray(d.createDragbars)&&o(d.createDragbars),a.isArray(d.createHandles)&&q(d.createHandles),d.drawBorders&&a.isArray(d.createBorders)&&p(d.createBorders),a(document).bind("touchstart.jcrop-ios",function(b){a(b.currentTarget).hasClass("jcrop-tracker")&&b.stopPropagation()});var M=z().mousedown(r("move")).css({cursor:"move",position:"absolute",zIndex:360});return _.support&&M.bind("touchstart.jcrop",_.createDragger("move")),J.append(M),F(),{updateVisible:w,update:x,release:B,refresh:v,isAwake:function(){return b},setCursor:function(a){M.css("cursor",a)},enableHandles:D,enableOnly:function(){j=!0},showHandles:C,disableHandles:F,animMode:G,setBgOpacity:y,done:H}}(),bd=function(){function f(){N.css({zIndex:450}),_.support&&a(document).bind("touchmove.jcrop",k).bind("touchend.jcrop",m),e&&a(document).bind("mousemove.jcrop",h).bind("mouseup.jcrop",i)}function g(){N.css({zIndex:290}),a(document).unbind(".jcrop")}function h
|
||||||
|
(a){return b(l(a)),!1}function i(a){return a.preventDefault(),a.stopPropagation(),X&&(X=!1,c(l(a)),bc.isAwake()&&d.onSelect.call(bt,t(ba.getFixed())),g(),b=function(){},c=function(){}),!1}function j(a,d){return X=!0,b=a,c=d,f(),!1}function k(a){return a.pageX=a.originalEvent.changedTouches[0].pageX,a.pageY=a.originalEvent.changedTouches[0].pageY,h(a)}function m(a){return a.pageX=a.originalEvent.changedTouches[0].pageX,a.pageY=a.originalEvent.changedTouches[0].pageY,i(a)}function n(a){N.css("cursor",a)}var b=function(){},c=function(){},e=d.trackDocument;return e||N.mousemove(h).mouseup(i).mouseout(i),E.before(N),{activateHandlers:j,setCursor:n}}(),be=function(){function e(){d.keySupport&&(b.show(),b.focus())}function f(a){b.hide()}function h(a,b,c){d.allowMove&&(ba.moveOffset([b,c]),bc.updateVisible(!0)),a.preventDefault(),a.stopPropagation()}function i(a){if(a.ctrlKey||a.metaKey)return!0;Z=a.shiftKey?!0:!1;var b=Z?10:1;switch(a.keyCode){case 37:h(a,-b,0);break;case 39:h(a,b,0);break;case 38:h(a,0,-b);break;case 40
|
||||||
|
:h(a,0,b);break;case 27:d.allowSelect&&bc.release();break;case 9:return!0}return!1}var b=a('<input type="radio" />').css({position:"fixed",left:"-120px",width:"12px"}),c=a("<div />").css({position:"absolute",overflow:"hidden"}).append(b);return d.keySupport&&(b.keydown(i).blur(f),g||!d.fixedSupport?(b.css({position:"absolute",left:"-20px"}),c.append(b).insertBefore(E)):b.insertBefore(E)),{watchKeys:e}}();_.support&&N.bind("touchstart.jcrop",_.newSelection),K.hide(),bs(!0);var bt={setImage:bq,animateTo:bg,setSelect:bh,setOptions:bl,tellSelect:bj,tellScaled:bk,setClass:bf,disable:bm,enable:bn,cancel:bo,release:bc.release,destroy:bp,focus:be.watchKeys,getBounds:function(){return[F*U,G*V]},getWidgetSize:function(){return[F,G]},getScaleFactor:function(){return[U,V]},getOptions:function(){return d},ui:{holder:H,selection:L}};return a.browser.msie&&H.bind("selectstart",function(){return!1}),B.data("Jcrop",bt),bt},a.fn.Jcrop=function(b,c){var d;return this.each(function(){if(a(this).data("Jcrop")){if(b==="api")return a
|
||||||
|
(this).data("Jcrop");a(this).data("Jcrop").setOptions(b)}else this.tagName=="IMG"?a.Jcrop.Loader(this,function(){a(this).css({display:"block",visibility:"hidden"}),d=a.Jcrop(this,b),a.isFunction(c)&&c.call(d)}):(a(this).css({display:"block",visibility:"hidden"}),d=a.Jcrop(this,b),a.isFunction(c)&&c.call(d))}),this},a.Jcrop.Loader=function(b,c,d){function g(){f.complete?(e.unbind(".jcloader"),a.isFunction(c)&&c.call(f)):window.setTimeout(g,50)}var e=a(b),f=e[0];e.bind("load.jcloader",g).bind("error.jcloader",function(b){e.unbind(".jcloader"),a.isFunction(d)&&d.call(f)}),f.complete&&a.isFunction(c)&&(e.unbind(".jcloader"),c.call(f))},a.Jcrop.defaults={allowSelect:!0,allowMove:!0,allowResize:!0,trackDocument:!0,baseClass:"jcrop",addClass:null,bgColor:"black",bgOpacity:.6,bgFade:!1,borderOpacity:.4,handleOpacity:.5,handleSize:7,aspectRatio:0,keySupport:!0,createHandles:["n","s","e","w","nw","ne","se","sw"],createDragbars:["n","s","e","w"],createBorders:["n","s","e","w"],drawBorders:!0,dragEdges:!0,fixedSupport:!0,
|
||||||
|
touchSupport:null,shade:null,boxWidth:0,boxHeight:0,boundary:2,fadeTime:400,animationDelay:20,swingSpeed:3,minSelect:[0,0],maxSize:[0,0],minSize:[0,0],onChange:function(){},onSelect:function(){},onDblClick:function(){},onRelease:function(){}}})(jQuery);
|
|
@ -104,6 +104,7 @@ switch($mode)
|
||||||
case "items":
|
case "items":
|
||||||
case "manage_items":
|
case "manage_items":
|
||||||
{
|
{
|
||||||
|
$collection = $cbcollection->get_collection($cid);
|
||||||
$type = clean($_GET['type']);
|
$type = clean($_GET['type']);
|
||||||
assign('type',$type);
|
assign('type',$type);
|
||||||
switch($type)
|
switch($type)
|
||||||
|
@ -126,6 +127,21 @@ switch($mode)
|
||||||
|
|
||||||
case "photos":
|
case "photos":
|
||||||
{
|
{
|
||||||
|
if ( isset($_GET['cover_photo']) ) {
|
||||||
|
$cover_photo = mysql_clean( $_GET['cover_photo'] );
|
||||||
|
if ( $cover_photo != $collection['cover_photo'] ) {
|
||||||
|
if ( $cbcollection->object_in_collection( $cover_photo, $collection['collection_id'] ) ) {
|
||||||
|
if ( $cbcollection->set_cover_photo( $cover_photo, $collection['collection_id'] ) ) {
|
||||||
|
e('new_cover_photo_set','m');
|
||||||
|
} else {
|
||||||
|
e('unable_new_cover_photo');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
e('item_not_exist');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(isset($_POST['delete_selected']))
|
if(isset($_POST['delete_selected']))
|
||||||
{
|
{
|
||||||
$count = count($_POST['check_item']);
|
$count = count($_POST['check_item']);
|
||||||
|
@ -141,8 +157,7 @@ switch($mode)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$collection = $cbcollection->get_collection($cid);
|
|
||||||
|
|
||||||
assign('c',$collection);
|
assign('c',$collection);
|
||||||
assign('objs',$objs);
|
assign('objs',$objs);
|
||||||
|
|
||||||
|
|
14
upload/styles/cbv3/layout/collections.html
Normal file
14
upload/styles/cbv3/layout/collections.html
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
<ul class="thumbnails">
|
||||||
|
{foreach from=$collections item=collection}
|
||||||
|
<li class="span">
|
||||||
|
<div class="thumbnail">
|
||||||
|
<img src="{$cbcollection->get_thumb($collection)}"/>
|
||||||
|
</div>
|
||||||
|
<div class="caption">
|
||||||
|
<h5><a href="{$cbcollection->collection_links($collection,'view')}">{$collection.collection_name}</a></h5>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
{foreachelse}
|
||||||
|
no collection
|
||||||
|
{/foreach}
|
||||||
|
</ul>
|
59
upload/styles/cbv3/layout/edit_account.html
Normal file
59
upload/styles/cbv3/layout/edit_account.html
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
{if $mode == 'avatar_bg'}
|
||||||
|
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
{if $mode == 'make_avatar'}
|
||||||
|
<h2 class="page-header">Set Avatar</h2>
|
||||||
|
{assign var=pd value=$photo.photo_details|json_decode}
|
||||||
|
|
||||||
|
{if $smarty.get.set_avatar != 1}
|
||||||
|
<div class="well clearfix">
|
||||||
|
<h4 style="float:left;">Crop Photo<br /> <small>Drag the corners of the transparent box below to crop this photo into your avatar. </small></h4>
|
||||||
|
<form action="" method="post" class="clearfix" style="margin:0px;">
|
||||||
|
<input type="hidden" name="start_x" id ="start_x" value="0" />
|
||||||
|
<input type="hidden" name="end_x" id ="end_x" value="{$Cbucket->configs.max_profile_pic_width}" />
|
||||||
|
|
||||||
|
<input type="hidden" name="start_y" id="start_y" value="0" />
|
||||||
|
<input type="hidden" name="end_y"id="end_y" value="{$Cbucket->configs.max_profile_pic_width}" />
|
||||||
|
|
||||||
|
<input type="hidden" name="pid" value="{$smarty.get.pid}" />
|
||||||
|
<button type="button" class="moveR btn btn-large" onclick="window.location = '{$cbphoto->photo_links($photo,view_photo)}'">Cancel</button>
|
||||||
|
<input type="submit" name="set_avatar" class="btn btn-large btn-primary marginR10 moveR" value="Set Avatar" />
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<!-- Jcrop Start -->
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(function() {
|
||||||
|
function updateCoords ( coords ) {
|
||||||
|
/* var rx = {$Cbucket->configs.max_profile_pic_width} / coords.w;
|
||||||
|
var ry = {$Cbucket->configs.max_profile_pic_width} / coords.h;
|
||||||
|
|
||||||
|
$('#preview_{$photo.photo_id}').css({
|
||||||
|
width: Math.round(rx * {$pd.l.width}) + 'px',
|
||||||
|
height: Math.round(ry * {$pd.l.height}) + 'px',
|
||||||
|
marginLeft: '-' + Math.round(rx * coords.x) + 'px',
|
||||||
|
marginTop: '-' + Math.round(ry * coords.y) + 'px'
|
||||||
|
});*/
|
||||||
|
|
||||||
|
$('#start_x').val( coords.x );
|
||||||
|
$('#end_x').val( coords.x2 );
|
||||||
|
|
||||||
|
$('#start_y').val( coords.y );
|
||||||
|
$('#end_y').val( coords.y2 );
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#{$cbphoto->selector_id}_{$photo.photo_id}').Jcrop({
|
||||||
|
onChange: updateCoords,
|
||||||
|
onSelect: updateCoords,
|
||||||
|
setSelect : [0,0,{$Cbucket->configs.max_profile_pic_width},{$Cbucket->configs.max_profile_pic_width}],
|
||||||
|
aspectRatio : 1,
|
||||||
|
minSize : [{$smarty.const.AVATAR_SMALL_SIZE},{$smarty.const.AVATAR_SMALL_SIZE}]
|
||||||
|
})
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
<!-- Jcrop End -->
|
||||||
|
{/if}
|
||||||
|
<div class="thumbnail" style="width:{$pd.l.width}px; margin:auto;">
|
||||||
|
{get_photo details=$photo size="l" output="html"}
|
||||||
|
</div>
|
||||||
|
{/if}
|
30
upload/styles/cbv3/layout/manage_collections.html
Normal file
30
upload/styles/cbv3/layout/manage_collections.html
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
{if $mode == "manage" || $mode == ""}
|
||||||
|
<ul class="thumbnails">
|
||||||
|
{foreach from=$usr_collects item=collection}
|
||||||
|
<li class="span">
|
||||||
|
<div class="thumbnail">
|
||||||
|
<img src="{$cbcollection->get_thumb($collection)}"/>
|
||||||
|
<div class="caption">
|
||||||
|
<h5><a href="{$cbcollection->collection_links($collection,'view')}">{$collection.collection_name}</a></h5>
|
||||||
|
<p><a href="?mode=manage_items&cid={$collection.collection_id}&type={$collection.type}" class="btn">Items</a></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
{/foreach}
|
||||||
|
</ul>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
{if $mode == "manage_items" || $mode == "collection_items"}
|
||||||
|
<ul class="thumbnails">
|
||||||
|
{foreach from=$objs item=collection}
|
||||||
|
<li class="span">
|
||||||
|
<div class="thumbnail">
|
||||||
|
{get_photo details=$collection output="html" size="m"}
|
||||||
|
<div class="caption">
|
||||||
|
<p><a href="?mode=manage_items&cid={$collection.collection_id}&type={$c.type}&cover_photo={$collection.photo_id}" class="btn btn-mini">Cover Photo</a></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
{/foreach}
|
||||||
|
</ul>
|
||||||
|
{/if}
|
1
upload/styles/cbv3/layout/view_item.html
Normal file
1
upload/styles/cbv3/layout/view_item.html
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<h2><a href="{$cbphoto->photo_links($object,'ma')}" target="_blank">Set Avatar</a></h2>
|
9
upload/styles/global/photo_tagger.html
Normal file
9
upload/styles/global/photo_tagger.html
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<link href="{$js}/jquery_plugs/css/jquery.cbtagger.css" rel="stylesheet" />
|
||||||
|
<script type="text/javascript">
|
||||||
|
{literal}
|
||||||
|
var CBTAGGER;
|
||||||
|
$( document ).ready( function() {
|
||||||
|
CBTAGGER = $('#{/literal}{$cbphoto->get_selector_id()}_{$object.photo_id}{literal}').cbtag({/literal}{$tagger_configs}{literal}).data("cbtagger");
|
||||||
|
})
|
||||||
|
{/literal}
|
||||||
|
</script>
|
|
@ -80,6 +80,7 @@ if ( $cbcollection->is_viewable( $cid ) ) {
|
||||||
$photo = $cbphoto->get_photo( $item );
|
$photo = $cbphoto->get_photo( $item );
|
||||||
if ( $photo ) {
|
if ( $photo ) {
|
||||||
$info = $cbphoto->collection->get_collection_item_fields( $cid, $photo['photo_id'], 'ci_id' );
|
$info = $cbphoto->collection->get_collection_item_fields( $cid, $photo['photo_id'], 'ci_id' );
|
||||||
|
|
||||||
if ( $info ) {
|
if ( $info ) {
|
||||||
$photo = array_merge( $photo, $info[0] );
|
$photo = array_merge( $photo, $info[0] );
|
||||||
increment_views( $photo['photo_id'], 'photo' );
|
increment_views( $photo['photo_id'], 'photo' );
|
||||||
|
@ -89,6 +90,8 @@ if ( $cbcollection->is_viewable( $cid ) ) {
|
||||||
assign( 'c', $collect );
|
assign( 'c', $collect );
|
||||||
|
|
||||||
subtitle( $photo['photo_title'] . ' « ' . $collect['collection_name'] );
|
subtitle( $photo['photo_title'] . ' « ' . $collect['collection_name'] );
|
||||||
|
|
||||||
|
insert_photo_colors( $photo );
|
||||||
} else {
|
} else {
|
||||||
e( lang( "item_not_exist" ) );
|
e( lang( "item_not_exist" ) );
|
||||||
$Cbucket->show_page = false;
|
$Cbucket->show_page = false;
|
||||||
|
|
Loading…
Add table
Reference in a new issue