Jump to content

Leaderboard


Popular Content

Showing content with the highest reputation since 07/21/2019 in all areas

  1. 2 points
    the path being used in the opendir() statement either has a hard-coded '/home/sites/' in it or is using a variable that has that incorrect value in it. based on the path where the code is actually at, that part of the path should be - /home/customer/www/
  2. 2 points
    Store the info that the user put in the original QR code. User retrieves and edits the data, then generates new QR code.
  3. 1 point
    I saw nothing in the documentation to explain this, and I'm confident that this is both concrete5's fault and something that they should fix. For you, a) Create a CSS file for overriding this kind of stuff, define a new font-family like "Glyphicons Halflings 2" with correct srcs, and override .ccm-ui .glyphicon and whatever else to use the corrected font-family b) Fix the concrete5 files directly
  4. 1 point
    Perhaps you can make use of the get_class() function
  5. 1 point
    Unfortunately, there is no perfect answer. Every "spam" system can have different things it looks for to determine what is spam. If there was a simple list of things to do, then every spammer would do those things so their email would not wind up in spam. You will want to do some research, but here a a few things to consider: 1. The server sending the email should be an "authorized" sender for the domain in the from address. In this case you are using Gmail to send an email on behalf of 'bidsoliciationapp.com'. There are ways to change the MX records (similar to DNS records) to authorize a server for a particular domain. But, I think that would require reaction from Google as well if you want to use your current configuration. You may need to use a Google from address or use a dedicated emailing service that can help with the right configuration. Of course, that would cost money. I only understand these things tertiarily, so some of my 'facts' may be slightly off. 2. The name of the domain could be problematic with words such as "bids", "solicitation" could raise a red flag. 3. Content: I would not start with a "Hello Bob, please click <here> . . . " It just seems like something I would see in a Spam email. I don't know if that is part of the problem or not. What you can do: Set up an account with a few different email providers and send some samples of your current emails to them to see if any are flagged as spam. If so, then change the content to something completely innocuous. Does that go through w/o being detected as Spam? If yes, then you know it is the content causing the detection. If not, then it is likely something to do with the configuration/meta data.
  6. 1 point
    Composer creates an autoload file that you can include at the top of your PHP scripts instead of having to include every package individually. Then you just have to use them as if they're classes that you've included. https://getcomposer.org/doc/01-basic-usage.md#autoloading Example from site. require ( __DIR__ . '/vendor/autoload.php'; $log = new Monolog\Logger('name'); $log->pushHandler(new Monolog\Handler\StreamHandler('app.log', Monolog\Logger::WARNING)); $log->addWarning('Foo');
  7. 1 point
  8. 1 point
    An egregious understatement of what Composer does is that it downloads files. If you need to reference some of those files in your application, notably Javascript or CSS or other client-side assets, then yes: you still have to code that into your application. The bit that Composer does automatically is for PHP classes, which is to create a single file you can include (again, you have to make your application do it) that will automatically pull in whatever classes the libraries provide. To learn how to use x3dom, I suggest starting with the tutorial.
  9. 1 point
    You need to learn the difference between arrays and strings. The first is an array of arrays, the second is an array of strings containing numbers and commas Array ( [0] => Array ( [0] => 1 [1] => 5 [2] => 6 [3] => 7 [4] => 8 [5] => 9 ) [1] => Array ( [0] => 2 [1] => 7 [2] => 6 [3] => 5 [4] => 4 [5] => 3 ) [2] => Array ( [0] => 3 [1] => 12 [2] => 13 [3] => 14 [4] => 15 [5] => 16 ) ) Array ( [0] => 1,5,6,7,8,9 [1] => 2,7,6,5,4,3 [2] => 3,12,13,14,15,16 )
  10. 1 point
    The 2 things have nothing to do with each other, but I will say this about SQL Injections. Forget about mysqli_real_escape_string or any attempt to escape anything, and use parameters. Use parameters and bind the values. This eliminates the possibility of SQL Injections, because no interpolation is being done, and you also no longer have to care about escaping quotes or other characters special to SQL. https://www.php.net/htmlspecialchars is something you can use to combat XSS, or https://www.php.net/manual/en/filter.filters.sanitize.php. For XSS the best solution is to store the input in the DB as is, and then do your filtration/conversion when you are going to present the string on your site/within your application.
  11. 1 point
    @Techbriefers - Brilliant! The way you managed to repeat what Psyco posted 14 hours earlier, removing all structure and readability and fitting the query into a single line, shows sheer genius.
  12. 1 point
    I would be interested to know WHY you are wanting to do this. What are these "duplicate" records for and if their data is the same as the 'parent' why do you need to refer to the parent for the data? Also, since each element doesn't have a defined index I'm not sure how you want to make the reference. Do you just want to store the first element value (e.g. '10') in the child element? This would be a lot easier to work with if the elements also had named indexes. Anyway, here is a possible solution. Note, once you run this IF you change one of the referenced values in a parent element it WILL be reflected in the child elements. function mapArrayReferences(&$inputArray) { //Create array to map unique value sets $mappingAry = array(); foreach($inputArray as $elementKey => $element) { //Remove the first element off the array array_shift($element); //Create a hash of the remaining array $hash = md5(implode("|", $element)); //Check if the hash already exists in the mapping array $parentKey = array_search($hash, $mappingAry); if($parentKey !== false) { //Change the current element values to refer to parent $inputArray[$elementKey][1] = &$inputArray[$parentKey][1]; $inputArray[$elementKey][2] = &$inputArray[$parentKey][2]; $inputArray[$elementKey][3] = &$inputArray[$parentKey][3]; $inputArray[$elementKey][4] = &$inputArray[$parentKey][4]; } else { //Add new parent to mapping array $mappingAry[$elementKey] = $hash; } } return; } Usage $dataAry = array( array("10", 25, 31, "Yes", "No"), array("20", 21, 18, "No", "No"), array("30", 11, 47, "No", "No"), array("40", 14, 60, "No", "No"), array("Ten", 25, 31, "Yes", "No"), array("dix", 25, 31, "Yes", "No"), array("twenty", 21, 18, "No", "No") ); //Map child elements to parent element values mapArrayReferences($dataAry); //Change a parent element value $dataAry[0][2] = 99; print_r($dataAry); Output
  13. 1 point
    The method I was suggesting with that link to the php manual was $sql="SELECT * FROM test LIMIT 10"; $result = mysqli_query($con,$sql); $data = $result->fetch_all(MYSQLI_ASSOC); echo json_encode($data); However you can traverse the $result object as you suggest $sql="SELECT * FROM test LIMIT 10"; $result = mysqli_query($con,$sql); $data = []; foreach ($result as $row) { $data[] = $row; } echo json_encode($data);
  14. 1 point
    This looks totally mixed up right not really, this is just a guess from you what "banking website"? As you don't seem to be firm with the technology, i would think it's not YOUR website, more like the website of the bank you are customer at. and the website is accessed via URL - that has plain nothing to to with any "folder" as i think you mean from a filesystem - except that there's a common fallback. And the syntax for a URL is documented: https://en.wikipedia.org/wiki/URL#Syntax
  15. 1 point
    It sounds like it would be more efficient to make [#][0] the key of sets of subarrays . Then you can go straight ot the ones you want instead of repeatedly searching the whole array. array ( [string] => array ( array (int, int, string, string), array (int, int, string, string), array (int, int, string, string), array (int, int, string, string) ), ... [string] => array ( array (int, int, string, string), array (int, int, string, string), array (int, int, string, string), array (int, int, string, string) ) );
  16. 1 point
    I don't understand what you want, post a reproducible example.
  17. 1 point
    Protecting a form field from what? htmlspecialchars() is for use when outputting user-supplied data data to a web page. mysql_real_escape string() is was used to protect input values to queries from SQL injection. This is now obsolete, replaced by mysqli_real_escape_string() or (better still) the use of prepared statements to completely separate the query code from the user-supplied data.
  18. 1 point
    Seems like you figured out that you needed to find where the $base variable was being set, and change that. Congrats on figuring it out, and on behalf of the the others who aided, you're most welcome.
  19. 1 point
    Your problem is that you're adding extra keyup handlers each time a field changes. Look at your code: $(".ui").change(function(){ myResult.keyup(function(e) { //... }); }); That says, every time an element in .ui changes, add a keyup handler to myResult. So on your first pass, as you enter your inputs you're adding a key up handler to every input. On your second pass, you end up adding yet another key up handler to every input so your handler function ends up running twice. On a third pass, you'd add another so your handler runs three times. ... Combine that with your global state variables and you get a mess. When you enter the right value your first handler changes myResult and m to a different input. Then your second handler looks at that new input value and sees that it doesn't match the next sequence value and shows an error. You need to remove the change handler and just add a single keyup (or keypress) handler. Ideally you'd find a way to rely on global state variables less as well.
  20. 1 point
    Massive MASSIVE thank you guys, that fixed it! 😀😀😀😀
  21. 1 point
    Don't screenshot code. Post the code using the code icon (<>) and select PHP.
  22. 1 point
    To add to what Mac said, usually there are some configuration files involved. We have no way of saying for sure without code to look at, but a typical strategy would be to set up a variable or constant that contains the site root. Mac helpfully highlighted the differences for you. You should do a search through the source files for '/home/sites' and make sure that is replaced with '/home/customer/www'. Sometimes these configurations are stored in database tables, so that might be the problem if it's not hardcoded. There is no way for us to know for sure again without looking at some of the sourcecode for the site.
  23. 1 point
    There are many methods. A simple one is to store a last modified time with the data. It should be updated when the data changes, and it would be best if it was handled automatically by the database (and all database software can do that) so you don't have to worry about it. Include the current modification time in the edit form as a hidden input so that when your script processes the form, it can check if the modification time from the form still matches the one in the database. If the times don't match then you show the form back to the user with some appropriate message. An improvement is to have the page periodically check with the server to see if there were changes. You can then present that to the user when it happens and the user can do what they want. Keep in mind if you are periodically checking that it might be user A makes their changes just before user B tries, so your form code still has to check for modifications before it saves; the checks on the page are to help make the user's life a little easier, not yours. Another method is to detect the actual changes made by the user, which means you have to remember what the data was - probably with hidden inputs. When user B changes the dateRun, you can tell from the original data that the dateRun in the database hasn't changed so it's safe to update that field. This is more complicated, so better suited if you expect multiple users to be editing the same object at the same time somewhat frequently, but don't expect them to be editing the same fields in the object. The most professional solution is first to understand why you have multiple users editing the same thing. You have both a technical problem of overwriting changes but also a human problem of two people probably not knowing what the other is doing. Which means you can't truly fix this until you can resolve both problems.
  24. 1 point
    You would need to involve javascript. You could do this almost all in javascript then do an ajax call to send the data to php. Here's a guide that shows how to listen for sound and make a reactive page. It should give you an idea of how to start. https://hackernoon.com/creative-coding-using-the-microphone-to-make-sound-reactive-art-part1-164fd3d972f3
  25. 1 point
    It's unclear to me what exactly your goal is, but most likely the answer is no. PHP doesn't really have the ability to play sounds or listen for sounds. Try and clarify what your end goal is and maybe some better help could be provided. For example, are you talking making a web page with a stop watch, or some CLI script?
  26. 1 point
    In other words, if you have a problem with your code then you should probably post your code.
  27. 1 point
    Either of these functions will do what you want, and without you having to recreate the wheel.
  28. 1 point
    IF you don't understand what I said above, take a fresh look at the code I provided you earlier and read it carefully and try to understand what you are doing differently.
  29. 1 point
    It's not. Here. Yes. Here. Admittedly, I'm asking you to think a little when it comes to some of it, but ... really? Beyond that, Barand has been his typical self and gone above and beyond the call of duty to answer your questions in no uncertain terms and with concrete code examples; yet there are more requests to simply do it for you.
  30. 1 point
    How about <script type="text/javascript"> $( document ).ready(function(){ ccmatrix = $("#ccMatrix"); var form = $("<form/>", {action: '#',method: '#'}); for(i=0; i<3; i++) { for(j=0; j<3; j++) { cname = "col"+j // class name for each column $(ccmatrix).append($("<input/>", { type: 'text', class: 'result ' + cname, name: 'u_i', tabindex: j*3+i, value: j*3+i, autofocus: j+i==0 })); } $(ccmatrix).append('<br>'); } }); </script> <style type="text/css"> .col0 { background-color: #ff11aa;} .col1 { background-color: #aaff11;} .col2 { background-color: #11aaff;} .result {text-align: right; width: 50px; padding: 4px; margin: 8px } </style>
  31. 1 point
    You're looking to avoid inline styles, correct? If so, the following line of code doesn't really change anything: $("input[tabindex = "+ind+"]").css('backgroundColor', clr); You'll still end up with the style attribute attached to each individual input tag. Instead, you could define classes (as suggested by Barand) for your colors. I would name the classes based on whatever each color represents. To apply the class names to the input fields, you could use the .addClass() method. More informaiton can be found here: https://api.jquery.com/addClass/ Basically, you would define a variable like you did for "clr". Maybe the variable would be named something like "clrClass", which would be set to whatever class names you decide to use. So basically, the following lines would be replaced with the new variable and class names: if(ind<3) clr = '#ff11aa'; if(ind>=3 && ind<6) clr = '#aaff11'; if(ind>=6 && ind<=9) clr = '#11aaff'; Then use your tabindex method like the following: $("input[tabindex = "+ind+"]").addClass(clrClass);
  32. 1 point
    Or you could have just said: $cat_name = str_replace('&', 'and ', strtolower($cat_name)); No need to define arrays for this purpose nor to create a second field to hold category name.
  33. 1 point
    try <script type="text/javascript"> var colors = [ 'red', 'green', 'blue', 'yellow', 'cyan', 'magenta', 'orange', 'coral', 'khaki' ] $( document ).ready(function(){ ccmatrix = $("#ccMatrix"); var form = $("<form/>", {action: '#',method: '#'}); counter = 0; for(i=0; i<3; i++) { for(j=0; j<3; j++) { var clr = colors[j*3+i] $(ccmatrix).append($("<input/>", { type: 'text', id: 'result', name: 'u_i', size: '1px', tabindex: j*3+i+1, autofocus: ( j*3+i+1==5 ), // set focus on 5th when page loads style: 'background-color:'+clr+'; color:white; text-align:right; font-weight:600' })) } $(ccmatrix).append('<br>'); } }); </script>
  34. 1 point
    Using my original code with the addition of "tabindex" attributes to control the input order ... $( document ).ready(function(){ ccmatrix = $("#ccMatrix"); var form = $("<form/>", {action: '#',method: '#'}); counter = 0; for(i=0; i<3; i++) { if(i===0) clr = '#ff11aa'; if(i===1) clr = '#aaff11'; if(i===2) clr = '#11aaff'; for(j=0; j<3; j++) { $(ccmatrix).append($("<input/>", { type: 'text', id: 'result', name: 'u_i', size: '1px', tabindex: j*3+i+1, style: 'background-color:'+clr })) } $(ccmatrix).append('<br>'); } });
  35. 1 point
    Did you try anything yourself? Like https://duckduckgo.com/?q=php+qr+code+reader
  36. 1 point
    I would use grid. Using the data-pos="n" attribute selector in CSS and JS you change the color as you want. You could also just use the IDs in the linked fiddle if that's easier. You could also use the nth-of-type() selector in CSS to cut down on the typing if you want.
  37. 1 point
    $('input').css({backgroundColor: '#aaff11'}); means set all "input"s to this background color - so they all get the same value on each call. try $( document ).ready(function(){ ccmatrix = $("#ccMatrix"); var form = $("<form/>", {action: '#',method: '#'}); counter = 0; for(i=0; i<3; i++) { if(i===0) clr = '#ff11aa'; if(i===1) clr = '#aaff11'; if(i===2) clr = '#11aaff'; for(j=0; j<3; j++) { $(ccmatrix).append($("<input/>", { type: 'text', id: 'result', name: 'u_i', size: '1px', value: j*3+i+1, style: 'background-color:'+clr })) } $(ccmatrix).append('<br>'); } });
  38. 1 point
    You should do this with Javascript and canvas, not PHP. But you'll still have to come up with the math to do what you want. I'm thinking parametric equations. Fun stuff.
  39. 1 point
    So you need a QR code reader.
  40. 1 point
    As gradients come in two flavours - linear and radial, then good luck with that.
  41. 1 point
    from one of your previous threads on this forum - if (IS_LOGGED == false) { header("Location: " . PT_Link('login')); exit(); } or more simply - if (!IS_LOGGED) { header("Location: " . PT_Link('login')); exit(); } this of course assumes that the code producing the IS_LOGGED defined constant is consistently being used and exists before the code you have posted. a feature like controlling who can view a certain page, like the profiles, should be part of the user permission system. does this code have a general purpose user permission system in it?
  42. 1 point
    I would use class names instead id names. It simplifies iteration. I would also use the money_id as the index in the input fieldname for the qty. $result = [ ['money_id' => 1, 'money_item' =>'Item A', 'money_value' => 300, 'money_qty' => 10 ], ['money_id' => 2, 'money_item' =>'Item B', 'money_value' => 500, 'money_qty' => 10 ], ['money_id' => 3, 'money_item' =>'Item C', 'money_value' => 1000, 'money_qty' => 10 ], ['money_id' => 4, 'money_item' =>'Item D', 'money_value' => 1500, 'money_qty' => 10 ], ['money_id' => 5, 'money_item' =>'Item E', 'money_value' => 2000, 'money_qty' => 10 ] ]; echo "<table>"; foreach ($result as $row){ $mid = $row['money_id']; echo "<tr>"; echo "<td style='width:70%;'>".$row['money_item']; echo "<input type='hidden' class='moneyValue' value='{$row['money_value']}' data-id='$mid' ></td>"; echo "<td class='text-center'><input class='Qty up text-center' value='{$row['money_qty']}' name='moneyQty[$mid]' type='text' data-id='$mid' ></td>"; echo "<td><span class='moneyTotal' data-id='$mid' >Total</span></td>"; echo "</tr>\n"; } echo "<tr><td colspan='2'>Total</td><td id='grandtotal'>Grand Total</td></tr>\n"; echo "</table>\n" When you process the POSTed data you can then just foreach ($_POST['moneyQty'] as $mid => $moneyQty) { // now you have the id to retrieve price from database // as you process each quantity } Javascript <script type="text/javascript"> $().ready( function() { calcLineTotals() $(".Qty").change( function() { calcLineTotals() }) }) function calcLineTotals() { var gtot = 0 $(".Qty").each( function(k,v) { // foreach element of class "Qty" var mid = $(v).data("id") // get its data-id var qty = $(v).val() // get the qty var price = $(".moneyValue[data-id="+mid+"]").val() // get price from moneyValue element with same data-id $(".moneyTotal[data-id="+mid+"]").html(qty * price) // put total in total element with same data-id gtot += qty* price // accumulate grand total }) $("#grandtotal").html(gtot) // put grand total in element with id = grandtotal } </script>
  43. 0 points
    Looks like multiple linear and/or radial gradients. How are you at math? You'll need some. More than some.
This leaderboard is set to New York/GMT-04:00
  • Newsletter

    Want to keep up to date with all our latest news and information?
    Sign Up
×
×
  • 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.