Jump to content

requinix

Administrators
  • Posts

    15,229
  • Joined

  • Last visited

  • Days Won

    427

Everything posted by requinix

  1. Assuming you don't have a problem getting to the "params" property, The RokCommon_Registry class controls access to its "data" property. An educated guess says that the class will have some method you can call to get the "joomla_articles" value. Get it, unset what you want to unset, then use a corresponding method to set the value back.
  2. That's a bad thing to do. What is the problem you're trying to solve?
  3. There is no "most efficient way". It's like asking what's the most efficient way of opening a door. Or the most efficient way of pushing a button. Your site needs to make sure that people can only do stuff with projects they're involved with, so... you make sure that people can only do stuff with projects they're involved with. Say you've got a page to edit a project. Probably got a project ID in the URL or something. Make sure that you only present the page if the user belongs to the project. As in you do a SQL query to see if there's a record in that third table for the logged-in user and the desired project.
  4. I can't think of anything unique. Not without resorting to something like Java or Flash to get actual computer information. And no, you cannot get the MAC address with Javascript.
  5. I don't know where you are in the book, but the errata (3rd edition) mentions an instance of O(n) on page 26 that's supposed to be O(n^2).
  6. I don't know of an O(n) solution. The "normal" solution would be O(n*m) and a slightly better one would be O(n*log m). $string = preg_filter($pattern, $replacement, $string); // O(1)It's not actually O(1) since you have to consider what that function is doing: loop through the inputs (n) and test the pattern, where the pattern is a set of alternations (m). Thus that's O(n*m), but will be faster than your PHP since it's compiled code. However efficiency isn't determined by runtime but by complexity. The normal solution is like output = "" for each character in input { // O(n) if character is not found in search string { // O(m) output += character } } // O(n*m)The faster solution is sort the search string // O(log m) output = "" for each character in input { // O(n) if character is not found in search string using a binary search { // O(log m) output += character } } // O(n*log m)
  7. ignore_repeated_errors can help with that. Another trick is to use Linux's logrotate: it can keep individual error files small by rotating them: error.log becomes error.log.1 becomes error.log.1.gz and so on. You can have it email you the error file at the same time.
  8. set_error_handler Not quite the same thing but it will let you catch most errors. Not the very fatal ones, though.
  9. Almost. There is a class somewhere named "Table" in the "Cake\ORM" namespace. Odds are it will be in a file Cake\ORM\Table.php (or .class.php or whatever) but that is not always true. Normally to refer to that class in code you would have to write the full path, like $table = new \Cake\ORM\Table();With a use you can tell PHP that any mention of "Table" actually refers to Cake\ORM\Table, so you can write the shorter $table = new Table();
  10. Your browser goes not think that www.xy is a website. It doesn't know the .xy TLD. Use a different domain name, one with a known TLD, or you can probably get away with typing the shorter "www.xy/".
  11. Simply dd-ing won't work if the disk is still in use. Get a boot disc to run a "live" whatever, then dd inside of that. rsync is also popular. Advice: times change. Copy the files you need personally, copy any particular settings you've made for the system and applications, then wait for it to die. Don't worry about making an image of everything. Reinstall stuff as you need it. It's spring cleaning for your computer.
  12. I don't know where valid or obj.office are coming from, but what I meant was a simple document.listingform.office.value == ""
  13. "isset" isn't the thing you're looking for, then. Because the thing exists. Just check for an empty value.
  14. So you're trying to add ? Copy the line for and change it to a capital D.
  15. Did someone forget to install NTP?
  16. When you create the database you don't automatically USE it. Either use fully-qualified table names or call mysqli::select_db (after creating it, of course).
  17. You can't copy to a directory name - it needs to be a file name. You should have gotten an error about that. $temp = '/root_of_the_directory/extracted_files/random_zip_file_or_whatever.zip';I suggest going back to using tempnam() too. Does the code work for any other $remote_file_location, like an image or webpage?
  18. That there is not a valid query. What was probably happening was the "username" column was added and everything after the semicolon was ignored. Use a comma. A comma. You would know that if you bothered to learn SQL. $mySQL = "alter table users add `username` varchar(20) not null, add `location` varchar(100) not null ";
  19. First, New/Edit/Delete user are three different things. Was your description only talking about the Edit portion? Second, I'm not sure about this combobox (I assume you mean a textbox with autocomplete?) being the best way to find a user. If I needed to edit a user, would I want to use a search page first? Often the process is to search for the user to edit, check the search results to see I got the right person, then click a link/button to go to the edit page. Third, AJAX. That's the thing. - AJAX is what lets your Javascript communicate with PHP - JSON is a way of sending data back and forth between the two - Cookies are the things that keep you logged in on websites (among other things they do) but you don't really need to worry about that for this - Headers, again don't need to worry much about those - XML is another way of sending data, but JSON won that battle as far as AJAX is concerned Fourth, rewriting the form. There are a million ways you could do this. What I'm thinking right now is: 1. In your Javascript you keep track of the various form elements and what piece of data they represent (eg, username or email) 2. The AJAX returns a simple blob of data in JSON. Maybe it looks like { "name": "MrScabby", "email": "myscabby@example.com", "phone": "123-555-7890" }3. Use Javascript to update every form element according to the data returned. For example, a textbox corresponding to the name will get the name value. Do this very generically, even if it's just a lot of if the element is a textbox then { ... } else if it is a list then { ... } etc, then apply that to everything you can.
  20. It could very well be that ZipArchive won't work with http:// "files". Like Ch0cu3r said, copy the file to something temporary locally, then extract (and delete the file afterwards). $temp = tempnam(sys_get_temp_dir(), "zip"); if (copy($remote_file_location, $temp) && is_file($temp) && filesize($temp) > 0) { // extract $temp unlink($temp); } else { // error }
  21. The code already tries to do that with ini_set('memory_limit', '1000000M');That's about a terabyte. It was suggestion only to modify that ugly ini_set() line. The memory problem will still be there.
  22. Tip: use -1 for the memory limit if you don't want a memory limit. 1. Where are those AT* lines coming from? 2. Have you used something like memory_get_usage to see where the memory increase comes from? 3. Why did you disable blocking? PHP will soak up CPU until a message comes in. Leave blocking off if you must, but use stream_select to wait for a message to arrive, optionally with a timeout, and only try to recv a message once that returns activity (by looking at the modified $read parameter).
  23. Is it the same amount of time for stuff at the top of the switch (corner moulding) than at the bottom (ceiling-only labor)? Use microtime(true) to see how long things take, like $start = microtime(true); switch($productId) { ... } $end = microtime(true); error_log("switch took " . ceil(($end - $start) / 1024) . "ms");Another thing is to install XDebug and use profiling: it'll measure how long everything takes, dump everything to a file, then you open the file with a program that reads "cachegrind" output and look through to see where the time is going.
  24. You're exit;ing if you want to show the cached version. Which would be alright except you miss out on the rest of the content. Your scheme won't work: for the code after $ch->clone() to run, all the code before it must also run. Which will defeat the purpose of caching. Try something else: move the header/menu thing into its own file, then write a function to either include a file or use a cached version if available (basically what you have now). 1. The header/menu thing has its own file and doesn't actually do anything involving caching or whatever. Just does its header/menu stuff. 2. The main file calls some function, like runfile("header.php"), knowing that one way or another that file's contents will be outputted 3. That function does your caching bit, which it can do by using your cache class or not (I'd do the latter) Also, - That's PHP 4-style code. You're not still using PHP 4, right? - The whole fopen/fread/fclose loop can be replaced with one call to file_get_contents, or readfile since all you're doing is outputting the contents. - You should be using filemtime() for the modification time and not fileatime() for the access time which may not even be supported by the filesystem.
  25. A high temperature would be more like 90C. 60-90C is a fairly wide range to go by, low end is great, high end is when you should try to do something about it. Yeah, I've had "crunches" (vague term) that were caused by wires hitting a fan. Particularly the fan's own wires. I've also had one that had a defect where the blades were actually hitting the sides of the fan.
×
×
  • 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.