当前位置: 首页>>代码示例>>PHP>>正文


PHP scale_image函数代码示例

本文整理汇总了PHP中scale_image函数的典型用法代码示例。如果您正苦于以下问题:PHP scale_image函数的具体用法?PHP scale_image怎么用?PHP scale_image使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了scale_image函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: display_shoutbox

function display_shoutbox()
{
    global $db, $game, $portal_action;
    $count = $portal_action == 'full_shoutbox' ? 30 : 10;
    $sql = 'SELECT sb.*, u.user_name, u.user_avatar
            FROM shoutbox sb
            INNER JOIN (user u) USING (user_id)
            ORDER BY timestamp DESC
            LIMIT 0, ' . $count;
    if (($sb_posts = $db->queryrowset($sql)) === false) {
        message(DATABASE_ERROR, 'Could not query shoutbox data');
    }
    include_once 'include/libs/images.php';
    $game->out('
<table class="style_outer" border="0" cellpadding="2" cellspacing="2" width="90%">
  <tr>
    <td align="center">
      <span class="sub_caption">Shoutbox:</span><br><br>
      <table width="100%" border="0" cellpadding="2" cellspacing="2" class="style_inner">
    ');
    $count = count($sb_posts) - 1;
    for ($i = $count; $i >= 0; --$i) {
        //        $game->out('<i>'.$sb_posts[$i]['player_name'].' ('.date('d.m.y H:i', $sb_posts[$i]['timestamp']).')</i>:<br>'.wordwrap($sb_posts[$i]['message'], 50, '<br>', 1).'<br>');
        $game->out('<tr><td width="7%">');
        if (!empty($sb_posts[$i]['user_avatar'])) {
            $info = scale_image($sb_posts[$i]['user_avatar'], 100 * 0.35, 166 * 0.35);
            if ($info[0] > 0 && $info[1] > 0) {
                $game->out('<img src="' . $sb_posts[$i]['user_avatar'] . '" width="' . $info[0] . '" height="' . $info[1] . '">');
            } else {
                $game->out('&nbsp;');
            }
        } else {
            $game->out('&nbsp;');
        }
        $game->out('</td>');
        $game->out('<td width="92%"><a href="' . parse_link('a=stats&a2=viewplayer&id=' . $sb_posts[$i]['user_id']) . '"><i>' . $sb_posts[$i]['user_name'] . '</a> (' . date('d.m.y H:i', $sb_posts[$i]['timestamp']) . ')</i>: ' . wordwrap($sb_posts[$i]['message'], 85, '<br>', 1) . '</td></tr>');
    }
    $game->out('
      </table>
      <br>
      <table width="100%" border="0" cellpadding="1" cellspacing="1">
        <tr>
          <form name="shoutbox" method="post" action="' . parse_link('a=portal&do=post_shoutbox') . '" onSubmit="return this.submit_post.disabled = true;">
          <td width="100%">
            <input type="text" name="shoutbox_msg" size="80" class="field_nosize" maxlength="480" style="background-image:url(' . $game->GFX_PATH . 'template_bg4.jpg);">&nbsp;
            <input type="submit" name="submit_post" class="button_nosize" width="100" value="' . constant($game->sprache("TEXT0")) . '" style="background-image:url(' . $game->GFX_PATH . 'template_bg4.jpg);">
          </td>
          </form>
        </tr>
        <tr>
          <td>
            ' . ($portal_action == 'full_shoutbox' ? '<a href="' . parse_link('a=portal') . '">' . constant($game->sprache("TEXT1")) . '</a>' : '<a href="' . parse_link('a=portal&do=full_shoutbox') . '">' . constant($game->sprache("TEXT2")) . '</a>') . '
          </td>
        </tr>
      </table>
    </td>
  </tr>
</table>
    ');
}
开发者ID:startrekfinalfrontier,项目名称:UI,代码行数:60,代码来源:portal.php

示例2: create

 /**
  * Create a thumbnail from a given file
  * 
  * This function will create a new thumbnail based on input file and return 
  * path of generated thumbnail on success (FALSE othervise). If thumbnails 
  * already exists it will return its path
  *
  * @param string $path
  * @param string $prefix
  * @param integer $max_width
  * @param integer $max_height
  * @return string
  */
 function create($path, $prefix, $max_width, $max_height)
 {
     $destination = THUMBNAILS_PATH . '/' . $prefix . '-' . basename($path);
     if (is_file($destination)) {
         return $destination;
     } else {
         if (scale_image($path, $destination, $max_width, $max_height, IMAGETYPE_JPEG)) {
             return $destination;
         }
         // if
     }
     // if
     return false;
 }
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:27,代码来源:Thumbnails.class.php

示例3: cleanse_html

function cleanse_html($atom, $href)
{
    $html = SimpleHtmlDom\str_get_html($atom);
    foreach ($html->find('img') as $element) {
        // Skip smilies
        if (str_contains($element->src, '/smilies/')) {
            continue;
        }
        $class = 'img img-thumbnail forum-thumb';
        $element->outertext = '<a href="' . $href . '"><img class="' . $class . '" src="' . scale_image($element->src, 200) . '"></a>';
    }
    foreach ($html->find('p') as $element) {
        if ($element->class == 'dummy') {
            $element->outertext = '<small class="feed-small">' . $element->innertext . '</small>';
        }
    }
    $html->save;
    return $html;
}
开发者ID:kmklr72,项目名称:lmms.io,代码行数:19,代码来源:forums.php

示例4: resize_image_squared

function resize_image_squared($image_path, $target_width)
{
    scale_image($image_path, $target_width, $target_width);
    // target_width suffices. squared image.
    list($width, $height) = getimagesize($image_path);
    crop_image($image_path, min($width, $height), min($width, $height));
}
开发者ID:jaksmid,项目名称:website,代码行数:7,代码来源:file_upload_helper.php

示例5: edit_icon

 /**
  * Edit Project Icon
  *
  * @param void
  * @return null
  */
 function edit_icon()
 {
     if ($this->active_project->isNew()) {
         $this->httpError(HTTP_ERR_NOT_FOUND);
     }
     // if
     if (!$this->active_project->canEdit($this->logged_user)) {
         $this->httpError(HTTP_ERR_FORBIDDEN);
     }
     // if
     if (!extension_loaded('gd')) {
         $message = lang('<b>GD not Installed</b> - GD extension is not installed on your system. You will not be able to upload project icons, company logos and avatars!');
         if ($this->request->isAsyncCall()) {
             echo "<p>{$message}</p>";
             die;
         } else {
             $this->wireframe->addPageMessage($message, PAGE_MESSAGE_ERROR);
         }
         // if
     }
     // if
     if ($this->request->isSubmitted()) {
         if (!isset($_FILES['icon']) || !is_uploaded_file($_FILES['icon']['tmp_name'])) {
             $message = lang('Please select an image');
             if ($this->request->isAsyncCall()) {
                 $this->httpError(HTTP_ERR_OPERATION_FAILED, $message);
             } else {
                 flash_error($message);
                 $this->redirectToUrl($this->active_project->getEditIconUrl());
             }
             // if
         }
         // if
         if (can_resize_images()) {
             $errors = new ValidationErrors();
             do {
                 $from = WORK_PATH . '/' . make_password(10) . '_' . $_FILES['icon']['name'];
             } while (is_file($from));
             if (!move_uploaded_file($_FILES['icon']['tmp_name'], $from)) {
                 $errors->addError(lang("Can't copy image to work path"), 'icon');
             } else {
                 if (FIX_UPLOAD_PERMISSION !== false) {
                     @chmod($from, FIX_UPLOAD_PERMISSION);
                 }
                 // if
                 // small avatar
                 $to = $this->active_project->getIconPath();
                 $small = scale_image($from, $to, 16, 16, IMAGETYPE_GIF);
                 // large avatar
                 $to = $this->active_project->getIconPath(true);
                 $large = scale_image($from, $to, 40, 40, IMAGETYPE_GIF);
                 @unlink($from);
             }
             // if
             if (empty($from)) {
                 $errors->addError('Select icon', 'icon');
             }
             // if
             if ($errors->hasErrors()) {
                 $this->smarty->assign('errors', $errors);
                 $this->render();
             }
             // if
             cache_remove('project_icons');
         }
         // if
     }
     // if
 }
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:75,代码来源:ProjectController.class.php

示例6: upload

function upload($attachid)
{
    global $attachmentids, $options, $attachdb;
    if ($attachdb[$attachid]) {
        if ($attachdb[$attachid]['isimage']) {
            $attachmentids[$attachid] = $attachdb[$attachid]['articleid'];
            $a_thumb_path = $attachdb[$attachid]['thumb_filepath'];
            $a_path = $attachdb[$attachid]['filepath'];
            if ($attachdb[$attachid]['thumb_filepath'] && $options['attachments_thumbs'] && file_exists(SABLOG_ROOT . $a_thumb_path)) {
                $attachdb[$attachid]['filepath'] = $attachdb[$attachid]['thumb_filepath'];
                $a_path = $a_thumb_path;
            } else {
                $imagesize = @getimagesize(SABLOG_ROOT . $a_path);
                $size = explode('x', strtolower($options['attachments_thumbs_size']));
                $im = scale_image(array('max_width' => $size[0], 'max_height' => $size[1], 'cur_width' => $imagesize[0], 'cur_height' => $imagesize[1]));
                $attachdb[$attachid]['thumb_width'] = $im['img_width'];
                $attachdb[$attachid]['thumb_height'] = $im['img_height'];
            }
            return "<div class=\"attach\"><a href=\"" . $options['url'] . "attachment.php?id={$attachid}\" target=\"_blank\"><img src=\"" . $options['url'] . "{$a_path}\" alt=\"{$attachdb[$attachid][filename]} - 大小: {$attachdb[$attachid][filesize]} - 尺寸: {$imagesize[0]} x {$imagesize[1]} - 点击打开新窗口浏览全图\" width=\"{$attachdb[$attachid][thumb_width]}\" height=\"{$attachdb[$attachid][thumb_height]}\" /></a></div>";
        } else {
            $attachmentids[$attachid] = $attachdb[$attachid]['articleid'];
            return "<a href=\"" . $options['url'] . "attachment.php?id={$attachid}\" title=\"{$attachdb[$attachid][filename]} - 大小:{$attachdb[$attachid][filesize]} - 下载次数:{$attachdb[$attachid][downloads]}\" target=\"_blank\">{$attachdb[$attachid][filename]}</a>";
        }
    } else {
        return "[attach={$attachid}]";
    }
}
开发者ID:BGCX261,项目名称:zjnewcitycode-svn-to-git,代码行数:27,代码来源:attachment.func.php

示例7: eval

         if ($mybb->user['receivepms'] != 0 && $buddy['receivepms'] != 0 && $groupscache[$buddy['usergroup']]['canusepms'] != 0) {
             eval("\$send_pm = \"" . $templates->get("misc_buddypopup_user_sendpm") . "\";");
         } else {
             $send_pm = '';
         }
         if ($buddy['lastactive']) {
             $last_active = $lang->sprintf($lang->last_active, my_date($mybb->settings['dateformat'], $buddy['lastactive']) . ", " . my_date($mybb->settings['timeformat'], $buddy['lastactive']));
         } else {
             $last_active = $lang->sprintf($lang->last_active, $lang->never);
         }
         if ($buddy['avatar']) {
             $buddy['avatar'] = htmlspecialchars_uni($buddy['avatar']);
             if ($buddy['avatardimensions']) {
                 require_once MYBB_ROOT . "inc/functions_image.php";
                 list($width, $height) = explode("|", $buddy['avatardimensions']);
                 $scaled_dimensions = scale_image($width, $height, 44, 44);
             } else {
                 $scaled_dimensions = array("width" => 44, "height" => 44);
             }
         } else {
             $buddy['avatar'] = $theme['imgdir'] . "/default_avatar.gif";
             $scaled_dimensions = array("width" => 44, "height" => 44);
         }
         $margin_top = ceil((50 - $scaled_dimensions['height']) / 2);
         if ($buddy['lastactive'] > $timecut && ($buddy['invisible'] == 0 || $mybb->user['usergroup'] == 4) && $buddy['lastvisit'] != $buddy['lastactive']) {
             eval("\$buddys['online'] .= \"" . $templates->get("misc_buddypopup_user_online") . "\";");
         } else {
             eval("\$buddys['offline'] .= \"" . $templates->get("misc_buddypopup_user_offline") . "\";");
         }
     }
 } else {
开发者ID:slothly,项目名称:mybb,代码行数:31,代码来源:misc.php

示例8: fetch_scaled_avatar

function fetch_scaled_avatar($user, $max_width = 80, $max_height = 80)
{
    $scaled_dimensions = array("width" => $max_width, "height" => $max_height);
    if ($user['avatar']) {
        if ($user['avatardimensions']) {
            require_once MYBB_ROOT . "inc/functions_image.php";
            list($width, $height) = explode("|", $user['avatardimensions']);
            $scaled_dimensions = scale_image($width, $height, $max_width, $max_height);
        }
    }
    return array("width" => $scaled_dimensions['width'], "height" => $scaled_dimensions['height']);
}
开发者ID:GeorgeLVP,项目名称:mybb,代码行数:12,代码来源:users.php

示例9: createThumb

function createThumb($str_image_src, $ext, $suffix, $int_new_width, $int_new_height, $sql, $fid)
{
    if ($ext == "jpg") {
        $res_src_image = imagecreatefromjpeg($str_image_src);
    } elseif ($ext == "png") {
        $res_src_image = imagecreatefrompng($str_image_src);
    } elseif ($ext == "gif") {
        $res_src_image = imagecreatefromgif($str_image_src);
    }
    $str_image_dest = basename($str_image_src);
    $str_image_dest = realpath('.') . '\\images\\' . substr($str_image_dest, 0, strrpos($str_image_dest, '.')) . $suffix . '.jpg';
    $int_new_height_tmp = get_image_height($res_src_image, $int_new_width);
    $res_dst_image = imagecreatetruecolor($int_new_width, $int_new_height);
    // Check proportions are the same.
    if ($int_new_height / $int_new_width == imageSY($res_src_image) / imageSX($res_src_image)) {
        // Resize Image
        imagecopyresampled($res_dst_image, $res_src_image, 0, 0, 0, 0, $int_new_width, $int_new_height, imagesx($res_src_image), imagesy($res_src_image));
    } else {
        // Scale Image
        $res_scaled_image = scale_image(&$res_src_image, $int_new_width, $int_new_height);
        // Crop Image
        crop_image(&$res_dst_image, &$res_scaled_image, $int_new_width, $int_new_height);
    }
    imagejpeg($res_dst_image, $str_image_dest);
    global $nooutput;
    if ($nooutput == '' or !isset($nooutput)) {
        if (!isset($_SESSION["file_info"])) {
            $_SESSION["file_info"] = array();
        }
        ob_end_clean();
        ob_start();
        imagejpeg($res_dst_image);
        $imagevariable = ob_get_contents();
        ob_end_clean();
        $file_id = md5($_FILES["Filedata"]["tmp_name"] + rand() * 100000);
        $_SESSION["file_info"][$file_id] = $imagevariable;
        echo "FILEID:" . $file_id . "\n";
        // Return the file id to the script
        echo "FID:" . $fid;
        return $res_dst_image;
    }
}
开发者ID:Emaren,项目名称:agentpage,代码行数:42,代码来源:upload.php

示例10: MakeThumbnail

function MakeThumbnail($upfiledir, $src, $tName, $tw = '', $th = '', $scale = true, $tDir = "thumb")
{
    global $iCMS;
    $R = array();
    $image = "";
    $tMap = array(1 => 'gif', 2 => 'jpeg', 3 => 'png');
    $tw = empty($tw) ? (int) $iCMS->config['thumbwidth'] : $tw;
    $th = empty($th) ? (int) $iCMS->config['thumbhight'] : $th;
    if ($tw && $th) {
        list($width, $height, $type) = @getimagesize($src);
        if ($width < 1 && $height < 1) {
            $R['width'] = $tw;
            $R['height'] = $th;
            $R['src'] = $src;
            return $R;
        }
        if ($width > $tw || $height > $th) {
            createdir($upfiledir . $tDir);
            if ($scale) {
                $im = scale_image(array("mw" => $tw, "mh" => $th, "cw" => $width, "ch" => $height));
            } else {
                $im = array('w' => $tw, 'h' => $th);
            }
            $R['width'] = $im['w'];
            $R['height'] = $im['h'];
            $tName .= '_' . $R['width'] . 'x' . $R['height'];
            $img = icf($tMap[$type], $src);
            if ($img['res']) {
                $thumb = imagecreatetruecolor($im['w'], $im['h']);
                imagecopyresampled($thumb, $img['res'], 0, 0, 0, 0, $im['w'], $im['h'], $width, $height);
                PHP_VERSION != '4.3.2' && UnsharpMask($thumb);
                $R['src'] = $upfiledir . $tDir . "/" . $tName;
                __image($thumb, $img['type'], $R['src']);
                $R['src'] .= '.' . $img['type'];
            } else {
                $R['src'] = $src;
            }
        } else {
            $R['width'] = $width;
            $R['height'] = $height;
            $R['src'] = $src;
        }
        return $R;
    }
}
开发者ID:jonycookie,项目名称:projectm2,代码行数:45,代码来源:common.php

示例11: generate_thumbnail

/**
 * Generates a thumbnail based on specified dimensions (supports png, jpg, and gif)
 * 
 * @param string the full path to the original image
 * @param string the directory path to where to save the new image
 * @param string the filename to save the new image as
 * @param integer maximum hight dimension
 * @param integer maximum width dimension
 * @return array thumbnail on success, error code 4 on failure
 */
function generate_thumbnail($file, $path, $filename, $maxheight, $maxwidth)
{
    if (!function_exists("imagecreate")) {
        $thumb['code'] = 3;
        return $thumb;
    }
    $imgdesc = getimagesize($file);
    $imgwidth = $imgdesc[0];
    $imgheight = $imgdesc[1];
    $imgtype = $imgdesc[2];
    $imgattr = $imgdesc[3];
    $imgbits = $imgdesc['bits'];
    $imgchan = $imdesc['channels'];
    if ($imgwidth == 0 || $imgheight == 0) {
        $thumb['code'] = 3;
        return $thumb;
    }
    if ($imgwidth >= $maxwidth || $imgheight >= $maxheight) {
        check_thumbnail_memory($imgwidth, $imgheight, $imgtype, $imgbits, $imgchan);
        if ($imgtype == 3) {
            if (@function_exists("imagecreatefrompng")) {
                $im = @imagecreatefrompng($file);
            }
        } elseif ($imgtype == 2) {
            if (@function_exists("imagecreatefromjpeg")) {
                $im = @imagecreatefromjpeg($file);
            }
        } elseif ($imgtype == 1) {
            if (@function_exists("imagecreatefromgif")) {
                $im = @imagecreatefromgif($file);
            }
        } else {
            $thumb['code'] = 3;
            return $thumb;
        }
        if (!$im) {
            $thumb['code'] = 3;
            return $thumb;
        }
        $scale = scale_image($imgwidth, $imgheight, $maxwidth, $maxheight);
        $thumbwidth = $scale['width'];
        $thumbheight = $scale['height'];
        $thumbim = @imagecreatetruecolor($thumbwidth, $thumbheight);
        if (!$thumbim) {
            $thumbim = @imagecreate($thumbwidth, $thumbheight);
            $resized = true;
        }
        // Attempt to preserve the transparency if there is any
        $trans_color = imagecolortransparent($im);
        if ($trans_color >= 0 && $trans_color < imagecolorstotal($im)) {
            $trans = imagecolorsforindex($im, $trans_colors);
            $new_trans_color = imagecolorallocate($thumbim, $trans['red'], $trans['blue'], $trans['green']);
            imagefill($thumbim, 0, 0, $new_trans_color);
            imagecolortransparent($thumbim, $new_trans_color);
        }
        if (!isset($resized)) {
            @imagecopyresampled($thumbim, $im, 0, 0, 0, 0, $thumbwidth, $thumbheight, $imgwidth, $imgheight);
        } else {
            @imagecopyresized($thumbim, $im, 0, 0, 0, 0, $thumbwidth, $thumbheight, $imgwidth, $imgheight);
        }
        @imagedestroy($im);
        if (!function_exists("imagegif") && $imgtype == 1) {
            $filename = str_replace(".gif", ".jpg", $filename);
        }
        switch ($imgtype) {
            case 1:
                if (function_exists("imagegif")) {
                    @imagegif($thumbim, $path . "/" . $filename);
                } else {
                    @imagejpeg($thumbim, $path . "/" . $filename);
                }
                break;
            case 2:
                @imagejpeg($thumbim, $path . "/" . $filename);
                break;
            case 3:
                @imagepng($thumbim, $path . "/" . $filename);
                break;
        }
        @my_chmod($path . "/" . $filename, '0666');
        @imagedestroy($thumbim);
        $thumb['code'] = 1;
        $thumb['filename'] = $filename;
        return $thumb;
    } else {
        return array("code" => 4);
    }
}
开发者ID:benn0034,项目名称:SHIELDsite2.old,代码行数:98,代码来源:functions_image.php

示例12: imagecreatefromjpeg

            $image_res = imagecreatefromjpeg($img_temp);
            break;
        default:
            $image_res = false;
    }
    if ($image_res) {
        $img_info = pathinfo($img_name);
        $img_extension = strtolower($img_info["extension"]);
        $img_name_only = strtolower($img_info["filename"]);
        $new_file_name = $img_name_only . "_" . rand(0, 9999999999) . '.' . $img_extension;
        $thumb_folder = $img_folder . $thumb_prefix . $new_file_name;
        $image_folder = $img_folder . $new_file_name;
        if (!scale_image($image_res, $thumb_folder, $img_type, $img_width, $img_height, $jpg_quality, 'thumb')) {
            die("Error creating thumb :(");
        }
        if (!scale_image($image_res, $image_folder, $img_type, $img_width, $img_height, $jpg_quality, 'original')) {
            die("Error creating image :(");
        }
        if (save_data($_POST, $thumb_prefix, $new_file_name, $twidth, $theight, $fwidth, $fheight)) {
            echo '<IMG SRC="../photos/' . $thumb_prefix . $new_file_name . '">';
        }
        imagedestroy($image_res);
    }
}
function save_data($post, $tmb, $img, $twidth, $theight, $fwidth, $fheight)
{
    $title = $post["image_title"];
    $date = $post["image_date"];
    $category = $post["image_category"];
    $gear = $post["image_gear"];
    $description = $post["image_description"];
开发者ID:morgenfrue,项目名称:gallery,代码行数:31,代码来源:uploader.php

示例13: htmlspecialchars_uni

         for ($i = 0; $i < $user['stars']; ++$i) {
             $user['userstars'] .= "<img src=\"{$starimage}\" border=\"0\" alt=\"*\" />";
         }
     }
     if ($user['userstars'] && $usergroup['groupimage']) {
         $user['userstars'] = "<br />" . $user['userstars'];
     }
     // Show avatar
     if ($user['avatar'] != '') {
         $user['avatar'] = htmlspecialchars_uni($user['avatar']);
         $avatar_dimensions = explode("|", $user['avatardimensions']);
         if ($avatar_dimensions[0] && $avatar_dimensions[1]) {
             list($max_width, $max_height) = explode("x", my_strtolower($mybb->settings['memberlistmaxavatarsize']));
             if ($avatar_dimensions[0] > $max_width || $avatar_dimensions[1] > $max_height) {
                 require_once MYBB_ROOT . "inc/functions_image.php";
                 $scaled_dimensions = scale_image($avatar_dimensions[0], $avatar_dimensions[1], $max_width, $max_height);
                 $avatar_width_height = "width=\"{$scaled_dimensions['width']}\" height=\"{$scaled_dimensions['height']}\"";
             } else {
                 $avatar_width_height = "width=\"{$avatar_dimensions[0]}\" height=\"{$avatar_dimensions[1]}\"";
             }
         }
         eval("\$user['avatar'] = \"" . $templates->get("memberlist_user_avatar") . "\";");
     } else {
         $user['avatar'] = "";
     }
     $user['regdate'] = my_date($mybb->settings['dateformat'], $user['regdate']) . ", " . my_date($mybb->settings['timeformat'], $user['regdate']);
     $user['lastvisit'] = my_date($mybb->settings['dateformat'], $user['lastactive']) . ", " . my_date($mybb->settings['timeformat'], $user['lastactive']);
     $user['postnum'] = my_number_format($user['postnum']);
     eval("\$users .= \"" . $templates->get("memberlist_user") . "\";");
 }
 // Do we have no results?
