Completed
Push — master ( 0424ea...923121 )
by Michael
03:57
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
$moduleDirName = basename( dirname( __DIR__ ) ) ;
24
$main_lang =  '_' . strtoupper( $moduleDirName ) ;
25
26
/**
27
 * Xoops Header
28
 */
29
include dirname(dirname(__DIR__)) . '/mainfile.php';
30
include_once XOOPS_ROOT_PATH . '/header.php';
31
include_once XOOPS_ROOT_PATH . '/class/criteria.php';
32
33
/**
34
 * Include modules classes
35
 */
36
include_once __DIR__ . '/class/pictures.php';
37
38
/**
39
 * Check if using XoopsCube (by jlm69)
40
 * Needed because of a difference in the way Xoops and XoopsCube handle tokens
41
 */
42
43
$xCube=false;
44
if (preg_match("/^XOOPS Cube/",XOOPS_VERSION)) { // XOOPS Cube 2.1x
45
$xCube=true;
46
}
47
48
/**
49
 * Verify Ticket for Xoops Cube (by jlm69)
50
 * If your site is XoopsCube it uses $xoopsGTicket for the token.
51
52
 */
53
54 View Code Duplication
if ($xCube) {
55
if ( ! $xoopsGTicket->check( true , 'token' ) ) {
56
        redirect_header($_SERVER['HTTP_REFERER'],3,$xoopsGTicket->getErrors());
57
    }
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
/**
71
 * Receiving info from get parameters
72
 */
73
$cod_img = $_POST['cod_img'];
74
//$lid = $_POST['lid'];
0 ignored issues
show
Unused Code Comprehensibility introduced by
64% 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...
75
//$marker = $_POST['marker'];
76
$marker = isset( $_POST['marker'] ) ? $_POST['marker'] : '' ;
77
78
if ($marker==1) {
79
/**
80
 * Creating the factory  loading the picture changing its caption
81
 */
82
$picture_factory = new Xoopsjlm_picturesHandler ($xoopsDB);
83
$picture = $picture_factory->create(false);
84
$picture->load($_POST['cod_img']);
85
$picture->setVar("title",$_POST['caption']);
86
87
/**
88
 * Verifying who's the owner to allow changes
89
 */
90
$uid = $xoopsUser->getVar('uid');
91
$lid = $picture->getVar('lid');
92
if ($uid == $picture->getVar('uid_owner')) {
93
           if ($picture_factory->insert($picture)) {
94
                     redirect_header("view_photos.php?lid=".$lid."&uid=".$uid."", 2, constant("_ADSLIGHT_DESC_EDITED"));
95 View Code Duplication
              } else {
96
                     redirect_header("view_photos.php?lid=".$lid."&uid=".$uid."", 2, constant("_ADSLIGHT_NOCACHACA"));
97
              }
98
    }
99
}
100
101
/**
102
 * Creating the factory  and the criteria to edit the desc of the picture
103
 * The user must be the owner
104
 */
105
$album_factory      = new Xoopsjlm_picturesHandler($xoopsDB);
106
$criteria_img = new Criteria ('cod_img',$cod_img);
107
$uid = $xoopsUser->getVar('uid');
108
$criteria_uid = new Criteria ('uid_owner',$uid);
109
$criteria = new CriteriaCompo ($criteria_img);
110
$criteria->add($criteria_uid);
111
112
/**
113
 * Lets fetch the info of the pictures to be able to render the form
114
 * The user must be the owner
115
 */
116
if ($array_pict = $album_factory->getObjects($criteria)) {
117
        $caption = $array_pict[0]->getVar("title");
118
        $url = $array_pict[0]->getVar("url");
119
}
120
$url = $xoopsModuleConfig['adslight_link_upload']."/thumbs/thumb_".$url;
121
$album_factory->renderFormEdit($caption,$cod_img,$url);
122
123
/**
124
 * Close page
125
 */
126
include XOOPS_ROOT_PATH . '/footer.php';
127