Completed
Push — master ( ce95ba...616741 )
by Michael
02:29
created

editdesc.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
-------------------------------------------------------------------------
4
                     ADSLIGHT 2 : Module for Xoops
5
6
        Redesigned and ameliorate By Luc Bizet user at www.frxoops.org
7
        Started with the Classifieds module and made MANY changes
8
        Website : http://www.luc-bizet.fr
9
        Contact : [email protected]
10
-------------------------------------------------------------------------
11
             Original credits below Version History
12
##########################################################################
13
#                    Classified Module for Xoops                         #
14
#  By John Mordo user jlm69 at www.xoops.org and www.jlmzone.com         #
15
#      Started with the MyAds module and made MANY changes               #
16
##########################################################################
17
 Original Author: Pascal Le Boustouller
18
 Author Website : [email protected]
19
 Licence Type   : GPL
20
-------------------------------------------------------------------------
21
*/
22
23
use Xmf\Request;
24
25
$moduleDirName = basename(dirname(__DIR__));
26
$main_lang     = '_' . strtoupper($moduleDirName);
27
28
/**
29
 * Xoops Header
30
 */
31
include dirname(dirname(__DIR__)) . '/mainfile.php';
32
include_once XOOPS_ROOT_PATH . '/header.php';
33
include_once XOOPS_ROOT_PATH . '/class/criteria.php';
34
35
/**
36
 * Include modules classes
37
 */
38
include_once __DIR__ . '/class/pictures.php';
39
40
/**
41
 * Check if using XoopsCube (by jlm69)
42
 * Needed because of a difference in the way Xoops and XoopsCube handle tokens
43
 */
44
45
$xCube = false;
46
if (preg_match('/^XOOPS Cube/', XOOPS_VERSION)) { // XOOPS Cube 2.1x
47
    $xCube = true;
48
}
49
50
/**
51
 * Verify Ticket for Xoops Cube (by jlm69)
52
 * If your site is XoopsCube it uses $xoopsGTicket for the token.
53
 */
54
55 View Code Duplication
if ($xCube) {
56
    if (!$xoopsGTicket->check(true, 'token')) {
57
        redirect_header($_SERVER['HTTP_REFERER'], 3, $xoopsGTicket->getErrors());
58
    }
59
} else {
60
    /**
61
     * Verify TOKEN for Xoops
62
     * If your site is Xoops it uses xoopsSecurity for the token.
63
     */
64
    if (!$GLOBALS['xoopsSecurity']->check()) {
65
        redirect_header($_SERVER['HTTP_REFERER'], 3, constant('_ADSLIGHT_TOKENEXPIRED'));
66
    }
67
}
68
69
/**
70
 * Receiving info from get parameters
71
 */
72
$cod_img = Request::getString('cod_img', '', 'POST');
73
//$lid = (int)$_POST['lid'];
0 ignored issues
show
Unused Code Comprehensibility introduced by
65% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
74
//$marker = $_POST['marker'];
75
$marker = Request::getInt('marker', '', 'POST');
76
77
if ($marker == 1) {
78
    /**
79
     * Creating the factory  loading the picture changing its caption
80
     */
81
    $picture_factory = new JlmPicturesHandler($xoopsDB);
82
    $picture         = $picture_factory->create(false);
83
    $picture->load(Request::getString('cod_img', '', 'POST'));
84
    $picture->setVar('title', Request::getString('caption', '', 'POST'));
85
86
    /**
87
     * Verifying who's the owner to allow changes
88
     */
89
    $uid = $GLOBALS['xoopsUser']->getVar('uid');
90
    $lid = $picture->getVar('lid');
91
    if ($uid == $picture->getVar('uid_owner')) {
92
        if ($picture_factory->insert($picture)) {
93
            redirect_header('view_photos.php?lid=' . $lid . '&uid=' . $uid . '', 2, constant('_ADSLIGHT_DESC_EDITED'));
94 View Code Duplication
        } else {
95
            redirect_header('view_photos.php?lid=' . $lid . '&uid=' . $uid . '', 2, constant('_ADSLIGHT_NOCACHACA'));
96
        }
97
    }
98
}
99
100
/**
101
 * Creating the factory  and the criteria to edit the desc of the picture
102
 * The user must be the owner
103
 */
104
$album_factory = new JlmPicturesHandler($xoopsDB);
105
$criteria_img  = new Criteria('cod_img', $cod_img);
106
$uid           = $GLOBALS['xoopsUser']->getVar('uid');
107
$criteria_uid  = new Criteria('uid_owner', $uid);
108
$criteria      = new CriteriaCompo($criteria_img);
109
$criteria->add($criteria_uid);
110
111
/**
112
 * Lets fetch the info of the pictures to be able to render the form
113
 * The user must be the owner
114
 */
115
if ($array_pict =& $album_factory->getObjects($criteria)) {
116
    $caption = $array_pict[0]->getVar('title');
117
    $url     = $array_pict[0]->getVar('url');
118
}
119
$url = $GLOBALS['xoopsModuleConfig']['adslight_link_upload'] . '/thumbs/thumb_' . $url;
120
$album_factory->renderFormEdit($caption, $cod_img, $url);
121
122
/**
123
 * Close page
124
 */
125
include XOOPS_ROOT_PATH . '/footer.php';
126