function load()
 {
     if ($this->exists() == true) {
         $this->import();
     } else {
         require_once 'classes/class.geshi.php';
         $this->data = array();
         $source = 'classes/geshi/';
         $d = dir($source);
         while (false !== ($entry = $d->read())) {
             if (get_extension($entry) == 'php' && !is_dir($source . $entry)) {
                 include_once $source . $entry;
                 if (!isset($language_data['NO_INDEX'])) {
                     $short = str_replace('.php', '', $entry);
                     $this->data[$short]['file'] = $entry;
                     $this->data[$short]['name'] = $language_data['LANG_NAME'];
                     $this->data[$short]['short'] = $short;
                 }
             }
         }
         $d->close();
         asort($this->data);
         $this->export();
     }
 }
Exemple #2
0
function SaveHTTPFile($fFileHTTPPath, $fFileSavePath, $fFileSaveName)
{
    //记录程序开始的时间
    $BeginTime = getmicrotime();
    //取得文件名
    $fFileSaveName = $fFileSavePath . "/" . $fFileSaveName;
    make_dir(dirname($fFileSaveName));
    //取得文件的内容
    ob_start();
    readfile($fFileHTTPPath);
    $img = ob_get_contents();
    ob_end_clean();
    //$size = strlen($img);
    //保存到本地
    $fp2 = @fopen($fFileSaveName, "a");
    fwrite($fp2, $img);
    fclose($fp2);
    /*加水印代码*/
    require_once ROOT_PATH . 'includes/cls_image.php';
    $ext = get_extension($fFileSaveName);
    $fFileSaveName = convert_GIF_to_JPG($fFileSaveName);
    if (CopyFiles($fFileSaveName)) {
        $image = new cls_image();
        $image->add_watermark($fFileSaveName, '', '../../../../' . $GLOBALS['waterMark']['watermark'], $GLOBALS['waterMark']['watermark_place'], $GLOBALS['waterMark']['watermark_alpha']);
    }
    if ($ext == 'gif' || $ext == '.gif') {
        back_JPG_to_GIF($fFileSaveName);
    }
    /*加水印代码--end*/
    //记录程序运行结束的时间
    $EndTime = getmicrotime();
    //返回运行时间
    return $EndTime - $BeginTime;
}
function export_template_list($path, $d = 0)
{
    if (substr($path, strlen($path) - 1) != '/') {
        $path .= '/';
    }
    $dirlist = array();
    if ($handle = opendir($path)) {
        while (false !== ($file = readdir($handle))) {
            if ($file != '.' && $file != '..') {
                $file = $path . $file;
                if (!is_dir($file)) {
                    $extension = get_extension($path);
                    if (stripos($extension, 'bak') === false) {
                        $dirlist[] = $file;
                    }
                } elseif ($d >= 0) {
                    $result = export_template_list($file . '/', $d + 1);
                    $dirlist = array_merge($dirlist, $result);
                }
            }
        }
        closedir($handle);
    }
    if ($d == 0) {
        natcasesort($dirlist);
    }
    return $dirlist;
}
function upload()
{
    $msg = 9;
    $con = mysqli_connect('localhost', 'shibli', 'shibli');
    mysqli_select_db($con, 'piclib');
    $imaget = mysqli_real_escape_string($con, $_FILES["userfile"]["type"]);
    $f = substr($imaget, 0, 5);
    if ($f == "image") {
        if (is_uploaded_file($_FILES['userfile']['tmp_name'])) {
            header("location: http://localhost:63342/VideoLibraryApp/views/fun.php");
        }
        $imgData = addslashes(file_get_contents($_FILES['userfile']['tmp_name']));
        $ext = get_extension($_FILES['userfile']['name']);
        $query2 = " Select max(imageID) from imgdata;";
        $result2 = mysqli_query($con, $query2);
        $row2 = mysqli_fetch_row($result2);
        $r = $row2[0] + 1;
        $sql = "INSERT INTO imgdata values({$r},'{$ext}','{$_POST['imageName']}','{$_POST['user']}','{$imgData}')";
        mysqli_query($con, $sql) or die("Error in Query: " . mysqli_error($con));
        header("location: http://localhost:63342/VideoLibraryApp/views/displayLogged.php");
    } else {
        //$finfo = finfo_open(FILEINFO_MIME_TYPE);
        //finfo_file($finfo, $_FILES['userfile']['tmp_name']);
        header("location: http://localhost:63342/VideoLibraryApp/views/main.css");
    }
    return $msg;
}
Exemple #5
0
function upload_data()
{
    $msg = "";
    $filename = $_FILES["file"]["name"];
    //文件名
    //echo get_extension($filename);exit;
    if (get_extension($filename) == "csv") {
        if ($_FILES["file"]["error"] > 0) {
            $msg = "上传错误: " . $_FILES["file"]["error"];
        } else {
            if (file_exists("data/" . $_FILES["file"]["name"])) {
                $msg = $_FILES["file"]["name"] . " 已经存在,请查看data文件下是否存在您的数据文件. ";
            } else {
                move_uploaded_file($_FILES["file"]["tmp_name"], "data/" . $_FILES["file"]["name"]);
                if (file_exists("data/" . $_FILES["file"]["name"])) {
                    $msg = "上传成功!文件已经保存在了 " . "data/" . $_FILES["file"]["name"] . "接下来您可以导入本次打卡记录了。";
                } else {
                    $msg = "上传失败,因为目录权限被拒绝,请手动上传。";
                }
            }
        }
    } else {
        $msg = "文件格式错误";
    }
    return $msg;
}
Exemple #6
0
 function convert_data($data)
 {
     global $db, $import_session, $mybb, $error_notice, $insert_data;
     static $field_info;
     if (!isset($field_info)) {
         // Get columns so we avoid any 'unknown column' errors
         $field_info = $db->show_fields_from("attachments");
     }
     $insert_data = array();
     foreach ($field_info as $key => $field) {
         if ($field['Extra'] == 'auto_increment') {
             if ($db->type != "sqlite") {
                 $insert_data[$field['Field']] = '';
             }
             continue;
         }
         if (isset($data[$field['Field']])) {
             $insert_data[$field['Field']] = $data[$field['Field']];
         }
     }
     // MyBB 1.6 values
     $insert_data['import_aid'] = $data['aid'];
     $insert_data['pid'] = $this->get_import->pid($data['pid']);
     $insert_data['uid'] = $this->get_import->uid($data['uid']);
     $attachname_array = explode('_', str_replace('.attach', '', $data['attachname']));
     $insert_data['attachname'] = 'post_' . $this->get_import->uid($attachname_array[1]) . '_' . $attachname_array[2] . '.attach';
     if ($data['thumbnail']) {
         $ext = get_extension($data['thumbnail']);
         $insert_data['thumbnail'] = str_replace(".attach", "_thumb.{$ext}", $insert_data['attachname']);
     }
     return $insert_data;
 }
