function b_weblog_recent_image_show($options) { global $xoopsDB, $xoopsUser, $xoopsConfig; if (function_exists("gd_info")) { $gd_infomation = gd_info(); if (substr($gd_infomation['GD Version'], 0, 10) != 'bundled (2') { // GD version 2 is required return false; } } $mydirname = empty($options[0]) ? basename(dirname(dirname(__FILE__))) : $options[0]; $max_images = $options[1]; $max_title_length = $options[2]; $max_contents_length = $options[3]; $date_format = $options[4]; $show_forbidden_pic = $options[5]; $block = array(); $block['images'] = array(); $currentuid = !empty($xoopsUser) ? $xoopsUser->getVar('uid', 'E') : 0; $user_id = !empty($_GET['user_id']) ? intval($_GET['user_id']) : 0; if (is_object($xoopsUser)) { $useroffset = $xoopsUser->timezone() - $xoopsConfig['server_TZ']; } else { $useroffset = $xoopsConfig['default_TZ'] - $xoopsConfig['server_TZ']; } include_once sprintf('%s/modules/%s/config.php', XOOPS_ROOT_PATH, $mydirname); $wb_configs = get_wb_moduleconfig($mydirname); list($bl_contents_field, $permission_group_sql) = weblog_create_permissionsql($wb_configs, $mydirname); $myts =& MyTextSanitizer::getInstance(); $weblog_image_url = XOOPS_URL . $wb_configs['weblog_myalbum_photospath']; $sql = sprintf('SELECT blog_id, user_id , uname, created+%d as created, title, contents , %s as contents_p FROM %s as bl , %s as u', $useroffset * 3600, $bl_contents_field, $xoopsDB->prefix($mydirname), $xoopsDB->prefix('users')); $sql = sprintf('%s WHERE bl.user_id=u.uid and (bl.private = \'N\' OR bl.user_id=\'%d\') and bl.contents like \'%s\' %s ', $sql, $currentuid, '%' . $weblog_image_url . '%', $permission_group_sql); if ($user_id) { $sql = sprintf('%s and bl.user_id=%d', $sql, $user_id); } $sql .= ' ORDER BY created DESC'; // Need to figure out how to access the module config while in a block //$result = $xoopsDB->query($sql, $xoopsModuleConfig['numinrecentblock'], 0); $result = $xoopsDB->query($sql, $max_images, 0); $alart = false; while ($myrow = $xoopsDB->fetchArray($result)) { $image = array(); $title = ""; if ($max_title_length > 0) { $title = $myts->makeTboxData4Show($myrow['title']); if (strlen($title) >= $max_title_length) { $title = xoops_substr($title, 0, $max_title_length - 1); } } $contents = ""; if ($max_contents_length > 0) { $contents = strip_tags($myts->xoopsCodeDecode($myrow['contents'])); if (strlen($contents) >= $max_contents_length) { $contents = xoops_substr($contents, 0, $max_contents_length - 1); } } $image['permission'] = bl_permission_alart($myrow['contents_p']); if ($image['permission']) { $alart = true; } $img_pattern = "/\\[img( align=['\"]?)?(left|center|right)?]([^\"\\(\\)\\?\\&'<>]*)\\[\\/img\\]/sU"; $image['image_url'] = array(); if (!(!$show_forbidden_pic && $image['permission'])) { if (preg_match_all($img_pattern, $myrow['contents'], $matches)) { $image['image_uri'] = str_replace($wb_configs['weblog_myalbum_photospath'], $wb_configs['weblog_myalbum_thumbspath'], $matches[3]); } } $image['title'] = $title; $image['contents'] = $contents; $image['uname'] = $myrow['uname']; $image['date'] = formatTimestamp($myrow['created'], $date_format, $xoopsConfig['default_TZ']); $image['entry_url'] = sprintf('%s/modules/%s/details.php?blog_id=%d', XOOPS_URL, $mydirname, $myts->makeTboxData4Show($myrow['blog_id'])); $image['blog_uri'] = sprintf('%s/modules/%s/index.php?user_id=%d', XOOPS_URL, $mydirname, $myts->makeTboxData4Show($myrow['user_id'])); $block['images'][] = $image; } if ($user_id > 0) { $blogOwner = new XoopsUser($user_id); $block['lang_whose'] = sprintf(_BL_ENTRY_FOR, $blogOwner->getVar('uname', 'E')); } if ($alart) { $block['lang_denote'] = _MB_WEBLOG_LANG_DENOTE_PERMIT; } return $block; }
$add_whr = ""; // $group_by = "" ; // show by each entry $group_by = " group by left(from_unixtime(created)+0,8) "; // show by daily if (!defined('_WEBLOG_COMMON_FUNCTIONS')) { $original_mydirname = @$mydirname; } $mydirname = $plugin['dirname']; include_once sprintf('%s/modules/%s/config.php', XOOPS_ROOT_PATH, $plugin['dirname']); $mydirname = @$original_mydirname; if (function_exists('weblog_create_permissionsql')) { $mod_handler =& xoops_gethandler('module'); $weblogmodule_config_handler =& xoops_gethandler('config'); $mod_weblog =& $mod_handler->getByDirname($plugin['dirname']); $weblog_config = $weblogmodule_config_handler->getConfigList($mod_weblog->mid()); list($bl_contents_field, $add_whr) = weblog_create_permissionsql($weblog_config, $plugin['dirname']); } else { $add_whr = ""; } // query (added 86400 second margin "begin" & "end") $weblog_minical_sql = "SELECT title,blog_id,`created`,count(blog_id) FROM " . $db->prefix('weblog' . $mydirnumber) . " as bl WHERE `created` >= {$range_start_s} AND `created` < {$range_end_s} and private!='Y' " . $add_whr . $group_by; $result = $db->query($weblog_minical_sql); while (list($title, $blog_id, $server_time, $entry_num) = $db->fetchRow($result)) { $user_time = $server_time + $tzoffset_s2u; $entry_num = $entry_num > 1 ? $entry_num . 'entries' : $entry_num . 'entry'; if (date('n', $user_time) != $this->month) { continue; } $target_date = date('j', $user_time); $tmp_array = array('dotgif' => $plugin['dotgif'], 'dirname' => $plugin['dirname'], 'link' => XOOPS_URL . "/modules/" . $plugin['dirname'] . "/index.php?caldate=" . date('Y-n-j', $user_time) . '&date=' . date('Ymd', $user_time), 'id' => $blog_id . $server_time, 'server_time' => $server_time, 'user_time' => $user_time, 'name' => 'blog_id', 'title' => $plugin['name'] . '(' . $entry_num . ')'); if ($just1gif) {
function &getObjects($criteria = null, $id_as_key = false, $contents_mode = "detail", $useroffset = 0) { $ret = array(); $limit = $start = 0; // use permission system or show title ? list($bl_contents_field, $permission_group_sql) = weblog_create_permissionsql(); // sql main $sql = sprintf('SELECT bl.blog_id, bl.user_id, bl.cat_id, bl.created+%d as created, bl.title, %s as contents, bl.private, bl.comments, bl.`reads`, bl.trackbacks, bl.permission_group, bl.dohtml, bl.dobr, bl.trackbacks, u.uname, u.user_avatar FROM %s as bl, %s as u ', $useroffset * 3600, $bl_contents_field, $this->db->prefix($this->mydirname), $this->db->prefix('users')); // criteria if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) { $sql .= sprintf(' %s %s %s', $criteria->renderWhere(), 'AND bl.user_id=u.uid ', $permission_group_sql); //$groupby = trim(str_replace('GROUP BY', "", $criteria->getGroupby())); //$sql .= ($groupby=='')?'':sprintf(' %s', $criteria->getGroupby()); $sort = $criteria->getSort() != '' ? $criteria->getSort() : 'blog_id'; $sql .= sprintf(' ORDER BY %s %s', $sort, $criteria->getOrder()); $limit = $criteria->getLimit(); $start = $criteria->getStart(); } else { $sql .= 'WHERE bl.user_id=u.uid ' . $permission_group_sql; } //echo $sql ; // DB connect if (!($result = $this->db->query($sql, $limit, $start))) { return $ret; } while ($myrow = $this->db->fetchArray($result)) { $entry = $this->create(); $entry->assignVars($myrow); if ($id_as_key) { $ret[$myrow['blog_id']] =& $entry; } else { $ret[] =& $entry; } unset($entry); } return $ret; }