Example #1
0
 /**
  *
  * @return string
  */
 public function showComponents()
 {
     $html = '';
     foreach (KitComponent::getAllByCriteria('kitId=?', array($this->kit->getId())) as $index => $kitComponent) {
         $html .= $this->getRow($kitComponent->getQty(), $kitComponent->getComponent()->getSku(), $kitComponent->getComponent()->getName(), 'itemRow');
     }
     return $html;
 }
Example #2
0
 public function __construct(database $db, User $user, $menu)
 {
     $this->db =& $db;
     $this->user =& $user;
     $this->ajax = Kit::GetParam('ajax', _REQUEST, _BOOL, false);
     $this->q = Kit::GetParam('q', _REQUEST, _WORD);
     $this->userid = Kit::GetParam('userid', _SESSION, _INT);
     $usertypeid = Kit::GetParam('usertype', _SESSION, _INT);
     if ($menu == '') {
         $this->message = __('No menu provided');
         return false;
     }
     if (!($this->theMenu = $user->MenuAuth($menu))) {
         $this->message = __('No permissions for this menu.');
         return false;
     }
     // Set some information about this menu
     $this->current = 0;
     $this->numberItems = count($this->theMenu);
     // We dont want to do 0 items
     if ($this->numberItems == 0) {
         $this->numberItems = -1;
     }
     $this->message = $this->numberItems . ' menu items loaded';
     return true;
 }
 public function __construct()
 {
     // Determine if this is an AJAX call or not
     $this->ajax = Kit::GetParam('ajax', _REQUEST, _BOOL, false);
     // Assume success
     $this->success = true;
     $this->clockUpdate = false;
     $this->focusInFirstInput = true;
     $this->appendHiddenSubmit = true;
     $this->uniqueReference = '';
     $this->buttons = '';
     $this->pageSize = 10;
     $this->pageNumber = 0;
     $this->initialSortColumn = 1;
     $this->initialSortOrder = 1;
     $this->modal = false;
     $this->extra = array();
     $this->dialogClass = '';
     // Start a DB transaction for all returns from the Web Portal
     try {
         $dbh = PDOConnect::init();
         if (!$dbh->inTransaction()) {
             $dbh->beginTransaction();
         }
     } catch (Exception $e) {
         Debug::LogEntry('error', $e->getMessage());
         trigger_error(__('Unable to open connection and start transaction'), E_USER_ERROR);
     }
     return true;
 }
 public function Add($dataSetId, $heading, $dataTypeId, $listContent, $columnOrder = 0, $dataSetColumnTypeId = 1, $formula = '')
 {
     Debug::LogEntry('audit', sprintf('IN - DataSetID = %d', $dataSetId), 'DataSetColumn', 'Add');
     try {
         $dbh = PDOConnect::init();
         // Is the column order provided?
         if ($columnOrder == 0) {
             $SQL = "";
             $SQL .= "SELECT IFNULL(MAX(ColumnOrder), 1) AS ColumnOrder ";
             $SQL .= "  FROM datasetcolumn ";
             $SQL .= "WHERE datasetID = :datasetid ";
             $sth = $dbh->prepare($SQL);
             $sth->execute(array('datasetid' => $dataSetId));
             if (!($row = $sth->fetch())) {
                 return $this->SetError(25005, __('Could not determine the Column Order'));
             }
             $columnOrder = Kit::ValidateParam($row['ColumnOrder'], _INT);
         }
         // Insert the data set column
         $SQL = "INSERT INTO datasetcolumn (DataSetID, Heading, DataTypeID, ListContent, ColumnOrder, DataSetColumnTypeID, Formula) ";
         $SQL .= "    VALUES (:datasetid, :heading, :datatypeid, :listcontent, :columnorder, :datasetcolumntypeid, :formula) ";
         $sth = $dbh->prepare($SQL);
         $sth->execute(array('datasetid' => $dataSetId, 'heading' => $heading, 'datatypeid' => $dataTypeId, 'listcontent' => $listContent, 'columnorder' => $columnOrder, 'datasetcolumntypeid' => $dataSetColumnTypeId, 'formula' => $formula));
         $id = $dbh->lastInsertId();
         Debug::LogEntry('audit', 'Complete', 'DataSetColumn', 'Add');
         return $id;
     } catch (Exception $e) {
         Debug::LogEntry('error', $e->getMessage());
         return $this->SetError(25005, __('Could not add DataSet Column'));
     }
 }
