Skip to content

Instantly share code, notes, and snippets.

@geekwright
geekwright / scheme-301.php
Last active April 24, 2017 00:51
This code fragment is intended to be added into a XOOPS installation's mainfile.php. If the invoking URL does not match the scheme declared in XOOPS_URL (i.e. "https",) it will force a 301 redirect to the matching URL with the declared scheme.
<?php
// add these lines to mainfile.php directly below the line "define('XOOPS_URL', ...);"
$checkScheme = function () {
$s = $_SERVER;
$parsed = parse_url(XOOPS_URL);
$targetScheme = $parsed['scheme'];
$currentScheme = (!empty($s['HTTPS']) && $s['HTTPS'] !== 'off') ? 'https' : 'http';
if (0 !== strcmp($targetScheme, $currentScheme)) {
$host = $parsed['host'];
$port = isset($parsed['port']) ? ':' . $parsed['port'] : '';
@geekwright
geekwright / import_users.php
Created March 2, 2017 21:58
Quick and dirty XOOPS user import from csv file
<?php
/**
* modified from script by christian@frxoops.org
* Import users from a csv file into xoops 2.5.8
*
* Put this file and your users.cvs file in the root of your site
* go to http://yoursite/import_users.php in your browser
* click the button to rn the import
*
* Don't forget to DELETE it after you run it!
@geekwright
geekwright / emergency_update.php
Created January 13, 2015 22:05
Very short program to update the system module in XOOPS 2.6.0 in case of emergency
<?php
include __DIR__ . '/mainfile.php';
$xoops = Xoops::getInstance();
XoopsLoad::load('module', 'system');
$sysmod = new SystemModule();
$result = $sysmod->update('system');