Jump to content

All Activity

This stream auto-updates     

  1. Today
  2. Hi I use bootstrat treeview which is build upon a databse query. I have no idea how many nodes will apear at the treeview. I limit its size by using min-height and overflow-y:scroll in the css file it all looks good when the nodes are folded. but when i open a node it exceed the limit i declared. Does anyone has an idea how can i limit the height of the treeview no matter if nodes are expanded? Thank you
  3. I prefer using pdf-puppeteer for this job. It requires NodeJS but otherwise is fairly easy to setup. I uses a headless chrome instance to render the HTML into PDF so it supports fairly modern CSS (but not necessarily bleeding-edge). Render your template out to a temp file then pass that to the script to generate the PDF. Use a short JS script like this to handle the PDF generation const fs = require('fs'); const pdf = require('pdf-puppeteer'); const args = process.argv.slice(2); if (args.length < 2){ console.log('Usage: html2pdf source destination [options]'); process.exit(20); } const source = args[0]; const options = args.length === 2?JSON.parse(args[1]):{}; fs.readFile(source, 'UTF-8', function fileReadSuccess(err, data){ if (err){ throw err; } pdf(data, callback, options); function callback(pdfData){ console.log('PDF Data length: ' + pdfData.length); } }); Kick off the process with PHP using exec(). $cmd = $this->createCommandLine($source, $destinationPdf); exec($cmd, $output, $ret); if ($ret !== 0){ throw new \RuntimeException('Failed to generate PDF with command [' . $cmd . ']'); } $pdf = file_get_contents($destinationPdf);
  4. I've used barryvdh/laravel-dompdf before and I was pleased with it. But don't go into this thinking you can use the latest HTML and CSS standards. PDFs do not work like webpages. You may have to resort to using older styles of markup and formatting.
  5. You cannot change the RewriteRule and also not change it 😉 If you want to support /shareboard/login -> controller=shareboard, action=users, id=login, then add a new RewriteRule to do that. That's all it takes. Because it's okay to have more than one of these as long as they match different URL patterns. When you do that, please clean them up so less stuff is optional. Because you have a problem with being too flexible on what you're matching. Try going to some invalid URLs and see what happens.
  6. I feel like I should let you know: if I ever see you call me out in your threads, I do not reply to them.
  7. Thanks all, I will try it out and will reply once successful.
  8. Thanks! I get error 127, path not found indeed. I tried, exec('swetest'); exec('./swetest'); exec('/public_html/se/swetest'); Neither works. ps. i see google is full of exec error 127 If i dump it all in the server root i still get 127 so something must be fishy in the path?
  9. Thanks for confirming my theory.
  10. Then you need to check a few things. Use the third parameter to get the exit-code and see what it is. Typically 0 would mean success, anything else would be an error. There are two ways a program can output text, either via STDOUT, or STDERR. By default only STDOUT is captured. To capture STDERR as well you need to redirect it to STDOUT. This is done by adding 2>&1 to the end of your command. It's generally best to use a full path to the executable as your script may be running with a different $PATH value than you're normal shell.
  11. It doesn't appear to be used. It might just be there for consistency sake with the sw_id array. If both array's are auto-generated somewhere than it might have just been easier to keep two lists of pairs and dump them to an array rather than one list of pairs and one list of values only. I would have just written this to use either a 2d array or array of objects rather than this flattened array approach. It's unnecessarily hard to understand as written.
  12. Sorry, yes, you're right, i tried that however. I get array(0) { }
  13. If you look at the manual page for exec you'll see that it returns just If you look at the arguments list, you'll see there are two additional arguments you can pass to exec So if you want the full output, you need to pass a variable as the second argument and it will be filled with the output. exec('swetest -h', $output); var_dump($output);
  14. I have the following javascript that I am trying to reverse engineer: function set_sw(row) { var i; var ofs = ofs_sr + row * 6; var sel_var = document.forms[0].elements[ofs + 5]; // Use the sw_id table to get the ID and the user-friendly name sel_var.options[0] = new Option("None", "None", false); for (i = 0; i < sw_id.length; i += 2) { sel_var.options[i/2+1]=new Option(sw_id[i+1], sw_id[i], false); } // Set the option if (sel[row * 2 + 1] == "") { sel_var.selectedIndex = 0; return; } for (i = 0; i < sw_id.length; i += 2) { if (sel[row * 2 + 1] == sw_id[i]) { sel_var.selectedIndex = i/2 + 1; return; } } } My question is how the array 'sel' is being used? That array appears to be used as pairs of values. var sel = [0,"170000001A5EA905",0,"910000001A7F2A05"]; var sw_id = ["910000001A7F2A05","910000001A7F2A05","170000001A5EA905","Test"]; I am trying to understand where/how the first element of each pair is being used. It appears to me that it is not used but it seems strange then that it is there. I'm hoping some new eyes can help. Can someone tell me if and where it is being used in that script? TIA.
  15. By referencing the file system path to the file or by defining an included files folder in your php.ini file.
  16. Yeah, must be tough. I was only in my 50s when I started learning PHP.
  17. Post the code that's giving the problem. We are not clairvoyant.
  18. Yes If the drop down was malfunctioning, there was something else wrong with the code. Perhaps one of the tags was missing or coded incorrectly. All the above "Select here" code does is create a new option in the drop down so that neither "Yes" or "No" is the default selection, which is a good way to make sure the user actually makes a selection. They have to actually to interact with the drop down to answer the question. That depends on the tutorial. Most tutorials don't talk about everything a reader needs to know in order to do something. Otherwise too much time will be spent on trying to explain the basics before they can get to the topic the tutorial was designed for. Or maybe this was beyond the scope of the tutorial. If the tutorial was about creating a simple form, for example, they are not going to go into ever facet of an HTML form. There would be too many things to discuss for a single tutorial.
  19. Hello, I can't get exec() working with a binary, but it works with whoami, the binary also outputs on a plain linux machine. I have error reporting E_ALL enabled but i can't find anything usefull in the logs. What can i do? Thanks for helping. See pic for the output of the script, whoami works but swetest gives nothing. I know it works, it is in use elsewhere on servers. <?php if (ini_get('safe_mode')) echo 'safe mode is on<br>'; else echo 'safe mode is off<br>'; if (function_exists('exec')) echo "exec is enabled<br>"; else echo "exec is disabled<br>"; echo exec('whoami'); echo exec('swetest -h'); ?>
  20. Php Folks, I started learning php originally from 2015. On & off. Part time. Started getting into it seriously around 2017. From home. No classes. From forums and php manual and tutorial sites. Still at oop & mysqli. Had ups & downs as first learnt a lot of old stuffs then found out they been deprecated. For example, if I had originally known pdo is modern over mysqli then I would started on pdo from beginning. Got no real guidance anywhere. Just learnt things the hard way, coming across obstacles and bugging forums. Half-way learning mysqli I come across pdo. So you see, if I had taken school classes then they would have started me on the new stuffs. But because I learning from home, I came across a lot of old tutorials and started from there without knowing they are sort of outdated stuffs. Anyway, I don't like quitting half-way and so did not quit mysqli for pdo when a lot of programmers advised me to dump mysqli for pdo. Thought, since I "wasted time" on mysqli then might aswell build a few sites with it before ditching it. Part time study. Full time working on projects for 3yrs now. projects are own "hobby sites" so to speak and not for clients. I am not the freelancer type or professional type. layman type. Never really have launched any sites. I finish one site/project then move onto another project for learning purpose. So I learn very little then moving onto building sites based on what little I learnt. When I learnt how to use the SELECT, INSERT. DELETE, UPDATE in sql, I jumped into learning to build my own membership site (reg, log-in, logout, etc. pages) to deal with mysql db. So far, built membership parts (login, logout, account homepage, pagination). All by copying codes from tutorials and forums from people like you and changing here and there according to my needs. And when I get stuck. I bug programmers like you. I do have a conscious and do not like plagiarism even while learning and so everytime I copy paste codes from tutorials or forums (where I get help), I retype every line and then delete the copy-pasted lines and leave my typed lines in the file. that way, I feel good I atleast made some effort to build the site rather than copy & paste. Then, I change the codes here and there to suit my purpose. Don't you like me ? ;). You probably chuckling inside reading this. Here's an example of how I copy-paste then re-write the lines. <?php //Code from: https://www.w3schools.com/howto/tryit.asp?filename=tryhow_css_login_form ?> <!DOCTYPE html> <!DOCTYPE html> <html> <html> <head> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1"> <style> <style> body {font-family: Arial, Helvetica, sans-serif;} body {font-family: Arial, Helvetica, sans-serif;} form {border: 3px solid #f1f1f1;} form {border: 3px solid #f1f1f1;} input[type=text], input[type=password] { input[type=text], input[type=password] { width: 100%; width: 100%; padding: 12px 20px; padding: 12px 20px; margin: 8px 0; margin: 8px 0; display: inline-block; display: inline-block; border: 1px solid #ccc; border: 1px solid #ccc; box-sizing: border-box; box-sizing: border-box; } } button { button { background-color: #4CAF50; background-color: #4CAF50; color: white; color: white; padding: 14px 20px; padding: 14px 20px; margin: 8px 0; margin: 8px 0; border: none; border: none; cursor: pointer; cursor: pointer; width: 100%; width: 100%; } } button:hover { button:hover { opacity: 0.8; opacity: 0.8; } } .cancelbtn { .cancelbtn { width: auto; width: auto; padding: 10px 18px; padding: 10px 18px; background-color: #f44336; background-color: #f44336; } } .imgcontainer { .imgcontainer { text-align: center; text-align: center; margin: 24px 0 12px 0; margin: 24px 0 12px 0; } } img.avatar { img.avatar { width: 40%; width: 40%; border-radius: 50%; border-radius: 50%; } } .container { .container { padding: 16px; padding: 16px; } } span.psw { span.psw { float: right; float: right; padding-top: 16px; padding-top; 16px; } } /* Change styles for span and cancel button on extra small screens */ /* Change styles for span and cancel button on extra small screens */ @media screen and (max-width: 300px) { @media screen and (max-width: 300px) { span.psw { span.psw { display: block; display: block; float: none; float: none; } } .cancelbtn { .cancelbtn { width: 100%; width: 100%; } } } } </style> </style> </head> </head> <body> <body> <h2>Login Form</h2> <h2>Login Form</h2> <form action="/action_page.php" method="post"> <form action="/action_page.php" method="post"> <div class="imgcontainer"> <div class="imgcontainer"> <img src="img_avatar2.png" alt="Avatar" class="avatar"> <img src="img_avatar2.png" alt="Avatar" class="avatar"> </div> </div> <div class="container"> <div class="container"> <label for="uname"><b>Username</b></label> <label for="uname"><b>Username</b></label> <input type="text" placeholder="Enter Username" name="uname" required> <input type="text" placeholder="Enter Username" name="uname" required> <label for="psw"><b>Password</b></label> <label for="psw"><b>Password</b></label> <input type="password" placeholder="Enter Password" name="psw" required> <input type="password" placeholder="Enter Password" name="psw" required> <button type="submit">Login</button> <button type="submit">Login</button> <label> <label> <input type="checkbox" checked="checked" name="remember"> Remember me <input type="checkbox" checked="checked" name="remember"> Remember me </label> </label> </div> </div> <div class="container" style="background-color:#f1f1f1"> <div class="container" style="background-color:#f1f1f1"> <button type="button" class="cancelbtn">Cancel</button> <button type="submit" class="cancelbtn">Cancel</button> <span class="psw">Forgot <a href="#">password?</a></span> <span class="psw">Forgot <a href="#">password?</a></span> </div> </div> </form> </form> </body> </body> </html> </html> One thing I gain from this type of re-writings is that, typing the same thing over and over again sort of gets codes sink into my subconscious. Helps to memorise the codes. Ok. So now you know a little about me. As you can see, I always start on somebody else's skeleton, be it from a tutorial forum or a tutorial site or php manual. I have completed 3 websites, so to speak, in that way. 2 days ago I thought, I been doing this for 3yrs now. Let's test and see how well I can code without working on somebody else's skeleton. No copy-pasting from forums or tutorial sites or php manual. And so, look what I did. I coded all the following from my own memory. let me know how well I did. That repetition of lines re-writing has done me some good to memorise codes. I did make 2 mistakes. Note the comments in the code. You will notice "MY CODE ..." and then a correction "WHAT IT SHOULD BE ...". Compare the 2 and see how close or far away I was from the correction. And then give me score from 1-10 (where 10 is best) how well I did as a home study middle aged guy. Hard learning things at middle age. I think, if I had toild you I started learning a month ago then you'd give 9/10 but because it's been 3 yrs, you'll give 1/9 or 0. Just bear in mind it's not easy to learn things at middle age and remember them without forgetting. I learn fast but forget double fast. Lol! One thing though. My codes are not working. They do not INSERT data into db nor extract & display data from db. What is wrong ? TEST NUMBER 1: On this one, I first tried displaying data rows from mysql using mysqli_stmt_get_result(). That failed and so I tried with mysqli_stmt_bind_result() afterwards and so bear that in mind and don't ask me why I used both instead of one. Clicking the "search" button gives no response. Nothing happens on page. I did search for a ketywords that exist in each mysql tbl columns. <?php include('error_reporting.php'); require('conn.php'); //require('search_form.php'); ?> <form name = "search" method = "POST" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <label for="keywords">Keywords:*</label> <input type="text" name="keywords" id="keywords" placeholder="Input Keywords" required> <br> <label for="search_column">Search in ... ?</label> <select name="search_column" id="search_column"> <option value="page_url">Page Url</option> <option value="link_anchor_text">Link Anchor Text</option> <option value="page_description">Page Description</option> <option value="keyphrase">Keyphrase</option> <option value="keywords">Keywords</option> </select> <br> <label for="tos_agreement">Agree to TOS or not ? *</label> <select name="tos_agreement" id="tos_agreement" required> <option value="Yes">Yes</option> <option value="No">No</option> </select> <br> <input type="button" name="search_links" id="search_links" value="Search Links!"> <br> <input type="reset"> <br> </form> <?php if($_SERVER['REQUEST_METHOD'] === 'POST') { if(ISSET($_POST['search_links'])) { $_POST['page_url']; $_POST['link_anchor_text']; $_POST['page_description']; $_POST['keyphrase']; $_POST['keywords']; //I WROTE 2 QUERIES HERE AS I WASN'T SURE HOW IT SHOULD BE. FINALLY, STUCK TO THE LATTER. HOWEVER, ON TESTS NONE OF THEM WORK! //QUERY 1. $query = "SELECT FROM links (page_url,link_anchor_text,page_description,keyphrases,keywords) WHERE keywords = ?"; //QUERY 2... $query = "SELECT page_url,link_anchor_text,page_description,keyphrases,keywords FROM links WHERE page_url = ?, link_anchor_text = ?, page_description = ?, keyphrases = ?, keywords = ?"; $stmt = mysqli_stmt_init($conn); if(mysqli_stmt_prepare($stmt,$query)) { mysqli_stmt_bind_param($stmt,'sssss',$_POST['page_url'],$_POST['link_anchor_text'],$_POST['page_description'],$_POST['keyphrase'],$_POST['keywords']); //WRONG: FORGOT TO ADD "$result = " ... //mysqli_stmt_bind_result($stmt,$page_url,$link_anchor_text,$page_description,$keyphrase,$keywords); //CORRECTION: WHAT IT SHOULD BE ... $result = mysqli_stmt_bind_result($stmt,$page_url,$link_anchor_text,$page_description,$keyphrase,$keywords); //mysqli_stmt_execute($stmt);WRONG! THIS LINE SHOULDN'T EXIST UNLESS IT'S mysqli_stmt_get_result(). mysqli_stmt_fetch($stmt); //WASN'T SURE WHICH OF THE 3 FOLLOWING LINES ARE CORRECT REGARDING THE WHILE LOOP. FINALLY, STUCK TO THE 1ST LINE ... //1)... while(mysqli_stmt_fetch($stmt)) //2)... //while(mysqli_fetch_array($stmt,mysqli_assoc)) //3)... //while(mysqli_fetch($stmt)) { echo "url"; echo "<br>"; echo "anchor_text"; echo "<br>"; echo "description"; echo "<br>"; echo "keyphrases"; echo "<br>"; echo "keywords"; echo "<br>"; echo "|"; echo "<br>"; } mysqli_stmt_close($stmt);//CORRECTION: THIS SHOULD BE OUTSIDE THE "WHILE LOOP" mysqli_close($conn);//CORRECTION: THIS SHOULD BE OUTSIDE "IF" } else { echo "1. QUERY failed!"; } if(mysqli_stmt_prepare($stmt,$query)) { mysqli_stmt_bind_param($stmt,'sssss',$_POST['page_url'],$_POST['link_anchor_text'],$_POST['page_description'],$_POST['keyphrases'],$_POST['keywords']); mysqli_stmt_execute($stmt); //CORRECTION: FORGOT TO ADD "$result = " $result = mysqli_stmt_get_result($stmt); /* MY CODE WRONG! TRIED ECGHOING THE ARRAY "$row[]"! while($row = mysqli_fetch_array($result,mysqli_assoc)) { echo $row['page_url']; echo "<br>"; echo $row['link_anchor_text']; echo "<br>"; echo $row['page_description']; echo "<br>"; echo $row['keyphrases']; echo "<br>"; echo $row['keywords']; echo "<br>"; echo "|"; echo "<br>"; } */ //CORRECTION: HOW IT SHOULD BE: //$VARIABLE SHOULD BE ECHOED. NOT THE ARRAY $row[] while($row = mysqli_fetch_array($result,mysqli_assoc)) { $page_url = $row['page_url']; echo $page_url; echo "<br>"; $link_anchor_text = $row['link_anchor_text']; echo $link_anchor_text; echo "<br>"; $page_description = $row['page_description']; echo $page_description; echo "<br>"; $keyphrases = $row['keyphrases']; echo $keyphrases; echo "<br>"; $keywords = $row['keywords']; echo $keywords; echo "<br>"; echo "|"; echo "<br>"; } mysqli_stmt_close($stmt); mysqli_close($conn); } else { die("2. QUERY failed!"); } } } ?> TEST NUMBER 2: On this one, clicking the "submit links" button gives no response atall!. <?php include('error_reporting.php'); require('conn.php'); //equire('link_submission_form.php'); ?> <form name = "submit_link" method = "POST" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <label for="domain">Domain:</label> <input type="text" name="domain" id="domain" placeholder="Input Domain"> <br> <label for="domain_email">Domain Email:</label> <input type="email" name="domain_email" id="domain_email" placeholder="Input Domain Email"> <br> <label for="url">Url:</label> <input type="url" name="url" id="url" placeholder="Input Url"> <br> <label for="link_anchor_text">Link Anchor Text:</label> <input type="text" name="link_anchor_text" id="link_anchor_text" placeholder="Input Link Anchor Text"> <br> <textarea rows="10" cols="20">Page Description</textarea> <br> <label for="keywords">Keywords:</label> <input type="text" name="keywords" id="keywords" placeholder="Input Keywords related to Page"> <br> <label for="tos_agreement">Agree to TOS or not ?</label> <select name="tos_agreement" id="tos_agreement"> <option value="yes">Yes</option> <option value="no">No</option> </select> <br> <input type="button" name="submit_link" id="submit_link" value="Submit Link!"> <br> <input type="reset"> <br> </form> <?php if($_SERVER['REQUEST_METHOD'] === 'POST') { if(ISSET($_POST['submit_link'])) { $query = "INSERT into links (domain,domain_email,url,link_anchor_text,page_description,keywords) VALUES ?,?,?,?,?,?"; $stmt = mysqli_stmt_init($conn); if(mysqli_stmt_prepare($stmt,$query)) { mysqli_stmt_bind_param($stmt,'ssssss',$_POST['domain'],$_POST['domain_email'],$_POST['url'],$_POST['link_anchor_text'],$_POST['page_description'],$_POST['keywords']); mysqli_stmt_close($stmt); mysqli_close($conn); } else { die("INSERT failed!"); } } } ?> What is wrong ? Why both codes don't work ?
  21. You mean, by default if the programmer doesn't set an option to select "selected>" then by default the first option gets selected ? Well, I didn't have any selected by default, no option had the "selected>" and still my dropdown didn't work. Can't remember how it malfunctioned. I think the drop down menu was not appearing to show any options until I added the snippet: <option value="">Select here</option> Then it worked.
  22. I remember now! When my dropdown wasn't working, i was advised to add at the top of all options: <option value="">Select here</option> How come tutorials don;t teach this ? I gave 2 links, you can easily see they don't teach this. How did you programmers figure it out to do it like that to rid the problem, if tutorials didn't teach you ? Confused.
  23. Many thanks for this information. I'm unable to change the format when retrieving from database as this isnt my code, its from a template system and do not know how this is being queried. I have tried changing this re-format after retrieval in the array, and im still as yet to figure that out, everytime i try the code above it comes up with - Call to a member function format() on boolean which i think is the date. Might have to rethink how to proceed.
  24. @StevenOliver, Thank you very much! I did not know the differences between the 3 (error reporting, warning, exception handler). Though, I will need to learn more on exception stuff. I didn't know we shouldn't put db credentials on public_html. Thanks for bringing this to my attention. One question, if we put it outside the public folder, then how can files inside the public folder access the credential files without the www ?
  25. You have a couple of options 1 ) Re-format the date in the SQL query when you retrieve the records. EG SELECT DATE_FORMAT(invoice_date_created, '%d.%m.%Y') as invoice_date_created 2 ) Re-format after retrieval in the array $transaction['invoice_date_created'] = date('d.m.Y', strtotime($transaction['invoice_date_created']));
  26. hello - i was able to add the system variable to the win environment. but i stuck with the work on the regedit!? can you advice here!?
  1. Load more activity
  • 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.