Pixelpost

Authentic Photoblog Flavour


Go Back   Pixelpost Forum > DEVELOPMENT > Addons

Post Reply
 
Thread Tools
  #1  
Old 12-15-2005, 03:08 PM
eon's Avatar
eon Offline
pixelpost guru
 
Join Date: Nov 2005
Location: Ned
Posts: 280
Send a message via ICQ to eon
Smile Addon Fast edit button

In this tread ttlive asked for an "edit this image"-link.

Quote:
Originally Posted by ttlive
An "edit this" option directly from the Post would be wounderful.

In case I am loged-in in the Admin section and I surfe through my PP blog, than an "edit this" option would be amazing. The Login is saved anyway somewhere, because I don't have to use the PW if I reenter the Adminsection again on the e.g. next day.

In case if there are a lot of images are saved in the database, it is a long way to scroll via "Images/Older Images..." to edit an picture (Title, Category or description / text) that was published a long time ago.

I don't know whether this post ist correct in "Hacks and Modifications" or should have been published in Addon. If it should have been published in Addon, than I am sorry.

Is there a change to get an option like this, sometimes?
I have the same problem and I made a little addon for this called "Fastedit".
http://www.northing.nl/programs/fastedit.tar.gz
(I don't have zip, but you can open tar.gz with 7-zip)

<FAST_EDIT> is the tag to use in your template.

The cookie of pixelpost_admin is stored in /admin.
I can't reach this cookie out of index.php (any suggestions?)
So I moved the cookie to the root ("/").

Edit /admin/index.php
- row 126
PHP Code:
if (setcookie("pixelpost_admin",$cfgrow_password,time() +60*60*60*60"/")) 
- row 135
PHP Code:
setcookie("pixelpost_admin","nope",time() -60"/"); 
This is the code of the addon:
PHP Code:
if(!isset($_COOKIE['pixelpost_admin']) && $cfgrow['password'] != $_COOKIE['pixelpost_admin']) {
    
$tpl str_replace("<FAST_EDIT>","",$tpl); //delete <FAST_EDIT> when there is no valid cookie
}else{
    
$fastedit "<a href=\"/admin/index.php?view=images&id=$image_id\">Admin</a>";
    
$tpl str_replace("<FAST_EDIT>",$fastedit,$tpl); //show link


Have much fun with the Addon!
__________________
Northing.nl

Last edited by eon; 12-15-2005 at 05:50 PM. Reason: grammar + read suggestion Joe[y]
Reply With Quote
  #2  
Old 12-15-2005, 05:04 PM
Joe[y]'s Avatar
Joe[y]+ Offline
Team Pixelpost
 
Join Date: Mar 2005
Location: UK
Posts: 3,101
Send a message via MSN to Joe[y]
what if pixelpost really is in the root - ie, what to put instead of /pixelpost/ ?
Reply With Quote
  #3  
Old 12-15-2005, 05:41 PM
eon's Avatar
eon Offline
pixelpost guru
 
Join Date: Nov 2005
Location: Ned
Posts: 280
Send a message via ICQ to eon
I use my server to test different PHP opensource Contentmanagement-systems. Every system use his own index.php .

When your pixelpost is on root it must be "/" instand of "/pixelpost/".

I will rebuild the addon for the normal user. Done
__________________
Northing.nl
Reply With Quote
  #4  
Old 12-17-2005, 02:27 PM
posefius's Avatar
posefius Offline
pixelpost guru
 
Join Date: Mar 2005
Location: Netherlands
Posts: 100
This is an addon i always wanted, great!

Please can you explain me step by step what i need to do to use this addon. I put it in the addon directory and placed the tag <FAST_EDIT> in the image template but nothing happens. Do I also need to modify the index.php?

Please explain step-by-step, i'm not a PHP code writer.
Reply With Quote
  #5  
Old 12-17-2005, 03:43 PM
eon's Avatar
eon Offline
pixelpost guru
 
Join Date: Nov 2005
Location: Ned
Posts: 280
Send a message via ICQ to eon
Lightbulb

Quote:
Originally Posted by posefius
This is an addon i always wanted, great!

Please can you explain me step by step what i need to do to use this addon. I put it in the addon directory and placed the tag <FAST_EDIT> in the image template but nothing happens. Do I also need to modify the index.php?

Please explain step-by-step, i'm not a PHP code writer.
You placed the tag <FAST_EDIT> in the image template. That's oke!
There is something more that you have to do.

Find in "/admin/index.php" this code. It starts at row 123.
PHP Code:
if($_GET['x'] == "login") {
    
$cfgrow_password $cfgrow['password'];
    if((
$cfgrow['admin'] == $_POST['user']) AND ($cfgrow_password == md5($_POST['password']))) {
        
// login is valid, set cookie
        
if (setcookie("pixelpost_admin",$cfgrow_password,time() +60*60*60*60))
       
header("Location:index.php");
        unset(
$login);
        } else { 
$loginmessage "Username or Password Incorrect.<br />
        <a href='#' onclick=\"flip('askforpass'); return false;\">Forgot password?</a><p />
        "
; }
    } 
// if (login = yes) end

if($_GET['x'] == "logout") {
    
setcookie("pixelpost_admin","nope",time() -60);
    
header("Location:index.php");

This script controls the cookie that's tells the system if you logged in as an admin. Login and Logout. The cookie of login will be placed in the directory "/admin/". How that works I don't know. Take it as a fact.
BUT the addon is searching for a cookie in the directory "/", the root. So we have a problem. I thried to let the addon search in "/admin/" but that didn't work out.
My solution is this. Move the cookie to "/". That's what you have to do to use the addon.

Replace this script:
PHP Code:
        if (setcookie("pixelpost_admin",$cfgrow_password,time() +60*60*60*60)) 
for this:
PHP Code:
        if (setcookie("pixelpost_admin",$cfgrow_password,time() +60*60*60*60,"/")) 
What does it mean?
Set a cookie with the name "pixelpost_admin" and it contains the password of the admin ($cfgrow_password). The cookie will be expired at "time" + 15 days (60sec * 60 * 60 * 60) and will be stored in "/".

And replace this script:
PHP Code:
    setcookie("pixelpost_admin","nope",time() -60); 
for this:
PHP Code:
    setcookie("pixelpost_admin","nope",time() -60,"/"); 
What does it mean?
Set a cookie with the name "pixelpost_admin" and it contains the word "nope". The cookie will be expired at "time" - 60sec and wil be stored in "/". The cookie will be deleted because the time is in the history.


That's all folks! I have explained this little modification in the addon itself. But maybe I made the explination too short . Let me know if it's working or not.
__________________
Northing.nl

Last edited by eon; 12-17-2005 at 07:08 PM. Reason: more information
Reply With Quote
  #6  
Old 12-17-2005, 04:11 PM
tinyblob's Avatar
tinyblob Offline
team pixelpost
 
Join Date: Nov 2005
Location: scotland
Posts: 523
be aware that this addon is going to have to be re-written when 1.5 comes out
__________________
touchnothing.net
Reply With Quote
  #7  
Old 12-17-2005, 06:51 PM
eon's Avatar
eon Offline
pixelpost guru
 
Join Date: Nov 2005
Location: Ned
Posts: 280
Send a message via ICQ to eon
Keeps me off the street
__________________
Northing.nl
Reply With Quote
  #8  
Old 12-18-2005, 07:23 PM
eon's Avatar
eon Offline
pixelpost guru
 
Join Date: Nov 2005
Location: Ned
Posts: 280
Send a message via ICQ to eon
Exclamation

The addon Fastedit version 1 contains a bug.
This code:
PHP Code:
if(!isset($_COOKIE['pixelpost_admin']) && $cfgrow['password'] != $_COOKIE['pixelpost_admin']) {
    
$tpl str_replace("<FAST_EDIT>","",$tpl); //delete <FAST_EDIT> when there is no valid cookie
}else{
    
$fastedit "<a href=\"/pixelpost/admin/index.php?view=images&id=$image_id\">Admin</a>";
    
$tpl str_replace("<FAST_EDIT>",$fastedit,$tpl); //show link


?> 
Must be this code:
PHP Code:
if(!isset($_COOKIE['pixelpost_admin']) || $cfgrow['password'] != $_COOKIE['pixelpost_admin']) {
    
$tpl str_replace("<FAST_EDIT>","",$tpl); //delete <FAST_EDIT> when there is no valid cookie
}else{
    
$fastedit "<a href=\"/pixelpost/admin/index.php?view=images&id=$image_id\">Admin</a>";
    
$tpl str_replace("<FAST_EDIT>",$fastedit,$tpl); //show link


?> 
So "&&" must be "||".

Please replace the code or download the new version here or here.

There is also an Fastedit version for Pixelpost 1.5! You can download it here or here.
__________________
Northing.nl
Reply With Quote
  #9  
Old 12-18-2005, 07:44 PM
unseen's Avatar
unseen Offline
pixelpost guru
 
Join Date: Oct 2005
Location: kentucky-ish
Posts: 110
Send a message via AIM to unseen
awesome addon, eon. thanks!!
__________________
with love, jade


...click
Reply With Quote
  #10  
Old 12-18-2005, 08:10 PM
eon's Avatar
eon Offline
pixelpost guru
 
Join Date: Nov 2005
Location: Ned
Posts: 280
Send a message via ICQ to eon
Quote:
Originally Posted by unseen
awesome addon, eon. thanks!!
No Problem, thank you!
__________________
Northing.nl
Reply With Quote
Post Reply


Thread Tools




All times are GMT. The time now is 08:21 PM.

Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd. | Style Design: d3 designs