/**
 * returns bak file for restore
 * @param string
 */
function get_bak_file($file)
{
    if (get_extension($file) == 'php') {
        return substr_replace($file, '.bak', strrpos($file, '.'), 0);
    } else {
        return $file . '.bak';
    }
}
Exemple #8
0
function data_uri($file)
{
    $type = get_extension($file);
    $mime = 'image/' . $type;
    $contents = file_get_contents($file);
    $base64 = base64_encode($contents);
    return 'data:' . $mime . ';base64,' . $base64;
}
Exemple #9
0
 public function save_external_image($url = '', $path = '')
 {
     if (empty($url)) {
         return;
     }
     $ch = curl_init($url);
     curl_setopt($ch, CURLOPT_HEADER, 0);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
     $err = curl_error($ch);
     if (empty($err)) {
         $rawdata = curl_exec($ch);
     }
     curl_close($ch);
     if ($rawdata) {
         $ext = get_extension($path);
         $upload_path = './uploads/editor/';
         if (is_dir($upload_path) == false) {
             mkdir($upload_path, 0707);
             $file = $upload_path . 'index.php';
             $f = @fopen($file, 'w');
             @fwrite($f, '');
             @fclose($f);
             @chmod($file, 0644);
         }
         $upload_path .= cdate('Y') . '/';
         if (is_dir($upload_path) === false) {
             mkdir($upload_path, 0707);
             $file = $upload_path . 'index.php';
             $f = @fopen($file, 'w');
             @fwrite($f, '');
             @fclose($f);
             @chmod($file, 0644);
         }
         $upload_path .= cdate('m') . '/';
         if (is_dir($upload_path) === false) {
             mkdir($upload_path, 0707);
             $file = $upload_path . 'index.php';
             $f = @fopen($file, 'w');
             @fwrite($f, '');
             @fclose($f);
             @chmod($file, 0644);
         }
         list($usec, $sec) = explode(' ', microtime());
         $file_name = md5(uniqid(mt_rand())) . '_' . str_replace('.', '', $sec . $usec) . '.' . $ext;
         $save_dir = $upload_path . $file_name;
         $save_url = site_url('uploads/editor/' . cdate('Y') . '/' . cdate('m') . '/' . $file_name);
         $fp = fopen($save_dir, 'w');
         fwrite($fp, $rawdata);
         fclose($fp);
         if (file_exists($save_dir)) {
             return $save_url;
         }
     }
     return;
 }
