Jump to content

Search the Community

Showing results for tags 'apache'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

  1. Over the past few days I have been running into some issues with my server crashing due to apache max connections issues. I am running my site off of a hosted Cloud VPS with 200GB of storage, 8192MB Memory, 8TB of transfer, Apache, MySQL, PHP5, and CentOS. I am afraid the issue doesn't necessarily lay in the configuration of Apache, but the way I have scripted the php on my site, the reason I am reaching out here. My site isn't your average website, it is more of a web-based customer management program. There are currently only 2 pages you can actually access via the url bar (signin.php and index.php). All other content is loaded via AJAX and JQuery processes (.load and $.getScript). All AJAX requests are pointed toward a single file called functions.php where a _POST parameter contains the function name and any additional _POST data required by the function. FOR EXAMPLE: AJAX Call: $.post('functions/functions.php',{func:'myFunctionName',ops:'whatever',a:'whatever',b:'whatever'},function(data){ DO WHATEVER I WANT WITH THE RETURN DATA HERE },"json"); PHP (functions.php) require 'dbcon.php'; include 'main_class.php'; include 'f_customerdetail.php'; include 'f_listoptions.php'; include 'f_route.php'; include 'f_useractions.php'; if (isset($_POST['func'])){ $userfunc = $_POST['func']; $funcops = $_POST['ops']; if ($funcops != ''){ $userfunc($funcops); }else{ $userfunc(); } } The functions.php file includes all of my other php files containing all of the functions. Each of the other files (f_customerdata.php, f_route.php, f_payroll.php, etc.) contains a number of functions which handle that specific genre of the site; this was more of an organization method I used to keep track of things. Now that you have a little background, I want to know if that is a toxic way to do things? If I currently have 100 people using the site and anytime they navigate it requests data from the functions.php file then that means there are going to be a ton of requests pointing to that single file, thus causing apache to crash; correct? There are multiple functions which use cURL to scrape data from another website as well. Therefore, a connection to the functions.php file may last in upwards of 5 minutes depending upon the function. A large issue as that all of the content on the site is completely dynamic; it is completely driven by getting data from the database and displaying it. Am I going about this correctly by having a single file handling all of the functions? Or, do I need to re-approach it by pointing the AJAX requests directly to the file containing the functions for that particular situation? I know this is a large question. I am completely self-taught, 4 years experience, and have developed a massive project over the last 6 months. I just want to be sure I am going about this the correct way. Thank you for your input, Josh
  2. Hi, I am newbie to htaccess. i am using timthumb for resizing the images RewriteRule ^inner-banner/(.*)\.([jpg|gif|png|JPG|GIF|PNG]+)$ timthumb.php?src=http://mydomain.com/images/banner/$1.$2&h=350&w=960&zc=0 [QSA,L] This gives me the result : http://mydomain.com/inner-banner/myimage.jpg Now i mapped a subdomain to the folder images. http://subdomain.mydomain.com is mapped to the images folder. So now i need to show the above result as http://subdomain.mydomain.com/inner-banner/myimage.jpg i modified the htaccess like RewriteRule ^inner-banner/(.*)\.([jpg|gif|png|JPG|GIF|PNG]+)$ timthumb.php?src=http://subdomain.mydomain.com/banner/$1.$2&h=350&w=960&zc=0 [QSA,L] Expected Result: http://subdomain.mydomain.com/inner-banner/myimage.jpg But it is not coming like that. it shows 404. Kindly help me resolving this issue.
  3. I have a VPS using FastCGI (WHM/cPanel). As I understand it, in my configuration with FCGI, open_basedir must be set using a php.ini file in each user's /home/ directory (From what I've read, it won't work to do it in the global httpd.conf or global php.ini). I want to use open_basedir for improved security, as I recently had a hack that involved traversing through different user's directories. I have added this value to a user's home directory php.ini file: open_basedir = /home/USERNAME/public_html:/usr/lib/php:/usr/local/lib/php:/tmp What I want to know is, is there a way to test that this is functioning properly? How do I know if it is enforcing it as it should? Presumably I would want to try and execute a .php file in another user's directory from within that first user...however I don't know of a good way to test this. Any suggestions would be greatly appreciated.
  4. Hello, is it possible to allow dots inside your .htaccess? So like in the URL it would look something like. http://domain.com/the.rocker instead of http://domain.com/therocker Here is my code. RewriteRule ^([-a-zA-Z0-9_]+)$ userprofile.php?username=$1
  5. Hey there, I'm pretty new to this proxy server thing and planning on getting some kind of deggree/major in computer science and I have made some pretty substantial progress just by doing some fairly superficial research. I've succesfully set up my phproxy and everything works reletively fine, except for social media sites such as facebook, twitter, myspace, etc. whenever I try to go to these pages via my proxy, it loads just fine but the screen is blank; no logos or information of any type is displayed on the browser when I attempt accessing these sites. However youtube works just fine without a problem. When I initially set up the server I had to edit the Apache program on my computer server to allow access. Thats when everything started working correctly except for the display screw up on social media sites. Any ideas on how to make the damn thing display would be graciously accepted lol. for the life of me ive tried screwing with everything and even different phproxy programs. Thanks! ~~This kid P.s my OS is Widows 7 and ive tried on multiple browsers. also if yall have questions on info that ive provided, or havent, please dont hesitate to ask.
  6. I am confuse of web server and application server and looking for the solution. It would be great if someone explain me detail about the differences and use of the appserver.
  7. I've set up a Download-Script with PHP on my server, which checks some details before letting the user download files via Apache (X-Sendfile). The Files are outside the Document-Root. The code for downloading with Apache and the Module X-Sendfile is: header("X-Sendfile: $fullpath"); header("Content-Type: application/octet-stream"); header("Content-Disposition: attachment; filename=\"$link_file\""); When using Apache and X-Sendfile i have a download-speed of 500 kB/s with my client. I also tested it with Apache and without X-Sendfile with the same file within the Document Root - same thing here! So I tested downloading the same file, with the same client, the same infrastructure on both sides and the same internet-connection a few seconds later via PHP with readfile: header("Pragma: no-cache"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Type: application/octet-stream"); header("Content-Length: ".(string)(filesize($fullpath))); header("Content-Disposition: attachment; filename=\"$link_file\""); readfile($fullpath); This time the download-speed was 9.500 kB/s! I repeated this test using both options more than a multiple times and the result was the same every time trying. The only difference besides the download-speed was a waiting time of a few seconds (depending on the size of the file which was downloaded), when trying with the PHP readfile method. When repeating the PHP readfile method instantly, the waiting time didn't appear again. Most likely because it was stored in the memory after the first time. I'm using a professional HP Raid-System on the server, which has an average local Speed of 800 MB/s, so the reason for this can't be the Diskspeed. Also i didn't find any compressing- or bandwith-settings in the httpd.conf of Apache. Can anyone of you explain why there is such a great difference of the download-speed and how this can be changed? Thank you in advance. Server: Windows Server 2008 R2 Apache/2.2.21 (Win32) PHP/5.4.20 Client: Windows 7 Ultimate x64 Google Chrome 30.0.1599.101 LAN >100 Mbit/s
  8. I have a HTTP server setup on port 9000. I want to setup a squid proxy server lies before it. After I installed the squid, I just did two changes: acl Safe_ports port 9000 # http acl ppnetwork src 192.168.0.0/24 http_access allow ppnetwork Then, I squid -k parse squid The squid is running. I can see the log from cache.log 2013/09/18 16:25:44 kid1| Store logging disabled 2013/09/18 16:25:44 kid1| Swap maxSize 0 + 262144 KB, estimated 20164 objects 2013/09/18 16:25:44 kid1| Target number of buckets: 1008 2013/09/18 16:25:44 kid1| Using 8192 Store buckets 2013/09/18 16:25:44 kid1| Max Mem size: 262144 KB 2013/09/18 16:25:44 kid1| Max Swap size: 0 KB 2013/09/18 16:25:44 kid1| Using Least Load store dir selection 2013/09/18 16:25:44 kid1| Set Current Directory to /home/xxxxx/squid/var/cache/squid 2013/09/18 16:25:44 kid1| Loaded Icons. 2013/09/18 16:25:44 kid1| HTCP Disabled. 2013/09/18 16:25:44 kid1| Squid plugin modules loaded: 0 2013/09/18 16:25:44 kid1| Accepting HTTP Socket connections at local=0.0.0.0:3128 remote=[::] FD 9 flags=9 2013/09/18 16:25:45 kid1| storeLateRelease: released 0 objects But, if I access the http site like http://mysite:9000, should I supposed to see any contents in the squid access.log? If so, why is my access.log empty? Do I setup the proxy server correctly? Thanks!
  9. I'm trying to display products specific to a geographic location on the website. E.g. If a user selects city1 then my website url should change to city1.mysite.com. So the city1 part is dynamic on user selection. Please let me know how this is to be achieved and if this includes mod-rewrite or subdomains for each location. Thanks in advance.
  10. I want to know that mod_rewrite enable or not in my server You can see my php info file here http://www.grabkart.com/phpinfo.php
  11. I am curious about server access. Lets say you buy a hosting service, can you manually decide which directories will be public and which will be off limits? Do public directories have to include views (templates)? Because in a lot of frameworks I see views in private directories. Can you block access via .htaccess and only allow users to browse certain pages? How do you prevent them from browsing your entire php app files? I know this is a lot of question but a simple overview about directory structure in apache servers will do, since I am building one.
  12. Hi, I recently got a Raspberry Pi to accompany me in my noob adventures through the learning of PHP. However i was wondering wether it would be possible to set my raspberry pi up such that it could run 24/7 as a server which parses php that i have written on other devices. E.g. so that i could write a plain php document on a computer without php or apache installed and then send that document to the pi. The pi would then display the code on a webpage as it was intented to be seen. This would be useful as it would allow me to code in school and on other devices without having to go through the effort of installing apache +python (i would therefor also appreciate being able to put the documents on the pi without being connected to a local network, e.g. on holiday in another country). If it is indeed possible to do such a thing i would hugely appreciate advice/a guide as to how i could go about doing it! Kind regards Nub Nub Alex
  13. Hello everyone, I'm making some improvements to site I haven't created so please tell me how it exactly works as I have problems to configure it properly. I've downloaded all files and run localhost using XAMPP. Site should run when accessing /home/some_domain/public_html/index.php so I've created : <VirtualHost *:80> DocumentRoot "C:/xampp/htdocs/SomeProject/home/some_domain/public_html" ServerName some_project <Directory "C:/xampp/htdocs/SomeProject/home/some_domain/public_html"> AllowOverride All Order allow,deny Allow from all </Directory> </VirtualHost> That means, when I'm accessing http://some_project it runs index.php And that's ok. In index.php there's some include: include_once("includes/startup.php"); So it includes relatively there: /home/some_domain/public_html/includes/startup.php And that's fine. However... In startup.php there's something like this: define("_ROOTPATH_","/home/some_domain/public_html/"); and next line: include_once(_ROOTPATH_ ."includes/config.php"); And that's my problem as index.php was executed from C:/xampp/htdocs/SomeProject/home/some_domain/public_html/ so that include_once will behave this way: C:/xampp/htdocs/SomeProject/home/some_domain/public_html/home/some_domain/public_html/includes/config.php Of course such file is not available as it should direct to: C:/xampp/htdocs/SomeProject/home/some_domain/public_html/includes/config.php I'm not sure how it works on server and what I should do with my localhost to achieve that same environment. $_SERVER['DOCUMENT_ROOT'] for real site is: /home/some_domain/public_html Please help me to understand what I'm doing wrong.
  14. Not sure if this is in the right area. I have uploaded the script below to two sites with the same host, however one works and one doesn't, my host provider has said that the only difference is that the one that doesn't work has a more recent versionof Apache (2.4.4) The code affected is below function addToCart() { // make sure the product id exist if (isset($_GET['p']) && (int)$_GET['p'] > 0) { $productId = (int)$_GET['p']; } else { header('Location: http://www.jasondoyleracing.com/shop'); } // does the product exist ? $sql = "SELECT pd_id, pd_qty FROM tbl_product WHERE pd_id = $productId"; $result = dbQuery($sql); if (dbNumRows($result) != 1) { // the product doesn't exist header('Location: http://www.jasondoyleracing.com/shop/cart.php'); } } // current session id $sid = session_id(); // check if the product is already // in cart table for this session $sql = "SELECT pd_id FROM tbl_cart WHERE pd_id = $productId AND ct_session_id = '$sid'"; $result = dbQuery($sql); if (dbNumRows($result) == 0) { // put the product in cart table $sql = "INSERT INTO tbl_cart (pd_id, ct_qty, ct_session_id, ct_date) VALUES ($productId, 1, '$sid', NOW())"; $result = dbQuery($sql); } else { // update product quantity in cart table $sql = "UPDATE tbl_cart SET ct_qty = ct_qty + 1 WHERE ct_session_id = '$sid' AND pd_id = $productId"; $result = dbQuery($sql); } // an extra job for us here is to remove abandoned carts. // right now the best option is to call this function here //deleteAbandonedCart(); //header('Location: ' . $_SESSION['shop_return_url']); //} How do I make this compatible with with this particular Apache version.
  15. Hello, I am trying to setup an Apache, MySql, PHP combination on windows 2008 r2 machine and have gotten to the part where I am trying to setup PhpMyAdmin when i get an error stating "Call to undefined function mb_detect_encoding() in C:\...\...\gettext.inc on line 177" between google and this post: http://forums.phpfreaks.com/topic/42088-solved-scuttle-undefined-function/ It seemed likely to be that that the extension was commented out, so i verified the DLL was in the EXT directory and removed the comment for : extension=php_mbstring.dll then restarted the apache service. I then attempted to load the setup/index.php for PhpMyAdmin again, but it resulted in the same error. When i run php.exe -m It lists mbstring in the PHP Modules, however if i run <?php phpinfo(); ?> the resulting page lists NOTHING about mbstring... I would greatly appreciate any help regarding this issue. These are the various components and/or important info... OS: Windows 2008 R2 w/SP1 Apache: 2.4.4 win32 w/ ssl 0.9.8 PHP: v5.4.16 Win32 VC90x86 threadsafe MySql: 5.6.11.0 (presumably x86) PhpMyAdmin: 4.0.3 following setup guide: http://lifeofageekadmin.com/how-install-apache-2-4-php-5-4-and-mysql-5-5-21-on-windows-7/
  16. Hello, I need two rules in apache to work RewriteRule ^([^/]*)\.html$ index.php?page=$1 [L] RewriteRule ^([^/]*)/([^/]*)\.html$ index.php?pnumber=$1&page=$2 [L] First one rule does work and index.php?page=something redirect to /something.html Second rule does not work /index.php?pnumber=1&page=somthing need to be /1/something.html But when make this link i got 404 error the request url not found. Please can you tell me where is error, and how i can make to second rule work too? Thank you
  17. I have recently restructed my local web server and implemented VirtualHosts for using a subdomain. Currently the public_html is the directory for my domain and dev.domain.com lands in the dev directory, this is all working correctly. however, when I am working in my index.html in the dev directory and call for layout.css which is in static, it retreived the layout.css from the static folder in public_html/ and not the static directory in dev. How can I get around this issue? I have included the directory structure before if that helps. Sorry if my wording for explaining this is confusing. -root --public_html ---static ---etc --subdomains ---dev ----static ----etc ---fate Is the block in the vhost conf NameVirtualHost *:80 <VirtualHost *:80> serverName domain.com DocumentRoot "E:\root\public_html" </VirtualHost> NameVirtualHost *:80 <VirtualHost *:80> ServerName dev.domain.com ServerAlias dev.domain.com DocumentRoot "E:\root\subdomains\dev" <Directory "E:\root\subdomains\dev"> AllowOverride All order allow,deny Allow from all </Directory> </VirtualHost>
  18. Hi all, Hi All, I m new with php I m trying to run an open source php script on local host. i m using Easyphp 12.1 apache 2.4.2 php 5.4.6 MySql 5.5.27 1st page of script is load successfully with this url: http://127.0.0.1:8888/phplogin/ when i click on any link "Login" given on page i m facing an error "The connection was reset" and url change with This: http://127.0.0.1/phplogin/login.php/ (no port )
  19. Hi everybody, I am currently working with the php_serial.class to send out signals through the serial port of my computer. I set up a webserver on Windows with Apache and its working fine. The only problem is, that when I press the button on the homepage, it takes like 6 seconds to actually send something out the port. You guys have any ideas why this could be happening? I tested under Windows 7 and XP with the newest version of Apache Server and several different computers with different hardware. Always the same results. Here is the class: <?php define ("SERIAL_DEVICE_NOTSET", 0); define ("SERIAL_DEVICE_SET", 1); define ("SERIAL_DEVICE_OPENED", 2); /** * Serial port control class * * THIS PROGRAM COMES WITH ABSOLUTELY NO WARANTIES ! * USE IT AT YOUR OWN RISKS ! * * @author Rémy Sanchez <thenux@gmail.com> * @thanks Aurélien Derouineau for finding how to open serial ports with windows * @thanks Alec Avedisyan for help and testing with reading * @copyright under GPL 2 licence */ class phpSerial { var $_device = null; var $_windevice = null; var $_dHandle = null; var $_dState = SERIAL_DEVICE_NOTSET; var $_buffer = ""; var $_os = ""; /** * This var says if buffer should be flushed by sendMessage (true) or manualy (false) * * @var bool */ var $autoflush = true; /** * Constructor. Perform some checks about the OS and setserial * * @return phpSerial */ function phpSerial () { setlocale(LC_ALL, "en_US"); $sysname = php_uname(); if (substr($sysname, 0, 5) === "Linux") { $this->_os = "linux"; if($this->_exec("stty --version") === 0) { register_shutdown_function(array($this, "deviceClose")); } else { trigger_error("No stty availible, unable to run.", E_USER_ERROR); } } elseif(substr($sysname, 0, 7) === "Windows") { $this->_os = "windows"; register_shutdown_function(array($this, "deviceClose")); } else { trigger_error("Host OS is neither linux nor windows, unable tu run.", E_USER_ERROR); exit(); } } // // OPEN/CLOSE DEVICE SECTION -- {START} // /** * Device set function : used to set the device name/address. * -> linux : use the device address, like /dev/ttyS0 * -> windows : use the COMxx device name, like COM1 (can also be used * with linux) * * @param string $device the name of the device to be used * @return bool */ function deviceSet ($device) { if ($this->_dState !== SERIAL_DEVICE_OPENED) { if ($this->_os === "linux") { if (preg_match("@^COM(\d+):?$@i", $device, $matches)) { $device = "/dev/ttyS" . ($matches[1] - 1); } if ($this->_exec("stty -F " . $device) === 0) { $this->_device = $device; $this->_dState = SERIAL_DEVICE_SET; return true; } } elseif ($this->_os === "windows") { if (preg_match("@^COM(\d+):?$@i", $device, $matches) and $this->_exec(exec("mode " . $device)) === 0) { $this->_windevice = "COM" . $matches[1]; $this->_device = "\\.\com" . $matches[1]; $this->_dState = SERIAL_DEVICE_SET; return true; } } trigger_error("Specified serial port is not valid", E_USER_WARNING); return false; } else { trigger_error("You must close your device before to set an other one", E_USER_WARNING); return false; } } /** * Opens the device for reading and/or writing. * * @param string $mode Opening mode : same parameter as fopen() * @return bool */ function deviceOpen ($mode = "r+b") { if ($this->_dState === SERIAL_DEVICE_OPENED) { trigger_error("The device is already opened", E_USER_NOTICE); return true; } if ($this->_dState === SERIAL_DEVICE_NOTSET) { trigger_error("The device must be set before to be open", E_USER_WARNING); return false; } if (!preg_match("@^[raw]\+?b?$@", $mode)) { trigger_error("Invalid opening mode : ".$mode.". Use fopen() modes.", E_USER_WARNING); return false; } $this->_dHandle = @fopen($this->_device, $mode); if ($this->_dHandle !== false) { stream_set_blocking($this->_dHandle, 0); $this->_dState = SERIAL_DEVICE_OPENED; return true; } $this->_dHandle = null; trigger_error("Unable to open the device", E_USER_WARNING); return false; } /** * Closes the device * * @return bool */ function deviceClose () { if ($this->_dState !== SERIAL_DEVICE_OPENED) { return true; } if (fclose($this->_dHandle)) { $this->_dHandle = null; $this->_dState = SERIAL_DEVICE_SET; return true; } trigger_error("Unable to close the device", E_USER_ERROR); return false; } // // OPEN/CLOSE DEVICE SECTION -- {STOP} // // // CONFIGURE SECTION -- {START} // /** * Configure the Baud Rate * Possible rates : 110, 150, 300, 600, 1200, 2400, 4800, 9600, 38400, * 57600 and 115200. * * @param int $rate the rate to set the port in * @return bool */ function confBaudRate ($rate) { if ($this->_dState !== SERIAL_DEVICE_SET) { trigger_error("Unable to set the baud rate : the device is either not set or opened", E_USER_WARNING); return false; } $validBauds = array ( 110 => 11, 150 => 15, 300 => 30, 600 => 60, 1200 => 12, 2400 => 24, 4800 => 48, 9600 => 96, 19200 => 19, 38400 => 38400, 57600 => 57600, 115200 => 115200 ); if (isset($validBauds[$rate])) { if ($this->_os === "linux") { $ret = $this->_exec("stty -F " . $this->_device . " " . (int) $rate, $out); } elseif ($this->_os === "windows") { $ret = $this->_exec("mode " . $this->_windevice . " BAUD=" . $validBauds[$rate], $out); } else return false; if ($ret !== 0) { trigger_error ("Unable to set baud rate: " . $out[1], E_USER_WARNING); return false; } } } /** * Configure parity. * Modes : odd, even, none * * @param string $parity one of the modes * @return bool */ function confParity ($parity) { if ($this->_dState !== SERIAL_DEVICE_SET) { trigger_error("Unable to set parity : the device is either not set or opened", E_USER_WARNING); return false; } $args = array( "none" => "-parenb", "odd" => "parenb parodd", "even" => "parenb -parodd", ); if (!isset($args[$parity])) { trigger_error("Parity mode not supported", E_USER_WARNING); return false; } if ($this->_os === "linux") { $ret = $this->_exec("stty -F " . $this->_device . " " . $args[$parity], $out); } else { $ret = $this->_exec("mode " . $this->_windevice . " PARITY=" . $parity{0}, $out); } if ($ret === 0) { return true; } trigger_error("Unable to set parity : " . $out[1], E_USER_WARNING); return false; } /** * Sets the length of a character. * * @param int $int length of a character (5 <= length <= * @return bool */ function confCharacterLength ($int) { if ($this->_dState !== SERIAL_DEVICE_SET) { trigger_error("Unable to set length of a character : the device is either not set or opened", E_USER_WARNING); return false; } $int = (int) $int; if ($int < 5) $int = 5; elseif ($int > $int = 8; if ($this->_os === "linux") { $ret = $this->_exec("stty -F " . $this->_device . " cs" . $int, $out); } else { $ret = $this->_exec("mode " . $this->_windevice . " DATA=" . $int, $out); } if ($ret === 0) { return true; } trigger_error("Unable to set character length : " .$out[1], E_USER_WARNING); return false; } /** * Sets the length of stop bits. * * @param float $length the length of a stop bit. It must be either 1, * 1.5 or 2. 1.5 is not supported under linux and on some computers. * @return bool */ function confStopBits ($length) { if ($this->_dState !== SERIAL_DEVICE_SET) { trigger_error("Unable to set the length of a stop bit : the device is either not set or opened", E_USER_WARNING); return false; } if ($length != 1 and $length != 2 and $length != 1.5 and !($length == 1.5 and $this->_os === "linux")) { trigger_error("Specified stop bit length is invalid", E_USER_WARNING); return false; } if ($this->_os === "linux") { $ret = $this->_exec("stty -F " . $this->_device . " " . (($length == 1) ? "-" : "") . "cstopb", $out); } else { $ret = $this->_exec("mode " . $this->_windevice . " STOP=" . $length, $out); } if ($ret === 0) { return true; } trigger_error("Unable to set stop bit length : " . $out[1], E_USER_WARNING); return false; } /** * Configures the flow control * * @param string $mode Set the flow control mode. Availible modes : * -> "none" : no flow control * -> "rts/cts" : use RTS/CTS handshaking * -> "xon/xoff" : use XON/XOFF protocol * @return bool */ function confFlowControl ($mode) { if ($this->_dState !== SERIAL_DEVICE_SET) { trigger_error("Unable to set flow control mode : the device is either not set or opened", E_USER_WARNING); return false; } $linuxModes = array( "none" => "clocal -crtscts -ixon -ixoff", "rts/cts" => "-clocal crtscts -ixon -ixoff", "xon/xoff" => "-clocal -crtscts ixon ixoff" ); $windowsModes = array( "none" => "xon=off octs=off rts=on", "rts/cts" => "xon=off octs=on rts=hs", "xon/xoff" => "xon=on octs=off rts=on", ); if ($mode !== "none" and $mode !== "rts/cts" and $mode !== "xon/xoff") { trigger_error("Invalid flow control mode specified", E_USER_ERROR); return false; } if ($this->_os === "linux") $ret = $this->_exec("stty -F " . $this->_device . " " . $linuxModes[$mode], $out); else $ret = $this->_exec("mode " . $this->_windevice . " " . $windowsModes[$mode], $out); if ($ret === 0) return true; else { trigger_error("Unable to set flow control : " . $out[1], E_USER_ERROR); return false; } } /** * Sets a setserial parameter (cf man setserial) * NO MORE USEFUL ! * -> No longer supported * -> Only use it if you need it * * @param string $param parameter name * @param string $arg parameter value * @return bool */ function setSetserialFlag ($param, $arg = "") { if (!$this->_ckOpened()) return false; $return = exec ("setserial " . $this->_device . " " . $param . " " . $arg . " 2>&1"); if ($return{0} === "I") { trigger_error("setserial: Invalid flag", E_USER_WARNING); return false; } elseif ($return{0} === "/") { trigger_error("setserial: Error with device file", E_USER_WARNING); return false; } else { return true; } } // // CONFIGURE SECTION -- {STOP} // // // I/O SECTION -- {START} // /** * Sends a string to the device * * @param string $str string to be sent to the device * @param float $waitForReply time to wait for the reply (in seconds) */ function sendMessage ($str, $waitForReply = 0.1) { $this->_buffer .= $str; if ($this->autoflush === true) $this->flush(); usleep((int) ($waitForReply * 1000000)); } /** * Reads the port until no new datas are availible, then return the content. * * @pararm int $count number of characters to be read (will stop before * if less characters are in the buffer) * @return string */ function readPort ($count = 0) { if ($this->_dState !== SERIAL_DEVICE_OPENED) { trigger_error("Device must be opened to read it", E_USER_WARNING); return false; } if ($this->_os === "linux") { $content = ""; $i = 0; if ($count !== 0) { do { if ($i > $count) $content .= fread($this->_dHandle, ($count - $i)); else $content .= fread($this->_dHandle, 128); } while (($i += 128) === strlen($content)); } else { do { $content .= fread($this->_dHandle, 128); } while (($i += 128) === strlen($content)); } return $content; } elseif ($this->_os === "windows") { /* Do nohting : not implented yet */ } trigger_error("Reading serial port is not implemented for Windows", E_USER_WARNING); return false; } /** * Flushes the output buffer * * @return bool */ function flush () { if (!$this->_ckOpened()) return false; if (fwrite($this->_dHandle, $this->_buffer) !== false) { $this->_buffer = ""; return true; } else { $this->_buffer = ""; trigger_error("Error while sending message", E_USER_WARNING); return false; } } // // I/O SECTION -- {STOP} // // // INTERNAL TOOLKIT -- {START} // function _ckOpened() { if ($this->_dState !== SERIAL_DEVICE_OPENED) { trigger_error("Device must be opened", E_USER_WARNING); return false; } return true; } function _ckClosed() { if ($this->_dState !== SERIAL_DEVICE_CLOSED) { trigger_error("Device must be closed", E_USER_WARNING); return false; } return true; } function _exec($cmd, &$out = null) { $desc = array( 1 => array("pipe", "w"), 2 => array("pipe", "w") ); $proc = proc_open($cmd, $desc, $pipes); $ret = stream_get_contents($pipes[1]); $err = stream_get_contents($pipes[2]); fclose($pipes[1]); fclose($pipes[2]); $retVal = proc_close($proc); if (func_num_args() == 2) $out = array($ret, $err); return $retVal; } // // INTERNAL TOOLKIT -- {STOP} // } ?> And this is the index file of the website <?php //check the GET action var to see if an action is to be performed if (isset($_GET['action'])) { //Action required //Load the serial port class include "php_serial.class.php"; //Initialize the class $serial = new phpSerial(); //Specify the serial port to use... in this case COM1 $serial->deviceSet("COM1"); //Set the serial port parameters. The documentation says 9600 8-N-1, so $serial->confBaudRate(9600); //Baud rate: 9600 $serial->confParity("none"); //Parity (this is the "N" in "8-N-1") $serial->confCharacterLength(; //Character length (this is the "8" in "8-N-1") $serial->confStopBits(1); //Stop bits (this is the "1" in "8-N-1") $serial->confFlowControl("none"); //Device does not support flow control of any kind, //so set it to none. //Now we "open" the serial port so we can write to it $serial->deviceOpen(); //Issue the appropriate command according to the serial relay //board documentation if ($_GET['action'] == "on") { //to turn relay number 1 on, we issue the command for ($x = 1; $x<20; $x++) //loops output $serial->sendMessage("3"); } else if ($_GET['action'] == "off") { //to turn relay number 1 off, we issue this command for ($x = 1; $x<20; $x++) //loops output $serial->sendMessage("2"); } //We're done, so close the serial port again $serial->deviceClose(); }?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Serial Control Test</title> </head> <body> <h1>Serial Control Test</h1> <p><a href="<?=$_SERVER['PHP_SELF'] . "?action=on" ?>"> Click here to turn the system on.</a></p> <p><a href="<?=$_SERVER['PHP_SELF'] . "?action=off" ?>"> Click here to turn the system off.</a></p> </body> </html> Thanks for your help guys!
  20. I have a php login script which checks the user and displays the page without any issues on my production server which is on internet. The same php script is not working when i run it locally, am using win xp, UNISERV(Like XAMPP, WAMP). i have tested the database, it is working fine. I have tested sample session programs, it is creating the session in the tmp folder. But when I run login.php, it just give me blank page. Can someone help. Pl find my code below: <?php // login.php include_once 'common.php'; include_once 'db2.php'; session_start(); $uid = isset($_POST['uid']) ? $_POST['uid'] : $_SESSION['uid']; $pwd = isset($_POST['pwd']) ? $_POST['pwd'] : $_SESSION['pwd']; if(!isset($uid)) { ?> <!DOCTYPE html PUBLIC "-//W3C/DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Test - Login</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <head> <style type="text/css"> <!-- .style1 { font-size: 16px; font-family: Verdana, Arial, Helvetica, sans-serif; } .style3 { font-size: 12px; font-family: Verdana, Arial, Helvetica, sans-serif; } body { background-color: #D7F0FF; margin-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; } --> </style> </head> <body> <h1 class="style1"> <br><br>Exceltron Site -Testing Login Required </h1> <span class="style3"><br> You <strong>must login to access this area </strong>of the site. <br> <br> If you are not a registered user, please contact your Admin to sign up for instant access!</span> <p><form method="post" action="<?=$_SERVER['PHP_SELF']?>"> <span class="style3">User ID: <input type="text" name="uid" size="12" /> <br> <br /> Password:</span> <input type="password" name="pwd" SIZE="12" /> <br> <br /> <input type="submit" value="Login" /> </form></p> </body> </html> <?php exit; } $_SESSION['uid'] = $uid; $_SESSION['pwd'] = $pwd; dbConnect("exceltron"); $sql = "SELECT * FROM user WHERE userid = '$uid' AND password = '$pwd'"; $result = mysql_query($sql); if (!$result) { error('A database error occurred while checking your '. 'login details.\\nIf this error persists, please '. 'contact you@example.com.'); } if (mysql_num_rows($result) == 0) { unset($_SESSION['uid']); unset($_SESSION['pwd']); ?> <!DOCTYPE html PUBLIC "-//W3C/DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title> Access Denied </title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <style type="text/css"> <!-- .style1 { font-size: 16px; font-family: Verdana, Arial, Helvetica, sans-serif; } .style3 { font-size: 12px; font-family: Verdana, Arial, Helvetica, sans-serif; } --> </style> </head> <body> <br/> <br/> <h1 class="style1"> Access Denied </h1> <p class="style3">Your user ID or password is incorrect, or you are not a registered user on this site. To try logging in again, click <a href="<?=$_SERVER['PHP_SELF']?>">here</a>. To access, please contact our Admin !</a>.</p> </body> </html> <?php exit; } $username = mysql_result($result,0,'fullname'); $_SESSION['user'] = mysql_result($result,0,'userid'); ?>
  21. I've been using WAMPs since I started web development but recently I decided to get my hands a little dirty and to set Apache, PHP, MySQL and phpMyAdmin up by myself. I had been fiddling around in the Apache configuration for a while so I have a little experience. I installed Apache 2.2.22, PHP 5.3.5, MySQL 5.5 and phpMyAdmin 3.5.5 and after a little configuration I got everything to work together. I quickly ran into problems with Apache and my lack of understanding of it. Many of the things that used to work perfectly in the WAMP httpd.conf have either no effect on my fresh install or prevent me from starting the server. Some examples: The ErrorLogFormat directive prevents Apache from starting which is weird because it's part of the core module. Even though I have both mod_info.so and mod_status.so, if I try to start with SetHandler server-info or SetHandler server-status (within Location directives of course) the Apache will not start. For some reason the installation does not come with mod_authz_core.so which I rely on quite a bit (not sure if that's because it's obsolete and has been replaced or what). I don't know enough about compiling Apache or whatever you need to do to add additional modules. Some of the directives I use seem to be completely ignored even though I know the modules are loaded. For example, I made my own index page with handpicked icons. The mod_autoindex.so takes care of these things and I'm using a bunch of AddDescription, AddIcon, AddIconByType and other directives like that. Everything seems to work except that it's unable to find my icons, which are in the server root in a folder called "icons" just like on my WAMP setup so nothing has changed - except that things aren't working. The great thing about the Apache web server is that if it isn't able to start because of misconfiguration it only shows a window saying "The requested operation has failed!". The programmers could just as well have written something like "Hahaha! You idiot! You're screwed now!".
  22. Hey all I just replaced all our main gateways that house all our LAN based office PHP Apps I have made and the issue is that database parsing is not working like they did on the older systems. I currenly have PHP 5.3.3 and MySQL 5.1.66 and the code is outputting this on the screen rather then the $row[x] from the database. I'm sure this is a simple fix in the configuration somewhere to get these pages working again on the new setup. Annual Discount Card Purchases: '.$row[2].', '.$row[1].' ' ; } // Close Database Connection mysql_close(); ?> Gift Certificate Purchases: '.$row[1].' :: '.$row[12].' :: '.$row[13].' :: '.$row[14].' ' ; } // Close Database Connection mysql_close(); ?> Any help getting this to parse the data correcly and not print my code would be excellent. Remember nothing about the old working code has changes this is simple running the old PHP files on MUCH newer PHP and MySQL Versions. Best regards, TRI0N!
  23. Hello everybody, This is one of my first times that i need to configure a .htacces file, so maybe is this a very simple question but I cant figure it out by myself . Situation: I have a local site, that reachable under the URL: "framework.dev". But I need to configure a rewrite rule: rewrite all the URL's to index.php, except the exact URL: 'framework.dev'. example: framework.dev/users //Rewrite this url to index.php framework.dev/users/edit/1 //Rewrite this url to index.php framework.dev/login //Rewrite this url to index.php etc.. framework.dev //Do not rewrite How do i formulate the correct .htacces rewrite rule? Thank you for you time, Greetings Jelte PS: I you know a good .htaccess tutorial please inform me
  24. ozrhod

    Webdav

    Hi PHPfreakers, I have an intranet that users upload files to. When they upload a file it renamed the file to a GUID string and then stores this in a mySQL db (the db also allows for permissions and file sharing - via the intranet webpage). Now, however, I want to make it so I can get to my files (or ones I have permission to) from My Computer (or the UNIX/Mac/Linux equivalent). I'm learning about webDAV at the moment and thought of this as a potential solution, however I am running into a problem becaause all the files are in one directory, not one firectory per user. Any ideas what I can do? How I can make this work better? Oh, FYI - http://code.google.com/p/sabredav/ this is the library I have been looking at using because of its support for mySQL permissions and PHP library. Hope someone can help
  25. Hello Everyone. Till now I used to work on XAMPP and WAMP but today I tried installing Apache,PHP,and MySQL seperately(MAnually). For that I downloaded Apache(httpd-2.0.64-win32-x86-openssl-0.9.8o.msi), PHP(php-5.3.17-Win32-VC9-x86.msi) MySQL(mysql-5.5.28-win32.msi). First I installed Apache.Everything went right and on opening http://localhost it said that apache is correctly installed on your pc. Then I installed PHP.While installing,it asked for httpd.conf file so I provided it and everything went fine. Then I created a file named phpinfo.php in htdocs folder and wrote the following code in it <?php phpinfo(); ?> But when I opened the url http://localhost/phpinfo.php it is showing the following error. Please hefp me out.Unable to solve it.
×
×
  • 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.