4images Forum & Community
Welcome, Guest. Please login or register.
Did you miss your activation email?
February 22, 2018, 07:47:50 PM

Login with username, password and session length
Search:     Advanced search
You're looking for some 4images templates and styles? Then visit this thread to show websites with 4images templates to download.
Togle to toolbar
Translate this page with =>
Translate this page >
* Home Help Search Login Register
 
+  4images Forum & Community
|-+  4images Modifications / Modifikationen
| |-+  Mods & Plugins (Requests & Discussions) (Moderators: mawenzi, Rembrandt)
| | |-+  Rotating picture by user online
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: «« « 1 [2] 3 » »» Print
Author Topic: Rotating picture by user online  (Read 34041 times)
ruudvroon
Jr. Member
**
Offline Offline

Posts: 79

Thank You
-Given: 0
-Receive: 0


View Profile WWW
« Reply #15 on: October 26, 2005, 10:32:08 PM »

To add the rotate button for the admin:

Replace includes/rotate.php with this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<?
// change to suit your needs eg: define (JPG_QUALITY, '75'); gives a more compressed
// image file, but a poorer quality, when re-writing the jpeg after rotation.

define('JPG_QUALITY', '100');


//define variables and includes (should be no need to change these)
define('ROOT_PATH', './../');
include(ROOT_PATH.'global.php');
require(ROOT_PATH.'includes/sessions.php');
$user_access = get_permission();


//is there an image_id and does the user have permission to delete the image? If not, send them back to the index page!
if (!$image_id || ($config['user_delete_image'] != 1)) {
    header("Location: ".$site_sess->url(ROOT_PATH."index.php", "&"));
    exit;
  }
 
//if ok so far, read the image info from the database 
  $sql = "SELECT image_id, cat_id, user_id, image_name, image_media_file, image_thumb_file
          FROM ".IMAGES_TABLE."
          WHERE image_id = $image_id";
         
  $image_row = $site_db->query_firstrow($sql);

//is the user a registered user and the 'owner' of the image? If not, send them back to the index page!
  if ($user_info['user_level'] == ADMIN OR !$image_row || $image_row['user_id'] <= USER_AWAITING || ($user_info['user_id'] = $image_row['user_id'])) {

 
//so far so good, more variables need defining...
$ok=false;
$file=$image_row[image_media_file];
$cat_id=$image_row[cat_id];
$path_to_media = ROOT_PATH.MEDIA_DIR."/".$cat_id."/";
$path_to_thumbs = ROOT_PATH.THUMB_DIR."/".$cat_id."/";
$ext = get_file_extension($file); 

//clockwise or anticlockwise?
$degrees=0;
if ($wize=="neg"){$degrees = 90;}
if ($wize=="180"){$degrees = 180;}
if ($wize=="pos"){$degrees = 270;}

// Load existing images (if a 'jpg')
if (($ext == "jpg") || ($ext == "jpeg"))
{
$source_image = imagecreatefromjpeg($path_to_media.$file);
$source_thumb = imagecreatefromjpeg($path_to_thumbs.$file);
$ok=true;
}

// Load existing images (if a 'gif')
if ($ext == "gif")
{
$source_image = imagecreatefromgif($path_to_media.$file);
$source_thumb = imagecreatefromgif($path_to_thumbs.$file);
$ok=true;
}

if ($ok) //is it ok to process?
{
// Rotate
$rotate_image = imagerotate($source_image, $degrees, 0);
$rotate_thumb = imagerotate($source_thumb, $degrees, 0);

//Create new file names using timestamp as 'random' prefix to force browser to reload
$new_file_name=time().".".$ext;
$new_image = $path_to_media.$new_file_name;
$new_thumb = $path_to_thumbs.$new_file_name;

//Output 'new' images
if (($ext == "jpg") || ($ext == "jpeg"))
{
imagejpeg($rotate_image,$new_image,JPG_QUALITY);
imagejpeg($rotate_thumb,$new_thumb,JPG_QUALITY);
}

if ($ext == "gif")
{
imagegif($rotate_image,$new_image);
imagegif($rotate_thumb,$new_thumb);
}

//Delete 'old' files
unlink($path_to_media.$file);
unlink($path_to_thumbs.$file);
imagedestroy($rotate_image);
imagedestroy($rotate_thumb);
imagedestroy($source_image);
imagedestroy($source_thumb);


//write 'new' filenames to database
$sql=" UPDATE `4images_images`
SET `image_media_file` = '$new_file_name',`image_thumb_file` = '$new_file_name'
WHERE `image_id` = '$image_id'
LIMIT 1";

$result = $site_db->query($sql);

} //end of processing

//display new rotated image
header("Location: ".$site_sess->url(ROOT_PATH."details.php?&".URL_IMAGE_ID."=".$image_id, "&"));
}
  elseif (!$image_row || $image_row['user_id'] <= USER_AWAITING || ($user_info['user_id'] != $image_row['user_id'])) {
    header("Location: ".$site_sess->url(ROOT_PATH."index.php", "&"));
      exit;
  }

