Exemple #1
0
        POD::execute($query);
    }
    $result = true;
    foreach ($plugintables as $dbname) {
        $query = "DROP TABLE {$dbname}";
        $result = POD::execute($query) && $result;
    }
    deactivatePlugin($pluginname);
    if ($result == false) {
        Respond::ResultPage(1);
        exit;
    }
} else {
    // type 2, table
    $dbname = $_REQUEST['name'];
    if (strncmp($dbname, $database['prefix'], strlen($database['prefix'])) != 0) {
        Respond::ResultPage(1);
        exit;
    }
    if (in_array($dbname, $definedTables)) {
        Respond::ResultPage(1);
        exit;
    }
    if (!doesExistTable($dbname)) {
        Respond::ResultPage(1);
        exit;
    }
    $query = "DROP TABLE {$dbname}";
    POD::execute($query);
}
Respond::ResultPage(0);
Exemple #2
0
function getPluginTableName()
{
    importlib('model.common.setting');
    $context = Model_Context::getInstance();
    $likeEscape = array('/_/', '/%/');
    $likeReplace = array('\\_', '\\%');
    $escapename = preg_replace($likeEscape, $likeReplace, $context->getProperty('database.prefix'));
    $dbtables = POD::tableList($escapename);
    $dbCaseInsensitive = Setting::getServiceSetting('lowercaseTableNames', true);
    if ($dbCaseInsensitive === null) {
        doesExistTable('');
        // determine the table name rule. (lowercase only / mixed cases)
    }
    $definedTables = getDefinedTableNames();
    $dbtables = array_values(array_diff($dbtables, $definedTables));
    if ($dbCaseInsensitive == 1) {
        $tempTables = $definedTables;
        $definedTables = array();
        foreach ($tempTables as $table) {
            $table = strtolower($table);
            array_push($definedTables, $table);
        }
        $tempTables = $dbtables;
        $dbtables = array();
        foreach ($tempTables as $table) {
            $table = strtolower($table);
            array_push($dbtables, $table);
        }
        $dbtables = array_values(array_diff($dbtables, $definedTables));
    }
    return $dbtables;
}
Exemple #3
0
function treatPluginTable($plugin, $name, $fields, $keys, $version)
{
    $context = Model_Context::getInstance();
    //	global $context;
    if (doesExistTable($context->getProperty('database.prefix') . $name)) {
        $keyname = 'Database_' . $name;
        $value = $plugin;
        $result = Setting::getServiceSetting($keyname, null, true);
        if (is_null($result)) {
            $keyname = Utils_Unicode::lessenAsEncoding($keyname, 32);
            $value = Utils_Unicode::lessenAsEncoding($plugin . '/' . $version, 255);
            $query = DBModel::getInstance();
            $query->reset('ServiceSettings');
            $query->setAttribute('name', $keyname, true);
            $query->setAttribute('value', $value, true);
            $query->insert();
        } else {
            $keyname = Utils_Unicode::lessenAsEncoding($keyname, 32);
            $value = Utils_Unicode::lessenAsEncoding($plugin . '/' . $version, 255);
            $values = explode('/', $result, 2);
            if (strcmp($plugin, $values[0]) != 0) {
                // diff plugin
                return false;
                // nothing can be done
            } else {
                if (strcmp($version, $values[1]) != 0) {
                    $query = DBModel::getInstance();
                    $query->reset('ServiceSettings');
                    $query->setQualifier('name', 'equals', $keyname, true);
                    $query->setAttribute('value', $value, true);
                    $query->update();
                    $eventName = 'UpdateDB_' . $name;
                    fireEvent($eventName, $values[1]);
                }
            }
        }
        return true;
    } else {
        $query = "CREATE TABLE " . $context->getProperty('database.prefix') . $name . " (blogid int(11) NOT NULL default 0,";
        $isaiExists = false;
        $index = '';
        foreach ($fields as $field) {
            $ai = '';
            if (strtolower($field['attribute']) == 'int' || strtolower($field['attribute']) == 'mediumint') {
                if ($field['autoincrement'] == 1 && !$isaiExists) {
                    $ai = ' AUTO_INCREMENT ';
                    $isaiExists = true;
                    if (!in_array($field['name'], $keys)) {
                        $index = ", KEY({$field['name']})";
                    }
                }
            }
            $isNull = $field['isnull'] == 0 ? ' NOT NULL ' : ' NULL ';
            $defaultValue = is_null($field['default']) ? '' : " DEFAULT '" . POD::escapeString($field['default']) . "' ";
            $fieldLength = $field['length'] >= 0 ? "(" . $field['length'] . ")" : '';
            $sentence = $field['name'] . " " . $field['attribute'] . $fieldLength . $isNull . $defaultValue . $ai . ",";
            $query .= $sentence;
        }
        array_unshift($keys, 'blogid');
        $query .= " PRIMARY KEY (" . implode(',', $keys) . ")";
        $query .= $index;
        $query .= ") TYPE=MyISAM ";
        $query .= POD::charset() == 'utf8' ? 'DEFAULT CHARSET=utf8' : '';
        if (POD::execute($query)) {
            $keyname = Utils_Unicode::lessenAsEncoding('Database_' . $name, 32);
            $value = Utils_Unicode::lessenAsEncoding($plugin . '/' . $version, 255);
            Setting::setServiceSetting($keyname, $value, true);
            #POD::execute("INSERT INTO {$database['prefix']}ServiceSettings SET name='$keyname', value ='$value'");
            return true;
        } else {
            return false;
        }
    }
    return true;
}
Exemple #4
0
        if ($pool->update()) {
            showCheckupMessage(true);
        } else {
            showCheckupMessage(false);
        }
    }
    if (!DBAdapter::queryExistence("DESC {$database['prefix']}Sessions expires")) {
        $changed = true;
        echo '<li>', _text('자동 로그인을 위해 세션 테이블 구조를 수정합니다.'), ': ';
        if (DBAdapter::execute("ALTER TABLE {$database['prefix']}Sessions ADD expires int(11) NOT NULL DEFAULT 0 AFTER updated")) {
            showCheckupMessage(true);
        } else {
            showCheckupMessage(false);
        }
    }
    if (!doesExistTable($database['prefix'] . "Properties")) {
        $changed = true;
        echo '<li>', _text('프로퍼티 저장을 위한 테이블을 추가합니다.'), ': ';
        $pool = DBModel::getInstance();
        $pool->reset("Properties");
        $pool->structure = array("blogid" => array("type" => "integer", "length" => 11, "isNull" => false), "namespace" => array("type" => "varchar", "length" => 32, "isNull" => false, "default" => 'global'), "keyname" => array("type" => "varchar", "length" => 32, "isNull" => false), "value" => array("type" => "text", "isNull" => false));
        $pool->option['primary'] = array("blogid", "namespace", "keyname");
        if ($pool->create()) {
            showCheckupMessage(true);
        } else {
            showCheckupMessage(false);
        }
    }
}
/***** Common parts. *****/
if (doesHaveOwnership()) {
Exemple #5
0
     if (POD::execute($query . ' DEFAULT CHARSET=utf8') || POD::execute($query)) {
         showCheckupMessage(true);
     } else {
         showCheckupMessage(false);
     }
 }
 if (!DBAdapter::queryExistence("DESC {$database['prefix']}Lines permalink")) {
     $changed = true;
     echo '<li>', _text('라인 기능에 여러 라인의 통합을 위한 필드를 추가합니다.'), ': ';
     if (DBAdapter::execute("ALTER TABLE {$database['prefix']}Lines ADD root varchar(11) NOT NULL default 'default' AFTER blogid") && DBAdapter::execute("ALTER TABLE {$database['prefix']}Lines ADD author varchar(32) NOT NULL default '' AFTER category") && DBAdapter::execute("ALTER TABLE {$database['prefix']}Lines ADD permalink varchar(128) NOT NULL default '' AFTER content")) {
         showCheckupMessage(true);
     } else {
         showCheckupMessage(false);
     }
 }
 if (!doesExistTable($database['prefix'] . 'Widgets')) {
     $changed = true;
     echo '<li>', _text('위젯 기능 및 오픈소셜 지원을 위한 테이블을 만듭니다'), ': ';
     $query = "\n\t\tCREATE TABLE {$database['prefix']}Widgets (\n\t\t  id int(11) NOT NULL default 1,\n\t\t  blogid int(11) NOT NULL default 1,\n\t\t  title varchar(64) NOT NULL default 'Widget',\n\t\t  author varchar(32) NOT NULL default 'Textcube',\n\t\t  email varchar(32) DEFAULT NULL,\n\t\t  screenshot varchar(128) DEFAULT NULL,\n\t\t  thumbnail varchar(128) DEFAULT NULL,\n\t\t  titleurl varchar(128) DEFAULT NULL,\n\t\t  authorlink varchar(128) default null,\n\t\t  authorlocation varchar(32) default null,\n\t\t  authorphoto varchar(128) DEFAULT NULL,\n\t\t  height int(11) DEFAULT NULL,\n\t\t  scrolling int(1) default 0,\n\t\t  feature varchar(32) default 'opensocial',\n\t\t  content text NOT NULL default '',\n\t\t  PRIMARY KEY(id),\n\t\t  KEY(blogid)\n\t\t) TYPE=MyISAM\n\t\t";
     if (POD::execute($query . ' DEFAULT CHARSET=utf8') || POD::execute($query)) {
         showCheckupMessage(true);
     } else {
         showCheckupMessage(false);
     }
 }
 /* From Textcube 1.8.4 */
 if (!POD::queryExistence("DESC {$database['prefix']}RemoteResponseLogs responsetype")) {
     $changed = true;
     echo '<li>', _text('트랙백과 핑백의 출력을 위하여 필드 속성을 변경합니다.'), ': ';
     if (POD::execute("ALTER TABLE {$database['prefix']}RemoteResponseLogs CHANGE type responsetype ENUM('trackback','pingback') NOT NULL DEFAULT 'trackback'")) {
         showCheckupMessage(true);