Ejemplo n.º 1
0
 function UploadFiles()
 {
     global $ioptions, $filesendname;
     $our_folder = $this->folder;
     if ($_GET['uri'] != '') {
         $this->folder = $_GET['uri'];
         if (!file_exists(DIR . $this->folder)) {
             mkdir(DIR . $this->folder);
         }
         $realpath1 = realpath(DIR . $our_folder);
         $realpath2 = realpath(DIR . $_GET['uri']);
         $strlen1 = strlen($realpath1);
         $strlen2 = strlen($realpath2);
         if ($strlen1 > $strlen2) {
             page404();
             exit;
         }
         for ($i = 0; $i < $strlen1; $i++) {
             if ($realpath1[$i] != $realpath2[$i]) {
                 page404();
                 exit;
             }
         }
     } else {
         if ($_GET['folder'] != '') {
             $this->folder = '/storage/' . $_GET['folder'];
             if (!file_exists(DIR . $this->folder)) {
                 mkdir(DIR . $this->folder);
             }
         }
     }
     $result = array();
     if (isset($_FILES['Filedata'])) {
         $file = $_FILES['Filedata']['tmp_name'];
         $error = false;
         $size = false;
         /*if (!is_uploaded_file($file)  )  {
         				 
         
         			}
         			else {*/
         if (!is_uploaded_file($file)) {
             print "error1";
             exit;
         } else {
             if (!($size = @getimagesize($file)) && strtolower(substr($_FILES['Filedata']['name'], strrpos($_FILES['Filedata']['name'], '.') + 1)) != 'svg') {
                 print "error2";
                 exit;
             } else {
                 if (!$error && !in_array($size[2], array(1, 2, 3, 7, 8)) && strtolower(substr($_FILES['Filedata']['name'], strrpos($_FILES['Filedata']['name'], '.') + 1)) != 'svg') {
                     print "error3";
                     exit;
                 } else {
                     $ext = strtolower(substr($_FILES['Filedata']['name'], strrpos($_FILES['Filedata']['name'], '.') + 1));
                     $name = findname($_FILES['Filedata']['tmp_name'], DIR . $this->folder, $_FILES['Filedata']['name'], $_FILES['Filedata']['name'] == 'blob.png');
                     if (!file_exists(DIR . $this->folder . '/.thumbs')) {
                         mkdir(DIR . $this->folder . '/.thumbs');
                     }
                     if ($ioptions["water"] != '') {
                         $name = $name . "_water";
                     }
                     $source = DIR . $this->folder . '/' . $name . '.' . $ext;
                     if (!@copy($_FILES['Filedata']['tmp_name'], $source)) {
                         //print "error4";
                     }
                     if (true) {
                         if (!file_exists(DIR . $this->folder . '/.thumbs')) {
                             mkdir(DIR . $this->folder . '/.thumbs');
                         }
                         if ($ioptions["water"] != '') {
                             $thumb = DIR . $this->folder . '/.thumbs/preview1_' . $name . '.' . "png";
                         } else {
                             $thumb = DIR . $this->folder . '/.thumbs/preview1_' . $name . '.' . $ext;
                         }
                         //$thumb2 = DIR.$this->folder.'/.thumbs/preview_2_'.$name.'.'.$ext;
                         //$image = new files('tinyimages');
                         //$this->Resize($source,$thumb,200,200,'back-ffffff');
                         /******************************************************************
                          *****************************************************************
                          **************************************************************
                          *******************************************************************/
                         /*>>>>>>>>>>>>>>*/
                         $this->Resize($source, $thumb, $ioptions["w"], $ioptions["h"], 'thumb', $ioptions["water"]);
                         //<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                         /*>>>>>>>>>>>>>>*/
                         $i = 2;
                         $fl = 0;
                         while ($fl == 0) {
                             if (isset($ioptions["w" . $i]) && isset($ioptions["h" . $i])) {
                                 $thumb = DIR . $this->folder . '/.thumbs/preview' . $i . '_' . $name . '.' . $ext;
                                 if (strtolower($ext) != 'svg') {
                                     $this->Resize($source, $thumb, $ioptions["w" . $i], $ioptions["h" . $i], 'thumb');
                                 } else {
                                     copy($source, $thumb);
                                 }
                                 $i++;
                             } else {
                                 $fl = 1;
                             }
                         }
                         $result['result'] = 'success';
                         $newadress = $this->folder;
                         $newfilename = $name . '.' . $ext;
                         if (isset($_GET['uri'])) {
                             $newadress = $_GET['uri'];
                         }
                         if ($newadress == "") {
                             $newadress = "/storage";
                         }
                         print $newadress . "/" . $newfilename;
                     } else {
                         $result['result'] = 'success';
                         $newadress = "/storage";
                         $newfilename = $name . '.' . $ext;
                         if (isset($_GET['uri'])) {
                             $newadress = $_GET['uri'];
                         }
                         if ($newadress == "") {
                             $newadress = "/storage";
                         }
                         print $newadress . "/" . $newfilename;
                     }
                 }
             }
         }
     } else {
         print 'error5';
     }
     /*foreach ($result as $key=>$val) {
     			$return[$key] = iconv("windows-1251", "utf-8", $val);
     		}*/
     exit;
 }
