Exemplo n.º 1
0
 private function get_cached_code($handle, $do_not_echo = false, $ret_var = '')
 {
     $_cache_file = $this->cache_directory . 'tpl_' . (isset($this->files[$handle]) ? md5($this->files[$handle]) : md5(md5($handle)));
     $create_new_cache = 1;
     if ($_cache_present = file_exists($_cache_file)) {
         $_cache_stat = stat($_cache_file);
         $_template_stat = stat($this->files[$handle]);
         $create_new_cache = $_cache_stat['mtime'] < $_template_stat['mtime'] ? 1 : 0;
     }
     $code = '';
     if ($create_new_cache) {
         if (!isset($this->loadFile[$handle])) {
             if (!$this->loadfile($handle)) {
                 msgdie('FAIL', "Template->parse(): Couldn't load template file for handle {$handle} @ Line " . __LINE__);
             }
         }
         // actually compile the template now.
         if (!isset($this->compiled_code[$handle]) || empty($this->compiled_code[$handle])) {
             // Actually compile the code now.
             $code = $this->compile($this->uncompiled_code[$handle], $do_not_echo, $ret_var);
             $this->compiled_code[$handle] = $code;
         }
         $fh = fopen($_cache_file, 'w');
         fwrite($fh, $code);
         fclose($fh);
     } else {
         $code = file_get_contents($_cache_file);
     }
     return $code;
 }
Exemplo n.º 2
0
             $this->objSQL->updateRow('users', $update, 'id = ' . $uid);
             $this->objUser->setNotification($uid, 'Your Avatar has been reset by ' . $this->objUser->profile($this->objUser->grab('id')) . ' ', 'Avatar Reset');
             $script = "top.change_avatar('/" . root() . "images/no_avatar.png', '" . $_GET['username'] . "');";
         }
         echo '<script> ', $script, ' top.myLightWindow.deactivate();</script>';
         msgDie('OK', 'The avatar upload was successful.' . $avachgr, '', '', '', 0);
     } else {
         $this->objTPL->set_filenames(array('body' => 'modules/profile/template/ava_remove.tpl'));
         $this->objTPL->assign_vars(array('SFORM' => $this->objForm->start('remove', 'POST', '/' . root() . 'modules/profile/avatar/?action=reset' . (isset($_GET['username']) ? '&username='******'username'] : '')), 'EFORM' => $this->objForm->finish(), 'MSG' => 'Are you sure you want to reset ' . (isset($_GET['username']) ? $_GET['username'] . '\'s ' : 'your ') . 'avatar?', 'YES' => $this->objForm->button('Yes', 'submit', 'boxgreen'), 'NO' => $this->objForm->button('No', 'submit', 'boxred')));
         $this->objTPL->pparse('body');
     }
     break;
 case 'upload':
     if (HTTP_POST) {
         if ($_FILES['avatar']['error'] == 4) {
             msgdie('FAIL', 'The upload failed. Please try again.', '', '', '', 0);
         }
         $result = 0;
         $a = basename($_FILES['avatar']['name']);
         $file_ext = substr($a, strripos($a, '.'));
         $good_ext = array('.jpg', '.gif', '.bmp', '.png', '.jpeg');
         if (!in_array($file_ext, $good_ext)) {
             msgDie('FAIL', 'The upload failed. Please try again.', '', '', '', 0);
         }
         $file = $this->objUser->mkPasswd(md5($a), $uid) . $file_ext;
         if (!file_exists(cmsROOT . 'images/avatars/' . $uid . '/' . $file)) {
             if (!is_dir('images/avatars/' . $uid . '/')) {
                 mkdir('images/avatars/' . $uid . '/');
             }
             $target_path = cmsROOT . 'images/avatars/' . $uid . '/' . $file;
             if (@move_uploaded_file($_FILES['avatar']['tmp_name'], $target_path)) {
Exemplo n.º 3
0
            $_POST[$e] = '';
        }
    }
    echo $objForm->outputForm(array('FORM_START' => $objForm->start('register', array('method' => 'POST', 'action' => '?')), 'FORM_END' => $objForm->finish(), 'FORM_TITLE' => 'User Registration', 'FORM_SUBMIT' => $objForm->button('submit', 'Submit'), 'FORM_RESET' => $objForm->button('reset', 'Reset')), array('field' => array('User Info' => '_header_', 'Username' => $objForm->inputbox('username', 'hidden') . $objForm->inputbox('uname', 'text', $_POST['username'], array('extra' => 'maxlength="20" size="20"', 'required' => true)), 'Password' => $objForm->inputbox('password', 'password', $_POST['password'], array('required' => true)), 'Verify Password' => $objForm->inputbox('password_verify', 'password', $_POST['password_verify'], array('required' => true)), 'Email' => $objForm->inputbox('email', 'text', $_POST['email'], array('required' => true)), 'Captcha' => '_header_', 'Recaptcha' => $objForm->loadCaptcha('captcha')), 'desc' => array('Username' => 'This field can be [a-zA-Z0-9-_.]', 'Recaptcha' => $objForm->loadCaptcha('desc') . '<br />' . langVar('L_CAPTCHA_DESC')), 'errors' => $_SESSION['register']['error']));
    $objPage->showFooter();
} else {
    $userInfo = array();
    if (is_empty($_POST)) {
        $objPage->redirect($objCore->config('global', 'fullPath'), 1, 0);
        msgdie('FAIL', 'Error: Please use the form to submit your registration request.');
    }
    //the normal user cannot see this field so if it has value it is in this case,
    //to be considered as a spam submittion and disregarded
    if (!is_empty($_POST['username'])) {
        $objPage->redirect($objCore->config('global', 'fullPath'), 1, 0);
        msgdie('FAIL', 'Error: Spam attempt detected.');
    }
    //run through each of the expected fields and make sure theyre are here
    //we dont add the captcha in here purely cause the admin might hook in another captcha
    //and we wont know what fields it outputs etc
    $fields = array('uname', 'password', 'password_verify', 'email');
    foreach ($fields as $e) {
        if (!isset($_POST[$e]) || is_empty($_POST[$e])) {
            $_error[$e] = 'Please make sure all the fields are populated (' . $e . ').';
        }
    }
    //validate the username conforms to site standards
    if (!isset($_error['username']) && !$objUser->validateUsername($_POST['username'])) {
        $_error['username'] = '******';
    }
    //make sure there isnt already a user in the db with this username