-
Posts
15,229 -
Joined
-
Last visited
-
Days Won
427
Everything posted by requinix
-
Proxies. Configure your browser to use one of the millions of free proxies located around the world.
-
Don't rely on the time ranges (presumably 6-8, 8-12, 12-5, 5- to know what they did. What if someone clocked out for lunch after noon? What if they needed to leave early, like 3pm, for a doctor's appointment? What if they came in late, like 9am, or had to work late, like until 10pm?
-
You aren't using date or time properly, probably because you don't know what they do. Read the documentation. When you get the date and time into the right form, the next problem is your query. The date and time will be strings, and strings in queries need quotes. In fact this seems to be another place where you don't quite know what you're working with. After you fix the quotes and the other syntax error, you may find that it's returning far more "alerts" than you wanted it to - your condition says that the date is in the past or the time of day is earlier in the day (which says nothing about the date itself) or that the alert hasn't been sent yet.
-
What's the code? Did you put the £ right in the code? Was the file saved using UTF-8 encoding?
-
If you have to use .call then there's not much you can do because you're forcing yourself to call the function manually. And if you're doing that you might as well just pass e and the string at that time. Anything I can think of involves using more code so that you can use less code - pointless. What's wrong with .proxy? You could use it with event.data like $('#tt').on('click', $.proxy(test.init, test), 'some text as extra param'); var test = { init: function(e) { e.preventDefault(); console.log(e); console.log(e.data); } };Or write a wrapper like test.on('#tt', 'click', 'init', 'some text as extra param'); var test = { init: function(e) { e.preventDefault(); console.log(e); console.log(e.data); }, on: function(selector, event, handler, data) { $(selector).on(event, $.proxy(test[handler], test), data); } };(or for that matter, write a wrapper that uses the .call method)
-
->clientid is null so that's not it. [edit] Oh, the general syntax? Yes, if you decode JSON to an object (the default) then you'd use lots of ->s. [/edit] Starting at ThisUserID and working backwards, - That's the value and the key is "name" - "name" is part of an object in the "customfield" array - "customfield" is an array in the "customfields" object - "customfields" is part of an object in the "product" array - "product" is an array in the "products" object - "products" is at the top level Reversing that gives you the path. $arr->products->product[0]->customfields->customfield[0]->nameThere are two arrays in there. You need to consider whether they will have any objects inside them at all, whether there is only ever one, or whether there could be more than one.
-
I derived this monstrosity for work*: we had arbitrary HTML and I needed to cut it down to a certain number of words, not counting headings, and preserving as much markup as possible. Slightly redacted. For regular use, one would probably want to make a couple adjustments like removing the check for "foo_" and "foohead" (both indicating heading markup). /** * Truncate raw content * * @param mixed $content * @param int $words * @param bool $headings * @return array */ private static function truncateRaw($content, $words, $headings = false) { if(is_array($content)) { $ret = array('content' => array(), 'remaining' => $words); foreach($content as $key => $value) { if($ret['remaining'] <= 0) { if($ret['remaining'] == 0) { $ret['content'][$key] = '...'; } break; } $remaining = $value->truncate($ret['remaining'], $headings); $ret['content'][$key] = $value; $ret['remaining'] = $remaining; } return $ret; } else { $ret = array('content' => '', 'remaining' => $words); if($words <= 0) { return $ret; } // some special content has html comments explicitly marking a preview area if(($pos1 = strpos($content, '<!-- BEGIN PREVIEW -->')) !== false && ($pos2 = strpos($content, '<!-- END PREVIEW -->', $pos1)) !== false) { // 22 for strlen('<!-- BEGIN PREVIEW -->') $len = $pos2 - $pos1 - 22; $ret['content'] = trim(substr($content, $pos1 + 22, $len)); $ret['remaining'] = 0; } else { // cut the text in a way to preserve html tag structure $pieces = preg_split('#(</?(\w+).*?>)#is', $content, -1, PREG_SPLIT_DELIM_CAPTURE); // comes in triplets $excerpt = array(); $tags = array(); $header = 0; // counter for tag depth in headers $state = 0; // piece A: 0=text // piece B: 1=html tag // piece C: 2=open tag name, 3=opening tag name of header, 4=self-closing tag, 5=closing tag name // // A B C // +----+------+------------------------+ // | 0 -|-> 1 -|-> 2 if opening tag -|-> 0 and header++ (if header>0) // +----+------+------------------------+ // | 0 -|-> 1 -|-> 3 if opening header -|-> 0 and header++ // +----+------+------------------------+ // | 0 -|-> 1 -|-> 4 if self-closing -|-> 0 // +----+------+------------------------+ // | 0 -|-> 1 -|-> 5 if closing tag -|-> 0 and header-- (if header>0) // +----+------+------------------------+ // // break text if header==0, otherwise only increase word count // // h1 h2 h1 h0 // 013 0 12 0 15 015 014 012 0 15 0 // <p class="foo_header">Header <b>Text</b> </p> <br /> <p>Content</p> // ^ header ^ not header foreach($pieces as $piece) { // 0. text if($state == 0) { if($header) { if($headings) { $cut = self::cutWords($piece, $ret['remaining']); $excerpt[] = $cut['content']; $ret['remaining'] = $cut['remaining']; } else { $excerpt[] = $piece; $ret['remaining'] -= self::countWords($piece); } } else { $cut = self::cutWords($piece, $ret['remaining']); $excerpt[] = $cut['content']; $ret['remaining'] = $cut['remaining']; if($ret['remaining'] <= 0) { break; } } $state = 1; } // 1. html tag else if($state == 1) { // logic is easier to write in reverse order if($piece[1] == '/') { // closing // closing tag logic will decide when to add itself to the excerpt $state = 5; } else if(substr($piece, -2, 1) == '/') { // self-closing $excerpt[] = $piece; $state = 4; } else if(strlen($piece) >= 3 && $piece[1] == 'h' && ctype_digit($piece[2])) { // normal header $excerpt[] = $piece; $state = 3; } else if(strpos($piece, 'foo_') !== false || strpos($piece, 'foohead') !== false) { // old header $excerpt[] = $piece; $state = 3; } else { // text $excerpt[] = $piece; $state = 2; } } // 2. opening tag else if($state == 2) { $header && $header++; $tags[] = $piece; $state = 0; } // 3. opening header else if($state == 3) { $header++; $tags[] = $piece; $state = 0; } // 4. self-closing else if($state == 4) { $state = 0; } // 5. closing tag else if($state == 5) { $header && $header--; while($tags && $tag = array_pop($tags)) { $excerpt[] = "</{$tag}>"; if($tag == $piece) { break; } } $state = 0; } } // clean up any unclosed tags while($tags && $tag = array_pop($tags)) { $excerpt[] = "</{$tag}>"; } $ret['content'] = implode('', $excerpt); } return $ret; } }The most important thing was that it put tags onto a stack in order to close them out properly when the content gets cut inside multiple tags - I had to deal with things like ULs and tables. OR, instead of all this crazy work deciding how to get a summary: ask the writer to write one. Seriously. It's so much easier and their summary will be nicer than one you come up with automatically. * I don't normally like sharing stuff done for my job, IP rights and whatnot, but we're fairly lax and this is one of those times when there can be significant benefit to the community.
-
No, what you did was tell PHP where it should search for files when you try to include them. Completely different thing.
-
With just ->item, SimpleXML will always get the first element named "item". Use $xmlappend->addChild to create a new item each time, put that in a variable, and add the title and URL to that.
-
Go for an MP4 (which is just a "container" for stuff) using H.264 video and AAC or MP3 audio. Not sure how you did the conversion but make sure you're converting to those formats. Could be you converted without audio, or to an audio codec not supported by WMP or the browser. Is the MOV (preferably) or MP4 (to see what's wrong) online somewhere we can see? Very wrong.
-
Is this not something you can just do manually? Not many good reasons why you should be able to execute arbitrary SQL files on a regular basis. Fewer that require you to use PHP instead of, say, a cronjob.
-
Accessing Values with in a Simple Multidimensional Array?
requinix replied to CoolHandLuke's topic in PHP Coding Help
The firstColor is inside the color array which is inside the $m_array array. $m_array["color"]["firstColor"] -
checking array of data against a database
requinix replied to imperialized's topic in PHP Coding Help
There is an easier way: make sure the tag column is unique and do an INSERT IGNORE with all the tags at once. INSERT IGNORE INTO blogTags (tag) VALUES ("tag1", "tag2", "tag3")which will be easier to do without prepared statements. -
God Himself couldn't get this table to the top of the page
requinix replied to ZandarKoad's topic in PHP Coding Help
Purple? -
What's your full code so far? What have you tried? How did it not work?
-
God Himself couldn't get this table to the top of the page
requinix replied to ZandarKoad's topic in PHP Coding Help
You can't put BRs between table cells like that. The browser has to try to deal with the invalid markup you've given it, and it apparently does so by interpreting those as being placed before the table. -
Just because it uses the same = symbol doesn't mean it works the same way. That does not make sense. Rewrite the expression in terms of X alone. Meaning you have to end up at X = ....
-
What is differences between hostings?
requinix replied to Markds's topic in Other Web Server Software
GoDaddy has nothing to do with that, and if you move then you'll still have that same problem. It has to do with your stuff. Two different things. Can't have a CDN without a backend host, in one form or another. CDNs are about distributing static content by using lots of servers scattered around the world, each with a copy of the files you're trying to serve. With servers closer to the users, yes that means lower latency. A place like the PHP Freaks forums cannot use a CDN for the threads and posts and such because that isn't static, but it can use one for the CSS and images and other files that its pages need that don't change often. No one guarantees 100% uptime. What they will guarantee, if anything, is a certain number of "9s". For example, "five 9s" means 99.999% (which is about 25 seconds of downtime per month, on average). -
They do have permissions, it seems you're just not able to see them. (Must be that the FTP server or client just doesn't want to show you.) Unless you're saying they have permissions 0000, which is a very bad thing. PHP is running as a different user than you, meaning when it creates files and folders they will have a different owner (but likely still 0644/0755). That's something for you to keep in mind: - If the uploads folder was created by PHP then you (via FTP) will not be able to delete or rename or otherwise affect files within that folder... unless you modify the permissions of the files/folder within PHP. But you probably don't need to do that. - If you created the uploads folder then it'll need to be 0777 so that PHP (which is subject to the "other" permission set) can put files in there.
-
Not really. If you wanted better security then you should actually move to a dedicated box - so there aren't other, untrusted users on the same machine. But you probably don't need the added security. As a test of something, do a file upload through PHP and place the file wherever. This can just be a little test script you write quickly. When you look at the file through FTP, what user and group does it belong to?
-
It should already be set up so that everything you create via FTP is owned by you and your group, files are created 0644, and folders are 0755. If you create things via PHP, which includes doing file uploads, then it will be a little different.
-
If it's a shared server, as in shared hosting that you get from some company online, then you don't do anything. The hosting company manages it.
-
The most appropriative way of using data formats
requinix replied to web_craftsman's topic in PHP Coding Help
Don't make it more complicated than it needs to be. Add a column to whatever table you're using to hold the HTML-ready version, alongside the raw BBCode version. Yes, it doubles disk space, but disk space is cheap and plentiful while your time is not. -
Your taught your computer that application/force-download type is a "Wave Sound". The thing that triggers the download is the Content-Disposition header, so leave the Content-Type with the right value. Unfortunately that varies by file, and you probably aren't recording it anywhere accessible. You should install something like fileinfo in order to get the type based on the file contents (your only recourse), but if that's not an option, header("Content-Type: application/octet-stream");the application/octet-stream type is your best option because it has an official meaning, unlike application/force-download (which someone simply made up).