Location: PHPKode > scripts > Amailer > amailer/mysql.php
<?
##################################################################################
# Anonymous Mailer Copyright Termix 2002 - 2003. All rights researved.           #
# Just don't change anything.                                                    #
# and don't take out the copyright even though there is an option to take it out #
# and thats all                                                                  #
# Site: http://termix.ath.cx                                                     #
# Auther: Aaron                                                                  #
# E-Mail: hide@address.com                                               #
#                                                                                #
# File: setup.php                                                                #
##################################################################################
include "ver.php";


//////////////////////////////////////////////////////////////////////////////////////////////////
//                              CHECKING FOR EMPTY FIELDS                                       //
//////////////////////////////////////////////////////////////////////////////////////////////////
if(empty($host)) error_message("You have forgot to enter your mysql host");
if(empty($sqlusername)) error_message("You have forgotten to enter your mysql username");
//if(empty($sqlpass)) error_message("You have forgotten to enter your mysql password");
if(empty($dname)) error_message("Please enter a database name (default: amailer LEAVE IT AMAILER)");
if(empty($webmaster)) error_message("Enter your webmasters email");
if(empty($adminusername)) error_message("Please enter a username for the admin");
if(empty($adminpassword)) error_message("Please enter a password for the admin");
if(empty($logfile)) error_message("Please enter a logfile");
if(empty($copyleft)) error_message("Please set the copyrright to eitehr 1 or 0");
//////////////////////////////////////////////////////////////////////////////////////////////////
//                                END OF ERROR CHECKING                                         //
//////////////////////////////////////////////////////////////////////////////////////////////////



$dbhost = "$host";
$dbusername = "$sqlusername";
$dbuserpassword = "$sqlpass";
$default_dbname = "$dname";
$default_sort_order = 'ASC';
$default_order_by = 'id';
$records_per_page = 5;
$mail_logname = 'maillog';

function db_connect() {
global $dbhost, $dbusername, $dbuserpassword, $default_dbname;
global $MYSQL_ERRNO, $MYSQL_ERROR;

$link_id = mysql_connect($dbhost, $dbusername, $dbuserpassword);
if(!$link_id) {
$MYSQL_ERRNO = 0;
$MYSQL_ERROR = "Connection failed to the host $dbhost";

return 0;

}
else return $link_id;
}

function sql_error() {
global $MYSQL_ERRON, $MYSQl_ERROR;

if(empty($MYSQL_ERROR)) {
$MYSQL_ERRNO = mysql_errno();
$MYSQL_ERROR = mysql_error();

}
return "$MYSQL_ERRNO: $MYSQL_ERROR";
} 


$new_win_width = 600;
$new_win_hight = 400;


function html_header() {
global $new_win_width, $new_win_hight;
?>
<HTML>
<HEAD>
<SCRIPT LANGUAGE="JAVASCRIPT": TYPE-"TEXT/JAVASCRIPT">
<!--
function open_window(url) {
var NEW_WIN = null;
NEW_WUN = window.open ("", "RecordViewer", "toolbar=no, width="+ <?php echo $new_win_width ?>+ ",hight="+<?php echo $new_win_hight ?>+",directories=no,status=no,scrollbars=yes,resize=no,menubar=no");
NEW_WIN.location.href = url;
}
//-->
</SCRIPT>
<TITLE> User Record Viewer</TITLE>
</HEAD>
<BODY>
<?
}
function html_footer() {
?>
</BODY>
</HTML>
<?
}


############################
## ERROR MESSAGE FUNCTION ##
############################
function error_message($msg) {
html_header();
echo "<SCRIPT>alert(\"Error: $msg\");history.go(-1)</SCRIPT>";
html_footer();
exit;
}
###########################
##     END OF FUNCTION   ##
###########################


