Jump to content

kittrellbj

Members
  • Posts

    101
  • Joined

  • Last visited

    Never

About kittrellbj

  • Birthday 11/30/1982

Contact Methods

  • Website URL
    http://www.latenitebooks.com

Profile Information

  • Gender
    Male
  • Location
    USA

kittrellbj's Achievements

Member

Member (2/5)

0

Reputation

  1. Thank you for your post on this, that is some very good information and brings in some points that I had not thought about before - one being that I assumed PHP already loaded in everything it needed for SQLite functionality anyway. If it loads it only when called, and if the application uses it in each instance for each user, yes, that could cause a problem. For clarity, I wrote the $_SESSION[$id] part without thinking it would be misconstrued. This would be some constant value unique to each user, such as his username, his ID in the system, or a combination of such values. Of course the session id itself couldn't be used; it's hardly reliable. So, perhaps an architecture in MySQL with file mapping will be best, and all users are contained in a single table, i.e. Maps, which contains the information for each of their projects and maps files to the appropriate directory. I have been thinking that I could keep the users' files outside the public_html directory (or above it, I should say) so that they cannot be accessed through a web browser itself. The only way they could get to the files in that case is if someone was able to get an administrator's password who had root access.
  2. Ugh, this should be in Application Design. Sorry about that, it's been a little while since I've been around.
  3. I am working on a new PHP application (well, a huge revision of an old application), and I have a decision to make. I'd like to get a few thoughts on this decision from more experienced coders before beginning since, if I start one way and finish, it would be troublesome to change methodology after that point. Basically, I have clients that will set up an account on the server and be allowed access to an area where they can upload files, format data, and the software will compile all this together into a package for them based on a cron job's packaging instructions. The cron is more or less a queue controller to keep the system from getting bogged down since part of the service is free to use. Oh, I'm getting off on a tangent... Here's the crossroads that I'm at now: - The plan is to create a database of some kind for each user to keep their information separate from others. The materials being uploaded/packaged are copyrighted by the account holder, so the need for isolation is paramount (someone can't break into one database and get everyone's copyrighted works, for instance). - The separate databases issue keeps the system from becoming corrupted for everyone in case something goes wrong. I'd much rather deal with one client's corrupted database than having the whole service fall apart because something went wrong for one person. I know that SQLite seems to fit the bill for the above two primary requirements, and it also sounds good for other reasons: - transaction locking for a reader/writer: only one person per database, so they will either be reading or writing at any particular time, and no standing in line waiting for others to get done. I know that it's only milliseconds to perform transactions, but data safety is of the highest importance. - lightweight and can be configured easily. (Well, it's technically already configured with PHP 5 anyway.) - can easily create databases on the fly based on user sessions. (i.e. I can name a database md5($_SESSION[$id]) or something similar to make each page modular very quickly. I don't believe MySQL allows this (easily). - each package can easily be created in its own table. Of course, MySQL is easily capable of this. - the data for each package could go as high as 2 MB into the table if I put all the data in there (but I'm thinking of doing flat files that are mapped from the database instead to keep the database more compact.) The stats for this service will probably be less than 100 users active at any given time, and that is a high-end estimate if it becomes ultimately popular all over the place. Such is the nature of the niche market for this tool and the small community that exists in need of such tools. Any thoughts? Note: I can answer any further questions as they come along, but I can't add any more in this first post. For some reason, this textarea hops back and forth to the top each time I type a letter.
  4. Thanks for the help. I changed the query around to be a little more appropriate: $sql_clean = "SELECT * FROM complete WHERE createdate < CURRENT_DATE() - INTERVAL 3 DAY"; And it works like a charm. Thanks for the help and pushing an old, tired stranger over the finish line.
  5. I am having a little bit of trouble with this piece of code. I'm sure it's something simple, but I have been working on this thing all day and want to get it finally finished. Here's the troublesome code: function rrmdir($dir) { if (is_dir($dir)) { $objects = scandir($dir); foreach ($objects as $object) { if ($object != "." && $object != "..") { if (filetype($dir."/".$object) == "dir") rrmdir($dir."/".$object); else unlink($dir."/".$object); } } reset($objects); rmdir($dir); } } $sql_clean = "SELECT * complete WHERE createdate < date_sub(current_date, interval 1 minute)"; $sql_list = mysql_query($sql_clean); while($row = mysql_fetch_assoc($sql_list)) { $directory = "complete/" . $row['fileurl']; rrmdir($directory); } The purpose of this particular bit is to run on a cron every few days. It gets "createdate" and other info from the "complete" table in order to know how old the record is. If the record is older than (in the example, 1 minute; it will be set to several days on public) the defined max age, it removes that directory and everything within it to keep the directory clean and the disk usage down. The error returned is Line 46 is I may be doing the look-up on the MySQL database incorrectly, too. I haven't discounted that, and I'd be thankful if someone could help me out with this issue.
  6. Just after I wrote this, I found an answer that worked.
  7. I am having more trouble with this than is probably reasonable. Here's what I'm trying to do: 1. Copy text from a word processor (Microsoft Office or OpenOffice) into a .txt file (Notepad, etc.). 2. Convert the .txt file into a .html file. The problem I'm running into is that smart quotes (curly quotes), the long hyphen, and apostrophes are turning into ? in the final document. I've gone around Google trying to locate a solution that will work converting these troublesome characters into regular old double quotes ("), but they don't work. I'm working on a Windows XP machine, using XAMPP as my work environment. Most people submitting the .txt files will be coming from a Windows computer. (I know that Microsoft has done wonders in messing up the encoding system in regards to smart quotes...) I've tried: function convert_smart_quotes($string) { $quotes = array( "\xC2\xAB" => '"', // « (U+00AB) in UTF-8 "\xC2\xBB" => '"', // » (U+00BB) in UTF-8 "\xE2\x80\x98" => "'", // ‘ (U+2018) in UTF-8 "\xE2\x80\x99" => "'", // ’ (U+2019) in UTF-8 "\xE2\x80\x9A" => "'", // ‚ (U+201A) in UTF-8 "\xE2\x80\x9B" => "'", // ‛ (U+201B) in UTF-8 "\xE2\x80\x9C" => '"', // “ (U+201C) in UTF-8 "\xE2\x80\x9D" => '"', // ” (U+201D) in UTF-8 "\xE2\x80\x9E" => '"', // „ (U+201E) in UTF-8 "\xE2\x80\x9F" => '"', // ‟ (U+201F) in UTF-8 "\xE2\x80\xB9" => "'", // ‹ (U+2039) in UTF-8 "\xE2\x80\xBA" => "'", // › (U+203A) in UTF-8 ); $str = strtr($string, $quotes); return $string; } and also <?php function convert_smart_quotes($string) { $search = array(chr(145), chr(146), chr(147), chr(148), chr(151)); $replace = array("'", "'", '"', '"', '-'); return str_replace($search, $replace, $string); } ?> and also trying to display the HTML characters for them instead... <?php $replace = array('‘', '’', '“', '”', '—'); ?> Nothing seems to work. I know it has something to do with the encoding, but I can't seem to figure out a way to replace these little buggers and keep from having a million ? symbols throughout the file.
  8. Not a problem. Please mark as solved so others will know.
  9. On this line: $success = mail($webMaster, $emailSubject, $body, $headrers); Change "headrers" to "headers" and see if that helps.
  10. Using David's proposal you won't even notice that their is a script running so to speak, in contrast to using explode and file which would pull the entire file contents into memory. Yes, I tried it with a very large file on the server, about 5 MB in size. It ran and output the new file in about 12 seconds, and that's with latency time. (From my browser showing the "finished" page and looking into the FTP folder.) Hooking the processor to a Cron and a database will be a piece of cake. I am thinking of running the Cron job every 30 seconds to account for extremely large files being processed, but also to make sure that it doesn't make the people waiting for their conversions wait for very long. On the other hand, I could run the Cron for, say, every 10 minutes or so and process more at that time. I could also process the file at execution if you think that running this script at 50-100 times at a single instance (processing up to 100 MB at a time) would be too much strain for your average server. I know Cron jobs can stress the server, but I'd rather the system be self-sufficient like that so that, on the off-chance that 1000 people submit their 1 MB within the same 5 seconds, the server won't have problems. Of course, the service isn't popular yet - it's a start-up - so the system won't have huge numbers of submissions right off the bat (unless I get very lucky). Any thoughts? Very nice, I appreciate that. This site always has such helpful people, and the people never cease to impress.
  11. Thank you very much, David. That looks like it will do the trick. Also, does anyone think that processing files as large as 2 MB would kill the server? It would only be doing one at a time, of course. Should I chop the files up into chunks or throttle it some other way?
  12. I'll try pulling it in with file(). Explode will probably hang too much on larger files.
  13. I was afraid you were going to say explode. I will start working with the explode option to see how terrible it is at working with files of this size. I suppose I can explode by using the line returns as the delimiter.
  14. Here's what I'm trying to do, and I am having trouble getting started with this. It's a very simple process, but I didn't want to spend the next 6 hours in frustration, so some help getting started would be great. Here's the purpose of the script: 1. Allow user to add a text file to a form. 2. Take the text file, add HTML code to the beginning and end of each paragraph (a single line of text, usually paragraphs would be separated by a line return) 3. Send the user an email with the HTML file attached and thank them or whatever. 4. Allow the system to throttle itself (one-at-a-time) so that many people using the site won't bog it down. These files will probably be anywhere from 100 KB to 1,000 KB in size, usually hitting in the 300-500KB range. Here's what I can do very easily: 1. Allow user to add a text file - very simple and straightforward. 2. Take the text file, add HTML... - this is what I need a little help figuring out. Each paragraph needs to have <p> at the beginning and </p> at the end, and the script will also search for keywords on certain lines (section headers) and add a <align="center"> tag to that, and so forth. I can handle the formatting rules, but making sure the loop runs correctly could be a problem. 3. Send the user an email... - very easy, I can do that myself. 4. Allow the system to throttle itself... - this could be tricky. I was thinking a database with a TINYINT field, 0 for not processed yet, 1 for processing, 2 for processed. Cron job checks the next one on the list to see if it needs to send it to the processor, if the file is already being processed, or can be sent to a different database (completed entries) and removed from the current queue. The cron job would also be responsible for triggering the "Your file is converted!" email and the attachment. Any/all help would be greatly appreciated on this. I am going to work on the parts that I can do myself, and I'll be checking back for the discussion - in between Mountain Dew runs.
  15. Amazingly, this question was just answered in another thread: http://www.phpfreaks.com/forums/css-help/float-layout-fail/
×
×
  • 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.