2011-06-10 11:25:01 +00:00
< ? php
/** Get e - mail subject and message from database ( Adminer Editor )
2015-09-08 16:23:25 +00:00
* @ link https :// www . adminer . org / plugins / #use
2017-02-27 12:43:33 +00:00
* @ author Jakub Vrana , https :// www . vrana . cz /
2018-01-14 10:03:54 +00:00
* @ license https :// www . apache . org / licenses / LICENSE - 2.0 Apache License , Version 2.0
* @ license https :// www . gnu . org / licenses / gpl - 2.0 . html GNU General Public License , version 2 ( one or other )
2011-06-10 11:25:01 +00:00
*/
class AdminerEmailTable {
2011-08-11 15:06:42 +00:00
/** @access protected */
2011-06-10 11:25:01 +00:00
var $table , $id , $title , $subject , $message ;
/**
* @ param string quoted table name
* @ param string quoted column name
* @ param string quoted column name
* @ param string quoted column name
* @ param string quoted column name
*/
2015-08-15 15:04:21 +00:00
function __construct ( $table = " email " , $id = " id " , $title = " subject " , $subject = " subject " , $message = " message " ) {
2011-06-10 11:25:01 +00:00
$this -> table = $table ;
$this -> id = $id ;
$this -> title = $title ;
$this -> subject = $subject ;
$this -> message = $message ;
}
function selectEmailPrint ( $emailFields , $columns ) {
if ( $emailFields ) {
print_fieldset ( " email " , ( 'E-mail' ));
2018-01-13 08:34:01 +00:00
echo " <div> \n " ;
echo script ( " qsl('div').onkeydown = partial(bodyKeydown, 'email'); " );
2011-06-10 11:25:01 +00:00
echo " <p> " . ( 'From' ) . " : <input name='email_from' value=' " . h ( $_POST ? $_POST [ " email_from " ] : $_COOKIE [ " adminer_email " ]) . " '> \n " ;
echo ( 'Subject' ) . " : <select name='email_id'><option> " . optionlist ( get_key_vals ( " SELECT $this->id , $this->title FROM $this->table ORDER BY $this->title " ), $_POST [ " email_id " ], true ) . " </select> \n " ;
2018-01-13 08:34:01 +00:00
echo " <p> " . ( 'Attachments' ) . " : <input type='file' name='email_files[]'> " ;
echo script ( " qsl('input').onchange = function () {
this . onchange = function () { };
var el = this . cloneNode ( true );
el . value = '' ;
this . parentNode . appendChild ( el );
}; " );
2011-06-10 11:25:01 +00:00
echo " <p> " . ( count ( $emailFields ) == 1 ? '<input type="hidden" name="email_field" value="' . h ( key ( $emailFields )) . '">' : html_select ( " email_field " , $emailFields ));
2018-01-13 08:34:01 +00:00
echo " <input type='submit' name='email' value=' " . ( 'Send' ) . " '> " . confirm ();
2011-06-10 11:25:01 +00:00
echo " </div> \n " ;
echo " </div></fieldset> \n " ;
return true ;
}
}
function selectEmailProcess ( $where , $foreignKeys ) {
$connection = connection ();
if ( $_POST [ " email_id " ]) {
$result = $connection -> query ( " SELECT $this->subject , $this->message FROM $this->table WHERE $this->id = " . q ( $_POST [ " email_id " ]));
$row = $result -> fetch_row ();
$_POST [ " email_subject " ] = $row [ 0 ];
$_POST [ " email_message " ] = $row [ 1 ];
}
}
}