function showcaseComponentsShow($options) { include XOOPS_ROOT_PATH . "/modules/spotlight/components/showcase/config.php"; $sp_handler =& xoops_getmodulehandler('spotlight', 'spotlight'); $page_handler =& xoops_getmodulehandler('page', 'spotlight'); // spotlight object $sp_obj = $sp_handler->get($options[0]); if (!is_object($sp_obj) || empty($options[0])) { trigger_error("spotlight is not object ", E_USER_WARNING); } else { //spotlight name $block['sp_name'] = $sp_obj->getVar('sp_name'); // page list $criteria = new CriteriaCompo(); $criteria->add(new Criteria('sp_id', $options[0])); $criteria->setLimit($config['limit']); $criteria->setSort($config['sort']); $criteria->setOrder('ASC'); $pages = $page_handler->getAll($criteria, array('page_id', 'page_title', 'page_link', 'page_image', 'page_desc', 'published'), false); $myts = MyTextSanitizer::getInstance(); foreach ($pages as $k => $v) { $block['news'][$k] = $v; $block['news'][$k]['images'] = XOOPS_UPLOAD_URL . '/spotlight/image_' . $v['page_image']; $block['news'][$k]['thumbs'] = XOOPS_UPLOAD_URL . '/spotlight/thumb_' . $v['page_image']; $page_desc = strip_tags($myts->undoHtmlSpecialChars(strip_tags($v['page_desc']))); $block['news'][$k]['page_desc'] = xoops_substr($page_desc, '', $config['page_desc_substr']); $block['news'][$k]['page_title'] = xoops_substr($v['page_title'], '', $config['page_title_substr']); $block['news'][$k]['published'] = formatTimestamp($v['published'], $config['timeformat']); } // component name $block['component'] = $sp_obj->getVar('component_name'); return $block; } }
function fetchSummary($external_link_id) { // include_once dirname(dirname(__FILE__)).'/include/common_functions.php' ; global $forum_id; $db =& Database::getInstance(); $myts =& MyTextsanitizer::getInstance(); $module_handler =& xoops_gethandler('module'); $module =& $module_handler->getByDirname($this->mydirname); $config_handler =& xoops_gethandler('config'); $configs = $config_handler->getConfigList($module->mid()); $post_id = intval($external_link_id); $mydirname = $this->mydirname; if (preg_match('/[^0-9a-zA-Z_-]/', $mydirname)) { die('Invalid mydirname'); } $xpress_prefix = preg_replace('/wordpress/', 'wp', $mydirname); $blog_info = $this->get_comment_blog_info($forum_id); // query $post_row = $db->fetchArray($db->query("SELECT * FROM " . $blog_info['mb_table_prefix'] . "posts WHERE ID={$post_id}")); if (empty($post_row)) { return ''; } // dare to convert it irregularly $summary = str_replace('&', '&', htmlspecialchars(xoops_substr(strip_tags($post_row['post_content']), 0, 255), ENT_QUOTES)); $uri = preg_replace('/\\/$/', '', $blog_info['home']); $uri .= '/?p=' . $post_row['ID']; return array('dirname' => $mydirname . $blog_info['sub_dir'], 'module_name' => $blog_info['blogname'], 'subject' => $post_row['post_title'], 'uri' => $uri, 'summary' => $summary); }
function fetchSummary( $external_link_id ) { require_once dirname( dirname(__FILE__) ).'/class/d3downloads.textsanitizer.php' ; $db =& Database::getInstance() ; $myts =& d3downloadsTextSanitizer::getInstance() ; $module_handler =& xoops_gethandler( 'module' ) ; $module =& $module_handler->getByDirname( $this->mydirname ) ; $lid = intval( $external_link_id ) ; $mydirname = $this->mydirname ; if( preg_match( '/[^0-9a-zA-Z_-]/' , $mydirname ) ) die( 'Invalid mydirname' ) ; $sql = "SELECT lid, cid, title, description, filters FROM ".$db->prefix( $mydirname."_downloads" )." WHERE lid='".$lid."'" ; $myrow = $db->fetchArray( $db->query( $sql ) ) ; if( empty( $myrow ) ) return '' ; $cid = intval( $myrow['cid'] ) ; $uri = XOOPS_URL.'/modules/'.$mydirname.'/index.php?page=singlefile&cid='.$cid.'&lid='.$lid ; $filters = $myts->makeTboxData4Show( $myrow['filters'] ) ; $str = strip_tags( $myts->displayTarea( strip_tags( $myrow['description'] ), 0, 1, 1, 1, 1, $filters ) ) ; $summary = xoops_substr( $str , 0 , 255 ) ; return array( 'dirname' => $mydirname , 'module_name' => $module->getVar( 'name' ) , 'subject' => $myts->makeTboxData4Show( $myrow['title'] ) , 'uri' => $uri , 'summary' => $summary , ) ; }
function fetchSummary( $external_link_id ) { $db =& Database::getInstance() ; $myts =& MyTextSanitizer::getInstance(); $module_handler =& xoops_gethandler( 'module' ) ; $module =& $module_handler->getByDirname( $this->mydirname ) ; $entryID = intval( $external_link_id ) ; $mydirname = $this->mydirname ; if( preg_match( '/[^0-9a-zA-Z_-]/' , $mydirname ) ) die( 'Invalid mydirname' ) ; $content_row = $db->fetchArray( $db->query( "SELECT * FROM ".$db->prefix($mydirname."_ent")." WHERE entryID =$entryID" ) ) ; if( empty( $content_row ) ) return '' ; $categoryID = $content_row['categoryID']; $definition = $content_row['definition']; $_html = $content_row['html']; $_smiley = $content_row['smiley']; $_xcodes = $content_row['xcodes']; $_breaks = $content_row['breaks']; $str = strip_tags($myts->displayTarea($content_row['definition'],$_html,$_smiley,$_xcodes,$_breaks)); $summary = xoops_substr( $str , 0 , 255 ); $uri = XOOPS_URL.'/modules/'.$mydirname.'/entry.php?&entryID='.$entryID.'&categoryID='.$categoryID; return array( 'dirname' => $mydirname , 'module_name' => $module->getVar( 'name' ) , 'subject' => $myts->makeTboxData4Show( $content_row['term'] ) , 'uri' => $uri, 'summary' => $summary, ) ; }
function createUploadName($folder, $filename, $trimname = false) { $workingfolder = $folder; if (xoops_substr($workingfolder, strlen($workingfolder) - 1, 1) != '/') { $workingfolder .= '/'; } $ext = basename($filename); $ext = explode('.', $ext); $ext = '.' . $ext[count($ext) - 1]; $true = true; while ($true) { $ipbits = explode(".", $_SERVER["REMOTE_ADDR"]); list($usec, $sec) = explode(" ", microtime()); $usec = (int) ($usec * 65536); $sec = (int) $sec & 0xffff; if ($trimname) { $uid = sprintf("%06x%04x%04x", $ipbits[0] << 24 | $ipbits[1] << 16 | $ipbits[2] << 8 | $ipbits[3], $sec, $usec); } else { $uid = sprintf("%08x-%04x-%04x", $ipbits[0] << 24 | $ipbits[1] << 16 | $ipbits[2] << 8 | $ipbits[3], $sec, $usec); } if (!file_exists($workingfolder . $uid . $ext)) { $true = false; } } return $uid . $ext; }
function fetchSummary($external_link_id) { global $xoopsDB, $xoopsConfig, $xoopsUser; $myts =& MyTextSanitizer::getInstance(); $module_handler =& xoops_gethandler('module'); $module =& $module_handler->getByDirname($this->mydirname); $eventcomment_id = intval($external_link_id); $mydirname = $this->mydirname; if (!preg_match('/^(\\D+)(\\d*)$/', $mydirname, $regs)) { die('Invalid mydirname'); } $mydirnumber = $regs[2] === '' ? '' : intval($regs[2]); $table_event = $xoopsDB->prefix("pical{$mydirnumber}_event"); $MOD_PATH = XOOPS_ROOT_PATH . '/modules/' . $mydirname; if (!class_exists('piCal_xoops')) { require_once $MOD_PATH . '/class/piCal.php'; require_once $MOD_PATH . '/class/piCal_xoops.php'; } $cal = new piCal_xoops('', $xoopsConfig['language'], true); include $MOD_PATH . '/include/read_configs.php'; $whr_categories = $cal->get_where_about_categories(); $whr_class = $cal->get_where_about_class(); $content_row = $xoopsDB->fetchArray($xoopsDB->query("SELECT id, summary, description FROM {$table_event} WHERE id={$eventcomment_id} AND ({$whr_categories}) AND ({$whr_class})")); if (empty($content_row)) { redirect_header(XOOPS_URL . '/user.php', 3, _NOPERM); exit; } $subject = $myts->makeTboxData4Show($content_row['summary']); //HACK by domifara // $uri = XOOPS_URL.'/modules/'.$mydirname.'/index.php?action=View&event_id='.$eventcomment_id; $uri = XOOPS_URL . '/modules/' . $mydirname . '/index.php?action=View&event_id=' . $eventcomment_id; $str = strip_tags($myts->displayTarea(strip_tags($content_row['description']))); $summary = xoops_substr($str, 0, 255); return array('dirname' => $mydirname, 'module_name' => $module->getVar('name'), 'subject' => $subject, 'uri' => $uri, 'summary' => $summary); }
function get_set4sql($value, $col) { switch ($col['type']) { case 'text': case 'blob': if (get_magic_quotes_gpc()) { $value = stripslashes($value); } $length = empty($col['length']) ? 65535 : intval($col['length']); return "`{$col['name']}`='" . addslashes(xoops_substr($value, 0, $length)) . "'"; case 'char': case 'varchar': case 'string': if (get_magic_quotes_gpc()) { $value = stripslashes($value); } $length = empty($col['length']) ? 255 : intval($col['length']); return "`{$col['name']}`='" . addslashes(xoops_substr($value, 0, $length)) . "'"; case 'int': case 'integer': $value = intval($value); if (!empty($col['max'])) { $value = min($value, intval($col['max'])); } if (!empty($col['min'])) { $value = max($value, intval($col['min'])); } return "`{$col['name']}`={$value}"; } }
function fetchSummary($external_link_id) { $myts =& MyTextsanitizer::getInstance(); $module_handler =& xoops_gethandler('module'); $module =& $module_handler->getByDirname($this->mydirname); $config_handler =& xoops_gethandler('config'); $configs = $config_handler->getConfigList($module->mid()); // external_link_id means $content_id $content_id = intval($external_link_id); $mydirname = $this->mydirname; if (preg_match('/[^0-9a-zA-Z_-]/', $mydirname)) { die('Invalid mydirname'); } // get categoryObject and contentObject list($categoryObj, $contentObj) = pico_common_get_objects_from_content_id($mydirname, $content_id); // existence check if (!is_object($categoryObj) || !is_object($contentObj)) { return ''; } // permission check $content_data = $contentObj->getData(); if (empty($content_data['can_read'])) { return ''; } // dare to convert it irregularly $summary = str_replace('&', '&', htmlspecialchars(xoops_substr(strip_tags($content_data['body_cached']), 0, 255), ENT_QUOTES)); return array('dirname' => $mydirname, 'module_name' => $module->getVar('name'), 'subject' => $myts->makeTboxData4Show($content_data['subject_raw'], 1, 1), 'uri' => XOOPS_URL . '/modules/' . $mydirname . '/' . pico_common_make_content_link4html($configs, $content_data), 'summary' => $summary); }
function plzxoo_block_answers_show($options) { $max_rows = empty($options[1]) ? 5 : intval($options[1]); // 表示件数 $longest_subject = empty($options[2]) ? 50 : intval($options[2]); // 質問名の最大長 $single_answer_per_question = empty($options[3]) ? false : true; // 締め切った質問も表示するか $category_limit = preg_match('/^[0-9, ]+$/', @$options[4]) ? $options[4] : 0; // category limit $order_by_modified = empty($options[5]) ? false : true; // order by input_date(0) or modified_date(1) $db =& Database::getInstance(); if ($single_answer_per_question) { $grp_single = 'GROUP BY a.qid'; $select_input_date = 'MAX(a.input_date) AS max_input_date'; $select_modified_date = 'MAX(a.modified_date) AS max_modified_date'; $odr_1st = $order_by_modified ? 'max_modified_date DESC' : 'max_input_date DESC'; } else { $grp_single = ''; $select_input_date = 'a.input_date'; $select_modified_date = 'a.modified_date'; $odr_1st = $order_by_modified ? 'a.modified_date DESC' : 'a.input_date DESC'; } $whr_category = $category_limit ? 'q.cid IN (' . $category_limit . ')' : '1'; $result = $db->query("SELECT q.subject,q.qid,q.cid,c.name,q.uid,u.uname,q.size,a.uid,{$select_input_date},{$select_modified_date},a.body FROM " . $db->prefix("plzxoo_answer") . " a LEFT JOIN " . $db->prefix("plzxoo_question") . " q ON q.qid=a.qid LEFT JOIN " . $db->prefix("plzxoo_category") . " c ON q.cid=c.cid LEFT JOIN " . $db->prefix("users") . " u ON a.uid=u.uid WHERE ({$whr_category}) AND q.status IN (1,2) {$grp_single} ORDER BY {$odr_1st} LIMIT {$max_rows}"); $ret = array('dummy' => true); while (list($question_subject, $qid, $cid, $category_name, $question_uid, $answer_uname, $answer_num, $answer_uid, $input_date, $modified_date, $answer_body) = $db->fetchRow($result)) { $ret['answers'][] = array('question_subject' => htmlspecialchars(xoops_substr($question_subject, 0, $longest_subject), ENT_QUOTES), 'qid' => intval($qid), 'cid' => intval($cid), 'input_date' => intval($input_date), 'input_date_formatted' => formatTimestamp($input_date, 'm'), 'input_date_utime' => xoops_getUserTimestamp($input_date), 'modified_date' => intval($modified_date), 'modified_date_formatted' => formatTimestamp($modified_date, 'm'), 'modified_date_utime' => xoops_getUserTimestamp($modified_date), 'category_name' => htmlspecialchars($category_name, ENT_QUOTES), 'question_uid' => intval($question_uid), 'answer_uname' => htmlspecialchars($answer_uname, ENT_QUOTES), 'answer_num' => intval($answer_num), 'answer_uid' => intval($answer_uid), 'answer_body' => intval($answer_body)); } return $ret; }
function assignVar($key, $value) { $vars =& $this->mVars[$key]; if (!isset($vars)) { return; } switch ($vars['data_type']) { case XOBJ_DTYPE_BOOL: $vars['value'] = $value ? 1 : 0; return; case XOBJ_DTYPE_INT: $vars['value'] = $value !== null ? (int) $value : null; return; case XOBJ_DTYPE_FLOAT: $vars['value'] = $value !== null ? (double) $value : null; return; case XOBJ_DTYPE_STRING: $len = $vars['maxlength']; $vars['value'] = $len !== null && strlen($value) > $len ? xoops_substr($value, 0, $len, null) : $value; return; case XOBJ_DTYPE_TEXT: $vars['value'] = $value; return; } }
function fetchSummary($external_link_id) { $db =& Database::getInstance(); $myts =& MyTextsanitizer::getInstance(); $module_handler =& xoops_gethandler('module'); $module =& $module_handler->getByDirname($this->mydirname); $storyid = intval($external_link_id); $mydirname = $this->mydirname; if (preg_match('/[^0-9a-zA-Z_-]/', $mydirname)) { die('Invalid mydirname'); } $mytrustdirpath = dirname(dirname(__FILE__)); require_once dirname(dirname(__FILE__)) . '/class/bulletin.php'; if (Bulletin::isPublishedExists($mydirname, $storyid)) { $article = new Bulletin($mydirname, $storyid); $subject4assign = $article->getVar('title'); $summary = $article->getVar('hometext'); if (function_exists('easiestml')) { $summary = easiestml($summary); } $summary4assign = htmlspecialchars(xoops_substr($this->unhtmlspecialchars(strip_tags($summary)), 0, 255), ENT_QUOTES); } else { $subject4assign = ''; $summary4assign = ''; } return array('dirname' => $mydirname, 'module_name' => $module->getVar('name'), 'subject' => $subject4assign, 'uri' => XOOPS_URL . '/modules/' . $mydirname . '/index.php?page=article&storyid=' . $storyid, 'summary' => $summary4assign); }
/** * @param $queryarray * @param $andor * @param $limit * @param $offset * @param $userid * @param array $categories * @param int $sortby * @param string $searchin * @param string $extra * * @return array */ function publisher_search($queryarray, $andor, $limit, $offset, $userid, $categories = array(), $sortby = 0, $searchin = '', $extra = '') { $publisher =& PublisherPublisher::getInstance(); $ret = array(); if ($queryarray == '' || count($queryarray) == 0) { $hightlightKey = ''; } else { $keywords = implode('+', $queryarray); $hightlightKey = '&keywords=' . $keywords; } $itemsObjs =& $publisher->getHandler('item')->getItemsFromSearch($queryarray, $andor, $limit, $offset, $userid, $categories, $sortby, $searchin, $extra); $withCategoryPath = $publisher->getConfig('search_cat_path'); //xoops_load("xoopslocal"); $usersIds = array(); foreach ($itemsObjs as $obj) { $item['image'] = 'assets/images/item_icon.gif'; $item['link'] = $obj->getItemUrl(); $item['link'] .= !empty($hightlightKey) && strpos($item['link'], '.php?') === false ? '?' . ltrim($hightlightKey, '&') : $hightlightKey; if ($withCategoryPath) { $item['title'] = $obj->getCategoryPath(false) . ' > ' . $obj->getTitle(); } else { $item['title'] = $obj->getTitle(); } $item['time'] = $obj->getVar('datesub'); //must go has unix timestamp $item['uid'] = $obj->uid(); //"Fulltext search/highlight $text = $obj->getBody(); $sanitizedText = ''; $textLower = strtolower($text); $queryarray = is_array($queryarray) ? $queryarray : array($queryarray); if ($queryarray[0] != '' && count($queryarray) > 0) { foreach ($queryarray as $query) { $pos = strpos($textLower, strtolower($query)); //xoops_local("strpos", $textLower, strtolower($query)); $start = max($pos - 100, 0); $length = strlen($query) + 200; //xoops_local("strlen", $query) + 200; $context = $obj->highlight(xoops_substr($text, $start, $length, ' [...]'), $query); $sanitizedText .= '<p>[...] ' . $context . '</p>'; } } //End of highlight $item['text'] = $sanitizedText; $item['author'] = $obj->author_alias(); $item['datesub'] = $obj->getDatesub($publisher->getConfig('format_date')); $usersIds[$obj->uid()] = $obj->uid(); $ret[] = $item; unset($item, $sanitizedText); } xoops_load('XoopsUserUtility'); $usersNames = XoopsUserUtility::getUnameFromIds($usersIds, $publisher->getConfig('format_realname'), true); foreach ($ret as $key => $item) { if ($item['author'] == '') { $ret[$key]['author'] = isset($usersNames[$item['uid']]) ? $usersNames[$item['uid']] : ''; } } unset($usersNames, $usersIds); return $ret; }
function assignVar($key, $value) { $vars =& $this->mVars[$key]; if (!isset($vars)) { return; } switch ($vars['data_type']) { case XOBJ_DTYPE_BOOL: $vars['value'] = $value ? 1 : 0; break; case XOBJ_DTYPE_INT: $vars['value'] = $value !== null ? intval($value) : null; break; case XOBJ_DTYPE_FLOAT: $vars['value'] = $value !== null ? floatval($value) : null; break; case XOBJ_DTYPE_STRING: if ($vars['maxlength'] !== null && strlen($value) > $vars['maxlength']) { $vars['value'] = xoops_substr($value, 0, $vars['maxlength'], null); } else { $vars['value'] = $value; } break; case XOBJ_DTYPE_TEXT: $vars['value'] = $value; break; } }
function fetchSummary($external_link_id) { $db =& Database::getInstance(); $myts =& MyTextsanitizer::getInstance(); $module_handler =& xoops_gethandler('module'); $module =& $module_handler->getByDirname($this->mydirname); $aid = intval($external_link_id); $mydirname = $this->mydirname; if (preg_match('/[^0-9a-zA-Z_-]/', $mydirname)) { die('Invalid mydirname'); } // language constants @(include XOOPS_ROOT_PATH . '/modules/' . $mydirname . '/language/' . @$GLOBALS['xoopsConfig']['language'] . '/main.php'); if (!defined('_MD_PLZXOO_LANG_QUESTION')) { @(include XOOPS_ROOT_PATH . '/modules/' . $mydirname . '/language/english/main.php'); } // query $myrow = $db->fetchArray($db->query("SELECT a.uid AS answer_uid,a.body AS answer_body,a.comment,q.subject,q.uid AS question_uid,q.body AS question_body,q.qid FROM " . $db->prefix("plzxoo_answer") . " a LEFT JOIN " . $db->prefix("plzxoo_question") . " q ON a.qid=q.qid WHERE aid={$aid}")); $comment = array('dirname' => $mydirname, 'module_name' => $module->getVar('name'), 'question' => array('id' => intval($myrow['qid']), 'uid' => intval($myrow['question_uid']), 'subject' => $myts->makeTboxData4Show($myrow['subject']), 'body' => htmlspecialchars(xoops_substr(strip_tags($myrow['question_body']), 0, 255), ENT_QUOTES)), 'answer' => array('id' => $aid, 'uid' => intval($myrow['answer_uid']), 'body' => htmlspecialchars(xoops_substr(strip_tags($myrow['answer_body']), 0, 255), ENT_QUOTES), 'comment' => htmlspecialchars(xoops_substr(strip_tags($myrow['comment']), 0, 255), ENT_QUOTES))); include_once XOOPS_ROOT_PATH . '/class/template.php'; $tpl =& new XoopsTpl(); $tpl->assign('comment', $comment); $ret = $tpl->fetch('db:plzxoo_d3comment_reference.html'); return $ret; /* return array( 'dirname' => $mydirname , 'module_name' => $module->getVar( 'name' ) , 'subject' => $myts->makeTboxData4Show( $myrow['subject'] ) , 'uri' => XOOPS_URL.'/modules/'.$mydirname.'/index.php?action=detail&qid='.intval($myrow['qid']) , 'summary' => htmlspecialchars( xoops_substr( strip_tags( $myrow['body'] ) , 0 , 255 ) , ENT_QUOTES ) , ) ;*/ }
function b_gnavi_d3pipes_joints($options) { global $xoopsDB; $mydirname = empty($options[0]) ? basename(dirname(dirname(__FILE__))) : $options[0]; if (preg_match('/[^0-9a-zA-Z_-]/', $mydirname)) { die('Invalid mydirname'); } require dirname(dirname(__FILE__)) . '/include/read_configs.php'; $cat_limitation = empty($options[1]) ? 0 : 1; $photos_num = empty($options[2]) ? 10 : intval($options[2]); $show_desc = empty($options[3]) ? 0 : 1; $query = "ORDER BY unixtime DESC"; $title_max_length = 255; // Category limitation if ($cat_limitation) { include_once XOOPS_ROOT_PATH . "/class/xoopstree.php"; $cattree = new XoopsTree($table_cat, "cid", "pid"); $children = $cattree->getAllChildId($cat_limitation); $whr_cat = "l.cid IN ("; foreach ($children as $child) { $whr_cat .= "{$child},"; } $whr_cat .= "{$cat_limitation})"; for ($i = 1; $i <= 4; $i++) { $whr_cat .= " OR l.cid{$i} IN ("; foreach ($children as $child) { $whr_cat .= "{$child},"; } $whr_cat .= "{$cat_limitation})"; } $whr_cat = "(" . $whr_cat . ")"; } else { $whr_cat = '1'; } $block = array(); $myts =& MyTextSanitizer::getInstance(); if ($show_desc) { $result = $xoopsDB->query("SELECT l.lid , l.cid , l.title , l.ext , l.res_x , l.res_y , l.submitter , l.status , l.date AS unixtime , l.hits , l.rating , l.votes , l.comments , c.title AS cat_title ,t.description ,t.arrowhtml FROM {$table_photos} l LEFT JOIN {$table_cat} c ON l.cid=c.cid LEFT JOIN {$table_text} t ON l.lid=t.lid WHERE l.status>0 AND {$whr_cat} {$query}", $photos_num, 0); } else { $result = $xoopsDB->query("SELECT l.lid , l.cid , l.title , l.ext , l.res_x , l.res_y , l.submitter , l.status , l.date AS unixtime , l.hits , l.rating , l.votes , l.comments , c.title AS cat_title FROM {$table_photos} l LEFT JOIN {$table_cat} c ON l.cid=c.cid WHERE l.status>0 AND {$whr_cat} {$query}", $photos_num, 0); } $count = 1; while ($photo = $xoopsDB->fetchArray($result)) { $photo['title'] = xoops_substr($myts->makeTboxData4Show($photo['title']), 0, $title_max_length + 3); $photo['cat_title'] = $myts->makeTboxData4Show($photo['cat_title']); $photo['date'] = formatTimestamp($photo['unixtime'], 's'); if ($show_desc) { $photo['body'] = xoops_substr(strip_tags($myts->displayTarea($photo['description'], $photo['arrowhtml'], 1, 1, 1, 1, 1)), 0, 512); } else { $photo['body'] = ''; } $photo['date'] = formatTimestamp($photo['unixtime'], 's'); $block['photo'][$count++] = $photo; } $block['mod_url'] = $mod_url; return $block; }
function _strcut($text, $start, $end) { $text = $this->formatBlogText4Preview($text); if (strlen($text) >= $end) { $msg = xoops_substr($text, 0, $end - 1); } else { $msg = $text; } return $msg; }
function b_news_randomnews_show($options) { include_once XOOPS_ROOT_PATH . '/modules/news/include/functions.php'; $myts =& MyTextSanitizer::getInstance(); $block = array(); $block['sort'] = $options[0]; $tmpstory = new NewsStory(); $restricted = news_getmoduleoption('restrictindex'); $dateformat = news_getmoduleoption('dateformat'); $infotips = news_getmoduleoption('infotips'); if ($dateformat == '') { $dateformat = 's'; } if ($options[4] == 0) { $stories = $tmpstory->getRandomNews($options[1], 0, $restricted, 0, 1, $options[0]); } else { $topics = array_slice($options, 4); $stories = $tmpstory->getRandomNews($options[1], 0, $restricted, $topics, 1, $options[0]); } unset($tmpstory); if (count($stories) == 0) { return ''; } foreach ($stories as $story) { $news = array(); $title = $story->title(); if (strlen($title) > $options[2]) { $title = xoops_substr($title, 0, $options[2] + 3); } $news['title'] = $title; $news['id'] = $story->storyid(); $news['date'] = formatTimestamp($story->published(), $dateformat); $news['hits'] = $story->counter(); $news['rating'] = $story->rating(); $news['votes'] = $story->votes(); $news['author'] = sprintf("%s %s", _POSTEDBY, $story->uname()); $news['topic_title'] = $story->topic_title(); $news['topic_color'] = '#' . $myts->displayTarea($story->topic_color); if ($options[3] > 0) { $html = $story->nohtml() == 1 ? 0 : 1; $news['teaser'] = news_truncate_tagsafe($myts->displayTarea($story->hometext, $html), $options[3] + 3); $news['infotips'] = ''; } else { $news['teaser'] = ''; if ($infotips > 0) { $news['infotips'] = ' title="' . news_make_infotips($story->hometext()) . '"'; } else { $news['infotips'] = ''; } } $block['stories'][] = $news; } $block['lang_read_more'] = _MB_READMORE; return $block; }
function fetchSummary($external_link_id) { $db =& Database::getInstance(); $myts =& MyTextSanitizer::getInstance(); $module_handler =& xoops_gethandler('module'); $module =& $module_handler->getByDirname($this->mydirname); $myalbum_id = intval($external_link_id); $mydirname = $this->mydirname; if (preg_match('/[^0-9a-zA-Z_-]/', $mydirname)) { die('Invalid mydirname'); } $MOD_PATH = XOOPS_ROOT_PATH . '/modules/' . $mydirname; include $MOD_PATH . '/include/read_configs.php'; $content_row = $db->fetchArray($db->query("SELECT p.lid, p.title, p.ext, p.res_x, p.res_y, t.description FROM {$table_photos} p, {$table_text} t WHERE p.lid=t.lid and p.lid={$myalbum_id}")); if (empty($content_row)) { return ''; } $title = $myts->makeTboxData4Show($content_row['title']); $lid = intval($content_row['lid']); $ext = $content_row['ext']; $window_x = intval($content_row['res_x']); $window_y = intval($content_row['res_y']); $image_target = $photos_url . '/' . $lid . '.' . $ext; $photos_image = $thumbs_dir . '/' . $lid . '.' . $ext; $icons_image = $MOD_PATH . '/icons/' . $ext . '.gif'; if (file_exists($photos_image)) { $image_url = $thumbs_url . '/' . $lid . '.' . $ext; $size = getimagesize($photos_image); if ($size) { $width = intval($size[0]); $height = intval($size[1]); $image_tag = "<a href=\"{$image_target}\" target=\"blank\" onClick=\"window.open('{$image_target}','','width={$window_x},height={$window_y}');return(false);\"><img src=\"{$image_url}\" width=\"{$width}\" height=\"{$height}\" alt=\"{$title}\" title=\"{$title}\" align=\"left\" /></a>"; } } elseif (file_exists($icons_image)) { $image_url = XOOPS_URL . '/modules/' . $mydirname . '/icons/' . $ext . '.gif'; $size = getimagesize($icons_image); if ($size) { $width = intval($size[0]); $height = intval($size[1]); $image_tag = "<a href=\"{$image_target}\" target=\"blank\"><img src=\"{$image_url}\" width=\"{$width}\" height=\"{$height}\" alt=\"{$title}\" title=\"{$title}\" align=\"left\" /></a>"; } } $desc = ''; if ($content_row['description']) { $str = strip_tags($myts->displayTarea(strip_tags($content_row['description']))); $desc = xoops_substr($str, 0, 255); } if ($desc && $image_tag) { $summary = $image_tag . $desc; } elseif (!$desc && $image_tag) { $summary = $image_tag; } return array('dirname' => $mydirname, 'module_name' => $module->getVar('name'), 'subject' => $title, 'uri' => XOOPS_URL . '/modules/' . $mydirname . '/photo.php?lid=' . $myalbum_id, 'summary' => $summary); }
function smarty_modifier_mb_truncate($string, $length = 80, $etc = '...') { if ($length <= 0) { return ''; } if (!empty($string) && strlen($string) > $length) { return xoops_substr($string, 0, $length, $etc = '...'); } else { return $string; } }
function reassign($data) { $entries = array(); if (is_array($data)) { foreach ($data['recentArr'] as $item) { $entry = array('pubtime' => $item->getShow('published'), 'link' => XOOPS_MODULE_URL . '/chalog/?action=BlogView&id=' . $item->getShow('id'), 'headline' => $item->getShow('title'), 'description' => xoops_substr(strip_tags($item->getShow('comment')), 0, 255), 'allow_html' => true); $entry['fingerprint'] = $entry['link']; $entries[] = $entry; } } return $entries; }
function b_ams_top_show($options) { $myts =& MyTextSanitizer::getInstance(); include_once XOOPS_ROOT_PATH . "/modules/AMS/class/class.newsstory.php"; $block = array(); if (!isset($options[4]) || $options[4] == 0 || $options[4] == array(0)) { $stories = AmsStory::getAllPublished($options[1], 0, false, 0, 1, true, $options[0]); } else { // If using Xoops 2.0.9.1 way of saving array values if (is_array($options[4])) { $topics = $options[4]; } else { $topics = array_slice($options, 4); } $stories = AmsStory::getAllPublished($options[1], 0, false, $topics, 1, true, $options[0]); } foreach ($stories as $key => $story) { switch ($options[0]) { case "rating": $stat = $story->rating; break; case "counter": $stat = $story->counter(); break; case "published": $stat = formatTimestamp($story->published(), "s"); break; } $news = array(); $title = $story->title(); if (strlen($title) >= $options[2]) { $title = xoops_substr($title, 0, $options[2] - 1); } $html = $story->nohtml ? 0 : 1; $news['title'] = $title; $news['id'] = $story->storyid(); $news['date'] = formatTimestamp($story->published(), "s"); $news['hits'] = $stat; $news['friendlyurl'] = $story->friendlyurl; $news['friendlyurl_enable'] = $story->friendlyurl_enable; if ($options[3] > 0) { $news['teaser'] = xoops_substr($myts->displayTarea($story->hometext, $html), 0, $options[3] - 1); } else { $news['teaser'] = ""; } $block['stories'][] = $news; } return $block; }
function b_marquee_tplleaguestats($limit, $dateformat, $itemssize) { include_once XOOPS_ROOT_PATH . '/modules/marquee/include/functions.php'; //######################## SETTINGS ###################### $display_season_name = false; // display season name? $hour = 1; // GMT+1 -> var = 1 $use_itemsize = false; // use marquee $itemsize value? $overwrite_limit_settings = true; // overwrite marquee's limit settings? $new_limit = 6; // new limit (valid only if // overwrite_limit_settings = true) $overwrite_dateformat_settings = true; // overwrite marquee's dateformat? $new_dateformat = "d/m/Y"; // new dateformat (valid only if // overwrite_dateformat_settings=true) //######################## SETTINGS ###################### global $xoopsDB; if ($overwrite_limit_settings) { $limit = $new_limit; } if ($overwrite_dateformat_settings) { $dateformat = $new_dateformat; } $block = array(); $myts =& MyTextSanitizer::getInstance(); $sql = "SELECT H.OpponentName as home, A.OpponentName as away, M.LeagueMatchHomeGoals as home_p, M.LeagueMatchAwayGoals as away_p,\r\n\t\t\t\t M.LeagueMatchDate as date, S.SeasonName as season\r\n\t\t FROM " . $xoopsDB->prefix("tplls_leaguematches") . " M\r\n\t\t LEFT JOIN " . $xoopsDB->prefix("tplls_opponents") . " AS H ON M.LeagueMatchHomeID = H.OpponentID\r\n\t\t LEFT JOIN " . $xoopsDB->prefix("tplls_opponents") . " AS A ON M.LeagueMatchAwayID = A.OpponentID\r\n\t\t LEFT JOIN " . $xoopsDB->prefix("tplls_seasonnames") . " AS S ON M.LeagueMatchSeasonID = S.SeasonID\r\n\t\t ORDER BY M.LeagueMatchDate DESC\r\n\t\t LIMIT 0,{$limit}"; $result = $xoopsDB->query($sql); while ($myrow = $xoopsDB->fetchArray($result)) { $title = $myts->htmlSpecialChars($myrow["home"]) . " - " . $myts->htmlSpecialChars($myrow["away"]) . " " . $myts->htmlSpecialChars($myrow["home_p"]) . "-" . $myts->htmlSpecialChars($myrow["away_p"]); if ($use_itemsize) { if ($itemssize > 0) { $title = xoops_substr($title, 0, $itemssize + 3); } } $arr_date = explode("-", $myrow['date']); $season = ''; if ($display_season_name) { $season = $myrow['season']; } $block[] = array('date' => formatTimestamp(mktime($hour, 0, 0, $arr_date[1], $arr_date[2], $arr_date[0]), $dateformat), 'category' => $season, 'author' => "", 'title' => $title, 'link' => "<a href=\"" . XOOPS_URL . "/modules/tplleaguestats\">" . $title . "</a>"); } return $block; }
/** * @credits Thanks to Mithandir * @param string $str * @param int $start * @param int $length * @param string $trimmarker * @return string */ function publisher_substr($str, $start, $length, $trimmarker = '...') { // if the string is empty, let's get out ;-) if ($str == '') { return $str; } // reverse a string that is shortened with '' as trimmarker $reversed_string = strrev(xoops_substr($str, $start, $length, '')); // find first space in reversed string $position_of_space = strpos($reversed_string, " ", 0); // truncate the original string to a length of $length // minus the position of the last space // plus the length of the $trimmarker $truncated_string = xoops_substr($str, $start, $length - $position_of_space + strlen($trimmarker), $trimmarker); return $truncated_string; }
function b_marquee_xoopsfaq($limit, $dateformat, $itemssize) { include_once XOOPS_ROOT_PATH . '/modules/marquee/include/functions.php'; $block = array(); $myts =& MyTextSanitizer::getInstance(); $db =& Database::getInstance(); $result = $db->query("SELECT c.*, t.category_title FROM " . $db->prefix("xoopsfaq_contents") . " c, " . $db->prefix("xoopsfaq_categories") . " t WHERE c.contents_visible>0 AND (c. category_id=t.category_id) ORDER BY contents_time DESC", $limit, 0); while ($myrow = $db->fetchArray($result)) { $title = $myts->htmlSpecialChars($myrow["contents_title"]); if ($itemssize > 0) { $title = xoops_substr($title, 0, $itemssize + 3); } $block[] = array('date' => formatTimestamp($myrow['contents_time'], $dateformat), 'category' => $myts->htmlSpecialChars($myrow['category_title']), 'author' => 0, 'title' => $title, 'link' => "<a href='" . XOOPS_URL . '/modules/xoopsfaq/index.php?cat_id=' . $myrow['category_id'] . "#q" . $myrow['contents_id'] . "'>" . $title . '</a>'); } return $block; }
function b_marquee_xoopspoll($limit, $dateformat, $itemssize) { include_once XOOPS_ROOT_PATH . '/modules/marquee/include/functions.php'; $block = array(); $myts =& MyTextSanitizer::getInstance(); $db =& Database::getInstance(); $result = $db->query("SELECT * FROM " . $db->prefix("xoopspoll_desc") . " WHERE start_time<=" . time() . " and end_time>" . time() . " ORDER BY start_time DESC", $limit, 0); while ($myrow = $db->fetchArray($result)) { $title = $myts->htmlSpecialChars($myrow["question"]); if ($itemssize > 0) { $title = xoops_substr($title, 0, $itemssize + 3); } $block[] = array('date' => formatTimestamp($myrow['start_time'], $dateformat), 'category' => '', 'author' => $myrow['user_id'], 'title' => $title, 'link' => "<a href='" . XOOPS_URL . '/modules/xoopspoll/index.php?poll_id=' . $myrow['poll_id'] . "'>" . $title . '</a>'); } return $block; }
function b_marquee_xfaq($limit, $dateformat, $itemssize) { include_once XOOPS_ROOT_PATH . '/modules/marquee/include/functions.php'; $block = array(); $myts =& MyTextSanitizer::getInstance(); $db =& Database::getInstance(); $result = $db->query("SELECT f.*, t.topic_title, t.topic_submitter FROM " . $db->prefix("xfaq_faq") . " f, " . $db->prefix("xfaq_topic") . " t WHERE f.faq_online>0 AND (f.faq_topic=t.topic_id) ORDER BY faq_date_created DESC", $limit, 0); while ($myrow = $db->fetchArray($result)) { $title = $myts->htmlSpecialChars($myrow["faq_question"]); if ($itemssize > 0) { $title = xoops_substr($title, 0, $itemssize + 3); } $block[] = array('date' => formatTimestamp($myrow['faq_date_created'], $dateformat), 'category' => $myts->htmlSpecialChars($myrow['topic_title']), 'author' => XoopsUser::getUnameFromId(intval($myrow['topic_submitter'])), 'title' => $title, 'link' => "<a href='" . XOOPS_URL . "/modules/xfaq/faq.php?faq_id=" . $myrow['faq_id'] . "'>{$title}</a>"); } return $block; }
function b_marquee_catads($limit, $dateformat, $itemssize) { global $xoopsModule, $xoopsModuleConfig, $xoopsDB; include_once XOOPS_ROOT_PATH . '/modules/catads/class/cat.php'; $block = array(); if (empty($xoopsModule) || $xoopsModule->getVar('dirname') != 'catads') { $module_handler =& xoops_gethandler('module'); $module =& $module_handler->getByDirname('catads'); $config_handler =& xoops_gethandler('config'); $config =& $config_handler->getConfigsByCat(0, $module->getVar('mid')); } else { $module =& $xoopsModule; $config =& $xoopsModuleConfig; } //echo '<br />ok'; $ads_hnd =& xoops_getmodulehandler('ads', 'catads'); $criteria = new CriteriaCompo(new Criteria('waiting', '0')); $criteria->add(new Criteria('published', time(), '<')); $criteria->add(new Criteria('expired', time(), '>')); $criteria->setSort('published'); $criteria->setOrder('DESC'); $criteria->setLimit($options[0]); $nbads = $ads_hnd->getCount($criteria); $a_item = array(); $cat_buffer = array(); if ($nbads > 0) { $ads = $ads_hnd->getObjects($criteria); $ts =& MyTextSanitizer::getInstance(); foreach ($ads as $oneads) { if ($itemssize > 0) { $title = xoops_substr($oneads->getVar('ads_title'), 0, $itemssize); } else { $title = $oneads->getVar('ads_title'); } if (!isset($cat_buffer[$oneads->getVar('cat_id')])) { $tmpcat = new AdsCategory($oneads->getVar('cat_id')); $cat_buffer[$oneads->getVar('cat_id')] = $tmpcat->title(); $cat_title = $tmpcat->title(); } else { $cat_title = $cat_buffer[$oneads->getVar('cat_id')]; } $block[] = array('date' => formatTimestamp($oneads->getVar('published'), $dateformat), 'category' => '', 'author' => XoopsUser::getUnameFromId($oneads->getVar('uid')), 'title' => $title, 'link' => "<a href='" . XOOPS_URL . '/modules/catads/adsitem.php?ads_id=' . $oneads->getVar('ads_id') . "'>" . $title . '</a>'); unset($a_item); } } return $block; }
function b_marquee_mylinks($limit, $dateformat, $itemssize) { include_once XOOPS_ROOT_PATH . '/modules/marquee/include/functions.php'; include_once XOOPS_ROOT_PATH . '/include/comment_constants.php'; $block = array(); $myts =& MyTextSanitizer::getInstance(); $db =& Database::getInstance(); $result = $db->query("SELECT m.lid, m.cid, m.title, m.date, m.hits, m.submitter, c.title as catitle FROM " . $db->prefix("mylinks_links") . " m, " . $db->prefix("mylinks_cat") . " c WHERE (c.cid=m.cid) AND (m.status>0) ORDER BY date DESC", $limit, 0); while ($myrow = $db->fetchArray($result)) { $title = $myts->htmlSpecialChars($myrow["title"]); if ($itemssize > 0) { $title = xoops_substr($title, 0, $itemssize + 3); } $block[] = array('date' => formatTimestamp($myrow['date'], $dateformat), 'category' => $myts->htmlSpecialChars($myrow['catitle']), 'author' => $myrow['submitter'], 'title' => $title, 'link' => "<a href='" . XOOPS_URL . '/modules/mylinks/singlelink.php?cid=' . $myrow['cid'] . "&lid=" . $myrow['lid'] . "'>" . $title . '</a>'); } return $block; }
function about_block_page_show($options) { @(include dirname(dirname(__FILE__)) . "/xoops_version.php"); $block = array(); $page_handler =& xoops_getmodulehandler('page', 'about'); $page = $page_handler->get($options[0]); $page_text = strip_tags($page->getVar('page_text', 'n')); if ($options[1] > 0) { $url = XOOPS_URL . '/modules/' . $modversion['dirname'] . '/index.php?page_id=' . $options[0]; $trimmarker = <<<EOF <a href="{$url}" class="more">{$options[2]}</a> EOF; $page_text = xoops_substr($page_text, 0, $options[1]) . $trimmarker; } $block['page_text'] = $page_text; $block['page_image'] = $options[3] == 1 ? XOOPS_UPLOAD_URL . '/' . $modversion['dirname'] . '/' . $page->getVar('page_image', 's') : ''; return $block; }
function b_marquee_smartpartner($limit, $dateformat, $itemssize) { $block = array(); if (!defined("SMARTPARTNER_DIRNAME")) { define("SMARTPARTNER_DIRNAME", 'smartpartner'); } include_once XOOPS_ROOT_PATH . "/modules/" . SMARTPARTNER_DIRNAME . "/include/common.php"; // Creating the partner handler object $smartpartner_partner_handler =& smartpartner_gethandler('partner'); $smartpartner_category_handler =& smartpartner_gethandler('category'); // Randomize $partnersObj =& $smartpartner_partner_handler->getPartners(0, 0, _SPARTNER_STATUS_ACTIVE); if (count($partnersObj) > 1) { $key_arr = array_keys($partnersObj); $key_rand = array_rand($key_arr, count($key_arr)); for ($i = 0; $i < count($partnersObj) && $i < $limit; $i++) { $newObjs[$i] = $partnersObj[$key_rand[$i]]; } $partnersObj = $newObjs; } $cat_id = array(); foreach ($partnersObj as $partnerObj) { if (!in_array($partnerObj->categoryid(), $cat_id)) { $cat_id[] = $partnerObj->categoryid(); } } if ($partnersObj) { for ($j = 0; $j < count($cat_id); $j++) { $categoryObj = $smartpartner_category_handler->get($cat_id[$j]); for ($i = 0; $i < count($partnersObj); $i++) { if ($partnersObj[$i]->categoryid() == $cat_id[$j]) { $smartConfig =& smartpartner_getModuleConfig(); if ($itemssize > 0) { $title = xoops_substr($partnersObj[$i]->title(), 0, $itemssize + 3); } else { $title = $partnersObj[$i]->title(); } $block[] = array('date' => '', 'category' => '', 'author' => '', 'title' => $title, 'link' => "<a href='" . XOOPS_URL . '/modules/smartpartner/partner.php?id=' . $partnersObj[$i]->id() . "'>" . $title . '</a>'); } } } } return $block; }