Completed
Pull Request — master (#4)
by Michael
02:17
created

include/installscript.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
/* Donations - Paypal financial management module for Xoops 2           */
4
/* Copyright (c) 2016 XOOPS Project                                     */
5
/* http://dev.xoops.org/modules/xfmod/project/?group_id=1060            */
6
/* 
7
/************************************************************************/
8
/*                                                                      */
9
/* Based on NukeTreasury for PHP-Nuke - by Dave Lawrence AKA Thrash     */
10
/* NukeTreasury - Financial management for PHP-Nuke                     */
11
/* Copyright (c) 2004 by Dave Lawrence AKA Thrash                       */
12
/*                       [email protected]                         */
13
/*                       [email protected]                          */
14
/*                                                                      */
15
/************************************************************************/
16
/*                                                                      */
17
/* This program is free software; you can redistribute it and/or modify */
18
/* it under the terms of the GNU General Public License as published by */
19
/* the Free Software Foundation; either version 2 of the License.       */
20
/*                                                                      */
21
/* This program is distributed in the hope that it will be useful, but  */
22
/* WITHOUT ANY WARRANTY; without even the implied warranty of           */
23
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU     */
24
/* General Public License for more details.                             */
25
/*                                                                      */
26
/* You should have received a copy of the GNU General Public License    */
27
/* along with this program; if not, write to the Free Software          */
28
/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  */
29
/* USA                                                                  */
30
/************************************************************************/
31
include_once XOOPS_ROOT_PATH . '/include/cp_functions.php';
32
33
$moduleDirName = basename(dirname(__DIR__));
34
global $xoopsConfig, $xoopsUser;
35
36
/*
37
38
echo "<hr>language: {$xoopsConfig['language']}<hr>";
39
40
$n = '_AD_DON_z_test';  if (defined($n)) {echo $n . " = " . constant($n)."<br>";} else {echo $n . " = ?<br>";}
41
$n = '_MD_DON_z_test';  if (defined($n)) {echo $n . " = " . constant($n)."<br>";} else {echo $n . " = ?<br>";}
42
$n = '_MI_DON_z_test';  if (defined($n)) {echo $n . " = " . constant($n)."<br>";} else {echo $n . " = ?<br>";}
43
$n = '_MB_DON_z_test';  if (defined($n)) {echo $n . " = " . constant($n)."<br>";} else {echo $n . " = ?<br>";}
44
*/
45
46
xoops_loadLanguage('main', $moduleDirName);
47
48
/**
49
 * @param XoopsObject|null $module
50
 * @return bool
51
 */
52
function xoops_module_install_xyp_base($module=null)
53
{
54
    global $xoopsDB, $xoopsUser;
55
    $moduleDirName = basename(dirname(__DIR__));
56
57
    //----------------------------------------------------------------
58
    //patch JJD pour francisation ou autre langue
59
    //----------------------------------------------------------------
60
    update_lg();
61
    //----------------------------------------------------------------
62
63
    $sql1 = 'UPDATE ' . $xoopsDB->prefix('donations_config') . ' SET `value` = "' . XOOPS_URL . '/modules/' . $moduleDirName . '/success.php" WHERE `name` = "ty_url"';
64
    $sql2 = 'UPDATE ' . $xoopsDB->prefix('donations_config') . ' SET `value` = "' . XOOPS_URL . '/modules/' . $moduleDirName . '/cancel.php" WHERE `name` = "pp_cancel_url"';
65
66
    $retVal = false;
67
    if ($xoopsUser && $xoopsDB->query($sql1) && $xoopsDB->query($sql2)) {
68
            $retVal = true;
69
    }
70
71
    return $retVal;
72
}
73
74
/************************************************************************
75
 *
76
 ************************************************************************/
77
function update_lg()
78
{
79
    global $xoopsDB;
80
81
    //    $moduleDirName = basename ( dirname( __DIR__ ) ) ;
0 ignored issues
show
Unused Code Comprehensibility introduced by
37% 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...
82
83
    if (defined('_AD_DON_DONATIONS')) {
84
        $prefixV = '_AD_DON_V_';
85
        $prefixT = '_AD_DON_T_';
86
    } else {
87
        $prefixV = '_MI_DON_V_';
88
        $prefixT = '_MI_DON_T_';
89
    }
90
91
    $lstName = 'receiver_email_;paypal_url_array;use_goal_array;' . 'week_goal_1st;week_goal_2nd;week_goal_3rd;week_goal_4th;' . 'month_goal_Jan;month_goal_Feb;month_goal_Mar;month_goal_Apr;' . 'month_goal_May;month_goal_Jun;month_goal_Jul;' . 'month_goal_Aug;month_goal_Sep;month_goal_Oct;' . 'month_goal_Nov;month_goal_Dec;quarter_goal_1st;quarter_goal_2nd;' . 'quarter_goal_3rd;quarter_goal_4th;swing_day_;ty_url_;' . 'pp_itemname_;don_button_submit_;don_button_top_;pp_image_url_;' . 'pp_cancel_url_;pp_get_addr_;pp_curr_code_array;don_amount_1;' . 'don_amount_2;don_amount_3;don_amount_4;don_amount_5;' . 'don_amount_6;don_amount_7;don_amt_checked_;pp_item_num_;' . 'don_top_img_width_;don_top_img_height_;don_sub_img_width_;' . 'don_sub_img_height_;don_text_rawtext;don_name_prompt_;' . 'don_name_yes_;don_name_no_;don_forceadd_;ipn_dbg_lvl_;ipn_log_entries_;' . 'assign_group_;assign_rank_';
92
93
    $table = $xoopsDB->prefix('donations_config');
94
    $sql0  = "INSERT INTO `{$table}` (`name`, `subtype`, `value`, `text`) " . "VALUES ('%1\$s', '%2\$s', '%3\$s', '%4\$s')";
95
96
    $sql = "DELETE FROM {$table}";
97
    $xoopsDB->queryF($sql);
98
    //echo "{$sql}<br>";
99
    $t = explode(';', $lstName);
100
101
    for ($h = 0, $hMax = count($t); $h < $hMax; ++$h) {
102
        //echo "<hr>{$t[$h]}<br>";
103
        $tc = explode('_', $t[$h]);
104
        //echo "<hr>{$t[$h]}-".count($tc)."-".count($tn)."<br>";
105
106
        //$tc = array_shift($tc);
107
        $subType = $tc[count($tc) - 1];
108
109
        $cstV = $prefixV . $t[$h];
110
        $cstT = $prefixT . $t[$h];
111
112
        //$tc = array_shift($tc);
113
        $tn   = array_pop($tc);
114
        $tn   = $tc;
115
        $name = implode('_', $tn);
116
        //echo "{$t[$h]}-".count($tc)."-".count($tn)."-{$tc[0]}-{$tn[0]}-{$name}<br>";
117
118
        $value = constant($cstV);
119
        $text  = constant($cstT);
120
        $text  = str_replace("'", "\'", $text);
121
        $text  = html_entity_decode($text);
122
        $text  = str_replace('<br>', "\r\n", $text);
123
        $text  = str_replace('<br />', "\r\n", $text);
124
125
        $sql = sprintf($sql0, $name, $subType, $value, $text);
126
        //        echo "{$sql}<br>";
127
        $xoopsDB->queryF($sql);
128
    }
129
}
130
131
eval('function xoops_module_install_' . $moduleDirName . '(&$module=NULL)
132
        {
133
        return xoops_module_install_xyp_base($module);
134
        }
135
    ');
136
137
/************************************************************************
138
 *
139
 * http://localhost/xoops2018a/modules/xdonations/include/installscript.php?op=update_lg
140
 * http://localhost/xoops2018a/modules/xdonations/include/installscript.php?op=update_lg
141
 * https://www.paypal.com/fr_FR/FR/i/btn/btn_donate_LG.gif
142
 ************************************************************************/
143
144
$op = isset($_GET['op']) ? $_GET['op'] : '';
145
146
switch ($op) {
147
    case 'update_lg':
148
        update_lg();
149
        break;
150
    default:
151
        break;
152
}
153