コード例 #1
0
ファイル: core_debug.php プロジェクト: optiva/xGlide
 /**
  * Add an error to the debugger registry
  * @param string $type
  * @param string $value
  * @param mixed $data 
  */
 public function add($type, $value, $data)
 {
     $this->data[] = array('type' => $type, 'value' => $value, 'data' => $data);
     switch ($type) {
         case '403':
             // Use this to stop accessing core.php etc
             header('HTTP/1.1 403 Forbidden');
             require __DIR__ . '/../errors/error403.html';
             exit;
             break;
         case '404':
             // Use this for missing presenters
             header('HTTP/1.1 404 Not Found');
             require __DIR__ . '/../errors/error404.html';
             exit;
             break;
         case '500':
             // Use this for fails.
             if (!core_settings::i()->get('CONFIG_SETTINGS_DEBUG')) {
                 header('HTTP/1.1 500 Internal Server Error');
                 require __DIR__ . '/../errors/error500.html';
                 exit;
             }
             break;
         case 'xml':
             // Use this for parcial fails like xml errors et al.
             if (!core_settings::i()->get('CONFIG_SETTINGS_DEBUG')) {
                 require __DIR__ . '/../errors/errorxml.html';
                 exit;
             }
             break;
     }
 }
コード例 #2
0
ファイル: core_settings.php プロジェクト: optiva/xGlide
 public static function i()
 {
     if (self::$instance === null) {
         $c = __CLASS__;
         self::$instance = new $c();
     }
     return self::$instance;
 }
コード例 #3
0
ファイル: core_logging.php プロジェクト: optiva/xGlide
 public function write()
 {
     $log = fopen(core_settings::i()->get('CONFIG_SETTINGS_LOGFILE'), "a");
     if (count($this->data) > 0) {
         foreach ($this->data as $name => $value) {
             if (isset($_SESSION['user']->str_username)) {
                 fwrite($log, '[' . date('Y-m-d H:i:s') . ']:' . $_SESSION['user']->str_username . ': (' . $name . ')' . $this->prepare($value) . "\n");
             } else {
                 fwrite($log, '[' . date('Y-m-d H:i:s') . ']:default: (' . $name . ')' . $this->prepare($value) . "\n");
             }
         }
     }
 }
コード例 #4
0
ファイル: core_database.php プロジェクト: optiva/xGlide
 public function columns($table)
 {
     if (core_settings::i()->get('CONFIG_SETTINGS_DEBUG')) {
         $starttime = lib_datetime_microtime();
     }
     $store = array();
     $object_result = core_database::i()->query("\n\t\t\t\tselect * from `" . core_database::i()->real_escape_string($table) . "` LIMIT 1;\n\t\t\t");
     $object_fields = $object_result->fetch_fields();
     for ($i = 0; $i < count($object_fields); $i++) {
         $store[] = $object_fields[$i]->name;
     }
     if (core_settings::i()->get('CONFIG_SETTINGS_DEBUG')) {
         $endtime = lib_datetime_microtime();
         core_debug::i()->add('query', $query, round($endtime - $starttime, 6));
     }
     return $store;
 }
