Results 1 to 5 of 5

Hybrid View

  1. #1
    Join Date
    Jun 2008
    Location
    Oregon
    Posts
    60
    Plugin Contributions
    0

    Default Running custom admin scripts from PHP CLI?

    What I want to do: Run a php script in an endless loop from command line (using nohup). The script makes some images with GD library, and takes a while to execute-- running from a browser is too slow.

    What it does: It will correctly tell that it is running from CLI and do echo's and other stuff. Then it hits a zen constant, like DIR_WS_CLASSES and spits out a message that it can't find that file.
    If I try to load application_top.php it stops execution, and leaves no errors or warnings (that I can find).

    Any php guru's have a tip or place to look?

    Thanks again!
    NiceBadge.com Lifetime guarantee on all badges! Free mock ups, 24 hour turn around time!

  2. #2
    Join Date
    Jan 2004
    Posts
    66,443
    Plugin Contributions
    279

    Default Re: Running custom admin scripts from PHP CLI?

    It's probably croaking because your CLI isn't aware of the current path/cwd and thus isn't able to use those relative paths to find required resources. Fix your CLI ability to know where it's working from and use the appropriate includes_path, and you will likely have more success.

    Although, why are you even loading application_top anyway? What specific Zen Cart capability do you need if you're making GD images?
    .

    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
    Jun 2008
    Location
    Oregon
    Posts
    60
    Plugin Contributions
    0

    Default Re: Running custom admin scripts from PHP CLI?

    Quote Originally Posted by DrByte View Post
    It's probably croaking because your CLI isn't aware of the current path/cwd and thus isn't able to use those relative paths to find required resources. Fix your CLI ability to know where it's working from and use the appropriate includes_path, and you will likely have more success.

    Although, why are you even loading application_top anyway? What specific Zen Cart capability do you need if you're making GD images?
    The rest of the mod is an admin page that allows modifying/creating the images. I was trying to off-load that time spent in GD to be processed separately, with Zend_Queue to be specific.
    Since it started as a zen cart admin module, most of the code I wrote has a lot of defines I wrote in the zen cart style. Mainly paths for images, and database tables.
    I'll see what I can do with your suggestions.
    NiceBadge.com Lifetime guarantee on all badges! Free mock ups, 24 hour turn around time!

  4. #4
    Join Date
    Jun 2008
    Location
    Oregon
    Posts
    60
    Plugin Contributions
    0

    Default Re: Running custom admin scripts from PHP CLI?

    I figured it out.
    The problem went away when I commented out line 210 or so in core.config.php. This is breakpoint 150, and requires init_admin_auth.php.

    I did this in an override....
    PHP Code:

     
    if(!defined('STDIN') ){
       
    $autoLoadConfig[150][] = array('autoType'=>'init_script',
                                     
    'loadFile'=> 'init_admin_auth.php');
     } 
    And everything seems hunky-dorie!

    Thanks again for your help, your advice on the directories was invaluable.
    NiceBadge.com Lifetime guarantee on all badges! Free mock ups, 24 hour turn around time!

  5. #5
    Join Date
    Jan 2004
    Posts
    66,443
    Plugin Contributions
    279

    Default Re: Running custom admin scripts from PHP CLI?

    Um ... be VERY careful there!!!!
    If you skip running init_admin_auth then you have NO security on your admin logins!

    I see you're using STDIN as a qualifier, which provides some measure of safety. But ANYBODY READING THIS DISCUSSION SHOULD USE *EXTREME* CAUTION when making such changes!!!!!!!!
    .

    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.

 

 

Similar Threads

  1. Replies: 0
    Last Post: 21 Jul 2012, 09:48 AM
  2. custom php scripts
    By warroyo90 in forum General Questions
    Replies: 0
    Last Post: 16 Jun 2012, 12:56 AM
  3. admin/categories.php running super slow...
    By ajlisowski in forum General Questions
    Replies: 13
    Last Post: 30 Jul 2010, 06:15 PM
  4. Custom php search scripts
    By neit in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 10 Feb 2010, 10:23 AM

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