Esempio n. 1
0
/**
*ͼÏñ´¦Àíº¯Êý
**/
function gdpic($srcFile, $dstFile, $width, $height, $type = '')
{
    require_once ROOT_PATH . "inc/waterimage.php";
    if (is_array($type)) {
        //½ØÈ¡Ò»²¿·Ö,ÒÔÂú×ãÆ¥Åä³ß´ç
        cutimg($srcFile, $dstFile, $x = $type[x] ? $type[x] : 0, $y = $type[y] ? $type[y] : 0, $width, $height, $x2 = $type[x2] ? $type[x2] : 0, $y2 = $type[y2] ? $type[y2] : 0, $scale = $type[s] ? $type[s] : 100, $fix = $type[fix] ? $type[fix] : '');
    } elseif ($type == 1) {
        //³É±ÈÀýµÄËõ·Å
        ResizeImage($srcFile, $dstFile, $width, $height);
    } else {
        //Óë³ß´ç²»Æ¥Åäʱ.ÓÃÉ«²ÊÌî³ä
        gdfillcolor($srcFile, $dstFile, $width, $height);
    }
}
Esempio n. 2
0
function GetContent($part, &$attachments)
{
    $config = GetConfig();
    $meta_return = NULL;
    DecodeBase64Part($part);
    if (BannedFileName($part->ctype_parameters['name']) || BannedFileName($part->ctype_parameters['name'])) {
        return NULL;
    }
    if ($part->ctype_primary == "application" && $part->ctype_secondary == "octet-stream") {
        if ($part->disposition == "attachment") {
            $image_endings = array("jpg", "png", "gif", "jpeg", "pjpeg");
            foreach ($image_endings as $type) {
                if (eregi(".{$type}\$", $part->d_parameters["filename"])) {
                    $part->ctype_primary = "image";
                    $part->ctype_secondary = $type;
                    break;
                }
            }
        } else {
            $mimeDecodedEmail = DecodeMIMEMail($part->body);
            FilterTextParts($mimeDecodedEmail);
            foreach ($mimeDecodedEmail->parts as $section) {
                $meta_return .= GetContent($section, $attachments);
            }
        }
    }
    if ($part->ctype_primary == "multipart" && $part->ctype_secondary == "appledouble") {
        $mimeDecodedEmail = DecodeMIMEMail("Content-Type: multipart/mixed; boundary=" . $part->ctype_parameters["boundary"] . "\n" . $part->body);
        FilterTextParts($mimeDecodedEmail);
        FilterAppleFile($mimeDecodedEmail);
        foreach ($mimeDecodedEmail->parts as $section) {
            $meta_return .= GetContent($section, $attachments);
        }
    } else {
        switch (strtolower($part->ctype_primary)) {
            case 'multipart':
                FilterTextParts($part);
                foreach ($part->parts as $section) {
                    $meta_return .= GetContent($section, $attachments);
                }
                break;
            case 'text':
                HandleMessageEncoding($part->headers["content-transfer-encoding"], $part->ctype_parameters["charset"], $part->body);
                //go through each sub-section
                if ($part->ctype_secondary == 'enriched') {
                    //convert enriched text to HTML
                    $meta_return .= etf2HTML($part->body) . "\n";
                } elseif ($part->ctype_secondary == 'html') {
                    //strip excess HTML
                    $meta_return .= HTML2HTML($part->body) . "\n";
                } else {
                    //regular text, so just strip the pgp signature
                    if (ALLOW_HTML_IN_BODY) {
                        $meta_return .= $part->body . "\n";
                    } else {
                        $meta_return .= htmlentities($part->body) . "\n";
                    }
                    $meta_return = StripPGP($meta_return);
                }
                break;
            case 'image':
                $file = GenerateImageFileName($config["REALPHOTOSDIR"], $part->ctype_secondary);
                //This makes sure there is no collision
                $ctr = 0;
                while (file_exists($file) && $ctr < 1000) {
                    $file = GenerateImageFileName($config["REALPHOTOSDIR"], $part->ctype_secondary);
                    $ctr++;
                }
                if ($ctr >= 1000) {
                    die("Unable to find a name for images that does not collide\n");
                }
                $fileName = basename($file);
                $fp = fopen($file, 'w');
                fwrite($fp, $part->body);
                fclose($fp);
                @exec('chmod 755 ' . $file);
                if ($config["USE_IMAGEMAGICK"] && $config["AUTO_SMART_SHARP"]) {
                    ImageMagickSharpen($file);
                }
                $mimeTag = '<!--Mime Type of File is ' . $part->ctype_primary . "/" . $part->ctype_secondary . ' -->';
                $thumbImage = NULL;
                $cid = trim($part->headers["content-id"], "<>");
                //cids are in <cid>
                if ($config["RESIZE_LARGE_IMAGES"]) {
                    list($thumbImage, $fullImage) = ResizeImage($file, strtolower($part->ctype_secondary));
                }
                $attachments["image_files"][] = array($thumbImage ? $config["REALPHOTOSDIR"] . $thumbImage : NULL, $config["REALPHOTOSDIR"] . $fileName, $part->ctype_secondary);
                if ($thumbImage) {
                    $marime = DetermineImageSize($file);
                    $marimex = $marime[0] + 20;
                    $marimey = $marime[1] + 20;
                    $attachments["html"][] .= $mimeTag . '<div class="' . $config["IMAGEDIV"] . '"><a href="' . $config["URLPHOTOSDIR"] . $fullImage . '" onclick="window.open(' . "'" . $config["URLPHOTOSDIR"] . $fullImage . "','" . "full_size_image" . "','" . "toolbar=0,scrollbars=0,location=0,status=0,menubar=0,resizable=1,height=" . $marimey . ",width=" . $marimex . "');" . "return false;" . '"><img src="' . $config["URLPHOTOSDIR"] . $thumbImage . '" alt="' . $part->ctype_parameters['name'] . '" title="' . $part->ctype_parameters['name'] . '" style="' . $config["IMAGESTYLE"] . '" class="' . $config["IMAGECLASS"] . '" /></a></div>' . "\n";
                    if ($cid) {
                        $attachments["cids"][$cid] = array($config["URLPHOTOSDIR"] . $fullImage, count($attachments["html"]) - 1);
                    }
                } else {
                    $attachments["html"][] .= $mimeTag . '<div class="' . $config["IMAGEDIV"] . '"><img src="' . $config["URLPHOTOSDIR"] . $fileName . '" alt="' . $part->ctype_parameters['name'] . '" style="' . $config["IMAGESTYLE"] . '" class="' . $config["IMAGECLASS"] . '"  /></div>' . "\n";
                    if ($cid) {
                        $attachments["cids"][$cid] = array($config["URLPHOTOSDIR"] . $fileName, count($attachments["html"]) - 1);
                    }
                }
                break;
            default:
                if (in_array(strtolower($part->ctype_primary), $config["SUPPORTED_FILE_TYPES"])) {
                    //pgp signature - then forget it
                    if ($part->ctype_secondary == 'pgp-signature') {
                        break;
                    }
                    //other attachments save to FILESDIR
                    $filename = $part->ctype_parameters['name'];
                    $file = $config["REALFILESDIR"] . $filename;
                    $fp = fopen($file, 'w');
                    fwrite($fp, $part->body);
                    fclose($fp);
                    @exec('chmod 755 ' . $file);
                    $cid = trim($part->headers["content-id"], "<>");
                    //cids are in <cid>
                    if ($part->ctype_secondary == "3gpp" || $part->ctype_secondary == "3gp" || $part->ctype_secondary == "3g2" || $part->ctype_secondary == "3gpp2") {
                        if ($config["3GP_QT"]) {
                            //Shamelessly borrowed from http://www.postneo.com/2003/12/19/embedding-3gpp-in-html
                            $attachments["html"][] = '<!--Mime Type of File is ' . $part->ctype_primary . "/" . $part->ctype_secondary . ' -->' . '<a href="' . $config["URLFILESDIR"] . $filename . '">Video' . '<object ' . 'classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" ' . 'codebase="http://www.apple.com/qtactivex/qtplugin.cab" ' . 'width="128" ' . 'height="112"> ' . '<param name="src" VALUE="' . $config["URLFILESDIR"] . $filename . '"> ' . '<param name="autoplay" VALUE="false"> ' . '<param name="controller" VALUE="true"> ' . '<embed ' . 'src="' . $config["URLFILESDIR"] . $filename . '" ' . 'width="128" ' . 'height="112" ' . 'autoplay="true" ' . 'controller="true" ' . 'type="video/quicktime" ' . 'pluginspage="http://www.apple.com/quicktime/download/" ' . 'width="128" ' . 'height="150"></embed> ' . '</object></a>';
                        } else {
                            if (file_exists($config["3GP_FFMPEG"])) {
                                $fileName = basename($file);
                                //options from http://www.getid3.org/phpBB2/viewtopic.php?p=1290&
                                $scaledFileName = "thumb." . $fileName;
                                $scaledFile = $config["REALPHOTOSDIR"] . $scaledFileName;
                                @exec(escapeshellcmd($config["3GP_FFMPEG"]) . " -i " . escapeshellarg($file) . " -y -ss 00:00:01 -vframes 1 -an -sameq -f gif " . escapeshellarg($scaledFile));
                                @exec('chmod 755 ' . escapeshellarg($scaledFile));
                                $attachments["html"][] .= '<!--Mime Type of File is ' . $part->ctype_primary . "/" . $part->ctype_secondary . ' --><div class="' . $config["3GPDIV"] . '"><a href="' . $config["URLPHOTOSDIR"] . $fileName . '"><img src="' . $config["URLPHOTOSDIR"] . $scaledFileName . '" alt="' . $part->ctype_parameters['name'] . '" style="' . $config["IMAGESTYLE"] . '" class="' . $config["IMAGECLASS"] . '" /></a></div>' . "\n";
                            } else {
                                $attachments["html"][] = '<!--Mime Type of File is ' . $part->ctype_primary . "/" . $part->ctype_secondary . ' --><div class="' . $config["ATTACHMENTDIV"] . '"><a href="' . $config["URLFILESDIR"] . $filename . '" class="' . $config["3GPCLASS"] . '">' . $part->ctype_parameters['name'] . '</a></div>' . "\n";
                            }
                        }
                    } elseif ($part->ctype_secondary == "x-shockwave-flash") {
                        $attachments["html"][] = '<!--Mime Type of File is ' . $part->ctype_primary . "/" . $part->ctype_secondary . ' -->' . '<object ' . 'classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"  ' . 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" ' . 'width=""  ' . 'height=""> ' . '<param name="movie" value="' . $config["URLFILESDIR"] . $filename . '"> ' . '<param name="quality" value="high"> ' . '<embed  ' . 'src="' . $config["URLFILESDIR"] . $filename . '"  ' . 'width=""  ' . 'height=""  ' . 'quality="high"  ' . 'pluginspage="http://www.macromedia.com/go/getflashplayer"  ' . 'type="application/x-shockwave-flash"  ' . 'width=""  ' . 'height=""></embed> ' . '</object>';
                    } else {
                        $attachments["html"][] = '<!--Mime Type of File is ' . $part->ctype_primary . "/" . $part->ctype_secondary . ' --><a href="' . $config["URLFILESDIR"] . $filename . '">' . $part->ctype_parameters['name'] . '</a>' . "\n";
                    }
                    if ($cid) {
                        $attachments["cids"][$cid] = array($config["URLFILESDIR"] . $filename, count($attachments["html"]) - 1);
                    }
                }
                break;
        }
    }
    return $meta_return;
}
$query = "SELECT * FROM products WHERE deleted='0' AND id=" . MySQLQuote($product_id);
$product = MySQLSELECT($query);
$query = "SELECT * FROM categories WHERE deleted='0'";
$cat_list = MySQLSELECT($query);
// $smarty = new SmartyEx;
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $product_id = $_POST['product_id'];
    $product_category = $_POST['product_category'];
    $product_price = $_POST['product_price'];
    $product_name = $_POST['product_name'];
    $product_description = $_POST['product_description'];
    $basefilename = basename($_FILES['product_image']['name']);
    if (!empty($basefilename)) {
        $tmp_upload = UPLOADS . $basefilename;
        if (move_uploaded_file($_FILES['product_image']['tmp_name'], $tmp_upload)) {
            ResizeImage($tmp_upload, 800, 600);
            rename($tmp_upload . '_resized', SYS_IMAGES_PATH . $basefilename);
            unlink($tmp_upload);
        }
        unlink(SYS_IMAGES_PATH . $product['product_image']);
        MySQLUPDATE('products', array('id' => $product_id), array('product_category' => $product_category, 'product_price' => MySQLQuote($product_price), 'product_name' => MySQLQuote($product_name), 'product_image' => MySQLQuote($basefilename), 'product_description' => MySQLQuote($product_description), 'updated_date' => date('Y-m-d H:i:s')));
    } else {
        MySQLUPDATE('products', array('id' => $product_id), array('product_category' => $product_category, 'product_price' => MySQLQuote($product_price), 'product_name' => MySQLQuote($product_name), 'product_description' => MySQLQuote($product_description), 'updated_date' => date('Y-m-d H:i:s')));
    }
    $_SESSION['flash']['update_product_ok'] = '1';
    header('Location: /quanly/product_detail.php?product_id=' . $product_id);
    exit;
}
if (isset($_SESSION['flash']['update_product_ok'])) {
    $smarty->assign('update_ok', '1');
    unset($_SESSION['flash']['update_product_ok']);
Esempio n. 4
0
        echo $font_style;
        ?>
;overflow:hidden;"><?php 
        echo $ovr->overlay_text;
        ?>
</textarea>
               
               <?php 
    }
    ?>
             
             <?php 
    if ($ovr->image != '' && $ovr->show_image_on_area == 1) {
        $src = Yii::app()->request->baseUrl . '/files/' . uid() . '/' . $ovr->image;
        $r_url = Yii::getPathOfAlias('webroot') . '/files/' . uid() . '/' . $ovr->image;
        ResizeImage($r_url, $r_url, 1024, 768, 80);
        echo "<img data-show='{$ovr->always_show_image}' src=" . $src . '?rand=' . rand(100000, 999999) . '"';
        $visibility = 'hidden';
        if ($ovr->always_show_image != 0) {
            $visibility = 'visible';
        }
        ?>
                       style="opacity:<?php 
        echo (int) $ovr->image_opacity / 100;
        ?>
;height: <?php 
        echo $points[2];
        ?>
px; width: <?php 
        echo $points[3];
        ?>
Esempio n. 5
0
function GetMySmallImg($classid, $no, $insertfile, $filepath, $yname, $maxwidth, $maxheight, $name, $id, $cjid, $userid, $username)
{
    global $empire, $dbtbpre, $public_r, $efileftp_fr;
    if (empty($yname)) {
        return "";
    }
    $no = "[s]" . $no;
    $filer = ResizeImage($yname, $name, $maxwidth, $maxheight, $public_r['spickill']);
    if ($filer['file']) {
        $insertfile = "small" . $insertfile . $filer['filetype'];
        $filesize = @filesize($filer['file']);
        //写入数据库
        $filetime = date("Y-m-d H:i:s");
        //变量处理
        $filesize = (int) $filesize;
        $classid = (int) $classid;
        $id = (int) $id;
        $cjid = (int) $cjid;
        $sql = $empire->query("insert into {$dbtbpre}enewsfile(filename,filesize,adduser,path,filetime,classid,no,type,id,cjid,onclick,fpath) values('{$insertfile}',{$filesize},'{$username}','{$filepath}','{$filetime}',{$classid},'{$no}',1,{$id},{$cjid},0,'{$public_r['fpath']}');");
        //FileServer
        if ($public_r['openfileserver']) {
            $efileftp_fr[] = $name . $filer['filetype'];
        }
    }
    return $filer;
}
Esempio n. 6
0
     case "11":
         if (isset($HTTP_POST_VARS['newname']) && $HTTP_POST_VARS['newname'] != '') {
             $uploadnm = $HTTP_POST_VARS['newname'];
         } else {
             if ($HTTP_POST_FILES['the_file']['name'] != urldecode($HTTP_POST_FILES['the_file']['name'])) {
                 $uploadnm = urldecode($HTTP_POST_FILES['the_file']['name']);
             } else {
                 $uploadnm = $HTTP_POST_FILES['the_file']['name'];
             }
         }
         $size = array($HTTP_POST_VARS['newX'], $HTTP_POST_VARS['newY']);
         $kp = "";
         //if ($HTTP_POST_VARS['newX'] == "" || $HTTP_POST_VARS['newY'] == "") {
         $kp = "1";
         //}
         $upload_error = ResizeImage($HTTP_POST_FILES['the_file'], $the_path . DIRECTORY_SEPARATOR . $uploadnm, $size[0], $size[1], $HTTP_POST_FILES['the_file']['type'], (int) isset($HTTP_POST_VARS['Sharpen']), $kp);
         break;
 }
 if ($upload_error != "") {
     echo $upload_error;
 } else {
     echo "<script>\n";
     echo "if (window.opener._dlg_) { \n";
     //echo "	window.opener._dlg_.frames['centru'].location.reload(true);\n";
     echo "\twindow.opener._dlg_.frames['centru'].location = window.opener._dlg_.frames['centru'].location + '&rand=' + Math.random();\n";
     echo "} else { \n";
     echo "\twindow.opener.parent.frames['centru'].location.reload(true);\n";
     echo "}\n";
     echo "window.close();</script>";
 }
 exit;