コード例 #5
0
ファイル: lib_text.php プロジェクト: optiva/xGlide
function string_keywords($string)
{
    // Returns csv string of most used words in a string.
    $string = strip_tags($string);
    $words = str_word_count($string, 1);
    $frequency = array_count_values($words);
    arsort($frequency);
    $array = array();
    $i = 0;
    foreach ($frequency as $key => $value) {
        if ($i == core_settings::i()->get('LANG_KEYWORDS_COUNT')) {
            break;
        }
        if (!in_array(strtolower($key), core_settings::i()->get('LANG_KEYWORDS_EXCLUDE'))) {
            $array[] = $key;
            $i++;
        }
    }
    return implode(", ", $array);
}
コード例 #6
0
ファイル: abstract_store.php プロジェクト: optiva/xGlide
 /**
  * Create record prototype
  */
 public function create(model $obj_data)
 {
     // <editor-fold defaultstate="collapsed" desc="BUILD QUERY">
     $pad = '                       ';
     $str_ident = '##' . get_called_class() . ' ' . __FUNCTION__ . '()' . " \n";
     $obj_data->sanitize();
     if (core_settings::i()->get('CONFIG_SETTINGS_DEVMODE')) {
         $array_columns = core_database::i()->columns(static::$db_table);
     }
     $array_fields = array();
     foreach (static::$db_columns as $str_fieldname => $str_fieldtype) {
         if (core_settings::i()->get('CONFIG_SETTINGS_DEVMODE')) {
             // check column really exists in dev mode
             if (!in_array($str_fieldname, $array_columns)) {
                 throw new Exception('Column "' . $str_fieldname . '" not allowed in "' . get_class($this) . '"');
             }
         }
         if (!empty($obj_data->{$str_fieldname})) {
             $array_fields[] = '`' . $str_fieldname . '`';
         }
     }
     $str_insert = 'INSERT INTO ' . static::$db_table . ' (' . implode(", ", $array_fields) . ") \n";
     $array_values = array();
     foreach (static::$db_columns as $str_fieldname => $str_fieldtype) {
         if (!empty($obj_data->{$str_fieldname})) {
             $array_values[] = $obj_data->{$str_fieldname};
         }
     }
     $str_values = 'VALUES (' . implode(", ", $array_values) . ')';
     // </editor-fold>
     // <editor-fold defaultstate="collapsed" desc="QUERY DATABASE">
     try {
         $this->array_result = core_database::i()->debug_query($str_insert . $pad . $str_values);
     } catch (Exception $e) {
         core_debug::i()->add('500', $e->getMessage(), '');
     }
     // </editor-fold>
 }
コード例 #7
0
ファイル: config.php プロジェクト: optiva/xGlide
 * @package xGlide
 * @version 3.0
 * @author Oliver Ridgway
 * @copyright Oliver Ridgway
 */
// Debugging
core_settings::i()->add('CONFIG_SETTINGS_DEBUG', true);
core_settings::i()->add('CONFIG_SETTINGS_DEVMODE', true);
// Logging
core_settings::i()->add('CONFIG_SETTINGS_LOGFILE', '/var/log/xGlide/action.log');
core_settings::i()->add('CONFIG_SETTINGS_LOGDAYS', NULL);
// Presenter Routing
core_settings::i()->add('CONFIG_SETTINGS_ROUTING', array());
// Page expiry in seconds
core_settings::i()->add('CONFIG_PAPER_EXPIRES', 600);
// Page expires in 5 minutes
// Name of the default presenter
core_settings::i()->add('CONFIG_SETTINGS_DEFAULTPRESENTER', 'default');
// Auth level
core_settings::i()->add('CONFIG_SETTINGS_AUTH', 0);
// Default Database settings
core_settings::i()->add('CONFIG_SERVERS_DATABASE_IP', $_SERVER["DB1_HOST"]);
core_settings::i()->add('CONFIG_SERVERS_DATABASE_USERNAME', $_SERVER["DB1_USER"]);
core_settings::i()->add('CONFIG_SERVERS_DATABASE_PASSWORD', $_SERVER["DB1_PASS"]);
core_settings::i()->add('CONFIG_SERVERS_DATABASE_DATABASE', $_SERVER["DB1_NAME"]);
core_settings::i()->add('CONFIG_SERVERS_DATABASE_PORT', $_SERVER["DB1_PORT"]);
// Hierarchy - You shouldn't normally need to change these
core_settings::i()->add('CONFIG_PAPER_ROOT', __DIR__ . '/../paper/');
core_settings::i()->add('CONFIG_PAPER_XSLT', __DIR__ . '/../paper/xsl/');
core_settings::i()->add('CONFIG_SITE_ROOT', '/');
コード例 #8
0
ファイル: core.php プロジェクト: optiva/xGlide
        }
    } else {
        // Can't find the presenter at all.
        // Show a 404
        core_debug::i()->add('404', 'File not found: ', __DIR__ . '/../../application/presenters/presenter_' . core_requests::i()->get('presenter') . '.php');
    }
}
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="DISPLAY RESULTS">
core_paper::i()->add($presenter->data);
core_paper::i()->template = core_requests::i()->get('presenter') . '.html';
core_paper::i()->display();
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="DEBUGGING + LOGGING">
if (core_settings::i()->get('CONFIG_SETTINGS_DEBUG')) {
    // Only display the debug data in xml or html files
    if (core_paper::i()->mime == 'text/html' && core_paper::i()->mime == 'text/xml') {
        print "<!--[\n\n";
        if (isset($_SESSION)) {
            print session_id() . "\n\n";
            print_r($_SESSION);
            print "\n\n";
        }
        print_r(core_debug::i()->get());
        print "\n]-->";
    }
}
if (core_settings::i()->get('CONFIG_SETTINGS_LOGFILE')) {
    core_logging::i()->write();
}
// </editor-fold>
コード例 #9
0
ファイル: core_paper.php プロジェクト: optiva/xGlide
 /**
  * Prints the Paper buffer to the screen 
  */
 public function display()
 {
     try {
         header('Content-Type: ' . $this->mime . '; charset=' . strtoupper($this->encoding) . '');
         header('Expires: ' . date('D, d M Y H:i:s ', time() + core_settings::i()->get('CONFIG_PAPER_EXPIRES')) . 'GMT');
         $handle = fopen($this->template, "r");
         $contents = fread($handle, filesize($this->template));
         fclose($handle);
         $find = array_keys($this->data);
         $replace = array_values($this->data);
         $xhtml = str_replace($find, $replace, $contents);
         print $xhtml;
     } catch (Exception $e) {
         core_debug::i()->add('500', $e->getMessage(), '');
     }
 }
