Pixelpost

Authentic Photoblog Flavour


Go Back   Pixelpost Forum > DEVELOPMENT > Addons

Post Reply
 
Thread Tools
  #31  
Old 08-12-2007, 03:17 PM
Dkozikowski's Avatar
Dkozikowski+ Offline
Team Pixelpost
 
Join Date: Oct 2005
Posts: 1,855
Send a message via AIM to Dkozikowski
OK, so my addon works with php4 and not 5??

Odd as I develop using PHP5 and I have zero issues.

and don't wory about those other warnings. those exist from some really old code that did not get cleaned up. they do not effect the way Pixelpost functions in any way.

We're working to clean the code 100% to get rid of all warnings and notices.

Last edited by Dkozikowski; 08-13-2007 at 04:52 PM.
Reply With Quote
  #32  
Old 08-12-2007, 03:46 PM
StatVoid's Avatar
StatVoid Offline
forum loafer
 
Join Date: Jul 2007
Location: New Jersey
Posts: 17
Send a message via ICQ to StatVoid Send a message via AIM to StatVoid
Lightbulb

That is the case unfortunately, at least in my experience.

Quote:
Originally Posted by dwilkinsjr View Post
OK, so my addon works with php4 and not 5??
That's a relief! Thank you for all the help.

Quote:
Originally Posted by dwilkinsjr View Post
and don't wory about those other warnings. those exist from some really old code that did not get cleaned up. they do not effect the way Pixelpost functions in any way.

We're working to clean the code 100% to get rid of all warnings and notices.
I do have one suggestion/request... Among other things (like just a count of the number of comments an image has), I believe there should be a way for the addon to add something like "Current Rating" alongside the standard Title, Filename, Categories, Tags, etc that are on the Images administration panel. Anything image related should be there. While editing those specific things should be separate, it would be nice to go to the Images section and just be able to see how many comments there are or what the rating is. I dunno, that's just my $.02.
__________________
shuttergap photography
Reply With Quote
  #33  
Old 08-12-2007, 04:09 PM
Dkozikowski's Avatar
Dkozikowski+ Offline
Team Pixelpost
 
Join Date: Oct 2005
Posts: 1,855
Send a message via AIM to Dkozikowski
Quote:
Originally Posted by StatVoid View Post
That is the case unfortunately, at least in my experience.



That's a relief! Thank you for all the help.



I do have one suggestion/request... Among other things (like just a count of the number of comments an image has), I believe there should be a way for the addon to add something like "Current Rating" alongside the standard Title, Filename, Categories, Tags, etc that are on the Images administration panel. Anything image related should be there. While editing those specific things should be separate, it would be nice to go to the Images section and just be able to see how many comments there are or what the rating is. I dunno, that's just my $.02.
Thanks for the good suggestion. Next version.

Last edited by Dkozikowski; 08-13-2007 at 04:52 PM.
Reply With Quote
  #34  
Old 08-12-2007, 08:00 PM
Dkozikowski's Avatar
Dkozikowski+ Offline
Team Pixelpost
 
Join Date: Oct 2005
Posts: 1,855
Send a message via AIM to Dkozikowski


AJAX RATINGS v0.6

Last updated on: August 12th, 2007

VERSION HISTORY
  • Key:
    • [!]Important
    • [+]New
    • [-]Fixed error
    • [*]Changes
  • Version 0.6
    • [+]Added new template tag to display total votes separately from the standard status message.
    • [+]Added new template tag to display total votes cast separately from the standard status message.
    • [+]Added optional admin_ajax_ratings.php addon file so you can view how many ratings each image has within your admin panel.
    • [+]Added new utility to completely erase the ratings data. (useful when testing)
    • [*]Updated User Guide

DOWNLOAD
Also, a "Top Rated" addon to compliment this addon is in the works

Last edited by Dkozikowski; 08-12-2007 at 08:44 PM.
Reply With Quote
  #35  
