Completed
Push — master ( 96da4e...7c5656 )
by Michael
04:52
created

transfer.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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 (http://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
include __DIR__ . '/header.php';
16
17 View Code Duplication
if (planet_parse_args($args_num, $args, $args_str)) {
0 ignored issues
show
This code seems to be duplicated across your project.

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.

Loading history...
18
    $args['article'] = @$args_num[0];
19
    $args['op']      = @$args_str[0];
20
}
21
22
$article_id = (int)(empty($_GET['article']) ? (empty($_POST['article']) ? @$args['article'] : $_POST['article']) : $_GET['article']);
23
24
$op = empty($_GET['op']) ? (empty($_POST['op']) ? @$args['op'] : $_POST['op']) : $_GET['op'];
25
$op = strtolower(trim($op));
26
27
if (empty($article_id)) {
28
    if (empty($_SERVER['HTTP_REFERER'])) {
29
        include XOOPS_ROOT_PATH . '/header.php';
30
        xoops_error(_NOPERM);
31
        $xoopsOption['output_type'] = 'plain';
32
        include XOOPS_ROOT_PATH . '/footer.php';
33
        exit();
34
    } else {
35
        $ref_parser = parse_url($_SERVER['HTTP_REFERER']);
36
        $uri_parser = parse_url($_SERVER['REQUEST_URI']);
37
        if ((!empty($ref_parser['host']) && !empty($uri_parser['host']) && $uri_parser['host'] != $ref_parser['host'])
38
            || ($ref_parser['path'] != $uri_parser['path'])
39
        ) {
40
            include XOOPS_ROOT_PATH . '/header.php';
41
            include XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/include/vars.php';
42
            xoops_confirm(array(), 'javascript: window.close();', sprintf(planet_constant('MD_TRANSFER_DONE'), ''),
43
                          _CLOSE, $_SERVER['HTTP_REFERER']);
44
            $xoopsOption['output_type'] = 'plain';
45
            include XOOPS_ROOT_PATH . '/footer.php';
46
            exit();
47
        } else {
48
            include XOOPS_ROOT_PATH . '/header.php';
49
            xoops_error(_NOPERM);
50
            $xoopsOption['output_type'] = 'plain';
51
            include XOOPS_ROOT_PATH . '/footer.php';
52
            exit();
53
        }
54
    }
55
}
56
57
$article_handler = xoops_getModuleHandler('article', $GLOBALS['moddirname']);
58
$article_obj     =& $article_handler->get($article_id);
59
60
// Display option form
61
if (empty($op)) {
62
    $module_variables .= "<input type=\"hidden\" name=\"article\" id=\"article\" value=\"{$article_id}\">";
63
    include XOOPS_ROOT_PATH . '/Frameworks/transfer/option.transfer.php';
64
    exit();
65
} else {
66
    $data           = array();
67
    $data['id']     = $article_id;
68
    $data['title']  = $article_obj->getVar('art_title');
69
    $data['time']   = $article_obj->getTime('l');
70
    $data['image']  = '';
71
    $data['source'] = $article_obj->getVar('art_link');
72
    $data['url']    = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.article.php' . URL_DELIMITER . ''
73
                      . $article_obj->getVar('art_id');
74
    $data['author'] = $article_obj->getVar('art_author');
75
76
    switch ($op) {
77
78
        // Use title
79
        case 'bookmark';
80
            break;
81
82
        case 'print':
83
        case 'pdf':
84
            ${"{$op}_data"}            =& $data;
85
            ${"{$op}_data"}['date']    = $pdf_data['time'];
86
            ${"{$op}_data"}['content'] = $article_obj->getVar('art_content');
87
            break;
88
89
        case 'newbb':
90
        default:
91
            $data['content'] = $article_obj->getSummary();
92
            break;
93
    }
94
    include XOOPS_ROOT_PATH . '/Frameworks/transfer/action.transfer.php';
95
    exit();
96
}
97