Jump to content

Help change $abspath_folder


delxy

Recommended Posts

Hi,

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,:)

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;

}

}

 

 

Link to comment
https://forums.phpfreaks.com/topic/194943-help-change-abspath_folder/
Share on other sites

Need a bit more description. "Doesn't work" means nothing. What doesn't work, what happens when you try it? What is it suppose to do and what does it do before any changes.

 

Also, if you cant edit your post, re-post the code within code or php tags! It's so hard to read I dont understand.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.