CMS  Version 3.9
scan.inc
Go to the documentation of this file.
1 <?php
2 /**************************************************************
3 
4  Copyright (c) 2010 Sonjara, Inc
5 
6  Permission is hereby granted, free of charge, to any person
7  obtaining a copy of this software and associated documentation
8  files (the "Software"), to deal in the Software without
9  restriction, including without limitation the rights to use,
10  copy, modify, merge, publish, distribute, sublicense, and/or sell
11  copies of the Software, and to permit persons to whom the
12  Software is furnished to do so, subject to the following
13  conditions:
14 
15  The above copyright notice and this permission notice shall be
16  included in all copies or substantial portions of the Software.
17 
18  Except as contained in this notice, the name(s) of the above
19  copyright holders shall not be used in advertising or otherwise
20  to promote the sale, use or other dealings in this Software
21  without prior written authorization.
22 
23  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
25  OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
27  HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
28  WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
30  OTHER DEALINGS IN THE SOFTWARE.
31 
32 *****************************************************************/
33 
34 if (!checkRole("admin") && $_SERVER["REMOTE_ADDR"] != $_SERVER["SERVER_ADDR"]
35  && $_SERVER["REMOTE_ADDR"] != gethostbyname($config['http_host'])
36  && $_SERVER["REMOTE_ADDR"] != "127.0.0.1")
37 {
38  throw new FakoliException("Anonymous component scans cannot be run from {$_SERVER["REMOTE_ADDR"]}");
39 }
40 
41 if ($_SERVER["REMOTE_ADDR"] == "127.0.0.1" && array_key_exists("clear", $_GET))
42 {
43  $db = ConnectionManager::getConnection();
44  $db->exec("TRUNCATE TABLE component");
45 
46  Cache::invalidate("fakoli_components");
47 }
48 
49 $verbosity = checkNumeric($_GET["verbosity"]);
51 $plain = checkNumeric($_GET["plain"]);
53 
55 
56 try
57 {
58  $mgr = new ComponentManager();
59  $mgr->scan();
60 }
61 catch(Exception $e)
62 {
63  if (checkRole("admin"))
64  {
65  throw $e;
66  }
67  else
68  {
69  echo $e->getMessage();
70  }
71 }
72 
73 if (checkRole("admin"))
74 {
75  redirect("/admin/components");
76 }
77 else
78 {
79  echo "Scan Complete\n";
80 }
81 
82 ?>
ComponentManager provides the core functionality for building the component map describing the applic...
static $verbosityLevel
Verbosity level for component scan (same as trace level)
static $plainOutput
Set to true for plain text output during component scan.
FakoliException is the base exception class for all Fakoli errors.
Definition: core.inc:53
static $rollbackBuffers
Specifies whether to rollback output buffers when there is an unhandled exception.
Definition: core.inc:84
if(!checkRole("admin") && $_SERVER["REMOTE_ADDR"] !=$_SERVER["SERVER_ADDR"] && $_SERVER["REMOTE_ADDR"] !=gethostbyname($config['http_host']) && $_SERVER["REMOTE_ADDR"] !="127.0.0.1") if($_SERVER["REMOTE_ADDR"]=="127.0.0.1" &&array_key_exists("clear", $_GET)) $verbosity
Definition: scan.inc:49
if($verbosity) ComponentManager $plain
Definition: scan.inc:51
global $config
Definition: import.inc:4
$db