1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Transfer handler for XOOPS |
4
|
|
|
* |
5
|
|
|
* This is intended to handle content intercommunication between modules as well as components |
6
|
|
|
* There might need to be a more explicit name for the handle since it is always confusing |
7
|
|
|
* |
8
|
|
|
* @copyright XOOPS Project (https://xoops.org) |
9
|
|
|
* @license http://www.fsf.org/copyleft/gpl.html GNU public license |
10
|
|
|
* @author Taiwen Jiang (phppp or D.J.) <[email protected]> |
11
|
|
|
* @since 3.00 |
12
|
|
|
* @package Frameworks::transfer ; module::planet |
13
|
|
|
*/ |
14
|
|
|
|
15
|
|
|
use Xmf\Request; |
16
|
|
|
|
17
|
|
|
include __DIR__ . '/header.php'; |
18
|
|
|
|
19
|
|
View Code Duplication |
if (PlanetUtility::planetParseArguments($args_num, $args, $args_str)) { |
|
|
|
|
20
|
|
|
$args['article'] = @$args_num[0]; |
21
|
|
|
$args['op'] = @$args_str[0]; |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
$article_id = Request::getInt('article', Request::getInt('article', @$args['article'], 'POST'), 'GET');//(int)(empty($_GET['article']) ? (empty($_POST['article']) ? @$args['article'] : $_POST['article']) : $_GET['article']); |
25
|
|
|
|
26
|
|
|
$op = Request::getString('op', Request::getString('op', @$args['op'], 'POST'), 'GET');//empty($_GET['op']) ? (empty($_POST['op']) ? @$args['op'] : $_POST['op']) : $_GET['op']; |
27
|
|
|
$op = strtolower(trim($op)); |
28
|
|
|
|
29
|
|
|
if (empty($article_id)) { |
30
|
|
|
if (empty(Request::getUrl('HTTP_REFERER', '', 'SERVER'))) { |
31
|
|
|
//$_SERVER['HTTP_REFERER'])) |
32
|
|
|
|
33
|
|
|
include XOOPS_ROOT_PATH . '/header.php'; |
34
|
|
|
xoops_error(_NOPERM); |
35
|
|
|
$xoopsOption['output_type'] = 'plain'; |
36
|
|
|
include XOOPS_ROOT_PATH . '/footer.php'; |
37
|
|
|
exit(); |
38
|
|
|
} else { |
39
|
|
|
$ref_parser = parse_url(Request::getUrl('HTTP_REFERER', '', 'SERVER')); //$_SERVER['HTTP_REFERER']); |
40
|
|
|
$uri_parser = parse_url(Request::getUrl('REQUEST_URI', '', 'SERVER'));// $_SERVER['REQUEST_URI']); |
41
|
|
|
if ((!empty($ref_parser['host']) && !empty($uri_parser['host']) && $uri_parser['host'] != $ref_parser['host']) |
42
|
|
|
|| ($ref_parser['path'] != $uri_parser['path'])) { |
43
|
|
|
include XOOPS_ROOT_PATH . '/header.php'; |
44
|
|
|
include XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/include/vars.php'; |
45
|
|
|
xoops_confirm([], 'javascript: window.close();', sprintf(planet_constant('MD_TRANSFER_DONE'), ''), _CLOSE, Request::getUrl('HTTP_REFERER', '', 'SERVER')); |
46
|
|
|
$xoopsOption['output_type'] = 'plain'; |
47
|
|
|
include XOOPS_ROOT_PATH . '/footer.php'; |
48
|
|
|
exit(); |
49
|
|
|
} else { |
50
|
|
|
include XOOPS_ROOT_PATH . '/header.php'; |
51
|
|
|
xoops_error(_NOPERM); |
52
|
|
|
$xoopsOption['output_type'] = 'plain'; |
53
|
|
|
include XOOPS_ROOT_PATH . '/footer.php'; |
54
|
|
|
exit(); |
55
|
|
|
} |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
$articleHandler = xoops_getModuleHandler('article', $GLOBALS['moddirname']); |
60
|
|
|
$article_obj = $articleHandler->get($article_id); |
61
|
|
|
|
62
|
|
|
// Display option form |
63
|
|
|
if (empty($op)) { |
64
|
|
|
$module_variables .= "<input type=\"hidden\" name=\"article\" id=\"article\" value=\"{$article_id}\">"; |
65
|
|
|
include XOOPS_ROOT_PATH . '/Frameworks/transfer/option.transfer.php'; |
66
|
|
|
exit(); |
67
|
|
|
} else { |
68
|
|
|
$data = []; |
69
|
|
|
$data['id'] = $article_id; |
70
|
|
|
$data['title'] = $article_obj->getVar('art_title'); |
71
|
|
|
$data['time'] = $article_obj->getTime('l'); |
72
|
|
|
$data['image'] = ''; |
73
|
|
|
$data['source'] = $article_obj->getVar('art_link'); |
74
|
|
|
$data['url'] = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.article.php' . URL_DELIMITER . '' . $article_obj->getVar('art_id'); |
75
|
|
|
$data['author'] = $article_obj->getVar('art_author'); |
76
|
|
|
|
77
|
|
|
switch ($op) { |
78
|
|
|
|
79
|
|
|
// Use title |
80
|
|
|
case 'bookmark': |
81
|
|
|
break; |
82
|
|
|
|
83
|
|
|
case 'print': |
84
|
|
|
case 'pdf': |
85
|
|
|
${"{$op}_data"} =& $data; |
86
|
|
|
${"{$op}_data"}['date'] = $pdf_data['time']; |
87
|
|
|
${"{$op}_data"}['content'] = $article_obj->getVar('art_content'); |
88
|
|
|
break; |
89
|
|
|
|
90
|
|
|
case 'newbb': |
91
|
|
|
default: |
92
|
|
|
$data['content'] = $article_obj->getSummary(); |
93
|
|
|
break; |
94
|
|
|
} |
95
|
|
|
include XOOPS_ROOT_PATH . '/Frameworks/transfer/action.transfer.php'; |
96
|
|
|
exit(); |
97
|
|
|
} |
98
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.