//lets start making the tables.
$dbname = "$dname";
$mail_logname = 'maillog';
$mail_log_def = "id MEDIUMINT (90) DEFAULT '0' NOT NULL AUTO_INCREMENT,";
$mail_log_def .= "name text,";
$mail_log_def .= "email text,";
$mail_log_def .= "name1 text,";
$mail_log_def .= "email1 text,";
$mail_log_def .= "sub text,";
$mail_log_def .= "xmessage text,";
$mail_log_def .= "realemail text,";
$mail_log_def .= "today text,";
$mail_log_def .= "host text,";
$mail_log_def .= "realip text,";
$mail_log_def .= "try varchar(6) NOT NULL,";
$mail_log_def .= "PRIMARY KEY (ID),";
$mail_log_def .= "UNIQUE id (ID)";

$admin_settings = 'admin';
$admin_settings_def  = "id MEDIUMINT (10) DEFAULT '0' NOT NULL AUTO_INCREMENT,";
$admin_settings_def .= "webmaster text,";
$admin_settings_def .= "admin_username text,";
$admin_settings_def .= "admin_password VARCHAR (30) NOT NULL,";
$admin_settings_def .= "copyleft text,";
$admin_settings_def .= "logfile text,";
$admin_settings_def .= "message text,";
$admin_settings_def .= "pmessage text,";
$admin_settings_def .= "urls text,";
$admin_settings_def .= "pathmailer text,";
$admin_settings_def .= "log_login text,";
$admin_settings_def .= "log_file text,";
$admin_settings_def .= "notify text,";
$admin_settings_def .= "date text,";
$admin_settings_def .= "time text,";
$admin_settings_def .= "PRIMARY KEY (ID),";
$admin_settings_def .= "UNIQUE id (ID)";


$link_id = db_connect();
if(!$link_id) die(sql_error());

if(!mysql_query("CREATE DATABASE $dbname")) die(sql_error());

echo "<center><b>Successfully created the '$dbname' database.</b></center><BR>";

if(!mysql_select_db($dbname)) die(sql_error());

if(!mysql_query("CREATE TABLE $mail_logname ($mail_log_def)"))
die(sql_error());
if(!mysql_query("CREATE TABLE $admin_settings ($admin_settings_def)"))
die(sql_error()); 

echo "<center><b>Successfully created the '$mail_logname' and '$admin_settings' tables.<br>Now you can start sending mails! <a href=\"index.php\">Click here to go to index</b></b></center>";

$default_sort_order = 'ASC';
$default_oder_by = 'id';
$records_per_page = 10;

$mail_log_def = 'maillog';
$admin_settings_def = 'admin';


$MYSQL_ERRNO = '';
$MYSQL_ERROR = '';


//Lets insert the values we got 
//Need to do some settings first.
if($message == "" && $pmessage == "") {
$pmessage = "\r\n\r\n\r\n _-~*^ Amailer $version ^*~-_";
$message = "<br><br><b>_-~*^ Amailer $version ^*~-_</b>";
$log_file   = "$pathmailer/log.dat";
//once conencted lets select the database

 if ($webmaster) {
  $result = mysql_query("INSERT INTO admin" . "(webmaster, admin_username, admin_password, logfile, copyleft, notify, message, log_login, log_file, pmessage, urls, pathmailer) " .
  "VALUES ('$webmaster', '$adminusername', '$adminpassword', '$logfile', '$copyleft', '$notify', '$message', '$loglogin', '$log_file', '$pmessage', '$urls', '$pathmailer')" ,$link_id);

$hhhost = "\$hhhhost = \"".$host."\"; \n";
$sssqlusername = "\$ssssqlusername = \"".$sqlusername."\"; \n"; 
$sssqlpassword = "\$ssssqlpassword = \"".$sqlpass."\"; \n";
$dddname = "\$ddddname = \"".$dname."\"; \n";
$filename="mysqlinfo.php"; 

// After that Nothing has to be changed here

$fl=fopen($filename,"a+"); 
// sets the pipe delimiters
fwrite($fl,"<? 
 $hhhost $sssqlusername $sssqlpassword $dddname ?>"); 
fclose($fl); 

 }
}
?>
Return current item: Amailer