Esempio n. 7
0
 function InputFile($filez, $filesize = 500)
 {
     $CI =& get_instance();
     $file_up = $_FILES[$filez]['name'];
     $file_up = date("YmdHis") . "." . str_replace("-", "_", url_title($file_up));
     $myfile_up = $_FILES[$filez]['tmp_name'];
     $ukuranfile_up = $_FILES[$filez]['size'];
     if ($filez == "foto") {
         $up_file = "./" . $CI->config->item('path_upload') . "/foto/" . $file_up;
     } else {
         $up_file = "./" . $CI->config->item('path_upload') . "/" . $file_up;
     }
     $ext_file = strrchr($file_up, '.');
     if ($ukuranfile_up < $filesize * 1024) {
         if (strtolower($ext_file) == ".jpg" || strtolower($ext_file) == ".JPG" || strtolower($ext_file) == ".jpeg" || strtolower($ext_file) == ".png") {
             if (copy($myfile_up, $up_file)) {
                 ResizeImage($up_file, 250, 250);
                 return $file_up;
             }
         } else {
             if (copy($myfile_up, $up_file)) {
                 return $file_up;
             } else {
                 return 3;
             }
         }
     } else {
         return 2;
     }
 }
Esempio n. 8
0
<?php

$img = $_GET['img'];
$height = $_GET['h'];
$width = $_GET['w'];
$smimg = ResizeImage('../' . $img, $width, $height, '../upload/' . microtime());
header("content-type:image/png");
echo file_get_contents($smimg);
function ResizeImage($imgPath, $maxwidth, $maxheight, $name)
{
    $ary = explode(".", $imgPath);
    $ext = $ary[count($ary) - 1];
    if ($ext == "jpg" || $ext == "jepg") {
        $im = imagecreatefromjpeg($imgPath);
    } elseif ($ext == "png") {
        $im = imagecreatefrompng($imgPath);
    } elseif ($ext == "gif") {
        $im = imagecreatefromgif($imgPath);
    }
    if ($im) {
        if (file_exists("{$name}.jpg")) {
            unlink("{$name}.jpg");
        }
        $width = imagesx($im);
        $height = imagesy($im);
        if ($maxwidth && $width > $maxwidth || $maxheight && $height > $maxheight) {
            if ($maxwidth && $width > $maxwidth) {
                $widthratio = $maxwidth / $width;
                $RESIZEWIDTH = true;
            }
            if ($maxheight && $height > $maxheight) {
Esempio n. 9
0
 if ($im) {
     // Insert the row
     $sql = "INSERT INTO " . ADS_IMAGES_TABLE . " \n\t\t\t\t\t\tVALUES ({$id}, 0, '', 1)";
     if (!$db->sql_query($sql)) {
         message_die(GENERAL_ERROR, 'Could not insert images row', '', __LINE__, __FILE__, $sql);
     }
     $img_seq_no = $db->sql_nextid();
     // First create the thumbnail
     $filename = ADS_IMAGES_PATH . "ad" . $id . "_img" . $img_seq_no . "_thumb";
     ResizeImage($im, $ads_config['thumb_img_width'], $ads_config['thumb_img_height'], $filename);
     // Then create the medium size image
     $filename = ADS_IMAGES_PATH . "ad" . $id . "_img" . $img_seq_no . "_medium";
     ResizeImage($im, $ads_config['medium_img_width'], $ads_config['medium_img_height'], $filename);
     // Then create the large size image
     $filename = ADS_IMAGES_PATH . "ad" . $id . "_img" . $img_seq_no . "_large";
     ResizeImage($im, $ads_config['large_img_width'], $ads_config['large_img_height'], $filename);
     if (file_exists(ADS_IMAGES_PATH . 'ad' . $id . '_img' . $img_seq_no . '_thumb.jpg') and file_exists(ADS_IMAGES_PATH . 'ad' . $id . '_img' . $img_seq_no . '_medium.jpg') and file_exists(ADS_IMAGES_PATH . 'ad' . $id . '_img' . $img_seq_no . '_large.jpg')) {
         // Update the row
         $sql = "UPDATE " . ADS_IMAGES_TABLE . " \n\t\t\t\t\t\t\tSET img_deleted_ind = 0\n\t\t\t\t\t\t\tWHERE id = {$id}\n\t\t\t\t\t\t\tAND img_seq_no = {$img_seq_no}";
     } else {
         message_die(GENERAL_ERROR, $lang['image_creation_failed']);
     }
     if (!$db->sql_query($sql)) {
         message_die(GENERAL_ERROR, 'Could not insert images row', '', __LINE__, __FILE__, $sql);
     }
     // Now destroy the temporary image
     ImageDestroy($im);
     // Put out the confirmation message
     $template->assign_vars(array('META' => '<meta http-equiv="refresh" content="3;url=' . append_sid("ads_item.{$phpEx}?id={$id}") . '">'));
     $message = $lang['create_img_confirmation'] . "<br /><br />" . sprintf($lang['click_to_add_images'], "<a href=\"" . append_sid("ads_images.{$phpEx}?id={$id}") . "\">", "</a>") . "<br /><br />" . sprintf($lang['click_to_view_ad'], "<a href=\"" . append_sid("ads_item.{$phpEx}?id={$id}") . "\">", "</a>") . "<br /><br />" . sprintf($lang['click_return_ads_index'], "<a href=\"" . append_sid("adverts.{$phpEx}") . "\">", "</a>");
     message_die(GENERAL_MESSAGE, $message);
Esempio n. 10
0
function DisplayImage($Image, $Size)
{
    if ($Image != "" && $Size != "") {
        if (!file_exists("upload/{$Image}...{$Size}")) {
            $NewThumb = ResizeImage("upload/{$Image}", $Size);
            imagejpeg($NewThumb, "upload/{$Image}...{$Size}");
            chmod("upload/{$Image}...{$Size}", 0644);
        }
        return "<img src=\"/upload/{$Image}...{$Size}\" border=\"0\">";
    }
}
Esempio n. 11
0
function upload_content_file($DestPath, $DestLinkPath, $MinW, $MaxW)
{
    global $ResultTargetID, $ResizeSizeX, $ResizeSizeY, $html;
    $StatusMessage = "";
    $tt_FileName = "";
    $max_FileName = "";
    $FileObject = $_FILES["upload_file"];
    if (!isset($FileObject) || $FileObject["size"] <= 0) {
        $StatusMessage = "El fitxer no és vàlid !! (" . $FileObject["size"] . ")";
        ShowPopUp($StatusMessage);
    } else {
        $uid = uniqid();
        $uploadedfile = $FileObject['tmp_name'];
        $Name = $uid . "-" . normalitzar($FileObject['name']);
        $tt_Name = "tt_" . $Name;
        $tt_FileName = $DestPath . "/" . $tt_Name;
        $FileName = $DestPath . "/" . $Name;
        $linkn = vvar("linkn", $FileObject['name']);
        if (esgrafic($Name)) {
            if (ResizeImage($uploadedfile, $MinW, 0, $tt_FileName) != TRUE) {
                $StatusMessage .= "Unable to resize the file to MIN specified dimensions. ";
            }
            if (ResizeImage($uploadedfile, $MaxW, 0, $FileName) != TRUE) {
                $StatusMessage .= "Unable to resize the file to MAX specified dimensions. ";
            }
            imagedestroy($uploadedfile);
            $html = " <a href=" . $DestLinkPath . "/" . $Name . "><img src=" . $DestLinkPath . "/" . $tt_Name . "></a> ";
        } else {
            move_uploaded_file($FileObject['tmp_name'], $FileName);
            $html = " <a href=\"" . $DestLinkPath . "/" . $Name . "\">" . $linkn . "</a> ";
        }
    }
    // debug();
    CloseWindow($ResultTargetID, $html);
}
Esempio n. 12
0
function GetMySmallImg($classid, $no, $insertfile, $filepath, $yname, $maxwidth, $maxheight, $name, $id, $cjid, $userid, $username, $modtype = 0, $fstb = 1)
{
    global $empire, $dbtbpre, $public_r, $efileftp_fr;
    if (empty($yname)) {
        return "";
    }
    $no = "[s]" . $no;
    $maxwidth = (int) $maxwidth;
    $maxheight = (int) $maxheight;
    $filer = ResizeImage($yname, $name, $maxwidth, $maxheight, $public_r['spickill']);
    if ($filer['file']) {
        $insertfile = "small" . $insertfile . $filer['filetype'];
        $filesize = @filesize($filer['file']);
        //写入数据库
        $pubid = 0;
        if ($id && !$cjid) {
            $pubid = ReturnInfoPubid($classid, $id);
        }
        //变量处理
        $filesize = (int) $filesize;
        $classid = (int) $classid;
        $id = (int) $id;
        $cjid = (int) $cjid;
        eInsertFileTable($insertfile, $filesize, $filepath, $username, $classid, $no, 1, $id, $cjid, $public_r[fpath], $pubid, $modtype, $fstb);
        //FileServer
        if ($public_r['openfileserver']) {
            $efileftp_fr[] = $name . $filer['filetype'];
        }
    }
    return $filer;
}
Esempio n. 13
0
<?php

// see https://github.com/yosun/php-image-resize - returns $newurl (unless $notincluded, then echos)
require_once 'libs/ImageResize.php';
function ResizeImage($x, $y, $imageurl)
{
    if ($x > 0 && $y > 0 && strlen($imageurl) > 3) {
        $data = parse_url(str_replace('/', '!', $imageurl));
        $newfilename = $data['scheme'] . '~' . $data['host'] . '~' . $x . '~' . $y . $data['path'];
        $newfilepath = 'temp/' . $newfilename;
        $newsavedfilepath = 'resized/' . $newfilename;
        $baseurl = 'http://futurestore.areality3d.com';
        if (!file_exists($newsavedfilepath)) {
            $handle = copy($imageurl, $newfilepath);
            $image = new ImageResize($newfilepath);
            $image->crop($x, $y);
            $image->save($newsavedfilepath);
            $newurl = $baseurl . '/' . $newsavedfilepath;
        } else {
            $newurl = $baseurl . '/' . $newsavedfilepath;
        }
        return $newurl;
    } else {
        return 'need x,y,imageurl';
    }
}
if ($notincluded == 1) {
    echo ResizeImage($x, $y, $imageurl);
}
Esempio n. 14
0
/**
 * handler for dl requests
 */
function ProcessDlRequest()
{
    global $config;
    global $http_return_code;
    /* run this puppy through premailer */
    $premailer = Premailer::html($_POST["html"], true, "hpricot", $config[BASE_URL]);
    $html = $premailer["html"];
    /* create static versions of resized images */
    $matches = [];
    $num_full_pattern_matches = preg_match_all('#<img.*?src="([^"]*?\\/[^/]*\\.[^"]+)#i', $html, $matches);
    for ($i = 0; $i < $num_full_pattern_matches; $i++) {
        if (stripos($matches[1][$i], "/img?src=") !== FALSE) {
            $src_matches = [];
            if (preg_match('#/img\\?src=(.*)&amp;method=(.*)&amp;params=(.*)#i', $matches[1][$i], $src_matches) !== FALSE) {
                $file_name = urldecode($src_matches[1]);
                $file_name = substr($file_name, strlen($config[BASE_URL] . $config[UPLOADS_URL]));
                $method = urldecode($src_matches[2]);
                $params = urldecode($src_matches[3]);
                $params = explode(",", $params);
                $width = (int) $params[0];
                $height = (int) $params[1];
                $static_file_name = $method . "_" . $width . "x" . $height . "_" . $file_name;
                $html = str_ireplace($matches[1][$i], $config[BASE_URL] . $config[STATIC_URL] . urlencode($static_file_name), $html);
                $image = ResizeImage($file_name, $method, $width, $height);
                $image->writeImage($config[BASE_DIR] . $config[STATIC_DIR] . $static_file_name);
            }
        }
    }
    /* perform the requested action */
    switch ($_POST["action"]) {
        case "download":
            header("Content-Type: application/force-download");
            header("Content-Disposition: attachment; filename=\"" . $_POST["filename"] . "\"");
            header("Content-Length: " . strlen($html));
            echo $html;
            break;
        case "email":
            $to = $_POST["rcpt"];
            $subject = $_POST["subject"];
            $headers = array();
            $headers[] = "MIME-Version: 1.0";
            $headers[] = "Content-type: text/html; charset=iso-8859-1";
            $headers[] = "To: {$to}";
            $headers[] = "Subject: {$subject}";
            $headers = implode("\r\n", $headers);
            if (mail($to, $subject, $html, $headers) === FALSE) {
                $http_return_code = 500;
                return;
            }
            break;
    }
}
Esempio n. 15
0
    <th> AutoSharpened <br/><p>WARNING-This feature takes a lot of processing power</p></th>
        <?php 
    foreach ($images as $image) {
        print "<td>";
        ImageMagickSharpen(POSTIE_ROOT . DIRECTORY_SEPARATOR . "test_files" . DIRECTORY_SEPARATOR . $image, $config["REALPHOTOSDIR"] . "Sharp-" . $image);
        print "<img src='" . $config["URLPHOTOSDIR"] . "/Sharp-" . $image . "'>";
        print "</td>\n";
    }
    ?>
    </tr>
    <?php 
}
?>
    <tr>
    <th> Scaled & Rotated</th>
        <?php 
foreach ($images as $image) {
    $result = ResizeImage(POSTIE_ROOT . DIRECTORY_SEPARATOR . "test_files" . DIRECTORY_SEPARATOR . $image, substr($image, -3, 3));
    RotateImages(90, array(array(null, $config["REALPHOTOSDIR"] . $result[0], 'jpg')));
    print "<td>";
    $size = DetermineImageSize($config["REALPHOTOSDIR"] . DIRECTORY_SEPARATOR . $result[0]);
    print "{$size['1']} x {$size['0']}<br\\>\n";
    print "<img src='" . $config["URLPHOTOSDIR"] . $result[0] . "'>";
    print "</td>\n";
}
?>
    </tr>
    </table>
    
</div>
Esempio n. 16
0
        } elseif ($Page == $Pages) {
            $PreviousPage = $Page - 1;
            $Pagination['Output'] = "<a href='?page={$PreviousPage}'>Previous</a> &mdash; Page <b>{$Page}</b> of <b>{$Pages}</b>.";
        } else {
            $NextPage = $Page + 1;
            $PreviousPage = $Page - 1;
            $Pagination['Output'] = "<a href='?page={$PreviousPage}'>Previous</a> &mdash; Page <b>{$Page}</b> of <b>{$Pages}</b>. &mdash; <a href='?page={$NextPage}'>Next</a>";
        }
        $Pagination['Output'] = "<div style='clear:both;'>{$Pagination['Output']}</div>";
        echo $Pagination['Output'];
    }
}
foreach ($Files as $File) {
    if (the($File) == 'Image') {
        if ($Generate == 'Thumbnails') {
            if (!file_exists("{$Path}/{$Thumbnail['Directory']}/{$Thumbnail['Size']}_{$File}")) {
                ResizeImage("{$Path}/{$Directory}/{$File}", "{$Path}/{$Thumbnail['Directory']}/{$Thumbnail['Size']}_{$File}", $Thumbnail['Size']);
            }
        }
        echo "<div class='GalleryContainer'>\r\t\t\t\t\t<a href='/{$Directory}/{$File}' rel='Gallery'>\r\t\t\t\t\t\t<img src='/{$Thumbnail['Directory']}/{$Thumbnail['Size']}_{$File}' class='GalleryImage' border='0' />\r\t\t\t\t\t</a>\r\t\t\t\t</div>";
    }
}
if ($Pagination['is'] == 'On') {
    if ($Pages > 1) {
        echo $Pagination['Output'];
    }
}
if ($Colorbox == 'Yes!') {
    echo "<script>\$(\"a[rel='Gallery']\").colorbox();</script>";
}
echo "</center>";
Esempio n. 17
0
<?php

if ($submitted == 1) {
    require_once '_conn.php';
    // generate thumbnails
    require_once 'image.resizer.php';
    $photo_large = ResizeImage(256, 256, $photo);
    $photo_thumb = ResizeImage(64, 64, $photo);
    $query = mins('items', array('name', 'photo', 'model', 'description', 'price', 'photo_large', 'photo_thumb'), array($name, $photo, $model, $description, $price, $photo_large, $photo_thumb));
    mquery($query);
    $id_i = mysql_insert_id();
    $json['id_i'] = '"' . $id_i . '"';
    echo stripslashes(json_encode($json));
} else {
    ?>
<form>
<div id="name"><label for="name">name</label> <input type="text" name="name" /></div>
<div id="photo"><label for="photo">photo</label> <input type="text" name="photo" /></div>
<div id="model"><label for="model">model</label> <input type="text" name="model" /></div>
<div id="description"><label for="description">description</label> <input type="text" name="description" /></div>
<div id="price"><label for="price">price</label> <input type="text" name="price" /></div>
<input type="hidden" name="submitted" value="1" />
<input type="submit" />
</form>
<?php 
}
Esempio n. 18
0
<?php

if ($submitted == 1 && $id_i > 0) {
    $filepath = $_FILES['file']['tmp_name'];
    // TODO add azure storage
    if (strlen($_FILES['file']['name']) > 2) {
        $uniqid = uniqid('pic');
        $newpath = 'img/' . $uniqid . '.' . $_FILES['file']['name'];
        move_uploaded_file($filepath, $newpath);
        $urlpath = 'http://futurestore.areality3d.com/' . $newpath;
        require_once '_conn.php';
        $query = mupd('items', 'photo', $urlpath, 'id_i', $id_i);
        mquery($query);
        require_once 'image.resizer.php';
        $photo_large = ResizeImage(256, 256, $urlpath);
        $photo_thumb = ResizeImage(64, 64, $urlpath);
        $query = mupd('items', 'photo_thumb', $photo_thumb, 'id_i', $id_i);
        mquery($query);
        $query = mupd('items', 'photo_large', $photo_large, 'id_i', $id_i);
        mquery($query);
    }
}
Esempio n. 19
0
function sys_ResizeImg($file, $width, $height, $docut = 0, $target_filename = '')
{
    global $public_r, $tranpicturetype;
    if (!$file || !$width || !$height) {
        return $file;
    }
    //扩展名
    $filetype = GetFiletype($file);
    if (!strstr($tranpicturetype, ',' . $filetype . ',')) {
        return $file;
    }
    $efileurl = eReturnFileUrl();
    if (strstr($file, $efileurl)) {
        $file = str_replace($efileurl, '/d/file/', $file);
    }
    if (strstr($file, '://')) {
        return $file;
    }
    $filename = ECMS_PATH . substr($file, 1);
    if (!file_exists($filename)) {
        return $file;
    }
    if ($target_filename) {
        $newfilename = $target_filename;
    } else {
        $newfilename = md5($file . '-' . $width . '-' . $height . '-' . $docut);
    }
    $newname = ECMS_PATH . 'e/data/tmp/titlepic/' . $newfilename;
    if (empty($target_filename) && file_exists($newname . $filetype)) {
        return $public_r['newsurl'] . 'e/data/tmp/titlepic/' . $newfilename . $filetype;
    }
    if (!defined('InEmpireCMSGd')) {
        include_once ECMS_PATH . 'e/class/gd.php';
    }
    $filer = ResizeImage($filename, $newname, $width, $height, $docut);
    $fileurl = $public_r['newsurl'] . 'e/data/tmp/titlepic/' . $newfilename . $filer['filetype'];
    return $fileurl;
}
Esempio n. 20
0
function sys_ResizeImg($file,$width,$height,$docut=0,$target_filename='',$target_path='e/data/tmp/titlepic/'){
	global $public_r,$ecms_config;
	if(!$file||!$width||!$height)
	{
		return $file;
	}
	//扩展名
	$filetype=GetFiletype($file);
	if(!strstr($ecms_config['sets']['tranpicturetype'],','.$filetype.','))
	{
		return $file;
	}
	$efileurl=eReturnFileUrl();
	if(strstr($file,$efileurl))
	{
		$file=str_replace($efileurl,'/data/',$file);
	}
	if(strstr($file,'://'))
	{
		return $file;
	}
	$filename=eReturnEcmsMainPortPath().substr($file,1);//moreport
	if(!file_exists($filename))
	{
		return $file;
	}
	if($target_filename)
	{
		$newfilename=$target_filename;
	}
	else
	{
		$newfilename=md5($file.'-'.$width.'-'.$height.'-'.$docut);
	}
	$newpath=ECMS_PATH.$target_path;
	$newurl=$public_r['newsurl'].$target_path;
	$newname=$newpath.$newfilename;
	if(empty($target_filename)&&file_exists($newname.$filetype))
	{
		return $newurl.$newfilename.$filetype;
	}
	if(!defined('InEmpireCMSGd'))
	{
		include_once ECMS_PATH.DASHBOARD.'/class/gd.php';
	}
	$filer=ResizeImage($filename,$newname,$width,$height,$docut);
	$fileurl=$newurl.$newfilename.$filer['filetype'];
	return $fileurl;
}
Esempio n. 21
0
 /**
  * Get Resource
  */
 public function GetResource($displayId = 0)
 {
     $proportional = Kit::GetParam('proportional', _GET, _BOOL, true);
     $thumb = Kit::GetParam('thumb', _GET, _BOOL, false);
     $dynamic = isset($_REQUEST['dynamic']);
     $file = $this->storedAs;
     $width = intval(Kit::GetParam('width', _REQUEST, _DOUBLE, 80));
     $height = intval(Kit::GetParam('height', _REQUEST, _DOUBLE, 80));
     // File upload directory.. get this from the settings object
     $library = Config::GetSetting("LIBRARY_LOCATION");
     $fileName = $library . $file;
     Debug::Audit(sprintf('Image Request %dx%d %s. Thumb: %s', $width, $height, $fileName, $thumb));
     // If we are a thumb request then output the cached thumbnail
     if ($thumb) {
         $fileName = $library . sprintf('tn_%dx%d_%s', $width, $height, $file);
         // If the thumbnail doesn't exist then create one
         if (!file_exists($fileName)) {
             Debug::LogEntry('audit', 'File doesnt exist, creating a thumbnail for ' . $fileName);
             if (!($info = getimagesize($library . $file))) {
                 die($library . $file . ' is not an image');
             }
             ResizeImage($library . $file, $fileName, $width, $height, $proportional, 'file');
         }
     }
     // Get the info for this new temporary file
     if (!($info = getimagesize($fileName))) {
         $fileName = 'theme/default/img/forms/filenotfound.png';
         $this->ReturnFile($fileName);
         exit;
     }
     if ($dynamic && !$thumb && $info[2]) {
         $width = intval(Kit::GetParam('width', _REQUEST, _DOUBLE, 80));
         $height = intval(Kit::GetParam('height', _REQUEST, _DOUBLE, 80));
         // dynamically create an image of the correct size - used for previews
         ResizeImage($fileName, '', $width, $height, $proportional, 'browser');
         exit;
     }
     if (!file_exists($fileName)) {
         //not sure
         Debug::LogEntry('audit', "Cant find: {$uid}", 'module', 'GetResource');
         $fileName = 'theme/default/img/forms/filenotfound.png';
     }
     $this->ReturnFile($fileName);
     exit;
 }
Esempio n. 22
0
function ReplaceKeywords($Matches)
{
    if ($Matches[2]) {
        $GoodStuff = $Matches[3];
    } else {
        $GoodStuff = $Matches[4];
    }
    if ($GoodStuff !== "") {
        switch (strtolower($Matches[1])) {
            case "total":
                switch (strtolower($GoodStuff)) {
                    case "pages":
                        $pageTotal = mysql_query("Select `ID` from `Wiki_Pages`");
                        $totalPages = mysql_num_rows($pageTotal);
                        return number_format($totalPages);
                        break;
                }
                break;
            case "ad":
                $position = strtolower($GoodStuff);
                if ($position == 'right') {
                    $class = 'right';
                } elseif ($position == 'left') {
                    $class = 'left';
                }
                $ID = uuid();
                return "<div id='{$ID}' class='{$class}'><iframe id='scraper-friend' src='https://ads.wetfish.net/friendship/scraper.html' style='width:175px; height:640px; border:0; outline:0; overflow:hidden;' scrolling='no'></iframe></div>";
                break;
            case "ads":
                $ID = uuid();
                $ID2 = uuid();
                return "<div id='{$ID}' class='left'><iframe id='scraper-friend' src='https://ads.wetfish.net/friendship/scraper.html' style='width:175px; height:640px; border:0; outline:0; overflow:hidden;' scrolling='no'></iframe></div>" . "<div id='{$ID2}' class='right'><iframe id='scraper-friend' src='https://ads.wetfish.net/friendship/scraper.html' style='width:175px; height:640px; border:0; outline:0; overflow:hidden;' scrolling='no'></iframe></div>";
                break;
            case "pre":
                $GoodStuff = trim(str_replace(array("{", "}", '[', ']'), array("&#123;", "&#125;", '&#91;', '&#93;'), $GoodStuff));
                return "<pre>{$GoodStuff}</pre>";
                break;
            case "center":
                return "<center>{$GoodStuff}</center>";
                break;
            case "magic":
                $Words = str_split_unicode(html_entity_decode($GoodStuff, false, 'UTF-8'));
                $Splitter = '';
                foreach ($Words as $Word) {
                    $magic .= "<span class='magic'>{$Word}</span>";
                }
                return "<span class='brew'>{$GoodStuff}</span>";
                break;
            case "color":
                $args = explode("|", $GoodStuff, 3);
                if (count($args) == 3) {
                    if ($args[1]) {
                        $args[1] = "background-color:{$args[1]}";
                    }
                    return "<span style='color:{$args[0]}; {$args[1]}'>{$args[2]}</span>";
                } elseif (count($args) == 2) {
                    return "<span style='color:{$args[0]}'>{$args[1]}</span>";
                } else {
                    return $GoodStuff;
                }
                break;
            case "infobox":
                $args = explode("|", $GoodStuff, 3);
                if ($args[2]) {
                    return "<div class='wiki-box' style='{$args[0]}'><div class='wiki-box-title'>{$args[1]}</div>{$args[2]}</div>";
                } else {
                    return "<div class='wiki-box'><div class='wiki-box-title'>{$args[0]}</div>{$args[1]}</div>";
                }
                break;
            case "titlebox":
                $args = explode("|", $GoodStuff, 2);
                return "<header class='title-box'><h1>{$args[0]}</h1><span>{$args[1]}</span></header>";
                break;
            case "box":
                $args = explode("|", $GoodStuff, 2);
                if ($args[1]) {
                    return "<div class='wiki-box' style='{$args[0]}'>{$args[1]}</div>";
                } else {
                    return "<div class='wiki-box'>{$args[0]}</div>";
                }
                break;
            case "title":
                return "<div class='wiki-box-title'>{$GoodStuff}</div>";
                break;
            case "style":
                $args = explode("|", $GoodStuff, 2);
                $args[0] = preg_replace("/([\\s\n]|&emsp;)+/", " ", $args[0]);
                return "<div style='{$args[0]}'>{$args[1]}</div>";
                break;
            case "right":
                return "<div class='right'>{$GoodStuff}</div>";
                break;
            case "left":
                return "<div class='left'>{$GoodStuff}</div>";
                break;
            case "bold":
            case "b":
                return "<b>{$GoodStuff}</b>";
                break;
            case "underline":
            case "u":
                return "<u>{$GoodStuff}</u>";
                break;
            case "italic":
            case "italics":
            case "i":
                return "<i>{$GoodStuff}</i>";
                break;
            case "strike":
            case "s":
                return "<span class='strike'>{$GoodStuff}</span>";
                break;
            case "big":
                return "<span class='big'>{$GoodStuff}</span>";
                break;
            case "medium":
            case "med":
                return "<span class='medium'>{$GoodStuff}</span>";
                break;
            case "small":
            case "sml":
                return "<span class='small'>{$GoodStuff}</span>";
                break;
            case "redirect":
                if (isset($_GET['random'])) {
                    return "<meta http-equiv='refresh' content='1;url=/{$GoodStuff}/?random'>You're being brought to '{$GoodStuff}'...";
                } else {
                    return "<meta http-equiv='refresh' content='1;url=/{$GoodStuff}'>You're being brought to '{$GoodStuff}'...";
                }
                break;
            case "heading":
                //return "<a name='".str_replace(array("&lt;", "&gt;", "&#34;", "&#39;", "&#92;", "&#96;", " "), "", $GoodStuff)."'></a>$GoodStuff<hr />";
                return "<div class='clear'>{$GoodStuff}</div><hr />";
                break;
            case "subheading":
                //return "<a name='".str_replace(array("&lt;", "&gt;", "&#34;", "&#39;", "&#92;", "&#96;", " "), "", $GoodStuff)."'></a>$GoodStuff<hr />";
                return "{$GoodStuff}<hr />";
                break;
            case "url":
                list($link, $text) = explode("|", $GoodStuff, 2);
                $link = trim($link);
                $text = trim($text);
                $url = parse_url($link);
                switch ($url['scheme']) {
                    case "http":
                    case "https":
                    case "ftp":
                    case "irc":
                        if (empty($text)) {
                            $text = $link;
                        }
                        return "<a href='{$link}' target='_blank'>{$text}</a>";
                        break;
                    case "fish":
                        $link = "https://wiki.wetfish.net/{$url['host']}";
                        if (empty($text)) {
                            $text = $url['host'];
                        }
                        return "<a href='{$link}'>{$text}</a>";
                        break;
                    default:
                        if (empty($text)) {
                            $text = $link;
                        }
                        return "<a href='http://{$link}' target='_blank'>{$text}</a>";
                        break;
                }
                break;
            case "image":
            case "img":
                //list($Link, $Size, $Position, $Border, $Text) = explode("|", $GoodStuff, 5);
                $args = explode('|', $GoodStuff, 6);
                $Link = trim($args[0]);
                $Border = trim($args[3]);
                $Text = trim($args[4]);
                $rand = trim($args[5]);
                $path = pathinfo($Link);
                // If a video extension was used
                if (preg_match('/^(webm|mp4|ogv)$/i', $path['extension'])) {
                    // Output a special html5 player that behaves like a gif
                    $options = array('autoplay' => true, 'controls' => false, 'muted' => true, 'loop' => true);
                    return embed_html5($Link, $options);
                }
                //				$args[1] = trim(str_replace('px', '', strtolower($args[1])));
                //				$args[2] = trim(str_replace('px', '', strtolower($args[2])));
                $args[1] = trim($args[1]);
                $args[2] = trim($args[2]);
                if (empty($args[1])) {
                    $args[1] = 0;
                }
                if (is_numeric($args[1]) and (is_string($args[2]) or empty($args[2]))) {
                    $Size = $args[1];
                    $Position = $args[2];
                } elseif (is_string($args[1]) and (is_numeric($args[2]) or empty($args[2]))) {
                    $Size = $args[2];
                    $Position = $args[1];
                }
                if (strtolower($Position) == "right" or strtolower($Position) == "left") {
                    $Position = "float:{$Position};";
                } elseif (strtolower($Position) == "border") {
                    $Border = true;
                } elseif (empty($Text)) {
                    $Text = $Position;
                }
                if ($Border) {
                    $Border = "border: 4px solid #C17EE8; padding:4px; margin-bottom:16px; border-radius:8px; -moz-border-radius:8px; -webkit-border-radius:8px;";
                } else {
                    unset($Border);
                }
                if (is_numeric($Size) and $Size < 1600 and $Size > 0 and strpos($Link, 'http://') === false) {
                    $Info = pathinfo($Link);
                    // Make sure the file actually exists
                    if (!file_exists(__DIR__ . "/upload/{$Info['basename']}")) {
                        // Display an icon if the image can't be loaded
                        $ImageText = "<a href='#error' class='exempt'><img src='/upload/apple.gif' title='There was an error loading this image' border='0' /></a>";
                    } else {
                        if (!file_exists(__DIR__ . "/upload/{$Size}_{$Info['basename']}")) {
                            ResizeImage($Link, __DIR__ . "/upload/{$Size}_{$Info['basename']}", $Size);
                        }
                        $ImageText = "<a href='/{$Link}' class='exempt'><img src='/upload/{$Size}_{$Info['basename']}' border='0' /></a>";
                    }
                } else {
                    if (strpos($Link, 'http://') === false && strpos($Link, 'https://') === false) {
                        $Link = "/{$Link}";
                    }
                    unset($Size);
                    $URL = parse_url($Link);
                    // Make sure wiki images exist
                    if (preg_match("{^/upload}", $URL['path']) && !file_exists(__DIR__ . "{$URL['path']}")) {
                        // Display an icon if the image can't be loaded
                        $ImageText = "<a href='#error' class='exempt'><img src='/upload/apple.gif' title='There was an error loading this image' border='0' /></a>";
                    } else {
                        if ($URL['host'] == "glitch.wetfish.net") {
                            $class = "class='glitchme'";
                        }
                        // This is a terrible hack and really should be expanded to parse and reconstruct the url
                        if ($rand) {
                            $rand = "&rand=" . mt_rand();
                        }
                        // Lol I should finish this some time
                        if (is_numeric($Size) and $Size < 1600 and $Size > 0) {
                            $size = "style=''";
                        }
                        $ImageText = "<img src='{$Link}{$rand}' {$class} />";
                    }
                }
                if ($Text) {
                    $Text = "<div class='small'>{$Text}</div>";
                }
                return "<div style='margin:0px 8px; display:inline-block; max-width:100%; {$Position} {$Border}'>{$ImageText} {$Text}</div>";
                break;
            case "red":
            case "redtube":
                $URL = parse_url($GoodStuff);
                $Video = trim($URL['path'], '/');
                return "<object height='344' width='434'> <param name='movie' value='https://embed.redtube.com/player/'> <param name='FlashVars' value='id={$Video}&style=redtube&autostart=false'> <embed src='https://embed.redtube.com/player/?id={$Video}&style=redtube' flashvars='autostart=false' pluginspage='https://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' height='344' width='434' /> </object>";
                break;
            case "motherless":
                $URL = parse_url($GoodStuff);
                if ($URL['host'] == "motherless.com") {
                    $Video = trim($URL['path'], '/');
                    $Data = file_get_contents($GoodStuff);
                    preg_match("/var __file_url = '(.*?)';/", $Data, $Filename);
                    return "<embed type='application/x-shockwave-flash' src='https://motherless.com/flash/player.swf' style='' id='player' name='player' quality='high' allowfullscreen='true' allowscriptaccess='always' wmode='transparent' flashvars='file=https://members.motherless.com/movies/{$Filename['1']}.flv&amp;image=https://motherless.com/thumbs/{$Video}.jpg&amp;mute=false&amp;streamer=lighttpd&amp;link=https://motherless.com/{$Video}' width='680' height='560'>";
                }
                break;
            case "video":
                $url = parse_url($GoodStuff);
                if (preg_match("/(^|\\.)youtube.com\$/i", $url['host'])) {
                    return embed_youtube($GoodStuff);
                }
                if (preg_match("/(^|\\.)youtu.be\$/i", $url['host'])) {
                    return embed_youtube($GoodStuff);
                }
                if (preg_match("/(^|\\.)vimeo.com\$/i", $url['host'])) {
                    return embed_vimeo($GoodStuff);
                }
                if (preg_match("/(^|\\.)vine.co\$/i", $url['host'])) {
                    return embed_vine($GoodStuff);
                }
                // Otherwise, it must be a html5 video!
                return embed_html5($GoodStuff);
                break;
            case "youtube":
                return embed_youtube($GoodStuff);
                break;
            case "vimeo":
                return embed_vimeo($GoodStuff);
                break;
            case "vine":
                return embed_vine($GoodStuff);
                break;
            case "playlist":
                $url = parse_url($GoodStuff);
                parse_str($url['query'], $query);
                return "<iframe width='640' height='360' src='https://www.youtube.com/embed/videoseries?list={$query['list']}&index={$query['index']}' frameborder='0' allowfullscreen></iframe>";
                break;
            case "soundcloud":
                return embed_soundcloud($GoodStuff);
                break;
            case "ytcracker":
                return "<iframe width='100%' height='450' scrolling='no' frameborder='no' src='https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/users/2977873&amp;color=ff5500&amp;auto_play=false&amp;hide_related=false&amp;show_artwork=true'></iframe>";
                break;
            case "load":
            case "embed":
                $URL = parse_url($GoodStuff);
                if (empty($URL['scheme'])) {
                    $URL['scheme'] = "http";
                }
                if (empty($URL['host'])) {
                    $URL['host'] = "wiki.wetfish.net";
                }
                if ($URL['path'] == 'index.php' or empty($URL['path']) or $URL['path'] == $_GET['SUPERdickPAGE'] or !empty($_GET['load'])) {
                    $URL['path'] = 'yousosilly.php';
                }
                if (empty($URL['query'])) {
                    $Query = array();
                    foreach ($_GET as $Key => $Value) {
                        if ($Key != 'SUPERdickPAGE') {
                            $Query[] = "{$Key}=" . urlencode($Value);
                        }
                    }
                    $URL['query'] = implode('&', $Query);
                }
                if (preg_match('/^.*\\.?wetfish.net$/i', $URL['host'])) {
                    $ID = uuid();
                    if ($URL['host'] == 'danger.wetfish.net') {
                        $URL['path'] = substr($URL['path'], 1);
                        if (preg_match("/^[a-f0-9]+\$/", $URL['path'])) {
                            $URL['query'] = "hash={$URL['path']}";
                            $URL['path'] = "view.php";
                        }
                    }
                    //return "<iframe src='{$URL['scheme']}://{$URL['host']}/{$URL['path']}?{$URL['query']}' style='height:0px; width:0px; display:none;'></iframe>
                    /**/
                    if ($URL['host'] != "wiki.wetfish.net") {
                        return "<div id='{$ID}'><script>\$('#{$ID}').load('/load.php?id={$ID}&url={$URL['scheme']}://{$URL['host']}/{$URL['path']}?" . urlencode($URL['query']) . "');</script></div>";
                    } else {
                        return "<div id='{$ID}'><script>\$('#{$ID}').load('/{$URL['path']}?{$URL['query']}&load=true');</script></div>";
                    }
                    /**/
                    //return "LOL GOOGLE HACKED WETFISH";
                }
                break;
            case "music":
                list($Derp, $Delay) = explode("|", $GoodStuff, 2);
                $URL = parse_url($Derp);
                parse_str($URL['query'], $Query);
                if (strpos($Derp, 'http://') === false or strpos($Link, 'https://') === false or strpos($Derp, 'http://') !== false and preg_match('/^.*\\.?wetfish.net$/i', $URL['host'])) {
                    if ($Delay) {
                        $Unique = uuid();
                        $Delay *= 1000;
                        $Javascript = "<script>setTimeout(\"\$('#{$Unique}').show()\", {$Delay})</script>";
                        return "{$Javascript}<embed id='{$Unique}' src='{$Derp}' width='0' height='0' autostart='true' loop='true' hidden='true' style='display:none;'></embed>";
                    } else {
                        return "<embed src='{$GoodStuff}' width='0' height='0' autostart='true' loop='true' hidden='true'></embed>";
                    }
                }
                break;
            case "flash":
                list($url, $width, $height) = explode("|", $GoodStuff);
                return "<object width='{$width}' height='{$height}'><param name='movie' value='{$url}'><embed src='{$url}' width='{$width}' height='{$height}'></embed></object>";
                break;
            case "drainbow":
            case "dblrainbow":
            case "doublerainbow":
            case "rainbow2":
                $Words = str_split_unicode(html_entity_decode($GoodStuff, ENT_QUOTES, 'UTF-8'));
                $Splitter = '';
                foreach ($Words as $Word) {
                    /*
                    $RandomRed = rand(0, 255);
                    $RandomGreen = rand(0, 255);
                    $RandomBlue  = rand(0, 255);
                    
                    $InvertedRed = 255 - $RandomRed;
                    $InvertedGreen = 255 - $RandomGreen;
                    $InvertedBlue = 255 - $RandomBlue;
                    */
                    $rainbowCounter++;
                    $randomHue = $rainbowCounter * 24 % 360;
                    $randomSaturation = rand(0, 5) + 95;
                    $randomLuminosity = rand(0, 24) + 44;
                    $invertedHue = ($randomHue + 180) % 360;
                    //background-color:rgb($InvertedRed, $InvertedGreen, $InvertedBlue);
                    //$Stuff .= "<span style='color:rgb($RandomRed, $RandomGreen, $RandomBlue); background-color:rgb($InvertedRed, $InvertedGreen, $InvertedBlue);'>$Word</span>$Splitter";
                    $Stuff .= "<span style='font-size:110%; color:hsla({$randomHue}, {$randomSaturation}%, {$randomLuminosity}%, 0.8); text-shadow:1px 1px #000; background-color:hsla({$invertedHue}, {$randomSaturation}%, {$randomLuminosity}%, 0.6);'>" . $Word . "</span>{$Splitter}";
                }
                return $Stuff;
                break;
            case "snow":
                return '<script type="text/javascript" src="/snowstorm.js"></script>';
                break;
            case "rainbow":
                $Words = str_split_unicode(html_entity_decode($GoodStuff, ENT_QUOTES, 'UTF-8'));
                $Splitter = '';
                foreach ($Words as $Word) {
                    /*
                    $RandomRed = rand(0, 255);
                    $RandomGreen = rand(0, 255);
                    $RandomBlue  = rand(0, 255);
                    
                    $InvertedRed = 255 - $RandomRed;
                    $InvertedGreen = 255 - $RandomGreen;
                    $InvertedBlue = 255 - $RandomBlue;
                    */
                    $rainbowCounter++;
                    $randomHue = -1 * $rainbowCounter * 24 % 360;
                    $randomSaturation = rand(0, 5) + 95;
                    $randomLuminosity = rand(0, 24) + 44;
                    $invertedHue = ($randomHue + 180) % 360;
                    //background-color:rgb($InvertedRed, $InvertedGreen, $InvertedBlue);
                    //$Stuff .= "<span style='color:rgb($RandomRed, $RandomGreen, $RandomBlue); background-color:rgb($InvertedRed, $InvertedGreen, $InvertedBlue);'>$Word</span>$Splitter";
                    $Stuff .= "<span style='font-size:110%; color:hsla({$randomHue}, {$randomSaturation}%, {$randomLuminosity}%, 0.8); text-shadow:1px 1px #000;'>" . $Word . "</span>{$Splitter}";
                }
                return $Stuff;
                break;
            case "glitch":
                $Splitter = ' ';
                $Words = preg_split("/{$Splitter}/", $GoodStuff);
                if (count($Words) == 1) {
                    $Words = str_split($GoodStuff);
                    $Splitter = '';
                }
                foreach ($Words as $Word) {
                    $rainbowCounter++;
                    $randomHue = rand(0, 360);
                    $randomSaturation = rand(0, 5) + 95;
                    $randomLuminosity = rand(0, 44) + 14;
                    $invertedHue = ($randomHue + 180) % 360;
                    $Stuff .= "<span style='font-size:110%; color:hsl({$randomHue}, {$randomSaturation}%, {$randomLuminosity}%); background-color:hsl({$invertedHue}, {$randomSaturation}%, {$randomLuminosity}%);'>{$Word}</span>{$Splitter}";
                }
                return $Stuff;
                break;
            case "anchor":
                return "<a name='{$GoodStuff}'>&nbsp;</a>";
                break;
            case "codepen":
                return embed_codepen($GoodStuff);
                break;
            case "fb":
            case "fishbux":
                list($amount, $image) = explode("|", $GoodStuff, 2);
                // Make sure image is an integer
                $image = (int) $image;
                // If none is set, generate a random image
                if (!$image) {
                    $image = mt_rand(2, 4);
                }
                return "<div class='fishbux'> {$amount}  <div class='wrap'><img src='/upload/fishbux/bux{$image}.gif'></div></div>";
                break;
        }
    } else {
        // Self documenting!
        if ($Matches[1]) {
            return $Matches[1] . "&#91;&#93;";
        }
    }
}