schemamigration: expand titles to 50 chars

This commit is contained in:
Claude 2015-01-27 13:19:20 +01:00
parent 795543d5c2
commit 39d665615a

View File

@ -281,6 +281,30 @@ class Main extends CI_Controller
$this->db->query("ALTER TABLE " . $db_prefix . "ci_sessions CHANGE COLUMN ip_address ip_address VARCHAR(45) NOT NULL DEFAULT '0'");
}
}
//expand title to 50
$fields = $this->db->field_data('pastes');
foreach ($fields as $field)
{
if ($field->name == 'title')
{
if ($field->max_length < 50)
{
$db_prefix = config_item('db_prefix');
if ($this->db->dbdriver == "postgre")
{
$this->db->query("ALTER TABLE " . $db_prefix . "pastes ALTER COLUMN title TYPE VARCHAR(50), ALTER COLUMN title SET NOT NULL");
}
else
{
$this->db->query("ALTER TABLE " . $db_prefix . "pastes CHANGE COLUMN title title VARCHAR(50) NOT NULL");
}
}
}
}
}
function _form_prep($lang = false, $title = '', $paste = '', $reply = false)
@ -698,7 +722,8 @@ class Main extends CI_Controller
function _valid_recaptcha()
{
if ($this->recaptcha_privatekey == null || $this->recaptcha_privatekey == '') {
if ($this->recaptcha_privatekey == null || $this->recaptcha_privatekey == '')
{
die("To use reCAPTCHA you must get an API key from <a href='https://www.google.com/recaptcha/admin/create'>https://www.google.com/recaptcha/admin/create</a>");
}
@ -707,7 +732,6 @@ class Main extends CI_Controller
$pk = $this->recaptcha_privatekey;
$ra = $_SERVER['REMOTE_ADDR'];
$rf = trim($this->input->post('g-recaptcha-response'));
$url = "https://www.google.com/recaptcha/api/siteverify?secret=" . $pk . "&response;=" . $rf . "&remoteip;=" . $ra;
$response = $this->curl->simple_get($url);
$status = json_decode($response, true);