Jump to content

ajoo

Members
  • Posts

    871
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by ajoo

  1. Hi, please can you suggest a lamp stack vagrant box with those specs ( Apache 2.4 and php 7) that would fulfill my testing needs. I have been trying to install a few of them without success on my 32 bit machine but most gave errors. One even had a virus ( scotch.io ). Any help appreciated. Thanks.
  2. Thank you Requinix and Guru Jacques for the advise. Will do the needful then.
  3. Hi all, The 2nd line in this code gives an error on the ubuntu12.04 VM though it works fine on the local xampp installation. $login_attempts_query = $database_connection->query('SELECT @login_attempts'); $login_attempts = $login_attempts_query->fetch_row()[0]; $login_attempts_query->close(); specifically a syntax error due to the square bracket"[". Why should this issue an error in one and not in the other environment? is this method deprecated or is this a version issue? Here is the the apache and php detail in the VM The xampp vesrion of Apache is 2.4 and php is 5.6 Would the following be the correct code replacement for the above? ( sorry checking across the two environments is most cumbersome after a days work ) $login_attempts_query = $database_connection->query('SELECT @login_attempts'); $login_attempts = $login_attempts_query->fetch_row(); $login_attempts = $login_attempts[0]; $login_attempts_query->close(); return $login_attempts; Thanks !
  4. Hi, Thanks for the reply Beneneman and Guru Jacques, Sorry for the late response but i realized a bit late that the question had been shifted to another, more appropriate, forum !! @Guru Jacques : Assuming that I don't have a public webserver at present, How should my present setup be different from the xampp stack setup that i currently have on my local machine? I mean what do I have to do to setup a "production" like environment on my local machine? is my present xampp setup appropriate for the development environment ? It's still unclear to me what's the difference between the two environments? Is it basically security ? I was thinking that I should setup a "production" like environment on the VirtualBox VM, even if just to see what a production like environment really is. Maybe I can then try and replicate it on the public webserver as closely as possible. Amazon aws, for eg, provides a large variety of VMs to choose from if I finally decided to set it up there. If my questions sound quixotic, its simply because I have had very little experience with servers and their setups. Thanks for bearing with them - me ! @Beneneman : I have been reading vagrant. Will use it for sure. Yes it would have made life easier had i read it before and used it. This is what I would like to do !!! I'll read up more, try out some and revert. Thank you both very much.
  5. Hi all, In the last topic i started, Guru Jacques suggested (a great idea ) that I install VM VirtualBox on my machine. After , a number of hit and trials I finally managed to install xubuntu 12.04 on my machine. My machine has the following configuration : Pentium P4 2.2 GHz running Windows 7 and 4Gigs of RAM. I have allotted 1 Gig to the xubuntu and it seems a bit tardy even when the guest additions have yet to be installed. Still it's workable. Given my configuration, I would like to ask if I have chosen the correct linux flavour and the right version. There is a plethora of flavors and versions over there and I am not sure if i have picked the right one. I tried lubuntu which is said to have a smaller footprint and is supposed to be the fastest version there but it failed to start on my machine. I was about to install the XAMPP stack on top of xubuntu when I came across an article which said that the XAMPP STACK should not be installed in the production environment. This has triggered a few more questions. 1. Do specific servers have an advantage over another on a given OS ? 2. Which server should then be installed for production and development environments? I have little experience with any servers and the Apache I installed as my localhost was installed via the stack. 3. Would I have to install 2 servers or would I just need two configurations of the same server for production and development modes? (Benanamen provided a link of vagarant and I think that has something to do with this. I have not had time to check that out yet) 4. If the configurations solve the issue, then is it easy to switch between these 2 modes and how? Well that's it for the time being. I am sure there will be more as I go along this path. Thanks all !
  6. Congratulations Guru Barand !!!!
  7. Thanks for clarifying those nagging doubts, Guru Jacques. Happy New year !
  8. HI all ! Ok so before the new year here are some real noob questions maybe after reading the replies of Mac_gyver and Guru Jacques. 1. Instead of making changes to the ini variables like error_reporting(E_ALL); in the index file or changing the variables - that will be used to set some of the ini properties - $secure = false; // Set to true if using https. $httponly = true; would it not have been better for me to make two ini files for dev. and prod. and switch between the two , since now I will have to remove, at least, all of error_reporting(E_ALL); for the production environment? 2. Is there a better way to manage these if not in the ini files ? Like for e.g, Would it be recommended to use some defines to evaluate code for production and development and place these ini variables inside of those blocks for their selective execution. Something like. define('PROD', 1); if(PROD === 1) error_reporting('E_ALL'); 3. Coming back to the custom php.ini files, I just create a php.ini in a text editor and define these variables in there and they would come into effect ? like this : custom php.ini error_reporting : on display_errors: off session.name: sec_sess_id httponly: on secure: off 4. And where should I place this php.ini file which would be local to the project? in the root - or outside the root? Thanks loads & a Happy new year to all !!
  9. Thanks Guru Jacques, That really makes it so much clearer !! hmm , yes I will have to scan the project for these, at least once, and find them, I will do that and revert in case I run into some issue regarding these. Thanks loads and a Merry Christmas to you and all on the forum !
  10. Hi mac_gyver and Guru Jacques and thanks for your replies ! @ Mac_gyver That itself nailed it. For reasons unknown to me, i was using session_start in verifymail.php. I changed that to sess_start() and things are back to normal. The idea of putting the same initializing code into a file by itself is great. I'll use it. While I have heard of single page websites, I don't know how to implement one. I'll keep in mind to check it soon. A link to a nice tutorial on that would be great ! @Guru Jacques ! I am not really sure about the custom ini settings thingy you mention. I'll look up some user.ini examples to understand that a bit further. I think this was just a bit of an oversight. I don't think my code is making changes to any ini settings, so hopefully none would be overwritten. I would be glad if you can elaborate this a bit more and possibly with a small example. Confused deputy would suit me better ! Thanks loads to you both !
  11. Hi all ! I have an index file which begins as <?php error_reporting(E_ALL); define('INCLUDE_CHECK',true); require_once 'fran_load.php'; session_start(); // works fine with session_start() //sess_start(); // was working fine earlier but is now problematic header("Content-Security-Policy-Report-Only: default-src 'self' img-src 'self' data: https://www.google.com/ https://ajax.googleapis.com/ https://www.gstatic.com/ http://localhost/xampp/franchisee/; report-uri http://localhost/xampp/franchisee/reports/reportcspviolation.php"); // mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); $mysqliDriver = new mysqli_driver(); $mysqliDriver->report_mode = MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT; $timezone = "Asia/Calcutta"; if(function_exists('date_default_timezone_set')) date_default_timezone_set($timezone); // set_exception_handler('exception_handler'); . . . and an email activation request page.verifymail.php which begins as <?php error_reporting(E_ALL); session_start(); header("Content-Security-Policy-Report-Only content=default-src 'self' https://www.google.com/recaptcha/ https://ajax.googleapis.com/ajax/libs/jquery/1.3.2/"); define('INCLUDE_CHECK',true); require_once 'fran_load.php'; /* echo "<pre>"; echo $_SESSION['user_token']; echo "</pre>"; exit(); */ $message = ''; $terminate = false; . . . sess_start() is function sess_start() { $session_name = 'sec_session_id'; // Set a custom session name $secure = false; // Set to true if using https. $httponly = true; // This stops javascript being able to access the session id. ini_set('session.use_only_cookies', 1); // Forces sessions to only use cookies. $cookieParams = session_get_cookie_params(); // Gets current cookies params. session_set_cookie_params($cookieParams["lifetime"], $cookieParams["path"], $cookieParams["domain"], $secure, $httponly); // 0, /, ''. session_name($session_name); // Sets the session name to the one set above. session_start(); // Start the php session } Earlier all seemed to work well, but suddenly there is an issue. On submitting the form with action = "verifymail.php" which sends from the index.php to verifymail.php, i find that the $_SESSION variable is blank, thereby not maintaining the session on that page. I am setting some session variables in the form before it is submitted. I commented out sess_start() on index.php and simply used session_start() and all seems to work fine. I would like to use sess_start, since I am setting the cookie timeout and other values therein, if I can. Please can someone suggest why this is happening and how it can be overcome to use sess_start(). Thanks all.
  12. Hi Guru Jacques ! Thanks for the reply or I would have continued struggling with this. Thanks loads.
  13. Hi all ! This snippet below, with an older version of jquery, namely 1.7.2 works fine with Internet Explorer 8 <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.js"></script> while this one below, the newer version, namely 3.1.1 <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.js"></script> gives the Object Expected error. My login page with a slider login panel renders but with errors, it says, and the slider does not function. It does not slide down. The two script lines are exact same except for the version diff. Please suggest if and how may I resolve this issue. Thanks loads everyone.
  14. The following does it :- ob_start(); imagejpeg($dst_img); $imagedata = ob_get_contents(); ob_end_flush(); Thanks for the pointer mac_gyver
  15. Hi all, The following bit of snippet displays a resized jpeg. $dst = imageCreateTrueColor($nwidth, $nheight); imageCopyResampled($dst, $src, 0, 0, 0, 0, $nwidth, $nheight, $ix, $iy); imagejpeg($dst); Is there a simple, direct way to extract image data (BLOB) from this without actually saving the imagejpeg($dst) to a file first and then reading it back again ? Thanks all !
  16. Hi Guru Barand ! I tried that before I asked but i was getting an error. It said something like - the $filename ('path/to/file') should be a resource and not a string. - but eventually it worked. Thank you.
  17. Hi all, Below is the last bit of code that loads an image from a local machine, resizes it and displays the resized image on a screen. imagepng($dst); // displays the resized image imagedestroy($src); imagedestroy($dst); What I want to do now is to save the resized image on the server. How may I do that ? Any help is much appreciated. Thanks all.
  18. Hi all ! The following code snippet taken from the php manual does not display the png image. The similar code for jpeg images works fine. The server support for png images is enabled on my server. function LoadPNG($imgname) { /* Attempt to open */ $im = @imagecreatefrompng($imgname); /* See if it failed */ if(!$im) { /* Create a blank image */ $im = imagecreatetruecolor(150, 30); $bgc = imagecolorallocate($im, 255, 255, 255); $tc = imagecolorallocate($im, 0, 0, 0); imagefilledrectangle($im, 0, 0, 150, 30, $bgc); /* Output an error message */ imagestring($im, 1, 5, 5, 'Error loading ' . $imgname, $tc); } return $im; } header('Content-Type: image/png'); $img = LoadPNG('bogus.image'); imagepng($img); imagedestroy($img); Please can someone explain how to get this working? Thanks all !
  19. Hi all ! I realized that the code snippet requires to make a db connection. DB.php is not present. Anyways , the snippet above works just fine. It's just that I am unable to constrain it's size of the displayed image (after reading the stored image on the server) to the one I want. I have seen similar code on the net but that does not use the readfile function. I think it has to do with this function that the image size is not being constrained. <img width="xxx" height="yyy" ... doesn't seem to work either. Is there any way to constraint the size of the displayed image without actually resizing it ? Thanks all !
  20. Hi all ! I have been experimenting with a bit of code that uploads file to the server. The image is previewed once selected and can then be uploaded. The uploaded image is then selected and displayed. Here is the code usp5.php <?php error_reporting(E_ALL); require_once 'DB.php'; $uploaddir = 'D:/xampp/php/internals/uploads/'; # Outside of web root // echo $uploadfile."<br>"; // exit(); if(isset($_POST['upload'])) { $blob = "BLOB"; $filename = $_FILES['userfile']['name']; $filetype = $_FILES['userfile']['type']; $tmp_filename = $_FILES['userfile']['tmp_name']; $uploadfile = tempnam($uploaddir, "upm"); if (move_uploaded_file($tmp_filename, $uploadfile)) { try { $query = "INSERT INTO images (name, original_name, mime_type, images) VALUES (?,?,?,?)"; $stmt = $link->prepare($query); $stmt->bind_param('ssss',$uploadfile,$filename,$filetype,$blob); if($stmt->execute()){ $id=$stmt->insert_id; // get the just inserted id } else{ echo "Error : ".$link->error; } } catch(mysqli_sql_exception $imageException) { if ($imageException->getCode() === MYSQL_ER_DUP_ENTRY) { echo'The filename is already taken, please choose a different name.'; return false; } else { // rethrow exception throw $imageException; } } } if(!is_numeric($id)) { die("File id must be numeric"); } $query = 'SELECT name, mime_type FROM images WHERE id=?'; $stmt = $link->prepare($query); $stmt->bind_param('i',$id); $stmt->execute(); $stmt->bind_result($filename,$type); $stmt->store_result(); $stmt->fetch(); $stmt->free_result(); if(is_null($filename) || count($filename)===0) { die("File not found"); } header("Content-Type: " . $type); // echo "<div class='div2'>"; // works good without the div. Divs cause the binary dump to show instead echo '<img src="'.readfile($filename).'"alt="">'; // echo "</div>"; } ?> <html> <head> <title>File Upload To Database</title> <link class="jsbin" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css" rel="stylesheet" type="text/css" > <link rel="stylesheet" type="text/css" media="screen" href="divs.css" /> <script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> <script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.0/jquery-ui.min.js"></script> <meta charset=utf-8 /> </head> <body> <form name="upload" action="#" method="POST" enctype="multipart/form-data"> Select the file to upload: <br> <input type="file" name="userfile" onchange="readURL(this)"; /><br> <br><input type="submit" name="upload" value="Upload"> <div class = "div1"> <img id="image" src="#" alt="load image" /> <!-- This displays the image. --> </div> </form> <!-- <img class="div2" src="'<?php // readfile($filename); ?>'" alt="load image" /> --> <script> function readURL(input) { if (input.files && input.files[0]) { var reader = new FileReader(); reader.onload = function (e) { $('#image') .attr('src', e.target.result) .width(200) .height(200); }; reader.readAsDataURL(input.files[0]); }else{ alert( "File not selected or browser incompatible." ); } } </script> </body> </html> divs.css .div1 { height:220px; width: 220px; display:block; margin:5px; border:1px solid navy; background-color:#ffffbb; } .div2 { height:350px; width: 350px; display:block; margin-left:1px; border:1px solid navy; background-color:#ffaaff; } img{ max-width: 100%; max-height: 100%; } In the first preview, before upload, a bigger image is automatically reduced to fit into a 200px by 200px due to the width and height set in the jquery. After the image is loaded on the server and is selected using the id of the image, I am unable to fit the same in a div to restrict the size of the image to any arbitrary given dimensions. Kindly help me with that. Is it possible to display both the images simultaneously in two separate divs ? How ? Any security issues in this ? Thanks all !
  21. Hi all ! I have created a fiddle of the issue that I am facing. It has been partially resolved. i.e. the slider now moves uniformally. However in the close position, the slider tab displays the text for the open and close positions simultaneously. I request anyone to try and have a look and suggest a resolve. fiddle: https://jsfiddle.net/ajoo/totym83v/3/ Thanks.
  22. Hmm Hi Guys, experts, Gurus !! More than a 100 views and no response !? Surely this coudn't be that tough a problem to crack !! Or have i done something wrong - like not defined the problem correct or not given the right inputs? Looking forward to some response. Please advise. Thanks !!!!
  23. Hi all, Please find a zipped file with code simulating the slider distortion issue described above. I hope someone will be able to figure out what's going wrong and provide a solution for the same. Thanks all ! slider.zip
  24. Hi all, I request someone to take a look at this, hopefully not a big, CSS issue that is baffling me for some days now. Thanks all
  25. Hi Kicken, Thanks again for the reply and the Twig example. I am sure it will be of great help in helping me learn about templating. I was in the process of checking out the code you sent earlier. However it always goes and dies at the following bit of code:- if (!is_dir($path) || !is_readable($path)){ die('Cannot access '.$path); and gives the following error:- Any suggestions?
×
×
  • 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.