Old 08-12-2007, 08:57 PM
Ubbe's Avatar
Ubbe Offline
pixelpost guru
 
Join Date: Apr 2006
Location: Denmark
Posts: 151
I get a "500 Internal Server Error" When using any of the tags in my template???
__________________
Best Regards
Ubbe - UbbeDall.dk | Photoblog
Reply With Quote
  #36  
Old 08-12-2007, 09:06 PM
StatVoid's Avatar
StatVoid Offline
forum loafer
 
Join Date: Jul 2007
Location: New Jersey
Posts: 17
Send a message via ICQ to StatVoid Send a message via AIM to StatVoid
Thumbs up

Very nice update. Upgraded immediately!
__________________
shuttergap photography
Reply With Quote
  #37  
Old 08-12-2007, 09:43 PM
Dkozikowski's Avatar
Dkozikowski+ Offline
Team Pixelpost
 
Join Date: Oct 2005
Posts: 1,855
Send a message via AIM to Dkozikowski
Quote:
Originally Posted by Ubbe View Post
I get a "500 Internal Server Error" When using any of the tags in my template???
Ive found some people to have trouble the the regular expressions being used in my addons. So I commented them out to see if that helps you.

Open the ajax_ratings.php addon file and replace all the text with the following.

PHP Code:
<?php
/*

Written  by: Dwilkinsjr
Written for: Pixelpost 1.6.0 www: http://www.pixelpost.org/
Based on: Unobtrusive AJAX Star Rating Bar ( http://www.masugadesign.com/the-lab/scripts/unobtrusive-ajax-star-rating-bar )
By: Ryan Masuga

    <!--
     
          __         _ ____   _              _
     ____/ /      __(_) / /__(_)___  _____  (_)____
    / __  / | /| / / / / //_/ / __ \/ ___/ / / ___/    AJAX RATINGS v0.6
   / /_/ /| |/ |/ / / / ,< / / / / (__  ) / / /        LAST UPDATED - AUG/12/2007
   \__,_/ |__/|__/_/_/_/|_/_/_/ /_/____/_/ /_/
                 http://dwilkinsjr.com/___/
                                       
                                       
    -->

Contact: dwilkinsjr@dwilkinsjr.com
Copyright (c) 2007 <http://wwww.dwilkinsjr.com>

License: http://www.gnu.org/copyleft/gpl.html

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.

*/

$addon_name "<a name=\"ajaxRate\"></a>Ajax Ratings";
$addon_version "0.6";
$addon_description "Ajax Ratings allows your visitors to rate your photos based on a scale of 1 to 10 or anywhere in between using the power of degradable ajax.<br /><br />Please read the <a href=\"../includes/ajaxRating/readmeUserGuide.html\">Ajax Rating User Guide</a> for full installation and configuration instructions.<br /><br />New tag: <code>&lt;AJAX_RATE&gt;</code><br /><br />ADDON Author: Dwilkinsjr (<a href='http://www.dwilkinsjr.com/myaddons' target='_blank'>dwilkinsjr.com</a>) (<a href=\"http://versioncheckr.com/38/".$addon_version."/\">Check for updates</a>)";


/**
 * Only run when the template tag is found on page
 *
 */
