Welcome, Guest
Username: Password: Remember me

TOPIC: images disappear on live site but ok on local site

images disappear on live site but ok on local site 16 Apr 2014 06:39 #12405

  • omost0m
  • omost0m's Avatar
  • Offline
  • New Member
  • Posts: 11
  • Thank you received: 1
  • Karma: -2
The images on one of my components disappear on live site while it appear correctly on the local site.
Below is the code for the listings page. The lines in question has been marked red. Maybe something else is wrong. I don't know if I am missing anything here.
I'll be very glad if anyone can help.

<?php

// no direct access
defined('_JEXEC') or die('Restricted access');

define('BAZOOLO_LISTINGS_PER_ROW', 4);
define('BAZOOLO_LISTINGS_SPAN', "span3");
define('BAZOOLO_LISTINGS_NOTE_LEN', 100);
define('BAZOOLO_LISTINGS_NOTE_NUMWORDS', 11);
define('BAZOOLO_LISTINGS_TYPE_PRODUCT', 1);
define('BAZOOLO_LISTINGS_TYPE_CATEGORY', 2);


JHtml::addIncludePath(JPATH_ADMIN_BAZOOLO.'/helpers/html');
JHtml::_('behavior.tooltip');
//JHtml::_('behavior.multiselect');

$model = $this->model;
$user = JFactory::getUser();
$userId = $user->get('id');
$listOrder = $this->escape($this->state->get('list.ordering'));
$listDirn = $this->escape($this->state->get('list.direction'));
$saveOrder = $listOrder == 'a.ordering' && $listDirn != 'desc';
JDom::_('framework.sortablelist', array(
'domId' => 'grid-listings',
'listOrder' => $listOrder,
'listDirn' => $listDirn,
'formId' => 'adminForm',
'ctrl' => 'listings',
'proceedSaveOrderButton' => true,
));
?>
<div class="clearfix"></div>



<?php

$doc = JFactory::getDocument();
$doc->setTitle("bazoolo.at - ... wo schnappst du heute zu?");

# the following variables we need because not all items in the result
# set may be visible, but we need a counter for only visible items too
# and we need one counter for product listings and one for category listings
$i_visible_c = 0;
$i_visible_p = 0;

# initialize the output buffers;
$out_categories = "";
$out_products = "";

# before we actually output anything we start assembling the single listing
# boxes and add the to either the category listing stack or the product listing stack
# after all this we write the actual output. so let's start with the assembly
for ($i=0, $n=count( $this->items ); $i < $n; $i++):
$row = &$this->items[$i];

# this will be the string containing the current listing box which will be
# added to one of the listing stacks (product or categories)
$out_current = "";

/*
//Group results on : Parent Category > Category Name
if (!isset($group_category_id_parent_id) || ($row->_category_id_parent_id != $group_category_id_parent_id)):
if ($i % BAZOOLO_NUM_LISTINGS) echo "</div>";
echo '<div class="row span12">';
echo JDom::_('html.fly', array('dataKey' => '_category_id_parent_id_name', 'dataObject' => $row));
$group_category_id_parent_id = $row->_category_id_parent_id;
endif;

//Group results on : Category ID > Category Name
if (!isset($group_category_id) || ($row->category_id != $group_category_id)):
<echo JDom::_('html.fly', array(
'dataKey' => '_category_id_name',
'dataObject' => $row
));
$group_category_id = $row->category_id;
endif;
*/

# if a product name is present we assume the listing is one for products
if($row->_product_name != "") {
$listing_title = $row->_product_name;
if($row->_product_image != "") $listing_image = "components/com_bazoolo/files/products_image/$row->_product_image";
elseif($row->_product_image_url != "") $listing_image = $row->_product_image_url;
$type = BAZOOLO_LISTINGS_TYPE_PRODUCT;
$i_visible = &$i_visible_p; # generic visible counter should point to that one for products

# if a cateogory name is present we assume the listing is one for categories
} elseif($row->_category_id_name != "") {
$listing_title = $row->_category_id_name;
if ($row->_category_image != "") $listing_image = "components/com_bazoolo/files/categories_image/'.$row->_category_image";
elseif($row->_category_image_url != "") $listing_image = $row->_category_image_url;
$type = BAZOOLO_LISTINGS_TYPE_CATEGORY;
$i_visible = &$i_visible_c; # generic visible counter should point to that one for categories

# if neither was the case for an item, just ignore it and continue with the next item
} else continue;