Exemple #10
0
function __autoload($class)
{
    // $class = strtolower($class);
    // $class = str_replace('A\\',DIRECTORY_SEPARATOR,$class);
    $name = $class . '.class.php';
    // echo $name;
    get_extension($name);
    get_exist($name);
    require_once $name;
}
Exemple #11
0
function show_image($image)
{
    header('Content-type: image/' . get_extension($image));
    $handle = fopen($image, "rb");
    while (!feof($handle)) {
        $buffer = fgets($handle, 4096);
        echo $buffer;
    }
    fclose($handle);
}
Exemple #12
0
function getFileType($image_data)
{
    $f = finfo_open();
    $mime_type = finfo_buffer($f, $image_data, FILEINFO_MIME_TYPE);
    $ext = get_extension($mime_type);
    if ($ext === false) {
        error("Unsupported filetype: " . $mime_type);
    }
    return $ext;
}
Exemple #13
0
function verif_image($tabFile)
{
    $ret = _UPLOAD_NO_ERROR;
    $file_name = $tabFile["name"];
    $extension = get_extension($file_name);
    if (!in_array($extension, array(_UPLOAD_EXTENSION_JPG, _UPLOAD_EXTENSION_PNG, _UPLOAD_EXTENSION_GIF))) {
        $ret = _UPLOAD_TYPE_ERROR;
    }
    return $ret;
}
Exemple #14
0
/**
 * @param string $name
 * @param string $type
 * @return bool
 */
function jet_Upload($name = 'random', $type = 'image')
{
    if ($type and !file_exists(ROOT . '/uploads/' . $type)) {
        mkdir(ROOT . '/uploads/' . $type);
    }
    $f = array_keys($_FILES)[0];
    $ext = get_extension($_FILES[$f]['name']);
    $save_path = $type ? ROOT . '/uploads/' . $type . '/' : ROOT . 'uploads/';
    $save_name = $name ? $name . '.' . $ext : jetRandString(12) . '.' . $ext;
    return move_uploaded_file($_FILES[$f]["tmp_name"], $save_path . $save_name) || false;
}
function deal_upload_image($fileInfo, $allowExt = array("gif", "jpeg", "jpg", "png", "wbmp"), $maxSize = 1512000, $imgFlag = true)
{
    if ($fileInfo['error'] == 0) {
        //UPLOAD_ERR_OK
        $f_ext = get_extension($fileInfo['name']);
        if (!in_array($f_ext, $allowExt)) {
            return $mes = '非法文件类型';
        }
        if ($fileInfo['size'] > $maxSize) {
            return $mes = '文件大小超过上限';
        }
        if ($imgFlag) {
            $info = getimagesize($fileInfo['tmp_name']);
            if (!$info) {
                return $mes = '不是真实的图片类型';
            }
        }
        return true;
    } else {
        switch ($fileInfo['error']) {
            case 1:
                $mes = "超过了配置文件上传文件的大小";
                //UPLOAD_ERR_INI_SIZE
                break;
            case 2:
                $mes = "超过了表单设置上传文件的大小";
                //UPLOAD_ERR_FORM_SIZE
                break;
            case 3:
                $mes = "文件部分被上传";
                //UPLOAD_ERR_PARTIAL
                break;
            case 4:
                $mes = "没有文件被上传";
                //UPLOAD_ERR_NO_FILE
                break;
            case 6:
                $mes = "没有找到临时目录";
                //UPLOAD_ERR_NO_TMP_DIR
                break;
            case 7:
                $mes = "文件不可写";
                //UPLOAD_ERR_CANT_WRITE;
                break;
            case 8:
                $mes = "由于PHP的扩展程序中断了文件上传";
                //UPLOAD_ERR_EXTENSION
                break;
        }
        return $mes;
    }
}
function upload()
{
    $maxsize = 10000000;
    //set to approx 10 MB
    //check associated error code
    if ($_FILES['userfile']['error'] == UPLOAD_ERR_OK) {
        //check whether file is uploaded with HTTP POST
        if (is_uploaded_file($_FILES['userfile']['tmp_name'])) {
            //checks size of uploaded image on server side
            if ($_FILES['userfile']['size'] < $maxsize) {
                //checks whether uploaded file is of image type
                //if(strpos(mime_content_type($_FILES['userfile']['tmp_name']),"image")===0) {
                $finfo = finfo_open(FILEINFO_MIME_TYPE);
                if (strpos(finfo_file($finfo, $_FILES['userfile']['tmp_name']), "image") === 0) {
                    // prepare the image for insertion
                    $imgData = addslashes(file_get_contents($_FILES['userfile']['tmp_name']));
                    // put the image in the db...
                    // database connection
                    $con = mysqli_connect('localhost', 'shibli', 'shibli') or die(mysqli_error($con));
                    // select the db
                    mysqli_select_db($con, 'piclib') or die("Unable to select db" . mysqli_error($con));
                    // our sql query
                    $ext = get_extension($_FILES['userfile']['name']);
                    $query2 = " Select max(imageID) from imgdata;";
                    $result2 = mysqli_query($con, $query2);
                    $row2 = mysqli_fetch_row($result2);
                    $r = $row2[0] + 1;
                    $sql = "INSERT INTO imgdata values({$r},'{$ext}','{$_POST['imageName']}','{$_POST['user']}','{$imgData}')";
                    header('location: http://localhost:63342/VideoLibraryApp/views/displayLogged.php');
                    // insert the image
                    mysqli_query($con, $sql) or die("Error in Query: " . mysqli_error($con));
                    $msg = '<p>Image successfully saved in database with id =' . mysqli_insert_id($con) . ' </p>';
                } else {
                    $msg = "<p>Uploaded file is not an image.</p>";
                }
            } else {
                // if the file is not less than the maximum allowed, print an error
                $msg = '<div>File exceeds the Maximum File limit</div>
                <div>Maximum File limit is ' . $maxsize . ' bytes</div>
                <div>File ' . $_FILES['userfile']['name'] . ' is ' . $_FILES['userfile']['size'] . ' bytes</div><hr />';
            }
        } else {
            $msg = "File not uploaded successfully.";
        }
    } else {
        $msg = file_upload_error_message($_FILES['userfile']['error']);
    }
    return $msg;
}
Exemple #17
0
 function _do_upload()
 {
     $config['upload_path'] = './assets/logo/';
     $config['overwrite'] = TRUE;
     $config['file_name'] = 'logo';
     $config['allowed_types'] = 'jpg|jpeg|png|bmp';
     $this->load->library('upload', $config);
     $ext = @get_extension($_FILES['logo']["name"]);
     if ($this->upload->do_upload('logo')) {
         $resize = array('width' => 100, 'height' => 100, 'quality' => '100%', 'create_thumb' => false, 'source_image' => './assets/logo/' . $config['file_name'] . $ext);
         $this->load->library('image_lib', $resize);
         //$this->image_lib->initialize();
         $this->image_lib->resize();
         $this->image_lib->clear();
         return 'logo' . $ext;
     }
     return null;
 }