if(preg_match("<AJAX_RATE.*?>"$tpl)) {

    
/**
     * Match ALL parameters, not just the first one
     *
     *
     preg_match("/<AJAX_RATE\s*((.*?(<.*?>)?)*)\s*>/s", $tpl, $arg_string);
     $arg_string = $arg_string[1];

     while($arg_string != "") {
     
         preg_match("/^(.*?)=('|\")?(.*?)\\2\s*(.*)$/s", $arg_string, $out);
         
         $args[$out[1]] =  $out[3];
          $arg_string    =  $out[4];
     }*/
     
     /**
      * Set defaults
      *
      */
     
$stars     =  "5";
     
$imgwidth  =  "30";
     
$info      =  "on";
     
$thankyou  =  "on";
     
     
     
/**
      * Get arguments if set. If not, use default
      *
      *
     if($args['stars']) {
         $stars = $args['stars'];
         $stars = eregi_replace('[^0-9]+','',$stars);
     }
     if($args['img_width']) {
         $imgwidth = $args['img_width'];
         $imgwidth = eregi_replace('[^0-9]+','',$imgwidth);
     }
     if($args['rate_info']) {
         $info = $args['rate_info'];
         $info = eregi_replace('[^a-z]+','',$info);
     }
     if($args['thankyou']) {
         $thankyou = $args['thankyou'];
         $thankyou = eregi_replace('[^a-z]+','',$thankyou);
     }*/
     
     
    /**
     * Determine what kind of rating info needs to be displayed
     *
     */
    
if ($thankyou == "on" && $info == "on") { $info "1"; } else if ($thankyou == "off" && $info == "on") { $info "2"; } else if ($thankyou == "on" && $info == "off") { $info "3"; } else { $info "0"; }


    
/**
     * Check to see if the ajaxRatings table exists, if not, create it
     *
     */
    
$query mysql_query("SELECT `total_votes` FROM `".$pixelpost_db_prefix."ajaxRatings` LIMIT 1");
    
    if (!
$query) { mysql_query("CREATE TABLE `".$pixelpost_db_prefix."ajaxRatings` (`id` INT NOT NULL AUTO_INCREMENT,PRIMARY KEY(id),`img_id` INT(11) NOT NULL,`total_votes` INT(11) NOT NULL,`total_value` INT(11) NOT NULL,`used_ips` LONGTEXT NOT NULL)") or die(" Error: ".mysql_error()); }
    
    
    
$ip $_SERVER['REMOTE_ADDR'];
    
    
$query mysql_query("SELECT * FROM `".$pixelpost_db_prefix."ajaxRatings` WHERE `img_id` = '$image_id'");
    
    if (!
mysql_num_rows($query)) {
    
        
$query mysql_query("INSERT INTO `".$pixelpost_db_prefix."ajaxRatings` (`img_id`, `total_votes`, `total_value`, `used_ips`) VALUES ('$image_id', '0', '0', '')");
        
$query mysql_query("SELECT * FROM `".$pixelpost_db_prefix."ajaxRatings` WHERE `img_id` = '$image_id'");
    }
    
    
$row   mysql_fetch_assoc($query);
    
    
$count          $row['total_votes'];
    
$current_rating $row['total_value'];
    
    
$total_votes    = @number_format($current_rating/$count,1);
    
    
$tense          = ($count == 1) ? "vote" "votes";
    
    
$voted mysql_num_rows(mysql_query("SELECT `used_ips` FROM `".$pixelpost_db_prefix."ajaxRatings` WHERE `used_ips` LIKE '%$ip%' AND `img_id` = '$image_id'")); 
    
    
$ajax_rate "
    <div class=\"ratingblock\">
    <div id=\"unit_long$image_id\" align=\"center\">
    
    <ul id=\"unit_ul$image_id\" class=\"unit-rating\" style=\"width:"
.$imgwidth*$stars."px;\">
    
    <li class=\"current-rating\" style=\"width:"
.@number_format($current_rating/$count,2)*$imgwidth."px;\">Currently ".@number_format($current_rating/$count,2)."/".$stars."></li>\n";
    
    for (
$ncount 1$ncount <= $stars$ncount++) {
    
        if(!
$voted) { $ajax_rate .= "<li><a href=\"includes/ajaxRating/db.php?j=$ncount&amp;q=$image_id&amp;t=$ip&amp;c=$stars&amp;r=$info&amp;i=$imgwidth&amp;n=$vinfo_name\" class=\"r".$ncount."-unit rater\" rel=\"nofollow\">$ncount</a></li>\n"; }
    }
    
    
$ncount 0;
    
    if (
$info == "1" || $info == "2") { $info "Rating: <strong>$total_votes</strong>/$stars ($count $tense cast)"; } else { $info ""; }
    
    
$ajax_rate .= "
    </ul>
    
    $info
    
    </div>
    </div>"
;
    
    
$total_votes_ajax "<div id=\"total_votes$image_id\">$total_votes</div>";
    
    
$total_votes_cast_ajax "<div id=\"total_votes_cast$image_id\">$count $tense cast</div>";
    
    
/**
     * Ajax Rate template tag
     *
     *
    $tpl = preg_replace("/<AJAX_RATE\s*((.*?(<.*?>)?)*)\s*>/", $ajax_rate, $tpl);*/
    
$tpl ereg_replace("<AJAX_RATE>"$ajax_rate$tpl);
    
    
$tpl ereg_replace("<TOTAL_VOTES_AJAX_RATE>",$total_votes_ajax,$tpl);
    
    
$tpl ereg_replace("<TOTAL_VOTES_CAST_AJAX_RATE>",$total_votes_cast_ajax,$tpl);
}
?>
Use the template tags <AJAX_RATE> / <TOTAL_VOTES_AJAX_RATE> / <TOTAL_VOTES_CAST_AJAX_RATE>


