...

View Full Version : Help change $abspath_folder



delxy
03-11-2010, 08:36 PM
Hi,there
Need to change this line :
$abspath_folder = JPATH_BASE.DS.$folder;
somehow to
$abspath_folder = /public_html/mysite.com.$folder; or http://www.mysite.com.$folder;

I tried
$url=('http://www.mysite.com');
$abspath_folder =$url.$folder;
It dosn't work,:o
Regards,
Anton
Here is my code:
defined( '_JEXEC' ) or die( 'Restricted access' );

class modBackgroundHelper
{
function getBackgroundImage(&$params)
{
// get the parameters
$color = $params->get('color', '#ffffff');
$image = $params->get('image');
$random = $params->get('random');
$folder = $params->get('folder', 'images/stories');
$add_css = $params->get('additional_css');
$idofbg = $params->get('idofbg');

// prepare some variables
$the_array = array();
$the_image = array();

//check the ID to add the background to, if nothing make body
if ($idofbg == "") {
$idofbg = "body";
}

// use random image
if ($random == 1) {

// if folder doesnt contain slash to start, add
if ( strpos($folder, '/') !== 0 ) {
$folder = '/'. $folder;
}

// construct absolute path to directory
$abspath_folder = JPATH_BASE.DS.$folder;

// check if directory exists
if (is_dir($abspath_folder)) {
if ($handle = opendir($abspath_folder)) {
while (false !== ($file = readdir($handle))) {
if ($file != '.' && $file != '..' && $file != 'CVS' && $file != 'index.html' ) {
$the_array[] = $file;
}
}
}
closedir($handle);

foreach ($the_array as $img) {
if (!is_dir($abspath_folder .'/'. $img)) {
if (eregi('jpg', $img) || eregi('png', $img) || eregi('gif', $img) ) {
$the_image[] = $img;
}
}
}

if (!$the_image) {
return "No images";
} else {
$i = count($the_image);
$random = mt_rand(0, $i - 1);
$image = $the_image[$random];
$abspath_image = $abspath_folder . '/'. $image;
}
}
}
// no random image
else {
$folder = "images/stories";
}
$livesite = JURI::base();

// make the CSS output
$output = "<style type=\"text/css\">" . $idofbg . " { background-color:" . $color . " !important;";
if (!($image == -1 && random == 0)) {
$output .= "background-image: url(" . $livesite . $folder . '/' . $image . ") !important;";
// if add_css contains <br /> remove them
if (stristr($add_css, '<br />') == TRUE) {
$add_css = str_replace("<br />", "", $add_css);
}
$output .= $add_css;
}
$output .= " }</style>";

// echo the CSS output
return $output;
}
}

hoothelp
03-12-2010, 08:25 PM
Hello.

Several options for you on this one.



$abspath_folder = "/public_html/mysite.com$folder";




$url='http://www.mysite.com';
$abspath_folder = "$url$folder";




$url='http://www.mysite.com';
$abspath_folder = $url . $folder;


Hope it helps,
- C. Aaron Smith



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum