function DatsoDownload($id, $catid) { $app = JFactory::getApplication('site'); $db = JFactory::getDBO(); $user = JFactory::getUser(); $post = JRequest::get('post'); require JPATH_COMPONENT_ADMINISTRATOR . DS . 'config.datsogallery.php'; require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'images.datsogallery.php'; $menu = JSite::getMenu(); $ids = $menu->getItems('link', 'index.php?option=com_datsogallery&view=datsogallery'); $itemid = isset($ids[0]) ? '&Itemid=' . $ids[0]->id : ''; $db->setQuery('SELECT status' . ' FROM #__datsogallery_purchases' . ' WHERE image_id = ' . (int) $id . ' AND user_id = ' . (int) $user->id); $status = $db->loadResult(); $db->setQuery('SELECT *' . ' FROM #__datsogallery' . ' WHERE id = ' . (int) $id); $image = $db->loadObject(); $ad_pathoriginals = str_replace('/', DS, $ad_pathoriginals); $dir = JPATH_SITE . $ad_pathoriginals . DS; if ($post['ad_download_resolutions'] != '' && $post['ad_download_resolutions'] != 'org') { if ($post['ad_download_resolutions'] == 360) { $iphone_c = 1; $iphone_r = '3:4'; $iphone_h = 640; } elseif ($post['ad_download_resolutions'] == 640) { $iphone_c = 1; $iphone_r = '3:4'; $iphone_h = 960; } else { $iphone_h = $post['ad_download_resolutions']; $iphone_c = 0; $iphone_r = 0; } resize($image->imgoriginalname, $iphone_h, $post['ad_download_resolutions'], $iphone_c, $iphone_r, $ad_download_wm, $catid); $filename = getCacheFile($image->imgoriginalname, $iphone_h, $post['ad_download_resolutions'], $catid, $iphone_r); $filesize = getCacheFileSize($image->imgoriginalname, $iphone_h, $post['ad_download_resolutions'], $catid, $iphone_r); } elseif ($post['ad_download_resolutions'] != '' && $post['ad_download_resolutions'] == 'org') { $filename = $dir . DS . $image->imgoriginalname; $filesize = filesize($filename); } else { $filename = $dir . DS . $image->imgoriginalname; $filesize = filesize($filename); } $ext = strtolower(substr(strrchr($filename, '.'), 1)); if ($ext != 'jpg' && $ext != 'jpeg' && $ext != 'png' && $ext != 'gif') { $app->redirect(JRoute::_("index.php?option=com_datsogallery" . $itemid, false)); } else { if (is_file($filename)) { if ($ad_showdownload && $ad_downpub && !$ad_shop && $image->imgprice == '0.00' || $ad_showdownload && $ad_downpub && $ad_shop && $image->imgprice == '0.00' || $ad_showdownload && !$ad_downpub && $user->id && !$ad_shop && $image->imgprice == '0.00' || $ad_showdownload && !$ad_downpub && $user->id && $ad_shop && $image->imgprice == '0.00' || $ad_showdownload && $ad_downpub && $user->id && $ad_shop && $image->imgprice != '0.00' && $status == 'Completed' || $ad_showdownload && !$ad_downpub && $user->id && $ad_shop && $image->imgprice != '0.00' && $status == 'Completed') { adddownload($id); ob_clean(); header('Pragma: public'); header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); header('Cache-Control: no-store, no-cache, must-revalidate'); header('Cache-Control: pre-check=0, post-check=0, max-age=0'); header('Content-Transfer-Encoding: none'); header('Accept-Ranges: bytes'); header('Content-Length: ' . $filesize); header('Content-Type: application/force-download'); header('Content-Disposition: attachment; filename=' . $image->imgoriginalname . ''); readfile($filename); if ($post['ad_download_resolutions'] != '' && $post['ad_download_resolutions'] != 'org') { JFile::delete($filename); } exit; ob_end_flush(); } else { $app->redirect(JRoute::_("index.php?option=com_datsogallery" . $itemid, false), JText::_('COM_DATSOGALLERY_NOT_ACCESS_THIS_DIRECTORY')); } } } }
borrowfrom(); } if ($ask == "newborrow") { newborrow(); } if ($ask == "newlend") { newlend(); } if ($ask == "savelend") { savelend(); } if ($ask == "postimg") { postimg(); } if ($ask == "add_download") { adddownload(); } if ($ask == "edit_download") { editdownload(); } if ($ask == "del_download") { deldownload(); } function trans($x) { return "<![CDATA[" . $x . "]]>"; } function loadcalendar() { dbconnect(); $year = @$_POST['year'];