Jump to content

herghost

Members
  • Posts

    699
  • Joined

  • Last visited

Everything posted by herghost

  1. Array ( [0] => #Sat Jan 07 07:04:01 UTC 2012 ) Array ( [0] => isactive [1] => true ) Array ( [0] => level-name [1] => world ) Array ( [0] => enable-query [1] => false ) Array ( [0] => allow-flight [1] => false ) Array ( [0] => server-port [1] => 25565 )
  2. Hi Andy Thanks for your reply If I run your code (removing the extra $ sign) I get a host of errors: Undefined offset: 1 in C:\wamp\www\bm\text.php on line 42 = $parts[0] = $parts[1]; Undefined offset: 1 in C:\wamp\www\bm\text.php on line 43 = $vars[$parts[0]] = $parts[1]; I have also noticed that the 1st couple of lines are commented with # so I have removed these lines wondering if this was causing the error, but still get them: $file_handle = fopen("saves/server.properties", "rb"); while (!feof($file_handle) ) { $line_of_text = fgets($file_handle); if( !preg_match('/^#.*?\n/',$line_of_text) ) echo $line_of_text . "<br>"; $parts = explode('=', $line_of_text); $parts[0] = $parts[1]; $vars[$parts[0]] = $parts[1]; }
  3. Hi everyone I am using this code which is an example from a website <?php $file_handle = fopen("myfile", "rb"); while (!feof($file_handle) ) { $line_of_text = fgets($file_handle); $parts = explode('=', $line_of_text); print $parts[0] . $parts[1]. "<BR>"; } fclose($file_handle); ?> Which does what it is meant to, however what I am trying to do is put all the input into a form, so values can be changed. How do I separate each part? Eg the 1st line of the files reads isactive = true, how would I grab this so I can put it back to the file later as isactive = false? Not all the options are true/false, most are just strings or ints. Thanks
  4. Thanks This throws up a warning but does the job mkdir("saves/".$playername, 0777); mkdir("saves/".$playername."/".$worldname."", 0777); Should I somehow be moving into the saves/playername dir before creating the worldname dir?
  5. Im simply having a problem with structuring a directory structure for mkdir mkdir("saves/".$worldname."/".$playername, 0777); The middle "/" is causing issues, if I take it out I have no problem in creating a folder name saves/worldnameplayername/ just want to add playername as a sub-dir. I have tried every combination I can think of to get it to accept the divider :'( Any help?
  6. Hi all I am pulling my hair out trying to get the following script to work <?php error_reporting(E_ALL); ini_set('display_errors', '1'); if (!function_exists("ssh2_connect")) die("function ssh2_connect doesn't exist"); // log in at server1.example.com on port 22 if(!($con = ssh2_connect("*.*.*.*", 22))){ echo "fail: unable to establish connection\n"; } else { // try to authenticate with username root, password secretpassword if(!ssh2_auth_password($con, "root", "********")) { echo "fail: unable to authenticate\n"; } else { // allright, we're in! echo "okay: logged in...\n"; // execute a command if (!($stream = ssh2_exec($con, "ls -al" ))) { echo "fail: unable to execute command\n"; } else { echo "should be ok"; // collect returning data from command stream_set_blocking($stream, true); $data = "path to file checked by logging into WINSCP and looking at properties. Is a .txt file"; echo $data; while ($buf = fread($stream,4096)) { $data .= $buf; } fclose($stream); } } } Basically shouldnt this display the contents of the file to me? On screen I just get What is my error? Thanks
  7. This may spill over into java, just not quite sure yet! Basically what I am trying to do, is fill a box with text, click a button which runs a function which send the text in the box via a JSON request to an external server. The JSON works fine, I just want a way of submitting the string which hopefully doesnt involve a form, but its the only way I can think of! Any other ideas?
  8. Hi all My script now works, and the files are added to the zip, however the 1st two directories in my zip are 'uploads' and then the username, basically I want the zipped files to start from within the users directory and I just cant figure out what I need to do, any help would be greatly appreciated, been looking at these 30 odd lines for 6 hours //make zip $sourcefolder = "uploads/".$username.""; $zipfilename = "uploads/".$username.".zip"; $timeout = 5000; $dirlist = new RecursiveDirectoryIterator($sourcefolder); $filelist = new RecursiveIteratorIterator($dirlist); ini_set('max_execution_time', $timeout); $zip = new ZipArchive(); if ($zip->open("$zipfilename", ZipArchive::CREATE) !== TRUE) { die ("Could not open archive"); } foreach ($filelist as $key=>$value) { $zip->addFile(realpath($key), $key) or die ("ERROR: Could not add file: $key"); } $zip->close(); echo "<br>Archive ". $zipfilename . " created successfully."; ?> <br /><a href="http:<?php echo $zipfilename;?>" target="_blank"> Download <?php echo $zipfilename?></a>
  9. Fixed //make zip // Config Vars $sourcefolder = "uploads/".$username.""; // Default: "./" $zipfilename = "uploads/".$username.".zip"; // Default: "myarchive.zip" $timeout = 5000; // Default: 5000 // instantate an iterator (before creating the zip archive, just // in case the zip file is created inside the source folder) // and traverse the directory to get the file list. $dirlist = new RecursiveDirectoryIterator($sourcefolder); $filelist = new RecursiveIteratorIterator($dirlist); // set script timeout value ini_set('max_execution_time', $timeout); // instantate object $zip = new ZipArchive(); // create and open the archive if ($zip->open("$zipfilename", ZipArchive::CREATE) !== TRUE) { die ("Could not open archive"); } // add each file in the file list to the archive foreach ($filelist as $key=>$value) { $zip->addFile(realpath($key), $key) or die ("ERROR: Could not add file: $key"); } // close the archive $zip->close(); echo "<br>Archive ". $zipfilename . " created successfully."; // And provide download link ?> <br /><a href="http:<?php echo $zipfilename;?>" target="_blank"> Download <?php echo $zipfilename?></a>
  10. Hi all, I am trying to create a zip from a folder using php. My script works if I replace the variable $username with a constant, but with the variable I get nothing at all, no errors, no files. I have error reporting on as well. // Config Vars $username = "user"; $sourcefolder = "uploads/" . $username . "" ; // Default: "./" $zipfilename = "uploads/" . $username . ""; // Default: "myarchive.zip" $timeout = 5000 ; // Default: 5000 // instantate an iterator (before creating the zip archive, just // in case the zip file is created inside the source folder) // and traverse the directory to get the file list. $dirlist = new RecursiveDirectoryIterator($sourcefolder); $filelist = new RecursiveIteratorIterator($dirlist); // set script timeout value ini_set('max_execution_time', $timeout); // instantate object $zip = new ZipArchive(); // create and open the archive if ($zip->open("$zipfilename", ZipArchive::CREATE) !== TRUE) { die ("Could not open archive"); } // add each file in the file list to the archive foreach ($filelist as $key=>$value) { $zip->addFile(realpath($key), $key) or die ("ERROR: Could not add file: $key"); } // close the archive $zip->close(); echo "Archive ". $zipfilename . " created successfully."; // And provide download link ?> <a href="http:<?php echo $zipfilename;?>" target="_blank"> Download <?php echo $zipfilename?></a> Whats going on?! Many thanks Dave
  11. Thats exactly what I was aiming at! Cheers!
  12. Basically I am doing this: <?php $json = new MYCALL($host, $port, $username, $password, $salt); print_r($json->call('getBits',Array())); ?> Which prints the original string, basically how do I just take the result of [success]?
  13. Hi mate, its from a PHP page that calls a game server api. I think I understand that I have the output of the array as a string???
  14. Hi all, I am sure this is simple, but I just can't wrap my head around a suitable way of doing this! Basically I have my JSON result as something like : Array ( [result] => success [source] => gotBits [success] => 64 ) What I simply want to do is get the [success] output and store it as a variable. I have been looking at json_decode, but I cant find any examples for arrays, just strings? Can you push me in the right direction?
  15. Hi all, I am trying to create a wordpress theme that matches the rest of my website, however I have been stuck for a few days on the same bloody thing! Something in my css is causing my right sidebar to appear under my last post. (www.minecrafthosting.co/blog) I just cant seem to get it to appear inline. Can anyone see my error? The CSS validates which doesnt help me much @charset "utf-8"; /* CSS Document *//* Theme Name: MinecraftHosting.co Theme URI: http://www.minecrafthosting.co/ Description: Custom Theme Version: 1.0 Author: MinecraftHosting.co */ .centered { display: block; margin-left: auto; margin-right: auto; } .alignright { float: right; margin-left: 15px; } .alignleft { float: left; margin-right: 15px; } body { padding: 0; margin:0 auto; } td { font-family:Corbel; color:#a6aaa6; font-size:16px; text-align: center; } h1, h2, h3, h4, h5, h6 { clear: both; font-weight: normal; font-family:Corbel; } #top { width:100%; } #container { width:1000px; margin-left:auto; margin-right:auto; overflow:auto; z-index:1; color:#06C; } .container { width:50%; margin-top:55px; float:right; min-height:60px; } .container a:link { text-decoration:none; color: #A0FF42; text-decoration:none; font-family:Corbel; font-size: 16px; } .container a:visited { text-decoration:none; color: #A0FF42; text-decoration:none; font-family:Corbel; font-size: 16px; } .container a:hover { text-decoration:underline; font-family:Corbel; font-size: 16px; color: #F00; font-weight: 600; } .container a:active { text-decoration:none; color: #0CF; text-decoration:none; font-family:Corbel; font-size: 16px; } .static-top { width:100%; margin-left:auto; margin-right:auto; background: url(images/topbg.png) #000 top left repeat-x ; z-index:2; } .logo { min-height:60px; margin-top:30px; width:35%; float:left; } #topbg { background-color:#000; margin-top:40px; } /**/ /* Left Box*/ #leftbox .holder { margin-top:35px; float:left; width:400px; margin-left:15px; } #leftbox .single { margin-top:35px; float:left; width:750px; margin-left:15px; } /*Main Dia*/ #middle { width:100%; background:url(images/bg.jpg) repeat; min-height:500px; } .middlebox { width:1000px; margin-left:auto; margin-right:auto; overflow:auto; z-index:1; padding-left:5px; padding-top:35px; } .postdata { width:1000px; } /*footer*/ #footer { width:100%; background-color:#000; min-height:150px; bottom:0; list-style-type: none; padding-bottom:20px; clear: both; } .bottombox { width:1000px; margin-left:auto; margin-right:auto; overflow:auto; z-index:2; padding-left:5px; padding-top:35px; } .footerlinks { width:250px; float:left; } #footer li a { list-style:none; text-decoration: none; text-align:left; width:10em; color:#FFF; font-family:Corbel; } #footer li a:hover { list-style:none; text-decoration: none; text-align:left; width:10em; color:#0F0; font-family:Corbel; } #footer h3 { font-family:Corbel; color:#FFF; font-size:20px; font-style:italic; } .aboutbox { padding-top:35px; width:350px; float:right; font-family:Corbel; color:#FFF; font-size:12px; text-align:right; } .companybox { width:250px; float:left; margin-left:35px } ol, ul { list-style: none; } #primary, #secondary { float: right; overflow: hidden; width: 220px; } #secondary { clear: right; } #sidebar { float:right; width:220px;; } Thanks
  16. Hi all I am wondering if someone could help me with a join statement, basically I dont have a clue where to start! I have read some sql tut;s but its beyond me. Basically I am writing a script which checks a users balance from table 'money'and then updating the balance minus the cost of a action which is an int. The table money is simple p_name, balance basically the steps I have are: 1, get current balance 2, if conditions met, subtract int from current balance 3, update balance The problem I have is that in JDBC a while loop will cause an java output error in console even though the command operates as it should if you use more than one statement This is a plugin for minecraft. My code package me.herghost.Fiery.commands; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import me.herghost.Fiery.util.Configuration; import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; public class banCommand implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) { readCommand((Player) sender, commandLabel, args); return true; } @SuppressWarnings("unused") private void readCommand(Player player, String cmd, String[] args ) { if(cmd.equalsIgnoreCase("ban")&& player instanceof Player) { Bukkit.getOfflinePlayer(args[0]).setBanned(true); if (Bukkit.getPlayer(args[0]) != null) Bukkit.getPlayer(args[0]).kickPlayer("Banned by admin."); Command.broadcastCommandMessage(player, "Banning " + args[0]); String user = Configuration.getString("settings.mysql.user"); String pass = Configuration.getString("settings.mysql.pass"); String url = "jdbc:mysql://localhost:3306/Fiery"; String v = Configuration.getString("money.iscalled"); boolean t = Configuration.getBoolean("money.isenabled"); int cost = Configuration.getInt("commandcharge.ban"); int balance; Player p = (Player) player; try { Connection conn = DriverManager.getConnection(url, user, pass); Statement select = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); ResultSet rs = select.executeQuery("SELECT balance FROM money WHERE p_name ='" + p.getName() + "'"); while (rs.next()) { balance = rs.getInt("balance"); if(t = true && cost > 0) { int nbalance; if(cost < balance ) { nbalance = balance - cost; int rs1 = select.executeUpdate("UPDATE money SET balance = '" + nbalance + "'WHERE p_name ='" + p.getName() + "'"); p.sendMessage("You have been charged " + cost + " " + v + " - your new balance is " + nbalance + " " + v + ""); } else { p.sendMessage("Sorry, your balance is to low to execute this command"); } } } select.close(); } catch (SQLException e1) { e1.printStackTrace(); } } } } and the error 2011-11-30 22:58:19 [sEVERE] java.sql.SQLException: Operation not allowed after ResultSet closed 2011-11-30 22:58:19 [sEVERE] at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1073) 2011-11-30 22:58:19 [sEVERE] at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:987) 2011-11-30 22:58:19 [sEVERE] at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:982) 2011-11-30 22:58:19 [sEVERE] at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:927) 2011-11-30 22:58:19 [sEVERE] at com.mysql.jdbc.ResultSetImpl.checkClosed(ResultSetImpl.java:794) 2011-11-30 22:58:19 [sEVERE] at com.mysql.jdbc.ResultSetImpl.next(ResultSetImpl.java:7145) 2011-11-30 22:58:19 [sEVERE] at me.herghost.Fiery.commands.banCommand.readCommand(banCommand.java:61) 2011-11-30 22:58:19 [sEVERE] at me.herghost.Fiery.commands.banCommand.onCommand(banCommand.java:23) 2011-11-30 22:58:19 [sEVERE] at org.bukkit.command.PluginCommand.execute(PluginCommand.java:40) 2011-11-30 22:58:19 [sEVERE] at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:163) 2011-11-30 22:58:19 [sEVERE] at org.bukkit.craftbukkit.CraftServer.dispatchCommand(CraftServer.java:364) 2011-11-30 22:58:19 [sEVERE] at net.minecraft.server.NetServerHandler.handleCommand(NetServerHandler.java:756) 2011-11-30 22:58:19 [sEVERE] at net.minecraft.server.NetServerHandler.chat(NetServerHandler.java:721) 2011-11-30 22:58:19 [sEVERE] at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:714) 2011-11-30 22:58:19 [sEVERE] at net.minecraft.server.Packet3Chat.a(Packet3Chat.java:33) 2011-11-30 22:58:19 [sEVERE] at net.minecraft.server.NetworkManager.b(NetworkManager.java:226) 2011-11-30 22:58:19 [sEVERE] at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:92) 2011-11-30 22:58:19 [sEVERE] at net.minecraft.server.NetworkListenThread.a(SourceFile:108) 2011-11-30 22:58:19 [sEVERE] at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:516) 2011-11-30 22:58:19 [sEVERE] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:414) 2011-11-30 22:58:19 [sEVERE] at net.minecraft.server.ThreadServerApplication.run(SourceFile:457)
  17. Hi all Wondered if anyone had a tutrurial/guide on how to display only data from a table that matches a select box, ie, choosing 'dave' would only show daves entries? Cheers Dave
  18. Hi all, I have been using kloxo recently, and something struck me! To get into the control panel of quite a few different things like cpanel, whm etc you goto a port. How do you bind something like this to a port?
  19. never mind, got it! <script> $(function() { $( "#slider" ).slider({ value:4, min: 4, max: 64, step: 4, slide: function( event, ui ) { $( "#slots" ).val( ui.value ); if (ui.value < '5') { $('#test').css('display', 'block'); } else { $('#test').css('display', 'none'); } if (ui.value == '8') { $('#test1').css('display', 'block'); } else { $('#test1').css('display', 'none'); } } }); $( "#slots" ).val( $( "#slider" ).slider( "value" ) ); }); </script>
  20. Hi people I am a noob at jquery/js/etc and so I have run into some problems in what I am trying to do. I am using the jquery ui slider and the idea is for every increment I have a different div show up, while hiding any previous divs. I have 8 divs in total which need to be shown depending on the position of the slider. Here is what I have: <script> $(function() { $( "#slider" ).slider({ value:100, min: 4, max: 64, step: 4, slide: function( event, ui ) { $( "#slots" ).val( ui.value ); if (ui.value < '5') { $('#test').css('display', 'block'); } if (ui.value < '9') { $('#test1').css('display', 'block'); } } }); $( "#slots" ).val( $( "#slider" ).slider( "value" ) ); }); </script> The problems I am experiencing are basically that both divs are appearing and will not hide even when the slider is above 8, and my slider starts at the max value instead of the min! Can anyone help me out? Cheers
  21. Hi xyph, wow, thanks! Thats definitely above and beyond what I expected to get! Thanks for getting me started, I will see what I can do with it from here, if I get stuck with some simple stuff ill post on here, however if it goes way over my knowledge are you available for some freelance work?
  22. Hi Mjdamato, the color choice is not set yet, but I imagine its going to be around 64, with the default colour of white.
  23. Thanks xyph How easy would it be to save the whole image afterwards? squares that have not been changed would need to be able to be edited, while squares that have already been changed must be locked.
  24. Hi all I am looking for some help on how to achieve something. Basically I want a 50x50 square on a page where each 'square' can have its color changed. Once each colour has been changed I need to be able to count how many squares have there colour changed and save the new 50x50 square to a database. How do I go about achieving the square to start with! Cheers
  25. try it without the " around "$row['typeID']"
×
×
  • 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.