?>

Open details.php

FIND:
1
2
3
4
if ($user_info['user_level'] == ADMIN) {
  $admin_links .= "<a href=\"".$site_sess->url(ROOT_PATH."admin/index.php?goto=".urlencode("images.php?action=editimage&amp;image_id=".$image_id))."\" target=\"_blank\">".$lang['edit']."</a>&nbsp;";
  $admin_links .= "<a href=\"".$site_sess->url(ROOT_PATH."admin/index.php?goto=".urlencode("images.php?action=removeimage&amp;image_id=".$image_id))."\" target=\"_blank\">".$lang['delete']."</a>&nbsp;";
}

REPLACE WITH:
1
2
3
4
5
6
if ($user_info['user_level'] == ADMIN) {
  $admin_links .= "<a href=\"".$site_sess->url(ROOT_PATH."admin/index.php?goto=".urlencode("images.php?action=editimage&amp;image_id=".$image_id))."\" target=\"_blank\">".$lang['edit']."</a>&nbsp;";
  $admin_links .= "<a href=\"".$site_sess->url(ROOT_PATH."admin/index.php?goto=".urlencode("images.php?action=removeimage&amp;image_id=".$image_id))."\" target=\"_blank\">".$lang['delete']."</a>&nbsp;";
  $admin_links .= "<a href=\"".$site_sess->url(ROOT_PATH."includes/rotate.php?".URL_IMAGE_ID."=".$image_id."&amp;wize=90")."\">".$lang['rotate_neg']."</a>&nbsp;";
  $admin_links .= "<a href=\"".$site_sess->url(ROOT_PATH."includes/rotate.php?".URL_IMAGE_ID."=".$image_id."&amp;wize=270")."\">".$lang['rotate_pos']."</a>";
}

When an Image is uploaded, you get a page with te result, is it possible to add the rotate option to that page?
 Exclamation
Logged
ruudvroon
Jr. Member
**
Offline Offline

Posts: 79

Thank You
-Given: 0
-Receive: 0


View Profile WWW
« Reply #16 on: October 27, 2005, 07:48:47 PM »

I found it out myself:


Open member.php

Find:
1
$content .= "<table border=\"0\" align=\"center\">\n<tr>\n<td>\n".$media."\n</td>\n</tr>\n</table>\n";

Replace with:
1
$content .= "<table border=\"0\" align=\"center\">\n<tr>\n<td>\n<div align=\"center\"><a href=\"./includes/rotate.php?".URL_IMAGE_ID."=".$image_id."&amp;wize=neg\">".$lang['rotate_neg']."</a>&nbsp;<a href=\"./includes/rotate.php?".URL_IMAGE_ID."=".$image_id."&amp;wize=pos\">".$lang['rotate_pos']."</a></div><br />".$media."\n</td>\n</tr>\n</table>\n";



Logged
theendmc
Pre-Newbie

Offline Offline

Posts: 2

Thank You
-Given: 0
-Receive: 0