Example #5
0
 protected function handle_form_data($file, $index)
 {
     // Handle form data, e.g. $_REQUEST['description'][$index]
     // Link the file to the module
     $name = $_REQUEST['name'][$index];
     $duration = $_REQUEST['duration'][$index];
     $layoutId = Kit::GetParam('layoutid', _REQUEST, _INT);
     $type = Kit::GetParam('type', _REQUEST, _WORD);
     Debug::LogEntry('audit', 'Upload complete for Type: ' . $type . ' and file name: ' . $file->name . '. Name: ' . $name . '. Duration:' . $duration);
     // We want to create a module for each of the uploaded files.
     // Do not pass in the region ID so that we only assign to the library and not to the layout
     try {
         $module = ModuleFactory::createForLibrary($type, $layoutId, $this->options['db'], $this->options['user']);
     } catch (Exception $e) {
         $file->error = $e->getMessage();
         exit;
     }
     // We want to add this item to our library
     if (!($storedAs = $module->AddLibraryMedia($file->name, $name, $duration, $file->name))) {
         $file->error = $module->GetErrorMessage();
     }
     // Set new file details
     $file->storedas = $storedAs;
     // Delete the file
     @unlink($this->get_upload_path($file->name));
 }
Example #6
0
 function __construct(database $db, user $user)
 {
     $this->db =& $db;
     $this->user =& $user;
     $this->layoutid = Kit::GetParam('layoutid', _REQUEST, _INT);
     // Include the layout data class
     include_once "lib/data/layout.data.class.php";
     //if we have modify selected then we need to get some info
     if ($this->layoutid != '') {
         // get the permissions
         Debug::LogEntry('audit', 'Loading permissions for layoutid ' . $this->layoutid);
         $this->auth = $user->LayoutAuth($this->layoutid, true);
         if (!$this->auth->view) {
             trigger_error(__("You do not have permissions to view this layout"), E_USER_ERROR);
         }
         $sql = " SELECT layout, description, userid, retired, tags, xml FROM layout ";
         $sql .= sprintf(" WHERE layoutID = %d ", $this->layoutid);
         if (!($results = $db->query($sql))) {
             trigger_error($db->error());
             trigger_error(__("Cannot retrieve the Information relating to this layout. The layout may be corrupt."), E_USER_ERROR);
         }
         if ($db->num_rows($results) == 0) {
             $this->has_permissions = false;
         }
         while ($aRow = $db->get_row($results)) {
             $this->layout = Kit::ValidateParam($aRow[0], _STRING);
             $this->description = Kit::ValidateParam($aRow[1], _STRING);
             $this->retired = Kit::ValidateParam($aRow[3], _INT);
             $this->tags = Kit::ValidateParam($aRow[4], _STRING);
             $this->xml = $aRow[5];
         }
     }
 }
Example #7
0
 public function ValidateQuestion($questionNumber, $response)
 {
     switch ($questionNumber) {
         case 0:
             if (Kit::ValidateParam($response, _BOOL)) {
                 $this->a[0] = "Protected";
             } else {
                 $this->a[0] = "Off";
             }
             return true;
         case 1:
             $this->a[1] = Kit::ValidateParam($response, _INT, 30);
             return true;
         case 2:
             $this->a[2] = Kit::ValidateParam($response, _INT, 30);
             return true;
         case 3:
             $this->a[3] = Kit::ValidateParam($response, _BOOL);
             return true;
         case 4:
             // TODO: Teach Kit how to validate email addresses?
             $this->a[4] = Kit::ValidateParam($response, _PASSWORD);
             return true;
         case 5:
             // TODO: Teach Kit how to validate email addresses?
             $this->a[5] = Kit::ValidateParam($response, _PASSWORD);
             return true;
         case 6:
             $this->a[6] = Kit::ValidateParam($response, _INT, 12);
             return true;
     }
     return false;
 }
