Example #1
0
/**
 * Updates a cronjob handler.
 *
 * @since 6.0.00
 */
function updateCronjobs($id = '')
{
    $app = \Liten\Liten::getInstance();
    $cronDir = cronDir() . 'cron/';
    if (file_put_contents($cronDir . 'cronjobs.dat.php', '<' . '?php /*' . base64_encode(serialize($_SESSION['cronjobs'])) . '*/')) {
        $app->flash('success_message', _t('Database saved.'));
        // create 'backup'
        file_put_contents($cronDir . 'cronjobs.backup-' . date('Y-m-d') . '.php', '<' . '?php /*' . base64_encode(serialize($_SESSION['cronjobs'])) . '*/');
    } else {
        $app->flash('error_message', _t('Database not saved, could not create database file on server, please check write rights of this script.'));
    }
    // remove old cronjob backup files
    $files = glob($cronDir . 'cronjobs.backup*.php');
    if (is_array($files)) {
        foreach ($files as $file) {
            if (is_file($file) && time() - filemtime($file) >= 2 * 24 * 60 * 60) {
                // 2 days
                unlink($file);
            }
        }
    }
    if ($id != '' && is_numeric($id)) {
        redirect(get_base_url() . 'cron/view' . '/' . $id);
    } else {
        redirect($app->req->server['HTTP_REFERER']);
    }
    exit;
}
/**
 * Searches for plain email addresses in given $string and
 * encodes them (by default) with the help of eae_encode_str().
 *
 * Regular expression is based on based on John Gruber's Markdown.
 * http://daringfireball.net/projects/markdown/
 *
 * @param string $string
 *            Text with email addresses to encode
 * @return string $string Given text with encoded email addresses
 */
