Code Duplication    Length = 37-37 lines in 2 locations

class/Admin.php 1 location

@@ 292-328 (lines=37) @@
289
     * Variable $version = current smallworld version number
290
     * @return string
291
     */
292
    public function doCheckUpdate()
293
    {
294
        global $pathIcon16;
295
        $version  = $this->ModuleInstallVersion();
296
        $critical = false;
297
        $update   = false;
298
        $rt       = '';
299
        $url      = 'http://www.culex.dk/updates/smallworld_version.csv';
300
        $fileC    = $this->fetchURL($url, ['fopen', 'curl', 'socket']);
301
        $read     = explode(';', $fileC);
302
303
        $upd_img = $pathIcon16 . '/on.png';
304
305
        if ($read[0] > $version && '1' == $read[2]) {
306
            $critical = true;
307
            $upd_img  = $pathIcon16 . '/off.png';
308
        }
309
        if ($read[0] > $version && '1' != $read[2]) {
310
            $update  = true;
311
            $upd_img = '../assets/images/upd_normal.png';
312
        }
313
        if ($critical) {
314
            $rt = "<div class='smallworld_update'><img src='" . $upd_img . "'>";
315
            $rt .= _AM_SMALLWORLD_UPDATE_CRITICAL_UPD . '</div>';
316
            $rt .= "<textarea class='xim_update_changelog'>" . $read[1] . '</textarea><br><br>';
317
            $rt .= _AM_SMALLWORLD_UPDATE_SERVER_FILE . "<br><a href='" . $read[3] . "'>" . $read[3] . '</a>';
318
        } elseif ($update) {
319
            $rt = "<div class='smallworld_update'><img src='" . $upd_img . "'>";
320
            $rt .= _AM_SMALLWORLD_UPDATE_NORMAL_UPD . '</div>';
321
            $rt .= "<textarea class='smallworld_update_changelog'>" . $read[1] . '</textarea><br><br>';
322
            $rt .= _AM_SMALLWORLD_UPDATE_SERVER_FILE . "<br><a href='" . $read[3] . "'>" . $read[3] . '</a>';
323
        } else {
324
            $rt = "<div class='smallworld_update'><br><img src='" . $upd_img . "'>" . _AM_SMALLWORLD_UPDATE_YOUHAVENEWESTVERSION . '</div>';
325
        }
326
327
        return $rt;
328
    }
329
330
    /**
331
     * Fetch content of comma separated text file

class/SmallworldAdmin.php 1 location

@@ 291-327 (lines=37) @@
288
     * Variable $version = current smallworld version number
289
     * @return string
290
     */
291
    public function doCheckUpdate()
292
    {
293
        global $pathIcon16;
294
        $version = $this->ModuleInstallVersion();
295
        $critical = false;
296
        $update = false;
297
        $rt = '';
298
        $url = 'http://www.culex.dk/updates/smallworld_version.csv';
299
        $fileC = $this->fetchURL($url, ['fopen', 'curl', 'socket']);
300
        $read = explode(';', $fileC);
301
302
        $upd_img = $pathIcon16 . '/on.png';
303
304
        if ($read[0] > $version && '1' == $read[2]) {
305
            $critical = true;
306
            $upd_img = $pathIcon16 . '/off.png';
307
        }
308
        if ($read[0] > $version && '1' != $read[2]) {
309
            $update = true;
310
            $upd_img = '../assets/images/upd_normal.png';
311
        }
312
        if ($critical) {
313
            $rt = "<div class='smallworld_update'><img src='" . $upd_img . "'>";
314
            $rt .= _AM_SMALLWORLD_UPDATE_CRITICAL_UPD . '</div>';
315
            $rt .= "<textarea class='xim_update_changelog'>" . $read[1] . '</textarea><br><br>';
316
            $rt .= _AM_SMALLWORLD_UPDATE_SERVER_FILE . "<br><a href='" . $read[3] . "'>" . $read[3] . '</a>';
317
        } elseif ($update) {
318
            $rt = "<div class='smallworld_update'><img src='" . $upd_img . "'>";
319
            $rt .= _AM_SMALLWORLD_UPDATE_NORMAL_UPD . '</div>';
320
            $rt .= "<textarea class='smallworld_update_changelog'>" . $read[1] . '</textarea><br><br>';
321
            $rt .= _AM_SMALLWORLD_UPDATE_SERVER_FILE . "<br><a href='" . $read[3] . "'>" . $read[3] . '</a>';
322
        } else {
323
            $rt = "<div class='smallworld_update'><br><img src='" . $upd_img . "'>" . _AM_SMALLWORLD_UPDATE_YOUHAVENEWESTVERSION . '</div>';
324
        }
325
326
        return $rt;
327
    }
328
329
    /**
330
     * Fetch content of comma separated text file