Jump to content


  • Posts

  • Joined

  • Last visited

  • Days Won


Community Answers

  1. requinix's post in Difference between an instance variable inside the class and one outside the class..? was marked as the answer   
    Forums are way better than StackOverflow for anything but the most trivial and straight-forward of questions. Forget trying to discuss anything on SO...
    Yes: the first one allows one and only one instance of the class, while the second allows anyone to create as many as they want.
    Which also means the first one's constructor should be private. Public could be okay but that means two paradigms for the class and that's one too many.
  2. requinix's post in best forum site out there so far, i would like to see a tutorials section appear was marked as the answer   
    But what's to prevent us from having the same "deprecated stuff" problem in a couple years? What could we do to make the tutorial concept actually successful?
    I'm not just making these questions up: I worked on a site that had the exact same idea, and we even got some people to write a few, but writing them is hard so nobody wanted to keep making more and soon the ones that had been made previously fell out of date.
    It's a great idea on paper. It's a difficult idea in practice.
  3. requinix's post in Reading binary (data structures) files help was marked as the answer   
    The one helpful part missing from your post is stating what the correct values are supposed to be. Because e484d857-00b7-4107-a58a-36ff29f6a3a5 looks like a correct GUID to me.
    Typically, though, one deals with binary file data by reading an entire "block" of stuff at once and then unpacking it.
    $data = fread($handle, 52); print_r(unpack("C4header/vversion/vlicense/v2flags/Vnames/Vnameoffset/Vfiles/Vfileoffset/Vtypes/Vtypeoffset/C16guid", $data)); Array ( [header1] => 193 [header2] => 131 [header3] => 42 [header4] => 158 [version] => 127 [license] => 29 [flags1] => 33 [flags2] => 0 [names] => 31 [nameoffset] => 72 [files] => 7 [fileoffset] => 753 [types] => 6 [typeoffset] => 711 [guid1] => 228 [guid2] => 132 [guid3] => 216 [guid4] => 87 [guid5] => 0 [guid6] => 183 [guid7] => 65 [guid8] => 7 [guid9] => 165 [guid10] => 138 [guid11] => 54 [guid12] => 255 [guid13] => 41 [guid14] => 246 [guid15] => 163 [guid16] => 165 )  
  4. requinix's post in How can you generate a sysid with PHP? was marked as the answer   
    I know an application with lots of database tables. Each record has a blargh identifier that is unique across all blarghs in the world. Do you think they're the same as sysids?
    I can't tell you how to create a "sysid". I can tell you about things like UUIDs.
  5. requinix's post in Discord Link was marked as the answer   
  6. requinix's post in php install question was marked as the answer   
    Does Flywheel also have its own web server? Probably does.
    "Correct" is highly subjective. If you want to run both at once then all you actually need to do is make them run on different ports, say 8000 for one of them and 8001 for the other.
  7. requinix's post in Call function/PHP reload every 5 seconds was marked as the answer   
    Any errors in the browser console? Can you see in the developer console the browser making a network request to shipline.php?
  8. requinix's post in SAML SSO php7 app vs Microsoft app eg Teams was marked as the answer   
    Single sign-on means one place that you use to log in. It does not necessarily mean that you use it to sign in once and then nothing has to ask for your account again. In fact it shouldn't: the place with your account should be asking you each time whether you want to allow $app access to your account.
    If you coded the account stuff yourself and you're being asked multiple times then it means your app is not remembering you. If you wanted, you could have it remember you (like with a cookie) so that next time all you'd need to do is click a button to allow access.
    One way or another, you really should make sure that you have to click a button or do something - don't make the authentication completely automatic when a different app wants you to sign in. For example, in addition to remembering you, your site can also remember which apps you've allowed access to: if the same app wants access then that could be automatic, but if a different app wants access then your site should tell you first.
  9. requinix's post in Manage behaviour when comparing values. was marked as the answer   
    The general term is "CAPTCHA". Google's reCAPTCHA and whatever the non-Google alternative is, are the de-facto standards. It takes a little more work to implement but they're effective and reliable.
  10. requinix's post in Implications of final classes and final constants was marked as the answer   
    private + final doesn't make sense: if it's private then nothing can override it anyway. Just make it private.
  11. requinix's post in SQL syntax error (using SELECT FROM INNER JOIN ON WHERE) was marked as the answer   
    No it is not.
    Look at the query in your code:
    $query = "SELECT krs.id_thn_ak ,krs.kode_matakuliah ,matakuliah.nama_matakuliah ,matakuliah.sks ,krs.nilai FROM krs INNER JOIN matakuliah ON (krs.kode_matakuliah = matakuliah.kode_matakuliah) WHERE krs.nim = $nim AND krs.id_thn_ak = $thn_ak"; Look at the query in the error message:
    SELECT krs.id_thn_ak ,krs.kode_matakuliah ,matakuliah.nama_matakuliah ,matakuliah.sks ,krs.nilai FROM krs WHERE krs.nim = 18024114 AND krs.id_thn_ak = INNER JOIN matakuliah ON (krs.kode_matakuliah = matakuliah.kode_matakuliah) They are not the same query.
    Now look at this part of the query that was shown in the error message:
    ...FROM krs WHERE krs.nim = 18024114 AND krs.id_thn_ak = INNER JOIN matakuliah... See why the query does not work?
    Now look at this part of your code:
    $this->input->post('$id_thn_ak', TRUE); Look carefully. Are you sure that is correct?
  12. requinix's post in creating an array list to become $variables was marked as the answer   
    PSA: I will remove any further posts which tell OP how to do the task as-asked. As well-intentioned as the question and its direct answer is, using variable variables is not a good thing.
  13. requinix's post in How can I anchor to a <h1 id="title1"> tag of external url? was marked as the answer   
    I don't see any H2s with ids on the page. You can't link to one of them until they are given ids.
    Why do you not have a page dedicated to showing a single article? You should be linking to that, not to some anchor buried deep on a paginated page.
  14. requinix's post in PDO not working in my function (error: "Undefined variable '$pdo'.intelephense(1008)") was marked as the answer   
    Variables defined outside of functions are not available inside of functions.
    If you need $pdo then pass it as an argument like you're already doing for $id.
  15. requinix's post in Why drawing on canvas resizing/scaling with canvas size? was marked as the answer   
    The width and height of the canvas are different from the width and height of the canvas element. What you've done is resize the element, however it will remain at its default drawable dimensions of 300x150.
    If you want to resize the canvas itself then you need to update its .width and .height.
  16. requinix's post in Null Safe Operator was marked as the answer   
    Fix what? A null will be coerced to false.
  17. requinix's post in storing in SESSION vs dbTable was marked as the answer   
    No. The session is stored on the server so as long as the server isn't compromised then the session data won't be compromised.
    It's like my refrigerator. There's no lock on it so anyone could take and leave what they wanted at any time, so in that sense it's insecure, however the doors to my home are locked so people can't get inside.
  18. requinix's post in How to use namespace in PHP was marked as the answer   
    You'd use namespaces with your classes for the same reason that you'd use directories with your files: because giving each thing some long and complicated name just so that they all stay unique is a pain.
    Practically speaking, if you use underscores in your class names then you're already using namespaces.
  19. requinix's post in Removal was marked as the answer   
    By policy we don't delete accounts, except to comply with laws like GDPR.
    If you don't want to use your account then you can simply not use your account.
  20. requinix's post in Activity was marked as the answer   
    Didn't notice this thread earlier. If you didn't see the answer elsewhere, there were problems with Elasticsearch staying alive: kernel kept killing it due to memory problems. Then a reindex or two.
    Everything seems fine and stable now.
  21. requinix's post in Profile status was marked as the answer   
    I've tweaked some permissions. Do you see editing options in your list of status updates now?
  22. requinix's post in RecursiveIteratorIterator: exclude file was marked as the answer   
    Take a look at your output: the MD5 hash on the left and the value of $element on the right. If you want to skip the md5-container then that would be when $element is...?
    For a more useful solution, if what you care about is when the filename is "md5-container" and not what directory it's in then use a function like basename to get just the filename portion of $element.
    But perhaps a smarter solution would be to not put your md5-container inside the directory you're trying to inspect. Don't have to skip over something if it's not there in the first place.
  23. requinix's post in Warning: hex2bin(): Input string must be hexadecimal string in was marked as the answer   
    You should find another tutorial: the code they've convinced you to use is... well, it's silly. It pointlessly uses encryption for something that doesn't need to use encryption.
    If you want a remember me cookie then all you need is to store a long random token in your database and associate it with the user - preferably in one-to-many form so the user can have multiple tokens for multiple devices. Store it in the browser with the Secure and HttpOnly flags. Then, every time the token is used to log someone in, you generate a new token and replace the old one.
  24. requinix's post in Differences between "#.exa" and only ".exa" was marked as the answer   
    * means any element.
    div.font only applies to DIVs with a "font" class while .font applies to any type of element with a "font" class.
    # is for IDs.
    These are fairly basic CSS questions...
  25. requinix's post in Coordinate Grid Mapping (Battleship) was marked as the answer   
    I'm not really sure what the complexity is here, but I'm also not sure quite what it is you're trying to get.
    So you have an image with pixel dimensions WxH. You want to place circles on there, but I guess you don't want to place them on individual pixels but rather on grid "cells" to reduce the number of locations. So like a 100x100 image could be split into 10x5 cells (each is 10x20 pixels), reducing the number of locations from 100*100=10000 center points to 10*5=50 center points.
    Easy answer? Generate the set of cells you want to choose from, shuffle the set, then go through the first <?> of them and draw the circle appropriately.
    $cells = []; for ($x = 1; $x <= CELL_COUNT_X; $x++) { for ($y = 1; $y <= CELL_COUNT_Y; $y++) { $cells[] = [$x, $y]; } } shuffle($cells); for ($i = 0; $i < NUMBER_OF_CIRCLES; $i++) { list($x, $y) = $cells[$i]; // draw circle on the cell at ($x,$y) }  
  • 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.