Jump to content

requinix

Administrators
  • Posts

    15,229
  • Joined

  • Last visited

  • Days Won

    427

Everything posted by requinix

  1. What? $query = <<<SQL //set NOCOUNT ON /*optional*/ SELECT cast(h1.Weeknum AS varchar) +'|' +cast(h1.Year AS varchar) +'|' +QUOTENAME(CASE WHEN Cty.CountryName = 'Singapore' THEN 'SG' WHEN Cty.CountryName = 'Hong Kong' THEN 'HK' WHEN Cty.CountryName = 'Japan' THEN 'JP' WHEN Cty.CountryName = 'China' THEN 'CN' WHEN Cty.CountryName = 'Indonesia' THEN 'ID' WHEN Cty.CountryName = 'Taiwan' THEN 'TW' WHEN Cty.CountryName = 'Thailand' THEN 'TH' WHEN Cty.CountryName = 'Philippines' THEN 'PH' WHEN Cty.CountryName = 'Macau' THEN 'MO' WHEN Cty.CountryName = 'Malaysia' THEN 'MY' ELSE '' END , '""') +'|' + QUOTENAME(Loc.LocationName,'"') +'|' +QUOTENAME(CASE WHEN Cust.CustomerName = 'McDonalds'THEN'MCD' WHEN Cust.CustomerName = 'Subway' THEN 'SWY' WHEN Cust.CustomerName = 'Oishi' THEN 'OIS' WHEN Cust.CustomerName = 'Shell' THEN 'SHE' WHEN Cust.CustomerName = 'FSB' THEN 'FSB' WHEN Cust.CustomerName = 'Ikea' THEN 'IKE' WHEN Cust.CustomerName = 'Yellow Cab' THEN 'YEL' WHEN Cust.CustomerName = 'PUB' THEN 'PUB' ELSE '' END, '""') +'|'+cast(round(k1.[Value], 0) as varchar) +'|'+'0' -- Tonnage Delivered, assume 0 for now +'|'+cast(k2.[VALUE] as varchar) +'|'+cast(k3.[VALUE] as varchar) +'|'+cast(k4.[VALUE] as varchar) +'|'+'0' -- Deliveries with error, assume 0 for now +'|'+cast(k5.[VALUE] as varchar) +'|'+cast((round(k9.[VALUE]+k1.[VALUE],0)) as varchar) +'|'+cast(round(k7.[VALUE],0) as varchar) +'|'+'0' -- Tonnage Handled, assume 0 for now +'|'+cast(round(k8.[VALUE],0) as varchar) +'|'+'20151130' +'|'+'20151206' FROM [KeyPerformance].[dbo].[KpiDetails] as k1, [KeyPerformance].[dbo].[KpiDetails] as k2, [KeyPerformance].[dbo].[KpiDetails] as k3, [KeyPerformance].[dbo].[KpiDetails] as k4, [KeyPerformance].[dbo].[KpiDetails] as k5, [KeyPerformance].[dbo].[KpiDetails] as k6, [KeyPerformance].[dbo].[KpiDetails] as k7, [KeyPerformance].[dbo].[KpiDetails] as k8, [KeyPerformance].[dbo].[KpiDetails] as k9, [KeyPerformance].[dbo].[KpiHeader] as h1, [KeyPerformance].[dbo].[Customer] as Cust, [KeyPerformance].[dbo].[Location] as Loc, [KeyPerformance].[dbo].[Country] as Cty, [KeyPerformance].[dbo].[CalendarWeekOfYear] as Cal where k1.[KpiHeaderID] = k2.[KpiHeaderID] AND k2.[KpiHeaderID] = k3.[KpiHeaderID] AND k3.[KpiHeaderID] = k4.[KpiHeaderID] AND k4.[KpiHeaderID] = k5.[KpiHeaderID] AND k5.[KpiHeaderID] = k6.[KpiHeaderID] AND k6.[KpiHeaderID] = k7.[KpiHeaderID] AND k7.[KpiHeaderID] = k8.[KpiHeaderID] AND k8.[KpiHeaderID] = k9.[KpiHeaderID] AND k1.[KpiHeaderID] = h1.[KpiHeaderID] AND h1.[CustomerID] = Cust.[CustomerID] AND h1.[LocationID] = Loc.[LocationID] AND Loc.[CountryID] = Cty.[CountryID] AND h1.[WeekNum] = Cal.WeekOfYear AND h1.[Year] = Cal.Year -- AND k1.[KpiHeaderID] = 122 AND k1.[KpiItemsID] = 2 AND k2.[KpiItemsID] = 1 AND k3.[KpiItemsID] = 9 AND k4.[KpiItemsID] = 10 AND k5.[KpiItemsID] = 31 AND k6.[KpiItemsID] = 2 AND k7.[KpiItemsID] = 18 AND k8.[KpiItemsID] = 11 AND k9.[KpiItemsID] = 3 AND h1.Year = '2015' and Cal.WeekofYear = 48 --AND Cal.MonthID = 11; SQL;(huh. okay. pretend there's appropriate highlighting) Doing that would have completely bypassed the quotes problem.
  2. 1. Just post code normally. With the code highlighting. Most people don't bother looking at attachments. 2. Don't post database credentials. Stop what you're doing and go change your password. Right now. $query =" //set NOCOUNT ON /*optional*/ SELECT cast(h1.Weeknum AS varchar) +'|' +cast(h1.Year AS varchar) +'|' +QUOTENAME(CASE WHEN Cty.CountryName = 'Singapore' THEN 'SG' WHEN Cty.CountryName = 'Hong Kong' THEN 'HK' WHEN Cty.CountryName = 'Japan' THEN 'JP' WHEN Cty.CountryName = 'China' THEN 'CN' WHEN Cty.CountryName = 'Indonesia' THEN 'ID' WHEN Cty.CountryName = 'Taiwan' THEN 'TW' WHEN Cty.CountryName = 'Thailand' THEN 'TH' WHEN Cty.CountryName = 'Philippines' THEN 'PH' WHEN Cty.CountryName = 'Macau' THEN 'MO' WHEN Cty.CountryName = 'Malaysia' THEN 'MY' ELSE '' END , '""') +'|' + QUOTENAME(Loc.LocationName,'"') +'|' +QUOTENAME(CASE WHEN Cust.CustomerName = 'McDonalds'THEN'MCD' WHEN Cust.CustomerName = 'Subway' THEN 'SWY' WHEN Cust.CustomerName = 'Oishi' THEN 'OIS' WHEN Cust.CustomerName = 'Shell' THEN 'SHE' WHEN Cust.CustomerName = 'FSB' THEN 'FSB' WHEN Cust.CustomerName = 'Ikea' THEN 'IKE' WHEN Cust.CustomerName = 'Yellow Cab' THEN 'YEL' WHEN Cust.CustomerName = 'PUB' THEN 'PUB' ELSE '' END, '""') +'|'+cast(round(k1.[Value], 0) as varchar) +'|'+'0' -- Tonnage Delivered, assume 0 for now +'|'+cast(k2.[VALUE] as varchar) +'|'+cast(k3.[VALUE] as varchar) +'|'+cast(k4.[VALUE] as varchar) +'|'+'0' -- Deliveries with error, assume 0 for now +'|'+cast(k5.[VALUE] as varchar) +'|'+cast((round(k9.[VALUE]+k1.[VALUE],0)) as varchar) +'|'+cast(round(k7.[VALUE],0) as varchar) +'|'+'0' -- Tonnage Handled, assume 0 for now +'|'+cast(round(k8.[VALUE],0) as varchar) +'|'+'20151130' +'|'+'20151206' FROM [KeyPerformance].[dbo].[KpiDetails] as k1, [KeyPerformance].[dbo].[KpiDetails] as k2, [KeyPerformance].[dbo].[KpiDetails] as k3, [KeyPerformance].[dbo].[KpiDetails] as k4, [KeyPerformance].[dbo].[KpiDetails] as k5, [KeyPerformance].[dbo].[KpiDetails] as k6, [KeyPerformance].[dbo].[KpiDetails] as k7, [KeyPerformance].[dbo].[KpiDetails] as k8, [KeyPerformance].[dbo].[KpiDetails] as k9, [KeyPerformance].[dbo].[KpiHeader] as h1, [KeyPerformance].[dbo].[Customer] as Cust, [KeyPerformance].[dbo].[Location] as Loc, [KeyPerformance].[dbo].[Country] as Cty, [KeyPerformance].[dbo].[CalendarWeekOfYear] as Cal where k1.[KpiHeaderID] = k2.[KpiHeaderID] AND k2.[KpiHeaderID] = k3.[KpiHeaderID] AND k3.[KpiHeaderID] = k4.[KpiHeaderID] AND k4.[KpiHeaderID] = k5.[KpiHeaderID] AND k5.[KpiHeaderID] = k6.[KpiHeaderID] AND k6.[KpiHeaderID] = k7.[KpiHeaderID] AND k7.[KpiHeaderID] = k8.[KpiHeaderID] AND k8.[KpiHeaderID] = k9.[KpiHeaderID] AND k1.[KpiHeaderID] = h1.[KpiHeaderID] AND h1.[CustomerID] = Cust.[CustomerID] AND h1.[LocationID] = Loc.[LocationID] AND Loc.[CountryID] = Cty.[CountryID] AND h1.[WeekNum] = Cal.WeekOfYear AND h1.[Year] = Cal.Year -- AND k1.[KpiHeaderID] = 122 AND k1.[KpiItemsID] = 2 AND k2.[KpiItemsID] = 1 AND k3.[KpiItemsID] = 9 AND k4.[KpiItemsID] = 10 AND k5.[KpiItemsID] = 31 AND k6.[KpiItemsID] = 2 AND k7.[KpiItemsID] = 18 AND k8.[KpiItemsID] = 11 AND k9.[KpiItemsID] = 3 AND h1.Year = '2015' and Cal.WeekofYear = 48 --AND Cal.MonthID = 11;"You have unescaped "s within that string.
  3. First, the condition should have been $x because $dep[$max] is one too far since the array keys will be 0 through $max-1. What he said. The problem is the loop is going too far, right? So don't make it go that far. for ($x = 0; $x and then output the final lat/long pair since the loop didn't reach it.
  4. Sure. Just keep in mind that buying pink tennis balls could mean the user has a dog, car fluid could mean they have a lawnmower, and baby cream could mean they use moisturizing cream. Profiling is nice but only if you get it perfectly right, otherwise you start thinking a 70 year old man is a young single mother. My take after, like, 5 minutes of thought: Store in the database a list of different profiles: woman, sports, dog owner, etc. Each one is tied to a particular PHP class*, implying that testing or invoking the profile will run the code. Then store another list of items with profiles: pink tennis balls -> woman, pink tennis balls -> sports, pink tennis balls -> dog owner, etc. Each class follows a particular interface. interface IProfiledItem { public function __construct(Item $item); public function evaluate(ShoppingCart $cart); }Adding an item fires up the code and has the class decide whether it's an appropriate profile according to the cart. Eventually you've gathered up a bunch of (potential) profiles. * The code approach is faster but takes more effort to maintain over time. Long term, I'd probably try to put much more information in the database so more work can be generalized (eg, "profile A + profile B = profile C" or "item D suggests profile E at 50% and profile F at 20%").
  5. That's not IPN. If $insert_row = $mysqli->query("INSERT INTO BuyerTable (BuyerName,BuyerEmail,TransactionID,ItemName,ItemNumber,ItemAmount) VALUES ('$buyerName','$buyerEmail','$TransactionID','$ItemName','$ItemNumber', '$ItemTotalPrice')");is not executing properly then it means (a) code never reached that statement to begin with or (b) the query failed. You don't really do any logging in there. Add some: log when certain lines are reached, log assorted interesting values, log error messages from MySQL if they come up, log stuff. And test until you figure out precisely what went wrong. Couple obvious things to check out first: 1. Can't connect to the database - probably because you're using default values for the host and username/password. 2. One or more of the values you're trying to insert contain apostrophes which is why your code is vulnerable to SQL injection. Use prepared statements instead of putting values directly in queries like you're doing now.
  6. A single equals sign means comparison; @cum=0 would be saying "is @cum equal to 0". Colon+equals does assignment and will set @cum to 0 in the first part and then add profit in the second part. And yes, the init part is working like the init part in a for loop. for ($cum = 0; ; $cum = $cum + $profit) {You could do the assignment in a separate query beforehand SELECT 0 INTO @cumwhich would be like $cum = 0; for (; ; $cum = $cum + $profit) {
  7. You can put gallery.php anywhere you want. In the main folder makes the most sense. I'm making a couple changes: RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)$ $1.php [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([a-zA-Z0-9_-]+)/?$ profile.php?username=$1 [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^gallery/([a-zA-Z0-9_-]+)/?$ gallery.php?username=$1 [L]1. Note the two (pairs of) RewriteConds: they make sure that you don't accidentally rewrite from an existing file or (more likely) directory.2. Most of the time you should use the [L] flag so that when one rewriting rule matches it will stop processing the rest of the rules and immediately go with the new URL you told it to use. And a suggestion: decide whether you want to officially have trailing slashes or not - don't do both. You can still redirect from one to the other, of course. Something like RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)/$ $1 [L,R=301]should be able to handle redirecting away from a trailing slash for pretty much anything you have. Directories still need the trailing slash so those aren't affected.
  8. Because it isn't using a variable in the first place. All you did was make a string that contains an apostrophe, the word "jobno", another apostrophe, a period, and "xslx". If you want a variable in there then put a variable in there. if (!isset($_POST["jobno"])) { // error: value missing } else if ($_POST["jobno"] == "") { // error: empty value } else if (!ctype_digit($_POST["jobno"])) { // replace with whatever validation you need // error: invalid jobno } else { $jobno = $_POST["jobno"]; } // ... $objWriter->save($jobno . ".xlsx");
  9. Step 0: Fix your HTML and code. - Use type="text/javascript"s on <div id="map_canvas"></div> <div id="map_canvas2"></div>Step 2: Make sure your initialization code can work with particular elements and does not (eg) cause output when executed. Your function already does that with the param1 parameter. Step 3: Exactly what you do here varies by how you want to do it. You said something about the number of maps varying? Then I suggest making your page look like <div id="map_canvas_0"></div> <script type="text/javascript">initialize("map_canvas_0", 51.5403, -2.5463);</script>Repeat that sort of thing for each map to display. "But that doesn't follow the best practice of everything being just before the closing !" True, but the purpose of the best practice is (a) to keep code in a logical place and not scattered around the document and (b) because you can't run code immediately if it uses an element defined later down the page. Reasons behind my suggestion: - Lends itself to being generated in a loop - Puts the code and the map container in very close proximity to each other - initialize() does not set up the map immediately but on load (as it should be) The end result is basically <html> <head> ... <script src="https://maps.googleapis.com/maps/api/js"></script> <script type="text/javascript"> function initialize(canvas, lat, long) { $(function() { // for jquery. use whatever method to cause the function to be executed only after page/DOM load var mapCanvas = document.getElementById(canvas); var mapOptions = { center: new google.maps.LatLng(lat, lng), zoom: 17, mapTypeId: google.maps.MapTypeId.ROADMAP }; var map = new google.maps.Map(mapCanvas, mapOptions); }); } </script> </head> <body> <div id="map_canvas_0"></div> <script type="text/javascript">initialize("map_canvas_0", 51.5403, -2.5463);</script> <div id="map_canvas_1"></div> <script type="text/javascript">initialize("map_canvas_1", 41.5403, -2.5463);</script> </body> </html>
  10. Great. Then. Get PHPMailer, write code to send an email according to their documentation, and then use that if block you have to set the right To: address.
  11. So is your question about how to send emails? Get yourself a copy of PHPMailer and read through their documentation. It's pretty easy to use.
  12. And there it is. See, the "url" param, and thus the $url variable, and thus the $urls array, contains a string of all the URLs. That's no good. Your code needs an array of individual URLs, not all of them bunched together. 1. You copied and pasted that 'http://www.dallascowboys.com/rss/video', 'http://www.dallascowboys.com/rss/gallery', 'http://www.dallascowboys.com/rss/audio', 'http://espn.go.com/blog/feed?blog=nfceast', 'https://sports.yahoo.com/nfl/teams/dal/rss.xml',into the textarea. You, as a user, need to fix that so it becomes http://www.dallascowboys.com/rss/video http://www.dallascowboys.com/rss/gallery http://www.dallascowboys.com/rss/audio http://espn.go.com/blog/feed?blog=nfceast https://sports.yahoo.com/nfl/teams/dal/rss.xmlOne URL for each line. No extra apostrophes or commas or anything. Make sure your form has instructions to do that. 2. Now you know each line is a URL. Supposedly. IMO the best way to get the individual URLs out of it is to try to locate a valid URL on each line, which gives you some freedom about leaving blank lines and such: $url = $params->get('url'); // beginning of line, maybe whitespace, a "http://" or "https://" url, maybe more whitespace, then the end of the line if (preg_match_all('/^\s*(https?://\S+)\s*$/im', $url, $matches, PREG_PATTERN_ORDER)) { $urls = $matches[1]; } else { // did not find any urls $urls = array(); }3. Now that you have $urls set you don't need /********* Feeds *********/ $urls = array($url); /********* Feeds *********/
  13. Assuming you had $url = $params->get('url'); print_r($url); echo '<div id="wrapper" style="margin-top:1px;">'; echo '<ul id="ticker">';that means $url is actually the string 'http://www.dallascowboys.com/rss/video', 'http://www.dallascowboys.com/rss/gallery', 'http://www.dallascowboys.com/rss/audio', 'http://espn.go.com/blog/feed?blog=nfceast', 'https://sports.yahoo.com/nfl/teams/dal/rss.xml',which is no good. How is the "url" parameter being set? Can you make it an array of strings?
  14. Here's the thing: with /********* Feeds *********/ $urls = array($params->get('url')); /********* Feeds *********/$urls is guaranteed to be an array containing one single item. That contradicts the first output you gave. As for the second, there is no "$url" in the code you posted so I don't know where its value is coming from.
  15. Well, first step is figuring out the exact value of $urls... print_r($urls);
  16. "lol /b/'s attacking me but I have mad hacker skillz I can see them coming from 'localhost' lol watch me ddos them back wtf why is my computer so slow guys stop it's not funny anymore"
  17. ...What do you think "localhost" is? [edit] No, wait, this isn't going to work. localhost is always the computer who is trying to look up what "localhost" is. If I click a link to http://localhost/image1.jpg then localhost is my computer. If your server tries to download that image to itself then localhost is your server. What you're saying doesn't make sense. You cannot block localhost. Localhost is yourself. You are localhost. Are you trying to stop hotlinking in general? If so then forget all this "localhost" stuff.
  18. Huh. Linux typically handles Unicode filenames well. Are you absolutely sure the file is named correctly? Do you have shell access? SSH to the server, make sure your client is set to use UTF-8 encoding, and do an ls of the directory to see if the file is called Š.php.
  19. All the work happens in the bprs function. So that needs to change. You're using jQuery, right? Your second loop, which puts everything together using &s and =s, can be replaced with a call to $.param(), as long as the first loop creates an object that looks like { data: [ { name: "name 1", credits: 1 }, { name: "name 2", credits: 2 }, ... ] }So the first loop becomes like var rowCount = $('#accountsTable tr').length; var accountsCount = rowCount -1; var accountsData = []; for (var n = 1; n <= accountsCount; n++) { accountsData.push({ name: $('#accountName' + n).text(), credits: $('#credits' + n).text() }); }and the second loop goes away and becomes simply var data = $.param({ date: new Date(), data: accountsData });
  20. RewriteEngine on #force to https RewriteCond %{HTTPS} =off [OR] RewriteCond %{HTTP_HOST} !=www.example.com.au RewriteRule ^ https://www.example.com.au%{REQUEST_URI} [L,R=301] #Remove php from page RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ $1.php [L,QSA]
  21. Ah yes, the [L] flag. You may know that it means "last" as in "this is the last rule and stop processing anything else", but that's not quite accurate. It means to actually stop evaluating rules for this pass. If you rewrite to something else, Apache will probably send that new URL through its request processing procedure, which involves bringing up the .htaccess with its rules one more time. So what happens is 1. You rewrite /example to /example.php 2. mod_rewrite stops processing and "returns" to Apache 3. Apache gets the new URL (/example.php) and begins to handle that 4. Your .htaccess comes into play again and the "force to https" action kicks in 5. The user is then redirected to the HTTPS version of /example.php Pretty easy way to fix this: do external redirects before internal redirects. Switch the two rule bits around.
  22. Name your inputs either a) accountName[n] and credits[n] b) accounts[n][name] and data[n][credits] I'd suggest the second. Then your PHP looks like $contents = $mystring . "..."; $n = 1; $accounts = array(); foreach ($_POST["accounts"] as $account) { $accounts[] = "<strong>Account {$n}</strong><br>({$account['name']})<br>CREDITS<br>{$account['credits']}"; } $contents .= implode("<br>-<br>", $accounts);
  23. Looks like something is calling date_i18n() with a $unixtimestamp that isn't a number... Do you have any ideas where that may be? Look for a place that's showing bad date strings.
  24. Maybe it's me but that code seems quite confusing. You can make this really simple: 1. If page > 1 then show 2. For loop from 1 to current page - 1: show link for page 3. Show "link" for current page 4. For loop from current page + 1 to last page: show link for page 5. If page > link for last page 1, 3, and 5 are pretty obvious. For 2 and 4, it's possible for a loop to not even execute depending on what the current page is. Consider if the current page is 1 and the pages are 1-4: 1. Page is not > 1 then do not show 2. Loop from 1 to 0: show link (links: none) 3. Current page (links: 1) 4. Loop from 2 to 4: show link (links: 1, 2, 3, 4) 5. Page is > link (links: 1, 2, 3, 4, >>)
  25. No. Okay: 1. What would happen if I went to http://example.com.au? 2. What would happen if I went to https://example.com.au?
×
×
  • 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.