Jump to content

newbtophp

Members
  • Posts

    631
  • Joined

  • Last visited

Posts posted by newbtophp

  1. Whats wrong with this script?

     

    Its meant to have a field for input and then a button which when clicked reveals the output code.

     

    <html>
    <head>
    <script>
    function hp_d01(s){
    var o="",ar=new Array(),os="",ic=0;
    s=unescape(s);
    for(i=0;i<s.length;i++) {
    c=s.charCodeAt(i);
    if(c<128)c=c^2;
    os+=String.fromCharCode(c);
    if(os.length>80){
    ar[ic++]=os;
    os="";
    }
    }
    document.getElementById("code-output").\\
    appendChild(document.createTextNode(ar.join("")+os));
    }
    </script>
    </head>
    <body>
    <p>Input:</p>
    <textarea id="code-input" type="text" cols="80" rows="10">
    <input type="submit" value="Decode"
    onClick="hp_d01(document.getElementById(''code-input'').value);">
    <p id="code-output">Output</p>
    </body>
    </html>

  2. You'll probably want to look into fopen and fwrite.

     

    You could eval the current contents to extract all the variables, and then overwrite any changed ones with the new data, and then write them all back into the file.

     

    That's what I do for the config of my site.

     

    It's pretty fun :D

     

    Can you give me an example code of how you would do it  ???

     

    Sorry for this, but I've never done this before, and im still learning.

  3. I've got a file named "config.inc.php" which has variables like:

     

    //Basedir
    $siteurl = "text goes here";
    //Website Name
    $site_title = "text goes here";
    //Your Email
    $email = "text goes here";

     

    Im trying to create a form which will edit the variables ("text goes here")

     

    Like:

     

    <form>
    
    Website Url: (this edits $site_title)<BR>
    
    <input type="text" name="url" size="25"><BR><BR>
    
    Website Title: (this edits $siteurl)<BR>
    
    <input type="text" name="title" size="25"><BR><BR>
    
    Email: (this edits $email)<BR>
    
    <input type="text" name="email" size="25">
    
    <BR>
    <BR>
    
    <input type="submit" value="Submit">
    
    </form>

     

    How would I be able to build a form, so the fields in the form will actually edit the correct variables within config.inc.php.

    Like what ever i put in the "Website Title:" field then it will edit the $site_title variable at config.inc.php.

     

    Anyone can help?

     

  4. LOL This place is awesome, I learn loads.

     

    I think I've just answered my own question about the new tab XD

     

    However for the removing error mesage, I've already tried that, that only removes the text but not the actual switch between the pages.

     

    If I dont fill anything in the form and click submit it goes to that error echo @

     

    www.censored.com/#

     

    Currently the text which said "Error!" has been removed, but I want the "Error" page to redirect or stay on the homepage.

     

     

  5. Erm thankss  :-[ But  :o

     

    Still can't find how to make the link open in a new tab, and remove the error echo.

     

    For the new tab I've tried replacing:

     

    echo '<a href="http://www.'.$siteurl.'/get.php?i='.$folder_id.'">http://'.$siteurl.'/get.php?i='.$folder_id.'</a><br>';

     

    with

     

    echo '<a href="http://www.'.$siteurl.'/get.php?i='.$folder_id.'" target="_blank">http://'.$siteurl.'/get.php?i='.$folder_id.'</a><br>';

     

    But that gives syntax errors.

     

    For removing error code I've tried replacing (I want to remove the error page so when a incorrect submission is made through the form I dont want it to redirect to the error page, I've tried removing the line but the page still exists but without no text, so I tried the following):

     

    echo '<center>Error!';

     

    with

     

    echo '<meta HTTP-EQUIV="REFRESH" content="0; url=http://www.censored.com/index.php">';

     

    Still no luck  :-\ Can anyone provide me the correct code  please ???

     

     

  6. Heres the whole code;

     

    <?php
    require("config.inc.php");
    require("inc/func.php");
    $i = 0;
    $d = false; //debug
    $s = 0;		//success var
    
    if(isset($_POST['submit'])) {
    	$id = getNextId();
    	$folder = makeClean($_POST['folder']);
    	if(isset($_POST['mirror']) && $_POST['mirror']!=""){
    		if(is_numeric($_POST['mirror'])) {
    			$layerAdsID = $_POST['mirror'];
    		} else {
    			$mirror = checkURL($_POST['mirror']);
    		}
    	}
    	if(isset($_POST['siteurl']) && $_POST['siteurl']!="") $site_url = checkURL($_POST['siteurl']);
    	$admin_pw = makeClean($_POST['adminPW']);
    
    	if(empty($folder)) {
    		$folder = createDirName();
    		$folder_id = $folder;
    	} else {
    		$folder_id = createDirName();
    	}
    
    	while(folderExists($folder_id)) {
    		$folder_id = createDirName();
    	}
    
    	$urls 	= array();
    	$t_rows = explode("\n", $_POST['urls']);
    	foreach($t_rows as $a_rows) {
    		if(preg_match ("!^http:\/\/(.*)\.(.*)$!", $a_rows)) {
    			$sha1 = sha1($a_rows);
    			$md5  = md5($a_rows);
    			$time = time();
    			$ins = mysql_query("INSERT INTO 
    									stealth (
    										`url`,
    										`sha1`, 
    										`md5`, 
    										`timestamp`, 
    										`visits`, 
    										`belongs_to`, 
    										`folder_name`,
    										`folder_id`,
    										`mirror_url`,
    										`layeradsid`, 
    										`admin_pw`, 
    										`website_url`) 
    								VALUES (
    										'".$a_rows."',
    										'".$sha1."',
    										'".$md5."',
    										'".$time."',
    										'0',
    										'".$id."',
    										'".$folder."',
    										'".$folder_id."',
    										'".$mirror."',
    										'".$layerAdsID."',
    										'".$admin_pw."',
    										'".$site_url."')
    							");
    
    			$i++;
    			if($ins) {
    				$s = 1;
    				if($d) echo "MySQL ".$i." successful! (".mysqlError().").<br>";						
    			} else {
    				$s = 0;
    				if($d) debug("MySQL ".$i." error!", $ins);
    			}
    
    		}
    	}
    
    	if($s>0) {
    		echo "<table border=0 align=center cellpadding=5 cellspacing=5>
      <tr>
    
      </tr>
    
    </table>  <td></td><center><b>Sucess! </b><br><br>';
             echo 'Your URL: <br>';
             if(isset($t_rows[1])) {
                   echo '<input type="text" id="Links"  name"Links" value="http://www.'.$siteurl.'/get.php?i='.$folder_id.'" class="txt_sucess" onClick="this.form.Links.select();this.form.Links.focus()">';
                } else {
                   echo '<a href="http://www.'.$siteurl.'/get.php?i='.$folder_id.'">http://'.$siteurl.'/get.php?i='.$folder_id.'</a><br>';
                }
       
          } else {
             echo '<center>Error!';
          }
    } else {
    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
        <script language="JavaScript" type="text/javascript" src="main.js"></script>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <title></title>
        <style type="text/css">
        /*<![CDATA[*/
        div.c1 {text-align: left}
        /*]]>*/
        </style>
    </head>
    <body>
    <div id="sitemain">
      <div id="group">
      <div id="textbox">
        <div class="lr"><div class="ll">
    
              <div class="tl"><div class="tr"><div class="bl"><div class="br">
                <div class="bod">
                    <form action="#" method="post">
            <table border="0" align="center" cellpadding="3" cellspacing="3">
                              <tr>
                                <td><div align="center"><strong>Your Link(s): </strong>
                                      <br />
                                          <textarea name="urls" class="lnkarea"><?=$_POST['urls'];?>
    </textarea>
                                </div></td>
                              </tr>
                              <tr>
                                <td><div align="center"><strong>Password: 
                                  <br />
                                      <input name="adminPW" type="password" class="form" />
                                </strong></div></td>
                              </tr>
                </table>
    					<label>
    				<center><input name="submit" type="submit" id="submit" value="Secure!">
    		</label>
    				<br>
          </form>
    <br>
                </div>
    
    <? } ?>

     

    Im trying to make the url open in a new tab, and also edit the error echo so it dont exist, when theirs an error the page will stay the same.

  7. I did your way by adding an echo above the code and got syntax error after another, nomatter how i modified the code.

     

    "Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/something/public_html/api.php on line 93"

  8. Im trying to edit the below code, I tried to make the url open in a new tab, and make the error message go away so their is no error message (if the user does not input the fields and clicks submit it stays on that page until the user does. I dont want the page to redirect to the error message)

     

    I've tried inserting code within the echos "..." but I recieve tons of syntax errors, I even tried removing the echos "..." but no luck. :-\

     

    Heres the snippet I want to edit:

     

    </table>  <td></td><center><b>Sucess! </b><br><br>";
             echo "Your URL: <br>";
             if(isset($t_rows[1])) {
                   echo "<input type=\"text\" id=\"Links\"  name\"Links\" value=\"http://www.".$siteurl."/get.php?i=".$folder_id."\" class=\"txt_sucess\" onClick=\"this.form.Links.select();this.form.Links.focus()\">";
                } else {
                   echo "<a href="http://www.".$siteurl."/get.php?i=".$folder_id."\">http://".$siteurl."/get.php?i=".$folder_id."</a><br>";
                }
       
          } else {
             echo "<center>Error!";
          }
    } else {
    ?>

     

    Can anyone help?

     

    Thanks

  9. Im trying to code a snippet which will display a php file, which can then be edited within another webpage. I've completed it accept, it has a few flaws, once you edit the code the page exploads and messes up, and when you come back to the code inbetween each code I see \ dashes.

     

    Heres my code.php (which edits text.php):

     

    <?
    if($_POST['Submit']){
    $open = fopen("text.php","w+");
    $text = $_POST['update'];
    fwrite($open, $text);
    fclose($open);
    echo "File updated.<br />";
    echo "File:<br />";
    $file = file("text.php");
    foreach($file as $text) {
    echo $text."<br />";
    }
    echo "<p><a href=\"./text.php\" target=_blank>click here to view the updated file</a></p>";
    }else{
    $file = file("text.php");
    echo "<form action=\"".$PHP_SELF."\" method=\"post\">";
    echo "<textarea Name=\"update\" cols=\"50\" rows=\"10\">";
    foreach($file as $text) {
    echo $text;
    }
    echo "</textarea>";
    echo "<BR><input name=\"Submit\" type=\"submit\" value=\"Update\" />\n
    </form>";
    }
    ?>

     

    Is their a way to continue what im doing but remove the demo of the file edited (so the page dont expload), and remove it from showing dashes.

     

    Heres the live demo (for you to test):

     

    http://www.encrypt.hostxcel.co.uk/admin/code.php

     

    Thanks

  10. Well, on the admin page, look near the bottom where you include the files. You end the page and then insert some more divs (persumably the footer code). You need to include the footer.php page earlier on in the script.

     

    The header.php is right at the top, and the footer.php is at the very bottom, the footer contains divs.

     

    If I move the footer.php up within the above php code, the page will misfunction and display numerous syntax errors.

  11. Validating the frontpage

    Only gives errors about attributes being used wrongly, nesting things where they shouldn't.

     

    Validating the page using includes gives a nice

    "Line 87, Column 6: end tag for element "DIV" which is not open"

     

    I've decreased the w3 errors, I tried to decrease them all but sometime they lead to more errors.

     

    The /admin which has the includes, still no luck, the footer is still...  :-\

     

    Is their an alternative like a a css or div code which can fix this? or another way of including the layout.

  12. I've been working on a small script (its my first one, im newbie).

     

    And I can't seem to integrate the layout with the the whole script, I tried php include for the header and footer, it works but it dont come out right.

     

    Whereas if I had the layout coded without phpincludes it works perfectly.

     

    What I mean is when I do an include the footer is slightly more to the left, even though the css says its centered, just general inaccuracy.

     

    Heres the site:

     

    www.encrypt.hostxcel.co.uk

    (this has no includes and looks perfect)

     

    www.encrypt.hostxcel.co.uk/admin

    (this is using includes and the footer links are slightly misplaced (their not centered), and the bottom left and right edges are not curved like the homepage.)

     

    I used the exact code i did for the main page for the includes, except I separated the header (head tags/title) and footer (copyright/links divs).

     

    Can anyone help?

     

    Thanks

  13. Its all fixed, thanks alot Maq!!! and also thanks for your input iarq

     

    ;D

     

    Great, did you have the wrong database name or something?

     

    NOTE - Please click the tab in the bottom left, "topic solved".

     

    Yup, iarq's code had a different table name, it said "news" and I replaced it with my table name and it worked.

     

    <?php
    
    mysql_connect("localhost", "removed", "removed") or die(mysql_error());
    mysql_select_db("something_removed") or die(mysql_error());
    
    if($_GET['cmd'] == 'delete')
    {
        $id = mysql_real_escape_string($_GET['id']);
        $sql = "DELETE FROM [b]news[/b] WHERE id = $id";
        $result = mysql_query($sql) or die(mysql_error());
        if($result)
       {   
          echo "Row deleted!";
       }
       else
       {
          echo "There was an error deleting.";
       }
    }
       
    
    $data = mysql_query("SELECT * FROM stealth") or die(mysql_error());
    Print "<table border='1' cellpadding='3'>";
    Print "<th>Url:</th><th>Link:</th><th>Clicks:</th>";
    while($info = mysql_fetch_array( $data ))
    {
       Print "<tr>";
       Print "<td>".$info['folder_name'] . " </td>";
       Print "<td>".$info['url'] . " </td>";
       Print "<td>".$info['visits'] . "</td>";
       if(!isset($cmd))
       {
          echo "<td><a href='delete.php?cmd=delete&id={$info['id']}'>Delete</a></td>";
       }
       Print "</tr>";
    }
    Print "</table>";
    ?>

     

     

    SOLVED! yay! Thanks Maq!

  14. Try that, the mysql connection should've come before the deletion process.

     

    Move these two lines right before the if statement:

     

    mysql_connect("localhost", "removed", "removed") or die(mysql_error());
    mysql_select_db("something_removed") or die(mysql_error());

     

     

    I added the mysql config above the if, and the delete links show:

     

    "Table 'crypt_crypt.news' doesn't exist"

     

     

  15. Everything is displayed and configurated fine, except when I click a delete link it displays with errors saying:

     

    Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'nobody'@'localhost' (using password: NO) in /home/crypt/public_html/delete.php on line 5
    
    Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /home/crypt/public_html/delete.php on line 5
    
    Warning: mysql_query() [function.mysql-query]: Access denied for user 'nobody'@'localhost' (using password: NO) in /home/crypt/public_html/delete.php on line 7
    
    Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/crypt/public_html/delete.php on line 7
    Access denied for user 'nobody'@'localhost' (using password: NO)

  16. Its looking better, but the delete link aint functioning it returns with

     

    "Not Found

    The requested URL /delete.php was not found on this server.

     

    Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request. "

     

    The delete links look like (but dont have ids):

    http://www.mysite.com/delete.php?cmd=delete&id=

     

    This is sort of the way I'd like to have the rows deleted (but can't seem to figure how to integrate the code):

    http://www.spoono.com/php/tutorials/delete/delete.txt

     

  17. The table and delete is positioned right but the delete link dont function no more. (the delete link is meant to delete the selected row from the mysql database)

     

    All of the delete links (dont function) they are linked like:

     

    http://www.mysite.com/delete.php?cmd=delete&id=%3E%20-%20Delete%3C/a%3E%3C/td%3E%3C/tr%3E%3Ctr%3E%3Ctd%3EgF6ZXU12NJoj3NHQz%20%3C/td%3E%3Ctd%3Ehttp://www.something.com%20%3C/td%3E%3Ctd%3E2%3C/td%3E%3Ctd%3E%3Ca%20href=

     

    Heres how its looking now: (the appearance has progressed but the delete links dont work)

     

    2cfv7lf.jpg

  18. That's how it does look like.

     

    No it dont, it shows the results but the delete column aint displayed at the end (the image I showed was done in paint to show you)

     

     

    Your code didnt work, heres the total code with your added code;

     

    <?php
    mysql_connect("localhost", "REMOVED", "REMOVED") or die(mysql_error());
    mysql_select_db("REMOVED") or die(mysql_error());
    $data = mysql_query("SELECT * FROM stealth")
    or die(mysql_error());
    Print "<table border cellpadding=3>";
    Print "<th>Url:</th><th>Link:</th><th>Clicks:</th>";
    for($url=$r["url"]; $id=$r["id"]; $x++)
    {
       Print "<tr>";
       Print "<td>".$info['folder_name'] . " </td>";
       Print "<td>".$info['url'] .  " </td>";
       Print "<td>".$info['visits'] . "</td></tr>";
    }
    Print "</table>";
    
    
    if(!isset($cmd)) 
    {
    
       $result = mysql_query("select * from stealth"); 
       
    
       while($r=mysql_fetch_array($result)) 
       { 
    
          $url=$r["url"];
          $id=$r["id"];
         
          echo "<a href='delete.php?cmd=delete&id=$id'>$url - Delete</a>";
          echo "<br>";
        }
    }
    ?>
    
    <?
    if($cmd=="delete")
    {
        $sql = "DELETE FROM news WHERE id=$id";
        $result = mysql_query($sql);
        echo "Row deleted!";
    }
    ?>

     

     

    Heres how it looks now:  :o

     

    2jg04fp.jpg

     

  19. Im trying to add a column which will show a delete link on the end, the delete link will delete the row.

     

    Heres my code so far, I can't get the delete link to work/position right.

     

    stealth = my table

     

    Heres my delete.php:

     

    <?php
    mysql_connect("localhost", "removed", "removed") or die(mysql_error());
    mysql_select_db("something_removed") or die(mysql_error());
    $data = mysql_query("SELECT * FROM stealth")
    or die(mysql_error());
    Print "<table border cellpadding=3>";
    while($info = mysql_fetch_array( $data ))
    {
    Print "<tr>";
    Print "<th>Url:</th><td>".$info['folder_name'] . " </td>";
    Print "<th>Link:</th> <td>".$info['url'] . " </td>";
    Print "<th>Clicks:</th> <td>".$info['visits'] . "</td></tr>";
    }
    Print "</table>";
    
    
    if(!isset($cmd)) 
    {
    
       $result = mysql_query("select * from stealth"); 
       
    
       while($r=mysql_fetch_array($result)) 
       { 
    
          $url=$r["url"];
          $id=$r["id"];
         
          echo "<a href='delete.php?cmd=delete&id=$id'>$url - Delete</a>";
          echo "<br>";
        }
    }
    ?>
    
    <?
    if($cmd=="delete")
    {
        $sql = "DELETE FROM news WHERE id=$id";
        $result = mysql_query($sql);
        echo "Row deleted!";
    }
    ?>

     

     

    This is how I'd like it to look:

     

    13zwiz7.jpg

     

    Can anyone please help?

     

    Thanks

×
×
  • 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.