pull of unix socket to interact with apache2
[brisk.git] / web / spush / brisk-spush.php
1 #!/usr/bin/php
2 <?php
3 /*
4  *  brisk - spush/brisk-spush.php
5  *
6  *  Copyright (C) 2012 Matteo Nastasi
7  *                          mailto: nastasi@alternativeoutput.it 
8  *                                  matteo.nastasi@milug.org
9  *                          web: http://www.alternativeoutput.it
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful, but
17  * WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABLILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  * General Public License for more details. You should have received a
20  * copy of the GNU General Public License along with this program; if
21  * not, write to the Free Software Foundation, Inc, 59 Temple Place -
22  * Suite 330, Boston, MA 02111-1307, USA.
23  *
24  */
25
26 $G_base = "../";
27
28 require_once($G_base."Obj/sac-a-push.phh");
29 require_once("./brisk-spush.phh");
30 require_once($G_base."Obj/user.phh");
31 @include_once($G_base."Obj/curl-de-brisk.phh");
32 require_once($G_base."Obj/brisk.phh");
33 require_once($G_base."Obj/auth.phh");
34 require_once($G_base."Obj/zlibstream.phh");
35 require_once($G_base."Obj/mail.phh");
36 require_once($G_base."Obj/provider_proxy.phh");
37 require_once($G_base."index.php");
38 require_once($G_base."index_wr.php");
39 require_once($G_base."briskin5/Obj/briskin5.phh");
40 require_once($G_base."briskin5/index.php");
41 require_once($G_base."briskin5/index_wr.php");
42
43 if (FALSE) {
44 function my_e($number, $msg, $file, $line, $vars) {
45     print_r(debug_backtrace());
46     die();
47 }
48
49 function my_for_fatal()
50 {
51     // $error = error_get_last();
52     // if ( $error["type"] == E_ERROR ) {
53         print_r(debug_backtrace());
54         die();
55         // }
56     //   log_error( $error["type"], $error["message"], $error["file"], $error["line"] );
57 }
58
59 register_shutdown_function( "my_for_fatal" );
60 set_error_handler('my_e');
61 }
62
63 function main($argv)
64 {
65     GLOBAL $G_ban_list, $G_black_list, $G_cloud_smasher, $G_provider_proxy;
66
67     pid_save();
68     do {
69         if (($brisk = Brisk::create(LEGAL_PATH."/brisk-crystal.data", $G_ban_list, $G_black_list, $G_cloud_smasher)) == FALSE) {
70             log_crit("Brisk::create failed");
71             $ret = 1;
72             break;
73         }
74
75         if (($s_a_p = Sac_a_push::create($brisk, USOCK_PATH_PFX, 0, 0, $G_provider_proxy, $argv)) === FALSE) {
76             $ret = 2;
77             break;
78         }
79
80         $ret = $s_a_p->run();
81     } while (0);
82
83     pid_remove();
84     exit($ret);
85 }
86
87 main($argv);
88 ?>