function StringToDateTime($value) { if (!preg_match(GetConfigValue("datetime_regexp"), $value, $m)) { return '0000-01-01 00:00:00'; } return $m[3] . '-' . $m[1] . '-' . $m[2] . ' ' . $m[4] . ':' . $m[5] . ':' . (isset($m[7]) ? $m[7] : '00'); }
function GetTablesList() { static $tables = null; if ($tables == null) { $cmd = new DBCommand("SHOW TABLES FROM @dbname"); $cmd->Add('@dbname', DB_TableName, GetConfigValue("db_database")); $res = DB::GetAll($cmd); $tables = array(); foreach ($res as $row) { $tables[] = GetFirstValue($row); } } return $tables; }
function DBMySql() { $this->conn = mysql_connect(GetConfigValue('db_host'), GetConfigValue('db_user'), GetConfigValue('db_pass')) or StrikeError(mysql_error()); mysql_select_db(GetConfigValue('db_database'), $this->conn) or StrikeError(mysql_error()); }
function SendRaw(&$email) { $hdr = 'From: ' . $email->from . "\n"; foreach ($email->headers as $val) { $hdr .= $val . "\n"; } $hdr .= "MIME-Version: 1.0\n"; if (!count($email->attachments)) { $hdr .= 'Content-Type: text/html; charset=' . $email->charset . "\n"; $body = $email->body; } else { $str = $email->body; foreach ($email->attachments as $att) { $str .= $att->content; } $boundary = $this->GenerateBoundary($str); $hdr .= 'Content-Type: multipart/mixed; boundary="' . $boundary . '"' . "\n"; $attachs = ''; foreach ($email->attachments as $att) { if (strpos($att->mimeType, '/') === false) { SystemDie("Invalid MIME type of the attachment."); } $attachs .= "--{$boundary}\n"; $attachs .= 'Content-Type: ' . $att->mimeType; if ($att->contentName != '') { $attachs .= '; name="' . $att->contentName . '"'; } $attachs .= "\n"; $attachs .= "Content-Transfer-Encoding: base64\n"; if ($att->fileName != '') { $attachs .= 'Content-Disposition: attachment; filename="' . $att->fileName . '"' . "\n"; } if ($att->contentId != '') { $attachs .= 'Content-ID: <' . $att->contentId . ">\n"; } $attachs .= "\n"; $attachs .= chunk_split(base64_encode($att->content)) . "\n"; } $body = "--{$boundary}\n"; $body .= "Content-type: text/html; charset=" . $email->charset . "\n\n"; $body .= $email->body . "\n" . $attachs; $body .= "--{$boundary}--\n"; } if (DEBUG_ENABLE) { $msg = '<b>SendMail to "' . $email->to . '" with subject "' . $email->subject . '"</b>'; if (!GetConfigValue("send_mail")) { $msg .= ' <span style="color:red;">(Sending email is disabled)</span>'; } DebugWrite($msg, MSG_NORMAL); DebugWritePre('Headers', $hdr); DebugWritePre('Body', $body); } if (GetConfigValue("send_mail")) { mail($email->to, $email->subject, $body, $hdr); } }
function SendEmail($img) { $vars = array(); $vars['img'] = $img; $tpl_html = new Template(); $res_html = $tpl_html->Process(BASE_PATH . 'email.tpl', $vars); $email = new Email(); $email->from = 'admin@' . GetConfigValue('sitename'); $email->to = $this->GetEmail(); $email->subject = 'Deletion code for ' . $img->orig_filename; $email->body = ''; $attach = new EmailAttachment(); $attach->mimeType = 'text/html'; $attach->content = $res_html; $email->attachments[] = $attach; $email->Send(); }