I'm off to a concert now so report back and i'll check in the morning.

Good luck!
Reply With Quote
  #38  
Old 08-13-2007, 12:39 PM
Dkozikowski's Avatar
Dkozikowski+ Offline
Team Pixelpost
 
Join Date: Oct 2005
Posts: 1,855
Send a message via AIM to Dkozikowski
Ubbe, I noticed you got the ratings to display. Was it because of the code changes i listed above?

I also noticed the lack of AJAXy goodness. Try placing the JS code right before the </head> tag or at least after all the other JS stuff. I think there might be a conflict with some prototype / mootools stuff and i'll update that in the next release.
Reply With Quote
  #39  
Old 08-13-2007, 01:32 PM
Ubbe's Avatar
Ubbe Offline
pixelpost guru
 
Join Date: Apr 2006
Location: Denmark
Posts: 151
Quote:
Originally Posted by dwilkinsjr View Post
Ubbe, I noticed you got the ratings to display. Was it because of the code changes i listed above?

I also noticed the lack of AJAXy goodness. Try placing the JS code right before the </head> tag or at least after all the other JS stuff. I think there might be a conflict with some prototype / mootools stuff and i'll update that in the next release.
Yep the code above made the difference.

I tried placing the scripts as the last things now.
__________________
Best Regards
Ubbe - UbbeDall.dk | Photoblog
Reply With Quote
  #40  
Old 08-13-2007, 02:38 PM
Dkozikowski's Avatar
Dkozikowski+ Offline
Team Pixelpost
 
Join Date: Oct 2005
Posts: 1,855
Send a message via AIM to Dkozikowski
Quote:
Originally Posted by Ubbe View Post
Yep the code above made the difference.

I tried placing the scripts as the last things now.
Great, well everything seems to be working 100% for you now.

I need to get to the bottom of the regular expression issue though.


Since you are one of a handful of people experiencing problems, would you be willing to test for me or give me temporary FTP access so i can test out various modifications?

I'm going to private message you some test code to try, if you don't mind that is.

[Edit]
Scratch the private message. The message was too long so it wouldn't send.

If you can, replace your current working code with the following.

If the following fails to work, just go back to using the old working code.

Let me know the outcome. Thanks!

