Ejemplo n.º 1
0
 /**
  * Constructor
  */
 function __construct($to, $subject, $from = null)
 {
     $this->header = array('X-Mailer' => SSC_VER_UA);
     // To field
     if (!empty($to)) {
         $this->to = filter_var($to, FILTER_VALIDATE_EMAIL);
     }
     // From field
     if (!empty($from)) {
         $this->set_header('From', $from);
     } else {
         $this->set_header('From', ssc_var_get("admin_email", 'noreply@' . $_SERVER['SERVER_NAME']));
     }
     $this->subject = $subject;
 }
Ejemplo n.º 2
0
 /**
  * Resize an image to the specified size.  Takes an approximate guess at best compression based on file size
  * Either $width or $height may be -1 to indicate no maximum width/height but not both 
  * @param string Location to store the resized file
  * @param int Maximum width of the image
  * @param int Maximum height of the image
  * @return boolean Whether or not the resize was successful
  */
 function resize($target, $width = -1, $height = -1)
 {
     global $ssc_site_path;
     // Perform checks before passing off to the individual implementation
     // Can't have both don't-care width AND height
     if ($width < 1 && $height < 1) {
         return false;
     }
     // Check target location writability
     $dir = dirname($target);
     if (!is_dir($dir) || (fileperms($dir) & 0200) == 0) {
         return false;
     }
     // Preliminary checks ok - pass to library implementation
     $lib = 'sscImage' . ssc_var_get('image_library', 'GD2');
     if (!ssc_load_library($lib)) {
         return false;
     }
     if ($imgLib = new $lib($this->file)) {
         return $imgLib->_resize($target, $width, $height);
     } else {
         return false;
     }
 }
Ejemplo n.º 3
0
/**
 * Display the list of events - implementation of module_content
 * 
 * Only one type of display so don't need to parse any sort of input
 * 
 * @return string Main body content
 */
function events_content()
{
    global $ssc_database;
    // Set up the event time borders
    $borders['past'] = date("Y-m-d", strtotime(ssc_var_get('events.recent', '-2 weeks')));
    $borders['current-past'] = date("Y-m-d", strtotime(ssc_var_get('events.current.old', '-1 week')));
    $borders['current-future'] = date("Y-m-d", strtotime(ssc_var_get('events.current.new', '+1 week')));
    $borders['future'] = date("Y-m-d", strtotime(ssc_var_get('events.future', '+2 months')));
    // Get all events within the range
    $result = $ssc_database->query("SELECT title, description, uri, date, flags FROM #__events WHERE date >= '%s' AND date <= '%s' ORDER BY date ASC", $borders['past'], $borders['future']);
    if (!$result) {
        ssc_not_found();
        return;
    }
    ssc_set_title(ssc_var_get('events.title', 'Events'));
    // Load first event if possible
    if ($ssc_database->number_rows() > 0) {
        $data = $ssc_database->fetch_assoc($result);
    } else {
        $data = null;
    }
    // And start displaying the results
    $out = '<h3>' . t('Recent events') . '</h3>';
    $in = false;
    while ($data && $data['date'] <= $borders['current-past']) {
        if (!$in) {
            $out .= '<ul class="events-list">';
            $in = true;
        }
        $out .= _events_print_db_event($data);
        $data = $ssc_database->fetch_assoc($result);
    }
    if ($in) {
        $out .= '</ul>';
        $in = false;
    } else {
        $out .= t('There are no recent events');
    }
    $out .= '<h3>' . t('Current events') . '</h3>';
    while ($data && $data['date'] <= $borders['current-future']) {
        if (!$in) {
            $out .= '<ul class="events-list">';
            $in = true;
        }
        $out .= _events_print_db_event($data);
        $data = $ssc_database->fetch_assoc($result);
    }
    if ($in) {
        $out .= '</ul>';
        $in = false;
    } else {
        $out .= t('There are no current events');
    }
    $out .= '<h3>' . t('Upcoming events') . '</h3>';
    while ($data) {
        if (!$in) {
            $out .= '<ul class="events-list">';
            $in = true;
        }
        $out .= _events_print_db_event($data);
        $data = $ssc_database->fetch_assoc($result);
    }
    if ($in) {
        $out .= '</ul>';
    } else {
        $out .= t('There are no upcoming events');
    }
    return $out;
}
Ejemplo n.º 4
0
 */
define("_VALID_SSC", 1);
define("SSC_CRON_MIN_TIME", 60 * 59);
// Minimum 1hr time
// Only load from internally
if (isset($_SERVER['REMOTE_ADDR']) || !isset($_SERVER['argv'])) {
    die('Restricted access');
}
$sites = glob('./config/*.settings.inc.php');
if ($sites === false) {
    die('Restricted access');
}
include './includes/core.inc.php';
foreach ($sites as $site) {
    $site = str_replace(".settings.inc.php", "", $site);
    $site = substr($site, 9);
    $_SERVER['SERVER_NAME'] = $site;
    if ($site == 'default') {
        continue;
    }
    // Begin application startup
    ssc_init(SSC_INIT_EXTENSION);
    $lastrun = ssc_var_get("cron_last_run", 0);
    $now = time();
    // Run only if not up to hardcoded minimum per-run time
    if ($lastrun < $now - SSC_CRON_MIN_TIME) {
        module_hook('cron');
    }
    ssc_var_set("cron_last_run", $now);
    ssc_close();
}
Ejemplo n.º 5
0
/**
 * Add a wrapper to a side bar block
 * @param string $type Object type to template
 * @param array $data Associative array containing template data
 * @return string Theme wrapped sidebar
 */
