Example #1
0
 function initialise()
 {
     global $table_prefix;
     $me = new ReflectionObject($this);
     $plugin_initialised = getConfig(md5('plugin-' . $me->getName() . '-initialised'));
     if (empty($plugin_initialised)) {
         foreach ($this->DBstruct as $table => $structure) {
             if (!Sql_Table_exists($table_prefix . $me->getName() . '_' . $table)) {
                 #  print s('Creating table').' '.$table . '<br/>';
                 Sql_Create_Table($table_prefix . $me->getName() . '_' . $table, $structure);
             }
         }
         saveConfig(md5('plugin-' . $me->getName() . '-initialised'), time(), 0);
     }
 }
Example #2
0
             Sql_Query("alter table {$tables["usermessage"]} add index enteredindex (entered)");
             Sql_Create_Table($tables["urlcache"], $DBstruct["urlcache"]);
         }
         if ($minor < 9 || $minor == 9 && $sub <= 4) {
             Sql_Create_Table($tables["linktrack"], $DBstruct["linktrack"]);
             Sql_Create_Table($tables["linktrack_userclick"], $DBstruct["linktrack_userclick"]);
             SaveConfig("xormask", md5(uniqid(rand(), true)), 0);
         }
         if ($minor < 9 || $minor == 9 && $sub < 5) {
             Sql_Create_Table($tables["user_message_forward"], $DBstruct["user_message_forward"]);
             Sql_Query("alter table {$tables["user_attribute"]} add index userattid (attributeid,userid)");
             Sql_Query("alter table {$tables["user_attribute"]} add index attuserid (userid,attributeid)");
             Sql_Query("alter table {$tables["message"]} change column status status varchar(255)");
             Sql_Create_Table($tables["userstats"], $DBstruct["userstats"]);
             Sql_Create_Table($tables["bounceregex"], $DBstruct["bounceregex"]);
             Sql_Create_Table($tables["bounceregex_bounce"], $DBstruct["bounceregex_bounce"]);
         }
         break;
 }
 # fix the new powered by image for the templates
 Sql_Query(sprintf('update %s set data = "%s",width=70,height=30 where filename = "powerphplist.png"', $tables["templateimage"], $newpoweredimage));
 print '<script language="Javascript" type="text/javascript"> finish(); </script>';
 # update the system pages
 while (list($type, $pages) = each($system_pages)) {
     foreach ($pages as $page) {
         Sql_Query(sprintf('replace into %s (page,type) values("%s","%s")', $tables["task"], $page, $type));
     }
 }
 # mark the database to be our current version
 if ($success) {
     SaveConfig("version", VERSION, 0);
Example #3
0
 function initialise()
 {
     global $config;
     foreach ($this->DBstructure as $table => $val) {
         if (!Sql_Table_exists($table)) {
             #    print "creating $table <br>\n";
             Sql_Create_Table($this->tables[$table], $this->DBstructure[$table]);
         }
     }
 }
Example #4
0
 	Sql_Create_Table($tables["attachment"],$DBstruct["attachment"]);
 	Sql_Create_Table($tables["rssitem"],$DBstruct["rssitem"]);
 	Sql_Create_Table($tables["rssitem_data"],$DBstruct["rssitem_data"]);
 	Sql_Create_Table($tables["user_rss"],$DBstruct["user_rss"]);
 	Sql_Create_Table($tables["rssitem_user"],$DBstruct["rssitem_user"]);
 case "2.2.0":
 case "2.2.1":
 	Sql_Query("alter table {$tables["user"]} add column password varchar(255)");
 	Sql_Query("alter table {$tables["user"]} add column passwordchanged datetime");
 	Sql_Query("alter table {$tables["user"]} add column disabled tinyint default 0");
 	Sql_Query("alter table {$tables["user"]} add column extradata text");
 	Sql_Query("alter table {$tables["message"]} add column owner integer");
 case "2.3.0":
 case "2.3.1":
 case "2.3.2":case "2.3.3":
 	Sql_Create_Table($tables["listrss"],$DBstruct["listrss"]);
 case "2.3.4":case "2.4.0":
   Sql_Query("insert into {$tables["task"]} (page,type) values(\"import3\",\"user\")");
   Sql_Query("insert into {$tables["task"]} (page,type) values(\"import4\",\"user\")");
 case "2.5.0":case "2.5.1":
 case "2.5.2":
   Sql_Query("alter table {$tables["subscribepage"]} add column owner integer");
   Sql_Query("alter ignore table {$tables["task"]} add unique (page)");
 case "2.5.3":case "2.5.4":
   Sql_Query("alter table {$tables["user"]} add column foreignkey varchar(100)");
   Sql_Query("alter table {$tables["user"]} add index fkey (foreignkey)");
 case "2.5.5": case "2.5.6": case "2.5.7": case "2.5.8":
   # some very odd value managed to sneak in
   $cbgroups = Sql_Query("select id from {$tables["attribute"]} where type = \"checkboxgroup\"");
   while ($row = Sql_Fetch_Row($cbgroups)) {
     Sql_Query("update {$tables["user_attribute"]} set value = \"\" where attributeid = $row[0] and value=\"Empty\"");
Example #5
0
{
    for ($i = 0; $i < 10000; ++$i) {
        print " \n";
    }
    flush();
}
include dirname(__FILE__) . '/structure.php';
set_time_limit(60000);
if (!Sql_Table_exists($GLOBALS['tables']['linktrack_forward']) || !Sql_Table_exists($GLOBALS['tables']['linktrack_ml']) || !Sql_Table_exists($GLOBALS['tables']['linktrack_uml_click'])) {
    output('creating tables');
    Sql_Query('drop table ' . $GLOBALS['tables']['linktrack_forward']);
    Sql_Query('drop table ' . $GLOBALS['tables']['linktrack_ml']);
    Sql_Query('drop table ' . $GLOBALS['tables']['linktrack_uml_click']);
    Sql_Create_Table($GLOBALS['tables']['linktrack_ml'], $DBstruct['linktrack_ml']);
    Sql_Create_Table($GLOBALS['tables']['linktrack_forward'], $DBstruct['linktrack_forward']);
    Sql_Create_Table($GLOBALS['tables']['linktrack_uml_click'], $DBstruct['linktrack_uml_click']);
    output(s('creating tables done'));
}
$process_id = getPageLock();
if (empty($process_id)) {
    return;
}
## only convert up to a week ago.
$lastweek = date('Y-m-d', time() - 24 * 7 * 3600);
cl_output(sprintf('select count(*) from %s lt, %s m where lt.messageid = m.id and m.entered < "%s"', $GLOBALS['tables']['linktrack'], $GLOBALS['tables']['message'], $lastweek));
$num = Sql_Fetch_Row_Query(sprintf('select count(*) from %s lt, %s m where lt.messageid = m.id and m.entered < "%s"', $GLOBALS['tables']['linktrack'], $GLOBALS['tables']['message'], $lastweek));
output(s('%d entries still to convert', $num[0]) . '<br/>');
$c = 0;
$req = Sql_Query(sprintf('select lt.* from %s lt, %s m where lt.messageid = m.id and m.entered < "%s" limit %d', $GLOBALS['tables']['linktrack'], $GLOBALS['tables']['message'], $lastweek, $limit));
$total = Sql_Affected_Rows();
if ($total) {
Example #6
0
             Sql_Create_Table($tables['linktrack_forward'], $DBstruct['linktrack_forward']);
             Sql_Create_Table($tables['linktrack_ml'], $DBstruct['linktrack_ml']);
             Sql_Create_Table($tables['linktrack_uml_click'], $DBstruct['linktrack_uml_click']);
         }
         if ($minor < 11 || $minor == 11 && $sub < 3) {
             Sql_Query(sprintf('alter table %s add column optedin tinyint default 0', $tables['user']));
         }
         if ($minor < 11 || $minor == 11 && $sub < 5) {
             Sql_Query(sprintf('alter table %s add column category varchar(255) default ""', $tables['list']));
             Sql_Query(sprintf('alter table %s add column requeueinterval integer default 0', $tables['message']));
             Sql_Query(sprintf('alter table %s add column requeueuntil datetime', $tables['message']));
         }
         if ($minor < 11 || $minor == 11 && $sub < 7) {
             Sql_Create_Table($tables['admin_password_request'], $DBstruct['admin_password_request'], 1);
             Sql_Create_Table($tables['admintoken'], $DBstruct['admintoken'], 1);
             Sql_Create_Table($tables['i18n'], $DBstruct['i18n'], 1);
             unset($_SESSION['hasI18Ntable']);
             $req = Sql_Query(sprintf('select loginname,password from %s where length(password) < %d', $GLOBALS['tables']['admin'], $GLOBALS['hash_length']));
             while ($row = Sql_Fetch_Assoc($req)) {
                 $encryptedPassDB = hash(ENCRYPTION_ALGO, $row['password']);
                 $query = sprintf('update %s set password = "******" where loginname = "%s"', $GLOBALS['tables']['admin'], $encryptedPassDB, $row['loginname']);
                 Sql_Query($query);
             }
         }
         break;
 }
 ## add index on bounces, but ignore the error
 Sql_Query("create index statusindex on {$tables['user_attribute']} (status(10))", 1);
 Sql_Query("create index message_lookup using btree on {$tables['user_message_bounce']} (message)", 1);
 ## add index to i18n to avoid duplicate translations
 ## alter ignore doesn't seem to work on InnoDB: http://bugs.mysql.com/bug.php?id=40344
Example #7
0
if (empty($GLOBALS["SessionTableName"])) {
    return;
}
# only necessary on main pages, not in lt/dl etc
if (basename($_SERVER['SCRIPT_NAME']) != 'index.php') {
    return;
}
@ini_set("session.save_handler", "user");
$SessionTableName = $GLOBALS["SessionTableName"];
if (ini_get("session.save_handler") == "user") {
    session_set_save_handler('mysql_session_open', 'mysql_session_close', 'mysql_session_read', 'mysql_session_write', 'mysql_session_destroy', 'mysql_session_gc');
} else {
    #  @ini_set("session.save_handler","files");
}
if (!Sql_Table_exists($GLOBALS["SessionTableName"])) {
    Sql_Create_Table($GLOBALS["SessionTableName"], array("sessionid" => array("CHAR(32) NOT NULL PRIMARY KEY", ""), "lastactive" => array("INTEGER NOT NULL", ""), "data" => array("LONGTEXT", "")));
}
function mysql_session_open($save_path, $session_name)
{
    return true;
}
function mysql_session_close()
{
    return true;
}
function mysql_session_read($SessionID)
{
    #	dbg("Reading session info for $SessionID");
    $SessionTableName = $GLOBALS["SessionTableName"];
    $SessionID = addslashes($SessionID);
    $session_data_req = sql_query("SELECT data FROM {$SessionTableName} WHERE sessionid = '{$SessionID}'");
Example #8
0
             Sql_Create_Table($tables["linktrack_forward"], $DBstruct["linktrack_forward"]);
             Sql_Create_Table($tables["linktrack_ml"], $DBstruct["linktrack_ml"]);
             Sql_Create_Table($tables["linktrack_uml_click"], $DBstruct["linktrack_uml_click"]);
         }
         if ($minor < 11 || $minor == 11 && $sub < 3) {
             Sql_Query(sprintf('alter table %s add column optedin tinyint default 0', $tables['user']));
         }
         if ($minor < 11 || $minor == 11 && $sub < 5) {
             Sql_Query(sprintf('alter table %s add column category varchar(255) default ""', $tables['list']));
             Sql_Query(sprintf('alter table %s add column requeueinterval integer default 0', $tables['message']));
             Sql_Query(sprintf('alter table %s add column requeueuntil datetime', $tables['message']));
         }
         if ($minor < 11 || $minor == 11 && $sub < 7) {
             Sql_Create_Table($tables["admin_password_request"], $DBstruct["admin_password_request"], 1);
             Sql_Create_Table($tables["admintoken"], $DBstruct["admintoken"], 1);
             Sql_Create_Table($tables["i18n"], $DBstruct["i18n"], 1);
             unset($_SESSION['hasI18Ntable']);
             $req = Sql_Query(sprintf('select loginname,password from %s where length(password) < %d', $GLOBALS['tables']['admin'], $GLOBALS['hash_length']));
             while ($row = Sql_Fetch_Assoc($req)) {
                 $encryptedPassDB = hash(ENCRYPTION_ALGO, $row['password']);
                 $query = "update %s set password = '******' where loginname = ?";
                 $query = sprintf($query, $GLOBALS['tables']['admin'], $encryptedPassDB);
                 Sql_Query_Params($query, array($row['loginname']));
             }
             #        Sql_Create_Table($tables["gchartcache"],$DBstruct["gchartcache"],1); ## really need this?
         }
         break;
 }
 ## add index on bounces, but ignore the error
 Sql_Query("create index statusindex on {$tables["user_attribute"]} (status(10))", 1);
 Sql_Query("create index message_lookup using btree on {$tables["user_message_bounce"]} (message)", 1);