PHP Code:
<?php
/*

Written  by: Dwilkinsjr
Written for: Pixelpost 1.6.0 www: http://www.pixelpost.org/
Based on: Unobtrusive AJAX Star Rating Bar ( http://www.masugadesign.com/the-lab/scripts/unobtrusive-ajax-star-rating-bar )
By: Ryan Masuga

    <!--
     
          __         _ ____   _              _
     ____/ /      __(_) / /__(_)___  _____  (_)____
    / __  / | /| / / / / //_/ / __ \/ ___/ / / ___/    AJAX RATINGS v0.6
   / /_/ /| |/ |/ / / / ,< / / / / (__  ) / / /        LAST UPDATED - AUG/12/2007
   \__,_/ |__/|__/_/_/_/|_/_/_/ /_/____/_/ /_/
                 http://dwilkinsjr.com/___/
                                       
                                       
    -->

Contact: dwilkinsjr@dwilkinsjr.com
Copyright (c) 2007 <http://wwww.dwilkinsjr.com>

License: http://www.gnu.org/copyleft/gpl.html

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.

*/

$addon_name "<a name=\"ajaxRate\"></a>Ajax Ratings";
$addon_version "0.6";
$addon_description "Ajax Ratings allows your visitors to rate your photos based on a scale of 1 to 10 or anywhere in between using the power of degradable ajax.<br /><br />Please read the <a href=\"../includes/ajaxRating/readmeUserGuide.html\">Ajax Rating User Guide</a> for full installation and configuration instructions.<br /><br />New tag: <code>&lt;AJAX_RATE img_width=\"30px\" stars=\"5\" rate_info=\"on\" thankyou=\"on\"&gt;</code><br /><br />ADDON Author: Dwilkinsjr (<a href='http://www.dwilkinsjr.com/myaddons' target='_blank'>dwilkinsjr.com</a>) (<a href=\"http://versioncheckr.com/38/".$addon_version."/\">Check for updates</a>)";


/**
 * Only run when the template tag is found on page
 *
 */