function replace_phonegap_tag($path)
{
    $filelist = my_scandir($path);
    foreach ($filelist as $file) {
        if (get_extension($file) == "html") {
            $path_prefix = "";
            echo $file . "\n";
            $wwwpos = strpos($file, "www/");
            $filename = substr($file, $wwwpos);
            for ($i = 0; $i < substr_count($filename, "/") - 1; $i++) {
                $path_prefix .= "../";
            }
            $content = file_get_contents($file);
            $new_content = preg_replace("/<phonegap>.*<\\/phonegap>/is", "<script type='text/javascript' charset='utf-8' src='" . $path_prefix . "phonegap.js'></script>", $content);
            file_put_contents($file, $new_content);
        }
    }
}
function saveFile($postFileField)
{
    //get location where file will be saved
    $path = getenv("DOCUMENT_ROOT") . '/admin/reseller_locator/products/product_images/';
    $file_temp = $_FILES[$postFileField]['tmp_name'];
    $file_name = prep_filename($_FILES[$postFileField]['name']);
    $file_ext = get_extension($_FILES[$postFileField]['name']);
    $newf_name = set_filename($path, $file_name, $file_ext);
    $file_size = round($_FILES[$postFileField]['size'] / 1024, 2);
    $targetFile = str_replace('//', '/', $path) . $newf_name;
    //save the file
    move_uploaded_file($file_temp, $targetFile);
    if ($GLOBALS['debug']) {
        echo 'file ' . $file_name . ' was saved.';
    }
    //save file permissions
    chmod($targetFile, 0777);
    //return $file_name; //to be saved in the db
    return $newf_name;
    //to be saved in the db
}
Exemple #20
0
function make_thumb($img_name, $filename, $new_w, $new_h)
{
    $ext = get_extension($img_name);
    if (!strcmp("jpg", $ext) || !strcmp("jpeg", $ext)) {
        $src_img = imagecreatefromjpeg($img_name);
    }
    if (!strcmp("png", $ext)) {
        $src_img = imagecreatefrompng($img_name);
    }
    if (!strcmp("gif", $ext)) {
        $src_img = imagecreatefrompng($img_name);
    }
    $old_x = imageSX($src_img);
    $old_y = imageSY($src_img);
    $ratio1 = $old_x / $new_w;
    $ratio2 = $old_y / $new_h;
    if ($ratio1 > $ratio2) {
        $thumb_w = $new_w;
        $thumb_h = $old_y / $ratio1;
    } else {
        $thumb_h = $new_h;
        $thumb_w = $old_x / $ratio2;
    }
    $dst_img = ImageCreateTrueColor($thumb_w, $thumb_h);
    imagealphablending($dst_img, false);
    imagesavealpha($dst_img, true);
    imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $thumb_w, $thumb_h, $old_x, $old_y);
    if (!strcmp("png", $ext)) {
        imagepng($dst_img, $filename);
    }
    if (!strcmp("jpg", $ext) || !strcmp("jpeg", $ext)) {
        imagejpeg($dst_img, $filename, 100);
    }
    if (!strcmp("gif", $ext)) {
        imagegif($dst_img, $filename);
    }
    imagedestroy($dst_img);
    imagedestroy($src_img);
}
Exemple #21
0
 /**
  * @param array $infos assoc array of data from images table
  */
 function __construct($infos)
 {
     global $conf;
     $this->id = $infos['id'];
     $ext = get_extension($infos['path']);
     if (in_array($ext, $conf['picture_ext'])) {
         $this->rel_path = $infos['path'];
         $this->flags |= self::IS_ORIGINAL;
     } elseif (!empty($infos['representative_ext'])) {
         $this->rel_path = original_to_representative($infos['path'], $infos['representative_ext']);
     } else {
         $ext = strtolower($ext);
         $this->rel_path = trigger_change('get_mimetype_location', get_themeconf('mime_icon_dir') . $ext . '.png', $ext);
         $this->flags |= self::IS_MIMETYPE;
         if (($size = @getimagesize(PHPWG_ROOT_PATH . $this->rel_path)) === false) {
             $this->rel_path = 'themes/default/icon/mimetypes/unknown.png';
             $size = getimagesize(PHPWG_ROOT_PATH . $this->rel_path);
         }
         $this->size = array($size[0], $size[1]);
     }
     if (!$this->size) {
         if (isset($infos['width']) && isset($infos['height'])) {
             $width = $infos['width'];
             $height = $infos['height'];
             $this->rotation = intval($infos['rotation']) % 4;
             // 1 or 5 =>  90 clockwise
             // 3 or 7 => 270 clockwise
             if ($this->rotation % 2) {
                 $width = $infos['height'];
                 $height = $infos['width'];
             }
             $this->size = array($width, $height);
         } elseif (!array_key_exists('width', $infos)) {
             $this->flags |= self::DIM_NOT_GIVEN;
         }
     }
 }