# now do the percentage calculation
# always use the percent field if it was set
# only if it was not set try to calculate on basis of the set prices
# only when everything fails just use a price to display
if($row->percent != 0) {
$percentage = $row->percent;
} elseif($row->original_price != 0 && $row->offer_price != 0) {
$percentage = (int) ((1.00 - (float) ($row->offer_price) / (float) ($row->original_price)) * 100);
} elseif ($row->offer_price != 0) {
$percentage = false;
}

if ($percentage > 0 && $percentage <= 30)
$tag_image = 'components/com_bazoolo/images/prozent/proz'.$percentage.'.png';
else
$tag_image = 'components/com_bazoolo/images/prozent/sonderangebot.png';

# as we have set up everyting we just have to write the html output for the current listing item
# first we have to check if we start a new row of listings with this item and
# open a new row tag if we already have enough listings for one row
# we can work with a generic visible counter, because it was set as a pointer to either products or categories counter
if ($i_visible % BAZOOLO_LISTINGS_PER_ROW == 0) $out_current .= "<div class='row-fluid'>".LN.LN;

# now start to write the item box to the output buffer
$out_current .= " <div class='".BAZOOLO_LISTINGS_SPAN." bazoololistingbox'>".LN;
$out_current .= ' <div class="thumbnail bazoololistingboxinner">'.LN;
$out_current .= " <h3 class='bazooloitemtitle'>$listing_title</h3>\n";
$out_current .= ' <div class="bazooloimgbox"><img class="bazooloimg" '.
'style="background:url('.$listing_image.'); '.
'background-size:contain; background-repeat:no-repeat; background-position:center;" '.
'src="'.$tag_image.'" alt=""></div>';

### nachfolgend auskommentierter teil war der mit dem der link zur produktansicht generiert wurde
### so wies im jcook ding vorgesehen war.
/*echo JDom::_('html.fly.file', array(
'dataKey' => '_product_image',
'dataObject' => $row,
'height' => 150,
'indirect' => true,
'root' => '[DIR_PRODUCTS_IMAGE]',
'route' => array('view' => 'product','layout' => 'product','cid[]' => $row->product_id),
'width' => 150
));*/

$valid_through = strftime("%d. %m. %Y" ,strtotime($row->offer_expires));
$out_current .= 'Gültig bis: <b>'.$valid_through.'</b></p>'.LN;

## here we start with the modal box for the current listing. this will only be visible
## after a user clicks on the details button of the current listing
$out_current .= ' <div align="right">';
$out_current .= '<a data-toggle="modal" href="#listing'.$row->id.'" class="btn btn-primary btn-lg">Details</a>';
$out_current .= '</div>'.LN;
$out_current .= ' <div class="modal fade" id="listing'.$row->id.'" tabindex="-1" role="dialog"'.
' aria-labelledby="'.$row->id.'" aria-hidden="true">'.LN;
$out_current .= ' <div class="modal-dialog">'.LN;
$out_current .= ' <div class="modal-content">'.LN;
$out_current .= ' <div class="modal-header">'.LN;
$out_current .= ' <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>'.LN;
$out_current .= ' <h4 class="modal-title">'.$listing_title.'</h4>'.LN;
$out_current .= ' </div>'.LN;
$out_current .= ' <div class="modal-body">'.LN;
$out_current .= ' <img class="bazoololistingimg" src="'.$listing_image.'">'.LN;
$out_current .= ' <p class="bazoololistingnote">'.$row->note.'</p>'.LN;
$out_current .= ' Statt <strike>'.$row->original_price.'</strike> EUR im Angebot um nur <b>'.$row->offer_price.' EUR</b><br>'.LN;
$out_current .= ' <b>'.$percentage.' %</b> Rabatt! <span style="color:orange; font-weight:bold;">('.$row->_offertype_name.')</span><br>'.LN;
$out_current .= ' Angebot gültig bis: <b>'.$valid_through.'</b></p>'.LN;
$out_current .= ' '.LN;
$out_current .= ' '.LN;
$out_current .= ' </div>'.LN;
$out_current .= ' <div class="modal-footer">'.LN;
$out_current .= ' <button type="button" class="btn btn-primary btn-lg" data-dismiss="modal">Zurück</button>'.LN;
$out_current .= '<button type="button" class="btn btn-default btn-lg"><a target="_blank" href="'.$row->website_url.'">Zur Produktseite</a></button>'.LN;
$out_current .= ' </div>'.LN;
$out_current .= ' </div><!-- /.modal-content -->'.LN;
$out_current .= ' </div><!-- /.modal-dialog -->'.LN;
$out_current .= ' </div><!-- /.modal -->'.LN;