Ejemplo n.º 2
0
 function UploadFiles()
 {
     global $ioptions, $filesendname;
     $our_folder = $this->folder;
     if ($_GET['uri'] != '') {
         $this->folder = $_GET['uri'];
         if (!file_exists(DIR . $this->folder)) {
             mkdir(DIR . $this->folder);
         }
         $realpath1 = realpath(DIR . $our_folder);
         $realpath2 = realpath(DIR . $_GET['uri']);
         $strlen1 = strlen($realpath1);
         $strlen2 = strlen($realpath2);
         if ($strlen1 > $strlen2) {
             page404();
             exit;
         }
         for ($i = 0; $i < $strlen1; $i++) {
             if ($realpath1[$i] != $realpath2[$i]) {
                 page404();
                 exit;
             }
         }
     }
     $result = array();
     if (isset($_FILES['Filedata'])) {
         $file = $_FILES['Filedata']['tmp_name'];
         $error = false;
         $size = false;
         /*if (!is_uploaded_file($file)  )  {
         				 
         
         			}
         			else {*/
         if (!is_uploaded_file($file)) {
             print "error1";
             exit;
         } else {
             if (false) {
                 print "error2";
                 exit;
             } else {
                 if (!preg_match('/\\.(mp3|zip|txt|flv|doc|rtf|swf|docx|xlsx|xml|ies|pdf|zip|rar|xls|jpg|gif|png|jpeg|pptx?)$/i', $_FILES['Filedata']['name'])) {
                     print "ERROR_Invalid_filetype";
                     exit;
                 } else {
                     $newadress = "/storage";
                     $newfilename = $name . '.' . $ext;
                     if (isset($_GET['uri'])) {
                         $newadress = $_GET['uri'];
                     }
                     $ext = substr($_FILES['Filedata']['name'], strrpos($_FILES['Filedata']['name'], '.') + 1);
                     $name = findname($_FILES['Filedata']['tmp_name'], DIR . $this->folder, $_FILES['Filedata']['name'], false);
                     $source = DIR . $this->folder . '/' . $name . '.' . $ext;
                     if (!copy($_FILES['Filedata']['tmp_name'], $source)) {
                         print "error4";
                     } else {
                         $result['result'] = 'success';
                         $newadress = "/storage";
                         $newfilename = $name . '.' . $ext;
                         if (isset($_GET['uri'])) {
                             $newadress = $_GET['uri'];
                         }
                         if ($newadress == "") {
                             $newadress = "/storage";
                         }
                         print $newadress . "/" . $newfilename;
                     }
                 }
             }
         }
     } else {
         print 'error5';
     }
     /*foreach ($result as $key=>$val) {
     			$return[$key] = iconv("windows-1251", "utf-8", $val);
     		}*/
     exit;
 }
Ejemplo n.º 3
0
function layerdata4(&$energy1, $minenergy, $maxenergy, &$colorindex, $layer, &$mult, &$order)
{
    echo '<table  border="1">';
    //625 table
    echo '<tr>';
    for ($m = 0; $m < $mult[$order["5"]]; $m++) {
        //wwr print heading
        echo '<th style="font-size:15px;">' . findname($order["5"]) . ' ' . findAssoValue($order["5"], $m) . '</th>';
    }
    echo '</tr>';
    echo '<tr>';
    for ($m = 0; $m < $mult[$order["5"]]; $m++) {
        //wwr
        echo "<td>";
        echo '<table >';
        //625 table
        $flagod = 1;
        //for limiting the no of times "Overhang Depth" is to be printed
        for ($l = 0; $l < $mult[$order["4"]]; $l++) {
            //shgc
            echo '<tr>';
            echo "<td>";
            echo '<table >';
            //125 table
            echo "<tr>";
            echo "<td></td>";
            //an extra column due to shgc printing
            if ($flagod == 1) {
                for ($t = 0; $t < $mult[$order["3"]]; $t++) {
                    echo "<td>";
                    echo findname($order["3"]) . ' ' . findAssoValue($order["3"], $t);
                    echo "</td>";
                }
                //$flagod=0;
            }
            echo "</tr>";
            echo "<tr>";
            echo '<td>' . findname($order["4"]) . ' ' . findAssoValue($order["4"], $l) . '</td>';
            for ($k = 0; $k < $mult[$order["3"]]; $k++) {
                //overhang
                echo "<td>";
                echo '<table border="1" bgcolor="white">';
                //5*5 table
                echo "<tr>";
                echo "<th>";
                //extra heading due to azimuth angle
                echo "</th>";
                for ($t = 0; $t < $mult[$order["1"]]; $t++) {
                    echo "<th>";
                    echo findname($order["1"]) . ' ' . findAssoValue($order["1"], $t);
                    //printing ratio
                    echo "</th>";
                }
                echo "</tr>";
                for ($j = 0; $j < $mult[$order["2"]]; $j++) {
                    //represents azimuth
                    echo "<tr>";
                    $flag = 0;
                    if ($flag == 0) {
                        echo '<td>' . findname($order["2"]) . ' ' . findAssoValue($order["2"], $j) . '</td>';
                        //printing azimuth
                    }
                    for ($i = 0; $i < $mult[$order["1"]]; $i++) {
                        //aspect ratio
                        $hascolor = getcolor($i, $j, $k, $l, $m, $energy1, $minenergy, $maxenergy, $colorindex, $mult, $order);
                        $tempindex = 0;
                        //=intval(($energy1[5*$i+625*$j+25*$k+$l+125*$m]-$minenergy)/($maxenergy-$minenergy)*255);
                        //echo '<td bgcolor="'.$hascolor.'"><font color="black">'.(5*$i+625*$j+25*$k+$l+125*$m)." ".$tempindex.'</font></td>';
                        echo '<td  bgcolor="' . $hascolor . '"><font color="black">
                        <div style="width:' . $layer * 5 . 'px;height:10px"><font size="1">' . round($energy1[findmult($order["1"], $mult) * $i + findmult($order["2"], $mult) * $j + findmult($order["3"], $mult) * $k + findmult($order["4"], $mult) * $l + findmult($order["5"], $mult) * $m], 2) . '</font></div>
                     </font></td>';
                    }
                    echo "</tr>";
                }
                $flag = -1;
                echo "</table>";
                echo "</td>";
            }
            echo "</tr>";
            echo "</table>";
            echo "</td>";
            echo "</tr>";
        }
        echo "</table>";
        echo "</td>";
    }
    echo "</tr>";
    echo "</table>";
}
Ejemplo n.º 4
0
function UploadFiles()
{
    global $ioptions;
    $our_folder = $_SERVER["DOCUMENT_ROOT"] . "/storage";
    $result = array();
    if (isset($_FILES['image']) || !empty($_POST['base64'])) {
        if (!empty($_POST['base64'])) {
            $file = '/storage/tmp_base64.png';
            list($type, $data) = explode(';', $_POST['base64']);
            list(, $data) = explode(',', $data);
            $data = base64_decode($data);
            $file = $_SERVER['DOCUMENT_ROOT'] . '/storage/tmp_base64.png';
            file_put_contents($file, $data);
            $filename = 'blob.png';
            $is_magic = true;
        } else {
            $file = $_FILES['image']['tmp_name'];
            $filename = $_FILES['image']['name'];
            $is_magic = false;
        }
        $error = false;
        $size = false;
        $is_uploaded = !empty($_POST['base64']) || is_uploaded_file($file);
        if (!$is_uploaded) {
            if ($_GET['lng'] == 'ru') {
                $error = 'Пожалуйста, загружайте файлы не более 2Мб!';
            } else {
                $error = 'Please do not upload files over 2Mb!';
            }
        } else {
            if (!$error && !($size = @getimagesize($file))) {
                if ($_GET['lng'] == 'ru') {
                    $error = 'Ошибка, не верный тип файла';
                } else {
                    $error = 'Error, unsupported type of file';
                }
            } else {
                if (!$error && !in_array($size[2], array(1, 2, 3, 7, 8))) {
                    if ($_GET['lng'] == 'ru') {
                        $error = 'Ошибка типа файла, рекомендуется загружать файлы JPEG';
                    } else {
                        $error = 'Error type of file, recommend upload JPEG files';
                    }
                } else {
                    if (!$error && $size[0] < 5 || $size[1] < 5) {
                        if ($_GET['lng'] == 'ru') {
                            $error = 'Пожалуйста, загружайте картинки размером более 5px.';
                        } else {
                            $error = 'Please upload pictures larger than 5px.';
                        }
                    }
                }
            }
        }
        if ($error) {
            $result['result'] = 'failed';
            $result['error'] = $error;
        } else {
            $ext = strtolower(substr($filename, strrpos($filename, '.') + 1));
            $name = findname($file, $our_folder, $filename, $is_magic);
            $source = $our_folder . '/' . $name . '.' . $ext;
            if (!copy($file, $source)) {
                $result['result'] = 'error';
                if ($_GET['lng'] == 'ru') {
                    $result['error'] = 'Ошибка при копировании файла!';
                } else {
                    $result['error'] = 'Failed to copy a file!';
                }
            } else {
                if (!file_exists($our_folder . '/.thumbs')) {
                    mkdir($our_folder . '/.thumbs');
                }
                $thumb = $our_folder . '/.thumbs/100x100_' . $name . '.' . $ext;
                //$image = new files('tinyimages');
                //$this->Resize($source,$thumb,200,200,'back-ffffff');
                /******************************************************************
                 *****************************************************************
                 **************************************************************
                 *******************************************************************/
                /*>>>>>>>>>>>>>>*/
                //Resize($source,$thumb,$ioptions["w"],$ioptions["h"],'thumb');//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                $result['result'] = 'success';
                $newadress = "/storage";
                $newfilename = $name . '.' . $ext;
                if (isset($_GET['uri'])) {
                    $newadress = $_GET['uri'];
                }
                if ($newadress == "") {
                    $newadress = "/storage";
                }
                $result['filename'] = $newadress . "/" . $newfilename;
                if ($_GET['lng'] == 'ru') {
                    $result['size'] = "Загружено изображение ({$size['mime']}) размером {$size[0]}px/{$size[1]}px.";
                } else {
                    $result['size'] = "Uploaded image ({$size['mime']}) size {$size[0]}px/{$size[1]}px.";
                }
            }
        }
    } else {
        $result['result'] = 'error';
        if ($_GET['lng'] == 'ru') {
            $result['error'] = 'Нет файла или внутренняя ошибка!';
        } else {
            $result['error'] = 'No file or an internal error!';
        }
    }
    /*if (!headers_sent() ) {
    			header('Content-type: application/json');
    		}*/
    foreach ($result as $key => $val) {
        $return[$key] = iconv("windows-1251", "utf-8", $val);
    }
    /*
    header("Content-Type: text/plain; charset=UTF-8");
    echo json_encode($return);
    exit();
    */
    //var_dump($return);
    print '<script>';
    //	print "	alert('<img src=\"".$return['filename']."\" />');";
    print "window.parent.tinyMCE.getInstanceById(document.location.search.substr(1)).execCommand('mceInsertContent',false,'<img src=\"" . $return['filename'] . "\" alt=\"\" />');\n\n";
    //print "document.location.hash = '#".$_POST["inst"]."'";
    print '</script>';
}