--- a/lib/common.inc.php +++ b/lib/common.inc.php @@ -4,25 +4,31 @@ error_reporting(E_ALL ^ E_NOTICE); -$conn = new PDO("pgsql:dbname=contractDashboard;user=postgres;password=snmc;host=localhost"); - -if (!$conn) { - die("A database error occurred.\n"); -} +include('db.inc.php'); define('ROOT', pathinfo(__FILE__, PATHINFO_DIRNAME)); if (strstr($_SERVER['PHP_SELF'], "labs/") || strstr($_SERVER['PHP_SELF'], "admin/") || strstr($_SERVER['PHP_SELF'], "heuristics/")) { $basePath = "../"; } -if ($_SERVER['HTTP_HOST'] != "localhost") { -require $basePath."lib/amon-php/amon.php"; -Amon::config(array('address'=> 'http://127.0.0.1:2464', - 'protocol' => 'http', - 'secret_key' => "JBcSUdFOi5lK0vCjLjbHDpQamcBnRA4iV7QLaTADeDQ")); -Amon::setup_exception_handler(); -} - -require ROOT . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'openid.php'; +/*require ROOT . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'openid.php'; +require(ROOT.'/solarium/vendor/autoload.php'); +require(ROOT.'/solarium/library/Solarium/Autoloader.php'); +Solarium\Autoloader::register(); +// check solarium version available +//echo 'Solarium library version: ' . Solarium\Client::VERSION . ' - '; +$config = array( + 'endpoint' => array( + 'localhost' => array( + 'host' => '127.0.0.1', + 'port' => 8983, + 'path' => '/solr/contracts/', + ) + ) +); +// create a client instance +$solr_client = new Solarium\Client($config); + + $openid = new LightOpenID($_SERVER['HTTP_HOST']); // you have to open the session to be able to modify or remove it session_start(); @@ -51,24 +57,46 @@ } else { login(); } -} +}*/ // $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); function databaseError($errMsg) { if ($errMsg[2] != "") { echo '
"; } } - +function cleanseName($input) { + + return trim(join(" ",array_filter(explode(" ",strtolower($input)), function($v, $k) { + $cleanseNamesCorp = Array( + "ltd", + "limited", + "australia", + "australian", + "australasia", + "(aus)", + "(aust)", + "(australia)", + "the", + "pty", + "contractors", + "p/l", + "inc.", + "inc", + "incorporated" + ); + return !in_array($v,$cleanseNamesCorp) ; +}, ARRAY_FILTER_USE_BOTH))); +} function ucsmart($str) { $shortWords = Array("The", "Pty", "Ltd", "Inc", "Red", "Oil", "A", "An", "And", "At", "For", "In" , "Of", "On", "Or", "The", "To", "With"); - $strArray = explode(" ", preg_replace("/(?<=(? $value) $totale += array_sum_all($value); return $totale; +} + +function show_stats($stats) { + setlocale(LC_MONETARY, 'en_US'); + $value = number_format(doubleval($stats['total_value']) , 2); + echo "