Jump to content

wrathican

Members
  • Posts

    446
  • Joined

  • Last visited

    Never

Everything posted by wrathican

  1. im just lazy. i like being able to do things automatically. i guess i'll just have to restart the service myself:( bah @ manual computer labour!!!
  2. Ah sorry I should have posted my bat code. All it says is: net stop wampapache net start wampapache If thats the wrong way to go about it. Please let me know. Thanks!!
  3. Hi there folks. I don't know about you but i use subdomains on my localhost to make developing that much easier. I have created a php script to manage these subdomains. It is a very basic cut down version of the current index.php file, that accesses the windows HOSTS file and writes an entry for the new 'project' you create. It also accesses the httpd-vhosts.conf file and writes a virual host section in there too. after it writes to these files it then restarts apache by running a batch file using the exec command. You need to restart apache for the vhost information to take effect. My problem appears when restarting apache. Because the web service stops running for a moment the rest of the script fails to run. What i am asking is is there a way of detecting/performing a service restart using php? hope fully looking at my script might help you understand/help me solve my problem! <?php session_start(); # Default File Locations $hosts = '../../../../../../../../Windows/System32/drivers/etc/HOSTS'; $vhosts = '../../../../../../../../wamp/bin/apache/Apache2.2.11/conf/extra/httpd-vhosts.conf'; #Project Processing if(isset($_GET['action']) && $_GET['action'] != ''){ $action = $_GET['action']; switch($action){ case "addproj": $name = htmlentities(strtolower(preg_replace('/\s+/', '_', $_POST['name'])), ENT_QUOTES); if(!is_dir($name)){ $projDir = mkdir($name); if($projDir){ $rootDir = mkdir($name.'/htdocs'); if($rootDir){ mkdir($name.'/logs'); #add to hosts file and vhosts // hosts $file = fopen($hosts, 'a'); if($file){ fwrite($file, "\n127.0.0.1\t\t".$name.".localhost"); fclose($file); } $file = fopen($vhosts, 'a'); if($file){ $vhosts_a = " #start$name <VirtualHost *:80> DocumentRoot \"C:/wamp/www/$name/htdocs\" ServerName $name.localhost ErrorLog \"logs/$name-error.log\" CustomLog \"logs/$name-access.log\" common </VirtualHost> #end$name"; fwrite($file, $vhosts_a); fclose($file); } $restartfile = 'restart.bat'; exec($restartfile); }else{ $_SESSION['error'] = "Cannot create root directory"; rmdir($name); } }else{ $_SESSION['error'] = "Cannot create project directory"; } }else{ $_SESSION['error'] = "Project already exists. Please specify another name."; } break; case "info": phpinfo(); die(); break; } } #Content ?> <!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> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Project Management</title> <link rel="stylesheet" type"text/css" href="css.css" /> </head> <body> <h2>Tools</h2> <ul class="tools"> <li><a href="?action=info">phpinfo()</a></li> <li><a href="phpmyadmin/">phpmyadmin</a></li> <li><a href="sqlitemanager/">sqlitemanager</a></li> </ul> <h2>Projects</h2> <h3>Create Project</h3> <p class="error"> <?php echo (isset($_SESSION['error'])) ? $_SESSION['error'] : ''; ?> <form id="addproj" action="?action=addproj" method="post" > <label for="name">Name:</label> <input type="text" name="name" id="name" /> <input type="submit" name="create" value="Create" /> </form> <h3>Current Projects</h3> <ul class="projects"> <?php $lines = file_get_contents($hosts); $projects = split("\n", $lines); for($i = 0; $i < count($projects); $i++){ if($i > 21 && $projects[$i] != ''){ $url = trim(substr($projects[$i], 9)); $name = preg_replace('~\.localhost~', '', $url); echo "<li><a href=\"http://$url\">$name</a></li>"; } } ?> </ul> </body> </html> <?php unset($_SESSION['error']); Thanks in advance Wrath
  4. I write this in the hope that it will help a few people out there. There are many ways in which to debug JavaScript. Some involve websites, and some involve browsers. The best way I have found to debug Javascript is to use Mozilla Firefox with the FireBug add-on. If you are a developer and do not have these, then you are doing something wrong. FireBug provides excellent JS debugging, HTTP Request monitoring and inline html editing, among other features. FireFox has the advantage of being cross-platform allowing any add-ons to be platform independent too. Using other browsers error/debugging tools just dont cut it for me. Stay away from the Internet Explorer JS debugging client. It is terrible, although since IE8 it has become more informative, but you cannot use the browser again until it's closed. Another great way to debug JS and follow best practices is by pasting your script into JSLint. This provides a list of things wrong with your script. If you use AJAX then use JSON. Please do NOT use eval. Eval is EVIL as JSLint will constantly remind you of! Use a JSON parser. Preferrably this one kindly provided from the people over at JSON.org Please feel free to add your comments/debugging tips!
  5. Hey people. Im facing a bit of a dilema. Im making an image gallery and i currently create thumbnails when an image is uploaded to the server. i am hitting some tiny PITA's at the moment though, as when a user decides to delete and image, i have to check that each thumbnail and main image i want to delete exists, then delete them from the server and then from the database when i know they have been deleted. creating a thumbnail on the fly seems to be the easiest solution. as i would have just one entry in the database and one file stored locally. I have seen a set of files called phpThumb, which seem like they would suit my needs. but i'm a bit unsure on the best way to approach this. your advice would be most welcomed. Thanks Wrath
  6. that would only replace a maximum of two spaces. what if it were accidentally more than that? the regex would be better
  7. the best you can do i have x amount of file input boxes and select an file for each. name them all something like 'file[]' ensuring you have the '[]' in the name. this will submit the x amount of files as an array. simply loop through them on the processing page. $x = $_FILES['file']; // this is an array containing all of the files selected for($i = 0; $i < count($x); $i++){ echo $x[$i]['name']; }
  8. my advice would be to read up on multi dimensional arrays for you your problem, you have an array containing arrays: $array = array(); $array['one'] = array(); $array['one']['two'] = 'hello world'; var_dump($array); that should print something like Array(){ 'one' => Array(){ 'two' => hello world } }
  9. Hey people i am trying to install smarty on my webserver so that we do not need to include it with every website we make. I am having a little problem: my php.ini says that my include_path is: .:/etc/php5/apache2/includes/Smarty-2.6.22/libs and sure enough, all the required files are located in "/etc/php5/apache2/includes/Smarty-2.6.22/libs" ive restarted the webserver and tried different combinations in the ini but with no luck. what could i be doing wrong? cheers Wrath
  10. Hey people i am trying to install smarty on my webserver so that we do not need to include it with every website we make. I am having a little problem: my php.ini says that my include_path is: .:/etc/php5/apache2/includes/Smarty-2.6.22/libs and sure enough, all the required files are located in "/etc/php5/apache2/includes/Smarty-2.6.22/libs" ive restarted the webserver and tried different combinations in the ini but with no luck. what could i be doing wrong? cheers Wrath
  11. what he's asking for is the error that appears in your browser. eg: "Fatal Error: Missing } in /some/folder/where/your/script/is.php on line 26" is the error actually coming from that script?
  12. i have no idea, but there are a lot of more expereinced people on here, leave it open and someone will find a cure! sorry i couldnt help
  13. yes i would copy and paste just to make sure im not familiar with WP, so i can only do so much.
  14. are you sending the data from a form on a previous page? if so, can we see it?
  15. edit: the mysql_error() needs to go before the mysql_close(), don't know if you tested it that way. change it to this: <?php //previous code above - starting from mysql_query $result = mysql_query($query); if($result) { echo "yes"; }else{ echo "no"; } ?> that should tell you if your query executed successfully
  16. <select name="podcast_programming_years"> <option value=''>Select:</option> <?php for($py=1; $py<50; $py++){ echo"<option value='$py'>$py</option>"; } ?> </select>
  17. have a page called display_students.php (or similar) and use POST in your form to send the value of the select. the value of the select should be the id of the selected student in the table. your page would then be something like: <?php $id = $_POST['student']; //query $query = "SELECT * FROM students WHERE id='$id' LIMIT 1"; //display your data ?>
  18. put this at the end of your script: echo mysql_error(); see if you have an error in your sql
  19. simple answer "Yes" long answer "Yes, but..." and the but is: If you send too many errors though the query string, they have a great possibility of being truncated. i guess it is also considered as a security flaw. if you must do it that way (which i strongly advise against!) you do something like the following: <?php //$error = the array of errors for($i = 0; $i < count($error); $i++){ $qs .= "error[]={$error[$i]]&"; } header("Location: index.php?$qs"); ?> then loop through $_GET['error'] on the display page and display accordingly.
  20. can i ask what the full error is? including script names. is this script included in any other files? also try encasing the first if statement ("if ( function_exists('register_sidebar') )") in curly braces, so: <?php if ( function_exists('register_sidebar') ){ register_sidebar(array( 'before_widget' => '<li id="%1$s" class="widget %2$s">', 'after_widget' => '</li>', 'before_title' => '<h2 class="widgettitle">', 'after_title' => '</h2>', )); } ?>
  21. well i make line 26 if ( false !== ( $display = kubrick_header_display() ) ) {
  22. look up mysql joins. they will only work if the tables are related however. so you have a column in both tables called ID that are the same for each row. there is a tutorial on phpfreaks tutorials
  23. according to my editor there is no '}' on line 26.... is that the whole script, from line 1?
  24. you need to loop through each updater <?php for($i = 0; $i < count($Update); $i++){ //run your update code } ?>
×
×
  • 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.