Esempio n. 1
0
/**
 * Smarty Block Plugin to wrap its contents within another template.
 *
 * @access  public
 * @param   string[]    $params     parameters passed to import directive
 * @param   string      $content    content of block
 * @param   object      $caller     reference to calling Smarty class
 * @param   boolean     $repeat     set to true to repeat the block
 * @return  string                  content to replace block in output
 */
function smarty_block_wrap($params, $content, &$smarty, &$repeat)
{
    if (empty($params['file'])) {
        $smarty->_syntax_error("missing 'file' attribute in wrap tag", E_USER_ERROR, __FILE__, __LINE__);
    }
    $file = $params['file'];
    unset($params['file']);
    if (extname($file) == '') {
        $file .= '.tpl';
    }
    $assign = null;
    if (!empty($params['assign'])) {
        $assign = $params['assign'];
        unset($params['assign']);
    }
    $insert = 'content';
    if (!empty($params['insert'])) {
        $insert = $params['insert'];
        unset($params['insert']);
    }
    // Remember the template variables
    $_smarty_tpl_vars = $smarty->_tpl_vars;
    $params[$insert] = $content;
    ob_start();
    $smarty->_smarty_include(array('smarty_include_tpl_file' => $file, 'smarty_include_vars' => $params));
    $output = ob_get_contents();
    ob_end_clean();
    $smarty->_tpl_vars = $_smarty_tpl_vars;
    unset($_smarty_tpl_vars);
    if ($assign) {
        $smarty->assign($assign, $output);
        return '';
    }
    return $output;
}
Esempio n. 2
0
 function oneditimg()
 {
     if (isset($_FILES["userimage"])) {
         $uid = intval($this->get[2]);
         $avatardir = "/data/avatar/";
         $extname = extname($_FILES["userimage"]["name"]);
         if (!isimage($extname)) {
             exit('type_error');
         }
         $upload_tmp_file = TIPASK_ROOT . '/data/tmp/user_avatar_' . $uid . '.' . $extname;
         $uid = abs($uid);
         $uid = sprintf("%09d", $uid);
         $dir1 = $avatardir . substr($uid, 0, 3);
         $dir2 = $dir1 . '/' . substr($uid, 3, 2);
         $dir3 = $dir2 . '/' . substr($uid, 5, 2);
         !is_dir(TIPASK_ROOT . $dir1) && forcemkdir(TIPASK_ROOT . $dir1);
         !is_dir(TIPASK_ROOT . $dir2) && forcemkdir(TIPASK_ROOT . $dir2);
         !is_dir(TIPASK_ROOT . $dir3) && forcemkdir(TIPASK_ROOT . $dir3);
         $smallimg = $dir3 . "/small_" . $uid . '.' . $extname;
         if (move_uploaded_file($_FILES["userimage"]["tmp_name"], $upload_tmp_file)) {
             $avatar_dir = glob(TIPASK_ROOT . $dir3 . "/small_{$uid}.*");
             foreach ($avatar_dir as $imgfile) {
                 if (strtolower($extname) != extname($imgfile)) {
                     unlink($imgfile);
                 }
             }
             if (image_resize($upload_tmp_file, TIPASK_ROOT . $smallimg, 80, 80)) {
                 echo 'ok';
             }
         }
     } else {
         if ($this->setting["ucenter_open"]) {
             $this->load('ucenter');
             $imgstr = $_ENV['ucenter']->set_avatar($this->user['uid']);
         }
         include template("editimg");
     }
 }
Esempio n. 3
0
    $path = str_replace(DIRECTORY_SEPARATOR, '/', $path);
}
if (!empty($_SERVER['PATH_INFO'])) {
    $path = dirname(__FILE__) . $_SERVER['PATH_INFO'];
} else {
    $response->Redirect(TNT_REQUEST_URI . '/index.html');
    die(TNT_REQUEST_URI);
}
// Does the path exist - if not return a '404 Not Found' status
if (!file_exists($path) || !is_readable($path)) {
    echo 'path does not exist: ' . $path;
    header('HTTP/1.1 404 Not Found');
    TNT::Shutdown();
}
// Is it the path to a template file - if not send it directly
$ext = extname(strtolower($path));
if ($ext != 'html') {
    switch ($ext) {
        case 'gif':
            header('content-type: image/gif');
            break;
        case 'gif':
            header('content-type: image/jpeg');
            break;
        case 'png':
            header('content-type: image/png');
            break;
    }
    passthru($path);
    TNT::Shutdown();
    break;