From a8eed1d23155c80991bc614a875fcb5e7eec3f95 Mon Sep 17 00:00:00 2001 From: VuThao Date: Mon, 18 Jan 2016 17:51:05 +0700 Subject: [PATCH] Coding Style PSR-2 http://www.php-fig.org/psr/psr-2/ --- .gitignore | 1 + modules/weblinks/action_mysql.php | 6 +- modules/weblinks/admin.functions.php | 107 +++--- modules/weblinks/admin.menu.php | 6 +- modules/weblinks/admin/alias.php | 10 +- modules/weblinks/admin/brokenlink.php | 63 ++-- modules/weblinks/admin/cat.php | 332 ++++++++---------- modules/weblinks/admin/change_cat.php | 77 ++-- modules/weblinks/admin/checklink.php | 107 +++--- modules/weblinks/admin/config.php | 80 ++--- modules/weblinks/admin/content.php | 331 ++++++++--------- modules/weblinks/admin/del_cat.php | 55 ++- modules/weblinks/admin/del_link.php | 85 ++--- modules/weblinks/admin/delbroken.php | 19 +- modules/weblinks/admin/main.php | 65 ++-- .../weblinks/blocks/module.block_category.php | 105 +++--- modules/weblinks/checkurl.class.php | 111 +++--- modules/weblinks/funcs/detail.php | 29 +- modules/weblinks/funcs/main.php | 80 +++-- modules/weblinks/funcs/reportlink.php | 101 +++--- modules/weblinks/funcs/rss.php | 74 ++-- modules/weblinks/funcs/sitemap.php | 8 +- modules/weblinks/funcs/viewcat.php | 104 +++--- modules/weblinks/funcs/visitlink.php | 47 ++- modules/weblinks/functions.php | 177 +++++----- modules/weblinks/global.functions.php | 40 +-- modules/weblinks/language/admin_en.php | 6 +- modules/weblinks/language/admin_vi.php | 4 +- modules/weblinks/language/en.php | 6 +- modules/weblinks/language/vi.php | 6 +- modules/weblinks/rssdata.php | 15 +- modules/weblinks/search.php | 55 ++- modules/weblinks/siteinfo.php | 28 +- modules/weblinks/theme.php | 330 ++++++++--------- modules/weblinks/version.php | 24 +- 35 files changed, 1284 insertions(+), 1410 deletions(-) diff --git a/.gitignore b/.gitignore index 6f06d187d..d9180084a 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ /.settings /.project /.htaccess +/.buildpath /.gitattributes /composer.json /config.php diff --git a/modules/weblinks/action_mysql.php b/modules/weblinks/action_mysql.php index 77f992d6a..5f4942d06 100644 --- a/modules/weblinks/action_mysql.php +++ b/modules/weblinks/action_mysql.php @@ -8,7 +8,9 @@ * @Createdate 2-10-2010 20:59 */ -if ( ! defined( 'NV_IS_FILE_MODULES' ) ) die( 'Stop!!!' ); +if (! defined('NV_IS_FILE_MODULES')) { + die('Stop!!!'); +} $sql_drop_module = array(); @@ -93,4 +95,4 @@ ('sortoption', 'byid'), ('imgwidth', '100'), ('imgheight', '74'), -('timeout', '1')"; \ No newline at end of file +('timeout', '1')"; diff --git a/modules/weblinks/admin.functions.php b/modules/weblinks/admin.functions.php index ad5f39633..42675f6ad 100644 --- a/modules/weblinks/admin.functions.php +++ b/modules/weblinks/admin.functions.php @@ -8,26 +8,28 @@ * @Createdate 12/31/2009 2:29 */ -if( ! defined( 'NV_ADMIN' ) or ! defined( 'NV_MAINFILE' ) or ! defined( 'NV_IS_MODADMIN' ) ) die( 'Stop!!!' ); +if (! defined('NV_ADMIN') or ! defined('NV_MAINFILE') or ! defined('NV_IS_MODADMIN')) { + die('Stop!!!'); +} $allow_func = array( - 'alias', - 'main', - 'cat', - 'change_cat', - 'del_cat', - 'content', - 'del_link', - 'config', - 'multidel', - 'checklink', - 'brokenlink', - 'delbroken' + 'alias', + 'main', + 'cat', + 'change_cat', + 'del_cat', + 'content', + 'del_link', + 'config', + 'multidel', + 'checklink', + 'brokenlink', + 'delbroken' ); -define( 'NV_IS_FILE_ADMIN', true ); +define('NV_IS_FILE_ADMIN', true); -require_once ( NV_ROOTDIR . '/modules/' . $module_file . '/global.functions.php' ); +require_once(NV_ROOTDIR . '/modules/' . $module_file . '/global.functions.php'); /** @@ -36,22 +38,21 @@ * @param mixed $parentid * @return */ -function nv_fix_cat( $parentid ) +function nv_fix_cat($parentid) { - global $db, $module_data; + global $db, $module_data; - $sql = 'SELECT catid FROM ' . NV_PREFIXLANG . '_' . $module_data . '_cat WHERE parentid=' . $parentid . ' ORDER BY weight ASC'; - $result = $db->query( $sql ); + $sql = 'SELECT catid FROM ' . NV_PREFIXLANG . '_' . $module_data . '_cat WHERE parentid=' . $parentid . ' ORDER BY weight ASC'; + $result = $db->query($sql); - $weight = 0; - while( $row = $result->fetch() ) - { - ++$weight; - $sql = 'UPDATE ' . NV_PREFIXLANG . '_' . $module_data . '_cat SET weight=' . $weight . ' WHERE catid=' . intval( $row['catid'] ); - $db->query( $sql ); - } + $weight = 0; + while ($row = $result->fetch()) { + ++$weight; + $sql = 'UPDATE ' . NV_PREFIXLANG . '_' . $module_data . '_cat SET weight=' . $weight . ' WHERE catid=' . intval($row['catid']); + $db->query($sql); + } - $result->closeCursor(); + $result->closeCursor(); } /** @@ -64,16 +65,15 @@ function nv_fix_cat( $parentid ) * @param string $func_onchange * @return */ -function drawselect_number( $select_name = '', $number_start = 0, $number_end = 1, $number_curent = 0, $func_onchange = '' ) +function drawselect_number($select_name = '', $number_start = 0, $number_end = 1, $number_curent = 0, $func_onchange = '') { - $html = ''; - return $html; + $html = ''; + return $html; } /** @@ -85,15 +85,16 @@ function drawselect_number( $select_name = '', $number_start = 0, $number_end = * @param string $xkey * @return */ -function getlevel( $pid, $array_cat, $numxtitle = 5, $xkey = ' ' ) +function getlevel($pid, $array_cat, $numxtitle = 5, $xkey = ' ') { - $html = ''; - for( $i = 0; $i < $numxtitle; ++$i ) - { - $html .= $xkey; - } - if( $array_cat[$pid]['parentid'] != 0 ) $html .= getlevel( $array_cat[$pid]['parentid'], $array_cat ); - return $html; + $html = ''; + for ($i = 0; $i < $numxtitle; ++$i) { + $html .= $xkey; + } + if ($array_cat[$pid]['parentid'] != 0) { + $html .= getlevel($array_cat[$pid]['parentid'], $array_cat); + } + return $html; } /** @@ -106,13 +107,13 @@ function getlevel( $pid, $array_cat, $numxtitle = 5, $xkey = ' ' ) * @param string $func_onchange * @return */ -function drawselect_yesno( $select_name = '', $curent = 1, $lang_no = '', $lang_yes = '', $func_onchange = '' ) +function drawselect_yesno($select_name = '', $curent = 1, $lang_no = '', $lang_yes = '', $func_onchange = '') { - $html = ''; - return $html; -} \ No newline at end of file + $html = ''; + return $html; +} diff --git a/modules/weblinks/admin.menu.php b/modules/weblinks/admin.menu.php index 9a09a289a..5aac2dfde 100644 --- a/modules/weblinks/admin.menu.php +++ b/modules/weblinks/admin.menu.php @@ -8,9 +8,11 @@ * @Createdate 07/30/2013 10:27 */ -if( ! defined( 'NV_ADMIN' ) ) die( 'Stop!!!' ); +if (! defined('NV_ADMIN')) { + die('Stop!!!'); +} $submenu['content'] = $lang_module['weblink_add_link']; $submenu['cat'] = $lang_module['weblink_catlist']; $submenu['brokenlink'] = $lang_module['weblink_link_broken']; -$submenu['config'] = $lang_module['weblink_config']; \ No newline at end of file +$submenu['config'] = $lang_module['weblink_config']; diff --git a/modules/weblinks/admin/alias.php b/modules/weblinks/admin/alias.php index 5f0bda3ba..d15667aa7 100644 --- a/modules/weblinks/admin/alias.php +++ b/modules/weblinks/admin/alias.php @@ -8,11 +8,13 @@ * @Createdate 2-10-2010 18:49 */ -if( ! defined( 'NV_IS_FILE_ADMIN' ) ) die( 'Stop!!!' ); +if (! defined('NV_IS_FILE_ADMIN')) { + die('Stop!!!'); +} -$title = $nv_Request->get_title( 'title', 'post', '' ); -$alias = change_alias( $title ); +$title = $nv_Request->get_title('title', 'post', ''); +$alias = change_alias($title); include NV_ROOTDIR . '/includes/header.php'; echo $alias; -include NV_ROOTDIR . '/includes/footer.php'; \ No newline at end of file +include NV_ROOTDIR . '/includes/footer.php'; diff --git a/modules/weblinks/admin/brokenlink.php b/modules/weblinks/admin/brokenlink.php index 7205d7cf5..9f2cdbbc1 100644 --- a/modules/weblinks/admin/brokenlink.php +++ b/modules/weblinks/admin/brokenlink.php @@ -8,59 +8,56 @@ * @Createdate 2-9-2010 14:43 */ -if( ! defined( 'NV_IS_FILE_ADMIN' ) ) die( 'Stop!!!' ); +if (! defined('NV_IS_FILE_ADMIN')) { + die('Stop!!!'); +} $page_title = $lang_module['weblink_link_broken']; -$xtpl = new XTemplate( 'link_broken.tpl', NV_ROOTDIR . '/themes/' . $global_config['module_theme'] . '/modules/' . $module_file ); -$xtpl->assign( 'LANG', $lang_module ); +$xtpl = new XTemplate('link_broken.tpl', NV_ROOTDIR . '/themes/' . $global_config['module_theme'] . '/modules/' . $module_file); +$xtpl->assign('LANG', $lang_module); $base_url = NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name; $per_page = 10; -$page = $nv_Request->get_int( 'page', 'get', 0 ); +$page = $nv_Request->get_int('page', 'get', 0); -$all_page = $db->query( 'SELECT COUNT(*) FROM ' . NV_PREFIXLANG . '_' . $module_data . '_rows a INNER JOIN ' . NV_PREFIXLANG . '_' . $module_data . '_report b ON a.id=b.id' )->fetchColumn(); +$all_page = $db->query('SELECT COUNT(*) FROM ' . NV_PREFIXLANG . '_' . $module_data . '_rows a INNER JOIN ' . NV_PREFIXLANG . '_' . $module_data . '_report b ON a.id=b.id')->fetchColumn(); $sql = 'SELECT a.url, a.title, b.type, a.id FROM ' . NV_PREFIXLANG . '_' . $module_data . '_rows a INNER JOIN ' . NV_PREFIXLANG . '_' . $module_data . '_report b ON a.id=b.id LIMIT ' . $page . ', ' . $per_page; // GROUP BY a.url -if( $all_page > 0 ) -{ - $xtpl->assign( 'FORM_ACTION', NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=delbroken' ); +if ($all_page > 0) { + $xtpl->assign('FORM_ACTION', NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=delbroken'); - $result = $db->query( $sql ); - while( $row = $result->fetch() ) - { - $xtpl->assign( 'ROW', array( - 'id' => $row['id'], - 'title' => $row['title'], - 'url' => $row['url'], - 'type' => $row['type'] == 1 ? $lang_module['weblink_link_broken_die'] : $lang_module['weblink_link_broken_bad'], - 'url_edit' => NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=content&id=' . $row['id'] ) ); + $result = $db->query($sql); + while ($row = $result->fetch()) { + $xtpl->assign('ROW', array( + 'id' => $row['id'], + 'title' => $row['title'], + 'url' => $row['url'], + 'type' => $row['type'] == 1 ? $lang_module['weblink_link_broken_die'] : $lang_module['weblink_link_broken_bad'], + 'url_edit' => NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=content&id=' . $row['id'] )); - $xtpl->parse( 'main.data.loop' ); - } + $xtpl->parse('main.data.loop'); + } - $xtpl->parse( 'main.data' ); -} -else -{ - $xtpl->parse( 'main.empty' ); + $xtpl->parse('main.data'); +} else { + $xtpl->parse('main.empty'); } -$generate_page = nv_generate_page( $base_url, $all_page, $per_page, $page ); -if( ! empty( $generate_page ) ) -{ - $xtpl->assign( 'GENERATE_PAGE', $generate_page ); - $xtpl->parse( 'main.generate_page' ); +$generate_page = nv_generate_page($base_url, $all_page, $per_page, $page); +if (! empty($generate_page)) { + $xtpl->assign('GENERATE_PAGE', $generate_page); + $xtpl->parse('main.generate_page'); } -$xtpl->parse( 'main' ); -$contents = $xtpl->text( 'main' ); +$xtpl->parse('main'); +$contents = $xtpl->text('main'); include NV_ROOTDIR . '/includes/header.php'; -echo nv_admin_theme( $contents ); -include NV_ROOTDIR . '/includes/footer.php'; \ No newline at end of file +echo nv_admin_theme($contents); +include NV_ROOTDIR . '/includes/footer.php'; diff --git a/modules/weblinks/admin/cat.php b/modules/weblinks/admin/cat.php index d5792aafe..b5092f5bc 100644 --- a/modules/weblinks/admin/cat.php +++ b/modules/weblinks/admin/cat.php @@ -8,65 +8,65 @@ * @Createdate 2-9-2010 14:43 */ -if( ! defined( 'NV_IS_FILE_ADMIN' ) ) die( 'Stop!!!' ); +if (! defined('NV_IS_FILE_ADMIN')) { + die('Stop!!!'); +} $error = ''; -$catid = $nv_Request->get_int( 'catid', 'get', 0 ); -$pid = $nv_Request->get_int( 'pid', 'get', 0 ); +$catid = $nv_Request->get_int('catid', 'get', 0); +$pid = $nv_Request->get_int('pid', 'get', 0); $data_content = array( - 'catid' => $catid, - 'parentid_old' => 0, - 'parentid' => $pid, - 'title' => '', - 'alias' => '', - 'description' => '', - 'keywords' => '' + 'catid' => $catid, + 'parentid_old' => 0, + 'parentid' => $pid, + 'title' => '', + 'alias' => '', + 'description' => '', + 'keywords' => '' ); // Get array catid -$querysubcat = $db->query( 'SELECT * FROM ' . NV_PREFIXLANG . '_' . $module_data . '_cat ORDER BY parentid, weight ASC' ); +$querysubcat = $db->query('SELECT * FROM ' . NV_PREFIXLANG . '_' . $module_data . '_cat ORDER BY parentid, weight ASC'); $array_cat = array(); $numcat = 0; -while( $row = $querysubcat->fetch() ) -{ - $array_cat[$row['catid']] = $row; - if( $row['parentid'] == $pid ) ++$numcat; +while ($row = $querysubcat->fetch()) { + $array_cat[$row['catid']] = $row; + if ($row['parentid'] == $pid) { + ++$numcat; + } } -if( $pid > 0 ) $page_title = $lang_module['categories'] . ' : ' . $array_cat[$pid]['title']; +if ($pid > 0) { + $page_title = $lang_module['categories'] . ' : ' . $array_cat[$pid]['title']; +} //post data -$savecat = $nv_Request->get_int( 'savecat', 'post', 0 ); - -if( ! empty( $savecat ) ) -{ - $data_content['catid'] = $nv_Request->get_int( 'catid', 'post', 0 ); - $data_content['parentid_old'] = $nv_Request->get_int( 'parentid_old', 'post', 0 ); - $data_content['parentid'] = $nv_Request->get_int( 'parentid', 'post', 0 ); - $data_content['title'] = nv_substr( $nv_Request->get_title( 'title', 'post', '', 1 ), 0, 100 ); - $data_content['catimage'] = $nv_Request->get_title( 'catimage', 'post' ); - $data_content['keywords'] = $nv_Request->get_title( 'keywords', 'post' ); - $data_content['alias'] = nv_substr( $nv_Request->get_title( 'alias', 'post', '', 1 ), 0, 100 ); - $data_content['description'] = $nv_Request->get_textarea( 'description', '', NV_ALLOWED_HTML_TAGS ); - $data_content['alias'] = ( $data_content['alias'] == '' ) ? change_alias( $data_content['title'] ) : change_alias( $data_content['alias'] ); - - if( empty( $data_content['title'] ) ) - { - $error = $lang_module['weblink_sub_input']; - } - else - { - if( $data_content['catid'] == 0 ) - { - $weight = $db->query( 'SELECT max(weight) FROM ' . NV_PREFIXLANG . '_' . $module_data . '_cat WHERE parentid=' . intval( $data_content['parentid'] ) . '' )->fetchColumn(); - $weight = intval( $weight ) + 1; - - $stmt = $db->prepare( 'INSERT INTO ' . NV_PREFIXLANG . '_' . $module_data . '_cat SET - parentid =' . intval( $data_content['parentid'] ) . ', - weight =' . intval( $weight ) . ', +$savecat = $nv_Request->get_int('savecat', 'post', 0); + +if (! empty($savecat)) { + $data_content['catid'] = $nv_Request->get_int('catid', 'post', 0); + $data_content['parentid_old'] = $nv_Request->get_int('parentid_old', 'post', 0); + $data_content['parentid'] = $nv_Request->get_int('parentid', 'post', 0); + $data_content['title'] = nv_substr($nv_Request->get_title('title', 'post', '', 1), 0, 100); + $data_content['catimage'] = $nv_Request->get_title('catimage', 'post'); + $data_content['keywords'] = $nv_Request->get_title('keywords', 'post'); + $data_content['alias'] = nv_substr($nv_Request->get_title('alias', 'post', '', 1), 0, 100); + $data_content['description'] = $nv_Request->get_textarea('description', '', NV_ALLOWED_HTML_TAGS); + $data_content['alias'] = ($data_content['alias'] == '') ? change_alias($data_content['title']) : change_alias($data_content['alias']); + + if (empty($data_content['title'])) { + $error = $lang_module['weblink_sub_input']; + } else { + if ($data_content['catid'] == 0) { + $weight = $db->query('SELECT max(weight) FROM ' . NV_PREFIXLANG . '_' . $module_data . '_cat WHERE parentid=' . intval($data_content['parentid']) . '')->fetchColumn(); + $weight = intval($weight) + 1; + + $stmt = $db->prepare('INSERT INTO ' . NV_PREFIXLANG . '_' . $module_data . '_cat SET + parentid =' . intval($data_content['parentid']) . ', + weight =' . intval($weight) . ', inhome =1, numlinks =3, title =:title, @@ -75,159 +75,139 @@ description =:description, keywords =:keywords, add_time = ' . NV_CURRENTTIME . ', - edit_time =' . NV_CURRENTTIME ); - $stmt->bindParam( ':title', $data_content['title'], PDO::PARAM_STR ); - $stmt->bindParam( ':catimage', $data_content['catimage'], PDO::PARAM_STR ); - $stmt->bindParam( ':alias', $data_content['alias'], PDO::PARAM_STR ); - $stmt->bindParam( ':description', $data_content['description'], PDO::PARAM_STR ); - $stmt->bindParam( ':keywords', $data_content['keywords'], PDO::PARAM_STR ); - $stmt->execute(); - if( $idnew = $db->lastInsertId() ) - { - nv_insert_logs( NV_LANG_DATA, $module_name, $lang_module['add_cat'], $data_content['title'], $admin_info['userid'] ); - $nv_Cache->delMod( $module_name ); - Header( 'Location: ' . NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=' . $op . '&pid=' . $data_content['parentid'] ); - die(); - } - else - { - $error = $lang_module['errorsave']; - } - } - elseif( $data_content['catid'] > 0 ) - { - $check_exit = 0; - - if( $data_content['parentid'] != $data_content['parentid_old'] ) - { - $check_exit = $db->query( 'SELECT COUNT(*) FROM ' . NV_PREFIXLANG . '_' . $module_data . '_rows WHERE catid = ' . intval( $data_content['catid'] ) )->fetchColumn(); - } - - if( intval( $check_exit ) > 0 ) - { - $error = 'error delete cat'; - } - else - { - $stmt = $db->prepare( 'UPDATE ' . NV_PREFIXLANG . '_' . $module_data . '_cat SET - parentid=' . intval( $data_content['parentid'] ) . ', + edit_time =' . NV_CURRENTTIME); + $stmt->bindParam(':title', $data_content['title'], PDO::PARAM_STR); + $stmt->bindParam(':catimage', $data_content['catimage'], PDO::PARAM_STR); + $stmt->bindParam(':alias', $data_content['alias'], PDO::PARAM_STR); + $stmt->bindParam(':description', $data_content['description'], PDO::PARAM_STR); + $stmt->bindParam(':keywords', $data_content['keywords'], PDO::PARAM_STR); + $stmt->execute(); + if ($idnew = $db->lastInsertId()) { + nv_insert_logs(NV_LANG_DATA, $module_name, $lang_module['add_cat'], $data_content['title'], $admin_info['userid']); + $nv_Cache->delMod($module_name); + Header('Location: ' . NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=' . $op . '&pid=' . $data_content['parentid']); + die(); + } else { + $error = $lang_module['errorsave']; + } + } elseif ($data_content['catid'] > 0) { + $check_exit = 0; + + if ($data_content['parentid'] != $data_content['parentid_old']) { + $check_exit = $db->query('SELECT COUNT(*) FROM ' . NV_PREFIXLANG . '_' . $module_data . '_rows WHERE catid = ' . intval($data_content['catid']))->fetchColumn(); + } + + if (intval($check_exit) > 0) { + $error = 'error delete cat'; + } else { + $stmt = $db->prepare('UPDATE ' . NV_PREFIXLANG . '_' . $module_data . '_cat SET + parentid=' . intval($data_content['parentid']) . ', title=:title, catimage=:catimage, alias=:alias, description=:description, keywords=:keywords, edit_time=' . NV_CURRENTTIME . ' - WHERE catid =' . $data_content['catid'] ); - $stmt->bindParam( ':title', $data_content['title'], PDO::PARAM_STR ); - $stmt->bindParam( ':catimage', $data_content['catimage'], PDO::PARAM_STR ); - $stmt->bindParam( ':alias', $data_content['alias'], PDO::PARAM_STR ); - $stmt->bindParam( ':description', $data_content['description'], PDO::PARAM_STR ); - $stmt->bindParam( ':keywords', $data_content['keywords'], PDO::PARAM_STR ); - - if( $stmt->execute() ) - { - - if( $data_content['parentid'] != $data_content['parentid_old'] ) - { - $weight = $db->query( 'SELECT max(weight) FROM ' . NV_PREFIXLANG . '_' . $module_data . '_cat WHERE parentid=' . intval( $data_content['parentid'] ) . '' )->fetchColumn(); - $weight = intval( $weight ) + 1; - $sql = 'UPDATE ' . NV_PREFIXLANG . '_' . $module_data . '_cat SET weight=' . $weight . ' WHERE catid=' . intval( $data_content['catid'] ); - $db->query( $sql ); - nv_fix_cat( $data_content['parentid'] ); - nv_fix_cat( $data_content['parentid_old'] ); - } - - $nv_Cache->delMod( $module_name ); - nv_insert_logs( NV_LANG_DATA, $module_name, $lang_module['edit_cat'], $data_content['title'], $admin_info['userid'] ); - - Header( 'Location: ' . NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=' . $op . '&pid=' . $data_content['parentid'] ); - die(); - } - else - { - $error = $lang_module['errorsave']; - } - - } - } - } + WHERE catid =' . $data_content['catid']); + $stmt->bindParam(':title', $data_content['title'], PDO::PARAM_STR); + $stmt->bindParam(':catimage', $data_content['catimage'], PDO::PARAM_STR); + $stmt->bindParam(':alias', $data_content['alias'], PDO::PARAM_STR); + $stmt->bindParam(':description', $data_content['description'], PDO::PARAM_STR); + $stmt->bindParam(':keywords', $data_content['keywords'], PDO::PARAM_STR); + + if ($stmt->execute()) { + if ($data_content['parentid'] != $data_content['parentid_old']) { + $weight = $db->query('SELECT max(weight) FROM ' . NV_PREFIXLANG . '_' . $module_data . '_cat WHERE parentid=' . intval($data_content['parentid']) . '')->fetchColumn(); + $weight = intval($weight) + 1; + $sql = 'UPDATE ' . NV_PREFIXLANG . '_' . $module_data . '_cat SET weight=' . $weight . ' WHERE catid=' . intval($data_content['catid']); + $db->query($sql); + nv_fix_cat($data_content['parentid']); + nv_fix_cat($data_content['parentid_old']); + } + + $nv_Cache->delMod($module_name); + nv_insert_logs(NV_LANG_DATA, $module_name, $lang_module['edit_cat'], $data_content['title'], $admin_info['userid']); + + Header('Location: ' . NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=' . $op . '&pid=' . $data_content['parentid']); + die(); + } else { + $error = $lang_module['errorsave']; + } + } + } + } } -if( $data_content['catid'] > 0 ) -{ - $data_content = $array_cat[$data_content['catid']]; - $caption = $lang_module['edit_cat']; -} -else -{ - $data_content['catimage'] = ''; - $caption = $lang_module['add_cat']; +if ($data_content['catid'] > 0) { + $data_content = $array_cat[$data_content['catid']]; + $caption = $lang_module['edit_cat']; +} else { + $data_content['catimage'] = ''; + $caption = $lang_module['add_cat']; } $lang_module['edit'] = $lang_global['edit']; $lang_module['delete'] = $lang_global['delete']; -$xtpl = new XTemplate( 'cat.tpl', NV_ROOTDIR . '/themes/' . $global_config['module_theme'] . '/modules/' . $module_file ); -$xtpl->assign( 'LANG', $lang_module ); -$xtpl->assign( 'DATA', $data_content ); -$xtpl->assign( 'NV_BASE_ADMINURL', NV_BASE_ADMINURL ); -$xtpl->assign( 'NV_NAME_VARIABLE', NV_NAME_VARIABLE ); -$xtpl->assign( 'MODULE_NAME', $module_name ); -$xtpl->assign( 'NV_OP_VARIABLE', NV_OP_VARIABLE ); -$xtpl->assign( 'OP', $op ); -$xtpl->assign( 'PATH', NV_UPLOADS_DIR . '/' . $module_upload ); -$xtpl->assign( 'catid', $data_content['catid'] ); +$xtpl = new XTemplate('cat.tpl', NV_ROOTDIR . '/themes/' . $global_config['module_theme'] . '/modules/' . $module_file); +$xtpl->assign('LANG', $lang_module); +$xtpl->assign('DATA', $data_content); +$xtpl->assign('NV_BASE_ADMINURL', NV_BASE_ADMINURL); +$xtpl->assign('NV_NAME_VARIABLE', NV_NAME_VARIABLE); +$xtpl->assign('MODULE_NAME', $module_name); +$xtpl->assign('NV_OP_VARIABLE', NV_OP_VARIABLE); +$xtpl->assign('OP', $op); +$xtpl->assign('PATH', NV_UPLOADS_DIR . '/' . $module_upload); +$xtpl->assign('catid', $data_content['catid']); // get catid -if( ! empty( $array_cat ) ) -{ - foreach( $array_cat as $cat ) - { - $xtitle = ''; - - if( $cat['catid'] != $data_content['catid'] ) - { - if( $cat['parentid'] != 0 ) $xtitle = getlevel( $cat['parentid'], $array_cat ); - $cat['xtitle'] = $xtitle . $cat['title']; - $cat['sl'] = ( $cat['catid'] == $data_content['parentid'] ) ? ' selected="selected"' : ''; - $xtpl->assign( 'CAT', $cat ); - $xtpl->parse( 'main.loopcat' ); - } - - if( $cat['parentid'] == $data_content['parentid'] ) - { - $cat['link_add'] = NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=cat&pid=' . $cat['catid'] . ''; - $cat['link_edit'] = NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=cat&catid=' . $cat['catid'] . ''; - $cat['weight_select'] = drawselect_number( 'change', 1, $numcat, $cat['weight'], 'nv_chang_cat(this,' . $cat['catid'] . ',\'weight\');' ); - $cat['inhome_select'] = drawselect_yesno( $select_name = 'slinhome', $cat['inhome'], $lang_module['weblink_no'], $lang_module['weblink_yes'], 'nv_chang_cat(this,' . $cat['catid'] . ',\'inhome\');' ); - $xtpl->assign( 'ROW', $cat ); - $xtpl->parse( 'main.data.loop' ); - } - } - - $xtpl->assign( 'url_back', NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=cat&pid=' . $data_content['parentid'] . '' ); - if( $numcat > 0 ) $xtpl->parse( 'main.data' ); +if (! empty($array_cat)) { + foreach ($array_cat as $cat) { + $xtitle = ''; + + if ($cat['catid'] != $data_content['catid']) { + if ($cat['parentid'] != 0) { + $xtitle = getlevel($cat['parentid'], $array_cat); + } + $cat['xtitle'] = $xtitle . $cat['title']; + $cat['sl'] = ($cat['catid'] == $data_content['parentid']) ? ' selected="selected"' : ''; + $xtpl->assign('CAT', $cat); + $xtpl->parse('main.loopcat'); + } + + if ($cat['parentid'] == $data_content['parentid']) { + $cat['link_add'] = NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=cat&pid=' . $cat['catid'] . ''; + $cat['link_edit'] = NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=cat&catid=' . $cat['catid'] . ''; + $cat['weight_select'] = drawselect_number('change', 1, $numcat, $cat['weight'], 'nv_chang_cat(this,' . $cat['catid'] . ',\'weight\');'); + $cat['inhome_select'] = drawselect_yesno($select_name = 'slinhome', $cat['inhome'], $lang_module['weblink_no'], $lang_module['weblink_yes'], 'nv_chang_cat(this,' . $cat['catid'] . ',\'inhome\');'); + $xtpl->assign('ROW', $cat); + $xtpl->parse('main.data.loop'); + } + } + + $xtpl->assign('url_back', NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=cat&pid=' . $data_content['parentid'] . ''); + if ($numcat > 0) { + $xtpl->parse('main.data'); + } } -$xtpl->assign( 'DATA', $data_content ); -$xtpl->assign( 'CAPTION', $caption ); -$xtpl->assign( 'PATH', NV_UPLOADS_DIR . '/' . $module_upload ); -$xtpl->assign( 'UPLOAD_CURRENT', NV_UPLOADS_DIR . '/' . $module_upload . '/cat' ); +$xtpl->assign('DATA', $data_content); +$xtpl->assign('CAPTION', $caption); +$xtpl->assign('PATH', NV_UPLOADS_DIR . '/' . $module_upload); +$xtpl->assign('UPLOAD_CURRENT', NV_UPLOADS_DIR . '/' . $module_upload . '/cat'); -if( empty( $data_content['alias'] ) ) -{ - $xtpl->parse( 'main.getalias' ); +if (empty($data_content['alias'])) { + $xtpl->parse('main.getalias'); } -if( ! empty( $error ) ) -{ - $xtpl->assign( 'error', $error ); - $xtpl->parse( 'main.error' ); +if (! empty($error)) { + $xtpl->assign('error', $error); + $xtpl->parse('main.error'); } -$xtpl->parse( 'main' ); -$contents .= $xtpl->text( 'main' ); +$xtpl->parse('main'); +$contents .= $xtpl->text('main'); include NV_ROOTDIR . '/includes/header.php'; -echo nv_admin_theme( $contents ); -include NV_ROOTDIR . '/includes/footer.php'; \ No newline at end of file +echo nv_admin_theme($contents); +include NV_ROOTDIR . '/includes/footer.php'; diff --git a/modules/weblinks/admin/change_cat.php b/modules/weblinks/admin/change_cat.php index 68a031653..64ea67d97 100644 --- a/modules/weblinks/admin/change_cat.php +++ b/modules/weblinks/admin/change_cat.php @@ -8,50 +8,47 @@ * @Createdate 2-10-2010 18:49 */ -if( ! defined( 'NV_IS_FILE_ADMIN' ) ) die( 'Stop!!!' ); +if (! defined('NV_IS_FILE_ADMIN')) { + die('Stop!!!'); +} -$catid = $nv_Request->get_int( 'catid', 'post', 0 ); -$mod = $nv_Request->get_string( 'mod', 'post', '' ); -$new_vid = $nv_Request->get_int( 'new_vid', 'post', 0 ); +$catid = $nv_Request->get_int('catid', 'post', 0); +$mod = $nv_Request->get_string('mod', 'post', ''); +$new_vid = $nv_Request->get_int('new_vid', 'post', 0); $content = 'NO_' . $catid; -list( $catid, $parentid ) = $db->query( 'SELECT catid, parentid FROM ' . NV_PREFIXLANG . '_' . $module_data . '_cat WHERE catid=' . intval( $catid ) . '' )->fetch( 3 ); -if( $catid > 0 ) -{ - if( $mod == 'weight' and $new_vid > 0 ) - { - $sql = 'SELECT catid FROM ' . NV_PREFIXLANG . '_' . $module_data . '_cat WHERE catid!=' . $catid . ' AND parentid=' . $parentid . ' ORDER BY weight ASC'; - $result = $db->query( $sql ); - - $weight = 0; - while( $row = $result->fetch() ) - { - ++$weight; - if( $weight == $new_vid ) ++$weight; - $sql = 'UPDATE ' . NV_PREFIXLANG . '_' . $module_data . '_cat SET weight=' . $weight . ' WHERE catid=' . intval( $row['catid'] ); - $db->query( $sql ); - } - - $sql = 'UPDATE ' . NV_PREFIXLANG . '_' . $module_data . '_cat SET weight=' . $new_vid . ' WHERE catid=' . intval( $catid ); - $db->query( $sql ); - - $content = 'OK_' . $catid; - } - elseif( $mod == 'inhome' and ( $new_vid == 0 or $new_vid == 1 ) ) - { - $sql = 'UPDATE ' . NV_PREFIXLANG . '_' . $module_data . '_cat SET inhome=' . $new_vid . ' WHERE catid=' . intval( $catid ); - $db->query( $sql ); - $content = 'OK_' . $catid; - } - elseif( $mod == 'numlinks' and $new_vid >= 0 and $new_vid <= 10 ) - { - $sql = 'UPDATE ' . NV_PREFIXLANG . '_' . $module_data . '_cat SET numlinks=' . $new_vid . ' WHERE catid=' . intval( $catid ); - $db->query( $sql ); - $content = 'OK_' . $catid; - } - $nv_Cache->delMod( $module_name ); +list($catid, $parentid) = $db->query('SELECT catid, parentid FROM ' . NV_PREFIXLANG . '_' . $module_data . '_cat WHERE catid=' . intval($catid) . '')->fetch(3); +if ($catid > 0) { + if ($mod == 'weight' and $new_vid > 0) { + $sql = 'SELECT catid FROM ' . NV_PREFIXLANG . '_' . $module_data . '_cat WHERE catid!=' . $catid . ' AND parentid=' . $parentid . ' ORDER BY weight ASC'; + $result = $db->query($sql); + + $weight = 0; + while ($row = $result->fetch()) { + ++$weight; + if ($weight == $new_vid) { + ++$weight; + } + $sql = 'UPDATE ' . NV_PREFIXLANG . '_' . $module_data . '_cat SET weight=' . $weight . ' WHERE catid=' . intval($row['catid']); + $db->query($sql); + } + + $sql = 'UPDATE ' . NV_PREFIXLANG . '_' . $module_data . '_cat SET weight=' . $new_vid . ' WHERE catid=' . intval($catid); + $db->query($sql); + + $content = 'OK_' . $catid; + } elseif ($mod == 'inhome' and ($new_vid == 0 or $new_vid == 1)) { + $sql = 'UPDATE ' . NV_PREFIXLANG . '_' . $module_data . '_cat SET inhome=' . $new_vid . ' WHERE catid=' . intval($catid); + $db->query($sql); + $content = 'OK_' . $catid; + } elseif ($mod == 'numlinks' and $new_vid >= 0 and $new_vid <= 10) { + $sql = 'UPDATE ' . NV_PREFIXLANG . '_' . $module_data . '_cat SET numlinks=' . $new_vid . ' WHERE catid=' . intval($catid); + $db->query($sql); + $content = 'OK_' . $catid; + } + $nv_Cache->delMod($module_name); } include NV_ROOTDIR . '/includes/header.php'; echo $content; -include NV_ROOTDIR . '/includes/footer.php'; \ No newline at end of file +include NV_ROOTDIR . '/includes/footer.php'; diff --git a/modules/weblinks/admin/checklink.php b/modules/weblinks/admin/checklink.php index 6b2f5af4e..d14a9c09f 100644 --- a/modules/weblinks/admin/checklink.php +++ b/modules/weblinks/admin/checklink.php @@ -8,70 +8,63 @@ * @Createdate 2-9-2010 14:43 */ -if( ! defined( 'NV_IS_FILE_ADMIN' ) ) die( 'Stop!!!' ); +if (! defined('NV_IS_FILE_ADMIN')) { + die('Stop!!!'); +} $page_title = $lang_module['weblink_checkalivelink']; -$submit = $nv_Request->get_string( 'submit', 'post' ); +$submit = $nv_Request->get_string('submit', 'post'); -if( $submit ) -{ - $nv_Request->set_Cookie( 'ok', 1 ); +if ($submit) { + $nv_Request->set_Cookie('ok', 1); } -$xtpl = new XTemplate( 'checklink.tpl', NV_ROOTDIR . '/themes/' . $global_config['module_theme'] . '/modules/' . $module_file ); -$xtpl->assign( 'LANG', $lang_module ); - -if( $nv_Request->isset_request( 'ok', 'cookie' ) ) -{ - include NV_ROOTDIR . '/modules/' . $module_file . '/checkurl.class.php'; - $check = new CheckUrl(); - - $page_title = $lang_module['weblink_checkalivelink']; - - $numcat = $db->query( 'SELECT id FROM ' . NV_PREFIXLANG . '_' . $module_data . '_rows ' )->rowCount(); - $base_url = NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=checklink'; - $all_page = ( $numcat > 1 ) ? $numcat : 1; - $per_page = 5; - $page = $nv_Request->get_int( 'page', 'get', 0 ); - - $sql = 'SELECT url FROM ' . NV_PREFIXLANG . '_' . $module_data . '_rows LIMIT ' . $page . ', ' . $per_page; - $result = $db->query( $sql ); - - while( $row = $result->fetch() ) - { - $xtpl->assign( 'URL', $row['url'] ); - - if( $check->check_curl( $row['url'] ) ) - { - $xtpl->parse( 'main.check.loop.ok' ); - } - else - { - $xtpl->parse( 'main.check.loop.error' ); - } - - $xtpl->parse( 'main.check.loop' ); - } - - $generate_page = nv_generate_page( $base_url, $all_page, $per_page, $page ); - if( ! empty( $generate_page ) ) - { - $xtpl->assign( 'GENERATE_PAGE', $generate_page ); - $xtpl->parse( 'main.check.generate_page' ); - } - - $xtpl->parse( 'main.check' ); -} -else -{ - $xtpl->assign( 'FORM_ACTION', NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=checklink' ); - $xtpl->parse( 'main.form' ); +$xtpl = new XTemplate('checklink.tpl', NV_ROOTDIR . '/themes/' . $global_config['module_theme'] . '/modules/' . $module_file); +$xtpl->assign('LANG', $lang_module); + +if ($nv_Request->isset_request('ok', 'cookie')) { + include NV_ROOTDIR . '/modules/' . $module_file . '/checkurl.class.php'; + $check = new CheckUrl(); + + $page_title = $lang_module['weblink_checkalivelink']; + + $numcat = $db->query('SELECT id FROM ' . NV_PREFIXLANG . '_' . $module_data . '_rows ')->rowCount(); + $base_url = NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=checklink'; + $all_page = ($numcat > 1) ? $numcat : 1; + $per_page = 5; + $page = $nv_Request->get_int('page', 'get', 0); + + $sql = 'SELECT url FROM ' . NV_PREFIXLANG . '_' . $module_data . '_rows LIMIT ' . $page . ', ' . $per_page; + $result = $db->query($sql); + + while ($row = $result->fetch()) { + $xtpl->assign('URL', $row['url']); + + if ($check->check_curl($row['url'])) { + $xtpl->parse('main.check.loop.ok'); + } else { + $xtpl->parse('main.check.loop.error'); + } + + $xtpl->parse('main.check.loop'); + } + + $generate_page = nv_generate_page($base_url, $all_page, $per_page, $page); + if (! empty($generate_page)) { + $xtpl->assign('GENERATE_PAGE', $generate_page); + $xtpl->parse('main.check.generate_page'); + } + + $xtpl->parse('main.check'); +} else { + $xtpl->assign('FORM_ACTION', NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=checklink'); + $xtpl->parse('main.form'); } -$xtpl->parse( 'main' ); -$contents = $xtpl->text( 'main' ); +$xtpl->parse('main'); +$contents = $xtpl->text('main'); include NV_ROOTDIR . '/includes/header.php'; -echo nv_admin_theme( $contents ); -include NV_ROOTDIR . '/includes/footer.php'; \ No newline at end of file +echo nv_admin_theme($contents); +include NV_ROOTDIR . '/includes/footer.php'; diff --git a/modules/weblinks/admin/config.php b/modules/weblinks/admin/config.php index 22852f11b..2cf461743 100644 --- a/modules/weblinks/admin/config.php +++ b/modules/weblinks/admin/config.php @@ -8,55 +8,55 @@ * @Createdate 2-9-2010 14:43 */ -if( ! defined( 'NV_IS_FILE_ADMIN' ) ) die( 'Stop!!!' ); +if (! defined('NV_IS_FILE_ADMIN')) { + die('Stop!!!'); +} $page_title = $lang_module['weblink_config']; -$submit = $nv_Request->get_string( 'submit', 'post' ); +$submit = $nv_Request->get_string('submit', 'post'); $error = 0; -if( ! empty( $submit ) ) -{ - $weblinks_config['sort'] = ( $nv_Request->get_string( 'sort', 'post' ) == 'asc' ) ? 'asc' : 'des'; - $weblinks_config['sortoption'] = nv_htmlspecialchars ( $nv_Request->get_string( 'sortoption', 'post', 'byid' ) ); - $weblinks_config['showlinkimage'] = $nv_Request->get_int( 'showlinkimage', 'post', 0 ); - $weblinks_config['imgwidth'] = ( $nv_Request->get_int( 'imgwidth', 'post' ) >= 0 ) ? $nv_Request->get_int( 'imgwidth', 'post' ) : 100; - $weblinks_config['imgheight'] = ( $nv_Request->get_int( 'imgheight', 'post' ) >= 0 ) ? $nv_Request->get_int( 'imgheight', 'post' ) : 75; - $weblinks_config['per_page'] = ( $nv_Request->get_int( 'per_page', 'post' ) >= 0 ) ? $nv_Request->get_int( 'per_page', 'post' ) : 10; - - $sth = $db->prepare( 'UPDATE ' . NV_PREFIXLANG . '_' . $module_data . '_config SET name = :name WHERE name = :value'); - foreach( $weblinks_config as $name => $value ) - { - $sth->bindParam( ':name', $name, PDO::PARAM_STR ); - $sth->bindParam( ':value', $value, PDO::PARAM_STR ); - $sth->execute(); - } - - $sth->closeCursor(); +if (! empty($submit)) { + $weblinks_config['sort'] = ($nv_Request->get_string('sort', 'post') == 'asc') ? 'asc' : 'des'; + $weblinks_config['sortoption'] = nv_htmlspecialchars($nv_Request->get_string('sortoption', 'post', 'byid')); + $weblinks_config['showlinkimage'] = $nv_Request->get_int('showlinkimage', 'post', 0); + $weblinks_config['imgwidth'] = ($nv_Request->get_int('imgwidth', 'post') >= 0) ? $nv_Request->get_int('imgwidth', 'post') : 100; + $weblinks_config['imgheight'] = ($nv_Request->get_int('imgheight', 'post') >= 0) ? $nv_Request->get_int('imgheight', 'post') : 75; + $weblinks_config['per_page'] = ($nv_Request->get_int('per_page', 'post') >= 0) ? $nv_Request->get_int('per_page', 'post') : 10; + + $sth = $db->prepare('UPDATE ' . NV_PREFIXLANG . '_' . $module_data . '_config SET name = :name WHERE name = :value'); + foreach ($weblinks_config as $name => $value) { + $sth->bindParam(':name', $name, PDO::PARAM_STR); + $sth->bindParam(':value', $value, PDO::PARAM_STR); + $sth->execute(); + } + + $sth->closeCursor(); } // Set data adv $weblinks_config['asc'] = $weblinks_config['des'] = ''; -$weblinks_config['sort'] = ( $weblinks_config['sort'] == 'asc' ) ? $weblinks_config['asc'] = 'checked' : $weblinks_config['des'] = 'checked'; -$weblinks_config['byid'] = ( $weblinks_config['sortoption'] == 'byid' ) ? ' checked' : ''; -$weblinks_config['byrand'] = ( $weblinks_config['sortoption'] == 'byrand' ) ? ' checked' : ''; -$weblinks_config['bytime'] = ( $weblinks_config['sortoption'] == 'bytime' ) ? ' checked' : ''; -$weblinks_config['byhit'] = ( $weblinks_config['sortoption'] == 'byhit' ) ? ' checked' : ''; -$weblinks_config['ck_showlinkimage'] = ( $weblinks_config['showlinkimage'] == 1 ) ? ' checked' : ''; - -$xtpl = new XTemplate( 'config.tpl', NV_ROOTDIR . '/themes/' . $global_config['module_theme'] . '/modules/' . $module_file ); -$xtpl->assign( 'NV_BASE_ADMINURL', NV_BASE_ADMINURL ); -$xtpl->assign( 'NV_NAME_VARIABLE', NV_NAME_VARIABLE ); -$xtpl->assign( 'MODULE_NAME', $module_name ); -$xtpl->assign( 'NV_OP_VARIABLE', NV_OP_VARIABLE ); -$xtpl->assign( 'OP', $op ); -$xtpl->assign( 'LANG', $lang_module ); -$xtpl->assign( 'DATA', $weblinks_config ); - -$xtpl->parse( 'main' ); -$contents .= $xtpl->text( 'main' ); +$weblinks_config['sort'] = ($weblinks_config['sort'] == 'asc') ? $weblinks_config['asc'] = 'checked' : $weblinks_config['des'] = 'checked'; +$weblinks_config['byid'] = ($weblinks_config['sortoption'] == 'byid') ? ' checked' : ''; +$weblinks_config['byrand'] = ($weblinks_config['sortoption'] == 'byrand') ? ' checked' : ''; +$weblinks_config['bytime'] = ($weblinks_config['sortoption'] == 'bytime') ? ' checked' : ''; +$weblinks_config['byhit'] = ($weblinks_config['sortoption'] == 'byhit') ? ' checked' : ''; +$weblinks_config['ck_showlinkimage'] = ($weblinks_config['showlinkimage'] == 1) ? ' checked' : ''; + +$xtpl = new XTemplate('config.tpl', NV_ROOTDIR . '/themes/' . $global_config['module_theme'] . '/modules/' . $module_file); +$xtpl->assign('NV_BASE_ADMINURL', NV_BASE_ADMINURL); +$xtpl->assign('NV_NAME_VARIABLE', NV_NAME_VARIABLE); +$xtpl->assign('MODULE_NAME', $module_name); +$xtpl->assign('NV_OP_VARIABLE', NV_OP_VARIABLE); +$xtpl->assign('OP', $op); +$xtpl->assign('LANG', $lang_module); +$xtpl->assign('DATA', $weblinks_config); + +$xtpl->parse('main'); +$contents .= $xtpl->text('main'); include NV_ROOTDIR . '/includes/header.php'; -echo nv_admin_theme( $contents ); -include NV_ROOTDIR . '/includes/footer.php'; \ No newline at end of file +echo nv_admin_theme($contents); +include NV_ROOTDIR . '/includes/footer.php'; diff --git a/modules/weblinks/admin/content.php b/modules/weblinks/admin/content.php index 33ce80773..4754fd59c 100644 --- a/modules/weblinks/admin/content.php +++ b/modules/weblinks/admin/content.php @@ -8,7 +8,9 @@ * @Createdate 2-9-2010 14:43 */ -if( ! defined( 'NV_IS_FILE_ADMIN' ) ) die( 'Stop!!!' ); +if (! defined('NV_IS_FILE_ADMIN')) { + die('Stop!!!'); +} /** * check_url() @@ -17,234 +19,205 @@ * @param mixed $url * @return */ -function check_url( $id, $url ) +function check_url($id, $url) { - global $db, $module_data; - $sql = 'SELECT COUNT(*) FROM ' . NV_PREFIXLANG . '_' . $module_data . '_rows WHERE id != ' . intval( $id ) . ' AND url = ' . $db->quote( $url ); - $numurl = $db->query( $sql )->fetchColumn(); - $msg = ( $numurl > 0 ) ? false : true; - return $msg; + global $db, $module_data; + $sql = 'SELECT COUNT(*) FROM ' . NV_PREFIXLANG . '_' . $module_data . '_rows WHERE id != ' . intval($id) . ' AND url = ' . $db->quote($url); + $numurl = $db->query($sql)->fetchColumn(); + $msg = ($numurl > 0) ? false : true; + return $msg; } -if( defined( 'NV_EDITOR' ) ) -{ - require_once NV_ROOTDIR . '/' . NV_EDITORSDIR . '/' . NV_EDITOR . '/nv.php'; +if (defined('NV_EDITOR')) { + require_once NV_ROOTDIR . '/' . NV_EDITORSDIR . '/' . NV_EDITOR . '/nv.php'; } $page_title = $lang_module['weblink_add_link']; $data = array( - 'id' => '', - 'catid' => '', - 'title' => '', - 'alias' => '', - 'url' => '', - 'urlimg' => '', - 'description' => '', - 'add_time' => '', - 'edit_time' => '', - 'hits_total' => '', - 'admin_phone' => '', - 'admin_email' => '', - 'note' => '', - 'status' => 1 + 'id' => '', + 'catid' => '', + 'title' => '', + 'alias' => '', + 'url' => '', + 'urlimg' => '', + 'description' => '', + 'add_time' => '', + 'edit_time' => '', + 'hits_total' => '', + 'admin_phone' => '', + 'admin_email' => '', + 'note' => '', + 'status' => 1 ); $error = array(); -$data['id'] = $nv_Request->get_int( 'id', 'get', 0 ); -if( $data['id'] > 0 ) -{ - $sql = $db->query( 'SELECT * FROM ' . NV_PREFIXLANG . '_' . $module_data . '_rows WHERE id=' . $data['id'] ); +$data['id'] = $nv_Request->get_int('id', 'get', 0); +if ($data['id'] > 0) { + $sql = $db->query('SELECT * FROM ' . NV_PREFIXLANG . '_' . $module_data . '_rows WHERE id=' . $data['id']); - $data = $sql->fetch(); + $data = $sql->fetch(); - $page_title = $lang_module['weblink_edit_link']; + $page_title = $lang_module['weblink_edit_link']; } -if( $nv_Request->get_int( 'save', 'post,get', 0 ) ) -{ - $data['id'] = $nv_Request->get_int( 'id', 'post', 0 ); - $data['catid'] = $nv_Request->get_int( 'catid', 'post', 0 ); - $data['title'] = $nv_Request->get_title( 'title', 'post', '', 1 ); - $data['alias'] = $nv_Request->get_title( 'alias', 'post', '', 1 ); - $data['alias'] = ( $data['alias'] == '' ) ? change_alias( $data['title'] ) : change_alias( $data['alias'] ); - $data['url'] = $nv_Request->get_title( 'url', 'post', '' ); - $data['urlimg'] = $nv_Request->get_title( 'urlimg', 'post', '' ); - - if( ! nv_is_url( $data['urlimg'] ) and file_exists( NV_DOCUMENT_ROOT . $data['urlimg'] ) ) - { - $lu = strlen( NV_BASE_SITEURL . NV_UPLOADS_DIR . '/' ); - if( substr( $data['urlimg'], 0, $lu ) == NV_BASE_SITEURL . NV_UPLOADS_DIR . '/' ) - { - $data['urlimg'] = substr( $data['urlimg'], $lu ); - } - } - - if( ! empty( $data['url'] ) ) - { - if( ! preg_match( '#^(http|https|ftp|gopher)\:\/\/#', $data['url'] ) ) - { - $data['url'] = 'http://' . $data['url']; - } - } - - $data['description'] = $nv_Request->get_editor( 'description', '', NV_ALLOWED_HTML_TAGS ); - - $data['status'] = ( $nv_Request->get_int( 'status', 'post' ) == 1 ) ? 1 : 0; - // check url - if( empty( $data['url'] ) || ! nv_is_url( $data['url'] ) || ! check_url( $data['id'], $data['url'] ) || ! nv_check_url( $data['url'] ) ) - { - $error[] = $lang_module['error_url']; - } - if( empty( $data['title'] ) ) - { - $error[] = $lang_module['error_title']; - } - if( strip_tags( $data['description'] ) == '' ) - { - $error[] = $lang_module['error_description']; - } - - if( empty( $error ) ) - { - if( $data['id'] > 0 ) - { - $stmt = $db->prepare( 'UPDATE ' . NV_PREFIXLANG . '_' . $module_data . '_rows SET - catid=' . intval( $data['catid'] ) . ', +if ($nv_Request->get_int('save', 'post,get', 0)) { + $data['id'] = $nv_Request->get_int('id', 'post', 0); + $data['catid'] = $nv_Request->get_int('catid', 'post', 0); + $data['title'] = $nv_Request->get_title('title', 'post', '', 1); + $data['alias'] = $nv_Request->get_title('alias', 'post', '', 1); + $data['alias'] = ($data['alias'] == '') ? change_alias($data['title']) : change_alias($data['alias']); + $data['url'] = $nv_Request->get_title('url', 'post', ''); + $data['urlimg'] = $nv_Request->get_title('urlimg', 'post', ''); + + if (! nv_is_url($data['urlimg']) and file_exists(NV_DOCUMENT_ROOT . $data['urlimg'])) { + $lu = strlen(NV_BASE_SITEURL . NV_UPLOADS_DIR . '/'); + if (substr($data['urlimg'], 0, $lu) == NV_BASE_SITEURL . NV_UPLOADS_DIR . '/') { + $data['urlimg'] = substr($data['urlimg'], $lu); + } + } + + if (! empty($data['url'])) { + if (! preg_match('#^(http|https|ftp|gopher)\:\/\/#', $data['url'])) { + $data['url'] = 'http://' . $data['url']; + } + } + + $data['description'] = $nv_Request->get_editor('description', '', NV_ALLOWED_HTML_TAGS); + + $data['status'] = ($nv_Request->get_int('status', 'post') == 1) ? 1 : 0; + // check url + if (empty($data['url']) || ! nv_is_url($data['url']) || ! check_url($data['id'], $data['url']) || ! nv_check_url($data['url'])) { + $error[] = $lang_module['error_url']; + } + if (empty($data['title'])) { + $error[] = $lang_module['error_title']; + } + if (strip_tags($data['description']) == '') { + $error[] = $lang_module['error_description']; + } + + if (empty($error)) { + if ($data['id'] > 0) { + $stmt = $db->prepare('UPDATE ' . NV_PREFIXLANG . '_' . $module_data . '_rows SET + catid=' . intval($data['catid']) . ', title=:title, alias =:alias, url =:url, urlimg =:urlimg, description=:description, edit_time = ' . NV_CURRENTTIME . ', - status=' . intval( $data['status'] ) . ' - WHERE id =' . intval( $data['id'] ) ); - $stmt->bindParam( ':title', $data['title'], PDO::PARAM_STR ); - $stmt->bindParam( ':alias', $data['alias'], PDO::PARAM_STR ); - $stmt->bindParam( ':url', $data['url'], PDO::PARAM_STR ); - $stmt->bindParam( ':urlimg', $data['urlimg'], PDO::PARAM_STR ); - $stmt->bindParam( ':description', $data['description'], PDO::PARAM_STR, strlen( $data['description'] ) ); - - if( $stmt->execute() ) - { - nv_insert_logs( NV_LANG_DATA, $module_name, $lang_module['weblink_edit_link'], $data['title'], $admin_info['userid'] ); - Header( 'Location: ' . NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name ); - die(); - } - else - { - $error[] = $lang_module['errorsave']; - } - - } - else - { - $stmt = $db->prepare( 'INSERT INTO ' . NV_PREFIXLANG . '_' . $module_data . '_rows SET - catid =' . intval( $data['catid'] ) . ', + status=' . intval($data['status']) . ' + WHERE id =' . intval($data['id'])); + $stmt->bindParam(':title', $data['title'], PDO::PARAM_STR); + $stmt->bindParam(':alias', $data['alias'], PDO::PARAM_STR); + $stmt->bindParam(':url', $data['url'], PDO::PARAM_STR); + $stmt->bindParam(':urlimg', $data['urlimg'], PDO::PARAM_STR); + $stmt->bindParam(':description', $data['description'], PDO::PARAM_STR, strlen($data['description'])); + + if ($stmt->execute()) { + nv_insert_logs(NV_LANG_DATA, $module_name, $lang_module['weblink_edit_link'], $data['title'], $admin_info['userid']); + Header('Location: ' . NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name); + die(); + } else { + $error[] = $lang_module['errorsave']; + } + } else { + $stmt = $db->prepare('INSERT INTO ' . NV_PREFIXLANG . '_' . $module_data . '_rows SET + catid =' . intval($data['catid']) . ', title =:title, alias =:alias, url =:url, urlimg =:urlimg, note =:note, description =:description, - admin_phone =' . intval( $data['admin_phone'] ) . ', - admin_email =' . intval( $data['admin_email'] ) . ', + admin_phone =' . intval($data['admin_phone']) . ', + admin_email =' . intval($data['admin_email']) . ', add_time = ' . NV_CURRENTTIME . ', edit_time =' . NV_CURRENTTIME . ', hits_total = 0, - status = ' . intval( $data['status'] ) ); - $stmt->bindParam( ':title', $data['title'], PDO::PARAM_STR ); - $stmt->bindParam( ':alias', $data['alias'], PDO::PARAM_STR ); - $stmt->bindParam( ':url', $data['url'], PDO::PARAM_STR ); - $stmt->bindParam( ':urlimg', $data['urlimg'], PDO::PARAM_STR ); - $stmt->bindParam( ':note', $data['note'], PDO::PARAM_STR ); - $stmt->bindParam( ':description', $data['description'], PDO::PARAM_STR, strlen( $data['description'] ) ); - if( $stmt->execute() ) - { - nv_insert_logs( NV_LANG_DATA, $module_name, $lang_module['weblink_add_link'], $data['title'], $admin_info['userid'] ); - - Header( 'Location: ' . NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name ); - die(); - } - else - { - $error[] = $lang_module['errorsave']; - } - } - } - + status = ' . intval($data['status'])); + $stmt->bindParam(':title', $data['title'], PDO::PARAM_STR); + $stmt->bindParam(':alias', $data['alias'], PDO::PARAM_STR); + $stmt->bindParam(':url', $data['url'], PDO::PARAM_STR); + $stmt->bindParam(':urlimg', $data['urlimg'], PDO::PARAM_STR); + $stmt->bindParam(':note', $data['note'], PDO::PARAM_STR); + $stmt->bindParam(':description', $data['description'], PDO::PARAM_STR, strlen($data['description'])); + if ($stmt->execute()) { + nv_insert_logs(NV_LANG_DATA, $module_name, $lang_module['weblink_add_link'], $data['title'], $admin_info['userid']); + + Header('Location: ' . NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name); + die(); + } else { + $error[] = $lang_module['errorsave']; + } + } + } } // dung de lay data tu CSDL -$data['description'] = ( defined( 'NV_EDITOR' ) ) ? nv_editor_br2nl( $data['description'] ) : nv_br2nl( $data['description'] ); -$data['description'] = nv_htmlspecialchars( $data['description'] ); +$data['description'] = (defined('NV_EDITOR')) ? nv_editor_br2nl($data['description']) : nv_br2nl($data['description']); +$data['description'] = nv_htmlspecialchars($data['description']); -if( ! empty( $data['urlimg'] ) and ! nv_is_url( $data['urlimg'] ) ) -{ - $data['urlimg'] = NV_BASE_SITEURL . NV_UPLOADS_DIR . '/' . $data['urlimg']; +if (! empty($data['urlimg']) and ! nv_is_url($data['urlimg'])) { + $data['urlimg'] = NV_BASE_SITEURL . NV_UPLOADS_DIR . '/' . $data['urlimg']; } -if( defined( 'NV_EDITOR' ) and nv_function_exists( 'nv_aleditor' ) ) -{ - $edits = nv_aleditor( 'description', '100%', '300px', $data['description'] ); -} -else -{ - $edits = ''; +if (defined('NV_EDITOR') and nv_function_exists('nv_aleditor')) { + $edits = nv_aleditor('description', '100%', '300px', $data['description']); +} else { + $edits = ''; } -$querysubcat = $db->query( 'SELECT catid, parentid, title FROM ' . NV_PREFIXLANG . '_' . $module_data . '_cat ORDER BY parentid, weight ASC' ); +$querysubcat = $db->query('SELECT catid, parentid, title FROM ' . NV_PREFIXLANG . '_' . $module_data . '_cat ORDER BY parentid, weight ASC'); $array_cat = array(); -while( $row = $querysubcat->fetch() ) -{ - $array_cat[$row['catid']] = $row; +while ($row = $querysubcat->fetch()) { + $array_cat[$row['catid']] = $row; } -$data['description'] = htmlspecialchars( nv_editor_br2nl( $data['description'] ) ); - -$xtpl = new XTemplate( 'content.tpl', NV_ROOTDIR . '/themes/' . $global_config['module_theme'] . '/modules/' . $module_file ); -$xtpl->assign( 'LANG', $lang_module ); -$xtpl->assign( 'DATA', $data ); -$xtpl->assign( 'NV_BASE_ADMINURL', NV_BASE_ADMINURL ); -$xtpl->assign( 'NV_NAME_VARIABLE', NV_NAME_VARIABLE ); -$xtpl->assign( 'MODULE_NAME', $module_name ); -$xtpl->assign( 'NV_OP_VARIABLE', NV_OP_VARIABLE ); -$xtpl->assign( 'OP', $op ); -$xtpl->assign( 'DESCRIPTION', $edits ); - -if( ! empty( $array_cat ) ) -{ - foreach( $array_cat as $cat ) - { - $xtitle = ''; - if( $cat['parentid'] != 0 ) $xtitle = getlevel( $cat['parentid'], $array_cat ); - $cat['title'] = $xtitle . $cat['title']; - $cat['sl'] = ( $cat['catid'] == $data['catid'] ) ? 'selected="selected"' : ''; - $xtpl->assign( 'CAT', $cat ); - $xtpl->parse( 'main.loopcat' ); - } +$data['description'] = htmlspecialchars(nv_editor_br2nl($data['description'])); + +$xtpl = new XTemplate('content.tpl', NV_ROOTDIR . '/themes/' . $global_config['module_theme'] . '/modules/' . $module_file); +$xtpl->assign('LANG', $lang_module); +$xtpl->assign('DATA', $data); +$xtpl->assign('NV_BASE_ADMINURL', NV_BASE_ADMINURL); +$xtpl->assign('NV_NAME_VARIABLE', NV_NAME_VARIABLE); +$xtpl->assign('MODULE_NAME', $module_name); +$xtpl->assign('NV_OP_VARIABLE', NV_OP_VARIABLE); +$xtpl->assign('OP', $op); +$xtpl->assign('DESCRIPTION', $edits); + +if (! empty($array_cat)) { + foreach ($array_cat as $cat) { + $xtitle = ''; + if ($cat['parentid'] != 0) { + $xtitle = getlevel($cat['parentid'], $array_cat); + } + $cat['title'] = $xtitle . $cat['title']; + $cat['sl'] = ($cat['catid'] == $data['catid']) ? 'selected="selected"' : ''; + $xtpl->assign('CAT', $cat); + $xtpl->parse('main.loopcat'); + } } -$xtpl->assign( 'PATH', NV_UPLOADS_DIR . '/' . $module_upload ); -$xtpl->assign( 'DATA', $data ); +$xtpl->assign('PATH', NV_UPLOADS_DIR . '/' . $module_upload); +$xtpl->assign('DATA', $data); -if( empty( $data['alias'] ) ) -{ - $xtpl->parse( 'main.getalias' ); +if (empty($data['alias'])) { + $xtpl->parse('main.getalias'); } -if( ! empty( $error ) ) -{ - $xtpl->assign( 'error', implode( '
', $error ) ); - $xtpl->parse( 'main.error' ); +if (! empty($error)) { + $xtpl->assign('error', implode('
', $error)); + $xtpl->parse('main.error'); } -$xtpl->parse( 'main' ); -$contents .= $xtpl->text( 'main' ); +$xtpl->parse('main'); +$contents .= $xtpl->text('main'); include NV_ROOTDIR . '/includes/header.php'; -echo nv_admin_theme( $contents ); -include NV_ROOTDIR . '/includes/footer.php'; \ No newline at end of file +echo nv_admin_theme($contents); +include NV_ROOTDIR . '/includes/footer.php'; diff --git a/modules/weblinks/admin/del_cat.php b/modules/weblinks/admin/del_cat.php index b05c13581..f6c9aee40 100644 --- a/modules/weblinks/admin/del_cat.php +++ b/modules/weblinks/admin/del_cat.php @@ -8,40 +8,35 @@ * @Createdate 2-10-2010 18:49 */ -if( ! defined( 'NV_IS_FILE_ADMIN' ) ) die( 'Stop!!!' ); +if (! defined('NV_IS_FILE_ADMIN')) { + die('Stop!!!'); +} -$catid = $nv_Request->get_int( 'catid', 'post', 0 ); +$catid = $nv_Request->get_int('catid', 'post', 0); $contents = 'NO_' . $catid; -list( $catid, $parentid, $title ) = $db->query( 'SELECT catid, parentid,title FROM ' . NV_PREFIXLANG . '_' . $module_data . '_cat WHERE catid=' . intval( $catid ) )->fetch( 3 ); -if( $catid > 0 ) -{ - $check_parentid = $db->query( 'SELECT COUNT(*) FROM ' . NV_PREFIXLANG . '_' . $module_data . '_cat WHERE parentid = ' . ( int )$catid )->fetchColumn(); - if( intval( $check_parentid ) > 0 ) - { - $contents = 'ERR_' . sprintf( $lang_module['delcat_msg_cat'], $check_parentid ); - } - else - { - $check_rows = $db->query( 'SELECT COUNT(*) FROM ' . NV_PREFIXLANG . '_' . $module_data . '_rows WHERE catid = ' . ( int )$catid )->fetchColumn(); - if( intval( $check_rows ) > 0 ) - { - $contents = 'ERR_' . sprintf( $lang_module['delcat_msg_rows'], $check_rows ); - } - } - if( $contents == 'NO_' . $catid ) - { - $query = 'DELETE FROM ' . NV_PREFIXLANG . '_' . $module_data . '_cat WHERE catid=' . $catid; - if( $db->query( $query ) ) - { - nv_fix_cat( $parentid ); - $nv_Cache->delMod( $module_name ); - $contents = 'OK_' . $catid; - } - } - nv_insert_logs( NV_LANG_DATA, $module_name, $lang_module['weblink_del_title'], $title, $admin_info['userid'] ); +list($catid, $parentid, $title) = $db->query('SELECT catid, parentid,title FROM ' . NV_PREFIXLANG . '_' . $module_data . '_cat WHERE catid=' . intval($catid))->fetch(3); +if ($catid > 0) { + $check_parentid = $db->query('SELECT COUNT(*) FROM ' . NV_PREFIXLANG . '_' . $module_data . '_cat WHERE parentid = ' . ( int )$catid)->fetchColumn(); + if (intval($check_parentid) > 0) { + $contents = 'ERR_' . sprintf($lang_module['delcat_msg_cat'], $check_parentid); + } else { + $check_rows = $db->query('SELECT COUNT(*) FROM ' . NV_PREFIXLANG . '_' . $module_data . '_rows WHERE catid = ' . ( int )$catid)->fetchColumn(); + if (intval($check_rows) > 0) { + $contents = 'ERR_' . sprintf($lang_module['delcat_msg_rows'], $check_rows); + } + } + if ($contents == 'NO_' . $catid) { + $query = 'DELETE FROM ' . NV_PREFIXLANG . '_' . $module_data . '_cat WHERE catid=' . $catid; + if ($db->query($query)) { + nv_fix_cat($parentid); + $nv_Cache->delMod($module_name); + $contents = 'OK_' . $catid; + } + } + nv_insert_logs(NV_LANG_DATA, $module_name, $lang_module['weblink_del_title'], $title, $admin_info['userid']); } include NV_ROOTDIR . '/includes/header.php'; echo $contents; -include NV_ROOTDIR . '/includes/footer.php'; \ No newline at end of file +include NV_ROOTDIR . '/includes/footer.php'; diff --git a/modules/weblinks/admin/del_link.php b/modules/weblinks/admin/del_link.php index 79999e2af..403630169 100644 --- a/modules/weblinks/admin/del_link.php +++ b/modules/weblinks/admin/del_link.php @@ -8,62 +8,51 @@ * @Createdate 2-9-2010 14:43 */ -if( ! defined( 'NV_IS_FILE_ADMIN' ) ) die( 'Stop!!!' ); - -if( ! defined( 'NV_IS_AJAX' ) ) die( 'Wrong URL' ); - -$id = $nv_Request->get_int( 'id', 'post', 0 ); - -$listid = $nv_Request->get_string( 'listid', 'post', '' ); - -if( $listid != '' ) -{ - $del_array = array_map( 'intval', explode( ',', $listid ) ); -} -elseif( $id ) -{ - $del_array = array( $id ); +if (! defined('NV_IS_FILE_ADMIN')) { + die('Stop!!!'); } -if( ! empty( $del_array ) ) -{ - $a = 0; - foreach( $del_array as $id ) - { - list( $id, $title, $urlimg ) = $db->query( 'SELECT id, title, urlimg FROM ' . NV_PREFIXLANG . '_' . $module_data . '_rows WHERE id=' . $id )->fetch( 3 ); - if( $id > 0 ) - { - nv_insert_logs( NV_LANG_DATA, $module_name, 'log_del_rows', $title, $admin_info['userid'] ); +if (! defined('NV_IS_AJAX')) { + die('Wrong URL'); +} - $db->exec( 'DELETE FROM ' . NV_PREFIXLANG . '_' . $module_data . '_rows WHERE id=' . $id ); +$id = $nv_Request->get_int('id', 'post', 0); - if( ! empty( $urlimg ) ) - { - @unlink( NV_ROOTDIR . '/' . NV_UPLOADS_DIR . '/' . $urlimg ); - $_did = $db->query( 'SELECT did FROM ' . NV_UPLOAD_GLOBALTABLE . '_dir WHERE dirname=' . $db->quote( dirname( NV_UPLOADS_DIR . '/' . $urlimg ) ) )->fetchColumn(); - $db->query( 'DELETE FROM ' . NV_UPLOAD_GLOBALTABLE . '_file WHERE did = ' . $_did . ' AND title=' . $db->quote( basename( $urlimg ) ) ); - } - ++$a; - } - if( $a > 0 ) - { - $nv_Cache->delMod( $module_name ); - $contents = 'OK_' . $lang_module['weblink_del_success']; - } - else - { +$listid = $nv_Request->get_string('listid', 'post', ''); - $contents = 'NO_' . $lang_module['weblink_del_error']; - } - } +if ($listid != '') { + $del_array = array_map('intval', explode(',', $listid)); +} elseif ($id) { + $del_array = array( $id ); } -else -{ - - $contents = 'NO_' . $lang_module['weblink_del_err']; +if (! empty($del_array)) { + $a = 0; + foreach ($del_array as $id) { + list($id, $title, $urlimg) = $db->query('SELECT id, title, urlimg FROM ' . NV_PREFIXLANG . '_' . $module_data . '_rows WHERE id=' . $id)->fetch(3); + if ($id > 0) { + nv_insert_logs(NV_LANG_DATA, $module_name, 'log_del_rows', $title, $admin_info['userid']); + + $db->exec('DELETE FROM ' . NV_PREFIXLANG . '_' . $module_data . '_rows WHERE id=' . $id); + + if (! empty($urlimg)) { + @unlink(NV_ROOTDIR . '/' . NV_UPLOADS_DIR . '/' . $urlimg); + $_did = $db->query('SELECT did FROM ' . NV_UPLOAD_GLOBALTABLE . '_dir WHERE dirname=' . $db->quote(dirname(NV_UPLOADS_DIR . '/' . $urlimg)))->fetchColumn(); + $db->query('DELETE FROM ' . NV_UPLOAD_GLOBALTABLE . '_file WHERE did = ' . $_did . ' AND title=' . $db->quote(basename($urlimg))); + } + ++$a; + } + if ($a > 0) { + $nv_Cache->delMod($module_name); + $contents = 'OK_' . $lang_module['weblink_del_success']; + } else { + $contents = 'NO_' . $lang_module['weblink_del_error']; + } + } +} else { + $contents = 'NO_' . $lang_module['weblink_del_err']; } include NV_ROOTDIR . '/includes/header.php'; echo $contents; -include NV_ROOTDIR . '/includes/footer.php'; \ No newline at end of file +include NV_ROOTDIR . '/includes/footer.php'; diff --git a/modules/weblinks/admin/delbroken.php b/modules/weblinks/admin/delbroken.php index 2c45e4e9d..2d090d7f7 100644 --- a/modules/weblinks/admin/delbroken.php +++ b/modules/weblinks/admin/delbroken.php @@ -8,17 +8,18 @@ * @Createdate 2-9-2010 14:43 */ -if( ! defined( 'NV_IS_FILE_ADMIN' ) ) die( 'Stop!!!' ); +if (! defined('NV_IS_FILE_ADMIN')) { + die('Stop!!!'); +} -$id = $nv_Request->get_array( 'idcheck', 'post' ); +$id = $nv_Request->get_array('idcheck', 'post'); -nv_insert_logs( NV_LANG_DATA, $module_name, 'log_del_broken', 'id ' . $id, $admin_info['userid'] ); +nv_insert_logs(NV_LANG_DATA, $module_name, 'log_del_broken', 'id ' . $id, $admin_info['userid']); -foreach( $id as $value ) -{ - $sql = 'DELETE FROM ' . NV_PREFIXLANG . '_' . $module_data . '_report WHERE id=' . $value; - $db->query( $sql ); +foreach ($id as $value) { + $sql = 'DELETE FROM ' . NV_PREFIXLANG . '_' . $module_data . '_report WHERE id=' . $value; + $db->query($sql); } -Header( 'Location: ' . NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=brokenlink' ); -exit(); \ No newline at end of file +Header('Location: ' . NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=brokenlink'); +exit(); diff --git a/modules/weblinks/admin/main.php b/modules/weblinks/admin/main.php index 6f7f062fb..0d1e8c144 100644 --- a/modules/weblinks/admin/main.php +++ b/modules/weblinks/admin/main.php @@ -8,52 +8,51 @@ * @Createdate 2-9-2010 14:43 */ -if( ! defined( 'NV_IS_FILE_ADMIN' ) ) die( 'Stop!!!' ); +if (! defined('NV_IS_FILE_ADMIN')) { + die('Stop!!!'); +} $page_title = $lang_module['link_list']; -$xtpl = new XTemplate( 'main.tpl', NV_ROOTDIR . '/themes/' . $global_config['module_theme'] . '/modules/' . $module_file ); -$xtpl->assign( 'LANG', $lang_module ); -$xtpl->assign( 'FORM_ACTION', NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=multidel' ); +$xtpl = new XTemplate('main.tpl', NV_ROOTDIR . '/themes/' . $global_config['module_theme'] . '/modules/' . $module_file); +$xtpl->assign('LANG', $lang_module); +$xtpl->assign('FORM_ACTION', NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=multidel'); -$all_page = $db->query( 'SELECT COUNT(*) FROM ' . NV_PREFIXLANG . '_' . $module_data . '_rows' )->fetchColumn(); -if( empty( $all_page ) ) -{ - Header( 'Location: ' . NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=content' ); - exit(); +$all_page = $db->query('SELECT COUNT(*) FROM ' . NV_PREFIXLANG . '_' . $module_data . '_rows')->fetchColumn(); +if (empty($all_page)) { + Header('Location: ' . NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=content'); + exit(); } $base_url = NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name; $per_page = 10; -$page = $nv_Request->get_int( 'page', 'get', 0 ); +$page = $nv_Request->get_int('page', 'get', 0); $sql = 'SELECT * FROM ' . NV_PREFIXLANG . '_' . $module_data . '_rows ORDER BY id DESC LIMIT ' . $page . ', ' . $per_page; -$result = $db->query( $sql ); - -while( $row = $result->fetch() ) -{ - $xtpl->assign( 'ROW', array( - 'id' => $row['id'], - 'title' => $row['title'], - 'url' => $row['url'], - 'hits_total' => $row['hits_total'], - 'status' => $row['status'] == 1 ? $lang_module['weblink_yes'] : $lang_module['weblink_no'], - 'url_edit' => NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=content&id=' . $row['id'], - 'url_delete' => NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=del_link&id=' . $row['id'] ) ); - - $xtpl->parse( 'main.loop' ); +$result = $db->query($sql); + +while ($row = $result->fetch()) { + $xtpl->assign('ROW', array( + 'id' => $row['id'], + 'title' => $row['title'], + 'url' => $row['url'], + 'hits_total' => $row['hits_total'], + 'status' => $row['status'] == 1 ? $lang_module['weblink_yes'] : $lang_module['weblink_no'], + 'url_edit' => NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=content&id=' . $row['id'], + 'url_delete' => NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=del_link&id=' . $row['id'] )); + + $xtpl->parse('main.loop'); } -$generate_page = nv_generate_page( $base_url, $all_page, $per_page, $page ); -if( ! empty( $generate_page ) ) -{ - $xtpl->assign( 'GENERATE_PAGE', $generate_page ); - $xtpl->parse( 'main.generate_page' ); +$generate_page = nv_generate_page($base_url, $all_page, $per_page, $page); +if (! empty($generate_page)) { + $xtpl->assign('GENERATE_PAGE', $generate_page); + $xtpl->parse('main.generate_page'); } -$xtpl->parse( 'main' ); -$contents = $xtpl->text( 'main' ); +$xtpl->parse('main'); +$contents = $xtpl->text('main'); include NV_ROOTDIR . '/includes/header.php'; -echo nv_admin_theme( $contents ); -include NV_ROOTDIR . '/includes/footer.php'; \ No newline at end of file +echo nv_admin_theme($contents); +include NV_ROOTDIR . '/includes/footer.php'; diff --git a/modules/weblinks/blocks/module.block_category.php b/modules/weblinks/blocks/module.block_category.php index e2867ba9f..1fddf81e1 100644 --- a/modules/weblinks/blocks/module.block_category.php +++ b/modules/weblinks/blocks/module.block_category.php @@ -8,72 +8,67 @@ * @Createdate 2-9-2010 14:43 */ -if( ! defined( 'NV_IS_MOD_WEBLINKS' ) ) die( 'Stop!!!' ); +if (! defined('NV_IS_MOD_WEBLINKS')) { + die('Stop!!!'); +} global $catid; -if( empty( $catid ) ) $catid = 0; +if (empty($catid)) { + $catid = 0; +} -if( ! nv_function_exists( 'nv_weblink_category' ) ) -{ - function nv_weblink_category() - { - global $global_array_cat, $module_file, $module_info; +if (! nv_function_exists('nv_weblink_category')) { + function nv_weblink_category() + { + global $global_array_cat, $module_file, $module_info; - $xtpl = new XTemplate( 'block_category.tpl', NV_ROOTDIR . '/themes/' . $module_info['template'] . '/modules/' . $module_file ); - $xtpl->assign( 'TEMPLATE', $module_info['template'] ); - $xtpl->assign( 'NV_BASE_SITEURL', NV_BASE_SITEURL ); - $xtpl->assign( 'BLOCK_ID', 'web' . rand( 1, 1000 ) ); + $xtpl = new XTemplate('block_category.tpl', NV_ROOTDIR . '/themes/' . $module_info['template'] . '/modules/' . $module_file); + $xtpl->assign('TEMPLATE', $module_info['template']); + $xtpl->assign('NV_BASE_SITEURL', NV_BASE_SITEURL); + $xtpl->assign('BLOCK_ID', 'web' . rand(1, 1000)); - if( ! empty( $global_array_cat ) ) - { - $title_length = 20; - $html = ''; + if (! empty($global_array_cat)) { + $title_length = 20; + $html = ''; - foreach( $global_array_cat as $cat ) - { - if( $cat['parentid'] == 0 ) - { - $html .= '
  • '; - $html .= '' . nv_clean60( $cat['title'], $title_length ) . ''; - $html .= nv_weblink_sub_category( $cat['catid'], $title_length ); - $html .= '
  • '; - } - } + foreach ($global_array_cat as $cat) { + if ($cat['parentid'] == 0) { + $html .= '
  • '; + $html .= '' . nv_clean60($cat['title'], $title_length) . ''; + $html .= nv_weblink_sub_category($cat['catid'], $title_length); + $html .= '
  • '; + } + } - $xtpl->assign( 'HTML_CONTENT', $html ); - $xtpl->parse( 'main' ); + $xtpl->assign('HTML_CONTENT', $html); + $xtpl->parse('main'); - return $xtpl->text( 'main' ); - } - } + return $xtpl->text('main'); + } + } - function nv_weblink_sub_category( $catid, $title_length ) - { - global $global_array_cat; + function nv_weblink_sub_category($catid, $title_length) + { + global $global_array_cat; - if( empty( $catid ) ) - { - return ''; - } - else - { - $html = ''; + if (empty($catid)) { + return ''; + } else { + $html = ''; - return $html; - } - } + return $html; + } + } } -$content = nv_weblink_category(); \ No newline at end of file +$content = nv_weblink_category(); diff --git a/modules/weblinks/checkurl.class.php b/modules/weblinks/checkurl.class.php index 0f5b93351..6a97c7e30 100644 --- a/modules/weblinks/checkurl.class.php +++ b/modules/weblinks/checkurl.class.php @@ -13,69 +13,68 @@ */ class CheckUrl { - protected $host = null; - protected $port = null; + protected $host = null; + protected $port = null; - public function fsockopen( $host, $port ) - { - $this->host = preg_replace( '/http:\/\//i', '', $host ); - $this->port = $port; - $connection = @fsockopen( $this->host, $this->port ); + public function fsockopen($host, $port) + { + $this->host = preg_replace('/http:\/\//i', '', $host); + $this->port = $port; + $connection = @fsockopen($this->host, $this->port); - if( $connection ) - { - fclose( $connection ); - return true; - } + if ($connection) { + fclose($connection); + return true; + } - return false; - } + return false; + } - public function socket_connect() - { - $this->host = $host; - $this->port = $port; + public function socket_connect() + { + $this->host = $host; + $this->port = $port; - $sock = socket_create( AF_INET, SOCK_STREAM, SOL_TCP ); - $connection = @socket_connect( $sock, $this->host, $this->port ); + $sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); + $connection = @socket_connect($sock, $this->host, $this->port); - if( $connection ) - { - socket_close( $sock ); - return true; - } + if ($connection) { + socket_close($sock); + return true; + } - return false; - } + return false; + } - public function check_curl( $host ) - { - $this->host = $host; - if( ! function_exists( "curl_init" ) ) return false; + public function check_curl($host) + { + $this->host = $host; + if (! function_exists("curl_init")) { + return false; + } - $curl = curl_init(); - $header = array(); - $header[] = "Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5"; - $header[] = "Cache-Control: max-age=0"; - $header[] = "Connection: keep-alive"; - $header[] = "Keep-Alive: 300"; - $header[] = "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7"; - $header[] = "Accept-Language: en-us,en;q=0.5"; - $header[] = "Pragma: "; + $curl = curl_init(); + $header = array(); + $header[] = "Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5"; + $header[] = "Cache-Control: max-age=0"; + $header[] = "Connection: keep-alive"; + $header[] = "Keep-Alive: 300"; + $header[] = "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7"; + $header[] = "Accept-Language: en-us,en;q=0.5"; + $header[] = "Pragma: "; - curl_setopt( $curl, CURLOPT_URL, $this->host ); - curl_setopt( $curl, CURLOPT_USERAGENT, 'Googlebot/2.1 (+http://www.google.com/bot.html)' ); - curl_setopt( $curl, CURLOPT_HTTPHEADER, $header ); - curl_setopt( $curl, CURLOPT_REFERER, 'http://www.google.com' ); - curl_setopt( $curl, CURLOPT_ENCODING, 'gzip,deflate' ); - curl_setopt( $curl, CURLOPT_AUTOREFERER, true ); - curl_setopt( $curl, CURLOPT_RETURNTRANSFER, 1 ); - curl_setopt( $curl, CURLOPT_TIMEOUT, 10 ); - if( curl_exec( $curl ) ) - { - curl_close( $curl ); - return true; - } - return false; - } -} \ No newline at end of file + curl_setopt($curl, CURLOPT_URL, $this->host); + curl_setopt($curl, CURLOPT_USERAGENT, 'Googlebot/2.1 (+http://www.google.com/bot.html)'); + curl_setopt($curl, CURLOPT_HTTPHEADER, $header); + curl_setopt($curl, CURLOPT_REFERER, 'http://www.google.com'); + curl_setopt($curl, CURLOPT_ENCODING, 'gzip,deflate'); + curl_setopt($curl, CURLOPT_AUTOREFERER, true); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($curl, CURLOPT_TIMEOUT, 10); + if (curl_exec($curl)) { + curl_close($curl); + return true; + } + return false; + } +} diff --git a/modules/weblinks/funcs/detail.php b/modules/weblinks/funcs/detail.php index 513c53fa7..d9b9b9918 100644 --- a/modules/weblinks/funcs/detail.php +++ b/modules/weblinks/funcs/detail.php @@ -8,32 +8,31 @@ * @Createdate 3-6-2010 0:14 */ -if( ! defined( 'NV_IS_MOD_WEBLINKS' ) ) die( 'Stop!!!' ); +if (! defined('NV_IS_MOD_WEBLINKS')) { + die('Stop!!!'); +} $key_words = $module_info['keywords']; -$mod_title = isset( $lang_module['main_title'] ) ? $lang_module['main_title'] : $module_info['custom_title']; +$mod_title = isset($lang_module['main_title']) ? $lang_module['main_title'] : $module_info['custom_title']; global $global_array_cat; -$sql = 'SELECT * FROM ' . NV_PREFIXLANG . '_' . $module_data . '_rows WHERE id = ' . intval( $id ); -$result = $db->query( $sql ); +$sql = 'SELECT * FROM ' . NV_PREFIXLANG . '_' . $module_data . '_rows WHERE id = ' . intval($id); +$result = $db->query($sql); $row = $result->fetch(); $page_title = $row['title'] . ' - ' . $global_array_cat[$row['catid']]['title']; $row['visit'] = NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=visitlink-' . $row['alias'] . '-' . $row['id']; -$row['report'] = nv_url_rewrite( NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=reportlink-' . $row['alias'] . '-' . $row['id'], true ); +$row['report'] = nv_url_rewrite(NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=reportlink-' . $row['alias'] . '-' . $row['id'], true); -if( ! empty( $row['urlimg'] ) ) -{ - $row['urlimg'] = NV_BASE_SITEURL . NV_ASSETS_DIR . '/' . $row['urlimg']; -} -else -{ - $row['urlimg'] = NV_BASE_SITEURL . 'themes/' . $module_info['template'] . '/images/' . $module_file . '/no_image.gif'; +if (! empty($row['urlimg'])) { + $row['urlimg'] = NV_BASE_SITEURL . NV_ASSETS_DIR . '/' . $row['urlimg']; +} else { + $row['urlimg'] = NV_BASE_SITEURL . 'themes/' . $module_info['template'] . '/images/' . $module_file . '/no_image.gif'; } -$contents = call_user_func( 'detail', $row ); +$contents = call_user_func('detail', $row); include NV_ROOTDIR . '/includes/header.php'; -echo nv_site_theme( $contents ); -include NV_ROOTDIR . '/includes/footer.php'; \ No newline at end of file +echo nv_site_theme($contents); +include NV_ROOTDIR . '/includes/footer.php'; diff --git a/modules/weblinks/funcs/main.php b/modules/weblinks/funcs/main.php index e9c4aa674..cc7a0e4d0 100644 --- a/modules/weblinks/funcs/main.php +++ b/modules/weblinks/funcs/main.php @@ -8,57 +8,59 @@ * @Createdate 3-31-2010 0:33 */ -if( ! defined( 'NV_IS_MOD_WEBLINKS' ) ) die( 'Stop!!!' ); +if (! defined('NV_IS_MOD_WEBLINKS')) { + die('Stop!!!'); +} $page_title = $module_info['custom_title']; $key_words = $module_info['keywords']; -$mod_title = isset( $lang_module['main_title'] ) ? $lang_module['main_title'] : $module_info['custom_title']; +$mod_title = isset($lang_module['main_title']) ? $lang_module['main_title'] : $module_info['custom_title']; $array_cat = array(); -$sort = ( $weblinks_config['sort'] == 'des' ) ? 'desc' : 'asc'; -if( $weblinks_config['sortoption'] == 'byhit' ) $orderby = 'hits_total '; -elseif( $weblinks_config['sortoption'] == 'byid' ) $orderby = 'id '; -elseif( $weblinks_config['sortoption'] == 'bytime' ) $orderby = 'add_time '; -else $orderby = 'rand() '; +$sort = ($weblinks_config['sort'] == 'des') ? 'desc' : 'asc'; +if ($weblinks_config['sortoption'] == 'byhit') { + $orderby = 'hits_total '; +} elseif ($weblinks_config['sortoption'] == 'byid') { + $orderby = 'id '; +} elseif ($weblinks_config['sortoption'] == 'bytime') { + $orderby = 'add_time '; +} else { + $orderby = 'rand() '; +} $array_cat_content = array(); $urllink = NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '='; -foreach( $global_array_cat as $catid_i => $array_cat_i ) -{ - $content = array(); - if( $array_cat_i['parentid'] == 0 ) - { - $array_cat[$catid_i] = array( - 'title' => $array_cat_i['title'], - 'link' => $array_cat_i['link'], - 'description' => $array_cat_i['description'], - 'catimage' => $array_cat_i['catimage'], - 'subcat' => array() ); +foreach ($global_array_cat as $catid_i => $array_cat_i) { + $content = array(); + if ($array_cat_i['parentid'] == 0) { + $array_cat[$catid_i] = array( + 'title' => $array_cat_i['title'], + 'link' => $array_cat_i['link'], + 'description' => $array_cat_i['description'], + 'catimage' => $array_cat_i['catimage'], + 'subcat' => array() ); - $sql = 'SELECT id, author, title, alias, url, urlimg, note, description, add_time, hits_total FROM ' . NV_PREFIXLANG . '_' . $module_data . '_rows WHERE status = 1 AND catid =' . $catid_i . ' ORDER BY ' . $orderby . $sort . ' LIMIT 0,3'; - $result = $db->query( $sql ); - while( $row = $result->fetch() ) - { - $row['link'] = $global_array_cat[$catid_i]['link'] . '/' . $row['alias'] . '-' . $row['id']; - $row['linkvi'] = $urllink . 'visitlink-' . $row['alias'] . '-' . $row['id']; - $content[] = $row; - } - } - else - { - $parentid = $array_cat_i['parentid']; + $sql = 'SELECT id, author, title, alias, url, urlimg, note, description, add_time, hits_total FROM ' . NV_PREFIXLANG . '_' . $module_data . '_rows WHERE status = 1 AND catid =' . $catid_i . ' ORDER BY ' . $orderby . $sort . ' LIMIT 0,3'; + $result = $db->query($sql); + while ($row = $result->fetch()) { + $row['link'] = $global_array_cat[$catid_i]['link'] . '/' . $row['alias'] . '-' . $row['id']; + $row['linkvi'] = $urllink . 'visitlink-' . $row['alias'] . '-' . $row['id']; + $content[] = $row; + } + } else { + $parentid = $array_cat_i['parentid']; - $array_cat[$parentid]['subcat'][] = array( - 'title' => $global_array_cat[$catid_i]['title'], - 'link' => $global_array_cat[$catid_i]['link'], - 'count_link' => $global_array_cat[$catid_i]['count_link'] ); - } - $array_cat_content[$catid_i] = $content; + $array_cat[$parentid]['subcat'][] = array( + 'title' => $global_array_cat[$catid_i]['title'], + 'link' => $global_array_cat[$catid_i]['link'], + 'count_link' => $global_array_cat[$catid_i]['count_link'] ); + } + $array_cat_content[$catid_i] = $content; } -$contents = call_user_func( 'main_theme', $array_cat, $array_cat_content ); +$contents = call_user_func('main_theme', $array_cat, $array_cat_content); include NV_ROOTDIR . '/includes/header.php'; -echo nv_site_theme( $contents ); -include NV_ROOTDIR . '/includes/footer.php'; \ No newline at end of file +echo nv_site_theme($contents); +include NV_ROOTDIR . '/includes/footer.php'; diff --git a/modules/weblinks/funcs/reportlink.php b/modules/weblinks/funcs/reportlink.php index 2af1879ce..6c67024d0 100644 --- a/modules/weblinks/funcs/reportlink.php +++ b/modules/weblinks/funcs/reportlink.php @@ -8,73 +8,64 @@ * @Createdate 3-6-2010 0:14 */ -if( ! defined( 'NV_IS_MOD_WEBLINKS' ) ) die( 'Stop!!!' ); +if (! defined('NV_IS_MOD_WEBLINKS')) { + die('Stop!!!'); +} -$submit = $nv_Request->get_string( 'submit', 'post' ); -$report_id = $nv_Request->get_int( 'report_id', 'post' ); -$id = ( $id == 0 ) ? $report_id : $id; +$submit = $nv_Request->get_string('submit', 'post'); +$report_id = $nv_Request->get_int('report_id', 'post'); +$id = ($id == 0) ? $report_id : $id; -$sql = 'SELECT title, alias FROM ' . NV_PREFIXLANG . '_' . $module_data . '_rows WHERE id=' . intval( $id ); -$result = $db->query( $sql ); +$sql = 'SELECT title, alias FROM ' . NV_PREFIXLANG . '_' . $module_data . '_rows WHERE id=' . intval($id); +$result = $db->query($sql); $row = $result->fetch(); -unset( $sql, $result ); +unset($sql, $result); -if( !empty( $row ) ) -{ - $row['error'] = ''; - $row['action'] = nv_url_rewrite( NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=reportlink-' . $row['alias'] . '-' . $id, true ); - $row['id'] = $id; +if (!empty($row)) { + $row['error'] = ''; + $row['action'] = nv_url_rewrite(NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=reportlink-' . $row['alias'] . '-' . $id, true); + $row['id'] = $id; - $check = false; - if( $submit and $report_id ) - { - $sql = 'SELECT type FROM ' . NV_PREFIXLANG . '_' . $module_data . '_report WHERE id=' . intval( $report_id ); - $result = $db->query( $sql ); - $rows = $result->fetch(); + $check = false; + if ($submit and $report_id) { + $sql = 'SELECT type FROM ' . NV_PREFIXLANG . '_' . $module_data . '_report WHERE id=' . intval($report_id); + $result = $db->query($sql); + $rows = $result->fetch(); - $report = $nv_Request->get_int( 'report', 'post' ); - $report_note = nv_substr( $nv_Request->get_title( 'report_note', 'post', '', 1 ), 0, 255 ); + $report = $nv_Request->get_int('report', 'post'); + $report_note = nv_substr($nv_Request->get_title('report_note', 'post', '', 1), 0, 255); - $row['report_note'] = $report_note; - if( $report == 0 and empty( $report_note ) ) - { - $row['error'] = $lang_module['error']; - } - elseif( ! empty( $report_note ) and ! isset( $report_note{9} ) ) - { - $row['error'] = $lang_module['error_word_min']; - } - elseif( $rows['type'] == $report ) - { - $check = true; - } - else - { - $report_note = nv_nl2br( $report_note ); + $row['report_note'] = $report_note; + if ($report == 0 and empty($report_note)) { + $row['error'] = $lang_module['error']; + } elseif (! empty($report_note) and ! isset($report_note{9})) { + $row['error'] = $lang_module['error_word_min']; + } elseif ($rows['type'] == $report) { + $check = true; + } else { + $report_note = nv_nl2br($report_note); - $sql = 'INSERT INTO ' . NV_PREFIXLANG . '_' . $module_data . '_report SET + $sql = 'INSERT INTO ' . NV_PREFIXLANG . '_' . $module_data . '_report SET id=' . $report_id . ', type=' . $report . ', report_time=' . NV_CURRENTTIME . ', report_userid=0, - report_ip=' . $db->quote( $client_info['ip'] ) . ', - report_browse_key=' . $db->quote( $client_info['browser']['key'] ) . ', - report_browse_name=' . $db->quote( $client_info['browser']['name'] ) . ', - report_os_key=' . $db->quote( $client_info['client_os']['key'] ) . ', - report_os_name=' . $db->quote( $client_info['client_os']['name'] ) . ', - report_note=' . $db->quote( $report_note ); + report_ip=' . $db->quote($client_info['ip']) . ', + report_browse_key=' . $db->quote($client_info['browser']['key']) . ', + report_browse_name=' . $db->quote($client_info['browser']['name']) . ', + report_os_key=' . $db->quote($client_info['client_os']['key']) . ', + report_os_name=' . $db->quote($client_info['client_os']['name']) . ', + report_note=' . $db->quote($report_note); - $check = $db->query( $sql ); - } - } + $check = $db->query($sql); + } + } - $contents = call_user_func( 'report', $row, $check ); - - include NV_ROOTDIR . '/includes/header.php'; - echo nv_site_theme( $contents, 0 ); - include NV_ROOTDIR . '/includes/footer.php'; + $contents = call_user_func('report', $row, $check); + + include NV_ROOTDIR . '/includes/header.php'; + echo nv_site_theme($contents, 0); + include NV_ROOTDIR . '/includes/footer.php'; +} else { + trigger_error("you don't permission to access!!!", 256); } -else -{ - trigger_error( "you don't permission to access!!!", 256 ); -} \ No newline at end of file diff --git a/modules/weblinks/funcs/rss.php b/modules/weblinks/funcs/rss.php index 7dd15a5cf..aec1b58fb 100644 --- a/modules/weblinks/funcs/rss.php +++ b/modules/weblinks/funcs/rss.php @@ -8,55 +8,49 @@ * @Createdate Apr 20, 2010 10:47:41 AM */ -if( ! defined( 'NV_IS_MOD_WEBLINKS' ) ) die( 'Stop!!!' ); +if (! defined('NV_IS_MOD_WEBLINKS')) { + die('Stop!!!'); +} $channel = array(); $items = array(); $channel['title'] = $module_info['custom_title']; $channel['link'] = NV_MY_DOMAIN . NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name; -$channel['description'] = ! empty( $module_info['description'] ) ? $module_info['description'] : $global_config['site_description']; +$channel['description'] = ! empty($module_info['description']) ? $module_info['description'] : $global_config['site_description']; $catid = 0; -if( isset( $array_op[1] ) ) -{ - $alias_cat_url = $array_op[1]; - $cattitle = ''; - foreach( $global_array_cat as $catid_i => $array_cat_i ) - { - if( $alias_cat_url == $array_cat_i['alias'] ) - { - $catid = $catid_i; - break; - } - } +if (isset($array_op[1])) { + $alias_cat_url = $array_op[1]; + $cattitle = ''; + foreach ($global_array_cat as $catid_i => $array_cat_i) { + if ($alias_cat_url == $array_cat_i['alias']) { + $catid = $catid_i; + break; + } + } } -if( ! empty( $catid ) ) -{ - $channel['title'] = $module_info['custom_title'] . ' - ' . $global_array_cat[$catid]['title']; - $channel['link'] = NV_MY_DOMAIN . NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=' . $module_info['alias']['rss'] . '/' . $alias_cat_url; - $channel['description'] = $global_array_cat[$catid]['description']; +if (! empty($catid)) { + $channel['title'] = $module_info['custom_title'] . ' - ' . $global_array_cat[$catid]['title']; + $channel['link'] = NV_MY_DOMAIN . NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=' . $module_info['alias']['rss'] . '/' . $alias_cat_url; + $channel['description'] = $global_array_cat[$catid]['description']; - $sql = 'SELECT id, catid, add_time, title, alias, description, urlimg FROM ' . NV_PREFIXLANG . '_' . $module_data . '_rows WHERE catid=' . intval( $catid ) . ' AND status=1 ORDER BY id ASC LIMIT 30'; -} -else -{ - $sql = 'SELECT id, catid, add_time, title, alias, description, urlimg FROM ' . NV_PREFIXLANG . '_' . $module_data . '_rows WHERE status=1 ORDER BY id ASC LIMIT 30'; + $sql = 'SELECT id, catid, add_time, title, alias, description, urlimg FROM ' . NV_PREFIXLANG . '_' . $module_data . '_rows WHERE catid=' . intval($catid) . ' AND status=1 ORDER BY id ASC LIMIT 30'; +} else { + $sql = 'SELECT id, catid, add_time, title, alias, description, urlimg FROM ' . NV_PREFIXLANG . '_' . $module_data . '_rows WHERE status=1 ORDER BY id ASC LIMIT 30'; } -if( $module_info['rss'] ) -{ - $result = $db->query( $sql ); - while( list( $id, $catid_i, $publtime, $title, $alias, $description, $urlimg ) = $result->fetch( 3 ) ) - { - $rimages = ( ! empty( $urlimg ) ) ? '' : ''; - $catalias = $global_array_cat[$catid_i]['alias']; - $items[] = array( - 'title' => $title, - 'link' => NV_MY_DOMAIN . NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=' . $catalias . '/' . $alias . '-' . $id, - 'guid' => $module_name . '_' . $id, - 'description' => $rimages . $description, - 'pubdate' => $publtime ); - } +if ($module_info['rss']) { + $result = $db->query($sql); + while (list($id, $catid_i, $publtime, $title, $alias, $description, $urlimg) = $result->fetch(3)) { + $rimages = (! empty($urlimg)) ? '' : ''; + $catalias = $global_array_cat[$catid_i]['alias']; + $items[] = array( + 'title' => $title, + 'link' => NV_MY_DOMAIN . NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=' . $catalias . '/' . $alias . '-' . $id, + 'guid' => $module_name . '_' . $id, + 'description' => $rimages . $description, + 'pubdate' => $publtime ); + } } -nv_rss_generate( $channel, $items ); -die(); \ No newline at end of file +nv_rss_generate($channel, $items); +die(); diff --git a/modules/weblinks/funcs/sitemap.php b/modules/weblinks/funcs/sitemap.php index 2b0c82a18..5322f38a4 100644 --- a/modules/weblinks/funcs/sitemap.php +++ b/modules/weblinks/funcs/sitemap.php @@ -9,7 +9,9 @@ * @Createdate 4/12/2010, 1:27 */ -if (!defined('NV_IS_MOD_WEBLINKS')) die('Stop!!!'); +if (!defined('NV_IS_MOD_WEBLINKS')) { + die('Stop!!!'); +} $url = array(); $cacheFile = NV_LANG_DATA . '_sitemap_' . NV_CACHE_PREFIX . '.cache'; @@ -21,7 +23,7 @@ $sql = 'SELECT id, catid, add_time, alias FROM ' . NV_PREFIXLANG . '_' . $module_data . '_rows WHERE status=1 ORDER BY id ASC LIMIT 1000'; $result = $db->query($sql); - while (list ($id, $catid_i, $publtime, $alias) = $result->fetch(3)) { + while (list($id, $catid_i, $publtime, $alias) = $result->fetch(3)) { $catalias = $global_array_cat[$catid_i]['alias']; $url[] = array( 'link' => NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=' . $catalias . '/' . $alias . '-' . $id, // @@ -34,4 +36,4 @@ } nv_xmlSitemap_generate($url); -die(); \ No newline at end of file +die(); diff --git a/modules/weblinks/funcs/viewcat.php b/modules/weblinks/funcs/viewcat.php index 1ffb42bb5..7fc7d291a 100644 --- a/modules/weblinks/funcs/viewcat.php +++ b/modules/weblinks/funcs/viewcat.php @@ -8,7 +8,9 @@ * @Createdate 3-6-2010 0:14 */ -if( ! defined( 'NV_IS_MOD_WEBLINKS' ) ) die( 'Stop!!!' ); +if (! defined('NV_IS_MOD_WEBLINKS')) { + die('Stop!!!'); +} global $global_array_cat; @@ -19,71 +21,71 @@ $items = array(); $array_subcat = array(); $array_cat = array(); -foreach( $global_array_cat as $array_cat_i ) -{ - if( $array_cat_i['parentid'] == $catid ) - { - $array_subcat[] = array( - 'title' => $array_cat_i['title'], - 'link' => $array_cat_i['link'], - 'count_link' => $array_cat_i['count_link'] - ); - } +foreach ($global_array_cat as $array_cat_i) { + if ($array_cat_i['parentid'] == $catid) { + $array_subcat[] = array( + 'title' => $array_cat_i['title'], + 'link' => $array_cat_i['link'], + 'count_link' => $array_cat_i['count_link'] + ); + } } $array_cat[] = array( - 'title' => $global_array_cat[$catid]['title'], - 'link' => $global_array_cat[$catid]['link'], - 'description' => $global_array_cat[$catid]['description'] + 'title' => $global_array_cat[$catid]['title'], + 'link' => $global_array_cat[$catid]['link'], + 'description' => $global_array_cat[$catid]['description'] ); -$sort = ( $weblinks_config['sort'] == 'des' ) ? 'desc' : 'asc'; -if( $weblinks_config['sortoption'] == 'byhit' ) $orderby = 'hits_total '; -elseif( $weblinks_config['sortoption'] == 'byid' ) $orderby = 'id '; -elseif( $weblinks_config['sortoption'] == 'bytime' ) $orderby = 'add_time '; -else $orderby = 'rand() '; +$sort = ($weblinks_config['sort'] == 'des') ? 'desc' : 'asc'; +if ($weblinks_config['sortoption'] == 'byhit') { + $orderby = 'hits_total '; +} elseif ($weblinks_config['sortoption'] == 'byid') { + $orderby = 'id '; +} elseif ($weblinks_config['sortoption'] == 'bytime') { + $orderby = 'add_time '; +} else { + $orderby = 'rand() '; +} $base_url = $global_array_cat[$catid]['link']; $db->sqlreset() - ->select( 'COUNT(*)' ) - ->from( NV_PREFIXLANG . '_' . $module_data . '_rows' ) - ->where( 'status=1 AND catid=' . intval( $catid ) ); - -$num_items = $db->query( $db->sql() )->fetchColumn(); + ->select('COUNT(*)') + ->from(NV_PREFIXLANG . '_' . $module_data . '_rows') + ->where('status=1 AND catid=' . intval($catid)); + +$num_items = $db->query($db->sql())->fetchColumn(); -$db->select( 'id, author, title, alias, url, urlimg, add_time, description, hits_total' ) - ->order( $orderby . $sort ) - ->limit( $per_page ) - ->offset( ( $page - 1 ) * $per_page ); - -$result = $db->query( $db->sql() ); +$db->select('id, author, title, alias, url, urlimg, add_time, description, hits_total') + ->order($orderby . $sort) + ->limit($per_page) + ->offset(($page - 1) * $per_page); + +$result = $db->query($db->sql()); -while( $row = $result->fetch() ) -{ - $author = explode( '|', $row['author'] ); +while ($row = $result->fetch()) { + $author = explode('|', $row['author']); - if( $author[0] == 1 ) - { - $sql1 = 'SELECT * FROM ' . NV_AUTHORS_GLOBALTABLE . ' WHERE admin_id=' . $author[1] . ''; - $result1 = $db->query( $sql1 ); - $row1 = $result1->fetch(); - $row['author'] = $row1; - } + if ($author[0] == 1) { + $sql1 = 'SELECT * FROM ' . NV_AUTHORS_GLOBALTABLE . ' WHERE admin_id=' . $author[1] . ''; + $result1 = $db->query($sql1); + $row1 = $result1->fetch(); + $row['author'] = $row1; + } - $row['link'] = $global_array_cat[$catid]['link'] . '/' . $row['alias'] . '-' . $row['id']; - $row['visit'] = NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=visitlink-' . $row['alias'] . '-' . $row['id']; - $row['report'] = NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=reportlink-' . $row['alias'] . '-' . $row['id']; - $items[] = $row; + $row['link'] = $global_array_cat[$catid]['link'] . '/' . $row['alias'] . '-' . $row['id']; + $row['visit'] = NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=visitlink-' . $row['alias'] . '-' . $row['id']; + $row['report'] = NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=reportlink-' . $row['alias'] . '-' . $row['id']; + $items[] = $row; } -$contents = call_user_func( 'viewcat', $array_subcat, $array_cat, $items ); -$contents .= nv_alias_page( $page_title, $base_url, $num_items, $per_page, $page ); +$contents = call_user_func('viewcat', $array_subcat, $array_cat, $items); +$contents .= nv_alias_page($page_title, $base_url, $num_items, $per_page, $page); -if( $page > 1 ) -{ - $page_title .= ' ' . NV_TITLEBAR_DEFIS . ' ' . $lang_global['page'] . ' ' . $page; +if ($page > 1) { + $page_title .= ' ' . NV_TITLEBAR_DEFIS . ' ' . $lang_global['page'] . ' ' . $page; } include NV_ROOTDIR . '/includes/header.php'; -echo nv_site_theme( $contents ); -include NV_ROOTDIR . '/includes/footer.php'; \ No newline at end of file +echo nv_site_theme($contents); +include NV_ROOTDIR . '/includes/footer.php'; diff --git a/modules/weblinks/funcs/visitlink.php b/modules/weblinks/funcs/visitlink.php index dc0564be0..cf3648f3f 100644 --- a/modules/weblinks/funcs/visitlink.php +++ b/modules/weblinks/funcs/visitlink.php @@ -8,38 +8,35 @@ * @Createdate 3-6-2010 0:14 */ -if( ! defined( 'NV_IS_MOD_WEBLINKS' ) ) die( 'Stop!!!' ); +if (! defined('NV_IS_MOD_WEBLINKS')) { + die('Stop!!!'); +} global $timeout; $id = 0; -$temp = explode( '-', $array_op[0] ); -$id = end( $temp ) ; -$sql = 'SELECT url FROM ' . NV_PREFIXLANG . '_' . $module_data . '_rows WHERE id=' . intval( $id ) . ' LIMIT 0,1'; -$result = $db->query( $sql ); +$temp = explode('-', $array_op[0]); +$id = end($temp) ; +$sql = 'SELECT url FROM ' . NV_PREFIXLANG . '_' . $module_data . '_rows WHERE id=' . intval($id) . ' LIMIT 0,1'; +$result = $db->query($sql); $row = $result->fetch(); -if( $row['url'] != '' ) -{ - if( ! preg_match( '/http:\/\//i', $row['url'] ) ) - { - $url = 'http://' . $url; - } - - if( isset( $_COOKIE['timeout'] ) and $_COOKIE['timeout'] == $id ) - { - $contents .= sprintf( $lang_module['notimeout'], $timeout ); - } - else - { - setcookie( 'timeout', $id, time() + $timeout * 60 ); - $db->query( 'UPDATE ' . NV_PREFIXLANG . '_' . $module_data . '_rows SET hits_total=hits_total+1 WHERE id=' . intval( $id ) ); - } - - Header( 'Location: ' . $row['url'] ); - exit(); +if ($row['url'] != '') { + if (! preg_match('/http:\/\//i', $row['url'])) { + $url = 'http://' . $url; + } + + if (isset($_COOKIE['timeout']) and $_COOKIE['timeout'] == $id) { + $contents .= sprintf($lang_module['notimeout'], $timeout); + } else { + setcookie('timeout', $id, time() + $timeout * 60); + $db->query('UPDATE ' . NV_PREFIXLANG . '_' . $module_data . '_rows SET hits_total=hits_total+1 WHERE id=' . intval($id)); + } + + Header('Location: ' . $row['url']); + exit(); } include NV_ROOTDIR . '/includes/header.php'; -echo nv_site_theme( $contents ); +echo nv_site_theme($contents); include NV_ROOTDIR . '/includes/footer.php'; diff --git a/modules/weblinks/functions.php b/modules/weblinks/functions.php index a2cea0d2b..ebaf57fdc 100644 --- a/modules/weblinks/functions.php +++ b/modules/weblinks/functions.php @@ -8,11 +8,13 @@ * @Createdate 12/31/2009 0:51 */ -if( ! defined( 'NV_SYSTEM' ) ) die( 'Stop!!!' ); +if (! defined('NV_SYSTEM')) { + die('Stop!!!'); +} -define( 'NV_IS_MOD_WEBLINKS', true ); +define('NV_IS_MOD_WEBLINKS', true); -require_once ( NV_ROOTDIR . '/modules/' . $module_file . '/global.functions.php' ); +require_once(NV_ROOTDIR . '/modules/' . $module_file . '/global.functions.php'); /** * adminlink() @@ -20,114 +22,97 @@ * @param mixed $id * @return */ -function adminlink( $id ) +function adminlink($id) { - global $lang_module, $module_name; - $link = ' ' . $lang_module['delete'] . '  '; - $link .= ' ' . $lang_module['edit'] . ''; - return $link; + global $lang_module, $module_name; + $link = ' ' . $lang_module['delete'] . '  '; + $link .= ' ' . $lang_module['edit'] . ''; + return $link; } $catid = 0; $parentid = 0; $set_viewcat = ''; -$alias_cat_url = isset( $array_op[0] ) ? $array_op[0] : ''; +$alias_cat_url = isset($array_op[0]) ? $array_op[0] : ''; $array_mod_title = array(); $global_array_cat = array(); // Xac dinh RSS -if( $module_info['rss'] ) -{ - $rss[] = array( 'title' => $module_info['custom_title'], 'src' => NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=' . $module_info['alias']['rss'] ); +if ($module_info['rss']) { + $rss[] = array( 'title' => $module_info['custom_title'], 'src' => NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=' . $module_info['alias']['rss'] ); } $sql = 'SELECT catid, parentid, title, description, catimage, alias, keywords FROM ' . NV_PREFIXLANG . '_' . $module_data . '_cat WHERE inhome=1 ORDER BY parentid, weight'; -$result = $db->query( $sql ); - -while( list( $catid_i, $parentid_i, $title_i, $description_i, $catimage_i, $alias_i, $keywords_i ) = $result->fetch( 3 ) ) -{ - $link_i = NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=' . $alias_i; - - $sql1 = 'SELECT COUNT(*) FROM ' . NV_PREFIXLANG . '_' . $module_data . '_rows WHERE catid = '. $catid_i; - $result1 = $db->query( $sql1 ); - - $count_link = $result1->fetchColumn(); - - $global_array_cat[$catid_i] = array( - 'catid' => $catid_i, - 'parentid' => $parentid_i, - 'title' => $title_i, - 'alias' => $alias_i, - 'link' => $link_i, - 'description' => $description_i, - 'keywords' => $keywords_i, - 'catimage' => $catimage_i, - 'count_link' => $count_link ); - - if( $alias_cat_url == $alias_i ) - { - $catid = $catid_i; - $parentid = $parentid_i; - } - - //Xac dinh RSS - if( $module_info['rss'] ) - { - $rss[] = array( 'title' => $module_info['custom_title'] . ' - ' . $title_i, 'src' => NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=' . $module_info['alias']['rss'] . '/' . $alias_i ); - } +$result = $db->query($sql); + +while (list($catid_i, $parentid_i, $title_i, $description_i, $catimage_i, $alias_i, $keywords_i) = $result->fetch(3)) { + $link_i = NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=' . $alias_i; + + $sql1 = 'SELECT COUNT(*) FROM ' . NV_PREFIXLANG . '_' . $module_data . '_rows WHERE catid = '. $catid_i; + $result1 = $db->query($sql1); + + $count_link = $result1->fetchColumn(); + + $global_array_cat[$catid_i] = array( + 'catid' => $catid_i, + 'parentid' => $parentid_i, + 'title' => $title_i, + 'alias' => $alias_i, + 'link' => $link_i, + 'description' => $description_i, + 'keywords' => $keywords_i, + 'catimage' => $catimage_i, + 'count_link' => $count_link ); + + if ($alias_cat_url == $alias_i) { + $catid = $catid_i; + $parentid = $parentid_i; + } + + //Xac dinh RSS + if ($module_info['rss']) { + $rss[] = array( 'title' => $module_info['custom_title'] . ' - ' . $title_i, 'src' => NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=' . $module_info['alias']['rss'] . '/' . $alias_i ); + } } -unset( $sql, $result ); +unset($sql, $result); -$count_op = sizeof( $array_op ); +$count_op = sizeof($array_op); $per_page = $weblinks_config['per_page']; $page = 1; -if( ! empty( $array_op ) ) -{ - if( $catid == 0 ) - { - if( substr( $array_op[0], 0, 10 ) == 'visitlink-' ) - { - $op = 'visitlink'; - } - elseif( substr( $array_op[0], 0, 11 ) == 'reportlink-' ) - { - $op = 'reportlink'; - } - $temp = explode( '-', $array_op[0] ); - $id = intval( end( $temp ) ); - } - else - { - $op = 'main'; - if( $count_op == 1 or substr( $array_op[1], 0, 5 ) == 'page-' ) - { - $op = 'viewcat'; - if( $count_op > 1 ) - { - $page = intval( substr( $array_op[1], 5 ) ); - } - } - elseif( $count_op == 2 ) - { - $array_page = explode( '-', $array_op[1] ); - $id = intval( end( $array_page ) ); - $alias_url = str_replace( '-' . $id, '', $array_op[1] ); - if( $id > 0 and $alias_url != '' ) - { - $op = 'detail'; - } - } - $parentid = $catid; - while( $parentid > 0 ) - { - $array_cat_i = $global_array_cat[$parentid]; - $array_mod_title[] = array( - 'catid' => $parentid, - 'title' => $array_cat_i['title'], - 'link' => $array_cat_i['link'] ); - $parentid = $array_cat_i['parentid']; - } - sort( $array_mod_title, SORT_NUMERIC ); - } -} \ No newline at end of file +if (! empty($array_op)) { + if ($catid == 0) { + if (substr($array_op[0], 0, 10) == 'visitlink-') { + $op = 'visitlink'; + } elseif (substr($array_op[0], 0, 11) == 'reportlink-') { + $op = 'reportlink'; + } + $temp = explode('-', $array_op[0]); + $id = intval(end($temp)); + } else { + $op = 'main'; + if ($count_op == 1 or substr($array_op[1], 0, 5) == 'page-') { + $op = 'viewcat'; + if ($count_op > 1) { + $page = intval(substr($array_op[1], 5)); + } + } elseif ($count_op == 2) { + $array_page = explode('-', $array_op[1]); + $id = intval(end($array_page)); + $alias_url = str_replace('-' . $id, '', $array_op[1]); + if ($id > 0 and $alias_url != '') { + $op = 'detail'; + } + } + $parentid = $catid; + while ($parentid > 0) { + $array_cat_i = $global_array_cat[$parentid]; + $array_mod_title[] = array( + 'catid' => $parentid, + 'title' => $array_cat_i['title'], + 'link' => $array_cat_i['link'] ); + $parentid = $array_cat_i['parentid']; + } + sort($array_mod_title, SORT_NUMERIC); + } +} diff --git a/modules/weblinks/global.functions.php b/modules/weblinks/global.functions.php index 64b3eb479..a321d4c82 100644 --- a/modules/weblinks/global.functions.php +++ b/modules/weblinks/global.functions.php @@ -8,7 +8,9 @@ * @Createdate 12/31/2009 0:51 */ -if( ! defined( 'NV_MAINFILE' ) ) die( 'Stop!!!' ); +if (! defined('NV_MAINFILE')) { + die('Stop!!!'); +} /** * _substr() @@ -18,32 +20,28 @@ * @param integer $minword * @return */ -function _substr( $str, $length, $minword = 3 ) +function _substr($str, $length, $minword = 3) { - $sub = ''; - $len = 0; + $sub = ''; + $len = 0; - foreach( explode( ' ', $str ) as $word ) - { - $part = ( ( $sub != '' ) ? ' ' : '' ) . $word; - $sub .= $part; - $len += strlen( $part ); + foreach (explode(' ', $str) as $word) { + $part = (($sub != '') ? ' ' : '') . $word; + $sub .= $part; + $len += strlen($part); - if( isset( $word{$minword} ) && isset( $sub{$length - 1} ) ) - { - break; - } - } + if (isset($word{$minword}) && isset($sub{$length - 1})) { + break; + } + } - return $sub . ( ( isset( $str{$len} ) ) ? '...' : '' ); + return $sub . ((isset($str{$len})) ? '...' : ''); } $weblinks_config = array(); $sql = 'SELECT * FROM ' . NV_PREFIXLANG . '_' . $module_data . '_config'; -$list = $nv_Cache->db( $sql, '', $module_name ); -foreach( $list as $l ) -{ - - $weblinks_config[$l['name']] = $l['value']; +$list = $nv_Cache->db($sql, '', $module_name); +foreach ($list as $l) { + $weblinks_config[$l['name']] = $l['value']; } -unset( $sql, $list ); \ No newline at end of file +unset($sql, $list); diff --git a/modules/weblinks/language/admin_en.php b/modules/weblinks/language/admin_en.php index 0bda0a5c3..b43278a12 100644 --- a/modules/weblinks/language/admin_en.php +++ b/modules/weblinks/language/admin_en.php @@ -9,7 +9,9 @@ * @Createdate Mar 04, 2010, 08:22:00 AM */ -if( ! defined( 'NV_ADMIN' ) or ! defined( 'NV_MAINFILE' ) ) die( 'Stop!!!' ); +if (! defined('NV_ADMIN') or ! defined('NV_MAINFILE')) { + die('Stop!!!'); +} $lang_translator['author'] = 'VINADES.,JSC (contact@vinades.vn)'; $lang_translator['createdate'] = '04/03/2010, 15:22'; @@ -123,4 +125,4 @@ $lang_module['link_broken_out'] = 'Remove broken link'; $lang_module['config_error_per_page'] = 'Error: Not on per_page field'; $lang_module['siteinfo_numberlink'] = 'Total links'; -$lang_module['siteinfo_error'] = 'Bad link reports'; \ No newline at end of file +$lang_module['siteinfo_error'] = 'Bad link reports'; diff --git a/modules/weblinks/language/admin_vi.php b/modules/weblinks/language/admin_vi.php index dd86d1352..74180bf78 100644 --- a/modules/weblinks/language/admin_vi.php +++ b/modules/weblinks/language/admin_vi.php @@ -9,7 +9,9 @@ * @Createdate Mar 04, 2010, 03:22:00 PM */ -if( ! defined( 'NV_ADMIN' ) or ! defined( 'NV_MAINFILE' ) ) die( 'Stop!!!' ); +if (! defined('NV_ADMIN') or ! defined('NV_MAINFILE')) { + die('Stop!!!'); +} $lang_translator['author'] = 'VINADES.,JSC (contact@vinades.vn)'; $lang_translator['createdate'] = '04/03/2010, 15:22'; diff --git a/modules/weblinks/language/en.php b/modules/weblinks/language/en.php index 179f7deac..348de29b3 100644 --- a/modules/weblinks/language/en.php +++ b/modules/weblinks/language/en.php @@ -9,7 +9,9 @@ * @Createdate Mar 04, 2010, 08:22:00 AM */ -if( ! defined( 'NV_MAINFILE' ) ) die( 'Stop!!!' ); +if (! defined('NV_MAINFILE')) { + die('Stop!!!'); +} $lang_translator['author'] = 'VINADES.,JSC (contact@vinades.vn)'; $lang_translator['createdate'] = '04/03/2010, 15:22'; @@ -44,4 +46,4 @@ $lang_module['error'] = 'You must select at least 1 report type!'; $lang_module['error_word_min'] = 'You must input at least 10 characters'; $lang_module['view_title'] = 'Views'; -$lang_module['next_title'] = 'Next'; \ No newline at end of file +$lang_module['next_title'] = 'Next'; diff --git a/modules/weblinks/language/vi.php b/modules/weblinks/language/vi.php index af1909808..f7a88a441 100644 --- a/modules/weblinks/language/vi.php +++ b/modules/weblinks/language/vi.php @@ -9,7 +9,9 @@ * @Createdate Mar 04, 2010, 03:22:00 PM */ -if( ! defined( 'NV_MAINFILE' ) ) die( 'Stop!!!' ); +if (! defined('NV_MAINFILE')) { + die('Stop!!!'); +} $lang_translator['author'] = 'VINADES.,JSC (contact@vinades.vn)'; $lang_translator['createdate'] = '04/03/2010, 15:22'; @@ -44,4 +46,4 @@ $lang_module['error'] = 'Bạn phải lựa chọn 1 trong những yêu cầu báo cáo trước khi gửi thông tin đến chúng tôi!!!'; $lang_module['error_word_min'] = 'Chuỗi ký tự bạn nhập vào phải lớn hơn 10'; $lang_module['view_title'] = 'Lượt xem'; -$lang_module['next_title'] = 'Xem tiếp'; \ No newline at end of file +$lang_module['next_title'] = 'Xem tiếp'; diff --git a/modules/weblinks/rssdata.php b/modules/weblinks/rssdata.php index 9f648da85..06d34b9ed 100644 --- a/modules/weblinks/rssdata.php +++ b/modules/weblinks/rssdata.php @@ -8,15 +8,16 @@ * @Createdate Apr 20, 2010 10:47:41 AM */ -if( ! defined( 'NV_IS_MOD_RSS' ) ) die( 'Stop!!!' ); +if (! defined('NV_IS_MOD_RSS')) { + die('Stop!!!'); +} $rssarray = array(); $sql = 'SELECT catid, parentid, title, alias FROM ' . NV_PREFIXLANG . '_' . $mod_data . '_cat ORDER BY parentid ASC, weight ASC'; //$rssarray[] = array( 'catid' => 0, 'parentid' => 0, 'title' => '', 'link' => ''); -$list = $nv_Cache->db( $sql, '', $mod_name ); -foreach( $list as $value ) -{ - $value['link'] = NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $mod_name . '&' . NV_OP_VARIABLE . '=' . $mod_info['alias']['rss'] . '/' . $value['alias']; - $rssarray[] = $value; -} \ No newline at end of file +$list = $nv_Cache->db($sql, '', $mod_name); +foreach ($list as $value) { + $value['link'] = NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $mod_name . '&' . NV_OP_VARIABLE . '=' . $mod_info['alias']['rss'] . '/' . $value['alias']; + $rssarray[] = $value; +} diff --git a/modules/weblinks/search.php b/modules/weblinks/search.php index 5518b03f1..2dec29dc4 100644 --- a/modules/weblinks/search.php +++ b/modules/weblinks/search.php @@ -8,32 +8,31 @@ * @Createdate 03-05-2010 */ -if( ! defined( 'NV_IS_MOD_SEARCH' ) ) die( 'Stop!!!' ); - -$db->sqlreset()->select( 'COUNT(*)' )->from( NV_PREFIXLANG . '_' . $m_values['module_data'] . '_rows' )->where( '(' . nv_like_logic( 'title', $dbkeyword, $logic ) . ' OR ' . nv_like_logic( 'url', $dbkeyword, $logic ) . ' OR ' . nv_like_logic( 'description', $dbkeyword, $logic ) . ')' ); - -$num_items = $db->query( $db->sql() )->fetchColumn(); - -$db->select( 'id, catid, title, alias, description' )->limit( $limit )->offset( ( $page - 1 ) * $limit ); -$result = $db->query( $db->sql() ); - -if( $num_items ) -{ - $array_cat_url = array(); - $array_cat_url[0] = NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $m_values['module_name'] . '&' . NV_OP_VARIABLE . '=other'; - - $sql_cat = 'SELECT catid, alias FROM ' . NV_PREFIXLANG . '_' . $m_values['module_data'] . '_cat'; - $re_cat = $db->query( $sql_cat ); - while( list( $catid, $alias ) = $re_cat->fetch( 3 ) ) - { - $array_cat_url[$catid] = NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $m_values['module_name'] . '&' . NV_OP_VARIABLE . '=' . $alias; - } - - while( list( $id, $catid, $tilterow, $alias, $content ) = $result->fetch( 3 ) ) - { - $result_array[] = array( - 'link' => $array_cat_url[$catid] . '/' . $alias, - 'title' => BoldKeywordInStr( $tilterow, $key, $logic ), - 'content' => BoldKeywordInStr( $content, $key, $logic ) ); - } +if (! defined('NV_IS_MOD_SEARCH')) { + die('Stop!!!'); +} + +$db->sqlreset()->select('COUNT(*)')->from(NV_PREFIXLANG . '_' . $m_values['module_data'] . '_rows')->where('(' . nv_like_logic('title', $dbkeyword, $logic) . ' OR ' . nv_like_logic('url', $dbkeyword, $logic) . ' OR ' . nv_like_logic('description', $dbkeyword, $logic) . ')'); + +$num_items = $db->query($db->sql())->fetchColumn(); + +$db->select('id, catid, title, alias, description')->limit($limit)->offset(($page - 1) * $limit); +$result = $db->query($db->sql()); + +if ($num_items) { + $array_cat_url = array(); + $array_cat_url[0] = NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $m_values['module_name'] . '&' . NV_OP_VARIABLE . '=other'; + + $sql_cat = 'SELECT catid, alias FROM ' . NV_PREFIXLANG . '_' . $m_values['module_data'] . '_cat'; + $re_cat = $db->query($sql_cat); + while (list($catid, $alias) = $re_cat->fetch(3)) { + $array_cat_url[$catid] = NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $m_values['module_name'] . '&' . NV_OP_VARIABLE . '=' . $alias; + } + + while (list($id, $catid, $tilterow, $alias, $content) = $result->fetch(3)) { + $result_array[] = array( + 'link' => $array_cat_url[$catid] . '/' . $alias, + 'title' => BoldKeywordInStr($tilterow, $key, $logic), + 'content' => BoldKeywordInStr($content, $key, $logic) ); + } } diff --git a/modules/weblinks/siteinfo.php b/modules/weblinks/siteinfo.php index 338b68134..9d2d91cb3 100644 --- a/modules/weblinks/siteinfo.php +++ b/modules/weblinks/siteinfo.php @@ -8,23 +8,23 @@ * @Createdate Apr 20, 2010 10:47:41 AM */ -if( ! defined( 'NV_IS_FILE_SITEINFO' ) ) die( 'Stop!!!' ); +if (! defined('NV_IS_FILE_SITEINFO')) { + die('Stop!!!'); +} -$lang_siteinfo = nv_get_lang_module( $mod ); +$lang_siteinfo = nv_get_lang_module($mod); // Tong so link -$number = $db->query( 'SELECT COUNT(*) as number FROM ' . NV_PREFIXLANG . '_' . $mod_data . '_rows where status= 1' )->fetchColumn(); -if( $number > 0 ) -{ - $siteinfo[] = array( 'key' => $lang_siteinfo['siteinfo_numberlink'], 'value' => $number ); +$number = $db->query('SELECT COUNT(*) as number FROM ' . NV_PREFIXLANG . '_' . $mod_data . '_rows where status= 1')->fetchColumn(); +if ($number > 0) { + $siteinfo[] = array( 'key' => $lang_siteinfo['siteinfo_numberlink'], 'value' => $number ); } // So bao cao link hong -$number = $db->query( 'SELECT COUNT(*) as number FROM ' . NV_PREFIXLANG . '_' . $mod_data . '_report' )->fetchColumn(); -if( $number > 0 ) -{ - $pendinginfo[] = array( - 'key' => $lang_siteinfo['siteinfo_error'], - 'value' => $number, - 'link' => NV_BASE_ADMINURL . 'index.php?' . NV_NAME_VARIABLE . '=' . $mod . '&' . NV_OP_VARIABLE . '=brokenlink' ); -} \ No newline at end of file +$number = $db->query('SELECT COUNT(*) as number FROM ' . NV_PREFIXLANG . '_' . $mod_data . '_report')->fetchColumn(); +if ($number > 0) { + $pendinginfo[] = array( + 'key' => $lang_siteinfo['siteinfo_error'], + 'value' => $number, + 'link' => NV_BASE_ADMINURL . 'index.php?' . NV_NAME_VARIABLE . '=' . $mod . '&' . NV_OP_VARIABLE . '=brokenlink' ); +} diff --git a/modules/weblinks/theme.php b/modules/weblinks/theme.php index 13e414c91..f2f303aae 100644 --- a/modules/weblinks/theme.php +++ b/modules/weblinks/theme.php @@ -8,7 +8,9 @@ * @Createdate 12/31/2009 0:51 */ -if( ! defined( 'NV_IS_MOD_WEBLINKS' ) ) die( 'Stop!!!' ); +if (! defined('NV_IS_MOD_WEBLINKS')) { + die('Stop!!!'); +} /** * main_theme() @@ -17,73 +19,62 @@ * @param mixed $array_cat_content * @return */ -function main_theme( $array_cat, $array_cat_content ) +function main_theme($array_cat, $array_cat_content) { - global $module_info, $module_file, $lang_module, $weblinks_config; + global $module_info, $module_file, $lang_module, $weblinks_config; - $xtpl = new XTemplate( 'main_page.tpl', NV_ROOTDIR . '/themes/' . $module_info['template'] . '/modules/' . $module_file ); - $xtpl->assign( 'BASE_URL', NV_BASE_SITEURL ); - $xtpl->assign( 'SRC_IMG_WIDTH', $weblinks_config['imgwidth'] ); + $xtpl = new XTemplate('main_page.tpl', NV_ROOTDIR . '/themes/' . $module_info['template'] . '/modules/' . $module_file); + $xtpl->assign('BASE_URL', NV_BASE_SITEURL); + $xtpl->assign('SRC_IMG_WIDTH', $weblinks_config['imgwidth']); - foreach( $array_cat as $catid => $array_cat_i ) - { - if( ! empty( $array_cat_i ) and ! empty( $array_cat_content[$catid] ) ) - { - $xtpl->assign( 'CATE_TITLE', $array_cat_i['title'] ); - $xtpl->assign( 'LINK_URL_CATE', $array_cat_i['link'] ); - $i = 0; - foreach( $array_cat_i['subcat'] as $subcat ) - { - $xtpl->assign( 'CATE_TITLE_SUB', $subcat['title'] ); - $xtpl->assign( 'LINK_URL_CATE_SUB', $subcat['link'] ); - $xtpl->parse( 'main.loop_tab_cate.loop_sub_title' ); - if( $i == 2 ) - { - $xtpl->assign( 'NEXT_TITLE', $lang_module['next_title'] ); - $xtpl->parse( 'main.loop_tab_cate.next' ); - break; - } - ++$i; - } - if( ! empty( $array_cat_content[$catid] ) ) - { - foreach( $array_cat_content[$catid] as $content ) - { - $xtpl->assign( 'WEBLINK_TITLE', $content['title'] ); - $xtpl->assign( 'WEBLINK_VIEW', $content['link'] ); - if( $weblinks_config['showlinkimage'] == '1' ) - { - if( $content['urlimg'] != '' ) - { - $urlimg = NV_BASE_SITEURL . NV_ASSETS_DIR . '/' . $content['urlimg']; - } - else - { - $urlimg = NV_BASE_SITEURL . 'themes/' . $module_info['template'] . '/images/' . $module_file . '/no_image.gif'; - } - $xtpl->assign( 'SRC_IMG', $urlimg ); - $xtpl->parse( 'main.loop_tab_cate.have_data.img' ); - } - $intro = strip_tags( $content['description'] ); - $xtpl->assign( 'TEXT_HOME', nv_clean60( $intro, 200 ) . '...' ); - $xtpl->assign( 'VIEW_TILTE', $lang_module['view_title'] ); - $xtpl->assign( 'NUM_VIEW', $content['hits_total'] ); - $dateup = date( 'd/m/Y', $content['add_time'] ); - $xtpl->assign( 'DATE_UP', $dateup ); - $xtpl->assign( 'LINK_VISIT', $content['linkvi'] ); - $xtpl->assign( 'LINK_URL', nv_clean60( $content['url'], 70 ) . '...' ); - if( defined( 'NV_IS_ADMIN' ) ) - { - $xtpl->assign( 'ADMIN_LINK', adminlink( $content['id'] ) ); - } - $xtpl->parse( 'main.loop_tab_cate.have_data' ); - } - } - $xtpl->parse( 'main.loop_tab_cate' ); - } - } - $xtpl->parse( 'main' ); - return $xtpl->text( 'main' ); + foreach ($array_cat as $catid => $array_cat_i) { + if (! empty($array_cat_i) and ! empty($array_cat_content[$catid])) { + $xtpl->assign('CATE_TITLE', $array_cat_i['title']); + $xtpl->assign('LINK_URL_CATE', $array_cat_i['link']); + $i = 0; + foreach ($array_cat_i['subcat'] as $subcat) { + $xtpl->assign('CATE_TITLE_SUB', $subcat['title']); + $xtpl->assign('LINK_URL_CATE_SUB', $subcat['link']); + $xtpl->parse('main.loop_tab_cate.loop_sub_title'); + if ($i == 2) { + $xtpl->assign('NEXT_TITLE', $lang_module['next_title']); + $xtpl->parse('main.loop_tab_cate.next'); + break; + } + ++$i; + } + if (! empty($array_cat_content[$catid])) { + foreach ($array_cat_content[$catid] as $content) { + $xtpl->assign('WEBLINK_TITLE', $content['title']); + $xtpl->assign('WEBLINK_VIEW', $content['link']); + if ($weblinks_config['showlinkimage'] == '1') { + if ($content['urlimg'] != '') { + $urlimg = NV_BASE_SITEURL . NV_ASSETS_DIR . '/' . $content['urlimg']; + } else { + $urlimg = NV_BASE_SITEURL . 'themes/' . $module_info['template'] . '/images/' . $module_file . '/no_image.gif'; + } + $xtpl->assign('SRC_IMG', $urlimg); + $xtpl->parse('main.loop_tab_cate.have_data.img'); + } + $intro = strip_tags($content['description']); + $xtpl->assign('TEXT_HOME', nv_clean60($intro, 200) . '...'); + $xtpl->assign('VIEW_TILTE', $lang_module['view_title']); + $xtpl->assign('NUM_VIEW', $content['hits_total']); + $dateup = date('d/m/Y', $content['add_time']); + $xtpl->assign('DATE_UP', $dateup); + $xtpl->assign('LINK_VISIT', $content['linkvi']); + $xtpl->assign('LINK_URL', nv_clean60($content['url'], 70) . '...'); + if (defined('NV_IS_ADMIN')) { + $xtpl->assign('ADMIN_LINK', adminlink($content['id'])); + } + $xtpl->parse('main.loop_tab_cate.have_data'); + } + } + $xtpl->parse('main.loop_tab_cate'); + } + } + $xtpl->parse('main'); + return $xtpl->text('main'); } /** @@ -94,75 +85,60 @@ function main_theme( $array_cat, $array_cat_content ) * @param mixed $items * @return */ -function viewcat( $array_subcat, $array_cat, $items ) +function viewcat($array_subcat, $array_cat, $items) { - global $module_info, $module_file, $lang_module, $weblinks_config; + global $module_info, $module_file, $lang_module, $weblinks_config; - $xtpl = new XTemplate( 'viewcat.tpl', NV_ROOTDIR . '/themes/' . $module_info['template'] . '/modules/' . $module_file ); - $xtpl->assign( 'LANG', $lang_module ); - foreach( $array_cat as $array_cat_i ) - { - $xtpl->assign( 'CAT', $array_cat_i ); - if( ! empty( $array_cat_i['description'] ) ) - { - $xtpl->parse( 'main.cat.showdes' ); - } - $xtpl->parse( 'main.cat' ); - } - if( ! empty( $array_subcat ) ) - { - $a = 1; - foreach( $array_subcat as $array_subcat_i ) - { - $xtpl->assign( 'SUB', $array_subcat_i ); - if( ( $weblinks_config['showcatimage'] == 1 ) and ! empty( $array_subcat_i['catimage'] ) ) - { - if( file_exists( NV_UPLOADS_REAL_DIR . NV_UPLOADS_DIR . '/' . $array_subcat_i['catimage'] ) && $array_subcat_i['catimage'] != '' ) - { - $xtpl->assign( 'IMG', NV_BASE_SITEURL . $array_subcat_i['catimage'] ); - } - } - else - { - $xtpl->assign( 'IMG', NV_BASE_SITEURL . 'themes/' . $module_info['template'] . '/images/' . $module_file . '/no_image.gif' ); - } - $xtpl->parse( 'main.sub.loop' ); - ++$a; - } - $xtpl->parse( 'main.sub' ); - } - if( ! empty( $items ) ) - { - foreach( $items as $items_i ) - { - $items_i['add_time'] = nv_date( 'H:i l - d/m/Y', $items_i['add_time'] ); - $items_i['description'] = strip_tags( $items_i['description'] ); - $items_i['description'] = _substr( $items_i['description'], 200 ); - if( ! empty( $items_i['urlimg'] ) ) - { - $urlimg = NV_BASE_SITEURL . NV_ASSETS_DIR . '/' . $items_i['urlimg']; - } - else - { - $urlimg = NV_BASE_SITEURL . 'themes/' . $module_info['template'] . '/images/' . $module_file . '/no_image.gif'; - } - $xtpl->assign( 'IMG', $urlimg ); - $items_i['url'] = nv_clean60( $items_i['url'], 70 ) . '...'; - $xtpl->assign( 'ITEM', $items_i ); - if( defined( 'NV_IS_ADMIN' ) ) - { - $xtpl->assign( 'ADMIN_LINK', adminlink( $items_i['id'] ) ); - } - if( $weblinks_config['showlinkimage'] == '1' ) - { - $xtpl->parse( 'main.items.loop.img' ); - } - $xtpl->parse( 'main.items.loop' ); - } - $xtpl->parse( 'main.items' ); - } - $xtpl->parse( 'main' ); - return $xtpl->text( 'main' ); + $xtpl = new XTemplate('viewcat.tpl', NV_ROOTDIR . '/themes/' . $module_info['template'] . '/modules/' . $module_file); + $xtpl->assign('LANG', $lang_module); + foreach ($array_cat as $array_cat_i) { + $xtpl->assign('CAT', $array_cat_i); + if (! empty($array_cat_i['description'])) { + $xtpl->parse('main.cat.showdes'); + } + $xtpl->parse('main.cat'); + } + if (! empty($array_subcat)) { + $a = 1; + foreach ($array_subcat as $array_subcat_i) { + $xtpl->assign('SUB', $array_subcat_i); + if (($weblinks_config['showcatimage'] == 1) and ! empty($array_subcat_i['catimage'])) { + if (file_exists(NV_UPLOADS_REAL_DIR . NV_UPLOADS_DIR . '/' . $array_subcat_i['catimage']) && $array_subcat_i['catimage'] != '') { + $xtpl->assign('IMG', NV_BASE_SITEURL . $array_subcat_i['catimage']); + } + } else { + $xtpl->assign('IMG', NV_BASE_SITEURL . 'themes/' . $module_info['template'] . '/images/' . $module_file . '/no_image.gif'); + } + $xtpl->parse('main.sub.loop'); + ++$a; + } + $xtpl->parse('main.sub'); + } + if (! empty($items)) { + foreach ($items as $items_i) { + $items_i['add_time'] = nv_date('H:i l - d/m/Y', $items_i['add_time']); + $items_i['description'] = strip_tags($items_i['description']); + $items_i['description'] = _substr($items_i['description'], 200); + if (! empty($items_i['urlimg'])) { + $urlimg = NV_BASE_SITEURL . NV_ASSETS_DIR . '/' . $items_i['urlimg']; + } else { + $urlimg = NV_BASE_SITEURL . 'themes/' . $module_info['template'] . '/images/' . $module_file . '/no_image.gif'; + } + $xtpl->assign('IMG', $urlimg); + $items_i['url'] = nv_clean60($items_i['url'], 70) . '...'; + $xtpl->assign('ITEM', $items_i); + if (defined('NV_IS_ADMIN')) { + $xtpl->assign('ADMIN_LINK', adminlink($items_i['id'])); + } + if ($weblinks_config['showlinkimage'] == '1') { + $xtpl->parse('main.items.loop.img'); + } + $xtpl->parse('main.items.loop'); + } + $xtpl->parse('main.items'); + } + $xtpl->parse('main'); + return $xtpl->text('main'); } /** @@ -171,39 +147,33 @@ function viewcat( $array_subcat, $array_cat, $items ) * @param mixed $row * @return */ -function detail( $row ) +function detail($row) { - global $module_info, $module_file, $lang_module, $weblinks_config; + global $module_info, $module_file, $lang_module, $weblinks_config; - $xtpl = new XTemplate( 'detail.tpl', NV_ROOTDIR . '/themes/' . $module_info['template'] . '/modules/' . $module_file ); - $row['add_time'] = nv_date( 'H:i l - d/m/Y', $row['add_time'] ); - $row['edit_time'] = nv_date( 'H:i l - d/m/Y', $row['edit_time'] ); - if( $weblinks_config['showlinkimage'] == '1' ) - { - if( $row['urlimg'] != '' ) - { - if( ! nv_is_url( $row['urlimg'] ) ) - { - $row['urlimg'] = $row['urlimg']; - } - $xtpl->assign( 'IMG', $row['urlimg'] ); - } - else - { - $xtpl->assign( 'IMG', NV_BASE_SITEURL . 'themes/' . $module_info['template'] . '/images/' . $module_file . '/no_image.gif' ); - } - $xtpl->parse( 'main.img' ); - } - $xtpl->assign( 'LANG', $lang_module ); - $row['url'] = nv_clean60( $row['url'], 60 ) . '...'; - $xtpl->assign( 'DETAIL', $row ); - ! empty( $row['description'] ) ? $xtpl->parse( 'main.des' ) : ''; - if( defined( 'NV_IS_ADMIN' ) ) - { - $xtpl->assign( 'ADMIN_LINK', adminlink( $row['id'] ) ); - } - $xtpl->parse( 'main' ); - return $xtpl->text( 'main' ); + $xtpl = new XTemplate('detail.tpl', NV_ROOTDIR . '/themes/' . $module_info['template'] . '/modules/' . $module_file); + $row['add_time'] = nv_date('H:i l - d/m/Y', $row['add_time']); + $row['edit_time'] = nv_date('H:i l - d/m/Y', $row['edit_time']); + if ($weblinks_config['showlinkimage'] == '1') { + if ($row['urlimg'] != '') { + if (! nv_is_url($row['urlimg'])) { + $row['urlimg'] = $row['urlimg']; + } + $xtpl->assign('IMG', $row['urlimg']); + } else { + $xtpl->assign('IMG', NV_BASE_SITEURL . 'themes/' . $module_info['template'] . '/images/' . $module_file . '/no_image.gif'); + } + $xtpl->parse('main.img'); + } + $xtpl->assign('LANG', $lang_module); + $row['url'] = nv_clean60($row['url'], 60) . '...'; + $xtpl->assign('DETAIL', $row); + ! empty($row['description']) ? $xtpl->parse('main.des') : ''; + if (defined('NV_IS_ADMIN')) { + $xtpl->assign('ADMIN_LINK', adminlink($row['id'])); + } + $xtpl->parse('main'); + return $xtpl->text('main'); } /** @@ -213,26 +183,24 @@ function detail( $row ) * @param mixed $check * @return */ -function report( $row, $check ) +function report($row, $check) { - global $module_info, $lang_module, $module_file; + global $module_info, $lang_module, $module_file; - $xtpl = new XTemplate( 'report.tpl', NV_ROOTDIR . '/themes/' . $module_info['template'] . '/modules/' . $module_file ); - $xtpl->assign( 'LANG', $lang_module ); - $xtpl->assign( 'ROW', $row ); - $xtpl->assign( 'NV_BASE_SITEURL', NV_BASE_SITEURL ); + $xtpl = new XTemplate('report.tpl', NV_ROOTDIR . '/themes/' . $module_info['template'] . '/modules/' . $module_file); + $xtpl->assign('LANG', $lang_module); + $xtpl->assign('ROW', $row); + $xtpl->assign('NV_BASE_SITEURL', NV_BASE_SITEURL); - if( ! empty( $row['error'] ) ) - { - $xtpl->parse( 'main.error' ); - } + if (! empty($row['error'])) { + $xtpl->parse('main.error'); + } - if( $check ) - { - $xtpl->parse( 'main.close' ); - $xtpl->parse( 'main.success' ); - } + if ($check) { + $xtpl->parse('main.close'); + $xtpl->parse('main.success'); + } - $xtpl->parse( 'main' ); - return $xtpl->text( 'main' ); -} \ No newline at end of file + $xtpl->parse('main'); + return $xtpl->text('main'); +} diff --git a/modules/weblinks/version.php b/modules/weblinks/version.php index f3cf641a1..da71674e7 100644 --- a/modules/weblinks/version.php +++ b/modules/weblinks/version.php @@ -8,16 +8,18 @@ * @Createdate 05/07/2010 09:47 */ -if( ! defined( 'NV_ADMIN' ) or ! defined( 'NV_MAINFILE' ) ) die( 'Stop!!!' ); +if (! defined('NV_ADMIN') or ! defined('NV_MAINFILE')) { + die('Stop!!!'); +} $module_version = array( - 'name' => 'weblinks', - 'modfuncs' => 'main,viewcat,detail', - 'is_sysmod' => 0, - 'virtual' => 1, - 'version' => '4.0.24', - 'date' => 'Wed, 20 Oct 2010 00:00:00 GMT', - 'author' => 'VINADES (contact@vinades.vn)', - 'note' => '', - 'uploads_dir' => array( $module_name, $module_name . '/cat' ) -); \ No newline at end of file + 'name' => 'weblinks', + 'modfuncs' => 'main,viewcat,detail', + 'is_sysmod' => 0, + 'virtual' => 1, + 'version' => '4.0.24', + 'date' => 'Wed, 20 Oct 2010 00:00:00 GMT', + 'author' => 'VINADES (contact@vinades.vn)', + 'note' => '', + 'uploads_dir' => array( $module_name, $module_name . '/cat' ) +);