/** * 创建数组缓存 * int setArrayCache( string $name, array $arr ) * @param string $name 缓存名称,尽量长点避免重名,用于读取缓存 * @param array $arr 要缓存的数组 * @return integer 0不成功,非0成功 * @author xiaowu * */ function setArrayCache($name, $arr) { $cache_dir = getCacheFile(); $cache_file = getCacheFile($name); MooMakeDir($cache_dir); $str = "<?php\n//Array Cache File, Do Not Modify Me!\n//Created: " . gmdate("Y-m-d H:i:s") . "\n\n\t\tif(!defined('IN_MOOPHP')) exit('Access Denied');\n\$data=" . var_export($arr, true) . ";\n?>"; return file_put_contents($cache_file, $str); }
require JPATH_COMPONENT_ADMINISTRATOR . DS . 'config.datsogallery.php'; require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'images.datsogallery.php'; $db = JFactory::getDBO(); $user = JFactory::getUser(); $groups = implode(',', $user->getAuthorisedViewLevels()); $id = JRequest::getVar('id', 0, 'get', 'int'); $catid = JRequest::getVar('catid', 0, 'get', 'int'); if ($id) { $db->setQuery('SELECT c.access' . ' FROM #__datsogallery_catg AS c' . ' LEFT JOIN #__datsogallery AS a' . ' ON a.catid = c.cid' . ' WHERE a.id = ' . $id . ' AND c.approved = 1' . ' AND c.access IN (' . $groups . ')'); $access = $db->loadObject(); if (!$access) { die(JText::_('COM_DATSOGALLERY_NOT_ACCESS_THIS_DIRECTORY')); } else { $db->setQuery('SELECT a.imgoriginalname' . ' FROM #__datsogallery AS a' . ' WHERE a.id = ' . $id . ' AND a.catid = ' . $catid); $image = $db->loadResult(); } resize($image, $ad_orgwidth, $ad_orgheight, 0, 0, $ad_showwatermark, $catid); $cacheimage = getCacheFile($image, $ad_orgwidth, $ad_orgheight, $catid); $imagesize = getimagesize($cacheimage); $expires = 60 * 60 * 24 * 14; header('Pragma: public'); header('Cache-Control: maxage=' . $expires); header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $expires) . ' GMT'); header('Last-Modified: ' . date('r')); header('Accept-Ranges: bytes'); header('Content-Length: ' . filesize($cacheimage)); header('Content-Type: ' . $imagesize['mime']); ob_clean(); readfile($cacheimage); exit; }
$rows = $db->loadObjectList(); if (count($rows)) { foreach ($rows as $row) { echo "<a style=\"visibility:hidden;\" rel=\"shadowbox[screenshots];player=img\"\n href=\"" . JURI::root() . "index.php?option=com_datsogallery&task=sbox&catid=" . $obj->catid . "&id=" . $row->id . "&format=raw\" title=\"" . jsspecialchars($row->imgtitle) . "\"></a>\n"; } } $db->setQuery('SELECT *' . ' FROM #__datsogallery' . ' WHERE id != ' . $obj->id . ' AND id ' . $wheredesc . $obj->id . ' AND catid = ' . $obj->catid . ' AND published = 1' . ' AND approved = 1' . ' ORDER BY ordering ' . $order); $rows = $db->loadObjectList(); if (count($rows)) { foreach ($rows as $row) { echo "<a style=\"visibility:hidden;\" rel=\"shadowbox[screenshots];player=img\"\n href=\"" . JURI::root() . "index.php?option=com_datsogallery&task=sbox&catid=" . $obj->catid . "&id=" . $row->id . "&format=raw\" title=\"" . jsspecialchars($row->imgtitle) . "\"></a>\n"; } } } } $cachefile = getCacheFile($obj->imgoriginalname, $ad_maxwidth, $ad_maxheight, $obj->catid); $msize = getimagesize($cachefile); $hres = $msize[1] / 2 - $ad_thumbwidth1 / 2 + 10; ?> </div> <div style="position:absolute;left:0;top: <?php echo $hres; ?> px"> <?php $db->setQuery("SELECT * FROM #__datsogallery WHERE id = " . $pid); $rowsPrev = $db->loadObjectList(); if (count($rowsPrev)) { foreach ($rowsPrev as $rowPrev) { echo "<a href='" . JRoute::_('index.php?option=com_datsogallery&task=image&catid=' . $obj->catid . '&id=' . $pid . $itemid) . $na . "'>\n"; echo "<img src='" . resize($rowPrev->imgoriginalname, $ad_thumbwidth1, $ad_thumbheight1, $ad_crop, '1:1', 0, $obj->catid) . "' " . get_width_height($rowPrev->imgoriginalname, $ad_thumbwidth1, $ad_thumbheight1, $obj->catid, '1:1') . " class='dgimg' alt='' /></a>\n";
function space_comment() { global $user_arr; $message = trim(MooGetGPC('message', 'string', 'P')); if (empty($message)) { echo 'emptymessage'; exit; } $type = MooGetGPC('type', 'string', 'P'); if (in_array($type, array('video', 'lifetimes'))) { $type == 'video' ? $c_type = 1 : ($c_type = 2); } else { echo 'no'; exit; } $gender_value = MooGetGPC('gender_value', 'integer', 'P'); //得到评论包含的配置文件 $cache_file = getCacheFile($gender_value . $c_type); if (!file_exists($cache_file)) { echo 'no'; exit; } //视频 if ($type == 'video') { $vid = MooGetGPC('vid', 'integer', 'P'); if (empty($vid)) { echo 'no'; exit; } $commentid = MooGetGPC('commentid', 'integer', 'P'); $uid = MooGetGPC('uid', 'integer', 'P'); $param['comment_type'] = 1; //评论类型1为视频介绍 $param['vid'] = $vid; //评论的视频 $param['comment'] = ubbCode($message); //提交的评论 $param['cid'] = $uid; //被评论人的uid $param['uid'] = $user_arr['uid']; //评论人uid $param['nickname'] = $user_arr['nickname']; //评论人的昵称 $param['dateline'] = time(); inserttable('diamond_comment', $param); echo json_encode($param); exit; } //人生经历 if ($type == 'lifetimes') { $commentid = MooGetGPC('commentid', 'integer', 'P'); $uid = MooGetGPC('uid', 'integer', 'P'); $param['comment_type'] = 2; //评论类型2为人生经历 $param['comment'] = ubbCode($message); //提交的评论 $param['cid'] = $uid; //被评论人的uid $param['uid'] = $user_arr['uid']; //评论人uid $param['nickname'] = $user_arr['nickname']; //评论人的昵称 $param['dateline'] = time(); inserttable('diamond_comment', $param); echo json_encode($param); exit; } }
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')); } } } }