Exemple #22
0
 function img_uploadify()
 {
     if (!empty($_FILES)) {
         $path = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . '/';
         $file_temp = $_FILES['Filedata']['tmp_name'];
         $file_name = prep_filename($_FILES['Filedata']['name']);
         $file_ext = get_extension($_FILES['Filedata']['name']);
         $real_name = $file_name;
         $newf_name = set_filename($path, $file_name, $file_ext);
         $file_size = round($_FILES['Filedata']['size'] / 1024, 2);
         $file_type = preg_replace("/^(.+?);.*\$/", "1", $_FILES['Filedata']['type']);
         $file_type = strtolower($file_type);
         $targetFile = str_replace('//', '/', $path) . $newf_name;
         move_uploaded_file($file_temp, $targetFile);
         $filearray = array();
         $filearray['full_path'] = $targetFile;
         $filearray['file_name'] = $newf_name;
         $filearray['real_name'] = $real_name;
         $filearray['file_ext'] = $file_ext;
         $filearray['file_size'] = $file_size;
         $filearray['file_temp'] = $file_temp;
         return $filearray;
     }
 }
Exemple #23
0
/**
 * Fetch the attachments for a specific post and parse inline [attachment=id] code.
 * Note: assumes you have $attachcache, an array of attachments set up.
 *
 * @param int The ID of the item.
 * @param array The post or item passed by reference.
 */