Example #8
0
 function displayPage()
 {
     $db =& $this->db;
     $user =& $this->user;
     $error = Kit::GetParam('ErrorMessage', _SESSION, _HTMLSTRING, __('Unknown Error'));
     Theme::Set('ErrorMessage', $error);
     Theme::Render('error');
 }
Example #9
0
 function displayPage()
 {
     $db =& $this->db;
     $user =& $this->user;
     $error = Kit::GetParam('ErrorMessage', _SESSION, _HTMLSTRING, __('Unknown Error'));
     echo __('There has been an application error.');
     echo $error;
     exit;
 }
Example #10
0
 public function ValidateQuestion($questionNumber, $response)
 {
     switch ($questionNumber) {
         case 0:
             $this->a[0] = Kit::ValidateParam($response, _BOOL);
             return true;
     }
     return false;
 }
Example #11
0
 public static function coreStop($message)
 {
     $title = 'Oops';
     $error = \Kit::translateSystemError($message);
     if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) and $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') {
         \Components\XHR::returnError($error);
     }
     exit(include KIT_CORE . '/Etc/SystemTpl/Exception.php');
 }
Example #12
0
 /**
 * Constructor
 *
 * @param type $source
 *   (Optional) Defaults to NULL. Can be a string, in which case you need to
     set $is_file to FALSE.  Otherwise the string should be a path to a file.
   @param bool $is_file
 */
 public function __construct($source = NULL, $is_file = TRUE)
 {
     $this->dirname = '';
     if ($source && $is_file) {
         $info = pathinfo($source);
         $this->dirname = $info['dirname'];
     }
     parent::__construct($source, $is_file);
     $this->imports = array();
 }
 /**
  * Gets and Sets the Local 
  * @return 
  */
 public static function InitLocale()
 {
     $localeDir = 'locale';
     $default = Config::GetSetting('DEFAULT_LANGUAGE');
     global $transEngine;
     global $stream;
     //Debug::LogEntry('audit', 'IN', 'TranslationEngine', 'InitLocal');
     // Try to get the local firstly from _REQUEST (post then get)
     $lang = Kit::GetParam('lang', _REQUEST, _WORD, '');
     // Build an array of supported languages
     $supportedLangs = scandir($localeDir);
     if ($lang != '') {
         // Set the language
         Debug::LogEntry('audit', 'Set the Language from REQUEST [' . $lang . ']', 'TranslationEngine', 'InitLocal');
         // Is this language supported?
         // if not just use the default (eb_GB).
         if (!in_array($lang . '.mo', $supportedLangs)) {
             trigger_error(sprintf('Language not supported. %s', $lang));
             // Use the default language instead.
             $lang = $default;
         }
     } else {
         $langs = Kit::GetParam('HTTP_ACCEPT_LANGUAGE', $_SERVER, _STRING);
         if ($langs != '') {
             //Debug::LogEntry('audit', ' HTTP_ACCEPT_LANGUAGE [' . $langs . ']', 'TranslationEngine', 'InitLocal');
             $langs = explode(',', $langs);
             foreach ($langs as $lang) {
                 // Remove any quality rating (as we aren't interested)
                 $rawLang = explode(';', $lang);
                 $lang = str_replace("-", "_", $rawLang[0]);
                 if (in_array($lang . '.mo', $supportedLangs)) {
                     //Debug::LogEntry('audit', 'Obtained the Language from HTTP_ACCEPT_LANGUAGE [' . $lang . ']', 'TranslationEngine', 'InitLocal');
                     break;
                 }
                 // Set lang as the default
                 $lang = $default;
             }
         } else {
             $lang = $default;
         }
     }
     // We have the language
     //Debug::LogEntry('audit', 'Creating new file streamer for '. $localeDir . '/' . $lang . '.mo', 'TranslationEngine', 'InitLocal');
     if (!($stream = new CachedFileReader($localeDir . '/' . $lang . '.mo'))) {
         trigger_error('Unable to translate this language');
         $transEngine = false;
         return;
     }
     $transEngine = new gettext_reader($stream);
 }
