Jump to content

2bigpigs

Members
  • Posts

    70
  • Joined

  • Last visited

  • Days Won

    2

Posts posted by 2bigpigs

  1. I like to time my scripts' execution so i get an idea of whether it's my connection or my script that's being slow.

    Also, By limit on execution time, It means the time before the script times out and is killed.

     

    I can't find the heliohost limit, Maybe it doesn't have one?

  2. But that may require me to know how large the user's screen is going to be or we could have a lot of wasted space on larger screens.. It's a good idea that's bound to work but i don't mind trying all sorts of stuff to get this to work.

    Plus the more independent it is, the easier it is for me to change stuff around without breaking. I was planning on adding fonts and font-sizes after my exams ( Which would be in may :( )

     

    I had another approach: Underline the text.

    But that stops when the text ends. Is there a way to stretch it across ( using a HUGE tab ( "\t" ) ) or right aligning a blank space so that it stretches?

     

    @Anush: I don't code much anymore. It's usually half an hour at night.

  3. Actually, I've switched from span to using a table and lists.

    My aim is to give a ruled-book feel to the page so it's easier to read / more original.

     

    And my method isn't working properly, Here's an example page:

    http://www.slamsite.....php?entry_id=1

     

    The lines appear only after a new line (<br/>) but not if the line was wrapped ( which is understandable since it's a border-bottom). It messes up on 'Favorite song' and 'Favorite Quote'.

    If you'll look at the site banner, You can see what i'm aiming for

     

    The site is still very much in development but i'd like to get this part right.

     

    This is the code what i'm currently using:

     

    <?php
    
    //Deep inside a class...
    $this->query( " SELECT fields_data FROM table WHERE page_id = $id");
    $assoc = $this->DB->get();
    $this->fields = explode( "\0" ,$assoc['fields_data'] ) );
    
    
    //Later on
    
    echo '<table class="page">';
    
    $i = 0;
    foreach($this->fields as &$n)
    {echo '<tr><td>
    <field>' , $n ,':</field></td>
    <td  class="entry"><li>' ,
    str_replace("\n", '</li><br/><li>', ( htmlentities(trim($this->field_data[$i])) ))  ,'</li></td></tr>';
    
    $i++;
    }
    echo '</table>';
    ?>

     

     

    CSS:

     

    
    
    .page li
    {display:inline-block;
    width:100%;
    border-bottom-style:solid;
    border-bottom-width:2px;
    list-style-type: none;
    padding-bottom:4px;
    border-bottom-color:black;
    }
    
    

     

     

    The whole background, Fields and data are all dynamic so they'll vary from page to page. :D

  4. I've been searching for a while but haven't found what i need.

    I'd like to achieve something like this:

    The underline continues even if the ____________________________________________

    line ends and it spans the whole div/span________________________________________

     

    ( ^ Cheap trick :P . I hope i was clear enough. I really appreciate all the help :) )

     

    Edit:

    Temporary fix i found for myself:

    li
    {width:100%;
    border-bottom-style:solid;
    border-bottom-width:1px;
    list-style-type: none;
    padding-bottom:4px;
    border-bottom-color:black;
    }

     

    This is a pain since i need PHP to wrap each line in <li>

  5. I'm running wamp on a windows XP

    1.86 Ghz Core 2 duo

    1.5 GB RAM ( Started off with 512 ).

     

    It runs great and all my scripts are tested on there before any uploads are done.

     

    Slow upload rates will affect you depending on what you'll be hosting. My pages are usually a lot of html with an occassional image. I think it works okay for people outside the LAN. I usually use it as a test-ground for my scripts so no network involved, Just localhost.

  6. Thanks.

    I was wondering whether heliohost had a preset include path for my files. If it did, Then i could easily move hosts or subdomains without having to worry too much.

    Right now i have one global_config which is in the same directory as the pages + a classes folder.

     

    Thanks for your support. I have my answer :)

  7. I wanted to avoid that. It makes everything ugly + i have different folders.

    If i can have an include path higher up ( Above public_html so nobody accesses the classes directly (even though it doesn't matter) ) i'd like to use it.

     

    I'm new to all this :(

  8. I'd like to include a few files in my scripts.

    On WAMP, I've been using the document root as include path but i don't know how to do it here.

    Ideally, I'd have this:

    <!--?php
    require_once('global.inc.php');
    require_once('myclass.inc.php');
    

    Is there a specific folder that i should put my includes in?

     

    I get this error:

    Failed opening required '/global.inc.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in/home/bigpig/public_html/ajax/shelf.php on line 5

     

    One more question: Will using too many includes (3) slow down execution by a lot?

  9. Edit:

    I'm not sure i'm suspended. I got an error page saying something like:

    You're seeing this page because:

    Too much resources,

    Inactivity,

    Breaking ToS

     

    But i seem to have access again. Sorry to bother you :(

     

     

    Username: bigpig

    Server: Johnny

    HelioHost main domain: brickhouse.heliohost.org

     

     

    I think i know why :(

    I did a DB export through PHPmyadmin. It wasn't that big a database ( 18 KB ) so i didn't think it would be much of a problem.

     

    I'm sorry. I know you're a free host and have many sites hosted on the servers.

    I was going to remove the DB completely and upload a new project.

    I guess i was asking too much of poor old johnny :(

     

    Thank you

    2bigpigs

  10. Thanks for this useful information

    so my new code will look like this

    <?php
    include 'mysql-connect.php';
    $username = mysql_real_escape_string( $_POST['username'] );
    $password = mysql_real_escape_string( $_POST['password'] );
    $firstname = mysql_real_escape_string( $_POST['firstname'] );
    $lastname = mysql_real_escape_string( $_POST['lastname'] );
    $email = mysql_real_escape_string( $_POST['email'] );
    $ip = $_SERVER['REMOTE_ADDR'];
    $strCheckUserSQL = "SELECT * FROM subs WHERE username='$username'";
    $CheckUserQuery = mysql_query($strCheckUserSQL);
    $strCheckEmailSQL = "SELECT * FROM subs WHERE email='$email'";
    $CheckEmailQuery = mysql_query($strCheckEmailSQL);
    // You really should escape these values, but I'm not going to do that here
    mysql_query("INSERT INTO subs (username, password, firstname, lastname, ip, email)
    VALUES ('$username', '$password', '$firstname', '$lastname', '$ip', '$email')");
    ?-->
    

    is this script secure??

    Looks good.

     

    i don't need to md5 the password.

    It's not that big an effort what you gain. Seriously, You should md5 them.

    All you have to do is pass the string through the md5 function and you'll get it. To make it even more secure, You can concatenate a random string to the password too.

    All you have to do is md5 the login password and compare it against the stored hash in your database]

    Eg:

    //without salt
    $password = md5($_POST['password']);
    
    //with salt
    $password= md5( $_POST['password'] . 'my secret salt' );
    

    You don't even have to escape it since the md5 can't contain any dangerous characters.

     

    A reason to use salt is because of the way md5s are 'decrypted' . They're not actually decrypted but are compared against a huge database of common strings and their hashes ( Admins, Could you confirm? ). So using a secret salt would change the hash would protect it from that approach too.

     

    Can you help me with the other script also please

    Is that to me?

    If it is, Sure. I'm pretty bored at home and have no ongoing projects. I'm still a beginner though :)

     

     

     

    Question about the script:

     

    <?
    $username = $_POST['subdomain'];
    $path="http://seifhate:pass@seifhatem.co.cc:2082/frontend/x3/subdomain/doadddomain.html?rootdomain=seifhatem.co.cc&domain=$username";
    $f = fopen($path, "r");
    echo $path;
    fclose($f);
    ?>
    <html>
    <form method="POST" action="">
    Subdomain: <input type="text" name="subdomain"/>
    <input type="submit" name="submit" value="Create"/>
    </html>

     

    You're going to run this script when you're logged into CPanel, Right?

     

     

    @xaav: I've tried using booleans in mysql, It never worked properly for me :(

    Any tips?

    • Like 1
  11. Escaping means to escape all the characters that could cause trouble.

    if you were to have a piece of code

    //without escaping quotes
    echo ' Hello, My name is O'Reilly It's nice to meet you ' ;
    

    You'll get an error here because the string is broken due to the single quotes (') in O'Reilly and it's.

    The highlighter makes this problem obvious here.

     

    This is a problem in every programming language and a lot of them escape these characters in the same way.

    By preceeding them with a \

    Eg:

    echo ' Hello, My name is O\'Reilly It\'s nice to meet you ' ;
    

     

    Escaping information you're going to use in a query is especially important because, if you don't escape it, You leave your queries vulnerable to SQL injection.

     

    Look at this script here:

    $strCheckUserSQL = "SELECT * FROM subs WHERE username='$username'";

    The string in $_POST['username'] is substituted in place of $username. If my username were to contain a single quote (Like O' Reilly) You'd have an invalide query which looks like this.

    "SELECT * FROM subs WHERE username='O' Reilly";

     

    This doesn't seem that serious but i could easily add SQL commands into my username to make your query execute commands that i want it to. I could steal all your passwords this way.

    To prevent SQL injection (Or atleast make it really difficult to do), You can use the mysql_real_escape_string() function. It requires you to have a connection to the database but you already have that.

     

    //Like this
    $username = mysql_real_escape_string( $_POST['username'] );
    

     

    I guess it's better that i don't post the string i'd enter to get your passwords.

    Here's an example i wrote up if you're interested in learning what SQL injection is: http://ping-localhos...brickhouse.html

     

    Also, You could md5 encrypt your passwords. A lot of identity theft happens because people use the same passwords on many sites. So if i were to steal passwords from your sites, I'd try them on every other site too.

    • Like 1
  12. I don't think you need to use any of those if you just want to send a mail (Like for email validation or password recovery).

    Just use the mail function with the required arguments and you should be fine.

     

    $to='myemail@gmail.com';
    
    $headers = 'From: testing@yourdomain.org';
    $subject = "Test";
    $message =
    'Hello!
    <body of the message>';
    
    if(mail($to,$subject,$message,$headers))
    echo 'Mail sent' ;//Doesn't mean it was received properly
    else
    echo 'Error sending the mail';
    

     

    You can add a 'Reply-To' in your headers so that they respond to an email address which exists (you can create one in your Cpanel'

     

    Eg:

    
    $headers = 'From: noreply@mydomain.org' . "\r\n" .
       'Reply-To: webmaster@mydomain.org' . "\r\n";
    

  13. I created a database in PHPMyadmin. It doesn't show up in CPanel and PHPMyadmin doesn't let me DROP the database.

    When i try

     DROP DATABASE db_name;

    I get an error saying 'DROP DATABSE statements are not allowed.'

     

    Or if there was a way i could assign a user privileges to this database. That would be fine too.

    Help?

     

    Edit: Got around it by a comment.

    DROP /**/ DATABASE db_name;

    . I guess i should have tried it out myself before asking. Sorry :(

×
×
  • Create New...