function d3downloads_notify_base( $mydirname , $category , $item_id ) { include_once dirname( __FILE__ ).'/class/user_access.php' ; include_once dirname( __FILE__ ).'/class/mydownload.php' ; $db =& Database::getInstance() ; $module_handler =& xoops_gethandler( 'module' ) ; $module =& $module_handler->getByDirname( $mydirname ) ; $user_access = new user_access( $mydirname ) ; $mydownload = new MyDownload( $mydirname ) ; if ($category=='global') { $item['name'] = ''; $item['url'] = ''; return $item; } if ( $category=='category' ) { // Assume we have a valid cat_id $whr_cat = "cid IN (".implode(",", $user_access->can_read() ).")" ; $sql = "SELECT title FROM ".$db->prefix( $mydirname."_cat" )." WHERE cid='".$item_id."' AND ($whr_cat)" ; $result = $db->query( $sql ); $result_array = $db->fetchArray( $result ); $item['name'] = $result_array['title']; $item['url'] = XOOPS_URL . "/modules/" . $module->getVar('dirname') . "/index.php?cid=".$item_id ; return $item ; } if ( $category=='file' ) { // Assume we have a valid topid_id $whr_cat = "cid IN (".implode(",", $user_access->can_read() ).")" ; $sql = "SELECT cid, title FROM ".$db->prefix( $mydirname."_downloads" )." WHERE lid = '".$item_id."'"; $sql .= " AND ".$mydownload->whr_append( 'Single' )." AND ($whr_cat)" ; $result = $db->query($sql); $result_array = $db->fetchArray( $result ); $item['name'] = $result_array['title']; $item['url'] = XOOPS_URL . "/modules/" . $module->getVar('dirname') . "/index.php?page=singlefile&cid=" . $result_array['cid'] . "&lid=" . $item_id; return $item ; } }
function b_sitemap_d3downloads( $mydirname ) { require_once dirname( dirname(__FILE__) ).'/class/user_access.php' ; include_once dirname( dirname(__FILE__) ).'/class/mycategory.php' ; $user_access = new user_access( $mydirname ) ; $mycategory = new MyCategory( $mydirname, 'Show' ) ; $whr = "cid IN ( ".implode( ",", $user_access->can_read() )." )" ; return $mycategory->sitemap( '', $whr, 1 ) ; }
function b_d3downloads_mylink_show( $options ) { global $xoopsConfig ; $db =& Database::getInstance() ; $myts =& MyTextSanitizer::getInstance() ; include_once dirname( dirname(__FILE__) ).'/class/user_access.php' ; include_once dirname( dirname(__FILE__) ).'/class/block_download.php' ; require_once dirname( dirname(__FILE__) ).'/include/common_functions.php' ; $mydirname = empty( $options[0] ) ? 'd3downloads' : $options[0] ; $categories = empty( $options[1] ) ? '' : $options[1] ; $intree = empty( $options[2] ) ? 0 : 1 ; $selected_order = empty( $options[3] ) || ! in_array( $options[3] , d3download_list_order() ) ? 'd.date DESC' : $options[3] ; $max_entry = empty( $options[4] ) ? 10 : intval( $options[4] ) ; $max_size = empty( $options[5] ) ? 25 : intval( $options[5] ) ; $date_format = empty( $options[6] ) ? 'Y/m/d' : htmlspecialchars ( $options[6] , ENT_QUOTES ) ; $block_type= empty( $options[7] ) ? 1 : intval( $options[7] ) ; $this_template = empty( $options[8] ) ? 'db:'.$mydirname.'_block_mylink.html' : trim( $options[8] ) ; if( preg_match( '/[^0-9a-zA-Z_-]/' , $mydirname ) ) die( 'Invalid mydirname' ) ; $user_access = new user_access( $mydirname ) ; $whr = "d.cid IN (".implode(",", $user_access->can_read() ).")" ; $block_download = new block_download( $mydirname ) ; $downdata = $block_download->get_downdata_for_block( $whr, $max_entry, $max_size, $date_format, $selected_order, $categories, $intree, 1 ) ; if( ! empty( $downdata ) ){ $block['download'] = $downdata ; $block['mydirname'] = $mydirname ; $block['mod_url'] = XOOPS_URL.'/modules/'.$mydirname ; $block['selected_order'] = $selected_order; $block['type'] = $block_type; $block['lang_title'] = _MB_D3DOWNLOADS_LANG_TITLE; $block['lang_category'] = _MB_D3DOWNLOADS_LANG_CTITLE; $block['lang_postname'] = _MB_D3DOWNLOADS_LANG_POSTNAME; $block['lang_hits'] = _MB_D3DOWNLOADS_LANG_HITS; $block['lang_rating'] = _MB_D3DOWNLOADS_LANG_RATING; $block['lang_votes'] = _MB_D3DOWNLOADS_LANG_VOTES; $block['lang_updated'] = _MB_D3DOWNLOADS_LANG_DATE; if( empty( $options['disable_renderer'] ) ) { require_once XOOPS_ROOT_PATH.'/class/template.php' ; $tpl = new XoopsTpl() ; $tpl->assign( 'block' , $block ) ; $ret['content'] = $tpl->fetch( $this_template ) ; return $ret ; } else { return $block ; } } }
function b_d3downloads_list_show( $options ) { global $xoopsConfig ; $db =& Database::getInstance() ; $myts =& MyTextSanitizer::getInstance() ; include_once dirname( dirname(__FILE__) ).'/class/user_access.php' ; include_once dirname( dirname(__FILE__) ).'/class/block_download.php' ; require_once dirname( dirname(__FILE__) ).'/include/common_functions.php' ; $mydirname = empty( $options[0] ) ? 'd3downloads' : $options[0] ; $categories = empty( $options[1] ) ? '' : $options[1] ; $selected_order = empty( $options[2] ) || ! in_array( $options[2] , d3download_list_order() ) ? 'd.date DESC' : $options[2] ; $max_entry = empty( $options[3] ) ? 10 : intval( $options[3] ) ; $date_format = empty( $options[4] ) ? 'Y/m/d' : htmlspecialchars ( $options[4] , ENT_QUOTES ) ; $show_body = empty( $options[5] ) ? false : true ; $this_template = empty( $options[6] ) ? 'db:'.$mydirname.'_block_list.html' : trim( $options[6] ) ; $intree = empty( $options[7] ) ? 0 : 1 ; if( preg_match( '/[^0-9a-zA-Z_-]/' , $mydirname ) ) die( 'Invalid mydirname' ) ; $user_access = new user_access( $mydirname ) ; $whr = "d.cid IN (".implode(",", $user_access->can_read() ).")" ; $block_download = new block_download( $mydirname ) ; $downdata = $block_download->get_downdata_for_block( $whr, $max_entry, 0, $date_format, $selected_order, $categories, $intree ) ; if( ! empty( $downdata ) ){ $block['download'] = $downdata ; $block['mydirname'] = $mydirname ; $block['mod_url'] = XOOPS_URL.'/modules/'.$mydirname ; $block['show_body'] = $show_body; if( empty( $options['disable_renderer'] ) ) { require_once XOOPS_ROOT_PATH.'/class/template.php' ; $tpl = new XoopsTpl() ; $tpl->assign( 'block' , $block ) ; $ret['content'] = $tpl->fetch( $this_template ) ; return $ret ; } else { return $block ; } } }
function validate_id( $link_id ) { include_once dirname( dirname(__FILE__) ).'/class/user_access.php' ; include_once dirname( dirname(__FILE__) ).'/class/mydownload.php' ; $db =& Database::getInstance() ; $mydirname = $this->mydirname ; $user_access = new user_access( $mydirname ) ; $mydownload = new MyDownload( $mydirname ) ; $lid = intval( $link_id ) ; $whr_cat = "cid IN (".implode(",", $user_access->can_read() ).")" ; $sql = "SELECT COUNT(*) FROM ".$db->prefix( $mydirname."_downloads" )." WHERE lid='".$lid."' AND ( $whr_cat )" ; $sql .= " AND ".$mydownload->whr_append( 'Single' )." AND cancomment = '1'" ; list( $count ) = $db->fetchRow( $db->query( $sql ) ) ; if( $count <= 0 ) return false ; else return $lid ; }
function b_d3downloads_category_show( $options ) { include_once dirname( dirname(__FILE__) ).'/class/user_access.php' ; include_once dirname( dirname(__FILE__) ).'/class/mycategory.php' ; $mydirname = empty( $options[0] ) ? 'd3downloads' : $options[0] ; $intree = empty( $options[1] ) ? 0 : 1 ; $cols= empty( $options[2] ) ? 1 : intval( $options[2] ) ; $this_template = empty( $options[3] ) ? 'db:'.$mydirname.'_block_category.html' : trim( $options[3] ) ; if( preg_match( '/[^0-9a-zA-Z_-]/' , $mydirname ) ) die( 'Invalid mydirname' ) ; $user_access = new user_access( $mydirname ) ; $whr = "cid IN ( ".implode( ",", $user_access->can_read() )." )" ; $mycategory = new MyCategory( $mydirname, 'Show' ) ; $whr_append = $mycategory->default_whr_append() ; $category = $mycategory->sitemap( 'index.php?', $whr, 0, $whr_append, $intree ) ; if( ! empty( $category ) ){ $block['category'] = $category ; $block['mydirname'] = $mydirname ; $block['mod_url'] = XOOPS_URL.'/modules/'.$mydirname ; $block['intree'] = $intree; $block['cols'] = $cols; $block['lang_total'] = _MB_D3DOWNLOADS_TOTAL; if( empty( $options['disable_renderer'] ) ) { require_once XOOPS_ROOT_PATH.'/class/template.php' ; $tpl = new XoopsTpl() ; $tpl->assign( 'block' , $block ) ; $ret['content'] = $tpl->fetch( $this_template ) ; return $ret ; } else { return $block ; } } }
$referer_host = $referer['host']; foreach ( $xoopsModuleConfig['referers'] as $ref ) { if ( ! empty( $ref ) && preg_match("/".$ref."/i", $referer_host ) ) { $goodhost = "1"; break ; } } if ( ! $goodhost ) { redirect_header( XOOPS_URL."/modules/".$mydirname."/index.php?page=singlefile?cid=$cid&lid=$lid", 20, _MD_D3DOWNLOADS_NOPERMISETOLINK ); exit() ; } } $user_access = new user_access( $mydirname ) ; $whr_cat = "d.cid IN (".implode(",", $user_access->can_read() ).")" ; $mydownload = new MyDownload( $mydirname, $whr_cat, $lid ) ; if( ! $mydownload->return_lid() ) { d3download_delete_cache_of_categories( $mydirname ) ; redirect_header( XOOPS_URL."/modules/".$mydirname."/", 20, _MD_D3DOWNLOADS_NOMATCH ) ; exit() ; } if ( xoops_refcheck() ) $mydownload->Hits_Count( $lid ) ; d3download_delete_cache_of_categories( $mydirname ) ; switch( $second ) { case false : $url = $mydownload->return_url('Show') ; $filename = $mydownload->return_filename('Show') ; $ext = $mydownload->return_ext('Show') ;
function d3download_submenu( $mydirname, $submenu_option ) { include_once dirname( dirname(__FILE__) ).'/class/user_access.php' ; $module_handler =& xoops_gethandler('module'); $config_handler =& xoops_gethandler('config'); $module =& $module_handler->getByDirname( $mydirname ); $mod_config =& $config_handler->getConfigsByCat( 0, $module->getVar( 'mid' ) ); $user_access = new user_access( $mydirname ) ; $whr = "cid IN (".implode(",", $user_access->can_read() ).")" ; $constpref = '_MI_' . strtoupper( $mydirname ) ; $submenu = array( 0 => array( 'name' => '' , 'url' => '' , 'sub' => array() ) ) ; if( d3download_submenu_option( $submenu_option, 'categories' ) ){ $submenu = array_merge( $submenu, d3download_get_categories_for_submenu( $mydirname, $whr ) ) ; } if( ! empty( $mod_config['show_mypost'] ) ){ $submitter = d3download_is_submitter( $mydirname, $whr ) ; if( ! empty( $submitter ) ) { $submenu['sub'][] = array( 'name' => constant( $constpref.'_MYPOST_VIEW' ) , 'url' => 'index.php?submitter='.$submitter , ); } } if( d3download_submenu_option( $submenu_option, 'mylink' ) && d3download_total_mylink( $mydirname, 0, $whr ) ){ $submenu['sub'][] = array( 'name' => constant( $constpref.'_MYLINK' ) , 'url' => 'index.php?page=mylink' , ); } if( ! empty( $submenu['sub'] ) ) return $submenu['sub']; else return ''; }
function d3downloads_global_search_base( $mydirname, $keywords, $andor, $limit, $offset, $userid ) { require_once dirname( __FILE__ ).'/class/d3downloads.textsanitizer.php' ; include_once dirname( __FILE__ ).'/class/mydownload.php' ; include_once dirname( __FILE__ ).'/class/user_access.php' ; $myts =& d3downloadsTextSanitizer::getInstance() ; $db =& Database::getInstance() ; $showcontext = isset( $_GET['showcontext'] ) ? $_GET['showcontext'] : 0 ; $mydownload = new MyDownload( $mydirname ) ; $user_access = new user_access( $mydirname ) ; $whr = "cid IN ( ".implode( ",", $user_access->can_read() )." )" ; if( $showcontext == 1 ){ $sql = "SELECT lid, cid, title, description, submitter, date FROM ".$db->prefix( $mydirname."_downloads" )."" ; } else { $sql = "SELECT lid, cid, title, submitter, date, title FROM ".$db->prefix( $mydirname."_downloads" )."" ; } $sql .= " WHERE ".$mydownload->whr_append( 'Single' )." AND ( $whr )" ; if ( $userid != 0 ) $sql .= " AND submitter=".$userid." "; // because count() returns 1 even if a supplied variable // is not an array, we must check if $querryarray is really an array if ( is_array( $keywords ) && $count = count( $keywords ) ) { $sql .= " AND ( ( title LIKE '%$keywords[0]%' OR description LIKE '%$keywords[0]%' )" ; for( $i=1; $i<$count; $i++ ){ $sql .= " $andor " ; $sql .= "( title LIKE '%$keywords[$i]%' OR description LIKE '%$keywords[$i]%' )" ; } $sql .= ") " ; } $sql .= "ORDER BY date DESC" ; $result = $db->query( $sql, $limit, $offset ) ; $ret = array(); while( $myrow = $db->fetchArray( $result ) ) { $lid = intval( $myrow['lid'] ) ; $cid = intval( $myrow['cid'] ) ; $title = $myts->makeTboxData4Show( $myrow['title'] ) ; $date = intval( $myrow['date'] ) ; $submitter = intval( $myrow['submitter'] ) ; $context = '' ; // get context for module "search" if( function_exists( 'search_make_context' ) && $showcontext ) { $body = $myts->displayTarea( $myrow['description'], 0, 1, 1, 1, 1 ) ; if ( strstr ( $body , '[pagebreak]' ) ){ $str = explode( '[pagebreak]', $body , 2 ) ; $body = $str[0] ; } $full_context = strip_tags( $body ) ; if( function_exists( 'easiestml' ) ) $full_context = easiestml( $full_context ) ; $context = search_make_context( $full_context , $keywords ) ; } $ret[] = array( 'link' => "index.php?page=singlefile&cid=$cid&lid=$lid" , 'title' => $title , 'time' => $date , 'uid' => $submitter , 'context' => $context , ) ; } return $ret ; }
function b_d3downloads_download_show( $options ) { include_once dirname( dirname(__FILE__) ).'/class/mydownload.php' ; include_once dirname( dirname(__FILE__) ).'/class/user_access.php' ; $mydirname = empty( $options[0] ) ? 'd3downloads' : $options[0] ; $download_id = intval( @$options[1] ) ; $this_template = empty( $options[2] ) ? 'db:'.$mydirname.'_block_download.html' : trim( $options[2] ) ; if( preg_match( '/[^0-9a-zA-Z_-]/' , $mydirname ) ) die( 'Invalid mydirname' ) ; $mod_url = XOOPS_URL.'/modules/'.$mydirname ; $module_handler =& xoops_gethandler('module'); $config_handler =& xoops_gethandler('config'); $module =& $module_handler->getByDirname( $mydirname ); $mod_config =& $config_handler->getConfigsByCat(0, $module->getVar('mid')); $user_access = new user_access( $mydirname ) ; $whr_cat4read = "d.cid IN (".implode(",", $user_access->can_read() ).")" ; $mydownload = new MyDownload( $mydirname ); $download4assign = $mydownload->get_downdata_for_singleview( $whr_cat4read, $download_id, 0, 0, 0, 1 ) ; $canuseshots = ! empty( $mod_config['useshots'] ) ? 1 : 0 ; $use_license = ! empty( $mod_config['use_license'] ) ? 1 : 0 ; $show_postname = ! empty( $mod_config['show_postname'] ) ? 1 : 0 ; if( ! empty( $download4assign ) ){ global $xoopsModule; $dirname = is_object( @$xoopsModule ) ? $xoopsModule->getVar('dirname') : '' ; if( is_object( $GLOBALS['xoopsTpl'] ) && $dirname != $mydirname ) { require_once dirname( dirname(__FILE__) ).'/include/common_functions.php' ; $my_module_header = d3download_dbmoduleheader( $mydirname ); $GLOBALS['xoopsTpl']->assign('xoops_module_header', $my_module_header . "\n" . $GLOBALS['xoopsTpl']->get_template_vars( "xoops_module_header" ) ); } $block['download'] = $download4assign ; $block['mydirname'] = $mydirname ; $block['mod_url'] = $mod_url ; $block['canuseshots'] = $canuseshots ; $block['use_license'] = $use_license ; $block['show_postname'] = $show_postname ; $block['lang_title'] = _MB_D3DOWNLOADS_LANG_TITLE; $block['lang_ctitle'] = _MB_D3DOWNLOADS_LANG_CTITLE; $block['lang_version'] = _MB_D3DOWNLOADS_LANG_VERSION; $block['lang_updated'] = _MB_D3DOWNLOADS_LANG_DATE; $block['lang_description'] = _MB_D3DOWNLOADS_LANG_DESCRIPTION; $block['lang_hits'] = _MB_D3DOWNLOADS_LANG_HITS; $block['lang_size'] = _MB_D3DOWNLOADS_LANG_SIZE; $block['lang_kb'] = _MB_D3DOWNLOADS_LANG_KB; $block['lang_platform'] = _MB_D3DOWNLOADS_LANG_PLATFORM; $block['lang_license'] = _MB_D3DOWNLOADS_LICENSE; $block['lang_homepage'] = _MB_D3DOWNLOADS_LANG_HOMEPAGE; $block['lang_broken'] = _MB_D3DOWNLOADS_BROKEN_FILE; if( empty( $options['disable_renderer'] ) ) { require_once XOOPS_ROOT_PATH.'/class/template.php' ; $tpl = new XoopsTpl() ; $tpl->assign( 'block' , $block ) ; $ret['content'] = $tpl->fetch( $this_template ) ; return $ret ; } else { return $block ; } } }
function get_Item( $category_option, $intree=0, $limit=0, $offset=0, $rss=0, $mylink=0 ) { require_once dirname( dirname(__FILE__) ).'/class/user_access.php'; $user_access = new user_access( $this->mydirname ) ; $item = array() ; $permit = ( empty( $rss ) ) ? $this->get_permit() : false ; $whr = "d.cid IN (".implode(",", $user_access->can_read( $permit ) ).")" ; $where = "( $whr ) AND ".$this->whr_append()."" ; // categories switch( $intree ) { case true : $where .= " AND ( ". $this->whr_categories_intree_from_cids( $category_option )." )" ; break ; case false : $where .= " AND ( ". $this->whr_categories_from_cids( $category_option )." )" ; break ; } // mylink if ( ! empty( $mylink ) ){ $idarray = $this->get_mylink_idarray() ; if( empty( $idarray ) ) return $this->return_category_title( $category_option ) ; else $where .= " AND ( ". $this->get_whr_mylink( $idarray )." )" ; } $sql = $this->default_sql() ." WHERE $where ORDER BY d.date DESC" ; $result = $this->db->query( $sql, $limit, $offset ) ; if ( $this->db->getRowsNum( $result ) == 0 ) switch( $rss ) { case true : return $this->return_category_title( $category_option ) ; case false : return array() ; } $i = 0 ; while( $array = $this->db->fetchArray( $result ) ) { foreach ( $array as $key=>$value ){ $this->$key = $value ; } $lid = $this->return_lid() ; $cid = $this->return_cid() ; $item[$i]['link'] = $this->mod_url."/index.php?page=singlefile&cid=".$cid."&lid=".$lid ; $item[$i]['cat_link'] = $this->mod_url."/index.php?cid=".$cid ; $item[$i]['title'] = $this->return_title('Show') ; $item[$i]['cat_name'] = $this->return_category('Show') ; $item[$i]['time'] = $this->return_date() ; $item[$i]['uid'] = $this->return_submitter() ; $item[$i]['hits'] = $this->return_hits() ; $item[$i]['id'] = $lid ; $item[$i]['cid'] = $cid ; $item[$i]['replies'] = $this->return_comments() ; $html = $this->return_html() ; $smiley = $this->return_smiley() ; $xcode = $this->return_xcode() ; $br = $this->return_br() ; $filters = $this->return_filters() ; $body = $this->myts->displayTarea( $this->return_description('Show'), $html, $smiley, $xcode, 1, $br, $filters ) ; $item[$i]['description'] = $this->return_body( $lid, $cid, $body , 1, 0, $rss ) ; $i++ ; } return $item ; }