Example #14
0
 /**
  * Audit Log
  * @param string $entity
  * @param int $entityId
  * @param string $message
  * @param string|object|array $object
  */
 public static function audit($entity, $entityId, $message, $object)
 {
     \Debug::Audit(sprintf('Audit Trail message recorded for %s with id %d. Message: %s', $entity, $entityId, $message));
     if (self::$_auditLogStatement == null) {
         $dbh = \PDOConnect::newConnection();
         self::$_auditLogStatement = $dbh->prepare('
             INSERT INTO `auditlog` (logDate, userId, entity, message, entityId, objectAfter)
               VALUES (:logDate, :userId, :entity, :message, :entityId, :objectAfter)
         ');
     }
     // If we aren't a string then encode
     if (!is_string($object)) {
         $object = json_encode($object);
     }
     self::$_auditLogStatement->execute(array('logDate' => time(), 'userId' => \Kit::GetParam('userid', _SESSION, _INT, 0), 'entity' => $entity, 'message' => $message, 'entityId' => $entityId, 'objectAfter' => $object));
 }
 /**
  * Unlink all media from the provided media item
  * @param int $mediaid The media item to unlink from
  */
 public function UnlinkAllFromMedia($mediaid)
 {
     Debug::LogEntry('audit', 'IN', get_class(), __FUNCTION__);
     try {
         $dbh = PDOConnect::init();
         $mediaid = Kit::ValidateParam($mediaid, _INT, false);
         $sth = $dbh->prepare('DELETE FROM `lkmediadisplaygroup` WHERE mediaid = :mediaid');
         $sth->execute(array('mediaid' => $mediaid));
         return true;
     } catch (Exception $e) {
         Debug::LogEntry('error', $e->getMessage(), get_class(), __FUNCTION__);
         if (!$this->IsError()) {
             $this->SetError(1, __('Unknown Error'));
         }
         return false;
     }
 }
 /**
  * Links everyone to the layout specified
  * @param <type> $layoutId
  * @param <type> $view
  * @param <type> $edit
  * @param <type> $del
  * @return <type>
  */
 public function LinkEveryone($dataSetId, $view, $edit, $del)
 {
     Debug::LogEntry('audit', 'IN', 'DataSetGroupSecurity', 'LinkEveryone');
     try {
         $dbh = PDOConnect::init();
         // Get the Group ID for Everyone
         $sth = $dbh->prepare('SELECT GroupID FROM `group` WHERE IsEveryone = 1');
         $sth->execute();
         if (!($row = $sth->fetch())) {
             throw new Exception('Missing Everyone group');
         }
         // Link
         return $this->Link($dataSetId, Kit::ValidateParam($row['GroupID'], _INT), $view, $edit, $del);
     } catch (Exception $e) {
         Debug::LogEntry('error', $e->getMessage());
         return $this->SetError(25024, __('Could not Link DataSet to Group'));
     }
 }
Example #17
0
 /**
  * Change a users password
  * @param <type> $userId
  * @param <type> $oldPassword
  * @param <type> $newPassword
  * @param <type> $retypedNewPassword
  * @return <type> 
  */
 public function ChangePassword($userId, $oldPassword, $newPassword, $retypedNewPassword, $forceChange = false)
 {
     try {
         $dbh = PDOConnect::init();
         // Validate
         if ($userId == 0) {
             $this->ThrowError(26001, __('User not selected'));
         }
         // We can force the users password to change without having to provide the old one.
         // Is this a potential security hole - we must have validated that we are an admin to get to this point
         if (!$forceChange) {
             // Get the stored hash
             $sth = $dbh->prepare('SELECT UserPassword FROM `user` WHERE UserID = :userid');
             $sth->execute(array('userid' => $userId));
             if (!($row = $sth->fetch())) {
                 $this->ThrowError(26000, __('Incorrect Password Provided'));
             }
             $good_hash = Kit::ValidateParam($row['UserPassword'], _STRING);
             // Check the Old Password is correct
             if ($this->validate_password($oldPassword, $good_hash) === false) {
                 $this->ThrowError(26000, __('Incorrect Password Provided'));
             }
         }
         // Check the New Password and Retyped Password match
         if ($newPassword != $retypedNewPassword) {
             $this->ThrowError(26001, __('New Passwords do not match'));
         }
         // Check password complexity
         if (!$this->TestPasswordAgainstPolicy($newPassword)) {
             throw new Exception("Error Processing Request", 1);
         }
         // Generate a new SALT and Password
         $hash = $this->create_hash($newPassword);
         $sth = $dbh->prepare('UPDATE `user` SET UserPassword = :hash, CSPRNG = 1 WHERE UserID = :userid');
         $sth->execute(array('hash' => $hash, 'userid' => $userId));
         return true;
     } catch (Exception $e) {
         Debug::LogEntry('error', $e->getMessage());
         if (!$this->IsError()) {
             $this->SetError(25000, __('Could not edit Password'));
         }
         return false;
     }
 }
Example #18
0
 /**
  * Outputs a help link
  * @return 
  * @param $topic Object[optional]
  * @param $category Object[optional]
  */
 public static function Link($topic = "", $category = "General")
 {
     // if topic is empty use the page name
     $topic = $topic == '' ? Kit::GetParam('p', _REQUEST, _WORD) : $topic;
     $topic = ucfirst($topic);
     // Get the link
     try {
         $dbh = PDOConnect::init();
         $sth = $dbh->prepare('SELECT Link FROM help WHERE Topic = :topic and Category = :cat');
         $sth->execute(array('topic' => $topic, 'cat' => $category));
         if (!($link = $sth->fetchColumn(0))) {
             $sth->execute(array('topic' => $topic, 'cat' => 'General'));
             $link = $sth->fetchColumn(0);
         }
         return Config::GetSetting('HELP_BASE') . $link;
     } catch (Exception $e) {
         return false;
     }
 }
Example #19
0
 function __construct(database $db, user $user)
 {
     $this->db =& $db;
     $this->user =& $user;
     $this->layoutid = Kit::GetParam('layoutid', _REQUEST, _INT);
     //if we have modify selected then we need to get some info
     if ($this->layoutid != '') {
         // get the permissions
         Debug::LogEntry('audit', 'Loading permissions for layoutid ' . $this->layoutid);
         $layout = $this->user->LayoutList(NULL, array('layoutId' => $this->layoutid));
         if (count($layout) <= 0) {
             trigger_error(__('You do not have permissions to view this layout'), E_USER_ERROR);
         }
         $layout = $layout[0];
         $this->layout = $layout['layout'];
         $this->description = $layout['description'];
         $this->retired = $layout['retired'];
         $this->tags = $layout['tags'];
         $this->xml = $layout['xml'];
     }
 }
 /**
  * Links everyone to the layout specified
  * @param <type> $layoutId
  * @param <type> $view
  * @param <type> $edit
  * @param <type> $del
  * @return <type>
  */
 public function LinkEveryone($layoutId, $regionId, $mediaId, $view, $edit, $del)
 {
     try {
         $dbh = PDOConnect::init();
         $sth = $dbh->prepare('SELECT GroupID FROM `group` WHERE IsEveryone = 1');
         $sth->execute();
         if (!($row = $sth->fetch())) {
             throw new Exception("Error Processing Request", 1);
         }
         $groupId = Kit::ValidateParam($row['GroupID'], _INT);
         if (!$this->Link($layoutId, $regionId, $mediaId, $groupId, $view, $edit, $del)) {
             throw new Exception("Error Processing Request", 1);
         }
         return true;
     } catch (Exception $e) {
         Debug::LogEntry('error', $e->getMessage());
         if (!$this->IsError()) {
             $this->SetError(1, __('Unknown Error'));
         }
         return false;
     }
 }
Example #21
0
 public function add($tag)
 {
     try {
         $dbh = PDOConnect::init();
         // See if it exists
         $sth = $dbh->prepare('SELECT * FROM `tag` WHERE tag = :tag');
         $sth->execute(array('tag' => $tag));
         if ($row = $sth->fetch()) {
             return Kit::ValidateParam($row['tagId'], _INT);
         }
         // Insert if not
         $sth = $dbh->prepare('INSERT INTO `tag` (tag) VALUES (:tag)');
         $sth->execute(array('tag' => $tag));
         return $dbh->lastInsertId();
     } catch (Exception $e) {
         Debug::LogEntry('error', $e->getMessage(), get_class(), __FUNCTION__);
         if (!$this->IsError()) {
             $this->SetError(1, __('Unknown Error'));
         }
         return false;
     }
 }
Example #22
0
 /**
  * Show the library
  * @return 
  */
 function LayoutAssignView()
 {
     $db =& $this->db;
     $user =& $this->user;
     $response = new ResponseManager();
     //Input vars
     $name = Kit::GetParam('filter_name', _POST, _STRING);
     $tags = Kit::GetParam('filter_tags', _POST, _STRING);
     // Get a list of media
     $layoutList = $user->LayoutList(NULL, array('layout' => $name, 'tags' => $tags));
     $cols = array(array('name' => 'layout', 'title' => __('Name')));
     Theme::Set('table_cols', $cols);
     $rows = array();
     // Add some extra information
     foreach ($layoutList as $row) {
         $row['list_id'] = 'LayoutID_' . $row['layoutid'];
         $row['assign_icons'][] = array('assign_icons_class' => 'layout_assign_list_select');
         $row['dataAttributes'] = array(array('name' => 'rowid', 'value' => $row['list_id']), array('name' => 'litext', 'value' => $row['layout']));
         $rows[] = $row;
     }
     Theme::Set('table_rows', $rows);
     // Render the Theme
     $response->SetGridResponse(Theme::RenderReturn('table_render'));
     $response->callBack = 'LayoutAssignCallback';
     $response->pageSize = 5;
     $response->Respond();
 }
Example #23
0
 private function GetDataSetItems($displayId, $text)
 {
     $db =& $this->db;
     // Extra fields for data sets
     $dataSetId = $this->GetOption('datasetid');
     $upperLimit = $this->GetOption('upperLimit');
     $lowerLimit = $this->GetOption('lowerLimit');
     $filter = $this->GetOption('filter');
     $ordering = $this->GetOption('ordering');
     Debug::LogEntry('audit', 'Then template for each row is: ' . $text);
     // Combine the column id's with the dataset data
     $matches = '';
     preg_match_all('/\\[(.*?)\\]/', $text, $matches);
     $columnIds = array();
     foreach ($matches[1] as $match) {
         // Get the column id's we are interested in
         Debug::LogEntry('audit', 'Matched column: ' . $match);
         $col = explode('|', $match);
         $columnIds[] = $col[1];
     }
     // Get the dataset results
     Kit::ClassLoader('dataset');
     $dataSet = new DataSet($db);
     $dataSetResults = $dataSet->DataSetResults($dataSetId, implode(',', $columnIds), $filter, $ordering, $lowerLimit, $upperLimit, $displayId, true);
     $items = array();
     foreach ($dataSetResults['Rows'] as $row) {
         // For each row, substitute into our template
         $rowString = $text;
         foreach ($matches[1] as $sub) {
             // Pick the appropriate column out
             $subs = explode('|', $sub);
             $rowString = str_replace('[' . $sub . ']', $row[$subs[0]], $rowString);
         }
         $items[] = $rowString;
     }
     return $items;
 }
Example #24
0
 /**
  * Deletes a Group
  * @return 
  */
 function Delete()
 {
     // Check the token
     if (!Kit::CheckToken()) {
         trigger_error('Token does not match', E_USER_ERROR);
     }
     $response = new ResponseManager();
     $displayProfile = new DisplayProfile();
     $displayProfile->displayProfileId = Kit::GetParam('displayprofileid', _POST, _INT);
     if (!$displayProfile->Load()) {
         trigger_error($displayProfile->GetErrorMessage(), E_USER_ERROR);
     }
     if ($this->user->usertypeid != 1 && $this->user->userid != $displayProfile->userId) {
         trigger_error(__('You do not have permission to edit this profile'), E_USER_ERROR);
     }
     if (!$displayProfile->Delete($displayProfile->displayProfileId)) {
         trigger_error($displayProfile->GetErrorMessage(), E_USER_ERROR);
     }
     $response->SetFormSubmitResponse(__('Display Profile Deleted'), false);
     $response->Respond();
 }
Example #25
0
 public function RequestScreenShot()
 {
     // Check the token
     if (!Kit::CheckToken()) {
         trigger_error(__('Sorry the form has expired. Please refresh.'), E_USER_ERROR);
     }
     $db =& $this->db;
     $response = new ResponseManager();
     $displayObject = new Display($db);
     $displayId = Kit::GetParam('displayId', _POST, _INT);
     if (!$displayObject->RequestScreenShot($displayId)) {
         trigger_error($displayObject->GetErrorMessage(), E_USER_ERROR);
     }
     $response->SetFormSubmitResponse(__('Request Sent.'));
     $response->Respond();
 }
Example #26
0
    require_once 'install/upgradestep.class.php';
    $page = 'upgrade';
    if (Kit::GetParam('includes', _POST, _BOOL)) {
        $upgradeFrom = Kit::GetParam('upgradeFrom', _POST, _INT);
        $upgradeTo = Kit::GetParam('upgradeTo', _POST, _INT);
        for ($i = $upgradeFrom + 1; $i <= $upgradeTo; $i++) {
            if (file_exists('install/database/' . $i . '.php')) {
                include_once 'install/database/' . $i . '.php';
            }
        }
    }
}
// Create a Session
$session = new Session();
// Work out the location of this service
$serviceLocation = Kit::GetXiboRoot();
// OAuth
require_once 'lib/oauth.inc.php';
// Assign the page name to the session
$session->set_page(session_id(), $page);
// Create a user
$user = new User($db);
// Create Page
try {
    $pageManager = new PageManager($db, $user, $page);
    $pageManager->Authenticate();
    $pageManager->Render();
} catch (Exception $e) {
    trigger_error($e->getMessage(), E_USER_ERROR);
}
die;
Example #27
0
 /**
  * We need to update the user groups
  */
 private function UpdateUserGroups()
 {
     $db =& $this->db;
     // Get all the current users in the system
     $SQL = "SELECT UserID, groupID, UserName FROM `user`";
     if (!($result = $db->query($SQL))) {
         reportError('20.php', "Error creating user groups" . $db->error());
     }
     while ($row = $db->get_assoc_row($result)) {
         // For each display create a display group and link it to the display
         $ugid = 0;
         $userID = Kit::ValidateParam($row['UserID'], _INT);
         $groupID = Kit::ValidateParam($row['groupID'], _INT);
         $username = Kit::ValidateParam($row['UserName'], _STRING);
         $ug = new UserGroup($db);
         // For each one create a user specific group
         if (!($ugId = $ug->Add($username, 1))) {
             reportError('20.php', "Error creating user groups" . $db->error());
         }
         // Link to the users own userspecific group and also to the one they were already on
         $ug->Link($ugId, $userID);
         $ug->Link($groupID, $userID);
     }
 }