开发者ID:GeorgeLVP,项目名称:mybb,代码行数:31,代码来源:memberlist.php

示例14: array

 require_once SABLOG_ROOT . 'include/func/attachment.func.php';
 $attachdb = array();
 $query = $DB->query("SELECT attachmentid, articleid, dateline, filename, filetype, filesize, downloads, filepath, thumb_filepath, thumb_width, thumb_height, isimage FROM {$db_prefix}attachments WHERE articleid IN ({$aids}) ORDER BY attachmentid");
 $size = explode('x', strtolower($options['attachments_thumbs_size']));
 while ($attach = $DB->fetch_array($query)) {
     $attach['filesize'] = sizecount($attach['filesize']);
     $attach['dateline'] = sadate('Y-m-d H:i', $attach['dateline']);
     $attach['filepath'] = $options['attachments_dir'] . $attach['filepath'];
     $attach['thumbs'] = 0;
     if ($attach['isimage']) {
         if ($attach['thumb_filepath'] && $options['attachments_thumbs'] && file_exists(SABLOG_ROOT . $options['attachments_dir'] . $attach['thumb_filepath'])) {
             $attach['thumbs'] = 1;
             $attach['thumb_filepath'] = $options['attachments_dir'] . $attach['thumb_filepath'];
         } else {
             $imagesize = @getimagesize(SABLOG_ROOT . $attach['filepath']);
             $im = scale_image(array('max_width' => $size[0], 'max_height' => $size[1], 'cur_width' => $imagesize[0], 'cur_height' => $imagesize[1]));
             $attach['thumb_width'] = $im['img_width'];
             $attach['thumb_height'] = $im['img_height'];
         }
         $articledb[$attach['articleid']]['image'][$attach['attachmentid']] = $attach;
     } else {
         $articledb[$attach['articleid']]['file'][$attach['attachmentid']] = $attach;
     }
     //插入附件到文章中用的
     $attachdb[$attach['attachmentid']] = $attach;
 }
 unset($attach);
 $DB->free_result($query);
 $attachmentids = array();
 $aids = explode(',', $aids);
 foreach ($aids as $articleid) {
开发者ID:BGCX261,项目名称:zjnewcitycode-svn-to-git,代码行数:31,代码来源:article.php

示例15: show_file

function show_file($file_id, $user, $success = null)
{
    global $LSP_URL, $DATA_DIR;
    $dbh =& get_db();
    $stmt = $dbh->prepare('SELECT licenses.name AS license, size, realname, filename, users.login, ' . 'categories.name AS category, subcategories.name AS subcategory,' . 'insert_date, update_date, description, downloads, files.id FROM files ' . 'INNER JOIN categories ON categories.id=files.category ' . 'INNER JOIN subcategories ON subcategories.id=files.subcategory ' . 'INNER JOIN users ON users.id=files.user_id ' . 'INNER JOIN licenses ON licenses.id=files.license_id ' . 'WHERE files.id=:file_id');
    $stmt->bindParam(':file_id', $file_id);
    $found = false;
    if ($stmt->execute()) {
        while ($object = $stmt->fetch(PDO::FETCH_ASSOC)) {
            $title = array($object['category'], $object['subcategory'], get_file_url($file_id));
            if ($success == null) {
                echo '<div class="col-md-9">';
                create_title($title);
            } else {
                if ($success === true) {
                    display_success("Updated successfully", $title);
                    echo '<div class="col-md-9">';
                } else {
                    if ($success === false) {
                        display_error("Update failed.", $title);
                        echo '<div class="col-md-9">';
                    } else {
                        display_success("{$success}", $title);
                    }
                }
            }
            echo '<table class="table table-striped">';
            show_basic_file_info($object, false);
            // Bump the download button under details block
            $url = htmlentities('download_file.php?file=' . $object['id'] . '&name=' . $object['filename']);
            echo '<tr><td><strong>Name:</strong>&nbsp;' . $object['filename'];
            if (is_image($url)) {
                echo '<br><br><a href="' . $url . '"><img class="thumbnail" src="' . scale_image($DATA_DIR . $file_id, 300, parse_extension($url)) . '" alt=""></a>';
            }
            echo '</td><td class="lsp-file-info">';
            echo '<a href="' . $url . '" id="downloadbtn" class="lsp-dl-btn btn btn-primary">';
            echo '<span class="fa fa-download lsp-download"></span>&nbsp;Download</a>';
            echo '</td></tr>';
            echo '<tr><td colspan="2"><div class="well"><strong>Description:</strong><p>';
            echo $object['description'] != '' ? parse_links(newline_to_br($object['description'], true)) : 'No description available.';
            echo '</p></div></td></tr>';
            echo '<tr><td colspan="2">';
            echo '<nav id="lspnav" class="navbar navbar-default"><ul class="nav navbar-nav">';
            $can_edit = $object['login'] == $user || is_admin(get_user_id($user));
            $can_rate = !SESSION_EMPTY();
            $rate_self = $object['login'] == $user;
            global $LSP_URL;
            create_toolbar_item('Comment', "{$LSP_URL}?comment=add&file={$file_id}", 'fa-comment', $can_rate);
            create_toolbar_item('Edit', "{$LSP_URL}?content=update&file={$file_id}", 'fa-pencil', $can_edit);
            create_toolbar_item('Delete', "{$LSP_URL}?content=delete&file={$file_id}", 'fa-trash', $can_edit);
            $star_url = $LSP_URL . '?' . file_show_query_string() . '&rate=';
            create_toolbar_item(get_stars($file_id, $star_url, $rate_self ? false : $can_rate), '', null, $can_rate, $rate_self);
            echo '</ul></nav>';
            echo '<strong>Comments:</strong>';
            echo '</td></tr>';
            get_comments($file_id);
            echo '</table></div>';
            $found = true;
            break;
        }
    }
    if (!$found) {
        display_error('Invalid file: "' . sanitize($file_id) . '"');
    }
    $stmt = null;
    $dbh = null;
}
开发者ID:kmklr72,项目名称:lmms.io,代码行数:67,代码来源:dbo.php


注:本文中的scale_image函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。