コード例 #10
0
ファイル: core_xml.php プロジェクト: optiva/xGlide
 public final function create_html($array, $stylesheet)
 {
     $obj_xml = $this->generate_xml($array);
     $obj_stylesheet = new DOMDocument();
     $obj_stylesheet->load(core_settings::i()->get('CONFIG_PAPER_XSLT') . $stylesheet);
     $obj_xsl = new XSLTProcessor();
     $obj_xsl->registerPHPFunctions();
     $obj_xsl->importStyleSheet($obj_stylesheet);
     $str_xhtml = $obj_xsl->transformToXML($obj_xml);
     if (is_null($str_xhtml)) {
         $str_xhtml = "";
     }
     return $str_xhtml;
 }
コード例 #11
0
ファイル: core_auth.php プロジェクト: optiva/xGlide
 private final function connect_ntlm()
 {
     if (!isset($_SERVER['HTTP_AUTHORIZATION'])) {
         // step 1
         header("HTTP/1.1 401 Unauthorized");
         // step 2
         header("WWW-Authenticate: NTLM");
     }
     if (isset($_SERVER['HTTP_AUTHORIZATION']) && substr($_SERVER['HTTP_AUTHORIZATION'], 0, 5) == 'NTLM ') {
         $chaine = $_SERVER['HTTP_AUTHORIZATION'];
         $chaine = substr($chaine, 5);
         // type1 message
         $chained64 = base64_decode($chaine);
         if (ord($chained64[8]) == 1) {
             // step 3
             $retAuth = "NTLMSSP";
             $retAuth .= chr(0) . chr(2) . chr(0) . chr(0);
             $retAuth .= chr(0) . chr(0) . chr(0) . chr(0);
             $retAuth .= chr(0) . chr(40) . chr(0) . chr(0);
             $retAuth .= chr(0) . chr(1) . chr(130) . chr(0);
             $retAuth .= chr(0) . chr(0) . chr(2) . chr(2);
             $retAuth .= chr(2) . chr(0) . chr(0) . chr(0);
             $retAuth .= chr(0) . chr(0) . chr(0) . chr(0);
             $retAuth .= chr(0) . chr(0) . chr(0) . chr(0) . chr(0);
             $retAuth64 = base64_encode($retAuth);
             $retAuth64 = trim($retAuth64);
             header("HTTP/1.1 401 Unauthorized");
             // step 4
             header("WWW-Authenticate: NTLM {$retAuth64}");
         } else {
             if (ord($chained64[8]) == 3) {
                 // step 5
                 $lenght_domain = ord($chained64[31]) * 256 + ord($chained64[30]);
                 $offset_domain = ord($chained64[33]) * 256 + ord($chained64[32]);
                 $domain = substr($chained64, $offset_domain, $lenght_domain);
                 $lenght_login = ord($chained64[39]) * 256 + ord($chained64[38]);
                 $offset_login = ord($chained64[41]) * 256 + ord($chained64[40]);
                 $login = substr($chained64, $offset_login, $lenght_login);
                 $lenght_host = ord($chained64[47]) * 256 + ord($chained64[46]);
                 $offset_host = ord($chained64[49]) * 256 + ord($chained64[48]);
                 $host = substr($chained64, $offset_host, $lenght_host);
             }
         }
     }
     if (isset($login)) {
         $this->http_auth_complete = true;
         $username = preg_replace("/(.)(.)/", "\$1", $login);
         $domain = preg_replace("/(.)(.)/", "\$1", $domain);
         $username = strtolower($username);
         $domain = strtoupper($domain);
     }
     if (isset($username)) {
         $model_users = new model_users();
         $user = $model_users->auth($username);
         if (count($user) > 0 && $domain == core_settings::i()->get('CONFIG_AUTH_NTLM_DOMAIN')) {
             // if the user exists and there on the domain....
             $_SESSION = array();
             $_SESSION['users'] = $user[0];
             return true;
         } else {
             if (!($ad_connention = @ldap_connect(core_settings::i()->get('CONFIG_SERVERS_LDAP_IP')))) {
                 //return false;
             }
             ldap_set_option($ad_connention, LDAP_OPT_PROTOCOL_VERSION, 3);
             ldap_set_option($ad_connention, LDAP_OPT_REFERRALS, 0);
             if (!@ldap_bind($ad_connention, core_settings::i()->get('CONFIG_SERVERS_LDAP_BIND_USER') . core_settings::i()->get('CONFIG_SERVERS_LDAP_USER_SUFFIX'), core_settings::i()->get('CONFIG_SERVERS_LDAP_BIND_PASS'))) {
                 //return false;
             }
             $dn = "OU=Staff,OU=Users,OU=TC,DC=ad,DC=Trafford,DC=ac,DC=uk";
             $filter = '(|(sAMAccountName=' . $username . '*))';
             $justthese = array("givenName", "sn", "sAMAccountName", "title", "description", "department", "telephoneNumber", "physicalDeliveryOfficeName", "mail");
             $sr = ldap_search($ad_connention, $dn, $filter, $justthese);
             $info = ldap_get_entries($ad_connention, $sr);
             if ($info['count'] > 0) {
                 $user = new user_itrafford(NULL, isset($info[0]['samaccountname'][0]) ? $info[0]['samaccountname'][0] : '', 'firstvisit', isset($info[0]['givenname'][0]) ? $info[0]['givenname'][0] : '', isset($info[0]['sn'][0]) ? $info[0]['sn'][0] : '', 'staff', NULL, NULL, isset($info[0]['title'][0]) ? $info[0]['title'][0] : '', isset($info[0]['description'][0]) ? $info[0]['description'][0] : '', isset($info[0]['department'][0]) ? $info[0]['department'][0] : '', isset($info[0]['telephonenumber'][0]) ? $info[0]['telephonenumber'][0] : '', isset($info[0]['mail'][0]) ? $info[0]['mail'][0] : '', isset($info[0]['physicalDeliveryOfficeName'][0]) ? $info[0]['physicalDeliveryOfficeName'][0] : '', NULL);
                 $model_users->create($user);
                 return true;
             } else {
                 $dn = "OU=Students,OU=Users,OU=TC,DC=ad,DC=Trafford,DC=ac,DC=uk";
                 $filter = '(|(sAMAccountName=' . $username . '*))';
                 $justthese = array("givenName", "sn", "sAMAccountName", "title", "description", "department", "telephoneNumber", "physicalDeliveryOfficeName", "mail");
                 $sr = ldap_search($ad_connention, $dn, $filter, $justthese);
                 $info = ldap_get_entries($ad_connention, $sr);
                 if ($info['count'] > 0) {
                     $user = new user_itrafford(NULL, isset($info[0]['samaccountname'][0]) ? $info[0]['samaccountname'][0] : '', 'firstvisit', isset($info[0]['givenname'][0]) ? $info[0]['givenname'][0] : '', isset($info[0]['sn'][0]) ? $info[0]['sn'][0] : '', 'student', NULL, NULL, isset($info[0]['title'][0]) ? $info[0]['title'][0] : '', isset($info[0]['description'][0]) ? $info[0]['description'][0] : '', isset($info[0]['department'][0]) ? $info[0]['department'][0] : '', isset($info[0]['telephonenumber'][0]) ? $info[0]['telephonenumber'][0] : '', isset($info[0]['mail'][0]) ? $info[0]['mail'][0] : '', isset($info[0]['physicalDeliveryOfficeName'][0]) ? $info[0]['physicalDeliveryOfficeName'][0] : '', NULL);
                     $model_users->create($user);
                     return true;
                 }
             }
             return false;
         }
     } else {
         return false;
     }
 }