Example #28
0
 /**
  * Return file based media items to the browser for Download/Preview
  * @return
  * @param $download Boolean
  */
 public function ReturnFile($fileName = '')
 {
     // Return the raw flash file with appropriate headers
     $library = Config::GetSetting("LIBRARY_LOCATION");
     # If we weren't passed in a filename then use the default
     if ($fileName == '') {
         $fileName = $library . $this->storedAs;
     }
     $download = Kit::GetParam('download', _REQUEST, _BOOLEAN, false);
     $downloadFromLibrary = Kit::GetParam('downloadFromLibrary', _REQUEST, _BOOLEAN, false);
     $size = filesize($fileName);
     if ($download) {
         header('Content-Type: application/octet-stream');
         header("Content-Transfer-Encoding: Binary");
         header("Content-disposition: attachment; filename=\"" . ($downloadFromLibrary ? $this->originalFilename : basename($fileName)) . "\"");
     } else {
         $fi = new finfo(FILEINFO_MIME_TYPE);
         $mime = $fi->file($fileName);
         header("Content-Type: {$mime}");
     }
     //Output a header
     header('Pragma: public');
     header('Cache-Control: max-age=86400');
     header('Expires: ' . gmdate('D, d M Y H:i:s \\G\\M\\T', time() + 86400));
     header('Content-Length: ' . $size);
     // Send via Apache X-Sendfile header?
     if (Config::GetSetting('SENDFILE_MODE') == 'Apache') {
         header("X-Sendfile: {$fileName}");
         exit;
     }
     // Send via Nginx X-Accel-Redirect?
     if (Config::GetSetting('SENDFILE_MODE') == 'Nginx') {
         header("X-Accel-Redirect: /download/" . basename($fileName));
         exit;
     }
     // Return the file with PHP
     // Disable any buffering to prevent OOM errors.
     @ob_end_clean();
     readfile($fileName);
 }
