ghurty Posted January 17, 2010 Share Posted January 17, 2010 I have the following html part of my code: <img src="images/top01.jpg" height="162" width="800"> I would like to write a little PHP code to place somewhere else in the script that if any of the info is changed in that line, it will display an error on the page and halt it from loading. How would the code go. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/188761-how-to-have-a-php-code-check-to-see-if-html-value-has-been-modifed/ Share on other sites More sharing options...
oni-kun Posted January 17, 2010 Share Posted January 17, 2010 $str = '<img src="images/top01.jpg" height="162" width="800">'; if ($str != '<img src="images/top01.jpg" height="162" width="800">') { die ("HTML has changed"); } But this question makes no sense. Client side JS is so easily evaded, serverside they would need to modify virtually nothing to change it. Quote Link to comment https://forums.phpfreaks.com/topic/188761-how-to-have-a-php-code-check-to-see-if-html-value-has-been-modifed/#findComment-996479 Share on other sites More sharing options...
ghurty Posted January 17, 2010 Author Share Posted January 17, 2010 I am providing someone with some php code that I wrote, and I dont want them modifcations on it without having to come back to me. They would want to modify the image variables. So I want to use php (not js) code to make sure it stays the same, and I would obfuscate that code. Thakns Quote Link to comment https://forums.phpfreaks.com/topic/188761-how-to-have-a-php-code-check-to-see-if-html-value-has-been-modifed/#findComment-996481 Share on other sites More sharing options...
oni-kun Posted January 17, 2010 Share Posted January 17, 2010 I am providing someone with some php code that I wrote, and I dont want them modifcations on it without having to come back to me. They would want to modify the image variables. So I want to use php (not js) code to make sure it stays the same, and I would obfuscate that code. Thakns You can obfuscate HTML as you would php, I'm sure there are free alternatives for you, but obfuscating code is never a foolproof method. Quote Link to comment https://forums.phpfreaks.com/topic/188761-how-to-have-a-php-code-check-to-see-if-html-value-has-been-modifed/#findComment-996485 Share on other sites More sharing options...
laffin Posted January 17, 2010 Share Posted January 17, 2010 I think he is asking, how to make certain parts of his php code non-editable and required. and seriously there is no way to accomplish this, unless you encode some required functions. but even than, if u give up the main code, there will be ways to bypass the system. if I was you, i would use the separate code/display, so clients can edit the display but not the code, and encode the code. Quote Link to comment https://forums.phpfreaks.com/topic/188761-how-to-have-a-php-code-check-to-see-if-html-value-has-been-modifed/#findComment-996589 Share on other sites More sharing options...
Felex Posted January 17, 2010 Share Posted January 17, 2010 you can buffer output before display and than check the buffered output if it contains your html tag or not. at begining of your code ob_start(); // your code comes under ob_start(); at the end : $Output = ob_get_flush(); Now you can check whether $Output has <img src="images/top01.jpg" height="162" width="800"> or not with : echo (stristr($Output, '<img src="images/top01.jpg" height="162" width="800">') === false) ? 'Html error' : $Output; Quote Link to comment https://forums.phpfreaks.com/topic/188761-how-to-have-a-php-code-check-to-see-if-html-value-has-been-modifed/#findComment-996598 Share on other sites More sharing options...
oni-kun Posted January 17, 2010 Share Posted January 17, 2010 you can buffer output before display and than check the buffered output if it contains your html tag or not. at begining of your code ob_start(); // your code comes under ob_start(); at the end : $Output = ob_get_flush(); Now you can check whether $Output has <img src="images/top01.jpg" height="162" width="800"> or not with : echo (stristr($Output, '<img src="images/top01.jpg" height="162" width="800">') === false) ? 'Html error' : $Output; Nice fresh obfuscation technique, That i'm sure a few more people will not get. Albeit I find it pointless to obfuscate anything, if you're releasing it, it should be paid for, copyrighted, or free. Quote Link to comment https://forums.phpfreaks.com/topic/188761-how-to-have-a-php-code-check-to-see-if-html-value-has-been-modifed/#findComment-996602 Share on other sites More sharing options...
laffin Posted January 17, 2010 Share Posted January 17, 2010 Yes, and in order to bypass that check? even if encoded? all one has to do is append it to the page after the </html> tag or put it into a html comment. so it will still appear in the output buffer, but not get displayed. Quote Link to comment https://forums.phpfreaks.com/topic/188761-how-to-have-a-php-code-check-to-see-if-html-value-has-been-modifed/#findComment-996642 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.