-
Posts
15,229 -
Joined
-
Last visited
-
Days Won
427
Everything posted by requinix
-
Use phpMyAdmin or MySQL Workbench or something to connect to your database manually. So that you can do things yourself, not through code. Find where you can run a SQL query directly and run those two queries I wrote. Then post the output of each. Or, alternatively, just tell me what the names of the columns are in both tables and what type of data (eg, VARCHAR or DATETIME) each one is. The SHOW CREATE TABLE queries I posted are a quick way of doing exactly that, but it's only quick if you can actually run the queries somewhere.
-
... What is the structure of the eventhost and "wharehouse" tables? Easiest way to answer would be with a SHOW CREATE TABLE: SHOW CREATE TABLE eventhost; SHOW CREATE TABLE wharehouse;
-
//7 Retrieve Results from ResultSet $row = mysql_fetch_array($queryResult); That is where you get a row of data from the query. That row should have whatever value you need. Do a print_r($row);if you're not sure what's in it (hint: it mirrors the table columns). To redirect, you already have the header() so you just modify it accordingly. One thing, though: header() does not stop your code from executing, so since you actually want it to then you should exit;immediately after.
-
Safest option would be one each, but what's important is that the value changes somewhat frequently.
-
Pretty much, yeah
-
That's not something that happens without you specifically telling PHP to do it. So how did you set that up? Did you remember to do that on the Windows hosting?
-
Because you aren't going to log into MySQL yourself. It's for the code, and if you ever need to know what it is you can simply go into the code and find it. There's not a whole lot, regarding MySQL specifically. Make sure your users have as limited access as you can get away with: simple read and write users shouldn't need to create databases or alter tables, for example. There aren't really security settings in the config files...
-
Relax, it's the weekend. Not surprising. You're actually downloading the file twice, in a way: once from the storage server to the web server, and again from the web server to the user. That requires supporting content ranges in your code. You can tackle that after dealing with your download problem. There's not much point to having a server storing files if you don't have it serving the files to users. Just a glorified hard drive but without the good performance. Implement a sort of protection on that server. There are a few ways you could do it - here's two: 1. Create an "API" where the web server calls an API on the download server, gets a unique and temporary ID, then uses that in a URL which it gives to the client. That URL downloads the file but only works for a short time. 2. A time-sensitive signed URL. In the URL to the download server (that you give to the client) you include a timestamp and a hash a few bits of information: the file being downloaded, the timestamp, and a secret identifier. The download server calculates the hash by itself and then compares that to what it was given (and of course checks that the timestamp is still recent enough to be allowed). http://download.example.com/path/to/file.ext?timestamp=1234567890&hash=abcdefgI'd go for #2 myself.
-
how to "select" an item into a another software
requinix replied to kabar916's topic in PHP Coding Help
COM only works if the software was specifically written to support it. And for some PoS... er, POS... software, that's very unlikely. I don't think PHP can help you here. -
Maybe because $1 and $2 are not valid variable names?
-
Strict Standards: Only variables should be passed by reference
requinix replied to toppi24's topic in PHP Coding Help
Upgrade. Smarty 2.6.10 is obscenely old. I'm amazed you have it at all. -
Warning: preg_match(): Delimiter must not be alphanumeric or backslash
requinix replied to toppi24's topic in PHP Coding Help
preg_match() is for regular expressions. You are not using regular expressions. stripos is all you need. -
Silly typo. That line should be $filetype = 'application/vnd.ms-outlook'; That's the basic premise of MIME type detection: read a few bytes from the beginning of the file and look them up in a database. With that code, the "database" is simply "do the first 9 bytes match this known string", and if that's true then the detection result is application/vnd.ms-outlook. finfo is using a more comprehensive database, naturally. It apparently has those same 9 bytes (maybe fewer) except it maps those to be the application/CDFV2-corrupt type. So the idea is to check your own "database" first, since you know that to be accurate, and if there's no match then use the general purpose, 99%-accurate finfo.
-
(Threads merged.)
-
Not to brush you off with a dismissive "RTFM!" but Header Field Definitions X-File-Name and X-Mime-Type are custom fields that the uploading code presumably understands and knows to look for. X-Requested-With is basically always "XMLHttpRequest", for AJAX.
-
It may very well appear to be a "application/CDFV2-corrupt" file too, whatever that is. If it's not giving you the answer you want then you can do the MIME magic yourself pretty easily. $h = fopen('test.msg', 'rb'); $magic = "\xD0\xCF\x11\xE0\xA1\xB1\x1A\xE1\x00"; $bytes = fread($h, strlen($magic)); fclose($h); if ($bytes == $magic) { $filetype = 'application/CDFV2-corrupt'; } else { // use finfo }
-
That took a long time. Here's the first one, I need to go to bed. XML 1. In SimpleXML, what are the four basic rules for how an XML document is accessed? (Four answers.) a. Properties are [elements, or more precisely,] element iterators b. Numeric indexes are elements c. Non-numeric indexes are element attributes d. Converting an element to a string gets its text data e. Element namespaces are denoted by the ‘namespace’ attribute 2. SimpleXML objects can be created *directly* from what types of data sources? (Three answers. Yes, three.) a. A database resource b. A URI c. A DOMDocument object d. An array e. A string 3. What is the primary benefit of an XML reader based on SimpleXML compared to one based on the DOM classes? (Not a very good question.) a. All of the specified options b. Easier to develop a reader c. Requires less memory than DOM e. Faster than DOM methods 4. Event-based XML parsing is an example of which parsing model? (I have no idea what this is asking about.) a. XQuery b. XPath c. XML object naming d. DOM e. SAX 5. PHP 5 supports which of the following XML parsing/reading methods out-of-the-box? (Two or three answers, depending how you consider it.) a. XPath b. DOM c. FastDOM d. SimpleXMLElement 6. Which of the following will display the HREF attribute? (One answer.) $sxml = simplexml_load_string('<html><body><h1>please go <a href = "http://yahoo.com"> http://yahoo.com</a></h1></body></html>'); a. echo $sxml->body->h1->a['href']; b. echo $sxml->body->h1->a<href>; c. echo $sxml->h1->a->href; d. echo $sxml->body->h1->a->href; 7. What XML technology can be used to combine two XML documents in one? (One answer.) a. Namespaces b. Transformations c. DTD d. Validators 8. Replace the ???? to print "hello world" - with no leading/trailing whitespace or markup. (Probably one answer - I would have to check myself.) $xmldata = ' <?xml version="1.0" encoding="utf-8"?> <html> <body> <p> <b>hello world</b> </p> </body> </html> '; $sxe = simplexml_load_string($xmldata); $p = $sxe->body->p; $string = // ??????? print $string; a. strip_tags(($p->asXML())) b. trim(($p->asXML())) c. trim(strip_tags(($p->asXML()))) d. trim(strip_tags(($p->asText()))) e. trim(($p[1])) 9. Creating new nodes in XML documents using PHP can be done using...? (Two answers.) a. DOM b. SimpleXML c. XPath d. XQuery
-
find x with grep recursively - and open the file afterwards
requinix replied to Maze's topic in Miscellaneous
What do you mean by "open the file"? In an editor? vim (and surely emacs) accept multiple files as arguments and you can switch between them. grep -r "texthere" . | xargs vim -
Rather than have getPrice() do a query, and then have other methods doing their own queries, just do one query at the very start to get all the information at once. Store that in an array inside the object, then make getPrice() just get the one value out of it. class Product { private $data = array(); public function __construct($id) { $this->data = // get all the data for product #id } public function getPrice() { return $this->data["price"]; } }A bit simplistic but that should demonstrate my point.
-
Now we're back to the security thing you mentioned a couple days ago, which is probably unrelated to anything we've been talking about so far. The web server is denying access to that location and/or with the POST method. Can you find any rules or security settings that would explain that?
-
I'm not sure what else to say besides "the filename, but URL encoded". If you weren't sure what URL encoding it, it's basically that %XX stuff you found; the only character you actually have to worry about encoding is the slash - the rest are fine. That was what my first question was for. But it seems you have that sorted out. Yes. As I mentioned above, the period doesn't have to be escaped, but it's fine if it is. If putting the file contents back in there brings the error up again, please post the revised code for it. There's something on the web server blocking PUT. That's unfortunate but whatever, it's not worth messing around with. Change the method back to POST. However add a Content-Type header between the Open and Send. PHP will see that and not try to interpret the request like it normally would (ie, putting stuff into $_POST and such). http.SetRequestHeader "Content-Type", "application/zip"
-
All you did to the uploading code was change that one http.Open line to the new one, right? You also have to substitute "URL_encoded_filename_goes_here", which I wrote in the hopes that you would read that name and realize you were supposed to put the URL-encoded filename there and not just copy/paste it blindly.
-
Instead of having $categories_array[$folder] be an array of filenames, have it be an array of filenames => modification times. That's where you use filemtime(). $categories_array[$folder][$base_file_name] = filemtime('files/' . $folder . '/' . $file);After the files loop finishes (and before you move onto the next folder), asort the $categories_array[$folder] array.