Attachment 'main.php'

Download

   1 <?php
   2 /////////////////////////////////////////////////////////
   3 //	
   4 //	source/main.php
   5 //
   6 //	(C)Copyright 2000-2002 Ryo Chijiiwa <Ryo@IlohaMail.org>
   7 //
   8 //		This file is part of IlohaMail.
   9 //		IlohaMail is free software released under the GPL 
  10 //		license.  See enclosed file COPYING for details,
  11 //		or see http://www.fsf.org/copyleft/gpl.html
  12 //
  13 /////////////////////////////////////////////////////////
  14 
  15 /********************************************************
  16 
  17 	AUTHOR: Ryo Chijiiwa <ryo@ilohamail.org>
  18 	FILE: source/main.php
  19 	PURPOSE:
  20 		1.  List specified number of messages in specified order from given folder.
  21 		2.  Provide interface to read messages (link subjects to source/read_message.php)
  22 		3.  Provide interface to send messasge to senders (link "From" field to source/compose.php)
  23 		4.  Provide interface to move or delete messages
  24 		5.  Provide interface to view messages not currently listed.
  25 		6.  Provide functionality to move, delete messages and expunge folders.
  26 	PRE-CONDITIONS:
  27 		$user - Session ID
  28 		$folder - Folder name
  29 		[$sort_field] - Field to sort by {"subject", "from", "to", "size", "date"}
  30 		[$sort_order] - Order, "ASC" or "DESC"
  31 		[$start] - Show specified number of messages starting with this index
  32 
  33 ********************************************************/
  34 
  35 $exec_start_time = microtime();
  36 
  37 include("../include/stopwatch.inc");
  38 $clock = new stopwatch(true);
  39 
  40 $clock->register("start");
  41 
  42 include("../include/super2global.inc");
  43 $clock->register("pre-header");
  44 include("../include/header_main.inc");
  45 $clock->register("post-header");
  46 include("../include/ryosdates.inc");
  47 include("../include/icl.inc");
  48 include("../include/main.inc");
  49 include("../include/cache.inc");
  50 $clock->register("includes done");
  51 
  52 	if (!isset($folder)){
  53 		echo "Error: folder not specified";
  54 		exit;
  55 	}
  56 	include("../lang/".$my_prefs["lang"]."defaultFolders.inc");
  57 	include("../lang/".$my_prefs["lang"]."main.inc");
  58 	include("../lang/".$my_prefs["lang"]."dates.inc");
  59 
  60 	//initialize some vars
  61 	if (!isset($hideseen)) $hideseen=0;
  62 	if (!isset($showdeleted)) $showdeleted=0;
  63 	if (strcmp($folder, $my_prefs["trash_name"])==0) $showdeleted=1;
  64 	if (empty($my_prefs["main_cols"])) $my_prefs["main_cols"]="camfsdz";
  65 	
  66 	$clock->register("pre-connect");
  67 	
  68 	//connect to mail server
  69 	$conn = iil_Connect($host, $loginID, $password, $AUTH_MODE);
  70 	if (!$conn){
  71 		echo "Connection failed: $iil_error <br> ";
  72 		exit;
  73 	}
  74 	
  75 	$clock->register("post-connect");
  76 		
  77 	echo "\n<!-- ICLMessages:\n".$conn->message."-->\n";
  78 	
  79 	//move columns
  80 	//$MOVE_FIELDS = 1;
  81 	if ($MOVE_FIELDS){
  82 		$report = $mainErrors[8];
  83 		if ($move_col && $move_direction){
  84 			//echo "Moving fields <br>\n";
  85 			$col_pos = strpos($my_prefs["main_cols"], $move_col);
  86 			if ($col_pos !== false){
  87 				if ($move_direction=="right") $move_direction = 1;
  88 				else if ($move_direction=="left") $move_direction = -1;
  89 				$partner_col = $my_prefs["main_cols"][$col_pos+$move_direction];
  90 				//echo "Shift is $move_direction switching with $partner_col <br>\n";
  91 				if ($partner_col){
  92 					$my_prefs["main_cols"][$col_pos+$move_direction] = $move_col;
  93 					$my_prefs["main_cols"][$col_pos] = $partner_col;
  94 					include("../include/save_prefs.inc");
  95 				}
  96 			}
  97 		}
  98 	}
  99 	
 100 
 101 	//default names for toolbar input fields, used in main_tools.inc as well
 102 	$main_tool_fields = array("expunge", "empty_trash", "delete_selected",
 103 								"mark_read", "mark_unread", "moveto", "move_selected");
 104 
 105 	//if toolbar displayed at top & bottom, bottom fields will have '_2' appened
 106 	//at the end of field name.  we deal with that here
 107 	reset($main_tool_fields); 
 108 	while ( list($k,$tool_field)=each($main_tool_fields) ){
 109 		$tool_var_name = $tool_field."_2";
 110 		$tool_var_val = $$tool_var_name;
 111 		if (!empty($tool_var_val)) $$tool_field = $tool_var_val;
 112 	}										
 113 	
 114 	//actions (flagging, deleting, moving, etc)
 115 	if ($move_selected) $submit = "File";
 116 	if ($delete_selected) $submit = "Delete";
 117 	if ($empty_trash) $submit = "Expunge";
 118 	if ($mark_read) $submit = "Read";
 119 	if ($mark_unread) $submit = "Unread";
 120 	
 121 	if (isset($submit)){
 122 		$messages="";
 123 		
 124 		/* compose an IMAP message list string including all checked items */
 125 		if ((is_array($uids)) && (implode("",$uids)!="")){
 126 			$checkboxes = iil_C_Search($conn, $folder, "UID ".implode(",", $uids));
 127 		}
 128 		if (is_array($checkboxes)){
 129                $messages = implode(",", $checkboxes);
 130                $num_checked = count($checkboxes);
 131 		}
 132 		
 133 		/* "Move to trash" is same as "Delete" */
 134 		if (($submit=="File") && $moveto && (strcmp($moveto, $my_prefs["trash_name"])==0)) $submit="Delete";
 135            
 136 		/*  delete all */
 137 		if ($delete_all == 2 ){
 138 			$messages .= "1:".$delete_all_num;
 139 		}
 140 					
 141 		/* delete items */
 142 		$delete_success = false;
 143 		if (($submit=="Delete")||(strcmp($submit,$mainStrings[10])==0)){
 144 			//if folders and trash specified, move to trash
 145 			if ($ICL_CAPABILITY["folders"]){
 146 				if (strcmp($folder, $my_prefs["trash_name"])!=0){
 147 					if (!empty($my_prefs["trash_name"])){
 148 						if (iil_C_Move($conn, $messages, $folder, $my_prefs["trash_name"]) >= 0){
 149 							$delete_success = true;
 150 						}else{
 151 							$report = $mainErrors[2].":".$messages;
 152 						}
 153 					}
 154 				}else{
 155 					$report = $mainErrors[3].":".$messages;
 156 				}
 157 			}
 158 
 159 			//otherwise, just mark as deleted
 160 			if (!$delete_success){
 161 				if (iil_C_Delete($conn, $folder, $messages) > 0) $delete_success = true;
 162 			}
 163 			
 164 			//if deleted, format success report
 165 			if ($delete_success){
 166 				$report =  str_replace("%n", $num_checked, $mainMessages["delete"]);
 167 			}
 168 		}
 169 		
 170 		/*  move items */
 171 		if (($submit=="File")||(strcmp($submit,$mainStrings[12])==0)){
 172 			if (strcasecmp($folder, $my_prefs["trash_name"])==0){
 173 				iil_C_Undelete($conn, $folder, $messages);
 174 			}
 175 			if (iil_C_Move($conn, $messages, $folder, $moveto) >= 0){
 176 				$report = str_replace("%n", $num_checked, $mainMessages["move"]);
 177 				$report = str_replace("%f", $moveto, $report);
 178 				if (strcasecmp($folder, $my_prefs["trash_name"])==0){
 179 					iil_C_Delete($conn, $folder, $messages);
 180 				}
 181 			}else{
 182 				$report = $mainErrors[4];
 183 			}
 184 		}
 185 			
 186 			
 187 		/* empty trash  command */
 188 		if (($submit=="Expunge") && ($expunge==1)){
 189 			if ($folder==$my_prefs["trash_name"]){
 190 				if (!iil_C_ClearFolder($conn, $folder)){
 191 					echo $mainErrors[6]." (".$conn->error.")<br>\n";
 192 				}
 193 			}else{
 194 				$error .= "Folder $folder is not trash (trash is ".$my_prefs["trash_name"].")<br>\n";
 195 			}
 196 		}
 197 		
 198 		/* expunge non-trash folders automatically */
 199 		if (strcasecmp($folder,$my_prefs["trash_name"])!=0){
 200 			iil_C_Expunge($conn, $folder);
 201 		}
 202 		
 203 		/* mark as unread */
 204 		if ($submit=="Unread"){
 205 			iil_C_Unseen($conn, $folder, $messages);
 206 			$reload_folders = true;
 207 			$selected_boxes = $checkboxes;
 208 		}
 209 		
 210 		/* mark as read */
 211 		if ($submit=="Read"){
 212 			iil_C_Flag($conn, $folder, $messages, "SEEN");
 213 			$reload_folders = true;
 214 			$selected_boxes = $checkboxes;
 215 		}
 216 	} //end if submit
 217 		
 218 		
 219 	/* If search results were moved or deleted, stop execution here. */
 220 	if (isset($search_done)){
 221 		echo "<p>Request completed.\n";
 222 		echo "</body></html>";
 223 		exit;
 224 	}
 225 	
 226 	/* initialize sort field and sort order 
 227 		(set to default prefernce values if not specified */
 228 	
 229 	if (empty($sort_field)) $sort_field=$my_prefs["sort_field"];
 230 	if (empty($sort_order)) $sort_order=$my_prefs["sort_order"];
 231 
 232 	
 233 	/* figure out which/how many messages to fetch */
 234 	if ((empty($start)) || (!isset($start))) $start = 0;
 235 	$num_show=$my_prefs["view_max"];
 236 	if ($num_show==0) $num_show=50;
 237 	$next_start=$start+$num_show;
 238 	$prev_start=$start-$num_show;
 239 	if ($prev_start<0) $prev_start=0;
 240 	//echo "<p>Start: $start";
 241 	
 242 	/* flush, so the browser can't start renderin and user sees some feedback */
 243 	flush();
 244 	
 245 	$clock->register("pre-count");
 246 
 247 	/* retreive message list (search, or list all in folder) */
 248 	if ((!empty($search)) || (!empty($search_criteria))){
 249 		include("../lang/".$my_prefs["lang"]."search_errors.inc");
 250 		$criteria="";
 251 		$error="";
 252 		$date = $month."/".$day."/".$year;
 253 		if (empty($search_criteria)){
 254 			// check criteria
 255 			if ($date_operand=="ignore"){
 256 				if ($field=="-"){
 257 					$error=$searchErrors["field"];
 258 				}
 259 				if (empty($string)){
 260 					$error=$searchErrors["empty"];
 261 				}
 262 			}else if ((empty($date))||($date=="mm/dd/yyyy")){
 263 				$error=$searchErrors["date"];
 264 			}
 265 			if (!empty($date)){
 266 				$date_a=explode("/", $date);
 267 				$date=iil_FormatSearchDate($date_a[0], $date_a[1], $date_a[2]);
 268 			}
 269 		}
 270 		if ($error==""){
 271 			// format search string
 272 			if (empty($search_criteria)){
 273 				$criteria="ALL";
 274 				if ($field!="-") $criteria.=" $field \"$string\"";
 275 				if ($date_operand!="ignore") $criteria.=" $date_operand $date";
 276 				$search_criteria = $criteria;
 277 			}else{
 278 				$search_criteria = stripslashes($search_criteria);
 279 				$criteria = $search_criteria;
 280 			}
 281 			
 282 			echo "Searching \"$criteria\" in $folder<br>\n"; flush();
 283 			
 284 			// search
 285 			$messages_a=iil_C_Search($conn, $folder, $criteria);
 286 			if ($messages_a!==false){
 287 				$total_num=count($messages_a);
 288 				if (is_array($messages_a)) $messages_str=implode(",", $messages_a);
 289 				else $messages_str="";
 290 				echo "found: {".$messages_str."} <br>\n"; flush();
 291 			}else{
 292 				echo "Error: ".$conn->error."<br>\n"; flush();
 293 			}
 294 		}else{
 295 			$headers=false;
 296 		}
 297 	}else{
 298 		$total_num=iil_C_CountMessages($conn, $folder);
 299 		if ($total_num > 0) $messages_str="1:".$total_num;
 300 		else $messages_str="";
 301 		$index_failed = false;		
 302 	}
 303 	
 304 	$clock->register("post count");
 305 	
 306 	echo "<!-- Total num: $total_num //-->\n"; flush();
 307 		
 308 		
 309 	/* if there are more messages than will be displayed,
 310 	 		create an index array, sort, 
 311 	 		then figure out which messages to fetch 
 312 	*/
 313 	if (($total_num - $num_show) > 0){
 314 		//attempt ot read from cache
 315 		$read_cache = false;
 316 		if (file_exists(realpath($CACHE_DIR))){
 317 			$cache_path = $CACHE_DIR.ereg_replace("[\\/]", "", $loginID.".".$host);
 318 			$index_a = main_ReadCache($cache_path, $folder, $messages_str, $sort_field, $read_cache);
 319 		}
 320 		//if there are "recent" messages, ignore cache
 321 	    if ($ICL_CAPABILITY["radar"]){
 322 			$recent=iil_C_CheckForRecent($conn, $folder);
 323 			if ($recent > 0) $read_cache = false;
 324 		}
 325 		
 326 		//if not read from cache, go to server
 327 		if (!$read_cache){
 328 			$index_a=iil_C_FetchHeaderIndex($conn, $folder, $messages_str, $sort_field);
 329 			$clock->register("post index: no cache");
 330 		}else{
 331 			$clock->register("post index: cache");
 332 		}
 333 		
 334 		if ($index_a===false){
 335 			//echo "iil_C_FetchHeaderIndex failed<br>\n";
 336             if (strcasecmp($sort_field,"date")==0){
 337                 if (strcasecmp($sort_order, "ASC")==0){
 338                     $messages_str = $start.":".($start + $num_show);
 339                 }else{
 340                     $messages_str = ($total_num - $start - $num_show).":".($total_num - $start);
 341                 }
 342                 //echo $messages_str; flush();
 343                 $index_failed = false;
 344             }else{
 345                 $index_failed = true;
 346             }
 347 		}else{
 348 			if ((!$read_cache) && (file_exists(realpath($CACHE_DIR))))
 349 				main_WriteCache($cache_path, $folder, $sort_field, $index_a, $messages_str);
 350 
 351 			if (strcasecmp($sort_order, "ASC")==0) asort($index_a);
 352 			else if (strcasecmp($sort_order, "DESC")==0) arsort($index_a);
 353 			
 354 			reset($index_a);
 355 			$i=0;
 356 			while (list($key, $val) = each ($index_a)){
 357 				if (($i >= $start) && ($i < $next_start)) $id_a[$i]=$key;
 358 				$i++;
 359 			}
 360 			if (is_array($id_a)) $messages_str=implode(",", $id_a);
 361 
 362 		}
 363 		
 364 		
 365 		echo "<!-- Indexed: $index_a //-->"; flush();
 366 	}
 367 	
 368 	$clock->register("post index");
 369 
 370 	/* fetch headers */
 371 	if ($messages_str!=""){
 372 		//echo "Messages: $messages_str <br>\n";
 373 		$headers=iil_C_FetchHeaders($conn, $folder, $messages_str);
 374 		$headers=iil_SortHeaders($headers, $sort_field, $sort_order);  //if not from index array
 375 	}else{
 376 		$headers=false;
 377 	}
 378 	
 379 	$clock->register("post headers");
 380 	echo "<!-- Headers fetched: $headers //-->\n"; flush();
 381 	
 382 	/* if indexing failed, we need to get messages within range */
 383 	if ($index_failed){
 384 		$i = 0;
 385 		$new_header_a=array();
 386 		reset($headers);
 387 		while ( list($k, $h) = each($headers) ){
 388 			if (($i >= $start) && ($i < $next_start)){
 389 				$new_header_a[$k] = $headers[$k];
 390 				//echo "<br>Showing $i : ".$h->id;
 391 			}
 392 			$i++;
 393 		}
 394 		$headers = $new_header_a;
 395 	}
 396 		
 397 	/*  start form */
 398 	echo "\n<form name=\"messages\" method=\"POST\" action=\"main.php\">\n";			
 399 
 400 	/* Show folder name, num messages, page selection pop-up */
 401 	
 402 	if ($headers==false) $headers=array();
 403 	echo "<table width=\"100%\" cellpadding=2 cellspacing=0><tr bgcolor=\"".$my_colors["main_head_bg"]."\">\n";
 404 	echo "<td align=left valign=bottom>\n";
 405 		$disp_folderName = $defaults[$folder];
 406 		if (empty($disp_folderName)){
 407 			$disp_folderName = $folder;
 408 			if (iil_StartsWith($disp_folderName, $my_prefs["rootdir"])){
 409 				$disp_folderName = substr($disp_folderName, strlen($my_prefs["rootdir"])+1);
 410 			}
 411 		}
 412 		if (empty($search)){
 413 			echo "<span class=\"bigTitle\">";
 414 			echo iil_utf7_decode($disp_folderName);
 415 			echo "</span>\n";
 416 		}
 417 		echo "<span class=\"mainHeadingSmall\">\n";
 418 		if (strcasecmp("INBOX", $folder)==0)
 419 			echo "[<a href=\"main.php?user=$user&folder=$folder\" class=\"mainHeadingSmall\">".$mainStrings[17]."</a>]";
 420         if (strcmp($folder,$my_prefs["trash_name"])!=0)
 421 			echo "[<a href=\"main.php?user=$user&folder=$folder&delete_all=1\" class=\"mainHeadingSmall\">".$mainStrings[18]."</a>]";
 422 		echo "</span>\n";
 423 	echo "</td>\n";
 424 	echo "<td align=\"right\" valign=\"bottom\" class=\"mainHeadingSmall\">";
 425 		//show quota
 426 		if ($my_prefs["show_quota"]=="m"){
 427 			$quota = iil_C_GetQuota($conn);
 428 			include("../lang/".$my_prefs["lang"]."quota.inc");
 429 			if ($quota) echo $quotaStr["label"].LangInsertStringsFromAK($quotaStr["full"], $quota);
 430 			else echo $quotaStr["label"].$quotaStr["unknown"];
 431 		}
 432 	echo "</td>\n";
 433 	echo "</tr></table>";
 434 	
 435 	/* Confirm "delete all" request */
 436 	if ($delete_all==1){
 437 		echo "<p>".str_replace("%f", $folder, $mainErrors[7]);
 438 		echo "<span class=\"small\">[<a href=\"main.php?user=$user&folder=$folder&delete_all=2&delete_all_num=$total_num&submit=Delete\">";
 439 			echo $mainStrings[18]."</a>]</span>";
 440 		echo "<span class=\"small\">[<a href=\"main.php?user=$user&folder=$folder\">".$mainStrings[19]."</a>]</span>";
 441 	}
 442 	
 443 	
 444 	/* Show error messages, and reports */
 445 	if (!empty($error)) echo "<p><center><span style=\"color: red\">$error</span></center>";
 446 	//if ((empty($error)) && (empty($report))) echo "<p>";
 447 
 448 
 449 	$c_date["day"]=GetCurrentDay();
 450 	$c_date["month"]=GetCurrentMonth();
 451 	$c_date["year"]=GetCurrentYear();
 452 
 453 	if (count($headers)>0) {
 454 		if (!isset($start)) $start=0;
 455 		$i=0;
 456 
 457 		if (sizeof($headers)>0){			
 458 			/*  show "To" field or "From" field? */
 459 			if ($folder==$my_prefs["sent_box_name"]){
 460 				$showto=true;
 461 				$fromheading=$mainStrings[7];
 462 			}else{
 463 				$fromheading=$mainStrings[8];
 464 			}			
 465 
 466 
 467 			/*  show num msgs and any notices */
 468 			echo "<table width=\"100%\"><tr>";
 469 			echo "<td valign=bottom align=\"left\"><span class=\"mainLightSmall\">";
 470 
 471 			echo str_replace("%p", ($num_show>$total_num?$total_num:$num_show), str_replace("%n", $total_num, $mainStrings[0]))."&nbsp;";
 472 			
 473 			echo "</span</td>";
 474 			echo "<td align=center><span class=\"mainLightSmall\">";
 475 			if (!empty($report)) echo $report;
 476 			echo "</span></td>\n";
 477 			echo "<td valign=bottom align=right class=\"mainLightSmall\">";
 478 			//page controls
 479 			$num_items=$total_num;
 480 			if ($num_items > $num_show){
 481 				if ($prev_start < $start){
 482 					$args = "&sort_field=$sort_field&sort_order=$sort_order&start=$prev_start";
 483 					if (!empty($search_criteria)) $args .= "&search_criteria=".urlencode($search_criteria);
 484 					echo "[<a href=\"main.php?user=$sid&folder=".urlencode($folder).$args."\" class=\"mainLightSmall\">";
 485 					echo $mainStrings[2]." $num_show".$mainStrings[3]."</a>]";
 486 				}
 487 
 488 				if ($next_start<$num_items){
 489 					$num_next_str = $num_show;
 490 					if (($num_items - $next_start) < $num_show) $num_next_str = $num_items - $next_start;
 491 					$args = "&sort_field=$sort_field&sort_order=$sort_order&start=$next_start";
 492 					if (!empty($search_criteria)) $args .= "&search_criteria=".urlencode($search_criteria);
 493 					echo "[<a href=\"main.php?user=$sid&folder=".urlencode($folder).$args."\" class=\"mainLightSmall\">";
 494 					echo $mainStrings[4]." $num_next_str".$mainStrings[5]."</a>]";
 495 				}
 496 
 497 				echo "<select name=start class=\"small\">\n";
 498 					$c=0;
 499 					while ($c < $total_num){
 500 						$c2=($c + $num_show);
 501 						if ($c2 > $total_num) $c2=$total_num;
 502 						echo "<option value=".$c.($c==$start?" SELECTED":"").">".($c+1)."-".$c2."\n";
 503 						$c = $c + $num_show;
 504 					}
 505 				echo "</select>";
 506 				echo "<input type=submit value=\"".$mainStrings[16]."\">";
 507 				
 508 			}
 509 			echo "</td>\n";
 510 			echo "</tr></table>\n";
 511 
 512 			$clock->register("pre list");
 513 
 514 			/***
 515 			Show tool bar
 516 			***/
 517 			if (strpos($my_prefs["main_toolbar"], "t")!==false){
 518 				include("../include/main_tools.inc");
 519 			}
 520 
 521 			/* main list */
 522 			$num_cols = strlen($my_prefs["main_cols"]);
 523 			echo "\n<!-- MAIN LIST //-->\n";
 524 			echo "<table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"1\" bgcolor=\"".$my_colors["main_hilite"]."\">\n";
 525 			echo "<tr bgcolor=\"".$my_colors["main_head_bg"]."\">\n";
 526 				$check_link="<SCRIPT type=\"text/javascript\" language=JavaScript1.2><!-- Make old browsers think this is a comment.\n";
 527 				$check_link.="document.write(\"<a href=javascript:SelectAllMessages(true) class='tblheader'><b>+</b></a><span class=tblheader>|</span><a href=javascript:SelectAllMessages(false) class=tblheader><b>-</b></a>\")";
 528 				$check_link.="\n--></SCRIPT><NOSCRIPT>";
 529 				$check_link.="<a href=\"main.php?folder=".urlencode($folder)."&start=$start&user=$user&sort_field=$sort_field&sort_order=$sort_order&check_all=1\"><b>+</b></a>|";
 530  				$check_link.="<a href=\"main.php?folder=".urlencode($folder)."&start=$start&user=$user&sort_field=$sort_field&sort_order=$sort_order&uncheck_all=1\"><b>-</b></a>";
 531 				$check_link.="</NOSCRIPT>";
 532 				$tbl_header["c"] = "\n<td>$check_link</td>";
 533 				$tbl_header["s"] = "\n<td>".FormFieldHeader("subject", $mainStrings[6])."</td>";
 534 				if ($showto)
 535 					$tbl_header["f"] = "\n<td>".FormFieldHeader("to", $fromheading)."</td>";
 536 				else
 537 					$tbl_header["f"] = "\n<td>".FormFieldHeader("from", $fromheading)."</td>";
 538 				$tbl_header["d"] = "\n<td>".FormFieldHeader("date", $mainStrings[9])."</td>";
 539 				$tbl_header["z"] = "\n<td>".FormFieldHeader("size", $mainStrings[14])."</td>";
 540 				$tbl_header["a"] = "<td><img src=\"themes/".$my_prefs["theme"]."/images/att.gif\"></td>";
 541 				$tbl_header["m"] = "<td><img src=\"themes/".$my_prefs["theme"]."/images/reply.gif\"></td>";
 542 				for ($i=0;$i<$num_cols;$i++) echo $tbl_header[$my_prefs["main_cols"][$i]];
 543 			echo "\n</tr>\n";
 544 			if ($MOVE_FIELDS){
 545 				echo "<tr bgcolor=\"".$my_colors["main_head_bg"]."\">\n";
 546 				$base_url = "main.php?folder=".urlencode($folder)."&start=$start&user=$user&sort_field=$sort_field&sort_order=$sort_order";
 547 				$base_url.= "&MOVE_FIELDS=1";
 548 				for ($i=0;$i<$num_cols;$i++) echo ShowFieldControls($my_prefs["main_cols"][$i], $base_url, $i, $num_cols);
 549 				echo "</tr>\n";
 550 			}
 551 			$display_i=0;
 552 			$prev_id = "";
 553 			while (list ($key,$val) = each ($headers)) {
 554 				//$next_id = $headers[key($headers)]->id;
 555 				$header = $headers[$key];
 556 				$id = $header->id;
 557 				$seen = ($header->seen?"Y":"N");
 558 				$deleted = ($header->deleted?"D":"");
 559 				$frstdeleted="";
 560 				$nextdeleted="";
 561 				if ($deleted=="D"){$frstdeleted="<strike>";$nextdeleted="</strike>";}
 562 				if (($id>0) && (($showdeleted==0)&&($deleted!="D")) || ($showdeleted)){
 563 					if (($hideseen==0)||($seen=="N")){
 564 						$display_i++;
 565 						//echo "\n<tr ".(($i % 2)==0?"bgcolor=\"$bgc\"":"").">\n";
 566 						
 567 						echo "\n<tr bgcolor=\"".$my_colors["main_bg"]."\">\n";
 568 						
 569 						//show checkbox
 570 						$row["c"] = "<td><input type=\"checkbox\" name=\"checkboxes[]\" value=\"$id\" ";
 571 						$row["c"].= (isset($check_all)?"CHECKED":"");
 572 						if (!isset($uncheck_all)) $row["c"].=(($spam) && (isSpam($header->Subject)>0) ? "CHECKED":"");
 573 						if (is_array($selected_boxes) && in_array($id, $selected_boxes)) $row["c"].="CHECKED";
 574 						$row["c"].= "></td>\n";
 575 						//echo $row["c"];
 576 						
 577 						//show subject
 578 						$subject=trim(chop($header->subject));
 579 						if (empty($subject)) $subject=$mainStrings[15];
 580 						$args = "user=$user&folder=".urlencode($folder)."&id=$id&uid=".$header->uid."&start=$start";
 581 						$args.= "&num_msgs=$total_num&sort_field=$sort_field&sort_order=$sort_order";
 582 						$row["s"] = "<td>".$frstdeleted."<a href=\"read_message.php?".$args."\" ";
 583 						$row["s"].= ($my_prefs["view_inside"]!=1?"target=\"scr".$user.urlencode($folder).$id."\"":"").">".($seen=="N"?"<B>":"");
 584 						$row["s"].= encodeUTFSafeHTML(LangDecodeSubject($subject, $my_prefs["charset"])).($seen=="N"?"</B>":"")."</a>".$nextdeleted."</td>\n";
 585 						//echo $row["s"];
 586 						
 587 						//show sender||recipient
 588 						if ($showto) $row["f"] = "<td>".LangDecodeAddressList($header->to, $my_prefs["charset"], $user)."</td>\n";						
 589 						else $row["f"] = "<td>".LangDecodeAddressList($header->from, $my_prefs["charset"], $user)."</td>\n";
 590 						//echo $row["f"];
 591 
 592 						//show date/time
 593 						$timestamp = $header->timestamp;
 594 						$timestamp = $timestamp + ((int)$my_prefs["timezone"] * 3600);
 595 						$row["d"] = "<td><nobr>".ShowShortDate($timestamp, $lang_datetime)."&nbsp;</nobr></td>\n";
 596 						//echo $row["d"];
 597 
 598 						//show size
 599 						$row["z"] = "<td><nobr>".ShowBytes($header->size)."</nobr></td>\n";
 600 
 601 						//attachments?
 602 						$row["a"] = "<td>";
 603 						if (preg_match("/multipart\/m/i", $header->ctype)==TRUE){
 604 							$row["a"].= "<img src=\"themes/".$my_prefs["theme"]."/images/att.gif\">";
 605 						}
 606 						$row["a"].= "</td>\n";
 607 						//echo $row["a"];
 608 
 609 						//show flags
 610 						$row["m"] = "<td>".($header->deleted?"D":"").($header->answered?"<img src=\"themes/".$my_prefs["theme"]."/images/reply.gif\">":"&nbsp;")."</td>\n";
 611 						//echo $row["a"];
 612 						
 613 						for ($i=0;$i<$num_cols;$i++) echo $row[$my_prefs["main_cols"][$i]];
 614 						
 615 						echo "</tr>\n";
 616 						flush();
 617 					}
 618 				}
 619 				$i++;
 620 			}
 621 			echo "</table>";
 622 
 623 			flush();
 624 			
 625 			$clock->register("post list: $i");
 626 			
 627 			echo "<input type=\"hidden\" name=\"user\" value=\"$user\">\n";
 628 			echo "<input type=\"hidden\" name=\"folder\" value=\"$folder\">\n";
 629 			echo "<input type=hidden name=\"sort_field\" value=\"".$sort_field."\">\n";
 630 			echo "<input type=hidden name=\"sort_order\" value=\"".$sort_order."\">\n";
 631 			if (isset($search)) echo "<input type=hidden name=search_done value=1>\n";
 632 			echo "<input type=\"hidden\" name=\"max_messages\" value=\"".$display_i."\">\n";
 633 			
 634 			/***
 635 			Show tool bar
 636 			***/
 637 			if (strpos($my_prefs["main_toolbar"], "b")!==false){
 638 				$clock->register("pre tools include");
 639 				include("../include/main_tools.inc");
 640 				$clock->register("post tools include");
 641 			}
 642 			
 643 			echo "</form>\n";
 644 			
 645 			if (($folder=="INBOX")&&($ICL_CAPABILITY["radar"])){
 646 				/*** THIS JavaScript code does NOT run reliably!! ***/
 647 				echo "\n<script language=\"JavaScript\">\n";
 648 				echo "if (parent.radar)";
 649 				echo "  parent.radar.location=\"radar.php?user=".$user."\";\n";
 650 				echo "</script>\n";
 651 			}
 652 			if (($ICL_CAPABILITY["folders"]) && ($my_prefs["list_folders"]) && ($my_prefs["showNumUnread"]) && ($reload_folders)){
 653 				echo "\n<script language=\"JavaScript\">\n";
 654 				echo "parent.list1.location=\"folders.php?user=".$user."\";\n";
 655 				echo "</script>\n";
 656 			}
 657 		}else{
 658 			if (!empty($search)) echo "<p><center>".$mainErrors[0]."</center>";
 659 			else echo "<p><center><span class=mainLight>".$mainErrors[1]."</span></center>";
 660 		}
 661 	}else{
 662 		if (!empty($search)) echo "<p><center><span class=mainLight>".$mainErrors[0]."</span></center>";
 663 		else echo "<p><center><span class=mainLight>".$mainErrors[1]."</span></center>";
 664 	}
 665 	
 666 	iil_Close($conn);
 667 
 668 $clock->register("done");
 669 $exec_finish_time = microtime();
 670 echo '<!-- execution time: '.$exec_start_time.' ~ '.$exec_finish_time.' -->';
 671 echo "\n<!--\n";
 672 $clock->dump();
 673 echo "\n//-->\n";
 674 ?>
 675 </BODY></HTML>

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2018-07-30 19:28:26, 23.4 KB) [[attachment:main.php]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.