if(preg_match("<AJAX_RATE.*?>"$tpl)) {

    
/**
     * Match ALL parameters, not just the first one
     *
     */
     
preg_match("/<AJAX_RATE\s*(.*?)\s*>/s"$tpl$arg_string);/* preg_match("/<AJAX_RATE\s*((.*?(<.*?>)?)*)\s*>/s", $tpl, $arg_string); */
     
$arg_string $arg_string[1];

    echo 
'<pre>';
    
var_dump($arg_string);
    echo 
'</pre>';

     while(
$arg_string != "") {
     
         
preg_match("/^(.*?)=('|\")?(.*?)\\2\s*(.*)$/s"$arg_string$out);
         
         
$args[$out[1]] =  $out[3];
          
$arg_string    =  $out[4];
     }
     
     echo 
'<pre>';
     
var_dump($args);
     echo 
'</pre>';
     
     
/**
      * Set defaults
      *
      */
     
$stars     =  "5";
     
$imgwidth  =  "30";
     
$info      =  "on";
     
$thankyou  =  "on";
     
     
     
/**
      * Get arguments if set. If not, use default
      *
      */
     
if($args['stars']) {
         
$stars $args['stars'];
         
$stars eregi_replace('[^0-9]+','',$stars);
     }
     if(
$args['img_width']) {
         
$imgwidth $args['img_width'];
         
$imgwidth eregi_replace('[^0-9]+','',$imgwidth);
     }
     if(
$args['rate_info']) {
         
$info $args['rate_info'];
         
$info eregi_replace('[^a-z]+','',$info);
     }
     if(
$args['thankyou']) {
         
$thankyou $args['thankyou'];
         
$thankyou eregi_replace('[^a-z]+','',$thankyou);
     }
     
     
    
/**
     * Determine what kind of rating info needs to be displayed
     *
     */
    
if ($thankyou == "on" && $info == "on") { $info "1"; } else if ($thankyou == "off" && $info == "on") { $info "2"; } else if ($thankyou == "on" && $info == "off") { $info "3"; } else { $info "0"; }


    
/**
     * Check to see if the ajaxRatings table exists, if not, create it
     *
     */
    
$query mysql_query("SELECT `total_votes` FROM `".$pixelpost_db_prefix."ajaxRatings` LIMIT 1");
    
    if (!
$query) { mysql_query("CREATE TABLE `".$pixelpost_db_prefix."ajaxRatings` (`id` INT NOT NULL AUTO_INCREMENT,PRIMARY KEY(id),`img_id` INT(11) NOT NULL,`total_votes` INT(11) NOT NULL,`total_value` INT(11) NOT NULL,`used_ips` LONGTEXT NOT NULL)") or die(" Error: ".mysql_error()); }
    
    
    
$ip $_SERVER['REMOTE_ADDR'];
    
    
$query mysql_query("SELECT * FROM `".$pixelpost_db_prefix."ajaxRatings` WHERE `img_id` = '$image_id'");
    
    if (!
mysql_num_rows($query)) {
    
        
$query mysql_query("INSERT INTO `".$pixelpost_db_prefix."ajaxRatings` (`img_id`, `total_votes`, `total_value`, `used_ips`) VALUES ('$image_id', '0', '0', '')");
        
$query mysql_query("SELECT * FROM `".$pixelpost_db_prefix."ajaxRatings` WHERE `img_id` = '$image_id'");
    }
    
    
$row   mysql_fetch_assoc($query);
    
    
$count          $row['total_votes'];
    
$current_rating $row['total_value'];
    
    
$total_votes    = @number_format($current_rating/$count,1);
    
    
$tense          = ($count == 1) ? "vote" "votes";
    
    
$voted mysql_num_rows(mysql_query("SELECT `used_ips` FROM `".$pixelpost_db_prefix."ajaxRatings` WHERE `used_ips` LIKE '%$ip%' AND `img_id` = '$image_id'")); 
    
    
$ajax_rate "
    <div class=\"ratingblock\">
    <div id=\"unit_long$image_id\" align=\"center\">
    
    <ul id=\"unit_ul$image_id\" class=\"unit-rating\" style=\"width:"
.$imgwidth*$stars."px;\">
    
    <li class=\"current-rating\" style=\"width:"
.@number_format($current_rating/$count,2)*$imgwidth."px;\">Currently ".@number_format($current_rating/$count,2)."/".$stars."></li>\n";
    
    for (
$ncount 1$ncount <= $stars$ncount++) {
    
        if(!
$voted) { $ajax_rate .= "<li><a href=\"includes/ajaxRating/db.php?j=$ncount&amp;q=$image_id&amp;t=$ip&amp;c=$stars&amp;r=$info&amp;i=$imgwidth&amp;n=$vinfo_name\" class=\"r".$ncount."-unit rater\" rel=\"nofollow\">$ncount</a></li>\n"; }
    }
    
    
$ncount 0;
    
    if (
$info == "1" || $info == "2") { $info "Rating: <strong>$total_votes</strong>/$stars ($count $tense cast)"; } else { $info ""; }
    
    
$ajax_rate .= "
    </ul>
    
    $info
    
    </div>
    </div>"
;
    
    
$total_votes_ajax "<div id=\"total_votes$image_id\">$total_votes</div>";
    
    
$total_votes_cast_ajax "<div id=\"total_votes_cast$image_id\">$count $tense cast</div>";
    
    
/**
     * Ajax Rate template tag
     *
     */
    
$tpl preg_replace("/<AJAX_RATE\s*(.*?)\s*>/"$ajax_rate$tpl);
    
/* $tpl = preg_replace("/<AJAX_RATE\s*((.*?(<.*?>)?)*)\s*>/", $ajax_rate, $tpl); */
    
    
$tpl ereg_replace("<TOTAL_VOTES_AJAX_RATE>",$total_votes_ajax,$tpl);
    
    
$tpl ereg_replace("<TOTAL_VOTES_CAST_AJAX_RATE>",$total_votes_cast_ajax,$tpl);
}
?>
Reply With Quote
Post Reply


Thread Tools




All times are GMT. The time now is 04:54 AM.

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