View Profile
« Reply #17 on: January 14, 2006, 12:55:59 PM »

Boatman, many thanks for this code. Great time saver. Has there been any further development of this code? It would be great if admin had this ability not just at upload time but at any time. This would be good for editing after a bulk upload. If a zoom function could be added 4images in my opinion would be very much enhanced.

All the best, and thanks again.
Pete
Logged
mawenzi
Moderator
4images Guru
*****
Offline Offline

Posts: 4500

Thank You
-Given: 36
-Receive: 121


View Profile
« Reply #18 on: January 14, 2006, 03:04:28 PM »

... If a zoom function could be added 4images in my opinion would be very much enhanced. ...

... it is possible ... but it is only a example an only for IE ... here
Logged

Your first three "must do" before you ask a question ! ( © by V@no )
- please read the Forum Rules ...
- please study the FAQ ...
- please try to Search for your answer ...

You are on search for top 4images MOD's ?
- then please search here ... Mawenzi's Top 100+ MOD List (unsorted sorted) ...
theendmc
Pre-Newbie

Offline Offline

Posts: 2

Thank You
-Given: 0
-Receive: 0


View Profile
« Reply #19 on: January 14, 2006, 06:15:15 PM »

That looks nice. Any idea where the code is available?
Logged
boatman9999
Jr. Member
**
Offline Offline

Posts: 50

Thank You
-Given: 0
-Receive: 0


View Profile
« Reply #20 on: January 24, 2006, 06:15:07 PM »

Quote  [Expand]
Boatman, many thanks for this code. Great time saver. Has there been any further development of this code?

Sorry. No further development at this stage, I just don't have the time. Anybody is welcome to add to the code if they have anything to  input.
Logged
TheOracle
Hero Member
*****
Offline Offline

Posts: 875

Thank You
-Given: 0
-Receive: 3


View Profile
« Reply #21 on: January 24, 2006, 06:59:21 PM »

I found it out myself:


Open member.php

Find:
1
$content .= "<table border=\"0\" align=\"center\">\n<tr>\n<td>\n".$media."\n</td>\n</tr>\n</table>\n";

Replace with:
1
$content .= "<table border=\"0\" align=\"center\">\n<tr>\n<td>\n<div align=\"center\"><a href=\"./includes/rotate.php?".URL_IMAGE_ID."=".$image_id."&amp;wize=neg\">".$lang['rotate_neg']."</a>&nbsp;<a href=\"./includes/rotate.php?".URL_IMAGE_ID."=".$image_id."&amp;wize=pos\">".$lang['rotate_pos']."</a></div><br />".$media."\n</td>\n</tr>\n</table>\n";


I think you meant :

Quote  [Expand]

$content .= "<table border=\"0\" align=\"center\">\n<tr>\n<td>\n<div align=\"center\"><a href=\"./includes/rotate.php?".URL_IMAGE_ID."=".$image_id."&amp;wize=neg\">".$lang['rotate_neg']."</a>&nbsp;<a href=\"./includes/rotate.php?".URL_IMAGE_ID."=".$image_id."&amp;wize=pos\">".$lang['rotate_pos']."</a></div><br />".$media."\n</td>\n</tr>\n</table>\n";


with this one :

Quote  [Expand]

$content .= "<table border=\"0\" align=\"center\">\n<tr>\n<td>\n<div align=\"center\"><a href=\"".$site_sess->url(ROOT_PATH."includes/rotate.php?".URL_IMAGE_ID."=".$image_id."&amp;wize=neg")."\">".$lang['rotate_neg']."</a>&nbsp;<a href=\"".$site_sess->url(ROOT_PATH."includes/rotate.php?".URL_IMAGE_ID."=".$image_id."&amp;wize=pos")."\">".$lang['rotate_pos']."</a></div><br />".$media."\n</td>\n</tr>\n</table>\n";


Wink
Logged
lemccoy
Jr. Member
**
Offline Offline

Posts: 90

Thank You
-Given: 0
-Receive: 0