function theme_template($file, $data)
{
    global $ssc_site_path;
    $theme = ssc_var_get('theme_default', SSC_DEFAULT_THEME);
    $f = "{$ssc_site_path}/themes/{$theme}/{$file}.tpl.php";
    // Check it exists
    if (!file_exists($f)) {
        return '';
    }
    // Populate template data
    extract($data, EXTR_SKIP);
    ob_start();
    include $f;
    $return = ob_get_contents();
    ob_end_clean();
    return $return;
}
Ejemplo n.º 6
0
/**
 * Form valided.  Log the user in
 */
function login_form_submit()
{
    // Perform user login
    global $ssc_database, $ssc_user;
    if ($ssc_user->id > 0) {
        ssc_add_message(SSC_MSG_WARN, t('You are already logged in as !name! To re-login, logout first.', array('!name' => $ssc_user->username)));
        return;
    }
    $pass = new PasswordHash(8, true);
    // Get user details
    $result = $ssc_database->query("SELECT id, password, ip, fullname, username, gid, accessed FROM #__user WHERE username = '******' LIMIT 1", $_POST['user']);
    if (!$result) {
        return;
    }
    if (!($user = $ssc_database->fetch_object($result))) {
        ssc_add_message(SSC_MSG_CRIT, t('Invalid user name or password'));
        return;
    }
    // Username is good - check password
    if (!$pass->CheckPassword($_POST['pass'], $user->password)) {
        ssc_add_message(SSC_MSG_CRIT, t('Invalid user name or password'));
        return;
    }
    // Password good too - valid credentials
    session_regenerate_id(true);
    ssc_add_message(SSC_MSG_INFO, t('Welcome, !user.<br />You last logged in on !date at !time from !ip', array('!user' => $user->fullname, '!date' => date(ssc_var_get('date_long', SSC_DATE_LONG), $user->accessed), '!time' => date(ssc_var_get('time_full', SSC_TIME_FULL), $user->accessed), '!ip' => $user->ip)));
    unset($user->password);
    unset($user->accessed);
    unset($user->ip);
    $ssc_user = $user;
    $ssc_user->useragent = md5($_SERVER['HTTP_USER_AGENT']);
    $ssc_database->query("UPDATE #__user SET accessed = %d, ip = '%s', useragent = '%s' WHERE id = %d LIMIT 1", time(), $_SERVER['REMOTE_ADDR'], $ssc_user->useragent, $ssc_user->id);
    if ($_GET['q'] == 'user/login') {
        ssc_redirect('/');
    }
}
Ejemplo n.º 7
0
/**
 * gravatar generation and caching function
 */
function _blog_gravatar_get_url($email)
{
    return "http://www.gravatar.com/avatar/" . md5(strtolower($email)) . "?s=" . ssc_var_get("blog.gravatar.size", "80") . "&r=" . ssc_var_get("blog.gravatar.rating", "pg") . "&d=" . ssc_var_get("blog.gravatar.default", "wavatar");
}
Ejemplo n.º 8
0
function fbapp_widget($args)
{
    global $ssc_database, $ssc_site_url;
    $ret = '';
    $result = $ssc_database->query("SELECT updated, url, status, who FROM #__social_status ORDER BY updated DESC LIMIT 5");
    if (!$result) {
        return;
    }
    $pic = ssc_var_get("fbapp_twitterpic", '');
    if ($pic == '') {
        return;
    }
    while ($data = $ssc_database->fetch_assoc($result)) {
        $ret .= '<div class="social_tweet"><img src="' . $pic . '" alt="" />' . $data['status'] . '<br />' . l(date('g:ia d M', $data['updated']), $data['url']) . "</div><hr />\n";
    }
    return array('title' => 'Twitter Feed', 'body' => $ret . '<div class="social_tweet">' . l('Follow @st_au', 'http://twitter.com/st_au') . '</div>');
}
Ejemplo n.º 9
0
/**
 * Get/set a CSS file to be loaded
 * @param string $path Path to the CSS file relative to the base
 * @param string $media Target media for the CSS file
 * @return array Array containing CSS paths
 */
function ssc_add_css($path = null, $media = 'all')
{
    global $ssc_site_url, $ssc_site_path;
    static $css = array();
    if (isset($path) && !array_key_exists(md5($path), $css)) {
        if (strpos($path, '.theme.css') === false) {
            $css[md5($path)] = array($ssc_site_url . $path, $media);
        } else {
            $p = str_replace('.theme.css', '.css', $path);
            if (ssc_var_get('theme.rebuild', false) || !file_exists($ssc_site_path . $p)) {
                $file = file_get_contents($ssc_site_path . $path);
                if (strpos($file, '$') !== false) {
                    $file = str_replace('$base_url$', $ssc_site_url, $file);
                    $file = str_replace('$theme_url$', "{$ssc_site_url}/themes/" . ssc_var_get('theme_default', SSC_DEFAULT_THEME), $file);
                }
                file_put_contents($ssc_site_path . $p, $file);
                chmod($ssc_site_path . $p, 0644);
            }
            $css[md5($path)] = array($ssc_site_url . $p, $media);
        }
    }
    return $css;
}