コード例 #12
0
ファイル: lang_en.php プロジェクト: optiva/xGlide
<?php

/**
 * Language Config
 *
 * @author Oliver Ridgway
 * @package xGlide
 * @version 3.0
 */
core_settings::i()->add('LANG_KEYWORDS_COUNT', 10);
core_settings::i()->add('LANG_KEYWORDS_EXCLUDE', array("a", "able", "about", "above", "abroad", "according", "accordingly", "across", "actually", "adj", "after", "afterwards", "again", "against", "ago", "ahead", "ain't", "all", "allow", "allows", "almost", "alone", "along", "alongside", "already", "also", "although", "always", "am", "amid", "amidst", "among", "amongst", "an", "and", "another", "any", "anybody", "anyhow", "anyone", "anything", "anyway", "anyways", "anywhere", "apart", "appear", "appreciate", "appropriate", "are", "aren't", "around", "as", "a's", "aside", "ask", "asking", "associated", "at", "available", "away", "awfully", "b", "back", "backward", "backwards", "be", "became", "because", "become", "becomes", "becoming", "been", "before", "beforehand", "begin", "behind", "being", "believe", "below", "beside", "besides", "best", "better", "between", "beyond", "both", "brief", "but", "by", "c", "came", "can", "cannot", "cant", "can't", "caption", "cause", "causes", "certain", "certainly", "changes", "clearly", "c'mon", "co", "co.", "com", "come", "comes", "concerning", "consequently", "consider", "considering", "contain", "containing", "contains", "corresponding", "could", "couldn't", "course", "c's", "currently", "d", "dare", "daren't", "definitely", "described", "despite", "did", "didn't", "different", "directly", "do", "does", "doesn't", "doing", "done", "don't", "down", "downwards", "during", "e", "each", "edu", "eg", "eight", "eighty", "either", "else", "elsewhere", "end", "ending", "enough", "entirely", "especially", "et", "etc", "even", "ever", "evermore", "every", "everybody", "everyone", "everything", "everywhere", "ex", "exactly", "example", "except", "f", "fairly", "far", "farther", "few", "fewer", "fifth", "first", "five", "followed", "following", "follows", "for", "forever", "former", "formerly", "forth", "forward", "found", "four", "from", "further", "furthermore", "g", "get", "gets", "getting", "given", "gives", "go", "goes", "going", "gone", "got", "gotten", "greetings", "h", "had", "hadn't", "half", "happens", "hardly", "has", "hasn't", "have", "haven't", "having", "he", "he'd", "he'll", "hello", "help", "her", "here", "hereafter", "hereby", "herein", "here's", "hereupon", "hers", "herself", "he's", "hi", "him", "himself", "his", "hither", "hopefully", "how", "howbeit", "however", "hundred", "i", "i'd", "ie", "if", "ignored", "i'll", "i'm", "immediate", "in", "inasmuch", "inc", "inc.", "indeed", "indicate", "indicated", "indicates", "inner", "inside", "insofar", "instead", "into", "inward", "is", "isn't", "it", "it'd", "it'll", "its", "it's", "itself", "i've", "j", "just", "k", "keep", "keeps", "kept", "know", "known", "knows", "l", "last", "lately", "later", "latter", "latterly", "least", "less", "lest", "let", "let's", "like", "liked", "likely", "likewise", "little", "look", "looking", "looks", "low", "lower", "ltd", "m", "made", "mainly", "make", "makes", "many", "may", "maybe", "mayn't", "me", "mean", "meantime", "meanwhile", "merely", "might", "mightn't", "mine", "minus", "miss", "more", "moreover", "most", "mostly", "mr", "mrs", "much", "must", "mustn't", "my", "myself", "n", "name", "namely", "nd", "near", "nearly", "necessary", "need", "needn't", "needs", "neither", "never", "neverf", "neverless", "nevertheless", "new", "next", "nine", "ninety", "no", "nobody", "non", "none", "nonetheless", "noone", "no-one", "nor", "normally", "not", "nothing", "notwithstanding", "novel", "now", "nowhere", "o", "obviously", "of", "off", "often", "oh", "ok", "okay", "old", "on", "once", "one", "ones", "one's", "only", "onto", "opposite", "or", "other", "others", "otherwise", "ought", "oughtn't", "our", "ours", "ourselves", "out", "outside", "over", "overall", "own", "p", "particular", "particularly", "past", "per", "perhaps", "placed", "please", "plus", "possible", "presumably", "probably", "provided", "provides", "q", "que", "quite", "qv", "r", "rather", "rd", "re", "really", "reasonably", "recent", "recently", "regarding", "regardless", "regards", "relatively", "respectively", "right", "round", "s", "said", "same", "saw", "say", "saying", "says", "second", "secondly", "seeing", "seem", "seemed", "seeming", "seems", "seen", "self", "selves", "sensible", "sent", "serious", "seriously", "seven", "several", "shall", "shan't", "she", "she'd", "she'll", "she's", "should", "shouldn't", "since", "six", "so", "some", "somebody", "someday", "somehow", "someone", "something", "sometime", "sometimes", "somewhat", "somewhere", "soon", "sorry", "specified", "specify", "specifying", "still", "sub", "such", "sup", "sure", "t", "take", "taken", "taking", "tell", "tends", "th", "than", "thank", "thanks", "thanx", "that", "that'll", "thats", "that's", "that've", "the", "their", "theirs", "them", "themselves", "then", "thence", "there", "thereafter", "thereby", "there'd", "therefore", "therein", "there'll", "there're", "theres", "there's", "thereupon", "there've", "these", "they", "they'd", "they'll", "they're", "they've", "thing", "things", "think", "third", "thirty", "this", "thorough", "thoroughly", "those", "though", "three", "through", "throughout", "thru", "thus", "till", "to", "together", "too", "took", "toward", "towards", "tried", "tries", "truly", "try", "trying", "t's", "twice", "two", "u", "un", "under", "underneath", "undoing", "unfortunately", "unless", "unlike", "unlikely", "until", "unto", "up", "upon", "upwards", "us", "use", "used", "useful", "uses", "using", "usually", "v", "value", "various", "versus", "very", "via", "viz", "vs", "w", "want", "wants", "was", "wasn't", "way", "we", "we'd", "welcome", "well", "we'll", "went", "were", "we're", "weren't", "we've", "what", "whatever", "what'll", "what's", "what've", "when", "whence", "whenever", "where", "whereafter", "whereas", "whereby", "wherein", "where's", "whereupon", "wherever", "whether", "which", "whichever", "while", "whilst", "whither", "who", "who'd", "whoever", "whole", "who'll", "whom", "whomever", "who's", "whose", "why", "will", "willing", "wish", "with", "within", "without", "wonder", "won't", "would", "wouldn't", "x", "y", "yes", "yet", "you", "you'd", "you'll", "your", "you're", "yours", "yourself", "yourselves", "you've", "z", "zero"));