View Profile WWW
« Reply #22 on: February 17, 2006, 03:35:49 PM »

I am trying this on another 4images site I have just created and it just bounces back to the index.php after clickign the rotate button and doesn't change the picture.  Any ideas?
Logged
TheOracle
Hero Member
*****
Offline Offline

Posts: 875

Thank You
-Given: 0
-Receive: 3


View Profile
« Reply #23 on: February 17, 2006, 03:37:23 PM »

Would it be possible to see the codings you made ? It would be a lot more easier to determine the source of the problem. Wink
Logged
lemccoy
Jr. Member
**
Offline Offline

Posts: 90

Thank You
-Given: 0
-Receive: 0


View Profile WWW
« Reply #24 on: February 17, 2006, 03:39:36 PM »

//is there an image_id and does the user have permission to delete the image? If not, send them back to the index page!

OK that is what the problem is.  I logged in as the user (family site) and it allowed to rotate.  Let me go back and check the code...wow that was a fast response!


1
2
3
4
5
//is there an image_id and does the user have permission to delete the image? If not, send them back to the index page!
if (!$image_id || ($config['user_delete_image'] != 1)) {
    header("Location: ".$site_sess->url(ROOT_PATH."index.php", "&"));
    exit;
  }

I think this is the problem.  I can delete as an admin I just checked. 

Would there be a snippet of code that could replace this to just check if it's user owner or admin?

Oh Wait!  If I have it setup that users can delete their own posts, then I don't even need this code, correct?  Cause it checks here:

