ajoo
Members-
Posts
871 -
Joined
-
Last visited
-
Days Won
1
Everything posted by ajoo
-
Hi all, I have this slider in a project which was working great till I removed a small bit of inline css and tried to put it in an external file. That produced a distortion in the slider as it moves up n down. Earlier the slider tab moved uniformly ( it's size remained the same as it opened or closed). But now the slider becomes smaller as it opens. and comes back to the original size and place as it closes. Further the x in a circle is slightly eaten when the slide tab is in the open state. The HTML that worked great :- <!-- The tab on top --> <div class="tab"> <ul class="login"> <li class="left"> </li> <li>Hello <?php echo isset($user)? $user : 'Guest';?>!</li> <li class="sep">|</li> <li id="toggle"> <a id="open" class="open" href="#"><?php echo isset($id)?'Open Panel':'Log In | Register';?></a> <a id="close" style="display:none"; class="close" href="#">Close Panel</a> </li> <li class="right"> </li> </ul> </div> <!-- / top --> The accomanying CSS: .tab a.open,.tab a.close { height: 20px; line-height: 20px !important; padding-left: 30px !important; cursor: pointer; display: block; width: 100px; position: relative; top: 11px; } .tab a.open {background: url(../images/bt_open.png) no-repeat left 0;} .tab a.close {background: url(../images/bt_close.png) no-repeat left 0;} .tab a:hover.open {background: url(../images/bt_open.png) no-repeat left -19px;} .tab a:hover.close {background: url(../images/bt_close.png) no-repeat left -19px;} Once I removed the in line CSS style = " ..." , show in red in the code, and added the following bit of code in the external css file: .tab a.close { display: none; } the distortion that I have described above, crept in. I am not sure how I can make the slider work perfect as before. Please someone help me overcome this. Thanks all !
-
Hi ginerjm & kicken, Thank you both for the inputs to this. @ginerjm : I generally do keep my php code at the top and separated from the HTML. The js goes into it's own files. @kicken : I'll go through the code example and revert in sometime. You are correct in all your assumptions. The $rooms values do come from a DB. I just created those variables to simplify the code. What i was looking for was a way of working my example with a templating engine like Twig as you mentioned. I believe, and I may be wrong, that the php values (like the values in the array $rooms) are somehow, through the templating engine mechanism, passed to the HTML and rendered there. I was actually looking for an example of that sort. Still I am very grateful for all your inputs. I'll revert after playing around with the code and hopefully learning something nice ! Thanks.
-
Hi Destramic, Thanks for the response. Hmm It's a part of an HTML document which I have modified slightly. The php around this bit of code is because of the need to evaluate the value of rooms from a DB. ( not shown here) and then populate the same. It's those values that should be calculated else where ( in the pure php part of the doc ) and then sent thru here. I think that's what templating is able to accomplish. ( That's what I could make out from some of questions involving templates on the forum) The js, ofcourse would go into it's own file. That was just to put together a working example file. if($room === $displayed)echo ""; hmm again there was a session value that was to be echoed here. Something like that I intend to do after learning a bit about templating, Thanks loads !
-
Hi all, Below is a small example snippet of an enmeshed php, html, css & js program which I think would be an example of bad programming. Using this simple example below can someone please demonstrate how it may be used to separate the code and convert the html into a template. It would be a nice example to learn about templating I think. Thank all. <?php print_r($_POST); $rooms = array(1,2,3,4); $displayed = 2; ?> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js"></script> <script type="text/javascript"> $(document).ready(function(){ $('#room').change(function(){ $(this).parent('form').submit(); }); }); </script> <?php echo "<div>"; echo "<form id = 'form1' action='#' method='post' > "; echo "<select name='room' id='room'>"; if(isset($displayed)) echo "<option selected>".$displayed."</option>"; $i = 0; while($i < count($rooms)) { $room = $rooms[$i]; if($room === $displayed)echo ""; else echo "<option value = ".$room." > ".$room." </option>"; $i++; } echo "</select>"; echo "<noscript><input type='submit' value='Submit'></noscript>"; echo "</form>"; echo "</div>"; ?>
-
Hi Guru Jacques, Thank you very much. Upgrading the jquery library to the latest version helped clear all the errors. I am not getting them now. I have implemented the csp across the project - I think. Many thanks to you for informing me about CSP and all the help to complete its implementation. Kind regards
-
Hi Guru Jacques, No there were errors in firefox as well. I searched for them and found the errors. (see Below in the picture). There may have been even in Internet Explorer, but I did not know where to look for them. I tried but could not find them in IE. . I'll change the jquery version and see where that leads to. I'll revert with the results. Meanwhile does this now change your last answer in any way? Thank loads!.
-
Hi Guru Jacques, Kicken and all else ! I am still stuck with this. I have tested this in IE and Firefox as suggested by Guru Jacques and It seems that the problem lies in this particular div : <div id="panel"> It somehow gets styling. I don't know how. It showed up in IE and firefox but not in chrome. Please find attached all the jpegs showing the various results. Chrome: IE: ( have never used this before) FIREFOX: ( have never used this before) CODE: ( This is the actual code snapshot. No error in this even though the name says code_err ) I hope these will be good enough to help you ascertain the issue and guide me on how to correct these errors. Thanks loads.
-
Hi Guru Jacques, Thanks for the reply and the hint. It helped me remove almost all inline css styles but two which are occurring in the jquery.js file. As suggested, I have temporarily disabled the minified js file. I will revert back if I am still unable to figure out which code is causing this issue. Keeping this question open till then. Thanks loads.
-
Hi Guru Jacques, The flogin error is caused by the code : <a id="close" style="display: none;" class="close" href="#">Close Panel</a> which is a part of the larger block <ul class="login"> <li class="left"> </li> <li>Hello <?php echo isset($_SESSION['user'])? html_escape($_SESSION['user']) : 'Guest';?>!</li> <li class="sep">|</li> <li id="toggle"> <a id="open" class="open" href="#"><?php echo isset($_SESSION['id'])?'Open Panel':'Log In | Register';?></a> <a id="close" style="display: none;" class="close" href="#">Close Panel</a> </li> <li class="right"> </li> </ul> The error must be because of the inline css styling : style="display: none; The class close is a javascript manipulated :- // Collapse Panel $("#close").click(function(){ $("div#panel").slideUp("slow"); }); if I don't use the inline css style "display : none", then it messes up & the open and close button show up together and slide together. I want to keep the slider so how do I fix this? I have tried a couple of things but none seem to work. Please help. Does this also means that I will have to remove all inline css styles and somehow shift them into external css files for the csp to be effective? Thank you.
-
Hi Guru Jacques, The errors / violations that I mentioned in my message #10. They are the same as reported in the errors file. The violations occur because of some in-line resource and I am not sure which resource this is referring to so that I may rectify it. If I knew which bit of code is causing this issue I could change it. The errors violations seem to point to jquery.min.js:19, api.js:1 and flogin.php:82. I have also changed my header to include all the resources on self :- header("Content-Security-Policy-Report-Only: default-src 'self' https://www.google.com/ https://ajax.googleapis.com/ http://localhost/xampp/franchisee/; report-uri http://localhost/xampp/franchisee/reports/reportcspviolation.php"); Please advise. Thanks.
-
Hi Guru Jacques, Sir thank you for that correction. I have changed it but the errors remain. The csp is also generating the errors file in the specified folder. I do see one problem though and that is that I am using http instead of https. Could that be the reason for the errors? I am not sure but I think it's something else. Please find attached the errors file generated. Please advise best. Thanks, csp.zip
-
Hi Guru Jacques, The following seems to work. Hopefully there is no syntax error in this now. header("Content-Security-Policy-Report-Only : default-src 'self' https://www.google.com/ https://ajax.googleapis.com/; report-uri http://localhost/xampp/test/reportcspviolation.php"); I get four errors of which I have listed 2 below. The other two involve I still do not get the report any report. I'll be grateful if you show me how to have this generate a report and the way I should design the header for that. Anything else related as well. Thank you.
-
Hi ! Thanks kicken, I have set the headers with the header command as suggested by Guru Jacques as follows : header("Content-Security-Policy-Report-Only content=default-src 'none' https://www.google.com https://ajax.googleapis.com"); and this should, I think, give errors if the application is accessing resources from 'self' but it get no error. Also there is inline js in some of my pages but even that is not triggering any errors. Any ideas why this might be happening? Thanks !
-
Hi Guru Jacques, How to make the web server add the header ? Is it to be added in the httpd.conf file. If so, exactly where. Or can it be added anywhere ? (I have used the header function successfully to remove the the error I was getting). Thanks.
-
Hi Guru Jacques !! Thanks for the reply. In the particular case above I realized that I just needed to put the js snippet in its own js file and call it. I have tried it and it works but I am sure there will be quite a few examples where I'll need to make changes as advised by you. So after making the above change I have tried to implemented a trial CS policy by adding the following in the header: <meta http-equiv="Content-Security-Policy-Report-Only" content="default-src 'self' https://www.google.com/recaptcha/api.js" /> But this seems to be a wrong way of doing it since I get the error:- Please help. Thanks.
-
Hi, Please read CSV as CSP or content security policy. Sorry for that mistake. Thanks.
-
Hi all ! i have been trying to implement the CSV policy in my files. I have a bit of code that I am not sure how I can change it to suit the policy. Here's the code snippet : if(isset($_SESSION['msg'])) { // The script below shows the sliding panel on page load $script = ' <script type="text/javascript"> $(function(){ $("div#panel").show(); $("#toggle a").toggle(); }); </script>'; } As can be seen the script is loaded conditionally here. So how can I remove javascript embedded from this code so that this may be compatible with the CSV policy. NOTE: the javascript functions are in a separate js file loaded in the header. Thanks all !
-
Hi all, Please ignore this question. I have it sorted. It was a simple parse error. Thanks all,
-
Hi all, I am sorry if I am posting this in the wrong place. If so, kindly transfer it to the appropriate section. I was using code that used recaptcha and that worked perfectly well. Now it has stopped working. The recaptcha dialog box simply does not display. Does anyone have any clue what could be going on? Has someone else also faced this similar problem recently Thanks all.
-
Hi Kicken ! I think this should do the trick. I'll try it out and revert. Thanks you.
-
Hi Kicken, Thanks for the reply and another idea. In the application code, the staff_id comes from POST. The if statement is more like if(isset(staff_id) && $staff_id>0) // since no staff has a 0 id or NULL for that matter So in case the staff_id is not set is it equal to NULL? I wonder. It would be more like undefined and NULL i think. Please correct me if I am wrong but I think that would / could lead to ambiguous results if I implement your example. Thanks again.
-
Thanks Guru Jacques ! Then I'll stick to the longer version too.
-
Hi mac_gyver, Thanks for your reply. Yes you interpreted my question right. The code example is arbitrary and the idea is to reduce the code size. So yes that's it. I am using procedural code without classes and I am using mysqli. So is there any way to achieve this for me ? Requinix has suggested one and while it's short I am not sure if it's safe. Thanks !
-
Hi requinix, Thanks for the reply and this method. Without the staff_id, it will print out all the records in the table. Another thing, is this method security safe ? Thanks loads !
-
Hi all, Is there a better, shorter, sweeter way to pull out the data from the two similar set of queries below? $staff_id = '34'; if($staff > 0) { $query = "SELECT fname, lname, city, email, cell FROM staff"; $stmt = $con->prepare($query); $stmt->execute(); $stmt->bind_result($fname, $lname, $city, $email, $cell); $stmt->store_result(); $stmt->close(); } else { $query = "SELECT fname, lname, city, email, cell FROM staff WHERE staff_id=?"; $stmt = $con->prepare($query); $stmt->bind_param('i',$staff_id); $stmt->execute(); $stmt->bind_result($fname, $lname, $city, $email, $cell); $stmt->store_result(); $stmt->close(); } Thanks !