File: mailbox.php

package info (click to toggle)
postaci 1.1.3-4
  • links: PTS
  • area: main
  • in suites: woody
  • size: 1,176 kB
  • ctags: 1,382
  • sloc: php: 6,083; sql: 1,035; sh: 488; makefile: 47; pascal: 24
file content (406 lines) | stat: -rwxr-xr-x 18,651 bytes parent folder | download
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
<?
/*
   File name         : mailbox.php
   Version           : 1.1.3
   Last Modified By  : Umut Gokbayrak
   e-mail            : umut@trlinux.com
   Purpose           : This is a generic file that lists all the mail
                       headers in the current mailbox. Clicking on a header will
                       redirect the user to a POP3 or IMAP stream.
   Last modified     : 7 Nov 2000
*/

include ("includes/global.inc");
session_start();

// If first login redirect to preferences screen
if ($f == 1) {
  Header("Location: preferences.php?f=1");
}

// ID comparison between logged hash and session. If they are both the same, let the user to go on...
$dbq = $db->execute("select log_id from tblLoggedUsers where hash = '$ID'");
$log_id = $dbq->fields['log_id'];
$dbq->close();
if ($log_id == ""){
  Header("Location: index.php?error_id=1");
} else {
  function mychop($thistring,$length) {
    $result="";
    $mystring=trim($thistring);
    if (strlen($mystring)>$length) {
      $result=substr($mystring,0,$length);
      $result = "$result...";
    }else {
      $result=$mystring;
    }

    return($result);
  }

  $mbox_id = rawurldecode($mbox_id);

  include ("$postaci_directory" . "classes/imap_pop3.inc");

  // Check to see if the mbox_id is a valid one.
  $dbq = $db->execute("select user_id,username,password from tblLoggedUsers where hash='$ID'");
  $username = $dbq->fields['username'];
  $password = $dbq->fields['password'];
  $user_id = $dbq->fields['user_id'];
  $dbq->close();

  $email=new imap_pop3($default_port,$default_protocol,$default_host,$username,$password,$mbox_id);
  if ($f !=1 && $mbox_id != "INBOX") {$email->mbox_exists($mbox_id);}
  include ("$postaci_directory" . "includes/commonhead.inc");
  include ("$postaci_directory" . "includes/stylesheets.inc");
  include ("$postaci_directory" . "includes/javascripts.inc");
  include ("$postaci_directory" . "includes/functions.inc");

?>
  <meta http-equiv="refresh" content="180; url=mailbox.php?mbox_id=<? echo $mbox_id; ?>">
  </head>

  <body bgcolor='#F3F3F3' leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" background="images/background.gif" text="#000000" link="#1F4687" vlink="#1F4687" alink="#1F4687" onLoad="MM_preloadImages('images/turkish_version2.gif','images/english_version2.gif')">
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td width="1%" bgcolor="#273C79"><img src="images/empty.gif" width="15" height="1"></td>
      <td width="1%" bgcolor="#273C79" background="images/line_vertical_blue_back.gif"><img src="images/empty.gif" width="152" height="1"></td>
      <td width="98%" bgcolor="#273C79" background="images/line_vertical_blue_back.gif" align="right"><img src="images/postaci_webmail.jpg" width="349" height="32" alt="ver :  <? echo $postaci_version; ?>"></td>
    </tr>
  </table>
  <table width="100%" border="0" cellspacing="0" cellpadding="0" height="1">
    <tr>
      <td height="1" width="1%" bgcolor="#273C79"><img src="images/empty.gif" width="15" height="1"></td>
      <td height="1" width="1%"><img src="images/line_horizantal_shadow.gif" width="165" height="1"></td>
      <td height="1" width="98%"><img src="images/empty.gif" width="10" height="1"></td>
    </tr>
  </table>
  <table width="100%" border="0" cellspacing="0" cellpadding="0" height="400">
    <tr>
      <td width="1%"><img src="images/empty.gif" width="15" height="1"></td>
      <td width="1%" valign="top" align="left"><img src="images/company_logo2.jpg" width="152" height="152"><br>
        <table width="120" border="0" cellspacing="0" cellpadding="0" align="center">
          <tr>
            <td>
              <img src="images/dot.gif" width="10" height="10"> <a href="sendmail.php?post_act=0&mbox_id=<? echo $mbox_id; ?>"><? echo "$text25"; ?></a>
            </td>
          </tr>
          <tr>
            <td>
              <img src="images/dot.gif" width="10" height="10"> <a href="mailbox.php?mbox_id=INBOX"><? echo "$text26"; ?></a>
            </td>
          </tr>
          <tr>
            <td>
              <img src="images/dot.gif" width="10" height="10"> <a href="folders.php"><? echo "$text27"; ?></a>
            </td>
          </tr>
          <tr>
            <td>
              <table border="0" cellpadding="0" cellspacing="0" width="111">
                <tr>
                  <td width="8">
                    <img src="images/empty.gif" height="1" width="15">
                  </td>
                  <td width="112">
                    <?
                      if ($default_protocol == "pop3") {
                        echo "- <a href=\"mailbox.php?mbox_id=INBOX\">INBOX</a><br>";
                      }
                      $folders = $email->getMailboxes();
                      $folder_names = array();
                      $folder_counter=-1;
                      while (list($key,$val) = each($folders["name"])) {
                        $folder_counter++;
                        $folder_names[$folder_counter] = $val;
                      }
                      $ids = array();
                      $folder_counter=-1;
                      while (list($key,$val) = each($folders["id"])) {
                        $folder_counter++;
                        $ids[$folder_counter] = $val;
                      }

                      for($i=0;$i<count($ids);$i++) {
                        echo "- <a href=\"mailbox.php?mbox_id=$ids[$i]\">$folder_names[$i]</a><br>";
                      }
                    ?>
                  </td>
                </tr>
              </table>
            </td>
          </tr>
          <tr>
            <td>
              <img src="images/dot.gif" width="10" height="10"> <a href="preferences.php"><? echo "$text28"; ?></a>
            </td>
          </tr>
          <tr>
            <td>
              <img src="images/dot.gif" width="10" height="10"> <a href="index.php"><? echo "$text29"; ?></a>
            </td>
          </tr>
          <tr valign="bottom" align="center">
          <?
            if($show_sponsor) {
              echo "<td height=\"75\" class=\"style=\"8\">$text78</td>\n";
            } else {
              echo "<td height=\"75\" class=\"style=\"8\">&nbsp;</td>\n";
            }
          ?>
          </tr>
          <tr>
            <td>
              <div align="center">
                <table width="111" border="0" cellspacing="0" cellpadding="1" bgcolor="#333333">
                  <tr>
                  <?
                    if ($show_sponsor) {
                      echo "<td><a href=\"http://www.yimpas.net.tr\"><img src=\"images/sponsor.gif\" width=\"109\" height=\"30\" border=\"0\"></a></td>\n";
                    }
                  ?>
                  </tr>
                </table>
              </div>
            </td>
          </tr>
        </table>
      </td>
      <td width="98%" valign="top">

      <table width="100%" border="0" cellspacing="0" cellpadding="0" height="150">
       <? include ($postaci_directory . "includes/headinside.inc"); ?>
        <tr>
          <td width="10" height="180" valign="top">
            <p><img src="images/empty.gif" width="1" height="180"></p>
          </td>
          <td valign="top" align="left">
            <hr size="1">
            <form method="post" action="message_move.php" name="mesajlar" onSubmit="submitonce(this)">
              <input type="hidden" name="mbox_id" value="<? echo $mbox_id; ?>">

            <table width="100%" border="0" cellspacing="0" cellpadding="0" height="18">
              <tr bgcolor="#D1D1D1">
                <?
                  $mailadress = getMailAdress($user_id);
                  if ($email->protocol == "pop3") {
                    if (trim(strtoupper($mbox_id)) != "INBOX") {
                      $current_folder = getFolderName($mbox_id);
                    } else {
                      $current_folder = $mbox_id;
                    }
                  } else {
                    $current_folder = $mbox_id;
                  }
                ?>
                <td>&nbsp;<font color="#4E4E4E"><b> <? echo htmlspecialchars($mailadress) . " - " . $current_folder; ?></b></font></td>
              </tr>
            </table>
            &nbsp;<br>
            &nbsp;<br>
              <table width="100%" border="0" cellspacing="2" cellpadding="0">
                <tr align="right">
                  <td colspan="6">
                    <div align="right">

                    <?
                      echo "$text16 ";
                      echo "<select name=\"slcmbox\">\n";
                      for($i=0;$i<count($ids);$i++) {
                        if (trim($folder_names[$i]) != "INBOX" && trim($folder_names[$i]) != $current_folder) {
                          $folder_id = getFolderID($folder_names[$i],$user_id);
                          echo "<option value=\"$folder_id\">$folder_names[$i]</option>\n";
                        }
                      }
                      echo "</select>\n";
                      echo $text17;
                      echo "<input type=\"submit\" name=\"Submit\" value=\"$text18\">\n";
                     ?>

                      </div>
                  </td>
                </tr>
                <tr>
                  <td width="3%" bgcolor="#D1D1D1">
                    <input type="checkbox" name="allbox" value="checkbox" onClick="ToggleAll();">
                  </td>
                  <td width="2%" bgcolor="#D1D1D1"><img src="images/empty.gif" width="17" height="8"></td>
                  <?
                  if ($default_protocol == "pop3") {
                    $dbq = $db->execute("select mbox_id from tblMailBoxes where user_id=$user_id and mbox_type = 1");
                    $POP3toFolder = $dbq->fields['mbox_id'];
                    $dbq->close();
                  }

                  if ($mbox_id == "$to_folder" || $mbox_id == $POP3toFolder) {
                    echo "<td width=\"29%\" bgcolor=\"#D1D1D1\"><font color=\"#4E4E4E\"><b>$text32</b></font></td>";
                  } else {
                    echo "<td width=\"29%\" bgcolor=\"#D1D1D1\"><font color=\"#4E4E4E\"><b>$text12</b></font></td>";
                  }
                  ?>
                  <td width="46%" bgcolor="#D1D1D1"><font color="#4E4E4E"><b><? echo "$text13"; ?></b></font></td>
                  <td width="12%" bgcolor="#D1D1D1"><font color="#4E4E4E"><b><? echo "$text14"; ?></b></font></td>
                  <td width="8%" bgcolor="#D1D1D1"><font color="#4E4E4E"><b><? echo "$text15"; ?></b></font></td>
                </tr>
                <?
                  if ($email->empty_mailbox()) {
                    echo "  <tr>\n";
                    echo "    <td colspan='6' align='center'>\n";
                    echo "      &nbsp;<br><b><font color=\"#304167\">$text24</font></b>&nbsp;<p><hr size=\"1\">\n";
                    echo "    </td>\n";
                    echo "  </tr>\n";
                  } else {
                    $postaci_headers = $email->postaci_get_headers();

                    $message_count_right_now = count($postaci_headers["status"]);

                    for ($i = 0; $i < $message_count_right_now ;$i++) {
                      if ($postaci_headers["status"][$i] == 1) {
                        $message_new_tag_begin = "<b>";
                        $message_new_tag_end = "</b>";
                      } else {
                        $message_new_tag_begin = "";
                        $message_new_tag_end = "";
                      }

                      echo "<tr>\n";
                      $mesaj_numerosu = $postaci_headers["msg_no"][$i];
                      echo "  <td width='3%' bgcolor='#E4E4E4'><font color='#000000'><input type='checkbox' name='chk[]' value='$mesaj_numerosu'></font></td>\n";


                      if ($postaci_headers["attach"][$i] == 1) {
                        echo "  <td width='3%' bgcolor='#E4E4E4' nowrap align='center'><img src='images/attach.gif'></td>\n";
                      } else {
                        echo "  <td width='3%' bgcolor='#E4E4E4' nowrap align='center'>&nbsp;</td>\n";
                      }

                      $urlenc_mbox_id = rawurlencode($mbox_id);
                      if ($mbox_id == "$to_folder" || $mbox_id == $POP3toFolder) {
                          if ($default_protocol == "pop3" && $mbox_id != "INBOX") {
                            $post_act = 5;
                          } else {
                            $post_act = 3;
                          }
                          echo "<td width=\"29%\" bgcolor=\"#E4E4E4\" nowrap><a href=\"sendmail.php?topmsg=" . $topmsg . "&msg_id=" . $postaci_headers["msg_no"][$i] . "&mbox_id=$urlenc_mbox_id&post_act=" . $post_act . "\">";
                          echo "$message_new_tag_begin" . mychop($postaci_headers["to"][$i],25) . "$message_new_tag_end";
                          echo "</a>&nbsp;&nbsp;</td>";
                      } else {
                          if ($default_protocol == "pop3" && $mbox_id != "INBOX") {
                            $post_act = 7;
                          } else {
                            $post_act = 1;
                          }
                          echo "<td width=\"29%\" bgcolor=\"#E4E4E4\" nowrap><a href=\"sendmail.php?topmsg=" . $topmsg . "&msg_id=" . $postaci_headers["msg_no"][$i] . "&mbox_id=$urlenc_mbox_id&post_act=$post_act\">";
                          echo "$message_new_tag_begin" . mychop($postaci_headers["from"][$i],25) . "$message_new_tag_end";
                          echo "</a>&nbsp;&nbsp;</td>";
                      }
                      echo "<td width=\"46%\" bgcolor=\"#E4E4E4\" nowrap><a href=\"readmessage.php?topmsg=" . $topmsg . "&mbox_id=$urlenc_mbox_id&msg_no=" . $postaci_headers["msg_no"][$i] . "\">";
                      if ($postaci_headers["subject"][$i] == "") {
                        $postaci_headers["subject"][$i] = $text40;
                      }
                      echo "$message_new_tag_begin" . mychop(turkcelestir($postaci_headers["subject"][$i]),22) . "$message_new_tag_end";
                      echo "</a>&nbsp;&nbsp;</td>";
                      echo "<td width=\"12%\" bgcolor=\"#E4E4E4\" nowrap>" . $postaci_headers["msg_date"][$i];
                      echo "</td>";
                      echo "<td width=\"8%\" bgcolor=\"#E4E4E4\" nowrap align=\"center\">" . $postaci_headers["size"][$i] . "</td>";
                      echo "</tr>\n";
                    } // end for
                  } // end if
                ?>
              </table>
                <table width="100%" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td align="right">
                      <table width="100%" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                          <td>
                            <b><font color="#304167"><? echo "$text19 : $email->messagecount"; ?></font></b>
                          </td>
                          <td align="right">
                            <input type="submit" name="Submit2" value="<? echo $text57; ?>" onClick="formMailBox('1')">
                          </td>
                        </tr>
                      </table>
                    </td>
                  </tr>
                </table>
              </form>
              <?
                // Page identification with numbers.

                $how_many = calculateHowManyPages($email->messagecount);

                if ($how_many !=1) {
                  echo "<div align='center'>\n";
                  if ($default_protocol == "imap" || $mbox_id == "INBOX") { // IMAP or POP3 inbox
                    $tmptop = $email->messagecount;
                    for ($j=$how_many ; $j>0 ; $j = $j-1) {
                      $tmpbottom = $tmptop - $seperator +1;
                      if ($tmpbottom <= 0) {
                        $tmpbottom = 1;
                      }
                      if ($tmptop != $tmpbottom) {
                        echo "[ <b><a href='mailbox.php?mbox_id=$mbox_id&topmsg=$tmptop'>$tmptop-$tmpbottom</a></b> ] ";
                      } else {
                        echo "[ <b><a href='mailbox.php?mbox_id=$mbox_id&topmsg=$tmptop'>$tmptop</a></b> ]";
                      }
                      $tmptop = $tmpbottom -1;
                    }
                  } else {                                                 // pop3 db folder
                    if ($tmptop == 0) {
                      $dbq = $db->execute("select message_id from tblMessages where mbox_id=$mbox_id and user_id = $user_id order by message_id desc");
                      $max_msg_id = $dbq->fields['message_id'];
                      $dbq->close();
                      $topmsg = $max_msg_id;
                    }
                    $tmptop = $email->messagecount;
                    for ($j=$how_many ; $j>0 ; $j = $j-1) {
                      if ($topmsg2 != 0) {
                        $topmsg = $topmsg2;
                      }
                      $tmpbottom = $tmptop - $seperator +1;
                      $dbq = $db->execute("select message_id from tblMessages where mbox_id=$mbox_id and user_id = $user_id and message_id <= $topmsg order by message_id desc");
                      for ($n = 1;$n <= $seperator; $n++) {
                        $dbq->nextRow();
                      }
                      $topmsg2 = $dbq->fields['message_id'];
                      $dbq->close();

                      if ($tmpbottom <= 0) {
                        $tmpbottom = 1;
                      }
                      if ($tmptop != $tmpbottom) {
                        echo "[ <b><a href='mailbox.php?mbox_id=$mbox_id&topmsg=$topmsg'>$tmptop-$tmpbottom</a></b> ] ";
                      } else {
                        echo "[ <b><a href='mailbox.php?mbox_id=$mbox_id&topmsg=$topmsg'>$tmptop</a></b> ]";
                      }
                      $tmptop = $tmpbottom -1;

                    }
                  }
                  echo "</div>\n";
                }
              ?>
            <p>&nbsp; </p>
          </td>
          <td valign="top" width="10">&nbsp;</td>
        </tr>
        <tr>
          <td width="10" height="80" valign="top">&nbsp;</td>
          <td valign="bottom" align="right">
            <hr size="1">
            <div align="right"><span class="style8"><? echo $text84; ?></span></div>
            <p>
          </td>
          <td>&nbsp;</td>
        </tr>
      </table>
      </td>
    </tr>
  </table>
  </body>
  </html>

<?
}
?>