Example #29
0
 /**
  * Edit Media in the Database
  * @return
  */
 public function EditMedia()
 {
     $this->response = new ResponseManager();
     $db =& $this->db;
     $layoutid = $this->layoutid;
     $regionid = $this->regionid;
     $mediaid = $this->mediaid;
     if (!$this->auth->edit) {
         $this->response->SetError('You do not have permission to edit this assignment.');
         $this->response->keepOpen = false;
         return $this->response;
     }
     $windowsCommand = Kit::GetParam('windowsCommand', _POST, _STRING);
     $linuxCommand = Kit::GetParam('linuxCommand', _POST, _STRING);
     if ($windowsCommand == '' && $linuxCommand == '') {
         $this->response->SetError('You must enter a command');
         $this->response->keepOpen = true;
         return $this->response;
     }
     // Any Options
     $this->duration = 1;
     $this->SetOption('windowsCommand', urlencode($windowsCommand));
     $this->SetOption('linuxCommand', urlencode($linuxCommand));
     // Should have built the media object entirely by this time
     // This saves the Media Object to the Region
     $this->UpdateRegion();
     // Set this as the session information
     setSession('content', 'type', 'shellcommand');
     if ($this->showRegionOptions) {
         // We want to load a new form
         $this->response->loadForm = true;
         $this->response->loadFormUri = "index.php?p=timeline&layoutid={$layoutid}&regionid={$regionid}&q=RegionOptions";
     }
     return $this->response;
 }
Example #30
0
 /**
  * GetParam
  * @param <string> $param
  * @param <int> $type
  * @param <type> $default
  * @return <type>
  */
 protected function GetParam($param, $type, $default = null)
 {
     return Kit::GetParam($param, $this->POST, $type, $default);
 }