function eae_encode_emails($string)
{
    $app = \Liten\Liten::getInstance();
    // abort if $string doesn't contain a @-sign
    if ($app->hook->apply_filter('eae_at_sign_check', true)) {
        if (strpos($string, '@') === false) {
            return $string;
        }
    }
    // override encoding function with the 'eae_method' filter
    $method = $app->hook->apply_filter('eae_method', 'eae_encode_str');
    // override regex pattern with the 'eae_regexp' filter
    $regexp = $app->hook->apply_filter('eae_regexp', '{
			(?:mailto:)?
			(?:
				[-!#$%&*+/=?^_`.{|}~\\w\\x80-\\xFF]+
			|
				".*?"
			)
			\\@
			(?:
				[-a-z0-9\\x80-\\xFF]+(\\.[-a-z0-9\\x80-\\xFF]+)*\\.[a-z]+
			|
				\\[[\\d.a-fA-F:]+\\]
			)
		}xi');
    return preg_replace_callback($regexp, create_function('$matches', 'return ' . $method . '($matches[0]);'), $string);
}
Example #3
0
/**
 * Sets up object cache global scope and assigns it based on
 * the type of caching system used.
 *
 * @since 6.2.0
 */
function _etsis_cache_init()
{
    $app = \Liten\Liten::getInstance();
    $driver = $app->hook->apply_filter('etsis_cache_driver', 'file');
    $cache = new \app\src\Core\Cache\etsis_Object_Cache($driver);
    return $cache;
}
Example #4
0
/**
 * Desktop Push Notification
 * 
 * Notifications that can be pushed at a delayed time.
 * 
 * @since 6.2.11
 * @param string $title Give title of notification.
 * @param string $message Message that should be displayed.
 */
function etsis_push_notify($title, $message)
{
    $app = \Liten\Liten::getInstance();
    // Create a Notifier
    $notifier = NotifierFactory::create();
    // Create your notification
    $notification = (new Notification())->setTitle($title)->setBody($message)->setIcon(BASE_PATH . 'static/assets/imgages/icon-success.png');
    // Send it
    return $app->hook->apply_filter('push_notify', $notifier->send($notification));
}
Example #5
0
 public function __construct($personID = '')
 {
     $this->_app = \Liten\Liten::getInstance();
     if ($personID != '') {
         $this->_personID = floatval($personID);
     } else {
         $this->_personID = floatval(get_persondata('personID'));
     }
     $this->_userRoles = $this->getUserRoles('ids');
     $this->buildACL();
 }
Example #6
0
function update_prog_crse_column($data)
{
    $app = \Liten\Liten::getInstance();
    if (count($data)) {
        $id = $data['rid'];
        unset($data['rid']);
        $sql = $app->db->query("UPDATE prog_crse SET " . key($data) . "='" . $data[key($data)] . "' WHERE ID = ? LIMIT 1", [$id]);
        if ($sql->update()) {
            return $id;
        }
        return 0;
    }
}
Example #7
0
 public function __construct(\Liten\Liten $liten = null)
 {
     $this->app = !empty($liten) ? $liten : \Liten\Liten::getInstance();
     if (!extension_loaded('apc') && !ini_get('apc.enabled') || !function_exists('apc_fetch')) {
         return new \app\src\Core\Exception\Exception(_t('APC requires PHP APC extension to be installed and loaded.'), 'php_apc_extension');
     }
     /**
      * Filter sets whether caching is enabled or not.
      *
      * @since 6.2.0
      * @var bool
      */
     $this->enable = $this->app->hook->apply_filter('enable_caching', true);
 }
 public function __construct($driver, \Liten\Liten $liten = null)
 {
     $this->app = !empty($liten) ? $liten : \Liten\Liten::getInstance();
     if ($driver == 'file') {
         $this->_cache = new \app\src\Core\Cache\etsis_Cache_Filesystem();
     } elseif ($driver == 'apc') {
         $this->_cache = new \app\src\Core\Cache\etsis_Cache_APC();
     } elseif ($driver == 'memcache') {
         /**
          * Filter whether to use `\Memcache`|`\Memcached`.
          *
          * @since 6.2.0
          * @param
          *            bool false Use `\Memcache`|`\Memcached`. Default is false.
          */
         $useMemcached = $this->app->hook->apply_filter('use_memcached', false);
         $this->_cache = new \app\src\Core\Cache\etsis_Cache_Memcache($useMemcached);
         $pool = [['host' => '127.0.0.1', 'port' => 11211, 'weight' => 20]];
         /**
          * Filter the `\Memcache`|`\Memcached` server pool.
          *
          * @since 6.2.0
          * @param array $pool
          *            Array of servers to add to the connection pool.
          */
         $servers = $this->app->hook->apply_filter('memcache_server_pool', $pool);
         $this->_cache->addServer($servers);
     } elseif ($driver == 'external') {
         /**
          * Fires when being used to call another caching system not
          * native to eduTrac SIS.
          *
          * @since 6.2.0
          */
         $this->_cache = $this->app->hook->do_action('external_cache_driver');
     } elseif ($driver == 'xcache') {
         $this->_cache = new \app\src\Core\Cache\etsis_Cache_XCache();
     } elseif ($driver == 'cookie') {
         $this->_cache = new \app\src\Core\Cache\etsis_Cache_Cookie();
     } elseif ($driver == 'json') {
         $this->_cache = new \app\src\Core\Cache\etsis_Cache_JSON();
     } elseif ($driver == 'memory') {
         $this->_cache = new \app\src\Core\Cache\etsis_Cache_Memory();
     }
     if (is_etsis_exception($this->_cache)) {
         return $this->_cache->getMessage();
     }
     return $this->_cache;
 }
Example #9
0
/**
 *
 * @since 4.4
 */
function convertCourseSec($sect)
{
    $app = \Liten\Liten::getInstance();
    $section = $app->db->course_sec()->select('courseSecCode')->where('courseSecID = ?', $sect);
    $q = $section->find(function ($data) {
        $array = [];
        foreach ($data as $d) {
            $array[] = $d;
        }
        return $array;
    });
    foreach ($q as $r) {
        $section = $r['courseSecCode'];
    }
    return $section;
}
/**
 * Subject dropdown: shows general list of subjects and
 * if $subjectCode is not NULL, shows the subject attached
 * to a particular record.
 *
 * @deprecated since release 6.1.12
 * @see table_dropdown
 * @since 1.0.0
 * @param string $subjectCode
 *            - optional
 * @return string Returns the record key if selected is true.
 */
function subject_code_dropdown($subjectCode = NULL)
{
    _deprecated_function(__FUNCTION__, '6.1.12', 'table_dropdown');
    $app = \Liten\Liten::getInstance();
    $subj = $app->db->subject()->select('subjectCode,subjectName')->where('subjectCode <> "NULL"');
    $q = $subj->find(function ($data) {
        $array = [];
        foreach ($data as $d) {
            $array[] = $d;
        }
        return $array;
    });
    foreach ($q as $v) {
        echo '<option value="' . _h($v['subjectCode']) . '"' . selected($subjectCode, _h($v['subjectCode']), false) . '>' . _h($v['subjectCode']) . ' ' . _h($v['subjectName']) . '</option>' . "\n";
    }
}
Example #11
0
/**
 * Prints a list of active courses.
 */
function courseList($id = '')
{
    $app = \Liten\Liten::getInstance();
    $crse = $app->db->course()->select('courseCode')->where('courseID <> ?', $id)->_and_()->where('currStatus = "A"')->_and_()->where('endDate <= "0000-00-00"');
    $q = $crse->find(function ($data) {
        $array = [];
        foreach ($data as $d) {
            $array[] = $d;
        }
        return $array;
    });
    $a = [];
    foreach ($q as $r) {
        $a[] = $r['courseCode'];
    }
    return $a;
}
function degree_audit_tables()
{
    $app = \Liten\Liten::getInstance();
    $now = date('Y-m-d h:i:s');
    $hd = $app->db->query('SHOW TABLES LIKE "da_group"');
    $q = $hd->find(function ($data) {
        $array = [];
        foreach ($data as $d) {
            $array[] = $d;
        }
        return $array;
    });
    if (count($q) <= 0) {
        $sql = [];
        $sql = "";
        foreach ($sql as $query) {
            $app->db->query($query);
        }
    }
}
 public function __construct($useMemcached, \Liten\Liten $liten = null)
 {
     $this->app = !empty($liten) ? $liten : \Liten\Liten::getInstance();
     $this->useMemcached = $useMemcached;
     $ext = $this->useMemcached ? 'memcached' : 'memcache';
     if ($ext == 'memcached' && !class_exists('memcached')) {
         return new \app\src\Core\Exception\Exception(sprintf(_t('Memcached requires PHP <strong>%s</strong> extension to be loaded.'), $ext), 'php_memcache_extension');
     }
     if ($ext == 'memcache' && !function_exists('memcache_connect')) {
         return new \app\src\Core\Exception\Exception(sprintf(_t('Memcached requires PHP <strong>%s</strong> extension to be loaded.'), $ext), 'php_memcache_extension');
     }
     if ($ext == 'memcache') {
         $this->connection = new \Memcache();
     } else {
         $this->connection = new \Memcached('etsis');
     }
     /**
      * Filter sets whether caching is enabled or not.
      *
      * @since 6.2.0
      * @var bool
      */
     $this->enable = $this->app->hook->apply_filter('enable_caching', true);
 }
Example #14
0
/**
 * Returns the url based on route.
 */
function url($route)
{
    $app = \Liten\Liten::getInstance();
    $url = $app->req->url_for($route);
    return $url;
}
Example #15
0
/**
 * Change of Address Email
 * 
 * Function used to send change of address to
 * appropriate staff member.
 * 
 * @since 6.2.11
 */
function etsis_nodeq_change_address()
{
    $app = \Liten\Liten::getInstance();
    $email = _etsis_email();
    $host = $app->req->server['HTTP_HOST'];
    $site = _t('myeduTrac :: ') . _h(get_option('institution_name'));
    // Creates node's schema if does not exist.
    Node::dispense('change_address');
    try {
        $sql = Node::table('change_address')->where('sent', '=', 0)->findAll();
        if ($sql->count() == 0) {
            Node::table('change_address')->delete();
        }
        $numItems = $sql->count();
        $i = 0;
        if ($sql->count() > 0) {
            foreach ($sql as $r) {
                $message = _escape(get_option('coa_form_text'));
                $message = str_replace('#uname#', _h($r->uname), $message);
                $message = str_replace('#fname#', _h($r->fname), $message);
                $message = str_replace('#lname#', _h($r->lname), $message);
                $message = str_replace('#name#', get_name(_h($r->personid)), $message);
                $message = str_replace('#id#', _h($r->personid), $message);
                $message = str_replace('#address1#', _h($r->address1), $message);
                $message = str_replace('#address2#', _h($r->address2), $message);
                $message = str_replace('#city#', _h($r->city), $message);
                $message = str_replace('#state#', _h($r->state), $message);
                $message = str_replace('#zip#', _h($r->zip), $message);
                $message = str_replace('#country#', _h($r->country), $message);
                $message = str_replace('#phone#', _h($r->phone), $message);
                $message = str_replace('#email#', _h($r->email), $message);
                $message = str_replace('#adminemail#', _h(get_option('system_email')), $message);
                $message = str_replace('#url#', get_base_url(), $message);
                $message = str_replace('#helpdesk#', _h(get_option('help_desk')), $message);
                $message = str_replace('#currentterm#', _h(get_option('current_term_code')), $message);
                $message = str_replace('#instname#', _h(get_option('institution_name')), $message);
                $message = str_replace('#mailaddr#', _h(get_option('mailing_address')), $message);
                $headers = "From: {$site} <auto-reply@{$host}>\r\n";
                $headers .= "X-Mailer: PHP/" . phpversion();
                $headers .= "MIME-Version: 1.0" . "\r\n";
                $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
                $email->etsis_mail(_h(get_option('contact_email')), _t('Change of Address Request'), $message, $headers);
                $upd = Node::table('change_address')->find(_h($r->id));
                $upd->sent = 1;
                $upd->save();
                if (++$i === $numItems) {
                    //If we reach the last item, send user a desktop notification.
                    etsis_push_notify('Change of Address', 'Request has been submitted.');
                }
            }
        }
    } catch (\Exception $e) {
        return new \app\src\Core\Exception\Exception($e->getMessage(), 'NodeQ');
    }
}
Example #16
0
/**
 * Student router function.
 * 
 * Includes student router filter (student_router).
 *
 * @since 6.2.7
 */
function _etsis_student_router()
{
    $app = \Liten\Liten::getInstance();
    $router = $app->config('routers_dir') . 'student.router.php';
    if (!$app->hook->has_filter('student_router')) {
        require $router;
    }
    return $app->hook->apply_filter('student_router', $router);
}
 public function __construct(\Liten\Liten $liten = null)
 {
     $this->app = !empty($liten) ? $liten : \Liten\Liten::getInstance();
     if (ETSIS_FILE_CACHE_LOW_RAM && function_exists('memory_get_usage')) {
         $limit = _trim(ini_get('memory_limit'));
         $mod = strtolower($limit[strlen($limit) - 1]);
         switch ($mod) {
             case 'g':
                 $limit *= 1073741824;
                 break;
             case 'm':
                 $limit *= 1048576;
                 break;
             case 'k':
                 $limit *= 1024;
                 break;
         }
         if ($limit <= 0) {
             $limit = 0;
         }
         $this->_memory_limit = $limit;
         $limit = _trim(ETSIS_FILE_CACHE_LOW_RAM);
         $mod = strtolower($limit[strlen($limit) - 1]);
         switch ($mod) {
             case 'g':
                 $limit *= 1073741824;
                 break;
             case 'm':
                 $limit *= 1048576;
                 break;
             case 'k':
                 $limit *= 1024;
                 break;
         }
         $this->_memory_low = $limit;
     } else {
         $this->_memory_limit = 0;
         $this->_memory_low = 0;
     }
     /**
      * Filter sets whether caching is enabled or not.
      *
      * @since 6.2.0
      * @var bool
      */
     $this->enable = $this->app->hook->apply_filter('enable_caching', true);
     $this->persist = $this->enable && true;
     /**
      * File system cache directory.
      */
     $dir = $this->app->config('file.savepath') . 'cache';
     /**
      * Fiter the file cache directory in order to override it
      * in case some systems are having issues.
      *
      * @since 6.2.0
      * @param string $dir
      *            The directory where file system cache files are saved.
      */
     $cacheDir = $this->app->hook->apply_filter('filesystem_cache_dir', $dir);
     /**
      * If the cache directory does not exist, the create it first
      * before trying to call it for use.
      */
     if (!is_dir($cacheDir) || !file_exists($cacheDir)) {
         _mkdir($cacheDir);
     }
     /**
      * If the directory isn't writable, throw an exception.
      */
     if (!etsis_is_writable($cacheDir)) {
         return new \app\src\Core\Exception\Exception(_t('Could not create the file cache directory.'), 'cookie_cache');
     }
     /**
      * Cache directory is set.
      */
     $this->_dir = $cacheDir . DS;
 }
/**
 * Sanitizes a string, or returns a fallback string.
 *
 * Specifically, HTML and PHP tags are stripped. Further actions can be added
 * via the plugin API. If $string is empty and $fallback_string is set, the latter
 * will be used.
 *
 * @since 6.2.10
 *
 * @param string $string          The string to be sanitized.
 * @param string $fallback_string Optional. A string to use if $string is empty.
 * @param string $context        Optional. The operation for which the string is sanitized
 * @return string The sanitized string.
 */
function etsis_sanitize_string($string, $fallback_string = '', $context = 'save')
{
    $app = \Liten\Liten::getInstance();
    $raw_string = $string;
    if ('save' == $context) {
        $string = etsis_remove_accents($string);
    }
    /**
     * Filters a sanitized string.
     *
     * @since 6.2.10
     *
     * @param string $string        Sanitized string.
     * @param string $raw_string    The string prior to sanitization.
     * @param string $context       The context for which the string is being sanitized.
     */
    $string = $app->hook->apply_filter('sanitize_string', $string, $raw_string, $context);
    if ('' === $string || false === $string) {
        $string = $fallback_string;
    }
    return $string;
}
Example #19
0
/**
 * Shows error messages on login form.
 * 
 * @since 6.2.5
 */
function etsis_login_form_show_message()
{
    $app = \Liten\Liten::getInstance();
    $flash = new \app\src\Core\etsis_Messages();
    echo $app->hook->apply_filter('login_form_show_message', $flash->showMessage());
}
Example #20
0
/**
 * Custom function to query any eduTrac SIS
 * database table.
 *
 * @since 6.0.00
 * @param string $table            
 * @param mixed $field            
 * @param mixed $where            
 * @return mixed
 */
function qt($table, $field, $where = null)
{
    $app = \Liten\Liten::getInstance();
    if ($where !== null) {
        $query = $app->db->query("SELECT * FROM {$table} WHERE {$where}");
    } else {
        $query = $app->db->query("SELECT * FROM {$table}");
    }
    $result = $query->find(function ($data) {
        $array = [];
        foreach ($data as $d) {
            $array[] = $d;
        }
        return $array;
    });
    foreach ($result as $r) {
        return _h($r[$field]);
    }
}
Example #21
0
/**
 * Retrieves a list of roles from the roles table.
 *
 * @since 6.0.04
 * @return mixed
 */
function get_perm_roles()
{
    $app = \Liten\Liten::getInstance();
    $query = $app->db->query('SELECT
    		trim(leading "0" from ID) AS roleID, roleName
		FROM role');
    $result = $query->find(function ($data) {
        $array = [];
        foreach ($data as $d) {
            $array[] = $d;
        }
        return $array;
    });
    foreach ($result as $r) {
        echo '<option value="' . _h($r['roleID']) . '">' . _h($r['roleName']) . '</option>' . "\n";
    }
}
Example #22
0
/**
 * Retrieve student's hiatus status.
 *
 * @since 6.2.10
 * @return Student's hiatus status.
 */
function get_stu_shis($stu_id, $field)
{
    $app = \Liten\Liten::getInstance();
    $shis = $app->db->hiatus()->where('endDate <= "0000-00-00"')->_and_()->where('stuID = ?', $stu_id)->findOne();
    return _h($shis->{$field});
}
Example #23
0
 /**
  * __construct class constructor
  *
  * @access public
  * @since 1.0.1
  */
 public function __construct(\Liten\Liten $liten = null)
 {
     $this->_app = !empty($liten) ? $liten : \Liten\Liten::getInstance();
 }
Example #24
0
 /**
  * Constructor.
  *
  * @param etsis_Student|object $stu
  *            Student object.
  */
 public function __construct($stu, \Liten\Liten $liten = null)
 {
     foreach (get_object_vars($stu) as $key => $value) {
         $this->{$key} = $value;
     }
     $this->app = !empty($liten) ? $liten : \Liten\Liten::getInstance();
     $this->stuHeader = $this->getStuHeader();
 }
Example #25
0
 /**
  * Constructor is private so that another instance isn't created.
  *
  * @since 6.2.0
  */
 private function __construct(\Liten\Liten $liten = null)
 {
     // Make sure the script can handle large folders/files for zip and API calls.
     ini_set('max_execution_time', 600);
     ini_set('memory_limit', '1024M');
     if (function_exists('enable_url_ssl')) {
         $protocol = 'https://';
     } else {
         $protocol = 'http://';
     }
     $this->url = $protocol . $this->_baseURL . '/';
     $this->patch_url = $this->getReleaseJsonUrl();
     $this->local_base_dir = BASE_PATH;
     $this->local_backup_dir = '/tmp/';
     $this->app = !empty($liten) ? $liten : \Liten\Liten::getInstance();
     $this->update = new \VisualAppeal\AutoUpdate(rtrim($this->app->config('file.savepath'), '/'), rtrim(BASE_PATH, '/'), 1800);
     $this->current_release = $this->getCurrentRelease();
     $this->current_release_value = $this->current_release['current_release']['current_release_value'];
 }
Example #26
0
 public function __construct()
 {
     $this->mailer = _etsis_phpmailer();
     $this->app = \Liten\Liten::getInstance();
 }
Example #27
0
/**
 * Wrapper function for Hooks::maybe_unserialize() method and
 * unserializes value if it is serialized.
 *
 * @see Hooks::maybe_unserialized()
 *
 * @since 6.0.03
 * @param string $original
 *            Maybe unserialized original, if is needed.
 * @return mixed Any type of serialized data.
 */
function maybe_unserialize($original)
{
    $app = \Liten\Liten::getInstance();
    return $app->hook->maybe_unserialize($original);
}
Example #28
0
 public function __construct()
 {
     $this->_app = \Liten\Liten::getInstance();
     $this->_cache = new \app\src\DBCache();
 }
Example #29
0
if (!defined('BASE_PATH')) {
    exit('No direct script access allowed');
}
/**
 * Edit Course View
 * 
 * This view renders the course record for the CRSE screen.
 *  
 * @license GPLv3
 * 
 * @since       3.0.0
 * @package     eduTrac SIS
 * @author      Joshua Parker <*****@*****.**>
 */
$app = \Liten\Liten::getInstance();
$app->view->extend('_layouts/dashboard');
$app->view->block('dashboard');
$flash = new \app\src\Core\etsis_Messages();
include 'ajax.php';
$screen = 'acrse';
?>

<script src="//cdn.tinymce.com/4/tinymce.min.js"></script>
<script src="<?php 
echo get_base_url();
?>
static/assets/plugins/tinymce/plugin.js"></script>
<script type="text/javascript">
	tinymce.init({selector: "textarea",plugins: [ "placeholder" ]});
	$(".panel").show();
Example #30
0
 public function __construct()
 {
     $this->app = \Liten\Liten::getInstance();
 }