Jump to content

danlew

Members
  • Posts

    45
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

danlew's Achievements

Member

Member (2/5)

0

Reputation

  1. I am using php/mysql/apache linux server hosting for my site and testing the site on firefox 3.0+ I am creating a travel blog so I want to give my users a facility to uploaded images. I let them upload all images in a single folder "spaw2/uploads/images" and giving names of the files little dynamically using following code in spawfm.class.php spawfm.class.php (line no 514) I change from if (!@move_uploaded_file($uplfile['tmp_name'], $this->getCurrentFsDir().$uplfile_name)) { to $uplfile_name = $_SESSION['user_id_session']."-".$uplfile['name']; // i added this line if (!@move_uploaded_file($uplfile['tmp_name'], $this->getCurrentFsDir().$uplfile_name)) { where $_SESSION['user_id_session'] is the unique ID of a "loggedin user" who is uploading the file. so this way I upload images. for example if a user's unique ID is "007" then his uploaded files names will be like > 007-myfirstimage.jpg 007-mysecondimage.jpg 007-mysecondimage_1.jpg and so on.. it works fine till now . oh yes, and to make it successful i place session_start(); in the few php files to get value of $_SESSION variables. well this is not my problem. my problem now is I want to show a user only his own uploaded images in "SPAW file manager 's file list" I used a dirty trick in line no 276 in spawfm.class.php where I converted from > foreach ($directories as $key=>$file) { $directories[$key] = array( 'name' => $file, 'date' => $this->getFileDate($file), 'size' => $this->getFileSize($file), 'descr' => $lang->m('file_folder', 'file_details'), 'icon' => '../plugins/spawfm/img/'.$config->getConfigValueElement('PG_SPAWFM_FILETYPES_ICON_FOLDER', 'icon'), 'icon_big' => '../plugins/spawfm/img/'.$config->getConfigValueElement('PG_SPAWFM_FILETYPES_ICON_FOLDER', 'icon_big'), 'thumb' => $this->getFileThumbnail($file), 'other' => '' ); } to > foreach ($directories as $key=>$file) { $bravo_target=$_SESSION['user_id_session']."-"; // i added this line $bravo_img=substr($file,0,strlen($bravo_target)); // i added this line if($bravo_img==$bravo_target){ // i added this line $directories[$key] = array( 'name' => $file, 'date' => $this->getFileDate($file), 'size' => $this->getFileSize($file), 'descr' => $lang->m('file_folder', 'file_details'), 'icon' => '../plugins/spawfm/img/'.$config->getConfigValueElement('PG_SPAWFM_FILETYPES_ICON_FOLDER', 'icon'), 'icon_big' => '../plugins/spawfm/img/'.$config->getConfigValueElement('PG_SPAWFM_FILETYPES_ICON_FOLDER', 'icon_big'), 'thumb' => $this->getFileThumbnail($file), 'other' => '' ); } // i added this line } but strange .. its still showing all images resided in "images" folder where as I only want to show list of the files which are only his own uploaded by a user.
  2. I have this code on my index.php page where i want the image to show; index.php and i have this where im trying to upload the image from; cms-events.php At the moment its working perfectly, and the file is uploading to my ftp server under /files folder but the image is not displaying on my index.php page? When i than go to the database to check all fields have been entered apart from the image field? is this why? does it also need to go the database before it can be viewed on the index.php page? or do i have to add an extra line of code for the image to display on the index.php page...
  3. thats weird it gave the same error, Could Not Copy, Wrong Filetype ()
  4. Ok this is my latest trial run with code that can be seen below to get it working, image doesnt upload it gets an error saying - "Could Not Copy, Wrong Filetype" maybe its something to do with the file type I have named in the code or didnt create on my server? I followed it all perfectly from tutorial here; www.phpfreaks.com/tutorials/36/0.php All help will be much appreciated...
  5. Ok I have put together the code successfully from the tutorial link above, but I am stuck with adding image upload option to one of my tables in php. This is what I have done so far but it doesnt seems to be uploading?
  6. Oh yeah something like that would be great...
  7. I apologise nutycoder, that link ended up being very useful!, Thankyou
  8. I have put together this code from one of the tutorials found here http://www.php-mysql-tutorial.com/cms-admin-php-mysql.php and so far have this working; cms-admin.php but when I go to ww.nzsocietythai.org/library/cms-admin.php I have a few errors which I dont understand. Secondly I need to edit the code to suit my datasbe which has 3 tables 1 table has an image file, which will involve uploading images, how can I add this code to suit? Kindly awaiting suggestions and possible help on code!
  9. I am not after links, I want you to help me with my code which is what this forum is meant to be about.
  10. No, I want to stick with phpadmin, but what i want is to design or code an admin so the client can log in and add and edit as they wish.. What will I need to add to this code to have 3 categories which sit as tables in phpadmin? At the monet the code i have created only displays the edit option. 1. News (contain : date, title and description) 2. Events (contain : date, title , description and images) 3. Information (contain : date, title and description) <?php session_start(); ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>News System - Edit News</title> <style type="text/css"> <!-- select, textarea, input { border: #808080 1px solid; color: #000000; font-size: 11px; font-family: Verdana; BACKGROUND-COLOR: #ffffff } input[type=submit]:hover, input[type=button]:hover{ background-color:#EBEBEB !important; } a:active,a:visited,a:link {color: #446488; text-decoration: none; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 8pt;} a:hover {color: #00004F; text-decoration: none; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 8pt; } a.nav { padding-top:10px; padding-bottom:10px; padding:9px;} a.nav:active, a.nav:visited, a.nav:link { color: #000000; font-size : 10px; font-weight: bold; font-family: verdana; text-decoration: none;} a.nav:hover { font-size : 10px; font-weight: bold; color: black; font-family: verdana; text-decoration: underline; } .header { font-size : 16px; font-weight: bold; color: #808080; font-family: verdana; text-decoration: none; } .bborder { background-color: #FFFFFF; border: 1px #A7A6B4 solid; } .panel {-moz-border-radius: .3em .3em .3em .3em; border: 1px solid silver; background-color: #F7F6F4;} BODY, TD, TR {text-decoration: none; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 8pt; cursor: default;} --> </style> </head> <body> <?php $admin_username = "admin"; $admin_password = "password"; $act = $_GET['act']; if ($act == "logout") { session_destroy(); echo "You have successfully logout"; exit(); } if ($_SESSION['login'] != "" || $_SESSION['loginpass'] != "") { $already_login = "TRUE"; } if ($already_login == "TRUE") { } else { if (!isset($_POST['login_box'])) { ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <div> Username: <input type="text" name="username" value="" style="width:120px; height:18px; font-family:Tahoma; font-size:11px "><br> Password: <input type="password" name="password" value="" style="width:120px; height:18px; font-family:Tahoma; font-size:11px "><br> <input type="submit" name="login_box" value="Submit"> </div> </form> <?php } else { $username = $_POST['username']; $password = $_POST['password']; if ($username == "" || $password == "") { echo "Please fill up the blank."; } elseif ($username != $admin_username || md5($password) != md5($admin_password)) { echo "Sorry, you don't have the privileges to access."; } else { // Save them in session $_SESSION['loginid'] = $username; $_SESSION['loginpass'] = md5($password); echo "Permission granted."; echo "<META HTTP-EQUIV='Refresh' CONTENT='1'>"; } } } ?> <?php if ($already_login != "TRUE") { exit(); } require_once('config.php'); if ($_GET['id'] != "") { $id = $_GET['id']; $query = "SELECT * FROM news WHERE id ='$id'"; $result = mysql_query($query) or die("There's some problem editing the news, please report it to $support_email"); $row = mysql_fetch_assoc($result); if (!$row) { echo "The news doesn't exists."; exit(); } if (!isset($_POST['submit'])) { ?> <form action="<?php echo $_SERVER['PHP_SELF'] . "?id=$id"; ?>" method="post"> <table border=0 cellpading=0 cellspacing=0 width="654" > <tr> <td width="75"> Title <td width="575" colspan="2"> <input type=text size="55" name="title" value="<?php echo $row['title']; ?>"> </tr> <tr> <tr> <td width="75"> Date <td width="575" colspan="2"> <input type=text size="55" name="date" value="<?php echo $row['date']; ?>"> </tr> <tr> <td width="75" valign="top"> <br />Content <td> <textarea rows="12" cols="74" id="content" name="content"><?php echo $row['content']; ?></textarea> <td width="108" valign="top"> <p align="center"><br /> <a href="add.php?act=help" target="_blank">[README]</a><br> <a href="?act=logout">[Logout]</a> </tr> </table> <table border=0 cellpading=0 cellspacing=0 width="654" > <tr> <td width="75"> <td> <table border=0 cellspacing=0 cellpadding=0 width=100%> <tr> <td width=50%> <input type=submit style='font-weight:bold' title="Edit the New Article" value="Edit News" name="submit"> </td> <td width=50% align=right> </td> </tr> </table> </tr> </table> </form> <?php } else { $title = $_POST['title']; $content = $_POST['content']; $date = $_POST['date']; if ($title == "" || $content == "") { echo "Please fill up all the blanks."; } else { mysql_query("UPDATE `news` SET title='$title', date='$date', content='$content' WHERE id='$id'") or die ("There's some problem editing this news, please report it to $support_name."); echo "You have successfully edited your news."; } } } ?> </body> </html>
  11. I am trying to create an admin.. I have already my tables and backend working but i need to make a php admin like apanel so i can easily add and edit text without going to phpmyadmin to do it everytime. Can anyone help me? Wil i need to show some code here of how my tables are in MYSQL or PHP Docs?
  12. I have the script working here now : nzsocietythai.org/nzsocietythailand.php but i want to have it so when i click on the image it will go to page with info? what code do i need to set in different page and have link on it? It will have say the image but larger, and the long description thats it. Nice and simple..... The first page is just 1 image they click from this page "nzsocietythai.org/nzsocietythailand.php" than when it takes them to the secondary page it will show the same image but much bigger, with maybe an option to have 2 more images beside it and longer description....
  13. Yes that is what i would like... what extra code will i need for that?
×
×
  • 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.