function get_post_attachments($id, &$post)
{
    global $attachcache, $mybb, $theme, $templates, $forumpermissions, $lang;
    $validationcount = 0;
    $tcount = 0;
    if (isset($attachcache[$id]) && is_array($attachcache[$id])) {
        // This post has 1 or more attachments
        foreach ($attachcache[$id] as $aid => $attachment) {
            if ($attachment['visible']) {
                // There is an attachment thats visible!
                $attachment['filename'] = htmlspecialchars_uni($attachment['filename']);
                $attachment['filesize'] = get_friendly_size($attachment['filesize']);
                $ext = get_extension($attachment['filename']);
                if ($ext == "jpeg" || $ext == "gif" || $ext == "bmp" || $ext == "png" || $ext == "jpg") {
                    $isimage = true;
                } else {
                    $isimage = false;
                }
                $attachment['icon'] = get_attachment_icon($ext);
                // Support for [attachment=id] code
                if (stripos($post['message'], "[attachment=" . $attachment['aid'] . "]") !== false) {
                    // Show as thumbnail IF image is big && thumbnail exists && setting=='thumb'
                    // Show as full size image IF setting=='fullsize' || (image is small && permissions allow)
                    // Show as download for all other cases
                    if ($attachment['thumbnail'] != "SMALL" && $attachment['thumbnail'] != "" && $mybb->settings['attachthumbnails'] == "yes") {
                        eval("\$attbit = \"" . $templates->get("postbit_attachments_thumbnails_thumbnail") . "\";");
                    } elseif (($attachment['thumbnail'] == "SMALL" && $forumpermissions['candlattachments'] == 1 || $mybb->settings['attachthumbnails'] == "no") && $isimage) {
                        eval("\$attbit = \"" . $templates->get("postbit_attachments_images_image") . "\";");
                    } else {
                        eval("\$attbit = \"" . $templates->get("postbit_attachments_attachment") . "\";");
                    }
                    $post['message'] = preg_replace("#\\[attachment=" . $attachment['aid'] . "]#si", $attbit, $post['message']);
                } else {
                    // Show as thumbnail IF image is big && thumbnail exists && setting=='thumb'
                    // Show as full size image IF setting=='fullsize' || (image is small && permissions allow)
                    // Show as download for all other cases
                    if ($attachment['thumbnail'] != "SMALL" && $attachment['thumbnail'] != "" && $mybb->settings['attachthumbnails'] == "yes") {
                        eval("\$post['thumblist'] .= \"" . $templates->get("postbit_attachments_thumbnails_thumbnail") . "\";");
                        if ($tcount == 5) {
                            $thumblist .= "<br />";
                            $tcount = 0;
                        }
                        ++$tcount;
                    } elseif (($attachment['thumbnail'] == "SMALL" && $forumpermissions['candlattachments'] == 1 || $mybb->settings['attachthumbnails'] == "no") && $isimage) {
                        eval("\$post['imagelist'] .= \"" . $templates->get("postbit_attachments_images_image") . "\";");
                    } else {
                        eval("\$post['attachmentlist'] .= \"" . $templates->get("postbit_attachments_attachment") . "\";");
                    }
                }
            } else {
                $validationcount++;
            }
        }
        if ($validationcount > 0 && is_moderator($post['fid'])) {
            if ($validationcount == 1) {
                $postbit_unapproved_attachments = $lang->postbit_unapproved_attachment;
            } else {
                $postbit_unapproved_attachments = $lang->sprintf($lang->postbit_unapproved_attachments, $validationcount);
            }
            eval("\$post['attachmentlist'] .= \"" . $templates->get("postbit_attachments_attachment_unapproved") . "\";");
        }
        if ($post['thumblist']) {
            eval("\$post['attachedthumbs'] = \"" . $templates->get("postbit_attachments_thumbnails") . "\";");
        }
        if ($post['imagelist']) {
            eval("\$post['attachedimages'] = \"" . $templates->get("postbit_attachments_images") . "\";");
        }
        if ($post['attachmentlist'] || $post['thumblist'] || $post['imagelist']) {
            eval("\$post['attachments'] = \"" . $templates->get("postbit_attachments") . "\";");
        }
    }
}
function removeOldImages($dir, $name)
{
    global $filesystem;
    $dir = realpath($dir);
    $dir_open = @opendir($dir);
    while (($dir_content = readdir($dir_open)) !== false) {
        if ($dir_content != '.' && $dir_content != '..') {
            $ext = get_extension($dir_content, true);
            $fname = str_ireplace($ext, '', $dir_content);
            if ($fname == $name) {
                @$filesystem->unlink($dir . '/' . $dir_content);
            }
        }
    }
    closedir($dir_open);
}
Exemple #25
0
 /**
  * Get the language variables for a section.
  * @return array The language variables.
  */
 function get_languages()
 {
     $dir = @opendir($this->path);
     while ($lang = readdir($dir)) {
         $ext = do_strtolower(get_extension($lang));
         if ($lang != "." && $lang != ".." && $ext == "php") {
             $lname = str_replace("." . $ext, "", $lang);
             require $this->path . PATH_SPLITTER . $lang;
             $languages[$lname] = $langinfo['name'];
         }
     }
     @ksort($languages);
     return $languages;
 }