Example #9
0
<?php

require_once dirname(__FILE__) . '/accesscheck.php';
## fetch updated translation
#var_dump($LANGUAGES);
if (!Sql_Table_exists($GLOBALS['tables']['i18n'])) {
    include dirname(__FILE__) . '/structure.php';
    Sql_Create_Table($GLOBALS['tables']['i18n'], $DBstruct['i18n']);
}
if (isset($_GET['lan'])) {
    ## Non-JS version
    include 'actions/updatetranslation.php';
}
$force = !empty($_GET['force']);
$LU = getTranslationUpdates();
if (!$LU || !is_object($LU)) {
    print Error(s('Unable to fetch list of languages, please check your network or try again later'));
    return;
}
#var_dump($LU);
print '<ul>';
foreach ($LU->translation as $lan) {
    #  var_dump($lan);
    $lastupdated = getConfig('lastlanguageupdate-' . $lan->iso);
    if (!empty($LANGUAGES[(string) $lan->iso])) {
        $lan_name = $LANGUAGES[(string) $lan->iso][0];
    } else {
        $lan_name = $lan->name;
    }
    if ($force || $lan->iso == $_SESSION['adminlanguage']['iso'] && $lan->lastmodified > $lastupdated) {
        $updateLink = pageLinkAjax('updatetranslation&lan=' . $lan->iso, $lan_name);
               Sql_Create_Table($tables["user_message_forward"], $DBstruct["user_message_forward"]);
               Sql_Query("alter table {$tables["user_attribute"]} add index userattid (attributeid,userid)");
               Sql_Query("alter table {$tables["user_attribute"]} add index attuserid (userid,attributeid)");
               Sql_Query("alter table {$tables["message"]} change column status status varchar(255)");
               Sql_Create_Table($tables["userstats"], $DBstruct["userstats"]);
               Sql_Create_Table($tables["bounceregex"], $DBstruct["bounceregex"]);
               Sql_Create_Table($tables["bounceregex_bounce"], $DBstruct["bounceregex_bounce"]);
           }
           if ($minor < 10 || $minor == 10 && $sub < 13) {
               Sql_Create_Table($tables["admintoken"], $DBstruct["admintoken"]);
           }
           break;
   }
   ## make sure the token table exists
   if (!Sql_Table_exists($tables["admintoken"], 1)) {
       Sql_Create_Table($tables["admintoken"], $DBstruct["admintoken"]);
   }
   ## add index on bounces, but ignore the error
   Sql_Query("create index statusindex on {$tables["user_attribute"]} (status(10))", 1);
   Sql_Query("create index message_lookup using btree on {$tables["user_message_bounce"]} (message)", 1);
   ## mantis issue 9001, make sure that the "repeat" column in the messages table is renamed to repeatinterval
   # to avoid a name clash with Mysql 5.
   # problem is that this statement will fail if the DB is already running Mysql 5
   if (Sql_Table_Column_Exists($GLOBALS['tables']['message'], 'repeat')) {
       Sql_Query(sprintf('alter ignore table %s change column repeat repeatinterval integer default 0', $GLOBALS['tables']['message']));
   }
   # check whether it worked and otherwise throw an error to say it needs to be done manually
   if (Sql_Table_Column_Exists($GLOBALS['tables']['message'], 'repeat')) {
       print 'Error, unable to rename column "repeat" in the table ' . $GLOBALS['tables']['message'] . ' to be "repeatinterval"<br/>
 Please do this manually, refer to http://mantis.phplist.com/view.php?id=9001 for more information';
   }
