Jump to content

kicken

Gurus
  • Posts

    4,704
  • Joined

  • Last visited

  • Days Won

    179

Everything posted by kicken

  1. $baseimage, $w, and $h do not exist inside your function. You need to pass them in as additional parameters. function stacklayer($baseimage, $w, $h, $folder, $layer) { $newlayer = imagecreatefrompng($folder . '/' . $layer . '.png'); imagecopy($baseimage,$newlayer,0,0,0,0,$w,$h); imagedestroy($newlayer); } Then include them when you call your function. $baseimage = imagecreatefrompng("Base.png"); $w = imagesx($baseimage); $h = imagesy($baseimage); stackLayer($baseimage, $w, $h, 'Layer1', 'Image1');
  2. The npm package doesn't provide a compiled single-file to use. If you want to use it, you'd probably need to use something like webpack to compile everything into a single file for use on your site. Alternatively, there is a jquery-ui-dist package that contains the compiled output and you can just include it like you normally would.
  3. If you have a form element named Submit and it is included in the submitted data and it has a non-empty value, then sure you can do that. That's a lot of if's though compared to just use $_SERVER['REQUEST_METHOD']. One of your echo statements is outside of your check for if the data is posted. You only define the variable inside that if statement, so if the if is skipped because the page was not posted to your variable will be undefined.
  4. You might read through this MDN article on Responsive Images. You can use the srcset attribute to provide different images to display for different resolutions and the sizes attribute to determine which of the options to display for a given screen size. Have your CSS code then scale the images to the right size by setting their width to 100%. If you start with an image equal to or slightly larger than the screen size, then let the browser scale it down you shouldn't loose much in terms of image quality and still maintain a full 100% with image.
  5. It's not, for what it's worth. You can tell by looking at the Server API: line in the phpinfo() output. Yours says: Server API Apache 2.0 Handler If you were using FPM, it would says Server API FPM/FastCGI So if you want to use FPM you need to adjust your configuration for apache to do so. If you don't really care, then just make sure you edit appropriate php configuration file. Having code in the page won't help with issues that prevent the page from running in the first place such as your syntax errors. For that the settings must be configured in the php.ini file. After making changes in the php.ini file, you need to reload the configuration by reloading/restarting the apache service.
  6. I've no experience with Laminas or any other common ACL package, but based on a quick look at the Laminas site here's some thoughts. It would need to be unique with an ACL. If you wanted to have separate ACLs for your Project/Document/Something else entities you could do that and use the entity IDs directly. Otherwise, you'd need to augment them in some way. One relativly simple way might be just to combine it with the entity class name, eg: class Document implements ResourceInterface { private $id; //Entity ID from database public function getResourceId():string{ return self::class.'#'.$this-id; } } This ties into your question #2, you need to persist the acl in a way that you can query against it easily. This obviously means you can't just serialize the the ACL and stick it into the DB. Sure, that's possible according to the docs, but not very useful for any decently large system. The solution you linked I don't think is for the ACL specifically, just entities in general using the Laminas framework, but you could make your ACL configuration into various entities and use whatever solution you have currently to save and load them. The resource id could be split into separate fields in the table that you can query against, for example: select * from documents d inner join acl_resource res on ar.type='document' and ar.entity_id=d.id ... I don't remember if you were using symfony or not in your project, but if so note that it has it's own ACL bundle you could consider. It's a little more integrated I think which could be good or bad, I don't know. Like I mentioned, I haven't actually used any of these.
  7. You need to ensure you only run your UPDATE query if the user has submitted the form. Unless there's something you're not showing it looks like you're currently running it when the edit.php page is first loaded. At that point, $_POST will be empty so all your variables are empty and you update the record to all empty values. Use $_SERVER['REQUEST_METHOD'] to check if the request was a POST request and only run the query if so.
  8. Create a script that you can run every minute and it will check if there are any expired requests. If there are it will do the "move on to the next rider" stuff. Once that is working, create a cron job/scheduled task to execute that script every minute.
  9. Your connection object is the $dbh variable you create in your connect method and then return. That variable is only accessible in your connect method though, not your addUpdate method. As a result, where you have your lastInsertId call $dbh is null and you'll get an error. Since you're returning $dbh from your connect method, you can save it to the same variable name in your addUpdate method by splitting your connect call from your prepare call like so. $dbh = $this->connect(); $statement = $dbh->prepare(' INSERT INTO tblScheduleUpdates (updSuccess) VALUES (?)'); Now your $dbh variable is defined and you can use it to call the lastInsertId method.
  10. select coalesce(acs.acs_read, app.ap_read) as read, coalesce(acs.acs_modify, app.ap_modify) as modify, coalesce(acs.acs_administer, app.ap_administer) as administer from app left join acs on acs.acs_app=app.ID and acs.acs_usr=$user where app.ID=$app This will give you the value in acs if it exists. If no row exists it will fall back to the value in app. If a row in acs exists with ap_read=0, then the user would be denied read even if ap_read=1. If that's not what you want you will need to adjust things.
  11. Wrapping the call to drawImage in a setTimeout fixed the problem in my tests. I'd guess you need the delay to give the browser a chance to render the image before you can draw it.
  12. Yes. CURLOPT_POSTFIELDS is only for doing POST requests. For GET you just include the parameters in the URL's query string. You do that by adding a ? followed by the parameters in name=value&name=value2 format with proper url encoding applied. PHP has a function to build the appropriate string from an array of parameters: http_build_query. Use that and concatenate the result to the URL. 'https://geo.fcc.gov/api/census/area?'.http_build_query($data);
  13. @foxcloneNothing you've posted here would explain that output being included in the downloaded file. It's coming from somewhere else in your code that you haven't posted so there's really nothing anyone here can do to help you more at this point. You need to re-examine every scrap of code that is run when you make a download request and try to track down where that output is coming from.
  14. Then you probably have a var_dump somewhere outputting that which you have not shown in your code here.
  15. That's why I showed using xxd to get a hex dump of the file contents and then diff'ing that and not the files directly. That way you can actually see what the differences are.
  16. Look at the contents of the two files and see what the difference is. xxd foxclone50_amd64.deb >original xxd downloaded_foxclone50_amd64.deb >downloaded diff original downloaded
  17. Here: $ext = pathinfo($filename, PATHINFO_EXTENSION);{ // Get file extension //---------------------------------------------^ if ($ext == '.iso') header('Content-Type: application/x-cd-image'); elseif ($ext == '.gz') header('Content-Type: application/zip'); else header('Content-Type: octet-stream');} //---------------------------------------^ header("Content-Disposition: attachment; filename={$filename}"); header('Pragma: no-cache'); header('Expires: 0'); readfile($filename); That pair of braces is unnecessary. For a while I only noticed one of them and was wondering why you weren't getting a syntax error with the code.
  18. If I download a file with your code and compare the downloaded file's sha1 hash to the original's sha1 hash they are the same. Are you sure you're doing to comparisons correctly? There are a few things you should fix with your code. Your formatting needs work. You have a pair of {} that are unnecessary and hard to even see. Your if/elseif/else blocks should have {} around them for readability. The way you indented your code makes it look like all your headers are part of the else branch but only one of them actually is. You should add code to disable output buffering or you might hit memory errors on large files. You should add a Content-length header so the browser's download progress bar works. function mydloader($filename=NULL) { if (isset($filename)) { $filename = preg_replace("/\s+/u", " ", $filename); // Make sure no hidden characters in filename $ext = pathinfo($filename, PATHINFO_EXTENSION); // Get file extension if ($ext == '.iso'){ header('Content-Type: application/x-cd-image'); } elseif ($ext == '.gz'){ header('Content-Type: application/zip'); } else { header('Content-Type: octet-stream'); } header("Content-Disposition: attachment; filename={$filename}"); header('Pragma: no-cache'); header('Expires: 0'); header('Content-length: '.filesize($filename)); if (ob_get_level()) { ob_end_clean(); } readfile($filename); } else { echo "isset failed"; } }
  19. If you want the footer to be at the bottom of the view port on a short-content page, that's kind of a different problem. In the past this was somewhat more complicated to do and involved various tricks and browser quirks but these days you can use flex or grid layouts to accomplish it without too much trouble. I adapted your code to a flex layout as an example: @charset "utf-8"; html, body { width: 100%; height: 100%; margin: 0; padding: 0; } div.wrapper { display: flex; flex-direction: column; height: 100%; width: 80%; margin: 0 auto; } div.top { position: sticky; top: 0; left: 0; flex: 0 0 33px; border: 0px solid #e1e1e1; background-color: #339966; box-shadow: rgba(0, 0, 0, 0.16) 0px 3px 6px, rgba(0, 0, 0, 0.23) 0px 3px 6px; border-radius: 7px; } div.center { flex: 1 1 calc(100% - 66px); } div.bottom { position: flex; flex: 0 0 33px; border: 0px solid #e1e1e1; background-color: #339966; box-shadow: rgba(0, 0, 0, 0.16) 0px 3px 6px, rgba(0, 0, 0, 0.23) 0px 3px 6px; border-radius: 7px; } div.inset { margin: 2%; border: 0px solid #e1e1e1; box-shadow: rgba(0, 0, 0, 0.16) 0px 3px 6px, rgba(0, 0, 0, 0.23) 0px 3px 6px; border-radius: 7px; } HTML: <!doctype html> <html lang="NO" class="size"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" href="style.css"> <title></title> </head> <body class="padding"> <div class="wrapper"> <div class="top"> <div>&nbsp;XXXXX-Top Bar</div> </div> <div class="center"> <div class="inset"> <div class="green">XXX-Float Column 1</div> <div class="blue">XXXX-Float Column 2</div> </div> </div> <div class="bottom"> <div>&nbsp;XXXXX-Bottom Bar</div> </div> </div> </body> </html>
  20. Box-shadow should work in conjunction with border-radius to create a rounded shadow at the corners. Margin is generally how you'd go about getting space between two div tags that are next to each other. If you're doing something like a fixed-position / absolute positioned header then margin may not work as you'd expect though. You should post a complete example with the html and css you have, possibly as a fiddle link like I did above.
  21. Could change the code to render the envelope backwards? Are you trying to create a page the size of the envelope or just a normal page with envelope details printed in a specific place? Does anything change if you save the pdf to a file and then print it with adobe reader rather than from the browser?
  22. @kirkdickinsonIf you haven't noticed it yet, there is a warning that shows on your main page when the variable is not set: Warning: Undefined array key "con" in xxx/index.php on line 45 If you want to fix this, change this line in your page: $id = $_GET['con'].$ext; To this: $id = ($_GET['con']??'main').$ext;
  23. When require fails it reverts the files. As such, your new package wouldn't be considered when you did the install and you just end up back in the same situation again. Doing the require first allows composer to resolve everything while taking that new package you want into consideration. I think what the original error was trying to say is that the new package you want to install needs doctrine/dbal in the v2.7.0, ..., 2.13.7 but you currently have doctrine/dbal 3.3.2 installed and it's refusing to downgrade it automatically. Re-running with the --with-all-dependencies flag as it suggested probably would have worked as well.
  24. Disclaimer: I've not done any work with multiple currencies so I may be missing something You can normalize the data, you just do it differently and at different times. When inserting the data, normalize it to a fixed-point integer or decimal notation. Pick a point that gives you the precision you need and scale everything to that. In your table the most precise currency is 3 decimal places, so you could use that as your precision. $50.45 would become 50450 and ¥227 would become 277000. Your php code can deal with enforcing rules like JPY can't have decimals. Then when querying your data, you can have another table that stores the exchange rate from whatever $currency to your standardized currency. Join that able when querying your results and multiple the rate to get your standardized price and sort by that. drop temporary table if exists payment; create temporary table payment ( id int not null auto_increment primary key, amount bigint not null, currency char(3) not null ); insert into payment (amount, currency) values (50.45*1000, 'EUR') -- 50.45 EUR , (277*1000, 'JPY') -- 277 JPY , (50.45*1000, 'MXN') -- 50.45 MXN , (50.45*1000, 'RUB') -- 50.45 RUB , (5.045*1000, 'TND') -- 5.045 TND , (50.45*1000, 'USD');-- 50.45 USD drop temporary table if exists exchange_rate; create temporary table if not exists exchange_rate ( currency char(3) not null primary key, rateNumerator bigint not null, rateDenominator bigint not null ); insert into exchange_rate (currency, rateNumerator, rateDenominator) values ('EUR', 11276, 10000) , ('JPY', 00871637, 100000000) , ('MXN', 0486747, 10000000) , ('RUB', 0130442, 10000000) , ('TND', 346070, 1000000) , ('USD', 1, 1); select p.id, p.amount, p.amount/1000.0 as decimalAmount, p.currency, floor((p.amount*xr.rateNumerator)/rateDenominator) as usdNormalizedAmount, ((p.amount*xr.rateNumerator)/rateDenominator)/1000.0 as usdDecimalNormalizedAmount from payment p inner join exchange_rate xr on xr.currency=p.currency order by usdNormalizedAmount
  25. There is no align: property for CSS. For aligning inline elements like an image you want text-align:
×
×
  • 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.