./c0de/php/mysqlextract.txt

0.
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.
89.
90.
91.
92.
93.
94.
95.
96.
97.
98.
99.
100.
101.
102.
103.
104.
105.
106.
107.
108.
109.
110.
111.
112.
113.
114.
115.
116.
117.
118.
119.
120.
121.
122.
123.
124.
125.
126.
127.
128.
129.
130.
131.
132.
133.
134.
135.
136.
137.
138.
139.
140.
141.
142.
143.
144.
145.
146.
147.
148.
149.
150.
151.
152.
153.
<?php
 
 
 
If ($action=="mysql"){
 
        #Grab email addresses from MySQL
 
        include "./mysql.info.php";
 
        if (!$sqlhost || !$sqllogin || !$sqlpass || !$sqldb || !$sqlquery){
 
        print "Please configure mysql.info.php with your MySQL information. All settings in this config file are required.";
 
        exit;
 
        }
 
        $db = mysql_connect($sqlhost, $sqllogin, $sqlpass) or die("Connection to MySQL Failed.");
 
        mysql_select_db($sqldb, $db) or die("Could not select database $sqldb");
 
        $result = mysql_query($sqlquery) or die("Query Failed: $sqlquery");
 
        $numrows = mysql_num_rows($result);
 
 
 
        for($x=0; $x<$numrows; $x++){
 
        $result_row = mysql_fetch_row($result);
 
        $oneemail = $result_row[0];
 
        $emaillist .= $oneemail."\n";
 
        }
 
        }
 
 
 
if ($action=="send"){
 
        $message = urlencode($message);
 
        $message = ereg_replace("%5C%22", "%22", $message);
 
        $message = urldecode($message);
        $message = stripslashes($message);
        $subject = stripslashes($subject);
 
}
 
 
 
?>
<?
 
if ($action=="send"){
 
 
 
        if (!$from && !$subject && !$message && !$emaillist){
 
        print "Please complete all fields before sending your message.";
 
        exit;
 
        }
 
 
 
        $allemails = split("\n", $emaillist);
 
        $numemails = count($allemails);
 
 
 
        #Open the file attachment if any, and base64_encode it for email transport
 
        If ($file_name){
 
                @copy($file, "./$file_name") or die("The file you are trying to upload couldn't be copied to the server");
 
                $content = fread(fopen($file,"r"),filesize($file));
 
                $content = chunk_split(base64_encode($content));
 
                $uid = strtoupper(md5(uniqid(time())));
 
                $name = basename($file);
 
        }
 
 
 
        for($x=0; $x<$numemails; $x++){
 
                $to = $allemails[$x];
 
                if ($to){
 
                $to = ereg_replace(" ", "", $to);
 
                $message = ereg_replace("&email&", $to, $message);
 
                $subject = ereg_replace("&email&", $to, $subject);
 
                print "Sending mail to $to.......";
 
                flush();
 
                $header = "From: $realname <$from>\r\nReply-To: $replyto\r\n";
 
                $header .= "MIME-Version: 1.0\r\n";
 
                If ($file_name) $header .= "Content-Type: multipart/mixed; boundary=$uid\r\n";
 
                If ($file_name) $header .= "--$uid\r\n";
 
                $header .= "Content-Type: text/$contenttype\r\n";
 
                $header .= "Content-Transfer-Encoding: 8bit\r\n\r\n";
 
                $header .= "$message\r\n";
 
                If ($file_name) $header .= "--$uid\r\n";
 
                If ($file_name) $header .= "Content-Type: $file_type; name=\"$file_name\"\r\n";
 
                If ($file_name) $header .= "Content-Transfer-Encoding: base64\r\n";
 
                If ($file_name) $header .= "Content-Disposition: attachment; filename=\"$file_name\"\r\n\r\n";
 
                If ($file_name) $header .= "$content\r\n";
 
                If ($file_name) $header .= "--$uid--";
 
                mail($to, $subject, "", $header);
 
                print "ok<br>";
 
                flush();
 
                }
 
                }
 
 
 
}
 
 

Back