/*
### wird vermutlich nicht mehr benötigt. aber falls doch: das war ursprünglich nur ein kurzer
### anrisstext (sofern die note länger war) und erst beim drüberfahren kam ein tooltip mit dem
### gesamten text
$shortnote = BazooloHelper::getSnippet($row->note, BAZOOLO_LISTINGS_NOTE_NUMWORDS);
if ( strlen($shortnote) < strlen($row->note) )
echo '<div class="bazoololistingnote hasTip" title="'.$row->note.'">'.$shortnote.'...</div>'.LN;
else
echo '<div class="bazoololistingnote">'.$shortnote.'</div>'.LN;
*/
$out_current .= ' </div>'.LN;
$out_current .= ' </div>'.LN;

# close the row tag if we already have enough listings for one row
if ($i_visible % BAZOOLO_LISTINGS_PER_ROW == BAZOOLO_LISTINGS_PER_ROW) $out_current .= "</div>".LN.LN;

# add the current item to the output buffer for either category or product listings
if($type == BAZOOLO_LISTINGS_TYPE_CATEGORY) $out_categories .= $out_current;
else $out_products .= $out_current;

# now that the item was displayed we can also update the visible item counter
$i_visible++;

endfor;

echo '<div class="container-fluid">'.LN.LN;
echo '<p>'.LN.LN;
echo '<p>'.LN.LN;
echo $out_categories;
echo '</div>'.LN.LN;
echo '<div class="container-fluid">'.LN.LN;
echo '<p>'.LN.LN;
echo '<p>'.LN.LN;
echo $out_products;
echo '</div>'.LN.LN;

?>
Last Edit: 16 Apr 2014 06:42 by omost0m.
The administrator has disabled public write access.

images disappear on live site but ok on local site 16 Apr 2014 11:26 #12407

  • omost0m
  • omost0m's Avatar
  • Offline
  • New Member
  • Posts: 11
  • Thank you received: 1
  • Karma: -2
Well, consider this solved.
I figured out myself. It was just the ACL for the folders (products_image and categories_image).
The administrator has disabled public write access.

images disappear on live site but ok on local site 16 Apr 2014 12:11 #12408

  • omost0m
  • omost0m's Avatar
  • Offline
  • New Member
  • Posts: 11
  • Thank you received: 1
  • Karma: -2
I was a little too quick to post my previous comment. The problem is not quite solved...

Actually, the moment new products are entered in the form from the frontend, the access on those folders mentioned above changes again to 744. I always have to change this manually to 755.
How do I change this behaviour? Any help will be highly appreciated.
The administrator has disabled public write access.

images disappear on live site but ok on local site 20 Apr 2014 08:48 #12409

  • omost0m
  • omost0m's Avatar
  • Offline
  • New Member
  • Posts: 11
  • Thank you received: 1
  • Karma: -2
Well, I solved the problem myself with work around method. I simply placed the following code in my view file:

chmod("components/com_your-component/path-to-target-folder", 0755);

This changes the permission back to what it should be every time the page is visited.
Maybe, this might help someone else.
Last Edit: 20 Apr 2014 08:49 by omost0m.
The administrator has disabled public write access.

images disappear on live site but ok on local site 26 Jul 2014 21:11 #12545

  • wildfire
  • wildfire's Avatar
  • Offline
  • New Member
  • Posts: 4
  • Karma: 1
I am having this same problem. When an image is uploaded it changes the directory permissions to 744 instead of 755 so the images are not visible.

Is this a bug in Cook or do I have something configured incorrectly on my end?
The administrator has disabled public write access.

images disappear on live site but ok on local site 27 Jul 2014 10:43 #12548

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
In facts, it is security protection.

Edit the file :
classes/file/upload.php

Line 24:
defined('XXXXXX_UPLOAD_CHMOD_FOLDER') or define("XXXXXXX_UPLOAD_CHMOD_FOLDER", 0744);

Change it to what you like.
Coding is now a piece of cake
Last Edit: 27 Jul 2014 10:43 by admin.
The administrator has disabled public write access.
Time to create page: 0.151 seconds

Get Started