Example #11
0
if (empty($GLOBALS['SessionTableName'])) {
    return;
}
# only necessary on main pages, not in lt/dl etc
if (basename($_SERVER['SCRIPT_NAME']) != 'index.php') {
    return;
}
@ini_set('session.save_handler', 'user');
$SessionTableName = $GLOBALS['SessionTableName'];
if (ini_get('session.save_handler') == 'user') {
    session_set_save_handler('mysql_session_open', 'mysql_session_close', 'mysql_session_read', 'mysql_session_write', 'mysql_session_destroy', 'mysql_session_gc');
} else {
    #  @ini_set("session.save_handler","files");
}
if (!Sql_Table_exists($GLOBALS['SessionTableName'])) {
    Sql_Create_Table($GLOBALS['SessionTableName'], array('sessionid' => array('CHAR(32) NOT NULL PRIMARY KEY', ''), 'lastactive' => array('INTEGER NOT NULL', ''), 'data' => array('LONGTEXT', '')));
}
function mysql_session_open($save_path, $session_name)
{
    return true;
}
function mysql_session_close()
{
    return true;
}
function mysql_session_read($SessionID)
{
    #	dbg("Reading session info for $SessionID");
    $SessionTableName = $GLOBALS['SessionTableName'];
    $SessionID = addslashes($SessionID);
    $session_data_req = sql_query("SELECT data FROM {$SessionTableName} WHERE sessionid = '{$SessionID}'");