Not signed in (Sign In)

Vanilla 1.1.10 is a product of Lussumo. More Information: Documentation, Community Support.

  1.  
    I have installed Plogger 3.0 Beta and am running the gallery from a file outside the install folder. My gallery uses authentication and provides access to members only. I think it is quite reasonable that galleries will not always be displayed from the install folder. There are a few changes necessary to get this to work.


    =========plog-functions.php=========

    This needs to be updated so the picture can be found.

    function plogger_get_source_picture_url() {
    global $config;

    // -------- Added Two lines below -----------------
    $RL = strlen($_SERVER['DOCUMENT_ROOT']);
    $FOLDER = substr(dirname(__FILE__),$RL);

    // -------- Change the Return Value to use folder based on running file not the Config[baseurl] -------
    // return (!empty($config['allow_fullpic'])) ? $config["baseurl"].'images/'.SmartStripSlashes($GLOBALS["current_picture"]["path"]) : "#";
    return (!empty($config['allow_fullpic'])) ? $FOLDER.'/images/'.SmartStripSlashes($GLOBALS["current_picture"]["path"]) : "#";
    }

    function plogger_album_picture_count() {
    if(empty($GLOBALS["current_album"])) return 0; // ---- Modified by adding this line, else error occur when no current_album
    . . .
    }

    ==========plog-globals.php=========
    Before starting a session, you need to check to see if a session has already started. If you have an authentication system, you probably already have it started.
    So, this line needs to be modified:

    //if (!headers_sent())
    if (!headers_sent() and !session_id())
    {
    session_start();
    };

    ==========plog-comment.php==========
    You need to properly redirect to YOUR page when placing comments. Add this line before then header redirect.

    $redirect = $_SERVER['HTTP_REFERER']; //------ added --------
    header("Location: $redirect");
    •  
      CommentAuthorsidtheduck
    • CommentTimeJun 3rd 2008
     
    mvpetrovich,

    Thank you very much for your input and work at testing, finding, & fixing the bugs mentioned above. The development team has already picked up quite a few of these in the current SVN trunk and are getting ready for a post-Beta release soon. See my comments below.

    Posted By: mvpetrovich=========plog-functions.php=========

    This needs to be updated so the picture can be found.

    function plogger_get_source_picture_url() {
    global $config;

    // -------- Added Two lines below -----------------
    $RL = strlen($_SERVER['DOCUMENT_ROOT']);
    $FOLDER = substr(dirname(__FILE__),$RL);

    // -------- Change the Return Value to use folder based on running file not the Config[baseurl] -------
    // return (!empty($config['allow_fullpic'])) ? $config["baseurl"].'images/'.SmartStripSlashes($GLOBALS["current_picture"]["path"]) : "#";
    return (!empty($config['allow_fullpic'])) ? $FOLDER.'/images/'.SmartStripSlashes($GLOBALS["current_picture"]["path"]) : "#";
    }
    This has been picked up in the SVN. The full function code is now:function plogger_get_source_picture_url() {
    global $config;
    return (!empty($config['allow_fullpic'])) ? $config['gallery_url'].'images/'.SmartStripSlashes($GLOBALS["current_picture"]["path"]) : "#";
    }


    Posted By: mvpetrovichfunction plogger_album_picture_count() {
    if(empty($GLOBALS["current_album"])) return 0; // ---- Modified by adding this line, else error occur when no current_album
    . . .
    }
    This has also been picked up. The updated code reads:function plogger_album_picture_count() {
    if (isset($GLOBALS['current_album'])) {
    $row = $GLOBALS['current_album'];
    // XXX: surely this can be optimized?
    $numquery = "SELECT COUNT(*) AS `num_pictures` FROM `".TABLE_PREFIX."pictures` WHERE `parent_album`='".$row['id']."'";
    $numresult = run_query($numquery);
    return mysql_result($numresult, 'num_pictures');
    } else {
    return 0;
    }
    }


    Posted By: mvpetrovich==========plog-globals.php=========
    Before starting a session, you need to check to see if a session has already started. If you have an authentication system, you probably already have it started.
    So, this line needs to be modified:

    //if (!headers_sent())
    if (!headers_sent() and !session_id())
    {
    session_start();
    };
    Nice catch! It looks like this would only be a problem if the php.ini variable 'session.auto_start' is set to true, but your code should work regardless if 'session.auto_start' is set to 'false' or 'true'. I'll go ahead and change this in the SVN for the next release.

    Posted By: mvpetrovich==========plog-comment.php==========
    You need to properly redirect to YOUR page when placing comments. Add this line before then header redirect.

    $redirect = $_SERVER['HTTP_REFERER']; //------ added --------
    header("Location: $redirect");
    Currently, this is somewhat fixed in the SVN, but needs more work. The updated code is:$redirect = str_replace("&","&",generate_url("picture",$parent_id, array(), true));
    // XXX: SLOPPY fix - need more work!
    $redirect = str_replace("plog-comment.php", "", $redirect);
    However, your code works, but sometimes HTTP_REFERRER does not work the way you would expect (some programs like Norton Internet Security strip the HTTP_REFERRER global). It needs some more work, but I would hesitate to use HTTP_REFERRER for everyone (I know it works for you, but it may not work for everyone).

    Thanks again for your suggestions and testing! Keep it up! :D
  2.  
    Thanks for the reply. I am new to Plogger, so please keep that in mind. By the way, I selected Plogger because it is very clean, easy to setup and use, and produces compliant HTML output. It was also easy to track down how things were working. So, for the development team: Great job!

    1) A session would be set, not just with 'session.auto_start', but also with authentication, and sometimes other purposes for a site. I am using this in a members-only section of a site, and that is checked by the session settings. So, I think checking first before starting a new session is a a good thing.

    2) I understand the issues with HTTP_REFERER. HTTPS also does not have a HTTP_REFERER. The only other workarounds that comes to mind is to post to "plog-comment.php?refer=/mypage.php&otherquery" and then if the $_GET['refer'] is set, use it, or set the calling page in a session variable.

    Remember that I am new at this, but it seems to me that 'plog-comment.php' should not really be used as the form action parameter. That is a process-only file. 'plog-comment.php' should be included in 'gallery.php' when the comment submit button is detected. In that case, no redirect would be necessary. (By the way, I would probably not name the submit button "submit," but maybe "submitcomment" so you know what button was clicked. Otherwise you need to check the value. ) I think that would be more clean design.

    Your fix would not work in the site I am working on. That is because I am not using "/plogger/index.php" to generate the gallery. I have my own page in another directory. (That was a feature of Plogger, as I understood it, that you could embed it in any page, which you can with some minor tweaks.)

    Thanks!
    •  
      CommentAuthorsidtheduck
    • CommentTimeJun 5th 2008
     
    I understand that you are new to Plogger, but you make great suggestions! I was just letting you know what "fixes" were already updated since the release of Beta 3.0.

    1) I've added your code to the current SVN trunk, so it will be out with the next release (or you can download it here for testing).

    2) You make some good points. I haven't looked into the comments that much since starting to dig into the code myself, so you are probably more familiar with it than I am. If you come up with anything, let us know! Also, I'll try to take a look as well to see if I can come up with anything too.

    Again, thanks for the suggestions and helping to make Plogger better! It is much appreciated! :D
  3.  
    It is nice to be appreciated. OK, here is a working method for direct processing of comments, without using redirection.

    1) =============== ADD TO gallery.php ===============

    add after: global $config


    //--------- Added to process comments --------
    if (!empty($_POST['comment_post_ID'])) {
    include PLOGGER_DIR.'plog-process-comment.php';
    }


    "comment_post_ID" is only used in the comment form as a hidden variable, so it can be used to tell that you have posted a comment.

    2) ============== CREATE A NEW FILE: plog-process-comment.php ===============

    A new file was created to avoid loss of backward compatibility.


    <?php
    //Created this file from plog-comment.php to be called directly from gallery.php

    // this is our comment script, it simply writes the comment information
    // to our flat-file database and links it to the picture using the pictures id.

    $parent_id = intval($_POST["parent"]);


    // -------- get the URL ---------

    if(!empty($_POST['url'])) {

    if (preg_match('#^http\\:\\/\\/[a-z0-9\-]+\.([a-z0-9\-]+\.)?[a-z]+#i', $_POST['url'])) {
    $url = $_POST['url'];
    }
    elseif (preg_match('#^[a-z0-9\-]+\.([a-z0-9\-]+\.)?[a-z]+#i', $_POST['url'])) {
    $url = 'http://'.$_POST["url"];
    }
    else {
    $url = '';
    }
    } else {
    $url = '';
    }

    // If the captcha is required, check it here
    if ($_SESSION['require_captcha'] == true) {
    if (($_POST['captcha'] != $_SESSION['captcha']) || !$_POST['captcha']) {
    $_SESSION["comment_post_error"] = "CAPTCHA check failed!";
    return; // exit further processing of this file
    }
    }

    $rv = add_comment($parent_id,$_POST["author"],$_POST["email"],$url,$_POST["comment"]);

    if (!empty($rv["errors"])) {
    $_SESSION["comment_post_error"] = $rv["errors"];
    } elseif ($config['comments_moderate']) {
    $_SESSION["comment_moderated"] = 1;
    }

    ?>



    3) ======================= CHANGE THEME comments.php ======================

    The following form tag line needs to be changed as follows:


    <form action="' . htmlentities($_SERVER['REQUEST_URI']) . '" method="post" id="commentform">



    4) ============ Another fix =============
    This may have been a bug in the plog-functions.php file, in the add_comment() function.

    if ($config["comments_moderate"] == 1) {
    $approved = 0;
    $notify_msg = " (awaiting your approval)";
    } else {
    $approved = 1;
    $notify_msg = ''; // --- ADDED, to prevent error
    }


    That is it, I have that working on my site.
    Thankful People: sidtheduck
  4.  
    Another minor thing. People like to use ampersands.

    =================== plog-functions.php ==============


    function plogger_get_picture_caption() {
    if (!empty($GLOBALS["current_picture"]["caption"]))
    return htmlspecialchars(SmartStripSlashes($GLOBALS["current_picture"]["caption"])); // ----- added htmlspecialchars
    else
    return "&nbsp;";
    }