Merge pull request #50 from Sei-Lisa/sei-64k-nc-limit

Report error in settings.php when max length of 64K is exceeded
This commit is contained in:
codeviolet 2017-09-30 22:05:36 +10:00 committed by GitHub
commit 4bef4dc247

View file

@ -148,7 +148,22 @@ else if(isset($_REQUEST['w'])){ // write to a record
else{
$row = mysqli_fetch_assoc($result);
$newtext = $row['text'] . $given_text;
if($row['count']+1 == $given_count){
if (strlen($newtext) > 65535) {
$sql = "UPDATE $avpos_table"
. ' SET text = ' . StrSQL("64K limit exceeded.\n"
. "The text that was generated can't"
. " be saved as a notecard because it's"
. " too long.")
. ', count = ' . IntSQL(10000+$given_count)
. ', timestamp = NOW()'
. ' WHERE webkey = ' . StrSQL($given_webkey);
mysqli_query($link,$sql) or email_death("ERR03: " . mysqli_error($link));
$response = "NOTECARD TOO LONG";
}
else if (startsWith($newtext, '64K limit exceeded')) {
$response = "NOTECARD TOO LONG";
}
else if($row['count']+1 == $given_count){
$response = "ADDING";
if(endsWith($_REQUEST['t'],"\n\nend")){
@ -175,6 +190,8 @@ else if(isset($_REQUEST['w'])){ // write to a record
}
else if(isset($_REQUEST['q'])){ // read a record
$out = "";
$given_webkey = $_REQUEST['q'];
$sql = "SELECT * FROM $avpos_table"
. ' WHERE webkey = ' . StrSQL($given_webkey);