Exemple #26
0
function showcert()
{
    global $user, $globals, $l, $theme, $softpanel, $error, $done, $key_list;
    echo '<table border="0" cellpadding="8" cellspacing="0" width="100%" class="sai_altrowstable">	
	<tr>
		<th align="center" width="70%">' . $l['cert_file'] . '</th>
		<th align="center"  >' . $l['option'] . '</th>
	</tr>
	<tr>';
    // Getting cert files
    $key_list = $softpanel->keyfiles();
    // Why required again ?
    $i = 1;
    foreach ($key_list as $key => $value) {
        $ext = get_extension($value);
        if ($ext == 'key') {
            $file = get_filename($value);
            echo '<tr class="' . ($i % 2 == 0 ? "sai_evenrowcolor" : "sai_oddrowcolor") . '" >
					<td>
						<span id="name' . $key . '">' . $file . '</span>							
					</td>
					<td>
					 	<img title="Delete" class="delete" id="did' . $key . '" src="' . $theme['images'] . 'remove.gif" style="cursor:pointer" /> &nbsp;<img title="Show" class="edit" id="eid' . $file . '" src="' . $theme['images'] . 'editdetail.gif" style="cursor:pointer"  /> 
					 </td>';
            $i++;
        }
    }
    echo '</tr>
	</table><br /></br>
	<script language="javascript" type="text/javascript"><!-- // --><![CDATA[
	
		$(document).ready(function(){
			// For deleting record
			$(".delete").click(function() {
				message_box.delete_message ("Warning", "' . $l['record_del_conf'] . '", $(this).attr("id").substr(3));
			});
			
			// For creating DNS
			$(".edit").click(function(){
				var did = $(this).attr("id").substr(3);
				$.ajax({
					type: "POST",
					url: window.location+"&ajaxdetail=1&detail_record="+did,
					
					// Checking for error
					success: function(data){
						$("#detailrectab")
							.html(data)
							.slideDown("slide", "", 5000);
					},
					error: function() {
						message_box.show_message("Error", "' . $l['connect_error'] . '", 1);
					}
				});
													
			});
		});	
			
	// ]]></script>';
}
 if (count($ids) == 0) {
     error($lang->phrase('no_data_selected'));
 }
 $iid = implode(',', $ids);
 if ($config['updatepostcounter'] == 1 && $last['count_posts'] == 1) {
     $result = $db->query("SELECT COUNT(*) AS posts, name FROM {$db->pre}replies WHERE guest = '0' AND id IN ({$iid}) GROUP BY name", __LINE__, __FILE__);
     while ($row = $db->fetch_assoc($result)) {
         $db->query("UPDATE {$db->pre}user SET posts = posts-{$row['posts']} WHERE id = '{$row['name']}'", __LINE__, __FILE__);
     }
 }
 $db->query("DELETE FROM {$db->pre}replies WHERE id IN ({$iid})", __LINE__, __FILE__);
 $anz = $db->affected_rows();
 $uresult = $db->query("SELECT id, source FROM {$db->pre}uploads WHERE tid IN ({$iid})", __LINE__, __FILE__);
 while ($urow = $db->fetch_assoc($uresult)) {
     $filesystem->unlink('uploads/topics/' . $urow['source']);
     $thumb = 'uploads/topics/thumbnails/' . $urow['id'] . get_extension($urow['source'], true);
     if (file_exists($thumb)) {
         $filesystem->unlink($thumb);
     }
 }
 $db->query("DELETE FROM {$db->pre}postratings WHERE pid IN ({$iid})", __LINE__, __FILE__);
 $db->query("DELETE FROM {$db->pre}uploads WHERE tid IN ({$iid})", __LINE__, __FILE__);
 $result = $db->query("SELECT id FROM {$db->pre}replies WHERE topic_id = '{$info['id']}'");
 if ($db->num_rows($result) == 0) {
     $db->query("DELETE FROM {$db->pre}abos WHERE tid = '{$info['id']}'", __LINE__, __FILE__);
     $db->query("DELETE FROM {$db->pre}topics WHERE id = '{$info['id']}'", __LINE__, __FILE__);
     $votes = $db->query("SELECT id FROM {$db->pre}vote WHERE tid = '{$info['id']}'", __LINE__, __FILE__);
     $voteaids = array();
     while ($row = $db->fetch_num($votes)) {
         $voteaids[] = $row[0];
     }
Exemple #28
0
 }
 // Are we uploading a new avatar?
 if ($_FILES['avatar_upload']['name']) {
     $avatar = upload_avatar($_FILES['avatar_upload'], $user['uid']);
     if ($avatar['error']) {
         $errors = array($avatar['error']);
     } else {
         if ($avatar['width'] > 0 && $avatar['height'] > 0) {
             $avatar_dimensions = $avatar['width'] . "|" . $avatar['height'];
         }
         $extra_user_updates = array("avatar" => $avatar['avatar'] . '?dateline=' . TIME_NOW, "avatardimensions" => $avatar_dimensions, "avatartype" => "upload");
     }
 } else {
     if ($mybb->input['avatar_url'] && $mybb->input['avatar_url'] != $user['avatar']) {
         $mybb->input['avatar_url'] = preg_replace("#script:#i", "", $mybb->input['avatar_url']);
         $ext = get_extension($mybb->input['avatar_url']);
         // Copy the avatar to the local server (work around remote URL access disabled for getimagesize)
         $file = fetch_remote_file($mybb->input['avatar_url']);
         if (!$file) {
             $avatar_error = $lang->error_invalidavatarurl;
         } else {
             $tmp_name = "../" . $mybb->settings['avataruploadpath'] . "/remote_" . md5(random_str());
             $fp = @fopen($tmp_name, "wb");
             if (!$fp) {
                 $avatar_error = $lang->error_invalidavatarurl;
             } else {
                 fwrite($fp, $file);
                 fclose($fp);
                 list($width, $height, $type) = @getimagesize($tmp_name);
                 @unlink($tmp_name);
                 echo $type;
Exemple #29
0
        ?>
">
					<img src="<?php 
        echo $tpl->img('filetypes/folder');
        ?>
" alt="" border="0" />&nbsp;<?php 
        echo $dirname;
        ?>
					</a><br />
					<?php 
    }
    if ($i >= 0 || $dotdotdir) {
        echo "</td></tr><tr><td>";
    }
    foreach ($files as $filename) {
        $ext = strtolower(get_extension($filename));
        $icon = isset($fileicons[$ext]) ? $fileicons[$ext] : 'unknown';
        ?>
					<a href="javascript:selectImage('<?php 
        echo EDITOR_IMAGEDIR . $filename;
        ?>
');">
					  <img src="<?php 
        echo $tpl->img("filetypes/{$icon}");
        ?>
" alt="<?php 
        echo strtoupper($ext);
        ?>
" border="0" />&nbsp;<?php 
        echo $filename;
        ?>
Exemple #30
0
 $page->output_header($lang->smilies . " - " . $lang->add_multiple_smilies);
 $sub_tabs['manage_smilies'] = array('title' => $lang->manage_smilies, 'link' => "index.php?module=config-smilies");
 $sub_tabs['add_smilie'] = array('title' => $lang->add_smilie, 'link' => "index.php?module=config-smilies&amp;action=add");
 $sub_tabs['add_multiple_smilies'] = array('title' => $lang->add_multiple_smilies, 'link' => "index.php?module=config-smilies&amp;action=add_multiple", 'description' => $lang->add_multiple_smilies_desc);
 $sub_tabs['mass_edit'] = array('title' => $lang->mass_edit, 'link' => "index.php?module=config-smilies&amp;action=mass_edit");
 $page->output_nav_tabs($sub_tabs, 'add_multiple_smilies');
 $form = new Form("index.php?module=config-smilies&amp;action=add_multiple", "post", "add_multiple");
 echo $form->generate_hidden_field("step", "2");
 echo $form->generate_hidden_field("pathfolder", $path);
 $form_container = new FormContainer($lang->add_multiple_smilies);
 $form_container->output_row_header($lang->image, array("class" => "align_center", 'width' => '10%'));
 $form_container->output_row_header($lang->name);
 $form_container->output_row_header($lang->text_replace, array('width' => '20%'));
 $form_container->output_row_header($lang->include, array("class" => "align_center", 'width' => '5%'));
 foreach ($smilies as $key => $file) {
     $ext = get_extension($file);
     $find = str_replace("." . $ext, "", $file);
     $name = ucfirst($find);
     $form_container->output_cell("<img src=\"../" . $path . $file . "\" alt=\"\" /><br /><small>{$file}</small>", array("class" => "align_center", "width" => 1));
     $form_container->output_cell($form->generate_text_box("name[{$file}]", $name, array('id' => 'name', 'style' => 'width: 98%')));
     $form_container->output_cell($form->generate_text_box("find[{$file}]", ":" . $find . ":", array('id' => 'find', 'style' => 'width: 95%')));
     $form_container->output_cell($form->generate_check_box("include[{$file}]", 1, "", array('checked' => 1)), array("class" => "align_center"));
     $form_container->construct_row();
 }
 if ($form_container->num_rows() == 0) {
     flash_message($lang->error_no_images, 'error');
     admin_redirect("index.php?module=config-smilies&action=add_multiple");
 }
 $form_container->end();
 $buttons[] = $form->generate_submit_button($lang->save_smilies);
 $form->output_submit_wrapper($buttons);