1 | <?php |
---|
2 | |
---|
3 | class init_functions |
---|
4 | { |
---|
5 | var $public_functions = array ( 'init_expressoMail' => True ); |
---|
6 | |
---|
7 | |
---|
8 | function init_functions (){ |
---|
9 | } |
---|
10 | |
---|
11 | function _preferences_and_msgs() |
---|
12 | { |
---|
13 | $f = fopen($_SESSION['tempdir'].'get_preferences',"w"); |
---|
14 | include_once('class.functions.inc.php'); |
---|
15 | $functions = new Functions; |
---|
16 | $preferences = $functions->get_preferences(); |
---|
17 | fwrite($f,serialize($preferences)); |
---|
18 | fclose($f); |
---|
19 | include_once('class.imap_functions.inc.php'); |
---|
20 | $imap_functions = new imap_functions; |
---|
21 | $get_range_params = array( |
---|
22 | 'folder' => 'INBOX', |
---|
23 | 'msg_range_begin' => 1, |
---|
24 | 'msg_range_end' => $preferences['max_email_per_page'], |
---|
25 | 'sort_box_type' => 'SORTARRIVAL', |
---|
26 | 'search_box_type' => 'ALL', |
---|
27 | 'sort_box_reverse' => 1 |
---|
28 | ); |
---|
29 | $f = fopen($_SESSION['tempdir'].'get_range_msgs',"w"); |
---|
30 | fwrite($f,serialize($imap_functions->get_range_msgs($get_range_params))); |
---|
31 | fclose($f); |
---|
32 | } |
---|
33 | |
---|
34 | function _folders() |
---|
35 | { |
---|
36 | $f = fopen($_SESSION['tempdir'].'get_folders_list',"w"); |
---|
37 | include_once('class.imap_functions.inc.php'); |
---|
38 | $imap_functions = new imap_functions; |
---|
39 | fwrite($f,serialize($imap_functions->get_folders_list())); |
---|
40 | fclose($f); |
---|
41 | } |
---|
42 | function _dropcontacts() |
---|
43 | { |
---|
44 | $f = fopen($_SESSION['tempdir'].'get_dropdown_contacts',"w"); |
---|
45 | include_once('class.db_functions.inc.php'); |
---|
46 | $db_functions = new db_functions; |
---|
47 | fwrite($f,$db_functions->get_dropdown_contacts()); |
---|
48 | fclose($f); |
---|
49 | sleep(10); |
---|
50 | } |
---|
51 | |
---|
52 | function init_expressoMail() |
---|
53 | { |
---|
54 | $_SESSION['tempdir'] = ini_get("session.save_path"); |
---|
55 | $pid_arr = array(); |
---|
56 | ob_end_flush(); |
---|
57 | $fork_functions = array('0' => $this->_dropcontacts, '1' => $this->_folders, '2' => $this->_preferences_and_msgs); |
---|
58 | foreach ($fork_functions as $i => $ifunction) |
---|
59 | { |
---|
60 | $pid = pcntl_fork(); |
---|
61 | if ($pid == -1) { |
---|
62 | die('could not fork'); |
---|
63 | } else if ($pid) { |
---|
64 | $pid_arr[$i] = $pid; |
---|
65 | } |
---|
66 | else |
---|
67 | { |
---|
68 | $ifunction(); |
---|
69 | return; |
---|
70 | } |
---|
71 | } |
---|
72 | foreach ($pid_arr as $pid) |
---|
73 | pcntl_waitpid($pid, $status); |
---|
74 | |
---|
75 | $f = fopen($_SESSION['tempdir'].'get_dropdown_contacts',"r"); |
---|
76 | $return['get_dropdown_contacts'] = fread($f, filesize($_SESSION['tempdir'].'get_dropdown_contacts')); |
---|
77 | $f = fopen($_SESSION['tempdir'].'get_preferences',"r"); |
---|
78 | $return['get_preferences'] = fread($f, filesize($_SESSION['tempdir'].'get_preferences')); |
---|
79 | $f = fopen($_SESSION['tempdir'].'get_range_msgs',"r"); |
---|
80 | $return['get_range_msgs'] = fread($f, filesize($_SESSION['tempdir'].'get_range_msgs')); |
---|
81 | $f = fopen($_SESSION['tempdir'].'get_folders_list',"r"); |
---|
82 | $return['get_folders_list'] = fread($f, filesize($_SESSION['tempdir'].'get_folders_list')); |
---|
83 | return $return; |
---|
84 | } |
---|
85 | } |
---|
86 | ?> |
---|