Jump to content

Kleidi

Members
  • Posts

    30
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Kleidi's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hello, I have a simple image multi uploader that uploads images on the folder correctly but i don't know how to get the image names and insert them in the db. The uploader is part of a complex form for adding an article informations (id, name, permanenturl, section, etc) that works correctly. Image fields in db has names as follows: img1 img2 img3 img4 im5, a field for each image (since i thought that this is the best way to add the images on the article). The upload sections looks like this: <?php /** * Smart Image Uploader by @cafewebmaster.com * Free for private use * Please support us with donations or backlink */ $upload_image_limit = 5; // How many images you want to upload at once? $upload_dir = "/var/www/tour/te-ngarkuara/oferta/"; // default script location, use relative or absolute path ################################# UPLOAD IMAGES foreach($_FILES as $k => $v){ $img_type = ""; ### $htmo .= "$k => $v<hr />"; ### print_r($_FILES); if( !$_FILES[$k]['error'] && preg_match("#^image/#i", $_FILES[$k]['type']) && $_FILES[$k]['size'] < 1000000){ $img_type = ($_FILES[$k]['type'] == "image/jpeg") ? ".jpg" : $img_type ; $img_type = ($_FILES[$k]['type'] == "image/gif") ? ".gif" : $img_type ; $img_type = ($_FILES[$k]['type'] == "image/png") ? ".png" : $img_type ; $data = (date("jnHi")); // Merr daten dhe oren ne momentin e shtimit te fotografise $img_rname = $data."-".$_FILES[$k]['name']; // shton daten dhe oren perpara emrit te fotografise per te krijuar emer unik $img_rname = str_replace(" ","-",$img_rname); // Heq hapesirat dhe i zevendeso me - $img_path = $upload_dir.$img_rname; copy( $_FILES[$k]['tmp_name'], $img_path ); chmod("$img_path",0777); $feedback .= "Image and thumbnail created $img_rname<br />"; } } ############################### HTML FORM while($i++ < $upload_image_limit){ $form_img .= '<label>Image '.$i.': </label> <input type="file" name="uplimg'.$i.'"><br />'; } $htmo .= ' <p>'.$feedback.'</p> <form method="post" enctype="multipart/form-data"> '.$form_img.' <br /> <input type="submit" value="Upload Images!" style="margin-left: 50px;" /> </form> '; echo $htmo; Can anyone help me on this, please? Thank you in advance!
  2. This solution helped me too, but, what about text that does not come from db but from the php/html file? After i applied the solution you suggested, was resolved the apparition of non-latin letters that comes from the db but not the letter that comes from the file. Thank you!
  3. Hello there! I'm looking for a script that generates website screenshots. I want to use a script on my server bcz, i think, it will work faster than use services like webshotspro.com or any other, and have no restriction on size. I need a script that can cache the screenshot and refresh it every 2 weeks for example. Hope that you can help me on this. Thank you in advance!
  4. Anyone can help me on this, Please?
  5. Thanks for your reply It resolves only the upload issue. Now, the image is uploaded but it's name is not updated on the database. And, if i don't want to upload (modify) the existed image, what should i do? Bcz, if i leave blank the image label, the script update the database and the image field too
  6. Hello everyone! I'm working on a form that can upload an image on server and add the image name on mysql db. The add page works correctly, the image is uploaded correctly and the image name is inserted on the db. But, the edit page dows not work ... When i click on Send option on the edit page and i'm not adding any image, the image db field remains black, and, when i want to upload an image (change the image) via the edit page form, the image is not uploaded and the image db field remains blabk Can you help me please? add page <? include('header.php'); include ('includes/uploader.class.php'); $uploader = new uploader(); // Setting properties then Uploading the image $uploader->destDir = "D:/Program Files/VertrigoServ/www/oldi/imazhet/artikuj/"; $uploader->upload($_FILES['LajmeImg']); echo '<div class="majtas">'; // Remember any variables incase the form validation finds errors. $LajmeEmri = $_POST['LajmeEmri']; $KatLajmeID = $_POST['KatLajmeID']; // Kategoria Lajmeve $LajmeIntro = $_POST['LajmeIntro']; $LajmeTxt = $_POST['LajmeTxt']; $LajmeAktiv = $_POST['LajmeAktiv']; $LajmeTag = $_POST['LajmeTag']; $LajmeVideo = $_POST['LajmeVideo']; //$LajmeImg = $_FILES['LajmeImg']['name']; // Me autoName = False; regjistron ne db emrin real te fotografise $LajmeImg = $uploader->source['name']; // Me autoName = true; regjistron ne db emrin random te fotografise i gjeneruar ne base64 $LajmeLink = preg_replace("#[^a-z0-9\-_]#i", "",str_replace(' ', '_', $LajmeEmri)); // Ben Url automatikisht nga titulli (LajmeEmri) i lajmit if(isset($_POST['add_lajme'])) { $LajmeEmri = $_POST['LajmeEmri']; $KatLajmeID = $_POST['KatLajmeID']; // Kategoria Lajmeve $LajmeIntro = $_POST['LajmeIntro']; $LajmeTxt = $_POST['LajmeTxt']; $LajmeAktiv = $_POST['LajmeAktiv']; $LajmeTag = $_POST['LajmeTag']; $LajmeVideo = $_POST['LajmeVideo']; //$LajmeImg = $_FILES['LajmeImg']['name']; // Me autoName = False; regjistron ne db emrin real te fotografise $LajmeImg = $uploader->source['name']; // Me autoName = true; regjistron ne db emrin random te fotografise i gjeneruar ne base64 $LajmeLink = preg_replace("#[^a-z0-9\-_]#i", "",str_replace(' ', '_', $LajmeEmri)); // Ben Url automatikisht nga titulli (LajmeEmri) i lajmit if(trim($KatLajmeID) == '0') { $error = '<div class="error_message">Attention! Nuk ke zgjedhur kategorine.</div>'; } else if(trim($LajmeIntro) == '') { $error = '<div class="error_message">Attention! Nuk ke vene Intro.</div>'; } else if(trim($LajmeEmri) == '') { $error = '<div class="error_message">Attention! Nuk ke vene emrin.</div>'; } $count = mysql_num_rows(mysql_query("SELECT * FROM lajme WHERE LajmeLink='".$LajmeLink."'")); if($count > 0) { $error = '<div class="error_message">Ky emer/url gjendet ne database.</div>'; } if($error == '') { $sql = "INSERT INTO lajme (KatLajmeID, LajmeEmri, LajmeLink, LajmeIntro, LajmeTxt, LajmeAktiv, LajmeTag, LajmeVideo, LajmeImg) VALUES ('$KatLajmeID', '$LajmeEmri', '$LajmeLink', '$LajmeIntro', '$LajmeTxt', '$LajmeAktiv', '$LajmeTag', '$LajmeVideo', '$LajmeImg')"; $query = mysql_query($sql) or die("Fatal error: ".mysql_error()); echo "<h2>Success!</h2>"; echo "<div class='success_message'>U Shtua me sukses lajmi <b>$LajmeEmri</b> ne kategorine <b>$KatLajmeID</b> .</div>"; echo "<h2>Te Dhenat e Lajmit</h2>"; echo "<ul class='success-reg'>"; echo "<li><span class='success-info'><b>Titulli</b></span>$LajmeEmri</li>"; echo "<li><span class='success-info'><b>Url</b></span>$LajmeLink</li>"; echo "<li><span class='success-info'><b>Kategoria</b></span>$KatLajmeID</li>"; echo "<li><span class='success-info'><b>Aktive</b></span>$LajmeAktiv</li>"; echo "</ul>"; echo "<h2>Cfare deshiron te besh tani?</h2><br />"; echo "Shko tek <a href='lajme_edit.php'>modifikimi i lajmeve</a>.</li>"; } } if(!isset($_POST['add_lajme']) || $error != '') { echo $error; ?> <h2>Shto Lajme</h2> <form action="" method="post" enctype="multipart/form-data"> <label style="width: 28%;" for="KatLajmeID">Kategoria</label> <select id="KatLajmeID" name="KatLajmeID" size="1"> <?php $query="SELECT * FROM lajme_kategori "; $result=mysql_query($query); $num = mysql_num_rows ($result); mysql_close(); ?> <option selected value="0">Perzgjidh Kategorine</option> <? if ($num > 0 ) { $i=0; while ($i < $num) { $LKatID = mysql_result($result,$i,"LKatID"); $LKatEmri = mysql_result($result,$i,"LKatEmri"); $LKatLink = mysql_result($result,$i,"LKatLink"); $LKatAktiv= mysql_result($result,$i,"LKatAktiv"); ?> <option value="<?php echo $LKatID ?>"><?php echo $LKatEmri ?></option> <?php ++$i; } } ?> </select> <script type="text/javascript"> function toggle_LajmeLink(LajmeID) { if (window.XMLHttpRequest) { http = new XMLHttpRequest(); } else if (window.ActiveXObject) { http = new ActiveXObject("Microsoft.XMLHTTP"); } handle = document.getElementById(LajmeID); var url = '../ajax.php?'; if(handle.value.length > 0) { var fullurl = url + 'do=check_LajmeEmri_exists&LajmeEmri=' + encodeURIComponent(handle.value); http.open("GET", fullurl, true); http.send(null); http.onreadystatechange = statechange_LajmeEmri; }else{ document.getElementById('LajmeEmri').className = ''; } } function statechange_LajmeEmri() { if (http.readyState == 4) { var xmlObj = http.responseXML; var html = xmlObj.getElementsByTagName('result').item(0).firstChild.data; document.getElementById('LajmeEmri').className = html; } } </script> <label>Titulli</label><input type="text" name="LajmeEmri" value="<?=$LajmeEmri;?>" onchange="toggle_LajmeEmri('LajmeEmri')" width="70%" /><br /> <label>Intro</label><textarea id="LajmeIntro" name="LajmeIntro" value="<?=$LajmeIntro;?>"></textarea> <script type="text/javascript"> CKEDITOR.replace( 'LajmeIntro', { filebrowserBrowseUrl : 'includes/ckfinder/ckfinder.html', filebrowserImageBrowseUrl : 'includes/ckfinder/ckfinder.html?Type=Images', filebrowserFlashBrowseUrl : 'includes/ckfinder/ckfinder.html?Type=Flash', filebrowserUploadUrl : 'includes/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files', filebrowserImageUploadUrl : 'includes/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images', filebrowserFlashUploadUrl : 'includes/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Flash' }); </script><br /> <label>Lajmi</label><textarea id="LajmeTxt" name="LajmeTxt" value="<?=$LajmeTxt;?>"></textarea> <script type="text/javascript"> CKEDITOR.replace( 'LajmeTxt', { filebrowserBrowseUrl : 'includes/ckfinder/ckfinder.html', filebrowserImageBrowseUrl : 'includes/ckfinder/ckfinder.html?Type=Images', filebrowserFlashBrowseUrl : 'includes/ckfinder/ckfinder.html?Type=Flash', filebrowserUploadUrl : 'includes/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files', filebrowserImageUploadUrl : 'includes/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images', filebrowserFlashUploadUrl : 'includes/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Flash' }); </script><br /> <label>Fotografia</label> <input type="file" size="20" value="<?=$LajmeImg;?>" id="LajmeImg" name="LajmeImg" /><br /> <label>Video</label><textarea id="LajmeVideo" name="LajmeVideo" value="<?=$LajmeVideo;?>" rows="4" wrap="soft" style="width:700px;" /></textarea><br /> <label>Tag</label><input id="LajmeTag" type="text" name="LajmeTag" value="<?=$LajmeTag;?>" /><br /> <label>Aktive</label><input id="LajmeAktiv" name="LajmeAktiv" type="checkbox" value="PO"><br /> <input type="submit" value="Vazhdo" name="add_lajme" /> </form> <? } echo '</div>'; include('poshte.php');?> edit page <?php include('header.php'); include ('includes/uploader.class.php'); $uploader = new uploader(); // Setting properties then Uploading the image $uploader->destDir = "D:/Program Files/VertrigoServ/www/oldi/imazhet/artikuj/"; $uploader->upload($_FILES['LajmeImg']); echo '<div class="majtas">'; if(!$_GET['lajmeid'] && !isset($_POST['do_edit']) && !isset($_POST['edit_lajme'])) { echo $error; // Shfaq listen e lajmeve lajmet_lista(); } // Has the edit form been submitted? if(isset($_POST['do_edit'])) { $LajmeID = $_POST['LajmeID']; $LajmeEmri = $_POST['LajmeEmri']; $KatLajmeID = $_POST['KatLajmeID']; // Kategoria Lajmeve $LajmeIntro = $_POST['LajmeIntro']; $LajmeTxt = $_POST['LajmeTxt']; $LajmeAktiv = $_POST['LajmeAktiv']; $LajmeTag = $_POST['LajmeTag']; $LajmeVideo = $_POST['LajmeVideo']; $LajmeLink = $_POST['LajmeLink']; //$LajmeImg = $_FILES['LajmeImg']['name']; // Me autoName = False; regjistron ne db emrin real te fotografise $LajmeImg = $uploader->source['name']; // Me autoName = true; regjistron ne db emrin random te fotografise i gjeneruar ne base64 $LajmeImg = $_POST['LajmeImg']; $fshij = $_POST['fshij']; // Ticked the 'delete category' box? If so, delete and echo message. if($fshij == 'fshij_LajmeID' && $error == '') { $sql = "DELETE FROM lajme WHERE LajmeID=$LajmeID LIMIT 1"; $query = mysql_query($sql) or die("Fatal error: ".mysql_error()); echo "<h3>U Fshi</h3>"; echo "<div class='success_message'>Lajme <b>$LajmeID</b> u fshi nga sistemi.</div>"; echo "<h2>What to do now?</h2><br />"; echo "Go to the <a href='lajme_edit.php'>edit lajme</a> page.</li>"; } else { // Validate the submitted information if(trim($LajmeID) == '0') { $error = '<div class="error_message">LajmeID - Attention! You cannot edit the main Administrator, use database.</div>'; } else if(trim($LajmeEmri) == '') { $error = '<div class="error_message">LajmeEmri - Attention! You must enter a first name.</div>'; } else if(trim($LajmeLink) == '') { $error = '<div class="error_message">LajmeUrl - Attention! You must enter a last name.</div>'; } // Password been entered? If so, validate and update information. if(trim($KatLajmeID) == '') { $error = '<div class="error_message">Attention! Nuk ke zgjedhur kategorine.</div>'; } else if(trim($LajmeIntro) == '') { $error = '<div class="error_message">Attention! Nuk ke vene Intro.</div>'; } else if(trim($LajmeEmri) == '') { $error = '<div class="error_message">Attention! Nuk ke vene emrin.</div>'; } if($error == '') { $sql = "UPDATE lajme SET KatLajmeID = '$KatLajmeID', LajmeEmri = '$LajmeEmri', LajmeLink = '$LajmeLink', LajmeIntro = '$LajmeIntro', LajmeTxt = '$LajmeTxt', LajmeVideo = '$LajmeVideo', LajmeTag = '$LajmeTag', LajmeImg = '$LajmeImg', LajmeAktiv = '$LajmeAktiv' WHERE LajmeID = '$LajmeID'"; $query = mysql_query($sql) or die("Fatal error: ".mysql_error()); // $sql2 = "SELECT * FROM lajme_kategori WHERE LKatAktiv = PO"; //$sql2 = "SELECT B.LKatEmri, A.LajmeID AS LajmeID, A.LajmeEmri AS LajmeEmri, A.LajmeLink AS LajmeLink, A.LajmeIntro AS LajmeIntro, A.LajmeTxt AS LajmeTxt, A.LajmeTag AS LajmeTag, A.LajmeVideo AS LajmeVideo, A.LajmeAktiv AS LajmeAktiv, B.LKatAktiv = LKatAktiv FROM lajme A LEFT JOIN lajme_kategori B ON A.KatLajmeID = B.LKatID WHERE B.LKatID = KatLajmeID AND LKatAktiv = PO AND LajmeAktiv = PO "; //$sql2 = "SELECT * FROM lajme_Kategori WHERE LKatID = '$KatLajmeID'"; //$result2 = mysql_query($sql2); echo "<h2>U Modifikua</h2>"; echo "<div class='success_message'>Lajmi u modifikua: <b>$LajmeEmri ($LajmeLink)</b> me ID <b>$LajmeID </b>.</div>"; echo "<h2>What to do now?</h2><br />"; echo "Go to the <a href='lajme_edit.php'>edit lajme</a> page.</li>"; } } } // Has a category been selected to edit? if($_GET['lajmeid'] && !isset($_POST['do_edit']) && !isset($_POST['edit_lajme']) || $error != '') { $LajmeID = $_GET['lajmeid']; $sql = "SELECT B.LKatEmri, A.LajmeID AS LajmeID, A.LajmeEmri AS LajmeEmri, A.LajmeLink AS LajmeLink, A.LajmeIntro AS LajmeIntro, A.LajmeTxt AS LajmeTxt, A.LajmeTag AS LajmeTag, A.LajmeImg AS LajmeImg, A.LajmeVideo AS LajmeVideo, A.LajmeAktiv AS LajmeAktiv, A.KatLajmeID AS KatLajmeID FROM lajme A LEFT JOIN lajme_kategori B ON A.KatLajmeID = B.LKatID WHERE B.LKatID = KatLajmeID AND A.LajmeID='$LajmeID'"; $result = mysql_query($sql); $row = mysql_fetch_array($result); $LajmeEmri = $row['LajmeEmri']; $LajmeLink = $row['LajmeLink']; $LajmeIntro = $row['LajmeIntro']; $LajmeTxt = $row['LajmeTxt']; $LajmeVideo = $row['LajmeVideo']; $LajmeTag = $row['LajmeTag']; $LajmeImg = $row['LajmeImg']; $LajmeAktiv = $row['LajmeAktiv']; $KatLajmeID = $row['KatLajmeID']; $LKatEmri = $row['LKatEmri']; echo $error; echo "<h2>Informacionet per lajmin ( ".stripslashes($row['LajmeEmri'])." )</h2>"; ?> <form action="" method="post"> <input type="hidden" name="LajmeID" value="<?=$row['LajmeID'];?>" /> <label style="width: 28%;">Kategoria</label> <select name="KatLajmeID"> <option selected value="<?=stripslashes($row['KatLajmeID']);?>"><?=$LKatEmri ?></option> <?php // Marrja e te dhenave ekzistente ?> <?php $sql2 = "SELECT * FROM lajme_kategori WHERE LKatAktiv = 'PO'"; // Query per te marre kategorite nga database $result2 = mysql_query($sql2); ?> <? while($kategoria = mysql_fetch_array($result2)) { echo '<option value="'.stripslashes($kategoria['LKatID']).'">'.stripslashes($kategoria['LKatEmri']).'</option>'; // Lista e kategorive } ?> </select> <label>Titulli</label> <input type="text" name="LajmeEmri" value="<?=stripslashes($row['LajmeEmri']);?>" /><br /> <label>Linku</label> <input type="text" name="LajmeLink" value="<?=stripslashes($row['LajmeLink']);?>" /><br /> <label>Intro</label><textarea id="LajmeIntro" name="LajmeIntro" /><?=stripslashes($row['LajmeIntro']);?></textarea> <script type="text/javascript"> CKEDITOR.replace( 'LajmeIntro', { filebrowserBrowseUrl : 'includes/ckfinder/ckfinder.html', filebrowserImageBrowseUrl : 'includes/ckfinder/ckfinder.html?Type=Images', filebrowserFlashBrowseUrl : 'includes/ckfinder/ckfinder.html?Type=Flash', filebrowserUploadUrl : 'includes/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files', filebrowserImageUploadUrl : 'includes/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images', filebrowserFlashUploadUrl : 'includes/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Flash', }); </script><br /> <label>Lajmi</label> <textarea id="LajmeTxt" name="LajmeTxt" /><?=stripslashes($row['LajmeTxt']);?></textarea> <script type="text/javascript"> CKEDITOR.replace( 'LajmeTxt', { filebrowserBrowseUrl : 'includes/ckfinder/ckfinder.html', filebrowserImageBrowseUrl : 'includes/ckfinder/ckfinder.html?Type=Images', filebrowserFlashBrowseUrl : 'includes/ckfinder/ckfinder.html?Type=Flash', filebrowserUploadUrl : 'includes/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files', filebrowserImageUploadUrl : 'includes/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images', filebrowserFlashUploadUrl : 'includes/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Flash' }); </script><br /> <label>Video</label> <textarea id="LajmeVideo" name="LajmeVideo" rows="6" wrap="soft" style="width:700px;" /><?=stripslashes($row['LajmeVideo']);?></textarea><br /> Fotografia: <img src="../imazhet/artikuj/<?=stripslashes($row['LajmeImg']);?>" width="150" align="middle" /><br /> <label>Fotografia</label> <input type="file" size="20" name="LajmeImg" value="<?=stripslashes($row['LajmeImg']);?>" /><br /> <label>Tag</label> <input type="text" name="LajmeTag" value="<?=stripslashes($row['LajmeTag']);?>" /><br /> <label style="width: 50%;">Aktive</label> <input id="LajmeAktiv" name="LajmeAktiv" type="checkbox" <?php if ($LajmeAktiv == "PO") { echo "checked";} ?> value="PO"> <br /><br /> <div class="error_message">Do fshish kete lajm? (Nuk kthehet mbrapsh!) <input type="checkbox" class="checkbox" name="fshij" value="fshij_LajmeID"></div> <input type="submit" value="Ruaje" name="do_edit" /> </form> <? } echo '</div>'; include('poshte.php'); ?> uploaded class <?php /** * Uploader is a file transfer class. it can upload files and images. * It also can resize and crop images. * Works on PHP 5 * @author Alaa Al-Hussein * @link http://www.freelancer-id.com/projects * @version 1.0 * */ class uploader{ /** * Array, The file object as $_FILES['element']. * String, file location. */ public $source; /** * Destination file location as folder. */ public $destDir; /** * Directory for Resized images. */ public $resizeDir; /** * Directory for Cropped images. */ public $cropDir; /** * stores information for uploading file */ private $info = ''; /** * Enabling autoName will generate an auto file name for the uploaded file. */ public $autoName = true; /** * Handles the error when it occurs. */ private $errorMsg = ''; /** * new width for resizing and cropping. */ public $newWidth; /** * new height for resizing and cropping. */ public $newHeight; /** * TOP postion to cropping image. */ public $top = 0; /** * LEFT position for cropping image. */ public $left = 0; /** * JPG quality (0 - 100). used for image resizing or cropping. */ public $quality = 60; public function __construct(){ //nothing } /** * Uploads the file to the server. * @param Array $_FILES[] */ public function upload($source){ if($source != ""){ $this->source = $source; } if(is_array($this->source)){ if($this->fileExists()){ return false; } return $this->copyFile(); } else { return $this->source; } } /** * return the error messages. * @return String messages. */ public function getError(){ return $this->errorMsg; } /** * Get uploading information. */ public function getInfo(){ return $this->info; } /** * Get file ex. */ function getEx(){ return strtolower(substr($this->source['name'], strrpos($this->source['name'], '.') + 1)); } /** * Get random name. */ function randName(){ return substr(base64_encode(uniqid()),0,10); } /** * Copy the uploaded file to destination. */ private function copyFile(){ if(!$this->isWritable()){ $this->errorMsg .= '<div>Error, the directory: ('.$this->destDir.') is not writable. Please fix the permission to be able to upload.</div>'; return false; } $this->source['name'] = ($this->autoName) ? $this->randName().'.'.$this->getEx(): $this->source['name']; if(copy($this->source['tmp_name'],$this->destDir . $this->source['name'])){ // Done. $this->info .= '<div>file was uploaded successfully.</div>'; } else { $this->errorMsg .= '<div>Error, the file was not uploaded correctly because of an internal error. Please try again, if you see this message again, please contact web admin.</div>'; } } /** * Checks if the file was uploaded. * @return boolean */ private function uploaded(){ if($this->source['tmp_name']=="" || $this->source['error'] !=0){ $this->errorMsg .= '<div>Error, file was not uploaded to the server. Please try again.</div>'; return false; } else return true; } /** * Prepares the directory. */ private function preDir(){ if($this->destDir!="" && substr($this->destDir, -1,1) != "/"){ $this->destDir = $this->destDir . '/'; } if($this->resizeDir!="" && substr($this->resizeDir, -1,1) != "/"){ $this->destDir = $this->resizeDir . '/'; } if($this->cropDir!="" && substr($this->cropDir, -1,1) != "/"){ $this->destDir = $this->cropDir . '/'; } } /** * Check if the folder is writable or not. * @return boolean */ private function isWritable(){ $err = false; if(!is_writeable($this->destDir) && $this->destDir!=""){ $this->errorMsg .= '<div>Error, the directory ('.$this->destDir.') is not writeable. File could not be uploaded.</div>'; $err = true; } if(!is_writeable($this->resizeDir) && $this->resizeDir!=""){ $this->errorMsg .= '<div>Error, the directory ('.$this->resizeDir.') is not writeable. File could not be resized.</div>'; $err = true; } if(!is_writeable($this->cropDir) && $this->cropDir!=""){ $this->errorMsg .= '<div>Error, the directory ('.$this->cropDir.') is not writeable. File could not be cropped.</div>'; $err = true; } if($err == true){ return false; } else { return true; } } /** * Checks if the file exists on the server * @return boolean */ private function fileExists(){ $this->preDir(); if(file_exists($this->destDir.$this->source)){ $this->errorMsg .= '<div>Upload error because file already exists.</div>'; return true; } else { return false; } } /** /586742130./8532 Crops image. * @return String fileName or False on error */ public function crop($file='',$width='',$height='',$top='',$left=''){ if($file!=""){ $this->source = $file;} if ($width != '') $this->newWidth = $width; if ($height != '') $this->newHeight = $height; if ($top != '') $this->top = $top; if ($left != '') $this->left = $left; return $this->_resize_crop(true); } /** * Resizes an image. * @return String fileName or False on error */ public function resize($file='',$width='',$height=''){ if($file!=""){ $this->source = $file; } if($width != '') $this->newWidth = $width; if($height != '') $this->newHeight = $height; return $this->_resize_crop(false); } /** * Get the Temp file location for the file. * If the Source was a file location, it returns the same file location. * @return String Temp File Location */ private function getTemp(){ if(is_array($this->source)){ return $this->source['tmp_name']; } else { return $this->source; } } /** * Get the File location. * If the source was a file location, it returns the same file location. * @return String File Location */ private function getFile(){ if(is_array($this->source)){ return $this->source['name']; } else { return $this->source; } } /** * Resize or crop- the image. * @param boolean $crop * @return String fileName False on error */ private function _resize_crop ($crop) { $ext = explode(".",$this->getFile()); $ext = strtolower(end($ext)); list($width, $height) = getimagesize($this->getTemp()); if(!$crop){ $ratio = $width/$height; if ($this->newWidth/$this->newHeight > $ratio) { $this->newWidth = $this->newHeight*$ratio; } else { $this->newHeight = $this->newWidth/$ratio; } } $normal = imagecreatetruecolor($this->newWidth, $this->newHeight); if($ext == "jpg") { $src = imagecreatefromjpeg($this->getTemp()); } else if($ext == "gif") { $src = imagecreatefromgif ($this->getTemp()); } else if($ext == "png") { $src = imagecreatefrompng ($this->getTemp()); } if($crop){ $pre = 'part_'; if(imagecopy($normal, $src, 0, 0, $this->top, $this->left, $this->newWidth, $this->newHeight)){ $this->info .= '<div>image was cropped and saved.</div>'; } $dir = $this->cropDir; } else { $pre = 'thumb_'; if(imagecopyresampled($normal, $src, 0, 0, 0, 0, $this->newWidth, $this->newHeight, $width, $height)){ $this->info .= '<div>image was resized and saved.</div>'; } $dir = $this->resizeDir; } if($ext == "jpg" || $ext == "jpeg") { imagejpeg($normal, $dir . $pre . $this->getFile(), $this->quality); } else if($ext == "gif") { imagegif ($normal, $dir . $pre . $this->getFile()); } else if($ext == "png") { imagepng ($normal, $dir . $pre . $this->getFile(),0); } imagedestroy($src); return $src; } } ?> Can someone help me, please? Thank you in advance!
  7. I have tried in many ways but i'm not getting what i need My db tables looks like this: p_kategori table -- -- Table structure for table `p_kategori` -- CREATE TABLE IF NOT EXISTS `p_kategori` ( `id` int(6) NOT NULL auto_increment, `katemri` varchar(255) NOT NULL default '', `katpermalink` varchar(255) NOT NULL default '', `kataktiv` enum('N','Y') NOT NULL default 'Y', PRIMARY KEY (`id`), UNIQUE KEY `id` (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=9 ; -- -- Dumping data for table `p_kategori` -- INSERT INTO `p_kategori` (`id`, `katemri`, `katpermalink`, `kataktiv`) VALUES (1, 'Gjeneratore', 'gjeneratore/', 'Y'), (2, 'Elektroda', 'elektroda/', 'Y'), (3, 'Test', 'test/', ''), (4, 'Test2', 'test2/', ''), (5, 'Prove', 'prove/', ''), (6, 'Prove 2', 'prove2/', ''), (7, 'Prove 3', 'prove3/', 'Y'), (8, 'Test 4', 'test4/', 'Y'); p_produkte table -- -- Table structure for table `p_produkte` -- CREATE TABLE IF NOT EXISTS `p_produkte` ( `id` int(6) NOT NULL auto_increment, `katid` varchar(255) NOT NULL default '', `prodemri` varchar(255) NOT NULL default '', `prodimg` varchar(255) NOT NULL default '', `prodinfo` text NOT NULL, `prodpermalink` varchar(255) NOT NULL default '', `prodaktiv` enum('N','Y') NOT NULL default 'Y', PRIMARY KEY (`id`), UNIQUE KEY `id` (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ; -- -- Dumping data for table `p_produkte` -- INSERT INTO `p_produkte` (`id`, `katid`, `prodemri`, `prodimg`, `prodinfo`, `prodpermalink`, `prodaktiv`) VALUES (2, '1', 'XCV 220W', '220w.jpg', '<p>\r\n Gjenerator</p>\r\n', 'gjenerator_xcv220w/', 'Y'); kategorite.php - The page where appear the category list and, if clicks on a category, will appear a new page where should be listed all products on that category. <?php if (!isset($_GET['id'])) // if $_GET['id'] is NOT set { include 'D:/Program Files/VertrigoServ/www/joni/admini/includet/variabla.php'; include (BPATH . '/includet/dbconfig.php'); $query="SELECT * FROM `p_kategori` WHERE kataktiv = 'Y' ORDER BY `p_kategori`.`ID`"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); $i=0; while ($i < $num) { $id=mysql_result($result,$i,"id"); $katemri=mysql_result($result,$i,"katemri"); $katpermalink=mysql_result($result,$i,"katpermalink"); $kataktiv=mysql_result($result,$i,"kataktiv"); ?> <img src="imazhet/bulona.jpg" width="15" hspace="5" vspace="3" align="absmiddle" /><a href="kategorite.php?id=<?php echo $id; ?>"> <?php echo $katemri; ?></a><br> <?php $i++; } ?> <?php } // end if() else // $_GET['id'] IS set { if (!empty($_GET['id'])) // if $_GET['id'] is NOT empty { // getting infos from db include 'D:/Program Files/VertrigoServ/www/joni/admini/includet/variabla.php'; include (BPATH . '/includet/dbconfig.php'); $query="SELECT * FROM `p_kategori` WHERE id = '$_GET[id]'"; $result=mysql_query($query); $num=mysql_numrows($result); $id=mysql_result($result,$i,"id"); $katemri=mysql_result($result,$i,"katemri"); $katpermalink=mysql_result($result,$i,"katpermalink"); $kataktiv=mysql_result($result,$i,"kataktiv"); // end of getting infos from db ?> ... ... ... I don't know how to continue now! ... ... ... <?php } // end if() } // end else ?> I don't know how to continue now ! I have tried to use the query you suggest but i't didn;t worked bcz i don;t know how and where to use it. Can you please help me? Thank you in advance!
  8. Any example of you idea, pls ? Thanks!
  9. Ok ... got the idea, but, when i add a movie, how should look like the query? Thank you!
  10. <?php if (!isset($_GET['id'])) // if $_GET['id'] is NOT set { include 'D:/Program Files/VertrigoServ/www/joni/admini/includet/variabla.php'; include (BPATH . '/includet/dbconfig.php'); $query="SELECT * FROM `faqe` ORDER BY `faqe`.`ID`"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <!--Ketu fillon seksioni Head Indexin --> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <meta name="generator" content=":!:!: Albmania Host & Design :!:!:" /> <meta name="robots" content="Follow, Index" /> <meta name="author" content="Feriold O." /> <meta name="copyright" content=" © 2009 Mundesuar nga Albmania Host and Design - Feriold O." /> <meta http-equiv="Pragma" content="no-cache" /> <meta content="no-cache" http-equiv="no-cache" /> <meta name="revisit-after" content="1 DAYS"> <meta http-equiv="Cache-Control" content="no-cache" /> <title>Watch Live Football Games For Free</title> <meta name="description" content=" " /> <meta name="keywords" content=" " /> <link href="stildizenjimi.css" rel="stylesheet" type="text/css" /> <script src="http://localhost/live/js/skripte.js" type="text/javascript"></script> <link rel="shortcut icon" href="favicon.ico" > </head> <!--Ketu mbaron seksioni i Head për Indexin--> <!--Ketu fillon Trupi i indexit --> <body> <?php $i=0; while ($i < $num) { $id=mysql_result($result,$i,"id"); $emri=mysql_result($result,$i,"emri"); $teksti=mysql_result($result,$i,"teksti"); $tag=mysql_result($result,$i,"tag"); $permalink=mysql_result($result,$i,"permalink"); ?> <div class="trupi" align="center"> <div class="koka"> </div> <div class="pastro"></div> <div class="qender"> <div class="qendersiper"> <div class="qendersipermenu"> |<a href="http://localhost/joni/">Fillimi</a> |<a href="<?php echo $id; ?>_<?php echo $permalink; ?>"> <?php echo $emri; ?></a> | <?php $i++; } ?> </div> </div> <div class="majtas">Majtas </div> <div class="djathtas">Djathtas </div> </div> <div class="pastro"></div> </div> <!-- Ketu mbaron trupi i Indexit--> </body> </html> <?php } // end if() else // $_GET['id'] IS set { if (!empty($_GET['id'])) // if $_GET['id'] is NOT empty { // added by Kleidi: getting infos from db include 'D:/Program Files/VertrigoServ/www/joni/admini/includet/variabla.php'; include (BPATH . '/includet/dbconfig.php'); $query="SELECT * FROM `faqe` WHERE id = '$_GET[id]'"; $result=mysql_query($query); $num=mysql_numrows($result); $id=mysql_result($result,$i,"id"); $emri=mysql_result($result,$i,"emri"); $teksti=mysql_result($result,$i,"teksti"); $permalink=mysql_result($result,$i,"permalink"); $tag=mysql_result($result,$i,"tag"); // added by Kleidi: end of getting infos from db ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <!--Ketu fillon seksioni Head per ndeshjen --> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <meta name="generator" content=":!:!: Albmania Host & Design :!:!:" /> <meta name="robots" content="Follow, Index" /> <meta name="author" content="Feriold O." /> <meta name="copyright" content=" © 2009 Mundesuar nga Albmania Host and Design - Feriold O." /> <meta http-equiv="Pragma" content="no-cache" /> <meta content="no-cache" http-equiv="no-cache" /> <meta http-equiv="Cache-Control" content="no-cache" /> <title>Agalliu.Com - <?php echo $emri; ?></title> <meta name="description" content="" /> <meta name="keywords" content="" /> <link href="http://localhost/joni/stildizenjimi.css" rel="stylesheet" type="text/css" /> <link rel="shortcut icon" href="favicon.ico" > </head> <!--Ketu mbaron seksioni i Head për ndeshjen--> <!--Ketu fillon Trupi i ndeshjes--> <body> <?php $i=0; while ($i < $num) { $id=mysql_result($result,$i,"id"); $emri=mysql_result($result,$i,"emri"); $teksti=mysql_result($result,$i,"teksti"); $tag=mysql_result($result,$i,"tag"); $permalink=mysql_result($result,$i,"permalink"); ?> <div class="trupi" align="center"> <div class="koka"> </div> <div class="pastro"></div> <div class="qender"> <div class="qendersiper"> <div class="qendersipermenu"> |<a href="http://localhost/joni/">Fillimi</a> |<a href="<?php echo $id; ?>_<?php echo $permalink; ?>"> <?php echo $emri; ?></a> | <?php $i++; } ?> </div> </div> <div class="majtas">Majtas </div> <div class="djathtas"><b><?php echo $emri; ?> </b> <br /> <br /> <?php echo $teksti; ?><br /> <br /> <i><?php echo $tag; ?></i> </div> </div> <div class="pastro"></div> </div> <!-- Ketu mbaron trupi i Indexit--> </body> </html> </html> <?php // code to get movie information from database and output it } // end if() } // end else ?> That's the index.php My db looks like this: `id` int(6) NOT NULL auto_increment, `emri` varchar(255) NOT NULL default '', `permalink` varchar(255) NOT NULL default '', `teksti` text NOT NULL, `tag` varchar(255) NOT NULL default '', `aktive` enum('N','Y') NOT NULL default 'N', PRIMARY KEY (`id`), UNIQUE KEY `id` (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ; And rows looks like this: INSERT INTO `faqe` (`id`, `emri`, `permalink`, `teksti`, `tag`, `aktive`) VALUES (1, 'Any Name', 'any_name/', 'some text here', 'any, name, here', 'Y'); INSERT INTO `faqe` (`id`, `emri`, `permalink`, `teksti`, `tag`, `aktive`) VALUES (2, 'That Name', 'that_name/', 'some text here too', 'that, name, here', ''); Now, what i need is a way to show only the rows that are aktive=Y. I tried: $query="SELECT * FROM `faqe` WHERE `faqe`.`aktive` = `Y` ORDER BY `faqe`.`ID`"; but i received this error: and line 8 is this one: $num=mysql_numrows($result); Hope that i was understandable and someone can help me. Thank you in advance!
  11. Hello! I'm looking around for a way to show/hide some db results depending on a checkbox or dropdown selection. Ex: If i have 3 pages and i don't want that the page number 2 to appear, i check a box and save ti or select the option in dropdown menu and that page is not anymore visible. Any help please? Thank you in advance!
  12. Hello everyone. I'm playing around on a site that will show up all the products that i have but i want to add them on the category and when i click to a category to appear only the products that are in that category. I know that somehow i should make a table for categories and a table for products but how to link the table products with the categories table, and how to show them up? Ex: I have table movcat where are listed all the categories like Action, Thriller, Horror, Comedy, etc Then i have table movies where are listed all the movies but them are not inserted in any category. When i want to show them up i call a query to db and show them up, but those are not on any category and are showing up all of them. Can someone help me, PLEASE? P.S. Hope that i was understandable. Sorry for my bad english
  13. Hello again! I have a little problem with the delete option. When i click on "Delete Link" of id 40 (for ex) it's not deleted the id 40 but the last id on the list. I don't know what the problem is... can you please help me? Main page: <?php session_start(); if(!isset($_SESSION['loggedin'])) { header('Location: '.$domain.'index.php?error=1'); exit(); } ?> <html> <head> <script type="text/javascript"> var form_id; function confirm_delete(go_url) { var answer = confirm("Jeni te sigurte per fshirjen e ketij evenimenti?"); if (answer) { location=go_url; } } </script> </head> <body> <?php include '/includet/variabla.php'; include (BPATH_ADM . 'includet/dbconfig.php'); include (BPATH_ADM . 'includet/dblidhja.php'); $query="SELECT * FROM `ndeshje` ORDER BY `ndeshje`.`ID`"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); ?> <br /><br /><center><div class="ndeshjeshfaq"> <table width="598" border="0" align="center" class="ndeshjekoka"> <tr> <td width="25" class="ndshfaqid">ID</td> <td width="35" class="ndshfaqsporti">Sporti</td> <td width="265" class="ndshfaqndeshja">Ndeshja</td> <td width="50" class="ndshfaqmenyra">Menyra</td> <td width="50" class="ndshfaqora">Ora</td> <td width="90" class="ndshfaqdata">Data</td> <td width="110" class="ndshfaqmod">X - Mod</td> </tr> </table></center> <?php $i=0; while ($i < $num) { $id=mysql_result($result,$i,"ID"); $ndeshja=mysql_result($result,$i,"ndeshja"); $ora=mysql_result($result,$i,"ora"); $data=mysql_result($result,$i,"data"); $menyra=mysql_result($result,$i,"menyra"); $sporti=mysql_result($result,$i,"sporti"); ?> <center> <table width="598" border="0" class="ndeshjetabela"> <tr> <td width="25" class="ndshfaqid"><?php echo $id; ?></td> <td width="35" class="ndshfaqsporti"><img src="..<?php echo $sporti; ?>" width="13"></td> <td width="265" class="ndshfaqndeshja"><?php echo $ndeshja; ?></td> <td width="50" class="ndshfaqmenyra"><?php echo $menyra; ?></td> <td width="50" class="ndshfaqora"><?php echo $ora; ?></td> <td width="90" class="ndshfaqdata"><?php echo $data; ?></td> <?php include (BPATH_ADM . 'includet/dbconfig.php'); include (BPATH_ADM . 'includet/dblidhja.php'); $query="select * from ndeshje;"; $result=mysql_query($query); while ($row = mysql_fetch_array($result)){ $id = $row['ID']; } ?> <td width="110" class="ndshfaqmod"><a href="#" onClick="confirm_delete('modulet/ndeshje/fshij.php?fshij=true&id=<?php echo $id;?>');">Fshije</a> - <a href="link-for-edit-entry.php">Mod</a></td> </tr> </table></center> </div> <?php $i++; } ?> </body> </html> Delete page: <html> <body> <?php include '/includet/variabla.php'; include (BPATH_ADM . 'includet/dbconfig.php'); include (BPATH_ADM . 'includet/dblidhja.php'); $sql = "delete from ndeshje WHERE ID = '$_GET[id]'"; $result = mysql_query($sql); //print $sql; if (!$result) { echo "<div align ='center' class='error'>Fshirja e ndeshjes deshtoi!"; echo "<br>"; echo "<br>"; echo '<form><input type="button" class="buton" value="Kthehu Mbrapa" ONCLICK="history.go(-1)"></form>'; } else { echo "<div align ='center' class='header2'>Ndeshja u fshi me sukses!"; echo "<br>"; echo "<br>"; echo '<form><input type="button" class="buton" value="Kthehu Mbrapa" ONCLICK="history.go(-1)"></form>'; } ?> </body> </html> Thank you in advance!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.