Results 1 to 3 of 3
  1. #1
    Join Date
    May 2009
    Posts
    3
    Plugin Contributions
    0

    application error Notifier trouble

    I'm probably doing something very simple wrong, since I'm a PHP novice. Tell you what - I'll trade an answer to my problem for a quick bash script or Java help, both of which I'm a master of.

    My problem is this - I'm trying to create an observer of the "NOTIFY_DOWNLOAD_VIA_SYMLINK___BEGINS" event. I followed the tutorial, but just cant get my class to run when the event fires.

    First, I had to change the includes/modules/pages/download/header_php.php file like so:

    Code:
      if ($link_create_status==true) {
        $zco_notifier->notify('NOTIFY_DOWNLOAD_VIA_SYMLINK___BEGINS', array(DIR_FS_DOWNLOAD_PUBLIC . $tempdir . '/' . $download_link,DIR_FS_DOWNLOAD . $origin_filename) );
        header("RPGBOMB: Crap");
        header("HTTP/1.1 303 See Other");
        zen_redirect(DIR_WS_DOWNLOAD_PUBLIC . $tempdir . '/' . $download_link);
      }
    Notice the "$zco_notifier" line? Originally, the notify method was only passing the event name 'NOTIFY_DOWNLOAD_VIA_SYMLINK___BEGINS' as an argument. I added the array of the paths I needed from the download process.

    Next. I created the file config.rpgbomb.php in the includes/auto_loaders directory:

    Code:
    <?php
    $autoLoadConfig[10][] = array('autoType'=>'class',
                                  'loadFile'=>'observers/class.checkoutpdf.php');
    $autoLoadConfig[10][] = array('autoType'=>'classInstantiate',
                                  'className'=>'checkoutpdf',
                                  'objectName'=>'checkoutpdf');
    ?>
    I figure the numbers in there for the load order are ok, as I'm not going to be relying on anything other than what gets passed in through the array.

    Last, my class:

    Code:
    <?php
    class checkoutpdf extends base {
      function myObserver() {
        global $zco_notifier;
        $zco_notifier->attach($this, array('NOTIFY_DOWNLOAD_VIA_SYMLINK___BEGINS'));
      }
    
      function update(&$callingClass, $notifier, $paramsArray) {
        #$linkName = $paramsArray[0];
        #header("linkname: " . $linkName);
        #$origName = $paramsArray[1];
        #header("origname: " . $origName);
        header("FACETS: Crap!");
      }
    }
    
    ?>
    I tried to set a header to see if it would appear in the browser response. No dice, but I have no idea if that should work - I just assumed because it's technically procedural code...

    So what I need is just a little help over the hump - maybe a way to show that my the class is actually getting notified. I'm figuring once I can see that, my next move is to use the exec backticks to run a bash script I wrote to process the pdf files before the download happens. That brings up a good question - if I try to run a shell script from PHP - what directory am I in? I mean, if I did something like this:

    PHP Code:
    $output=`touch hereiam.txt`; 
    ...where would the file appear?

    Details of my installation are below:

    Zen Cart 1.3.8a
    Database Patch Level: 1.3.8
    v1.3.8 [2009-05-25 19:03:46] (Fresh Installation)
    v1.3.8 [2009-05-25 19:03:46] (Fresh Installation)
    PHP Version 5.2.6

  2. #2
    Join Date
    Jan 2004
    Posts
    66,446
    Plugin Contributions
    81

    Default Re: Notifier trouble

    1. To trigger a constructor, try changing the first function name to match the class name.
    ie:
    Code:
    function myObserver() {
    to
    Code:
    function checkoutpdf() {
    Or, if you're using PHP 5.x, say function __construct() {

    2. To test whether it's firing, add a command that says the following, inside your update() function:
    Code:
    die('It fired!');
    3. Your current working directory will be wherever your store's main index.php file resides ... ie: the one the browser called. You could run your exec() script and have it echo its current directory to a file whose path you specify, if you want to get more confirmation of that.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  3. #3
    Join Date
    May 2009
    Posts
    3
    Plugin Contributions
    0

    Idea or Suggestion Re: Notifier trouble

    Frickin genius! Figures I'd have a bonehead error in the code. I changed the constructor name to match the class and everything worked out.

    One interesting side effect - before I put the "die('It fired!')" line in the update function of my observer class, like so:
    Code:
      function update(&$callingClass, $notifier, $paramsArray) {
        die('It fired!');
      }
    ... the pdf would just open up in the browser. With the "die" line, the browser actually brings up the download dialog window. I'll have to check on that.

    So what do you want your bash script to do?

 

 

Similar Threads

  1. Notifier question
    By hubert in forum Code Collaboration
    Replies: 19
    Last Post: 8 Feb 2016, 12:42 AM
  2. v151 Notifier help please
    By slobadog in forum General Questions
    Replies: 12
    Last Post: 7 Mar 2013, 11:14 AM
  3. Class notifier usage
    By fe1lho in forum General Questions
    Replies: 1
    Last Post: 6 Oct 2011, 03:35 PM
  4. Notifier subsystem working?
    By birdoasis in forum Contribution-Writing Guidelines
    Replies: 1
    Last Post: 21 Oct 2007, 10:47 PM
  5. Notifier not Found
    By navdeep584 in forum General Questions
    Replies: 1
    Last Post: 9 Jun 2007, 06:09 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg