PSD-Tutorials.de
Forum für Design, Fotografie & Bildbearbeitung
Tutkit
Agentur
Hilfe
Kontakt
Start
Forum
Aktuelles
Besonderer Inhalt
Foren durchsuchen
Tutorials
News
Anmelden
Kostenlos registrieren
Aktuelles
Suche
Suche
Nur Titel durchsuchen
Von:
Menü
Anmelden
Kostenlos registrieren
App installieren
Installieren
JavaScript ist deaktiviert. Für eine bessere Darstellung aktiviere bitte JavaScript in deinem Browser, bevor du fortfährst.
Du verwendest einen veralteten Browser. Es ist möglich, dass diese oder andere Websites nicht korrekt angezeigt werden.
Du solltest ein Upgrade durchführen oder einen
alternativen Browser
verwenden.
Antworten auf deine Fragen:
Neues Thema erstellen
Start
Forum
Sonstiges
Webdesign, Webentwicklung & Programmierung
PHP, Javascript, jQuery, Ajax, nodeJS, MySQL...
passwortschutz per php
Beitrag
<blockquote data-quote="ackermaennchen" data-source="post: 1934537" data-attributes="member: 4585"><p><strong>AW: passwortschutz per php</strong></p><p></p><p>irgendwie funktioniert das alles nicht so wie ich will.</p><p></p><p>leigt wahrscheinlich dran, dass die url zum eig bild nur über ein ?dateiid ausgegeben wird, und nicht auf die thumb.php?dateiid ausgegeben wird. somit greift er ja auf die index zu die passwortgeschützt ist.</p><p></p><p>So hätte ich jetzt das problem verstanden.</p><p></p><p>Neuer Lösungsansatz ist jetzt beim upload ein passwort abzufragen.</p><p></p><p>Also auf der index.php beim uplaod Formular noch ein passwort eingabe feld hinzufügen.</p><p></p><p>Nur hab ich momentan noch kein plan wie ich das Einbauen muss. Also wie ich das Eingabefeld anlege schon. aber die Abfrage selber mit dem Send/Uplaodbutton zu verknüpfen nicht.</p><p></p><p>Ich weiß als Mod, dass das hier kein "mach mir mal" Forum ist, und das ist auch nicht meine Absicht.</p><p>Aber ich poste euch mal kurz die Codes für die betreffenden dateien. Vieleicht könnt ihr mir da weiterhelfen, an welcher Stelle ich was einsetzen muss.</p><p></p><p>index.php:</p><p></p><p>[PHP]<?php</p><p> require_once('./inc/config.php');</p><p></p><p>// LOAD IMAGE</p><p> loadImage();</p><p></p><p>// DELETE IMAGE</p><p> removeImage();</p><p></p><p>// check to see if we need to open a thumbnail page</p><p> if (isset($_GET['pt'])||isset($_GET['pm'])){</p><p> require('thumbnail.php');// THUMB PAGE</p><p> }</p><p></p><p>// check for errors coming from other pages</p><p> if(isset($_SESSION['err'])){</p><p> $Err = $_SESSION['err'];</p><p> unset($_SESSION['err']);</p><p> }</p><p></p><p>// set any header hooks</p><p> $header_hook = '</p><p> <script type= "text/javascript"></p><p> var max = '.$settings['SET_MAX_UPLOAD'].';</p><p> var extArray = new Array("'.implode('","',$imgFormats).'");</p><p> </script>'."\n\r";</p><p></p><p>// set page name for menu</p><p> $menu = 'home';</p><p>// set page title</p><p> $page_title = ' - '.$settings['SET_SLOGAN'];</p><p></p><p>// 404 page error</p><p> $page_error = '';</p><p> if (isset($_GET['err'])){</p><p> header($errorCode[$_GET['err']][0]); // Send correct HTTP Header</p><p> $page_error = array($errorCode[$_GET['err']][1]);</p><p> }</p><p></p><p>// load header</p><p> include './header.php'; </p><p>// check for any notes</p><p> success_note($Suc);</p><p>// 404 page error</p><p> error_note($page_error); </p><p>// check for any errors</p><p> error_note($Err); </p><p></p><p>//home page (upload) variables</p><p> $homeVar['inactive_files'] = $settings['SET_AUTO_DELETED'] ? sprintf($lang["site_index_auto_deleted"],$settings['SET_AUTO_DELETED_TIME']).'<br />':'';</p><p> $homeVar['hot_linking_limit'] = $settings['SET_MAX_BANDWIDTH']? '<b>'.$lang["site_index_max_bandwidth"].':</b> '.(format_size(1048576*$settings['SET_MAX_BANDWIDTH'])).' '.$lang["site_index_max_bandwidth_per"].($settings['SET_AUTO_DELETED_JUMP'] == 'm' ? $lang["site_index_max_bandwidth_per_month"]:$lang["site_index_max_bandwidth_per_week"]).'<br />':'';</p><p> $homeVar['max_upload'] = $settings['SET_MAX_UPLOAD'] ? '<div class="Upload_Multiple"><span>'.$lang["site_index_max_upload"].' </span><a href="#" class="add_another_file_input"></a><small>('.$lang["site_index_max_upload_max"].' '.$settings['SET_MAX_UPLOAD'].')</small></div>':'';</p><p> $homeVar['hide_tos'] = $settings['SET_HIDE_TOS'] ? '<p>'.sprintf($lang["site_index_tos_des"],'<a href="tos.php" title="'.$lang["site_menu_tos"].'">'.$lang["site_menu_tos"].'</a>').'</p>':'';</p><p> $homeVar['private_img'] = $settings['SET_PRIVATE_IMG_ON']? '<input id="private" name="private[0]" value="1" type="checkbox" /> <label for="private">'.$lang["site_index_private_img"].'</label><br/>':'';</p><p> $homeVar['short_url'] = $settings['SET_SHORT_URL_ON'] ? '<input id="shorturl" name="shorturl[0]" value="1" type="checkbox" /> <label for="shorturl">'.$lang["site_index_short_url"].' '.$settings['SET_SHORT_URL_API'].'</label><br/>':'';</p><p> $homeVar['resize_img'] = $settings['SET_RESIZE_IMG_ON']? '<span class="title">'.$lang["site_index_resize_title"].':</span> <label for="new_height">'.$lang["site_index_resize_height"].'</label> <input type="text" maxlength="4" size="4" class="text_input" id="new_height" name="new_height[]"><br/><label for="new_width">'.$lang["site_index_resize_width"].'</label> <input type="text" maxlength="4" size="4" class="text_input" id="new_width" name="new_width[]"><span class="small">'.$lang["site_index_resize_des"].'</span>':'';</p><p></p><p>?></p><p> <div class="contentBox"></p><p> <div class="<?php /* if($settings['SET_GOOGLE_ADS'] !=''){?> upload_adson<?php }*/ ?>"></p><p> <?php if(!$settings['SET_DIS_UPLOAD']||checklogin()){?></p><p> <p class="teaser"><?php echo $lang["site_index_des"];?></p></p><p> <p class="teaser"></p><p> <?php echo $homeVar['inactive_files'];?></p><p> <?php echo $homeVar['hot_linking_limit'];?></p><p> <b><?php echo $lang["site_index_Image_Formats"];?>:</b> <?PHP echo implode(", ",$imgFormats); ?><br /></p><p> <b><?php echo $lang["site_index_maximum_filesize"];?>:</b> <?php echo format_size($settings['SET_MAXSIZE']);?></p><p> </p></p><p> <form enctype="multipart/form-data" action="upload.php" method="post" class="upform" name="upload" id="upload"></p><p> <div class="upload_op"></p><p> <a id="linklocal" class="linklocal show" title="<?php echo $lang["site_index_local_image_upload_title"];?>"><?php echo $lang["site_index_local_image_upload"];?></a></p><p> <a id="linkremote" class="linkremote" title="<?php echo $lang["site_index_Remote_image_copy_title"];?>"><?php echo $lang["site_index_Remote_image_copy"];?></a></p><p> </div></p><p> <div class="loading"></p><p> <label><?php echo $lang["site_index_uploading_image"];?></label></p><p> <div id="uoloadingImage"></div></p><p> </div></p><p> <div class="input file"></p><p> <a class="closeUpload" href="#" title="Close"> </a></p><p> <div class="upload_form"></p><p> <div id="remote_panel" class="file_url" style="display: none;"></p><p> <label for="imgUrl"><?php echo $lang["site_index_Remote_image"];?></label></p><p> <input type="text" name="imgUrl" id="imgUrl" class="text_input long" /></p><p> </div></p><p> <div id="local_panel" class="file_upload"></p><p> <label for="file"><?php echo $lang["site_index_upload_image"];?>: </label></p><p> <div class="file_input_div"><input type="text" id="fileName" name="fileName[]" class="text_input long" readonly="readonly" /></p><p> <input type="button" value="<?php echo $lang["site_index_upload_browse_button"];?>" name="Search files" class="file_input_button button" /></p><p> <input type="file" name="file[]" id="file" class="file_input_hidden" onchange="javascript: copyfileName()" /></p><p> </div></p><p> </div></p><p> </div></p><p> <label for="alt" class="des"><?php echo $lang["site_index_upload_description"];?></label></p><p> <input type="text" name="alt[]" id="alt" class="text_input long_des" /></p><p></p><p> <?php if($settings['SET_PRIVATE_IMG_ON'] || $settings['SET_SHORT_URL_ON'] || $settings['SET_RESIZE_IMG_ON']){?></p><p> <div class="pref_title"><?php echo $lang["site_index_upload_preferences"];?></div></p><p> <div class="preferences"></p><p> <?php echo $homeVar['private_img'];?></p><p> <?php echo $homeVar['short_url'];?></p><p> <?php echo $homeVar['resize_img'];?></p><p> </div></p><p> <?php } ?></p><p> </div></p><p> <?php echo $homeVar['max_upload'];?></p><p> <input name="submit" type="submit" id="uploadbutton" value="<?php echo $lang["site_index_upload_button"];?>" class="uploadbutton button" onclick="return fileExt(extArray)" /></p><p> <div class="clear_both"></div></p><p> <?php echo $homeVar['hide_tos'];?></p><p> </form></p><p> </div></p><p> <?php /*if($settings['SET_GOOGLE_ADS'] !=''){?></p><p> <div class="ad_index"><?php echo $index_AdSense;?></div></p><p> <div class="ad_index"><?php echo $index_AdSense;?></div></p><p> <?php }*/ ?></p><p> <?php }else{//upload disable?></p><p> <p class="teaser"><b><?php echo $lang["site_index_upload_disable"];?></b></p></p><p> <?php } ?></p><p> </div></p><p><?php</p><p> if(isset($settings['SET_IMAGE_WIDGIT']) && $settings['SET_IMAGE_WIDGIT']){</p><p> ImageWidget($ROW_RANDIMG);</p><p> }</p><p> include './footer.php';[/PHP]</p><p></p><p>upload.php</p><p></p><p>[PHP]<?php</p><p></p><p></p><p> require_once('./inc/config.php');</p><p></p><p> if($settings['SET_DIS_UPLOAD'] && !checklogin()){</p><p> header('Location: index.php');</p><p> exit();</p><p> }</p><p></p><p>// set time out timer to 10mins</p><p> ini_set("max_execution_time", "600");</p><p> ini_set("max_input_time", "600");</p><p></p><p>//unset session</p><p> unset($_SESSION['upload']);</p><p> unset($_SESSION['err']);</p><p></p><p>////////////////////////////////////////////////////////////////////////////////////</p><p>// UPLOAD CODE START</p><p></p><p>// see if user is banned</p><p> if (db_isBanned()){</p><p> sendError($lang["site_upload_banned"]);</p><p> }</p><p></p><p>// see if a image url has been posted</p><p> if((isset($_POST['imgUrl']) && !empty($_POST['imgUrl'])) || isset($imgApiUrl)){</p><p> $image['URL'] = input(isset($_POST['imgUrl'])?$_POST['imgUrl']:$imgApiUrl);</p><p> require_once("lib/remoteImage.class.php");</p><p> $remoteImage = new remoteImages($DIR_TEMP,$settings,$lang);</p><p> $remoteImage->validExtensions = $imgFormats;</p><p> $remoteImage->validType = $acceptedFormats;</p><p> $remoteImage->minDimensions = $IMG_MIN_SIZE;</p><p> $remoteImage->maxDimensions = $IMG_MAX_SIZE;</p><p></p><p> if($remoteImage->getImage($image['URL'])){</p><p> //check that a file has been found and copyed to the temp dir</p><p> if(!is_null($remoteImage->file)){</p><p> $_FILES = $remoteImage->file;</p><p> }</p><p> }else{</p><p> sendError($remoteImage->error);</p><p> }</p><p> }</p><p></p><p> if( ($_SERVER['REQUEST_METHOD'] == 'POST' ||</p><p> isset($api)) &&</p><p> $_FILES['file']['name'][0] !='' && </p><p> !isset($_SESSION['err'])){</p><p></p><p> require_once("./lib/resize.class.php");</p><p> require_once("./lib/dupeimage.class.php");</p><p></p><p> $imgCount = 0;</p><p></p><p> for($i=0; $i < count($_FILES['file']['name']);++$i){</p><p> </p><p> // setup image var</p><p> $pieces = explode("?", $_FILES['file']['name'][$i]);</p><p> $pathInfo = pathinfo($_FILES['file']['name'][$i]);</p><p> $imgSize = @getimagesize($_FILES['file']['tmp_name'][$i]);</p><p></p><p> $image['name'] = $pieces[0];</p><p> $image['alt'] = removeSymbols(input(!empty($_POST["alt"][$i])?$_POST["alt"][$i]:$pathInfo['filename']));</p><p> $image['temp'] = $_FILES['file']['tmp_name'][$i];</p><p> $image['type'] = $imgSize['mime'];</p><p> $image['size'] = ($_FILES['file']['size'][$i] < 1?@filesize($image['temp']):$_FILES['file']['size'][$i]);</p><p> $removeList[] = $image['temp'];</p><p></p><p> //check it's a image & set image extension</p><p> if(!$image['ext'] = get_extension( $image['type'], false )){</p><p> sendError(sprintf('<b>'.$image['name'].'</b> '.$lang["site_upload_types_accepted"],implode(", ",$imgFormats)),'extension');</p><p> continue;</p><p> }</p><p></p><p> //min size(pixels)</p><p> if ($imgSize[0] < $IMG_MIN_SIZE || $imgSize[1] < $IMG_MIN_SIZE ){</p><p> sendError(sprintf('<b>'.$image['name'].'</b> '.$lang["site_upload_to_small"],$IMG_MIN_SIZE.'x'.$IMG_MIN_SIZE),'tosmall');</p><p> continue;</p><p> }</p><p></p><p> // max size(pixels)</p><p> if ($imgSize[0] > $IMG_MAX_SIZE || $imgSize[1] > $IMG_MAX_SIZE ){</p><p> sendError(sprintf('<b>'.$image['name'].'</b> '.$lang["site_upload_to_big"],$IMG_MAX_SIZE.'x'.$IMG_MAX_SIZE));</p><p> continue;</p><p> }</p><p></p><p> //Check file size (kb)</p><p> if($image['size'] > $settings['SET_MAXSIZE']){</p><p> sendError(sprintf('<b>'.$image['name'].'</b> '.$lang["site_upload_size_accepted"],format_size($settings['SET_MAXSIZE'])),'tobig');</p><p> continue;</p><p> }</p><p></p><p> //Make Image fingerprint</p><p> $finger = new phpDupeImage();</p><p> $fingerprint = $finger->fingerprint($image['temp']);</p><p></p><p> //check for Duplicate Images</p><p> if($settings['SET_NODUPLICATE']){</p><p> // If similar files exist, check them</p><p> if($fp=findImage('fingerprint',$fingerprint)){</p><p> foreach($fp as $fpItem){</p><p> if ($finger->are_duplicates($image['temp'],imageAddress(1,$fpItem))){</p><p> $dupFound = true;</p><p> break;</p><p> }</p><p> }</p><p> if(isset($dupFound)){</p><p> sendError('<b>'.$image['name'].'</b> '.$lang["upload_duplicate_found"],'duplicate');</p><p> continue;</p><p> }</p><p> }</p><p> }</p><p></p><p> //New random name</p><p> //Number of Possible Combinations</p><p> // 3 digit code 46656</p><p> // 4 digit code 1679616</p><p> // 5 digit code 60466176</p><p> $image['id'] = createHash(4,true);</p><p></p><p> //random delete ID</p><p> $image['did'] = $image['id'].createHash(6);</p><p></p><p> //Image address</p><p> $image['new'] = $image['id'].'.'.$image['ext'];</p><p> $image['address'] = $DIR_IMAGE.$image['new'];</p><p></p><p> // convert BMP to JPG and PSD to PNG</p><p> if(in_array($image['ext'],array('psd','bmp'))){</p><p> //Reset Image address</p><p> $image['ext'] = ($image['ext'] == 'psd'?$PNG_SAVE_EXT:$JPG_SAVE_EXT);</p><p> $image['new'] = $image['id'].'.'.$image['ext'];</p><p> $image['address'] = $DIR_IMAGE.$image['new'];</p><p> // convert psd/bmp to png</p><p> $convert = new resize($image['temp']);</p><p> $convert->imageConvert($image['address'],($image['ext'] == 'psd'?$PNG_QUALITY:$JPG_QUALITY));</p><p> $convert->destroyImage();</p><p> }</p><p> </p><p> //move image from remote server</p><p> elseif(isset($image['URL']) && input($image['URL']) != ''){</p><p> @copy($image['temp'],$image['address']);</p><p> }</p><p> </p><p> //move uploaded image</p><p> else{</p><p> move_uploaded_file($image['temp'],$image['address']);</p><p> }</p><p></p><p> // move file check</p><p> if(!file_exists($image['address'])){</p><p> sendError('<b>'.$image['name'].'</b> '.$lang["site_upload_err"].' .','filemove');</p><p> continue;</p><p> }</p><p></p><p> //Resize image if needed</p><p> if ($settings['SET_RESIZE_IMG_ON']) {</p><p></p><p> if((isset($_POST['new_width'][$i]) && !empty($_POST['new_width'][$i])) ||</p><p> (isset($_POST['new_height'][$i]) && !empty($_POST['new_height'][$i]))){</p><p></p><p> $new_dim = new resize($image['address']);</p><p> $new_dim -> stretchSmallImages(TRUE);</p><p></p><p> if(!empty($_POST['new_width'][$i]) && !empty($_POST['new_height'][$i])){</p><p> $new_dim -> resizeImage($_POST['new_width'][$i], $_POST['new_height'][$i], 'exact');</p><p> }</p><p> elseif(!empty($_POST['new_width'][$i]) && empty($_POST['new_height'][$i])){</p><p> $new_dim -> resizeImage($_POST['new_width'][$i], $imgSize[0], 'landscape');</p><p> }</p><p> elseif(empty($_POST['new_width'][$i]) && !empty($_POST['new_height'][$i])){</p><p> $new_dim -> resizeImage($imgSize[1], $_POST['new_height'][$i], 'portrait');</p><p> }</p><p></p><p> $new_dim -> saveImage($image['address'],100);</p><p> $new_dim -> destroyImage();</p><p> $imgSize = @getimagesize($image['address']);// update image size for db</p><p> }</p><p> }</p><p></p><p></p><p> //Thumb address</p><p> $THUMB_ADDRESS = $DIR_THUMB.$image['new'];</p><p> $THUMB_MID_ADDRESS = $DIR_THUMB_MID.$image['new'];</p><p></p><p> // thumb</p><p> $resize = new resize($image['address']);</p><p> $resize ->setMemoryLimit ($IMG_MEMORY_LIMIT);</p><p> $resize ->setTweakFactor ($IMG_TWEAK_FACTOR);</p><p> // make thumb</p><p> $resize -> resizeImage($THUMB_MID_MAX_WIDTH, $THUMB_MID_MAX_HEIGHT, $THUMB_MID_OPTION);</p><p> $resize -> saveImage($THUMB_MID_ADDRESS, ($image['ext'] == 'png'?$PNG_QUALITY:$JPG_QUALITY));</p><p> // make small thumb</p><p> $resize -> resizeImage($THUMB_MAX_WIDTH, $THUMB_MAX_HEIGHT, $THUMB_OPTION);</p><p> $resize -> saveImage($THUMB_ADDRESS, ($image['ext'] == 'png'?$PNG_QUALITY:$JPG_QUALITY));</p><p> $resize -> destroyImage();</p><p></p><p> //see if thumb's got made</p><p> if(!file_exists($THUMB_ADDRESS) || !file_exists($THUMB_MID_ADDRESS)){</p><p> @unlink($image['address']);</p><p> @unlink($THUMB_ADDRESS);</p><p> @unlink($THUMB_MID_ADDRESS);</p><p> sendError('<b>'.$image['name'].'</b> '.$lang["site_upload_err"].' ..','thumbmade');</p><p> continue;</p><p> }</p><p></p><p> // see if we need to get a short url for the image</p><p> $shorturl = null;</p><p> if (isset($_POST['shorturl'][$i]) && $_POST['shorturl'][$i] == 1 && $settings['SET_SHORT_URL_ON']){</p><p> $shorturl = shorturl_url('http://'.$_SERVER['HTTP_HOST'].preg_replace('/\/([^\/]+?)$/', '/', $_SERVER['PHP_SELF']).'?di='.$image['id']);</p><p> }</p><p></p><p> // get thumb's file size</p><p> $image['size'] = @filesize($image['address']);</p><p> $thumbsize = @filesize($THUMB_MID_ADDRESS);</p><p> $sthumbsize = @filesize($THUMB_ADDRESS);</p><p></p><p> // Make image info array to save to db</p><p> $newImageArray = array( 'id' => $image['id'],</p><p> 'name' => $image['name'],</p><p> 'alt' => $image['alt'],</p><p> 'added' => time(),</p><p> 'ext' => $image['ext'],</p><p> 'ip' => $_SERVER['REMOTE_ADDR'],</p><p> 'size' => $image['size'],</p><p> 'deleteid' => $image['did'],</p><p> 'thumbsize' => $thumbsize,</p><p> 'sthumbsize'=> $sthumbsize,</p><p> 'private' => (isset($_POST['private'][$i])?1:0),</p><p> 'report' => 0,</p><p> 'shorturl' => $shorturl,</p><p> 'fingerprint' =>$fingerprint,</p><p> );</p><p></p><p> //save new image to database</p><p> if(addNewImage($newImageArray)){</p><p></p><p> // save image to upload array to be sent to thumb page</p><p> $_SESSION['upload'][] = array('id' => $image['id'],'did' => $image['did']);</p><p></p><p> // count images uploaded</p><p> $imgCount++;</p><p> if($imgCount >= $settings['SET_MAX_UPLOAD'] && !checklogin()){</p><p> break; // break upload loop as you have updated max number of images in one go...</p><p> }</p><p></p><p> }else{</p><p> sendError('<b>'.$image['name'].'</b> '.$lang["site_index_delete_image_err_db"],'savedb');</p><p> continue;</p><p> }</p><p> }// end image upload loop</p><p> }</p><p>// error uploading image</p><p> elseif(!isset($_SESSION['err'])){</p><p> sendError($lang["site_upload_err"].' ...','uk');</p><p> }</p><p></p><p>// remove temp images</p><p> if(isset($removeList)){</p><p> foreach ($removeList as $tempImg){</p><p> // remove old file</p><p> if(file_exists($tempImg)){</p><p> unlink($tempImg);</p><p> }</p><p> }</p><p> }</p><p></p><p>// UPLOAD CODE END</p><p>////////////////////////////////////////////////////////////////////////////////////</p><p>////////////////////////////////////////////////////////////////////////////////////</p><p>// MAKE PAGE</p><p></p><p>// admin bulk uploader </p><p> if(isset($admin_upload)){</p><p> header('Location: '. $settings['SET_SITEURL'].'/admin.php?act=bulk');</p><p> exit();</p><p> }</p><p></p><p>// error send back to home page and show the error</p><p> if(!isset($_SESSION['upload'])){</p><p> header('Location: '. $settings['SET_SITEURL'].'/index.php');</p><p> exit();</p><p> }</p><p></p><p>// open thumb page and show upload images</p><p> header('Location: '. $settings['SET_SITEURL'].'/thumbnail.php');</p><p> die();</p><p></p><p></p><p>// MAKE PAGE END</p><p>////////////////////////////////////////////////////////////////////////////////////</p><p>////////////////////////////////////////////////////////////////////////////////////</p><p>// functions</p><p></p><p>// send error back to index page</p><p> function sendError($msg,$id=''){</p><p> if(isset($_SESSION['err'][$id])) $id = $id.'_'.time();</p><p> $_SESSION['err'][$id] = $msg;</p><p> }</p><p></p><p>// get file ext from mine</p><p> function get_extension($imagetype, $includeDot = false){</p><p> global $acceptedFormats;</p><p> if(empty($imagetype)) return false;</p><p> $dot = $includeDot ? '.' : '';</p><p> if(isset($acceptedFormats[$imagetype])){</p><p> return $dot.$acceptedFormats[$imagetype];</p><p> }</p><p> return false;</p><p> }</p><p></p><p></p><p>// very simple hash function to generate a random string</p><p> function createHash($length=5,$check=null){</p><p> $valid = 0;</p><p> $hash = '';</p><p> while(!$valid){</p><p> for($i=0;$i<$length;++$i){</p><p> // if you want to add letters you will have to change the id to varchar instead of int</p><p> $possibleValues = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";</p><p> // pick a random character from the possible ones</p><p> $hash .= substr($possibleValues, mt_rand(0, strlen($possibleValues)-1), 1);</p><p> }</p><p> // checks if the hash allready exists in the db</p><p> if(is_null($check) || !getImage($hash)){</p><p> $valid = 1;</p><p> }</p><p> }</p><p> return $hash;</p><p> }[/PHP]</p><p></p><p>Ich wäre euch sehr dankbar wenn ihr mir da helfen könnet.</p><p></p><p>Gruß</p><p></p><p>Enrico</p></blockquote><p></p>
[QUOTE="ackermaennchen, post: 1934537, member: 4585"] [b]AW: passwortschutz per php[/b] irgendwie funktioniert das alles nicht so wie ich will. leigt wahrscheinlich dran, dass die url zum eig bild nur über ein ?dateiid ausgegeben wird, und nicht auf die thumb.php?dateiid ausgegeben wird. somit greift er ja auf die index zu die passwortgeschützt ist. So hätte ich jetzt das problem verstanden. Neuer Lösungsansatz ist jetzt beim upload ein passwort abzufragen. Also auf der index.php beim uplaod Formular noch ein passwort eingabe feld hinzufügen. Nur hab ich momentan noch kein plan wie ich das Einbauen muss. Also wie ich das Eingabefeld anlege schon. aber die Abfrage selber mit dem Send/Uplaodbutton zu verknüpfen nicht. Ich weiß als Mod, dass das hier kein "mach mir mal" Forum ist, und das ist auch nicht meine Absicht. Aber ich poste euch mal kurz die Codes für die betreffenden dateien. Vieleicht könnt ihr mir da weiterhelfen, an welcher Stelle ich was einsetzen muss. index.php: [PHP]<?php require_once('./inc/config.php'); // LOAD IMAGE loadImage(); // DELETE IMAGE removeImage(); // check to see if we need to open a thumbnail page if (isset($_GET['pt'])||isset($_GET['pm'])){ require('thumbnail.php');// THUMB PAGE } // check for errors coming from other pages if(isset($_SESSION['err'])){ $Err = $_SESSION['err']; unset($_SESSION['err']); } // set any header hooks $header_hook = ' <script type= "text/javascript"> var max = '.$settings['SET_MAX_UPLOAD'].'; var extArray = new Array("'.implode('","',$imgFormats).'"); </script>'."\n\r"; // set page name for menu $menu = 'home'; // set page title $page_title = ' - '.$settings['SET_SLOGAN']; // 404 page error $page_error = ''; if (isset($_GET['err'])){ header($errorCode[$_GET['err']][0]); // Send correct HTTP Header $page_error = array($errorCode[$_GET['err']][1]); } // load header include './header.php'; // check for any notes success_note($Suc); // 404 page error error_note($page_error); // check for any errors error_note($Err); //home page (upload) variables $homeVar['inactive_files'] = $settings['SET_AUTO_DELETED'] ? sprintf($lang["site_index_auto_deleted"],$settings['SET_AUTO_DELETED_TIME']).'<br />':''; $homeVar['hot_linking_limit'] = $settings['SET_MAX_BANDWIDTH']? '<b>'.$lang["site_index_max_bandwidth"].':</b> '.(format_size(1048576*$settings['SET_MAX_BANDWIDTH'])).' '.$lang["site_index_max_bandwidth_per"].($settings['SET_AUTO_DELETED_JUMP'] == 'm' ? $lang["site_index_max_bandwidth_per_month"]:$lang["site_index_max_bandwidth_per_week"]).'<br />':''; $homeVar['max_upload'] = $settings['SET_MAX_UPLOAD'] ? '<div class="Upload_Multiple"><span>'.$lang["site_index_max_upload"].' </span><a href="#" class="add_another_file_input"></a><small>('.$lang["site_index_max_upload_max"].' '.$settings['SET_MAX_UPLOAD'].')</small></div>':''; $homeVar['hide_tos'] = $settings['SET_HIDE_TOS'] ? '<p>'.sprintf($lang["site_index_tos_des"],'<a href="tos.php" title="'.$lang["site_menu_tos"].'">'.$lang["site_menu_tos"].'</a>').'</p>':''; $homeVar['private_img'] = $settings['SET_PRIVATE_IMG_ON']? '<input id="private" name="private[0]" value="1" type="checkbox" /> <label for="private">'.$lang["site_index_private_img"].'</label><br/>':''; $homeVar['short_url'] = $settings['SET_SHORT_URL_ON'] ? '<input id="shorturl" name="shorturl[0]" value="1" type="checkbox" /> <label for="shorturl">'.$lang["site_index_short_url"].' '.$settings['SET_SHORT_URL_API'].'</label><br/>':''; $homeVar['resize_img'] = $settings['SET_RESIZE_IMG_ON']? '<span class="title">'.$lang["site_index_resize_title"].':</span> <label for="new_height">'.$lang["site_index_resize_height"].'</label> <input type="text" maxlength="4" size="4" class="text_input" id="new_height" name="new_height[]"><br/><label for="new_width">'.$lang["site_index_resize_width"].'</label> <input type="text" maxlength="4" size="4" class="text_input" id="new_width" name="new_width[]"><span class="small">'.$lang["site_index_resize_des"].'</span>':''; ?> <div class="contentBox"> <div class="<?php /* if($settings['SET_GOOGLE_ADS'] !=''){?> upload_adson<?php }*/ ?>"> <?php if(!$settings['SET_DIS_UPLOAD']||checklogin()){?> <p class="teaser"><?php echo $lang["site_index_des"];?></p> <p class="teaser"> <?php echo $homeVar['inactive_files'];?> <?php echo $homeVar['hot_linking_limit'];?> <b><?php echo $lang["site_index_Image_Formats"];?>:</b> <?PHP echo implode(", ",$imgFormats); ?><br /> <b><?php echo $lang["site_index_maximum_filesize"];?>:</b> <?php echo format_size($settings['SET_MAXSIZE']);?> </p> <form enctype="multipart/form-data" action="upload.php" method="post" class="upform" name="upload" id="upload"> <div class="upload_op"> <a id="linklocal" class="linklocal show" title="<?php echo $lang["site_index_local_image_upload_title"];?>"><?php echo $lang["site_index_local_image_upload"];?></a> <a id="linkremote" class="linkremote" title="<?php echo $lang["site_index_Remote_image_copy_title"];?>"><?php echo $lang["site_index_Remote_image_copy"];?></a> </div> <div class="loading"> <label><?php echo $lang["site_index_uploading_image"];?></label> <div id="uoloadingImage"></div> </div> <div class="input file"> <a class="closeUpload" href="#" title="Close"> </a> <div class="upload_form"> <div id="remote_panel" class="file_url" style="display: none;"> <label for="imgUrl"><?php echo $lang["site_index_Remote_image"];?></label> <input type="text" name="imgUrl" id="imgUrl" class="text_input long" /> </div> <div id="local_panel" class="file_upload"> <label for="file"><?php echo $lang["site_index_upload_image"];?>: </label> <div class="file_input_div"><input type="text" id="fileName" name="fileName[]" class="text_input long" readonly="readonly" /> <input type="button" value="<?php echo $lang["site_index_upload_browse_button"];?>" name="Search files" class="file_input_button button" /> <input type="file" name="file[]" id="file" class="file_input_hidden" onchange="javascript: copyfileName()" /> </div> </div> </div> <label for="alt" class="des"><?php echo $lang["site_index_upload_description"];?></label> <input type="text" name="alt[]" id="alt" class="text_input long_des" /> <?php if($settings['SET_PRIVATE_IMG_ON'] || $settings['SET_SHORT_URL_ON'] || $settings['SET_RESIZE_IMG_ON']){?> <div class="pref_title"><?php echo $lang["site_index_upload_preferences"];?></div> <div class="preferences"> <?php echo $homeVar['private_img'];?> <?php echo $homeVar['short_url'];?> <?php echo $homeVar['resize_img'];?> </div> <?php } ?> </div> <?php echo $homeVar['max_upload'];?> <input name="submit" type="submit" id="uploadbutton" value="<?php echo $lang["site_index_upload_button"];?>" class="uploadbutton button" onclick="return fileExt(extArray)" /> <div class="clear_both"></div> <?php echo $homeVar['hide_tos'];?> </form> </div> <?php /*if($settings['SET_GOOGLE_ADS'] !=''){?> <div class="ad_index"><?php echo $index_AdSense;?></div> <div class="ad_index"><?php echo $index_AdSense;?></div> <?php }*/ ?> <?php }else{//upload disable?> <p class="teaser"><b><?php echo $lang["site_index_upload_disable"];?></b></p> <?php } ?> </div> <?php if(isset($settings['SET_IMAGE_WIDGIT']) && $settings['SET_IMAGE_WIDGIT']){ ImageWidget($ROW_RANDIMG); } include './footer.php';[/PHP] upload.php [PHP]<?php require_once('./inc/config.php'); if($settings['SET_DIS_UPLOAD'] && !checklogin()){ header('Location: index.php'); exit(); } // set time out timer to 10mins ini_set("max_execution_time", "600"); ini_set("max_input_time", "600"); //unset session unset($_SESSION['upload']); unset($_SESSION['err']); //////////////////////////////////////////////////////////////////////////////////// // UPLOAD CODE START // see if user is banned if (db_isBanned()){ sendError($lang["site_upload_banned"]); } // see if a image url has been posted if((isset($_POST['imgUrl']) && !empty($_POST['imgUrl'])) || isset($imgApiUrl)){ $image['URL'] = input(isset($_POST['imgUrl'])?$_POST['imgUrl']:$imgApiUrl); require_once("lib/remoteImage.class.php"); $remoteImage = new remoteImages($DIR_TEMP,$settings,$lang); $remoteImage->validExtensions = $imgFormats; $remoteImage->validType = $acceptedFormats; $remoteImage->minDimensions = $IMG_MIN_SIZE; $remoteImage->maxDimensions = $IMG_MAX_SIZE; if($remoteImage->getImage($image['URL'])){ //check that a file has been found and copyed to the temp dir if(!is_null($remoteImage->file)){ $_FILES = $remoteImage->file; } }else{ sendError($remoteImage->error); } } if( ($_SERVER['REQUEST_METHOD'] == 'POST' || isset($api)) && $_FILES['file']['name'][0] !='' && !isset($_SESSION['err'])){ require_once("./lib/resize.class.php"); require_once("./lib/dupeimage.class.php"); $imgCount = 0; for($i=0; $i < count($_FILES['file']['name']);++$i){ // setup image var $pieces = explode("?", $_FILES['file']['name'][$i]); $pathInfo = pathinfo($_FILES['file']['name'][$i]); $imgSize = @getimagesize($_FILES['file']['tmp_name'][$i]); $image['name'] = $pieces[0]; $image['alt'] = removeSymbols(input(!empty($_POST["alt"][$i])?$_POST["alt"][$i]:$pathInfo['filename'])); $image['temp'] = $_FILES['file']['tmp_name'][$i]; $image['type'] = $imgSize['mime']; $image['size'] = ($_FILES['file']['size'][$i] < 1?@filesize($image['temp']):$_FILES['file']['size'][$i]); $removeList[] = $image['temp']; //check it's a image & set image extension if(!$image['ext'] = get_extension( $image['type'], false )){ sendError(sprintf('<b>'.$image['name'].'</b> '.$lang["site_upload_types_accepted"],implode(", ",$imgFormats)),'extension'); continue; } //min size(pixels) if ($imgSize[0] < $IMG_MIN_SIZE || $imgSize[1] < $IMG_MIN_SIZE ){ sendError(sprintf('<b>'.$image['name'].'</b> '.$lang["site_upload_to_small"],$IMG_MIN_SIZE.'x'.$IMG_MIN_SIZE),'tosmall'); continue; } // max size(pixels) if ($imgSize[0] > $IMG_MAX_SIZE || $imgSize[1] > $IMG_MAX_SIZE ){ sendError(sprintf('<b>'.$image['name'].'</b> '.$lang["site_upload_to_big"],$IMG_MAX_SIZE.'x'.$IMG_MAX_SIZE)); continue; } //Check file size (kb) if($image['size'] > $settings['SET_MAXSIZE']){ sendError(sprintf('<b>'.$image['name'].'</b> '.$lang["site_upload_size_accepted"],format_size($settings['SET_MAXSIZE'])),'tobig'); continue; } //Make Image fingerprint $finger = new phpDupeImage(); $fingerprint = $finger->fingerprint($image['temp']); //check for Duplicate Images if($settings['SET_NODUPLICATE']){ // If similar files exist, check them if($fp=findImage('fingerprint',$fingerprint)){ foreach($fp as $fpItem){ if ($finger->are_duplicates($image['temp'],imageAddress(1,$fpItem))){ $dupFound = true; break; } } if(isset($dupFound)){ sendError('<b>'.$image['name'].'</b> '.$lang["upload_duplicate_found"],'duplicate'); continue; } } } //New random name //Number of Possible Combinations // 3 digit code 46656 // 4 digit code 1679616 // 5 digit code 60466176 $image['id'] = createHash(4,true); //random delete ID $image['did'] = $image['id'].createHash(6); //Image address $image['new'] = $image['id'].'.'.$image['ext']; $image['address'] = $DIR_IMAGE.$image['new']; // convert BMP to JPG and PSD to PNG if(in_array($image['ext'],array('psd','bmp'))){ //Reset Image address $image['ext'] = ($image['ext'] == 'psd'?$PNG_SAVE_EXT:$JPG_SAVE_EXT); $image['new'] = $image['id'].'.'.$image['ext']; $image['address'] = $DIR_IMAGE.$image['new']; // convert psd/bmp to png $convert = new resize($image['temp']); $convert->imageConvert($image['address'],($image['ext'] == 'psd'?$PNG_QUALITY:$JPG_QUALITY)); $convert->destroyImage(); } //move image from remote server elseif(isset($image['URL']) && input($image['URL']) != ''){ @copy($image['temp'],$image['address']); } //move uploaded image else{ move_uploaded_file($image['temp'],$image['address']); } // move file check if(!file_exists($image['address'])){ sendError('<b>'.$image['name'].'</b> '.$lang["site_upload_err"].' .','filemove'); continue; } //Resize image if needed if ($settings['SET_RESIZE_IMG_ON']) { if((isset($_POST['new_width'][$i]) && !empty($_POST['new_width'][$i])) || (isset($_POST['new_height'][$i]) && !empty($_POST['new_height'][$i]))){ $new_dim = new resize($image['address']); $new_dim -> stretchSmallImages(TRUE); if(!empty($_POST['new_width'][$i]) && !empty($_POST['new_height'][$i])){ $new_dim -> resizeImage($_POST['new_width'][$i], $_POST['new_height'][$i], 'exact'); } elseif(!empty($_POST['new_width'][$i]) && empty($_POST['new_height'][$i])){ $new_dim -> resizeImage($_POST['new_width'][$i], $imgSize[0], 'landscape'); } elseif(empty($_POST['new_width'][$i]) && !empty($_POST['new_height'][$i])){ $new_dim -> resizeImage($imgSize[1], $_POST['new_height'][$i], 'portrait'); } $new_dim -> saveImage($image['address'],100); $new_dim -> destroyImage(); $imgSize = @getimagesize($image['address']);// update image size for db } } //Thumb address $THUMB_ADDRESS = $DIR_THUMB.$image['new']; $THUMB_MID_ADDRESS = $DIR_THUMB_MID.$image['new']; // thumb $resize = new resize($image['address']); $resize ->setMemoryLimit ($IMG_MEMORY_LIMIT); $resize ->setTweakFactor ($IMG_TWEAK_FACTOR); // make thumb $resize -> resizeImage($THUMB_MID_MAX_WIDTH, $THUMB_MID_MAX_HEIGHT, $THUMB_MID_OPTION); $resize -> saveImage($THUMB_MID_ADDRESS, ($image['ext'] == 'png'?$PNG_QUALITY:$JPG_QUALITY)); // make small thumb $resize -> resizeImage($THUMB_MAX_WIDTH, $THUMB_MAX_HEIGHT, $THUMB_OPTION); $resize -> saveImage($THUMB_ADDRESS, ($image['ext'] == 'png'?$PNG_QUALITY:$JPG_QUALITY)); $resize -> destroyImage(); //see if thumb's got made if(!file_exists($THUMB_ADDRESS) || !file_exists($THUMB_MID_ADDRESS)){ @unlink($image['address']); @unlink($THUMB_ADDRESS); @unlink($THUMB_MID_ADDRESS); sendError('<b>'.$image['name'].'</b> '.$lang["site_upload_err"].' ..','thumbmade'); continue; } // see if we need to get a short url for the image $shorturl = null; if (isset($_POST['shorturl'][$i]) && $_POST['shorturl'][$i] == 1 && $settings['SET_SHORT_URL_ON']){ $shorturl = shorturl_url('http://'.$_SERVER['HTTP_HOST'].preg_replace('/\/([^\/]+?)$/', '/', $_SERVER['PHP_SELF']).'?di='.$image['id']); } // get thumb's file size $image['size'] = @filesize($image['address']); $thumbsize = @filesize($THUMB_MID_ADDRESS); $sthumbsize = @filesize($THUMB_ADDRESS); // Make image info array to save to db $newImageArray = array( 'id' => $image['id'], 'name' => $image['name'], 'alt' => $image['alt'], 'added' => time(), 'ext' => $image['ext'], 'ip' => $_SERVER['REMOTE_ADDR'], 'size' => $image['size'], 'deleteid' => $image['did'], 'thumbsize' => $thumbsize, 'sthumbsize'=> $sthumbsize, 'private' => (isset($_POST['private'][$i])?1:0), 'report' => 0, 'shorturl' => $shorturl, 'fingerprint' =>$fingerprint, ); //save new image to database if(addNewImage($newImageArray)){ // save image to upload array to be sent to thumb page $_SESSION['upload'][] = array('id' => $image['id'],'did' => $image['did']); // count images uploaded $imgCount++; if($imgCount >= $settings['SET_MAX_UPLOAD'] && !checklogin()){ break; // break upload loop as you have updated max number of images in one go... } }else{ sendError('<b>'.$image['name'].'</b> '.$lang["site_index_delete_image_err_db"],'savedb'); continue; } }// end image upload loop } // error uploading image elseif(!isset($_SESSION['err'])){ sendError($lang["site_upload_err"].' ...','uk'); } // remove temp images if(isset($removeList)){ foreach ($removeList as $tempImg){ // remove old file if(file_exists($tempImg)){ unlink($tempImg); } } } // UPLOAD CODE END //////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////// // MAKE PAGE // admin bulk uploader if(isset($admin_upload)){ header('Location: '. $settings['SET_SITEURL'].'/admin.php?act=bulk'); exit(); } // error send back to home page and show the error if(!isset($_SESSION['upload'])){ header('Location: '. $settings['SET_SITEURL'].'/index.php'); exit(); } // open thumb page and show upload images header('Location: '. $settings['SET_SITEURL'].'/thumbnail.php'); die(); // MAKE PAGE END //////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////// // functions // send error back to index page function sendError($msg,$id=''){ if(isset($_SESSION['err'][$id])) $id = $id.'_'.time(); $_SESSION['err'][$id] = $msg; } // get file ext from mine function get_extension($imagetype, $includeDot = false){ global $acceptedFormats; if(empty($imagetype)) return false; $dot = $includeDot ? '.' : ''; if(isset($acceptedFormats[$imagetype])){ return $dot.$acceptedFormats[$imagetype]; } return false; } // very simple hash function to generate a random string function createHash($length=5,$check=null){ $valid = 0; $hash = ''; while(!$valid){ for($i=0;$i<$length;++$i){ // if you want to add letters you will have to change the id to varchar instead of int $possibleValues = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; // pick a random character from the possible ones $hash .= substr($possibleValues, mt_rand(0, strlen($possibleValues)-1), 1); } // checks if the hash allready exists in the db if(is_null($check) || !getImage($hash)){ $valid = 1; } } return $hash; }[/PHP] Ich wäre euch sehr dankbar wenn ihr mir da helfen könnet. Gruß Enrico [/QUOTE]
Bilder bitte
hier hochladen
und danach über das Bild-Icon (Direktlink vorher kopieren) platzieren.
Zitate einfügen…
Authentifizierung
Wenn ▲ = 5, ▼ = 2 und ■ = 7, was ist ▲ × ▼ + ■?
Antworten
Start
Forum
Sonstiges
Webdesign, Webentwicklung & Programmierung
PHP, Javascript, jQuery, Ajax, nodeJS, MySQL...
passwortschutz per php
Oben