custom redirect script not woking after move

Discussion in 'Integration' started by ccwjames, Mar 10, 2016.

  1. ccwjames

    ccwjames Member

    Joined:
    Sep 11, 2014
    Messages:
    430
    i moved my amember from var/www/html/
    to var/www/html/Membership

    I have a script that onces paid you are taken back (thanks redirect) that took you to a page to make a serial number for your membership. ( can also been used from a button at top of profile )

    now when i click it, i get the message i had before and a drop down asking what kind of line/serial

    but when before i had a message and the code, its not there.

    here is the code in my site.php..............i should add now on 5.03

    PHP:
    <?php

    require_once __DIR__ '/../../library/Am/Lite.php';

    Am_Di::getInstance()->hook->add(Am_Event::USER_AFTER_INSERT'onUserAfterInsert');
    function 
    onUserAfterInsert(Am_Event $event){
      
    $user $event->getUser();
      
    $di Am_Di::getInstance();
      
    $ticket $di->helpdeskTicketRecord;
      
    $ticket->created $ticket->updated sqlTime('now');
      
    $ticket->user_id $user->user_id;
      
    $ticket->status HelpdeskTicket::STATUS_AWAITING_USER_RESPONSE;
      
    // TICKET SUBJECT
      
    $ticket->subject 'Welcome User, Please read '.$user->name_f.' '.$user->name_l;
      
    $ticket->insert();
      
    $message $di->helpdeskMessageRecord;
      
    $message->dattm sqlTime('now');
      
    $message->admin_id 1// ADMIN ID
      // TICKET BODY
      
    $message->content =  'Welcome Please READ & close when read!

    Removed as a welcome note about membership

    please close this to confirm have read this message'
    ;
      
    $message->ticket_id $ticket->ticket_id;
      
    $message->insert();
    }

    // Redirect to custom page on purchase
    Am_Di::getInstance()->hook->add(Am_Event::THANKS_PAGE'onThanksPage');
    function 
    onThanksPage(Am_Event $event){
    /* @var $di Am_Di */
    $di Am_Di::getInstance();
    /* @var $invoice Invoice */
    $invoice $event->getInvoice();
    /* @var $controller ThanksController */
    $controller $event->getController();

    $controller->redirectLocation('/compsetup');
    }

    // Exec C/N script
    Am_Di::getInstance()->hook->add(Am_Event::USER_MENU'myAddMenuItem');
    function 
    myAddMenuItem(Am_Event $event)
    {
      
    $menu $event->getMenu();
      
    $menu->addPage(
      array(
      
    'id' => 'compsetup-id',
      
    'controller' => 'compsetup',
      
    'module' => 'default',
      
    'label' => "Line Generator",
      
    'order' => 500
      
    ));
    }
    class 
    CompsetupController extends Am_Controller // a Zend_Controller_Action successor
    {
      function 
    indexAction()
      {
      
    $user $this->getDi()->user//currently authenticated customer or throws exception if no auth
      
    $this->view->title "Line Generator";
      
    $this->view->content doScriptExec();
      
    $this->view->display('layout.phtml');
      }
    }

    function 
    doScriptExec() {
    // Get list of used products
    $prodids file_get_contents(__DIR__ "/used_products.txt");
    $name Am_Lite::getInstance()->getName();
    foreach (
    Am_Lite::getInstance()->getAccess() as $a) {
      if ((
    strtotime($a['expire_date']) > strtotime("today")) && (!strstr($prodids" - $a[access_id]\n"))) {
      
    $access_id $a['access_id'];
      
    $prod_id $a['product_id'];
       
    $user_id $a['user_id'];
      
    $expiry $a['expire_date'];
      
    $begin $a['begin_date'];
      }
    }

    // Get product name
    $prod_name =  Am_Lite::getInstance()->getProducts()[$prod_id];

    // Check that the user has a valid product
      
    if (!$access_id) return "<p style=\"color: RED;\">You have already generated a code for a connection or have not bought a membership.<br >
    If this you feel is an error, please email the site owner or open a helpdesk ticket.</p>"
    ;
      if (!
    $_REQUEST['corn']) {
       
    # View readme.txt for alternative dropdown config
       
    $pagetext '<div id="codegen">
          Generate a line for ' 
    $prod_name .
          
    '<form method="post" action="#">
          <select name="corn">
          <option value="c">C</option>      
          </select><input name="duration" type="hidden" value="' 
    $dur '" /><input type="submit" value="Setup" /></form>
          <div class="banner-ad" style="width: 100%; margin-top: 100px; margin-left: auto; margin-right: auto; text-align: center;">
           <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
           <!-- Newlinehome1 -->
           <ins class="adsbygoogle"
            style="display:inline-block;width:468px;height:60px"
            data-ad-client="ca-pub-3636828534890895"
            data-ad-slot="7801854901"></ins>
           <script>
           (adsbygoogle = window.adsbygoogle || []).push({});
           </script>
          </div><!-- /banner-ad -->
          </div><!-- /codegen -->'
    ;
       return 
    $pagetext;
      } else {
      
    $arg $_REQUEST['corn'];

       
    // Set a line in the used_products.txt file
      
    $prodids $prodids "User: $user_id Begin: $begin Exp: $expiry IP: $_SERVER[REMOTE_ADDR] - $access_id\n";
      
    file_put_contents(__DIR__ "/used_products.txt"$prodids);
      
       
    // Run the script and display results on-screen
       
    $scriptout shell_exec(__DIR__ "/codegen $arg $expiry $user_id \"$name\"");
       
    $pagetext '<div id="codegen">' .
          
    $scriptout .
          
    '<div class="banner-ad" style="width: 100%; margin-top: 100px; margin-left: auto; margin-right: auto; text-align: center;">
           <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
           <!-- Newlinehome1 -->
           <ins class="adsbygoogle"
            style="display:inline-block;width:468px;height:60px"
            data-ad-client="ca-pub-3636828534890895"
            data-ad-slot="7801854901"></ins>
           <script>
           (adsbygoogle = window.adsbygoogle || []).push({});
           </script>
          </div><!-- /banner-ad -->
          </div><!-- /codegen -->'
    ;
       return 
    $pagetext;
      }
    }
    i cant see if moving to a subfolder would change it as it users dir /
    or could it be a httacess rewrite thing?
  2. ccwjames

    ccwjames Member

    Joined:
    Sep 11, 2014
    Messages:
    430
    no strange not touched a thing and working out of the blue
  3. caesar

    caesar aMember Pro Developer Staff Member

    Joined:
    Oct 16, 2009
    Messages:
    1,669
    There is some API changes in 5.0 that cause this errors.

    1. replace
    Code:
    Am_Controller
    with
    Code:
    Am_Mvc_Controller
    2. replace
    Code:
    $controller = $event->getController();
    $controller->redirectLocation('/compsetup');
    with
    Code:
    Am_Mvc_Response::redirectLocation('/compsetup');
  4. ccwjames

    ccwjames Member

    Joined:
    Sep 11, 2014
    Messages:
    430
    will change later, but out of the blue without touching nothing, 30 mins later it worked
  5. ccwjames

    ccwjames Member

    Joined:
    Sep 11, 2014
    Messages:
    430
    well stopped working when added to 5.0.5
  6. ccwjames

    ccwjames Member

    Joined:
    Sep 11, 2014
    Messages:
    430
    sorted, was a bash thing

Share This Page