You are not logged in.
Hi,
I am using Xinha with Expression Engine (http://www.pmachine.com) where I have three weblogs. In the publish section of the admin console Xinha works fine with Image Manager or EFM but I would like each of them to point to a different directory to keep all the images seperate.
The URL for each webloge admin console looks like this:
http://www.mydomain.com/ee/index.php?S=[Session key]&C=publish&M=entry_form&weblog_id=1
http://www.mydomain.com/ee/index.php?S=[Session key]&C=publish&M=entry_form&weblog_id=2
http://www.mydomain.com/ee/index.php?S=[Session key]&C=publish&M=entry_form&weblog_id=3
Would it be possible to read out the weblog_id value from the URL and define a folder on my webserver for each one that Image Manager or EFM uses?
Thanks.
Andy
Offline
As ImageManager and EFM are configured through a php file (config.inc.php in the plugin directory) it should be no problem to use something like
$IMConfig['images_dir'] = $_SERVER['DOCUMENT_ROOT'].'/pathToYourImages/weblogimages_'.$_GET['weblog_id'].'/';
$IMConfig['images_url'] = '/pathToYourImages/weblogimages_'.$_GET['weblog_id'].'/';
Offline
Thanks for the quick response Ray. I tried it but unfortunately it doesn't seem to work - for some reason it doesn't get the weblog_id variable from the URL.
Is it because when I click on the Image Manager icon in Xinha it actually openes this URL without passing on the weblog_id variable?
http://www.mydomain.com/ee/xinha/plugins/ImageManager/backend.php?__plugin=ImageManager&__function=manager
It opens the IM URL in a popup correctly but just tries to load /path/to/weblogimages_ without adding the number resulting in an error.
Any ideas?
Last edited by andy_vdg (2006-08-22 13:33:32)
Offline
oh, of course you are right, the parameter isn't available in the url of the popup. So you'd have to cache it somehow, e.g in a session variable. If you don't know how php sessions work, write again.
Best wishes
Offline
Hi Ray,
Thanks again - and no I have very basic PHP skills. If you give me something to work with I can usually figure out how to tweak it and get it to work on my site... but other than that I am lost.
Thanks for your help.
Offline
OK,
in your /ee/index.php
session_start(); //If not already
$_SESSION['weblog_id'] = $_GET['weblog_id']; //This strores your variable in the session
in EFM cinfig.inc.php
session_start(); //Important, otherwise it won't work
//then like before
$IMConfig['images_dir'] = $_SERVER['DOCUMENT_ROOT'].'/pathToYourImages/weblogimages_'.$_SESSION['weblog_id'].'/';
$IMConfig['images_url'] = '/pathToYourImages/weblogimages_'.$_SESSION['weblog_id'].'/';
Offline
For ImageManager,
// It's useful to pass the configuration to the backend through javascript
// (this saves editing the backend config itself), but the problem is
// how do you make it so that the enduser can not sneakily send thier own
// config to the server (including directory locations etc!).
//
// Well, we specify 3 config variables (if the first is given all 3 are required)
// first in backend_config we provide the backend configuration (in the format
// required by the backend, in the case of PHP this is a serialized structure). We do not
// need to provide a complete configuration here, it will be merged with defaults.
//
// Then in backend_config_secret_key_location we store the name of a key in a
// session structure which stores a secret key (anything random), for example
// when making the Xinha editor in PHP we might do
// <?php $_SESSION['Xinha:ImageManager'] = uniqid('secret_'); ?>
// xinha_config.ImageManager.backend_config_secret_key_location = 'Xinha:ImageManager';
//
// Then finally in backend_config_hash we store an SHA1 hash of the config combined
// with the secret.
//
// A full example in PHP might look like
//
// <?php
// @session_start();
// $myConfig = array('base_dir' = '/home/your/directory', 'base_url' => '/directory')
// $myConfig = serialize($myConfig);
// if(!isset($_SESSION['Xinha:ImageManager'])) $_SESSION['Xinha:ImageManager'] = uniqid('secret_');
// $secret = $_SESSION['Xinha:ImageManager'];
// ?>
// xinha_config.ImageManager.backend_config = '<?php echo jsaddslashes($myConfig)?>';
// xinha_config.ImageManager.backend_config_hash = '<?php echo sha1($myConfig . $secret)?>';
// xinha_config.ImageManager.backend_config_secret_key_location = 'Xinha:ImageManager';
//
// (for jsspecialchars() see http://nz.php.net/manual/en/function.addcslashes.php)
//
//
Word of warning: this relies on your PHP application using the default PHP session name - whatever that is set to in your php.ini. If you are using a different session name, you will need to modify ImageManager (or use an .htaccess or php.ini or something to make it use the same session name).
James Sleeman
Offline
Hi, I currently have the same problem.
When I am trying to config the image manager as following:
<?php
session_start();
$IMConfig = array();
$IMConfig['images_dir'] = '/usr/export/www/vhosts/funnetwork/hosting/retaliator/smg/';
$IMConfig['images_url'] = 'http://retaliator.re.funpic.de/smg/';
$IMConfig = serialize($IMConfig);
if(!isset($_SESSION['Xinha:ImageManager']))
{
$_SESSION['Xinha:ImageManager'] = uniqid('secret_');
}
?>
Actually the image manager is working but when I submit the form I receive wrong image sources:
<img width="38" height="10" src="smg/mehr.gif" alt="mehr.gif" />
instead of
<img width="38" height="10" src="http://retaliator.re.funpic.de/smg/mehr.gif" alt="mehr.gif" />
Can anyone help me
thx rob
Offline
If there's any more need for discussion, please write here http://xinha.gogo.co.nz/punbb/viewtopic.php?id=573 to keep things together
Offline