• Resolved Julian

    (@julianarnold)


    I can’t get the Mage.php address to accept in the settings/mage enabler page in wp-admin. I have added the app/code/local/Mage/Core/functions.php file and changed the translate block.

    My wp install is on the same server as my magento installation, and I have modified the open_basedir restrictions to that the magento installation is accessable: I am trying to use /var/www/vhosts/secure.dialoguebooks.org/httpdocs/app/Mage.php but keep getting an ‘Invalid URL’ message.

    My wp installation is at /var/www/vhosts/dialoguebooks.org/subdomains/dev/httpdocs/

Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Author Richard Feraro

    (@richardferaro)

    Create a file in httpdocs and run the code below. Add your Magento address to Mage.php and use it as your Mage.php URL.

    <?php echo $_SERVER['DOCUMENT_ROOT']; ?>

    Thread Starter Julian

    (@julianarnold)

    Hey, thanks for the swift reponse.

    When I echo that I get “/var/www/vhosts/secure.dialoguebooks.org/httpdocs” – when I add the path to Mage.php (making /var/www/vhosts/secure.dialoguebooks.org/httpdocs/app/Mage.php) I get an invalid URL error.

    Is this because the wordpress installation and magento installation are on different file roots on the server? (i.e /var/www/vhosts/secure.dialoguebooks.org/httpdocs/ and /var/www/vhosts/dialoguebooks.org/subdomains/dev/httpdocs/)

    Thanks

    Julian

    Plugin Author Richard Feraro

    (@richardferaro)

    What happens when you run the code below in a separate file within /var/www/vhosts/dialoguebooks.org/subdomains/dev/httpdocs/

    <?php
        require_once ( "/var/www/vhosts/secure.dialoguebooks.org/httpdocs/app/Mage.php" );
        Mage::app("default");
        Mage::getSingleton("core/session", array("name" => "frontend"));
    ?>

    The idea is that Mage.php must be accessible locally.

    Thread Starter Julian

    (@julianarnold)

    Hmm, I get this message, although safe mode is definitely off:

    Warning: require_once() [function.require-once]: SAFE MODE Restriction in effect. The script whose uid is 10041 is not allowed to access /var/www/vhosts/secure.dialoguebooks.org/httpdocs/app/Mage.php owned by uid 10050 in /var/www/vhosts/dialoguebooks.org/subdomains/dev/httpdocs/mage.php on line 2

    Warning: require_once(/var/www/vhosts/secure.dialoguebooks.org/httpdocs/app/Mage.php) [function.require-once]: failed to open stream: Inappropriate ioctl for device in /var/www/vhosts/dialoguebooks.org/subdomains/dev/httpdocs/mage.php on line 2

    Fatal error: require_once() [function.require]: Failed opening required ‘/var/www/vhosts/secure.dialoguebooks.org/httpdocs/app/Mage.php’ (include_path=’.:’) in /var/www/vhosts/dialoguebooks.org/subdomains/dev/httpdocs/mage.php on line 2

    Plugin Author Richard Feraro

    (@richardferaro)

    That’s a configuration issue in either of the two setups you have. Double check if the Safe Mode setting is really turned off to allow you to access the file. A phpinfo(); will do the trick.

    Thread Starter Julian

    (@julianarnold)

    Ah, yes the webadmin was lying to me. Thanks for your help!

    Thread Starter Julian

    (@julianarnold)

    Although when I run:

    <?php
        require_once ( "/var/www/vhosts/secure.dialoguebooks.org/httpdocs/app/Mage.php" );
        Mage::app("default");
        Mage::getSingleton("core/session", array("name" => "frontend"));
    ?>

    I don’t get any output, and when I tried this:

    <?php if(class_exists('Mage')){
    		Mage::getSingleton('core/session', array('name' => 'frontend'));
    	}
    
    if(class_exists('Mage')){
    	$session = Mage::getSingleton("customer/session");
    	$magento_message = "Welcome ";
    	// Generate a personalize greeting
    	if($session->isLoggedIn()){
    		$magento_message .= $session->getCustomer()->getData('firstname').' ';
    		$magento_message .= $session->getCustomer()->getData('lastname').'!';
    	}else{
    		$magento_message .= "Guest!";
    	}
    
    	echo $magento_message;
    }
    ?>

    I just get the ‘Guest!’ message, even though I am logged in with my megnto session.

    Any ideas?

    Thanks

    Julian

    Thread Starter Julian

    (@julianarnold)

    (the second thing I tried above was in a wordpress template)

    Plugin Author Richard Feraro

    (@richardferaro)

    The script I posted will not produce a visible output on-screen. Instead, it will generate a cookie named ‘frontend‘ which tells you that Magento session is running. To double check using the first script if it is working, add the code below which will display an array of classes that has been successfully instantiated. It should include Mage and Varien in the list. If it doesn’t, there must be a fatal error somewhere. Add error_reporting(E_ALL); at the top most part of the file to display any error.

    <?php
    print_r(get_declared_classes());
    ?>

    Regarding your second script, if your session was started from Magento then you opened WordPress, they won’t share the same session because it uses cookies to authenticate users which in your case, they’re on a different cookie path. It’s similar with what Barry experienced in his comment. To overcome this, you must pass the SID to be used by the PHP session in WP page or vice-versa.

    You’re script doesn’t contain the login method. Try this instead (take note of the login part, replace it with your test account):

    <?php if(class_exists('Mage')){
    	Mage::getSingleton('core/session', array('name' => 'frontend'));
    	}
    
    if(class_exists('Mage')){
    	$session = Mage::getSingleton("customer/session");
    	// Add customer credentials here
    	$session->login('email', 'password');
    
    	$magento_message = "Welcome ";
    	// Generate a personalize greeting
    	if($session->isLoggedIn()){
    		$magento_message .= $session->getCustomer()->getData('firstname').' ';
    		$magento_message .= $session->getCustomer()->getData('lastname').'!';
    	}else{
    		$magento_message .= "Guest!";
    	}
    
    	echo $magento_message;
    }
    ?>
    Thread Starter Julian

    (@julianarnold)

    Yep, Mage and Varien are in the list of declared classes, but when I use the last code you wrote above, I get the following error:

    Fatal error: Uncaught exception 'Zend_Controller_Response_Exception' with message 'Cannot send headers; headers already sent in /var/www/vhosts/dialoguebooks.org/subdomains/dev/httpdocs/wp-content/themes/dialogue/header.php, line 20' in /var/www/vhosts/secure.dialoguebooks.org/httpdocs/lib/Zend/Controller/Response/Abstract.php:282 Stack trace: #0 /var/www/vhosts/secure.dialoguebooks.org/httpdocs/lib/Zend/Controller/Response/Abstract.php(115): Zend_Controller_Response_Abstract->canSendHeaders(true) #1 /var/www/vhosts/secure.dialoguebooks.org/httpdocs/app/code/core/Mage/Core/Model/App.php(1151): Zend_Controller_Response_Abstract->setHeader('Content-Type', 'text/html; char...') #2 /var/www/vhosts/secure.dialoguebooks.org/httpdocs/app/code/core/Mage/Core/Model/Cookie.php(93): Mage_Core_Model_App->getResponse() #3 /var/www/vhosts/secure.dialoguebooks.org/httpdocs/app/code/core/Mage/Core/Model/Cookie.php(208): Mage_Core_Model_Cookie->_getResponse() #4 /var/www/vhosts/secure.dialoguebooks.org/httpdocs/app/code/core/Mage/Core/Mod in /var/www/vhosts/secure.dialoguebooks.org/httpdocs/lib/Zend/Controller/Response/Abstract.php on line 282

    Thanks

    Julian

    Plugin Author Richard Feraro

    (@richardferaro)

    Place the code below in index.php of your theme just before the get_header(); call and don’t repeat it anywhere.

    if(class_exists('Mage')){
        Mage::getSingleton('core/session', array('name' => 'frontend'));
    }
    Thread Starter Julian

    (@julianarnold)

    okay, brilliant, thank you!

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘[Plugin: Mage Enabler] Invalid URL’ is closed to new replies.