Completed
Pull Request — master (#4)
by Michael
01:27
created

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
 * ****************************************************************************
4
 * MYIFRAME - MODULE FOR XOOPS
5
 * Copyright (c) Hervé Thouzard of Instant Zero (http://www.instant-zero.com)
6
 * ****************************************************************************
7
 */
8
9
require_once __DIR__ . '/../../mainfile.php';
10
require_once XOOPS_ROOT_PATH . '/modules/myiframe/include/functions.php';
11
$GLOBALS['xoopsOption']['template_main'] = 'myiframe.tpl';
12
require_once XOOPS_ROOT_PATH . '/header.php';
13
14
$suplparam = '';
15
if (isset($_GET)) {
16
    foreach ($_GET as $k => $v) {
17
        if (trim(strtoupper($k)) !== 'IFRAMEID') {
18
            $suplparam .= $k . '=' . $v . '&';
19
        }
20
    }
21
}
22
23
if (strlen(xoops_trim($suplparam)) > 0) {
24
    $suplparam = substr($suplparam, 0, strlen($suplparam) - 1);
25
}
26
27
$iframeHandler = xoops_getModuleHandler('myiframe', 'myiframe');
28
29
if (isset($_GET['iframeid'])) {
30
    $tblalign     = array(
31
        'top',
32
        'middle',
33
        'bottom',
34
        'left',
35
        'rigth'
36
    );
37
    $tblscrolling = array(
38
        'yes',
39
        'no',
40
        'auto'
41
    );
42
    $frameid      = (int)$_GET['iframeid'];
43
44
    $frame = $iframeHandler->get($frameid);
45
46
    if (is_object($frame)) {
47
        $iframeHandler->updatehits($frameid);
48
        $xoopsTpl->assign('frameok', true);
49
        $xoopsTpl->assign('longdesc', $frame->getVar('frame_description'));
50
        $xoopsTpl->assign('width', $frame->getVar('frame_width'));
51
        $xoopsTpl->assign('height', $frame->getVar('frame_height'));
52
        $xoopsTpl->assign('align', $tblalign[$frame->getVar('frame_align') - 1]);
53
        $xoopsTpl->assign('frameborder', $frame->getVar('frame_frameborder'));
54
        $xoopsTpl->assign('marginwidth', $frame->getVar('frame_marginwidth'));
55
        $xoopsTpl->assign('marginheight', $frame->getVar('frame_marginheight'));
56
        $xoopsTpl->assign('scrolling', $tblscrolling[$frame->getVar('frame_scrolling') - 1]);
57
        if (xoops_trim($suplparam) !== '') {
58
            $xoopsTpl->assign('url', $frame->getVar('frame_url') . '?' . $suplparam);
59
        } else {
60
            $xoopsTpl->assign('url', $frame->getVar('frame_url'));
61
        }
62
        $title = $frame->getVar('frame_description');
63
        myiframe_set_metas($title, $title);
64
    } else {
65
        $xoopsTpl->assign('frameok', false);
66
        $xoopsTpl->assign('frame_error', _MYIFRAME_FRAME_ERROR);
67
    }
68
} else {
69
    if (myiframe_getmoduleoption('showlist')) {
70
        $baseurl = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/index.php';
71
        $frarray = array();
72
        $critere = new Criteria('1', '1', '=');
73
        $critere->setSort('frame_description');
74
        $frarray = $iframeHandler->getObjects($critere);
75
        if (count($frarray) > 0) {
76
            foreach ($frarray as $frame) {
77 View Code Duplication
                if (xoops_trim($frame->getVar('frame_description') === '')) {
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...
78
                    $liendesc = $frame->getVar('frame_url');
79
                } else {
80
                    $liendesc = "<a href='" . $baseurl . '?iframeid=' . $frame->getVar('frame_frameid') . "'>" . $frame->getVar('frame_description') . '</a>';
81
                }
82
                $iframe['list'] = $liendesc;
83
                $xoopsTpl->append('iframes', $iframe);
84
            }
85
        }
86
    } else {
87
        $xoopsTpl->assign('frameok', false);
88
        $xoopsTpl->assign('frame_error', _MYIFRAME_FRAME_ERROR);
89
    }
90
}
91
include XOOPS_ROOT_PATH . '/footer.php';
92