Jump to content

Fabis94

Members
  • Posts

    87
  • Joined

  • Last visited

    Never

Everything posted by Fabis94

  1. strip_tags() works well, but it doesn't completely remove the <div> tags. I have places like <div class="something">Sometext</div> and it doesn't remove them. Any ideas?
  2. I want to remove the whole link.
  3. How do i trim out a link from a string? Each time the link could be different (for example once it might be <a href="www.somesite.com">AAA</a> and another time it might be <a href="www.othersite.net">BBB</a>). How do i make it delete the whole link?
  4. I want to make a PHP script that makes images that show your stats for a specific game. I want it to be like this: http://www.draynor.net/stat_signatures.php If you want to try it out, use the username Zezima. It automatically reads your stats from the Hiscore database and shows it on an image. The hiscores are read from here: http://hiscore.runescape.com/index_lite.ws?player=YourUsername (you change YourUsername to Zezima for example). I've never worked with Image editing in PHP so it would be nice if you could explain and show P.S. I don't need all the options like Male/Female, Backgrounds and stuff like that. I need only the plain way of putting text on an image. Lets say it writes your name on a green image (plain green) with the GET function.
  5. I'm sorry just i've been trying to fix this for the whole day and if i don't fix that i'm stuck. Anyways i don't know about the obj because i just followed a tutorial (that was wrong obviously) and i don't understand a thing about this. So it would be better if you could show me how to make it work because i have no idea.
  6. Don't tell me no one knows what's wrong. This looks so easy! 8 views for the whole day and no one has bothered to even post.
  7. Ok this is my form: echo '<form name="myform" action="newpage.php" method="post"><b>Create a new page - Enter its name (without .php):</b> '; echo '<input name="phpname2" type="text" size="15" maxlength="10" />'; echo '<br /><b>Write in the folder where it should be saved*:</b> <input name="folder_location2" type="text" value="/" size="15"><br>'; echo '<select name="howtowrite" id="howtowrite" onClick="whichTest()"><option selected>New</option><option>Quest</option><option>Skill</option></select>'; echo '<br>*Root of the server is "/" so if you want to save it on a folder called PHP, write "/PHP/".'; echo ' Always add the end-slash.<br><br><br><br>'; echo '<center><b>Write in the contents of the file:</b> '; echo '<textarea name="page_contents2" cols="60" rows="10"></textarea>'; //' . $htmlstart . ' echo '<br><input name="second_method" type="submit" /></center>'; (dont mind the Echos) I'm using it in a PHP script. I want howtowrite selector to change the textarea page_contents2 value. So for example if howtowrite is New the page_contents2 value becomes "New" etc. At howtowrite i already added onClick="whichTest()", but i am a total noob at Javascript i don't know what to do now. I made this function, but it doesn't work (obviously): <script language="JavaScript" type="text/javascript"> function whichTest() { var n = obj.SelectedIndex; var val = obj[n].text; switch (document.myform.howtowrite.text) { case "New": document.myform.page_contents2.value = '1'; break; case "Quest": document.myform.page_contents2.value = '2'; break; case "Skill": document.myform.page_contents2.value = '3'; break; } } </script>
  8. Seriously no one can help?
  9. Oh i understand what you meant, but the problem is $def_path already is set like that and the error isn't the one i mentioned in the first post sorry. So can anyone help? *I can't edit the other post (no Edit option)
  10. Don't mind the different domain names they are all the same in the real script. *Ooops sorry for double post. Mistook modify with Quote. Also the error happens if (!file_exists($filepath)) and $filepath is $filepath = $def_path . $_POST['upload_dir'] . basename($_FILES["file"]["name"]); But as it later says at "Upload: " . $_FILES["file"]["name"] Upload: (nothing) That means it didn't even get the file. Also i added echo "Errors(?): " . $_FILES["file"]["error"]; and it returned nothing too.
  11. I don't understand. At the beginning of my PHP script i already have: $def_path = '/home/content/f/a/b/fabis94/html'; Also if you're talking about the location that is $upload_dir then it's the directory where the file should be uploaded (you select your file, write in the directory where it should be uploaded and press UPLOAD). And the error i mentioned before is because of this thing. Also it says "Page already exists in this directory." not the error i mentioned before (sorry). And the error happens if the directory chosen doesn't end OR/AND start with '/' or if the directory is '/' (root) it doesn't give any errors. But it does! Also here is the WHOLE script (i gave u the uploading part only, but this part has also MAKING a new php file not uploading it) maybe something is interfering with something. <?php $htmlstart = '<!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>Untitled Document</title> </head> <body> </body> </html>'; $def_path = "/home/content/f/a/b/fabis94/html"; if (isset($_POST['name_added_get'])) { //Checks if the name is already set from the INDEX page if ($_POST['folder_location'] != '/') { if (substr($_POST['folder_location'], -1) != '/' || substr($_POST['folder_location'], 0, 1) != '/') { echo '<script language"text/javascript">alert("Folder Location must start and end with /");</script>'; echo '<script type="text/javascript">window.location="newpage.php";</script>'; exit; } } if (substr($_POST['phpname'], -1) == '/' || substr($_POST['phpname'], 0, 1) == '/') { echo '<script language"text/javascript">alert("Page name must not start or end with /");</script>'; echo '<script type="text/javascript">window.location="newpage.php";</script>'; exit; } $dom_path = 'http://www.mechtopia.net' . substr($_POST['folder_location'], -$a) . $_POST['phpname'] . '.php'; if (file_exists($def_path . $_POST['folder_location'])) {//ABC: /home/content/f/a/b/fabis94/html $filepath = $def_path . $_POST['folder_location'] . $_POST['phpname'] . '.php'; if (!file_exists($filepath)) {//If PHPNAME doesn't and FOLDERLOCATION exists $fopen = fopen($filepath, "w"); fwrite($fopen, $htmlstart); fclose($fopen); echo '<form action="newpage.php" method="post">'; echo 'Write the contents of the page: <br>'; echo '<center><textarea name="page_contents" cols="60" rows="10">' . file_get_contents($filepath) . '</textarea>'; echo '<input name="h_filepath" type="hidden" value="' . $filepath . '"/>'; $dom_path = 'http://www.mechtopia.net' . substr($_POST['folder_location'], -$a) . $_POST['phpname'] . '.php'; echo '<input name="dom_path" type="hidden" value="' . $dom_path . '"/>'; echo '<br><input value="Write contents to the page!" name="write_cont" type="submit" />'; echo '</form>'; } else { echo '<font color="red">Page already exists in the specified directory.</font>'; }//PHPNAME Exists IF ends here } else { echo '<font color="red">The directory you specified doesnt exist.</font>'; }//FOLDERLOCATION Exists IF ends here } if (isset($_POST['write_cont'])) { //If contents are ready being added - INDEX Method $opened_page = fopen($_POST['h_filepath'], "w") or die('Could not open the page that was made before.'); fwrite($opened_page, $_POST['page_contents']) or die('Could not write into the file.'); fclose($opened_page); echo '<script type="text/javascript">window.location="' . $_POST['dom_path'] . '";</script>'; } /*---------------------------INDEX Method Ends Here---------------------------------*/ if (!isset($_POST['name_added_get']) && !isset($_POST['write_cont']) && !isset($_POST['second_method'])) { echo '<form action="newpage.php" method="post"><b>Create a new page - Enter its name (without .php):</b> '; echo '<input name="phpname2" type="text" size="15" maxlength="10" />'; echo '<br /><b>Write in the folder where it should be saved*:</b> <input name="folder_location2" type="text" value="/" size="15">'; echo '<br>*Root of the server is "/" so if you want to save it on a folder called PHP, write "/PHP/".'; echo ' Always add the end-slash.<br><br><br><br>'; echo '<center><b>Write in the contents of the file:</b> '; echo '<textarea name="page_contents2" cols="60" rows="10">' . $htmlstart . '</textarea>'; echo '<br><input name="second_method" type="submit" /></center>'; } if (isset($_POST['second_method'])) {//Second Methods last part if ($_POST['folder_location2'] != '/') { if (substr($_POST['folder_location2'], -1) != '/' || substr($_POST['folder_location2'], 0, 1) != '/') { echo '<script language"text/javascript">alert("Folder Location must start and end with /");</script>'; echo '<script type="text/javascript">window.location="newpage.php";</script>'; exit; } } if (substr($_POST['phpname2'], -1) == '/' || substr($_POST['phpname2'], 0, 1) == '/') { echo '<script language"text/javascript">alert("Page name must not start or end with /");</script>'; echo '<script type="text/javascript">window.location="newpage.php";</script>'; exit; } $dom_path2 = 'http://www.mechtopia.net' . substr($_POST['folder_location2'], -$a) . $_POST['phpname2'] . '.php'; if (file_exists($def_path . $_POST['folder_location2'])) {//ABC: /home/content/f/a/b/fabis94/html $filepath = $def_path . $_POST['folder_location2'] . $_POST['phpname2'] . '.php'; if (!file_exists($filepath)) {//If PHPNAME doesn't and FOLDERLOCATION exists $dom_path2 = 'http://www.mechtopia.net' . substr($_POST['folder_location2'], -$a) . $_POST['phpname2'] . '.php'; $fopen2 = fopen($filepath, "w"); fwrite($fopen2, $_POST['page_contents2']); fclose($fopen2); echo '<script type="text/javascript">window.location="' . $dom_path2 . '";</script>'; } else { echo '<script language"text/javascript">alert("Page already exists in the specified directory");</script>'; echo '<script type="text/javascript">window.location="newpage.php";</script>'; exit; }//PHPNAME Exists IF ends here } else { echo '<script language"text/javascript">alert("The directory you specified doesnt exist");</script>'; echo '<script type="text/javascript">window.location="newpage.php";</script>'; exit; }//FOLDERLOCATION Exists IF ends here }/*----------------------------------2nd Method Ends here---------------------------------*/ if (!isset($_POST['name_added_get']) && !isset($_POST['write_cont']) && !isset($_POST['second_method'])) { echo '<br><br><hr>You can also upload a page instead of making a new one. Select the file below, select its destination '; echo 'and press "Upload File"<br>'; echo "<form action='upload_file.php' method='post'"; echo "enctype='multipart/form-data'>"; echo "<label for='file'>Filename:</label>"; echo "<input type='file' name='file' id='file' />"; echo "<br /><input type='hidden' name='MAX_FILE_SIZE' value='30000' /><br><input name='upload_dir' type='text' value='/' />"; echo "<input type='submit' name='upload' value='Submit' />"; echo "</form>"; if (isset($_POST['upload'])) {//If Upload Button is Pressed $upload_dir = $_POST['upload_dir']; if ($_POST['upload_dir'] != '/') { if (substr($_POST['upload_dir'], -1) != '/' || substr($_POST['upload_dir'], 0, 1) != '/') { echo '<script language"text/javascript">alert("Folder Location must start and end with /");</script>'; echo '<script type="text/javascript">window.location="newpage.php";</script>'; exit; } }//Correct Folder IF Ends if (file_exists($def_path . $_POST['upload_dir'])) {//ABC: /home/content/f/a/b/fabis94/html $filepath = $def_path . $_POST['upload_dir'] . basename($_FILES["file"]["name"]); $filename = basename($_FILES["file"]["name"]); echo "Upload: " . $_FILES["file"]["name"] . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; echo "Stored in: " . $_FILES["file"]["tmp_name"]; echo "Errors(?): " . $_FILES["file"]["error"]; echo 'Up dir: ' . $_POST['upload_dir'] . ' Original Basename: ' . $_FILES["file"]["name"] . 'Filepath: ' . $filepath . ' <br>'; if (!file_exists($filepath)) {//If PHPNAME doesn't and FOLDERLOCATION exists if (substr($filename, -4) == '.php') {//If it is a PHP file if (move_uploaded_file($_FILES["file"]["tmp_name"], $filepath)) { echo "<br><font color='green'>File is valid, and was successfully uploaded.</font>\n"; } else { echo "<br><font color='red'>Couldn't upload and move.</font>\n"; } } else { echo '<script language"text/javascript">alert("File must be .PHP");</script>'; echo '<script type="text/javascript">window.location="newpage.php";</script>'; } } else { echo '<script language"text/javascript">alert("Page already exists in the specified directory");</script>'; /*echo '<script type="text/javascript">window.location="newpage.php";</script>';*/ exit; }//PHPNAME Exists IF ends here } else { echo '<script language"text/javascript">alert("The directory you specified doesnt exist");</script>'; echo '<script type="text/javascript">window.location="newpage.php";</script>'; exit; }//FOLDERLOCATION Exists IF ends here }//Upload Button IF ends }//Upload method ends ?>
  12. Oh cmon can't be no one knows what to do. I tried to find out for more than 3 hours and couldn't understand.
  13. Here's the script: if (!isset($_POST['name_added_get']) && !isset($_POST['write_cont']) && !isset($_POST['second_method'])) { echo '<br><br><hr>You can also upload a page instead of making a new one. Select the file below, select its destination '; echo 'and press "Upload File"<br>'; echo "<form action='upload_file.php' method='post'"; echo "enctype='multipart/form-data'>"; echo "<label for='file'>Filename:</label>"; echo "<input type='file' name='file' id='file' />"; echo "<br /><input type='hidden' name='MAX_FILE_SIZE' value='30000' /><br><input name='upload_dir' type='text' value='/' />"; echo "<input type='submit' name='upload' value='Submit' />"; echo "</form>"; if (isset($_POST['upload'])) {//If Upload Button is Pressed $upload_dir = $_POST['upload_dir']; if ($_POST['upload_dir'] != '/') { if (substr($_POST['upload_dir'], -1) != '/' || substr($_POST['upload_dir'], 0, 1) != '/') { echo '<script language"text/javascript">alert("Folder Location must start and end with /");</script>'; echo '<script type="text/javascript">window.location="newpage.php";</script>'; exit; } }//Correct Folder IF Ends if (file_exists($def_path . $_POST['upload_dir'])) {//ABC: /home/content/f/a/b/fabis94/html $filepath = $def_path . $_POST['upload_dir'] . basename($_FILES["file"]["name"]); $filename = basename($_FILES["file"]["name"]); echo "Upload: " . $_FILES["file"]["name"] . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; echo "Stored in: " . $_FILES["file"]["tmp_name"]; echo 'Up dir: ' . $_POST['upload_dir'] . ' Original Basename: ' . $_FILES["file"]["name"] . 'Filepath: ' . $filepath . ' <br>'; if (!file_exists($filepath)) {//If PHPNAME doesn't and FOLDERLOCATION exists if (substr($filename, -4) == '.php') {//If it is a PHP file if (move_uploaded_file($_FILES["file"]["tmp_name"], $filepath)) { echo "<br><font color='green'>File is valid, and was successfully uploaded.</font>\n"; } else { echo "<br><font color='red'>Couldn't upload and move.</font>\n"; } } else { echo '<script language"text/javascript">alert("File must be .PHP");</script>'; echo '<script type="text/javascript">window.location="newpage.php";</script>'; } } else { echo '<script language"text/javascript">alert("Page already exists in the specified directory");</script>'; /*echo '<script type="text/javascript">window.location="newpage.php";</script>';*/ exit; }//PHPNAME Exists IF ends here } else { echo '<script language"text/javascript">alert("The directory you specified doesnt exist");</script>'; echo '<script type="text/javascript">window.location="newpage.php";</script>'; exit; }//FOLDERLOCATION Exists IF ends here }//Upload Button IF ends }//Upload method ends It just simpy says "Folder Location must start and end with /" in the pop-up window and also in this part: echo "Upload: " . $_FILES["file"]["name"] . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; echo "Stored in: " . $_FILES["file"]["tmp_name"]; It shows nothing. That means it didn't upload it and something is maybe wrong with my temp upload dir, but i use GoDaddy Shared Hosting and i don't have a php.ini file on the root (so it uses the default configs) and i cannot change the directory, but i used ini_get() and found out it's /tmp and the path to my actual site is: /home/content/f/a/b/XXXX/html/ So it is even before the 'home' directory and i cannot access that. Anyways: 1. There is something wrong with my script and please help me fix it 2. Can anyone give a php.ini file with all the default configs set so i can change them after.
  14. In forums (for example this one) the address says /index.php?action=post;board=1.0. How does it work? It doesn't create new pages (posts, topics, forums etc.), but just makes stuff in the same old one (index.php). I've seen it on other websites too. Like the page is comments.php?x=1 and its the page one of something, then you click Go To Page 2 and nothing in the address bar changes just the x=1 becomes x=2, but the whole page is different.
  15. I have a Database cell that has </table> as the last word/string in it. How do i make MYSQL remove it (so i can add my strings i got from $_POST and then put the </table> back again)?
  16. Oh and i don't want to get the cell in a var and then remove the end with PHP, but just do it straight with a query.
  17. Oh i didn't know you could do that. Anyways i have a Database cell that has </table> as the last word/string in it. How do i make MYSQL remove it (so i can add my strings i got from $_POST and then put the </table> back again)?
  18. Well the rowXcollumX is the NAME of the input field (For example, first input field has name="row1collumn1" the second one has name="row1collumn2"). How do i add all the values to an array from the $_POST? (Like the first input field will be $_POST['now1collumn1'])
  19. Hello? What should i do with arrays!
  20. What do you mean? How? Here's the whole script (there is still a PHP part with cookies and mysql_connect but it doesn't matter now): <form action="tableadd.php" method="post"> Select the table: <select name="whichtable"> <?php $select_tables = mysql_query("SELECT name,id FROM tables"); $num_rows_tables = mysql_num_rows($select_tables); while($assoc = mysql_fetch_assoc($select_tables)) { if ($assoc['id'] == 0) { echo '<option selected value="' . $assoc['name'] . '">' . $assoc['name'] . '</option>'; } else { echo '<option value="' . $assoc['name'] . '">' . $assoc['name'] . '</option>'; } } ?> </select> <input name="submit_select_table" type="submit" value="Select Table" /> </form><br /> <?php if (isset($_POST['whichtable'])) { $selectedtable = $_POST['whichtable']; $_SESSION['selectedtable'] = $selectedtable; echo '<br>'; $select_right_table = mysql_query("SELECT * FROM tables WHERE name='$selectedtable'") or die('Unable to select the TABLE collumn.'); $right_table = mysql_fetch_assoc($select_right_table) or die('Couldnt fetch assoc'); echo '<center>' . $right_table['table'] . '</center><br>'; $_SESSION['table'] = $right_table['table']; echo '<form action="tableadd.php" method="post">'; echo 'How much rows to add: <input name="hm_toadd" type="text" size="1" maxlength="1" /> '; echo '<input name="add_rows" type="submit" value="Submit" />'; echo '</form>'; } if (isset($_POST['add_rows'])) { $selectedtable = $_SESSION['selectedtable']; $right_table_show = $_SESSION['table']; echo '<center>' . $right_table_show . '</center><br><br><hr>'; $rc = mysql_query("SELECT * FROM tables WHERE name='$selectedtable'") or die('Cannot select $selectedtable'); $right_collumn = mysql_fetch_assoc($rc); $rightcoll = $right_collumn['collumns']; echo '<form action="tableadd.php" method="post">'; for ($a = 1; $a <= $_POST['hm_toadd']; $a++) { for ($b = 1; $b <= $right_collumn['collumns']; $b++) { echo 'Row ' . $a . ' Collumn ' . $b . ': <input name="row' . $a . 'collumn' . $b . '" type="text" /><br>'; } echo '<hr>'; } echo '<input name="add_rows_submit" type="submit" value="Add Rows" /></form>'; $_SESSION['hm_toadd'] = $_POST['hm_toadd']; } else { echo 'Select a table and enter how much rows do you want to add. If you want to add collums click HERE.'; } if (isset($_POST['add_rows_submit'])) { $rc = mysql_query("SELECT * FROM tables WHERE name='$selectedtable'") or die('Cannot select $selectedtable'); $right_collumn = mysql_fetch_assoc($rc); $hm_toadd = $_SESSION['hm_toadd']; $new = $hm_toadd * $right_collumn['collumns']; echo $new; for ($c = 1; $c <= $hm_toadd; $c++) { $add23 = '$row' . $c . 'collumn' . $d . ''; add1 = '<tr ' . $right_collumn['tr'] . '>'; for ($d = 1; $d <= $right_collumn['collumns']; $d++) { add2 = ' <td ' . $right_collumn['td'] . '>' . $add23 . '</td>'; } $add3 = '</tr>' $d++; } } ?> Also don't mind the variables repeating some times, this isn't the finished version of the script.
  21. Ok in the script i made variables like this: $row1collumn1, $row1collumn2 etc. the numbers after ROW and COLLUMN depend on the database entries. Anyways with $_POST they get sent to the action script (it is the same script though). Then i have this line: add2 = ' <td ' . $right_collumn['td'] . '>' . $add23 . '</td>'; And $add23 is: $add23 = '$row' . $c . 'collumn' . $d . ''; What i was trying to do is make that $add23 is the same as the rowXcollumnX and the FOR would change the values after ROW and COLLUMN but what it does is make the $add23 var be the string: '$rowXcollumnX' not be equal to a variable that has the name. It is hard to explain, but i think you got what i meant in the last sentance. Is there a way to make the $add2 var have the $rowXcollumnX variable between the <td> and </td> tags not just a string that says $rowXcollumnX Also with X i just meant the values that will be there.
×
×
  • 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.