Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 21
  1. #11
    Join Date
    Apr 2004
    Location
    vienna
    Posts
    198
    Plugin Contributions
    9

    Default Re: Admin auto login for a cron job

    Quote Originally Posted by Robbie_79 View Post
    I have the Admin Profiles addon installed, maybe thats whats makes the difference?
    yes, this makes a great difference

    1) if you have one, you have to edit /admin/init_includes/overrides/init_admin_auth.php in the same way as /admin/init_includes/init_admin_auth.php

    2) you have to create an admin user with id==13 ( define('CRON_ADMIN_USER_ID', '13'); ); I did it via phpMyAdmin

    3) you must grant permissions to admin-user 13 for the cron1.php via admin/admin_control.php?adminID=13

    4) logout & try it via web-browser

    5) now the cron-world should be OK

  2. #12
    Join Date
    Oct 2008
    Location
    Netherlands
    Posts
    26
    Plugin Contributions
    0

    Default Re: Admin auto login for a cron job

    aah great.
    If I only checked the AdminProfiles installation for overrides a bit earlyer

    thanks Hugo! u were a great help to me ;)

    Any particular reason you choose ID 13 for cron_user?

  3. #13
    Join Date
    Apr 2004
    Location
    vienna
    Posts
    198
    Plugin Contributions
    9

    Default Re: Admin auto login for a cron job

    Quote Originally Posted by Robbie_79 View Post
    Any particular reason you choose ID 13 for cron_user?
    NO, it's only the number in the name

  4. #14
    Join Date
    Apr 2009
    Posts
    5
    Plugin Contributions
    0

    Idea or Suggestion Re: Admin auto login for a cron job

    Thanks for this, very useful.

    To further secure it and avaoid people being eble to get to the admin without authentication I added:

    if ($_SERVER['REMOTE_ADDR'] == $_SERVER['SERVER_ADDR']) {
    define('CRON_ADMIN_USER_ID', '999');
    }

    So that only local scripts would be let through

  5. #15
    Join Date
    Nov 2009
    Posts
    11
    Plugin Contributions
    0

    Default Re: Admin auto login for a cron job

    Wouldn't it be better to put this test in:
    /admin/includes/init_includes/overrides/init_admin_auth.php
    rather than the script for the cron job?
    Then if you make any future cron jobs they will have to be called locally too.

  6. #16
    Join Date
    Oct 2007
    Location
    Stow on the Wold, in the Cotswolds - England
    Posts
    13
    Plugin Contributions
    0

    Default Re: Admin auto login for a cron job

    Dr Byte's solution works well for me but I thought I'd add a little caveat which might save somebody some time.

    If you run your php program directly as a cron job it won't have the right working directory and won't find /includes/config.php so it will fail with;
    ERROR: admin/includes/configure.php file not found. Suggest running zc_install/index.php?
    To avoid this you need to tell cron to change directory before invoking PHP to run the program, so your cron command should read
    Code:
    cd "public_html/admin"; /usr/local/bin/php my_program.php
    Remember to leave a space between your path to PHP and the program name, you are invoking PHP with the program name as a parameter.

    I hope this helps someone.
    [FONT="Verdana"]cotsweb.com[/FONT]

  7. #17
    Join Date
    Jan 2007
    Posts
    7
    Plugin Contributions
    0

    Default Re: Admin auto login for a cron job

    Hi Hugo...

    I am unclear on what needs to be added to the init_admin_auth.php file in your example do I just need to define the CRON_ADMIN_USER_ID?

    I have already added one to the database via SQL so now I just need to figure out this part and I am golden.

    Thanks in advance.
    Got toast!

  8. #18
    Join Date
    Jan 2012
    Posts
    15
    Plugin Contributions
    0

    Default Re: Admin auto login for a cron job

    hey - I'm trying to get a cron job to work too now. I keep getting an error in sessions.php so I'm guessing it is failing at authenticating the user or something. Anyone still around that knows how to do this and can help? I'm desperate for help!

  9. #19
    Join Date
    Jan 2012
    Posts
    15
    Plugin Contributions
    0

    Default Re: Admin auto login for a cron job

    Everyone - I got this working too with donothing's help! He/She rocks! This is making a huge difference for me and I greatly appreciate it.

  10. #20
    Join Date
    Oct 2004
    Posts
    1,045
    Plugin Contributions
    0

    Default Re: Admin auto login for a cron job

    Quote Originally Posted by DrByte View Post
    Here's one approach, which has basic security around it. You can enhance it further if you wish, but this should work as-is:

    1. In your cron PHP script that calls application_top, put this *before* the call to application_top:
    *snip*

    2. In your /admin/init_includes/init_admin_auth.php script, add the new lines as shown below:
    **snip**
    I tried this, but in the e-mail that I get when the cron runs, it says this:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>***</title> <link href="includes/stylesheet.css" rel="stylesheet" type="text/css" /> <meta name="robot" content="noindex, nofollow" /> </head> <body id="login" onload="document.getElementById('admin_name').focus()">
    <form name="login" action="https://www.***.com/storemanager/login.php?zenAdminID=9s5nqcqspgpfgd5v3vls43lor5" method="post">
    <fieldset>
    <legend>Admin Login</legend>
    <label class="loginLabel" for="admin_name">Admin Username:</label> <input style="float: left" type="text" id="admin_name" name="admin_name" value="" /> <br class="clearBoth" />
    <label class="loginLabel" for="admin_pass">Admin Password:</label> <input style="float: left" type="password" id="admin_pass" name="admin_pass" value="" /> <br class="clearBoth" />
    <input type="hidden" name="securityToken" value="bcbc7b1f6748bb93cb3aae681b130bfd">
    <input type="submit" name="submit" class="button" value="Login" />
    <a style="float: right;" href="https://www.***.com/storemanager/password_forgotten.php?zenAdminID=9s5nqcqspgpfgd5v3vls43lor5">Resend Password</a> </fieldset> </form> </body> </html>
    Is there something else I can try?
    Danielle

 

 
Page 2 of 3 FirstFirst 123 LastLast

Similar Threads

  1. cron job for Recover Cart Sale add-on
    By pdxdoug in forum All Other Contributions/Addons
    Replies: 1
    Last Post: 19 Sep 2015, 02:18 AM
  2. Can I use an auto Import/cron job for this?
    By KNM Computers in forum Templates, Stylesheets, Page Layout
    Replies: 28
    Last Post: 31 Jul 2013, 08:08 PM
  3. Setting up a cron job for the Snapshot add-on?
    By RescoCCC in forum All Other Contributions/Addons
    Replies: 11
    Last Post: 3 Jan 2012, 06:19 PM
  4. Cron Job for Optimize Database
    By Convergence in forum General Questions
    Replies: 4
    Last Post: 24 Jan 2011, 09:36 PM
  5. Cron Job for Updating QTY
    By ryanb4614 in forum General Questions
    Replies: 2
    Last Post: 9 Aug 2010, 07:13 AM

Bookmarks

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
Zen-Cart, Internet Selling Services, Klamath Falls, OR