Jump to content

adrianTNT

Members
  • Posts

    146
  • Joined

  • Last visited

Everything posted by adrianTNT

  1. I got stuck at something that I thought it was simple I have this code: do { echo $row_Recordset_count_referers['referer_url']; } while ($row_Recordset_count_referers = mysql_fetch_assoc($Recordset_count_referers)); That block will return site referers form database like this: How can I display each unique record and total instances next to it (sorted descending)? so that it looks like this: Can someone provide a code block? Or at least Instructions? Thank you.
  2. I didn't knew what 'distro' means, sure i know what an OS is Anyway ... I first asked godaddy to enable the zip on server, then they asked for permission to access the server and day later they told me that I need to do it myself, when I tried I could not access the server by SSH anymore, it disconnected me *before asking for password. After 4-5 more emails they said 4 Ips including my own is banned from accessing the SSH and in order to unban my IP I should login by SSH and edit some system files. ) Or I could pay them $75/ half hour and they could edit the files to unban me. So in order to access server by SSH you must first login by SSH and edit some files. LOL LOL. Thanks for the fast replies, I will try the commands as soon as they let me on the server.
  3. Im not sure what it means, is this the operating system version? It is Fedora 6 I also have plesk 8.2.1 installed (in case there is an easy way by plesk). This info is from my cpanel: Version psa v8.2.1_build82070918.10 os_FedoraCore 6 OS Linux 2.6.22.9-61.fc6 Thanks.
  4. You will have to ask your host to add support for the zip extension. Unless you have root access, you cannot do this yourself. I have root access and the host (GoDaddy) doesn't want to enable the zips since is a dedicated server and they say is my responsibility; I expected the server to have basic functions available, but whatever. So how can I fix this as root?
  5. Hi Ace, this is the code in the script, the error is: Fatal error: Call to undefined function zip_open() in ... // upload and unpack the zip of additional files if(isset($_FILES["zip_box"]['name']) and $_FILES["zip_box"]['name']!=''){ $dir = 'flash_files/'.$listing_id.'/'; $zip = zip_open($_FILES["zip_box"]['tmp_name']); while($zip_entry = zip_read($zip)) { $entry = zip_entry_open($zip,$zip_entry); $filename = zip_entry_name($zip_entry); $target_dir = $dir.substr($filename,0,strrpos($filename,'/')); $filesize = zip_entry_filesize($zip_entry); if (is_dir($target_dir) || mkdir($target_dir)) { if ($filesize > 0) { $contents = zip_entry_read($zip_entry, $filesize); file_put_contents($dir.$filename,$contents); echo $dir.$filename.'<br />'; // if there are php, asp files then rename them by adding _safe in the name if(strpos(strtolower($dir.$filename),'.php') == (strlen($dir.$filename)-4)){ rename($dir.$filename,$dir.$filename.'_safe'); } if(strpos(strtolower($dir.$filename),'.asp') == (strlen($dir.$filename)-4)){ rename($dir.$filename,$dir.$filename.'_safe'); } if(strpos(strtolower($dir.$filename),'.cgi') == (strlen($dir.$filename)-4)){ rename($dir.$filename,$dir.$filename.'_safe'); } if(strpos(strtolower($dir.$filename),'.js') == (strlen($dir.$filename)-3)){ rename($dir.$filename,$dir.$filename.'_safe'); } if(strpos(strtolower($dir.$filename),'.jsp') == (strlen($dir.$filename)-4)){ rename($dir.$filename,$dir.$filename.'_safe'); } } } } } I have previous server phpinfo and new server phpinfo, the new server is the one with problems, on the new server phpinfo I do not see the part "Zip Support Enabled". Thanks.
  6. Hello. My host updated PHP to 5.1.6 and now zip functions like zip_open do not work, it says undefined function or something similar, "zip enabled" doesn't show on phpinfo() eider. Is there an easyer way to use the zip functions? Maybe by downloading and including the libraries by include lines? Or only by recompiling the php? (this one sounds complicated). What can I do?
  7. ok, then if I use mysql_real_escape_string on all the variables in the query then I am ok? Is it something else I need to worry after I convert all the strings with this function?
  8. So injection can be used when selecting from database too? for example site.com/templates/files.html will select and print from database listings with cat_title "templates", could a user find other data (like passwords) by using an url formated something like this? site.com/SQL select 'passwords'/files.html ? Thanks.
  9. Hello. I need a bit help with understanding how to protect against SQL Injections. - Do I only need to worry about sql injections when inserting a record in database? Or when reading form database too? - Does this function protects me against injections? Or this only adds quotes next to values? Thank you. if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } }
  10. I found many examples for the unzip thing, but the 1st issue remains, I didn't find a code sample to zip all files and folders from one given location. I tried 6-7 versions, most of them link to external files or to 10 other libraries. I do not know why people complicate things with thousands of lines, all I want is to zip a folder
  11. Can someone please point me in the right direction with this? I am trying to create two things/codes. - I have files placed like this in directories: "/files/103/", "/files/104/", "/files/105/" The directories have multiple files and directories in them. Is there a simple function to create a zip "104.zip" that contains all the files and folders in that directory keeping the directory structure? - The other thing... users upload a zip by a form, is there a function to unzip an uploaded zip in a given directory (files/104/) keeping the directory structure from the zip? Maybe there is a class or something for this? Any ideas? Thank you.
  12. I just had a similar issue, I was printing listing descriptions taken form the database and in the database it looked like plain file but on multiple lines (no <br /> in it there). Printing it on screen made the words come one after another without new lines, I used nl2br() and now it looks perfect, it shows the text on new lines. Also... when editing the listing I load the text in a text area directly from database and it looks ok in the text area. So you only need the nl2br() when printing the text on screen.
  13. Hello, I do not know what is the best practice to do this, how do other scripts/sites do this? I have a downloads site with categories and users are subscribed to receive emails when a category has something new uploaded. The site might need to send let's say 10 000 emails to different users when a new file was uploaded. If on upload page I will have a loop that will repeat the mail function 10 000 times... - Will that work? - Or the user that submitted the file will need to wait on that upload page too long for 10 000 emails to be sent? - Or is it a good practice to add all emails in a database and send them later and maybe in smaller groups? How do others do this? Thanks. Adrian.
  14. After I duplicated the "full path" of file upload fields so I can access it, I found that you cannot set a default path to file (in file upload fields) so I will have to drop the idea. As I said I wanted to set the default value in that form if user previously submitted an upload form but he was sent back.
  15. Thanks for the replies. So I understand the best way is to create another hidden form field and to copy the value from file field to this hidden field. Will this work? Anyone knows how the JavaScript for this should look?
  16. I need a way to find the full path of a file uploaded by file upload form box. $_FILES['file1']['name'] gives just file name. I have a file upload form and if the user submitted something wrong I want the page to go back and have the forms maintain its values (the full path to local file, e.g: "c:/docs/landscape.jpg"). Any way to do that? This is a more complex applications so using another upload tool is not an option. Any ideas? Thanks. - Adrian.
  17. I think I got it, the problem was that I was trying to rewrite in the same directory, it seems to work ok in other directories. Thanks for your help. - Adrian.
  18. That line and many other combinations I try makes it print the file name (index.php) because in index.php I only have echo $_GET['word']; so (that I can see if it works), the line you mentioned shows the right word that I type in url, the one without slash prints "index.php". Maybe the problem is in php/apache settings? But in static site urls (without htaccess) if I do not type the slash it redirects me to the same url with slash at end, it does this by default. Any other ideas? Thank you.
  19. I tried this just now, It still works with the slash but if I do not enter the slash at end I get: Not Found The requested document was not found on this server.
  20. Hello. I have this rule: RewriteRule ^(.*)/ index.php?word=$1 Meaning that site/index.php?word=Adrian is also shown at site/adrian/ But how do I make it work without the slash at end too? site/adrian I thing this should be simple but this is my first attempt with URL rewrite. Thank you.
  21. Hello. I have aphoto gallery that was changed to have frendly URLs like gallery/cat6.htm instead of gallery/category.php?cat=6 I would like to change somehting and I dont know what code to edit for this, I want to have teh category name instead of the category number inside the url gallery/cat6.htm so that it becomes like this: gallery/lamborghini.htm (car site). Can somone tell me what lines I need to change for this? I dont have any experience with the url rewrite. This is the php code modified to allow friendly urls and its .htaccess file. I appreciate any help you can offer. In case you want to see the gallery I am talking about this is www.TheEngines.com/gallery/ Thanks. - Adrian. /* ORIGINAL CODE function url($url, $amp = "&") { global $l; $dummy_array = explode("#", $url); $url = $dummy_array[0]; if ($this->mode == "get" && !preg_match("/".SESSION_NAME."=/i", $url)) { $url .= preg_match("/\?/", $url) ? "$amp" : "?"; $url .= SESSION_NAME."=".$this->session_id; } if (!empty($l)) { $url .= preg_match("/\?/", $url) ? "$amp" : "?"; $url .= "l=".$l; } $url .= (isset($dummy_array[1])) ? "#".$dummy_array[1] : ""; return $url; } */ function url($url, $amp = "&") { global $l, $user_info; $dummy_array = explode("#", $url); $url = $dummy_array[0]; $url = str_replace('&', '&', $url); if (!defined('IN_CP')) { if (strstr($url, 'index.php')) { $url = str_replace('index.php', './', $url); } elseif (strstr($url, 'search.php')) { if (strstr($url, 'page=')) { preg_match('#page=([0-9]+)&?#', $url, $matches); if (isset($matches[1])) { $split = explode('?', $url); $url = $split[0]; $query = @$split[1]; $url = str_replace('search.php', 'search.'.$matches[1].'.htm', $url); $query = str_replace('page='.$matches[1].'&', '', $query); $query = str_replace('&page='.$matches[1], '', $query); $query = str_replace('page='.$matches[1], '', $query); if (!empty($query)) { $url .= '?' . $query; } } } else { $url = str_replace('search.php', 'search.htm', $url); } } elseif (strstr($url, 'lightbox.php')) { if (strstr($url, 'page=')) { preg_match('#page=([0-9]+)&?#', $url, $matches); if (isset($matches[1])) { $split = explode('?', $url); $url = $split[0]; $query = @$split[1]; $url = str_replace('lightbox.php', 'lightbox.'.$matches[1].'.htm', $url); $query = str_replace('page='.$matches[1].'&', '', $query); $query = str_replace('&page='.$matches[1], '', $query); $query = str_replace('page='.$matches[1], '', $query); if (!empty($query)) { $url .= '?' . $query; } } } else { $url = str_replace('lightbox.php', 'lightbox.htm', $url); } } elseif (strstr($url, 'categories.php')) { if (strstr($url, 'cat_id=') && strstr($url, 'page=')) { preg_match('#cat_id=([0-9]+)&?#', $url, $matches1); preg_match('#page=([0-9]+)&?#', $url, $matches2); if (isset($matches1[1]) && isset($matches2[1])) { $split = explode('?', $url); $url = $split[0]; $query = @$split[1]; $url = str_replace('categories.php', 'cat'.$matches1[1].'.'.$matches2[1].'.htm', $url); $query = str_replace('cat_id='.$matches1[1].'&', '', $query); $query = str_replace('&cat_id='.$matches1[1], '', $query); $query = str_replace('cat_id='.$matches1[1], '', $query); $query = str_replace('page='.$matches2[1].'&', '', $query); $query = str_replace('&page='.$matches2[1], '', $query); $query = str_replace('page='.$matches2[1], '', $query); if (!empty($query)) { $url .= '?' . $query; } } } elseif (strstr($url, 'cat_id=')) { preg_match('#cat_id=([0-9]+)&?#', $url, $matches); if (isset($matches[1])) { $split = explode('?', $url); $url = $split[0]; $query = @$split[1]; $url = str_replace('categories.php', 'cat'.$matches[1].'.htm', $url); $query = str_replace('cat_id='.$matches[1].'&', '', $query); $query = str_replace('&cat_id='.$matches[1], '', $query); $query = str_replace('cat_id='.$matches[1], '', $query); if (!empty($query)) { $url .= '?' . $query; } } } else { $url = str_replace('categories.php', 'cat.htm', $url); } } elseif (strstr($url, 'details.php?image_id=')) { if (strstr($url, 'image_id=') && strstr($url, 'mode=')) { preg_match('#image_id=([0-9]+)&?#', $url, $matches1); preg_match('#mode=([a-zA-Z0-9]+)&?#', $url, $matches2); if (isset($matches1[1]) && isset($matches2[1])) { $split = explode('?', $url); $url = $split[0]; $query = @$split[1]; $url = str_replace('details.php', 'img'.$matches1[1].'.'.$matches2[1].'.htm', $url); $query = str_replace('image_id='.$matches1[1].'&', '', $query); $query = str_replace('&image_id='.$matches1[1], '', $query); $query = str_replace('image_id='.$matches1[1], '', $query); $query = str_replace('mode='.$matches2[1].'&', '', $query); $query = str_replace('&mode='.$matches2[1], '', $query); $query = str_replace('mode='.$matches2[1], '', $query); if (!empty($query)) { $url .= '?' . $query; } } } else { preg_match('#image_id=([0-9]+)&?#', $url, $matches); if (isset($matches[1])) { $split = explode('?', $url); $url = $split[0]; $query = @$split[1]; $url = str_replace('details.php', 'img'.$matches[1].'.htm', $url); $query = str_replace('image_id='.$matches[1].'&', '', $query); $query = str_replace('&image_id='.$matches[1], '', $query); $query = str_replace('image_id='.$matches[1], '', $query); if (!empty($query)) { $url .= '?' . $query; } } } } elseif (strstr($url, 'postcards.php?image_id=')) { preg_match('#image_id=([0-9]+)&?#', $url, $matches); if (isset($matches[1])) { $split = explode('?', $url); $url = $split[0]; $query = @$split[1]; $url = str_replace('postcards.php', 'postcard.img'.$matches[1].'.htm', $url); $query = str_replace('image_id='.$matches[1].'&', '', $query); $query = str_replace('&image_id='.$matches[1], '', $query); $query = str_replace('image_id='.$matches[1], '', $query); if (!empty($query)) { $url .= '?' . $query; } } } } if ($this->mode == "get" && strstr($url, $this->session_id)) { $url .= strpos($url, '?') !== false ? '&' : '?'; $url .= SESSION_NAME."=".$this->session_id; } if (!empty($l)) { $url .= strpos($url, '?') ? '&' : '?'; $url .= "l=".$l; } $url = str_replace('&', $amp, $url); $url .= isset($dummy_array[1]) ? "#".$dummy_array[1] : ""; return $url; } THE .HTACCESS: # Begin search engine friendly links code RewriteEngine On #RewriteBase / RewriteRule ^lightbox\.htm$ lightbox.php?%{QUERY_STRING} RewriteRule ^lightbox\.([0-9]+)\.htm$ lightbox.php?page=$1&%{QUERY_STRING} RewriteRule ^search\.htm$ search.php?%{QUERY_STRING} RewriteRule ^search\.([0-9]+)\.htm$ search.php?page=$1&%{QUERY_STRING} RewriteRule ^cat\.htm$ categories.php?%{QUERY_STRING} RewriteRule ^cat([0-9]+)\.([0-9]+)\.htm$ categories.php?cat_id=$1&page=$2&%{QUERY_STRING} RewriteRule ^cat([0-9]+)\.htm$ categories.php?cat_id=$1&%{QUERY_STRING} RewriteRule ^img([0-9]+)\.htm$ details.php?image_id=$1&%{QUERY_STRING} RewriteRule ^img([0-9]+)\.([a-zA-Z0-9]+)\.htm$ details.php?image_id=$1&mode=$2&%{QUERY_STRING} RewriteRule ^postcard([a-zA-Z0-9]+)\.htm$ postcards.php?postcard_id=$1&%{QUERY_STRING} RewriteRule ^postcard\.img([0-9]+)\.htm$ postcards.php?image_id=$1&%{QUERY_STRING} # End search engine friendly links code
  22. I got into an issue: when inside a function and use global $comments_per_page; I get: Parse error: parse error, unexpected T_GLOBAL Why could this happen ? edit: sorry about that, it was because of something else.
  23. Thanks, you are right. (I should have made a quick test for that). I am not familiar with this 'passing by reference' I seen it again today at http://www.php.net/global but I dont realy understand what it is, I am kind of new to php I will try to use "global $variable_name" inside functions (now that I am sure what it does) and see if that fixes my issues. Thank you.
  24. Yes, it is a setting and making it constant as you said could work, but I have more variables to use in same script and I was trying to figure out the way I have to use the other ones too. so if inside a function I add global $comments_per_page and after that I change it's value inside the same function does this mean the variable value is also changed globally? Or only temporary to be used inside that function?
×
×
  • 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.