1
2
//is the user a registered user and the 'owner' of the image? If not, send them back to the index page!
  if ($user_info['user_level'] == ADMIN OR !$image_row || $image_row['user_id'] <= USER_AWAITING || ($user_info['user_id'] = $image_row['user_id'])) {

Does that make sense?
« Last Edit: February 17, 2006, 04:09:07 PM by lemccoy » Logged
TheOracle
Hero Member
*****
Offline Offline

Posts: 875

Thank You
-Given: 0
-Receive: 3


View Profile
« Reply #25 on: February 17, 2006, 03:54:54 PM »

Disgarding the fact the replacement above is the not the correct way to call it, in which file did you applyed these modifications ? More details please.
Logged
lemccoy
Jr. Member
**
Offline Offline

Posts: 90

Thank You
-Given: 0
-Receive: 0


View Profile WWW
« Reply #26 on: February 17, 2006, 04:00:44 PM »

ok in rotate.php I have edited the checking permissions area to come up with:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?
// change to suit your needs eg: define (JPG_QUALITY, '75'); gives a more compressed
// image file, but a poorer quality, when re-writing the jpeg after rotation.

define('JPG_QUALITY', '100');


//define variables and includes (should be no need to change these)
define('ROOT_PATH', './../');
include(ROOT_PATH.'global.php');
require(ROOT_PATH.'includes/sessions.php');
$user_access = get_permission();


//is there an image_id and does the user have permission to delete the image? If not, send them back to the index page!
//if (!$image_id || ($config['user_delete_image'] != 1)) {
//    header("Location: ".$site_sess->url(ROOT_PATH."index.php", "&"));
//    exit;
//  }
 
//if ok so far, read the image info from the database 
  $sql = "SELECT image_id, cat_id, user_id, image_name, image_media_file, image_thumb_file
          FROM ".IMAGES_TABLE."
          WHERE image_id = $image_id";
         
  $image_row = $site_db->query_firstrow($sql);

//is the user a registered user and the 'owner' of the image? If not, send them back to the index page!
//  if (!$image_row || $image_row['user_id'] <= USER_AWAITING || ($user_info['user_id'] != $image_row['user_id'])) {
//    header("Location: ".$site_sess->url(ROOT_PATH."index.php", "&"));
//     exit;
//  }

//is the user an administrator? If not, send them back to the index page!
    if ($user_info['user_id'] != ADMIN) {
    header("Location: ".$site_sess->url(ROOT_PATH."index.php", "&"));
     exit;
    }
 
//so far so good, more variables need defining...

this isn't working however either.  Basically I only want admins to be able to rotate the pictures.  I can deal with the templates/links.  Thanks Oracle!
Logged
TheOracle
Hero Member
*****
Offline Offline

Posts: 875

Thank You
-Given: 0
-Receive: 3


View Profile
« Reply #27 on: February 17, 2006, 04:16:33 PM »

If rotates.php file is under the includes folder, there's no need to include this block :

Quote  [Expand]

//define variables and includes (should be no need to change these)
define('ROOT_PATH', './../');
include(ROOT_PATH.'global.php');
require(ROOT_PATH.'includes/sessions.php');
$user_access = get_permission();


However, you'd need to import the file in the appropriate source file from your ROOT_PATH instead. Wink

Quote  [Expand]

//is the user an administrator? If not, send them back to the index page!
    if ($user_info['user_id'] != ADMIN) {
  header("Location: ".$site_sess->url(ROOT_PATH."index.php", "&"));
     exit;
    }


move it below :

Quote  [Expand]

//is there an image_id and does the user have permission to delete the image? If not, send them back to the index page!
//if (!$image_id || ($config['user_delete_image'] != 1)) {
//    header("Location: ".$site_sess->url(ROOT_PATH."index.php", "&"));
//    exit;
//  }


As for this line,

Quote  [Expand]

if (!$image_row || $image_row['user_id'] <= USER_AWAITING || ($user_info['user_id'] != $image_row['user_id'])) {


you could say :

1
2
3
4
5

$check_user = $user_info['user_level'] == ADMIN;

if (!$image_row || $image_row['user_id'] != $check_user) {


However, you might hear other inputs on this.
Logged
lemccoy
Jr. Member
**
Offline Offline

Posts: 90

Thank You
-Given: 0
-Receive: 0


View Profile WWW
« Reply #28 on: February 17, 2006, 04:33:30 PM »

I have just disabled all checks within rotate.php  Confused

The links will only showup for admins.  Hopefully no-one is mean enough to find out which site it is and rotate all my pictures!  (BTW I have never posted the link here!)  Laughing

Oh, and I needed to have the

1
//define variables and includes (should be no need to change these)

or else I got errors.
« Last Edit: February 17, 2006, 04:46:36 PM by lemccoy » Logged
V@no
If you don't tell me what to do, I won't tell you where you should go :)
Administrator
4images Guru
*****
Offline Offline

Posts: 17849

Thank You
-Given: 47
-Receive: 565

mmm PHP...


View Profile WWW
« Reply #29 on: February 18, 2006, 01:09:00 AM »

Your condition is wrong, you must use user_level and not user_id Wink
here is the fixed version of conditional block:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
// change to suit your needs eg: define (JPG_QUALITY, '75'); gives a more compressed
// image file, but a poorer quality, when re-writing the jpeg after rotation.

define('JPG_QUALITY''100'); 


//define variables and includes (should be no need to change these)
define('ROOT_PATH''./../');
include(
ROOT_PATH.'global.php');
require(
ROOT_PATH.'includes/sessions.php');
$user_access get_permission();


//is there an image_id and user is admin? If not, send them back to the index page!
if (!$image_id || $user_info['user_level'] != ADMIN) {
    
header("Location: ".$site_sess->url(ROOT_PATH."index.php""&"));
    exit;
  }
  
//if ok so far, read the image info from the database  
  
$sql "SELECT image_id, cat_id, user_id, image_name, image_media_file, image_thumb_file
          FROM "
.IMAGES_TABLE."
          WHERE image_id = 
$image_id";
          
  
$image_row $site_db->query_firstrow($sql);

//did we get any result from the database? If not, send them back to the index page!
  
if (!$image_row) {
  
  header("Location: ".$site_sess->url(ROOT_PATH."index.php""&"));
     exit;
  }

  
//so far so good, more variables need defining...
Logged

Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)
Pages: «« « 1 [2] 3 » »» Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.09 seconds with 20 queries.
Post your comments here