Jump to content

0perator

Members
  • Posts

    57
  • Joined

  • Last visited

    Never

Posts posted by 0perator

  1. hey guys, below is my code for my IRC robot, there is no network lag as it is running locally, but the bot takes AGES to reply to anything I say, i think the php interpreter is running slow perhaps due to some bad code, but i just cant figure out what it is! thanks!

     

    <?php
    include("functions.php");
    error_reporting(0);
    include("classes.php");
    $timer = false;
    $amiready = false;
    /*if(!details()){
    $display = new interfacer;
    $display->the_interface();
    }
    else{*/
    //$varset = new variablesetter();
    //$varset->setvars();
    $channel = "#bots";
    $tyu = 1;
    
    $sock = fsockopen("localhost", 6667);
    fputs($sock,"USER PHPBot thegeeks.us PHP :PHP Bot\n");
    
    //Sends the NICK to server
    fputs($sock,"NICK Anetslek\n");
    $currentnick = "Anetslek";
    //Join #lamerchan
    say("sup", $channel, $sock);
    $loghandle = fopen(date(d)."-".date(m)."-".date(Y).".txt", "a+");
    logw($loghandle, "\r\n----------------------------\r\nSTARTING LOGGING AT ". date(H).":".date(i).":".date(s)."\r\n----------------------------\r\n\r\n");
    sqlcon();
    while (1) {
    
       //Recieves the data into $data in 128 bytes.
       while ($data = fgets($sock,128)) {
          //puts the data in an array by word
          $get = explode(' ', $data);
          //echo $data;
    fputs($sock,"JOIN #bots\r\n");
    
    $timer = true;
          //Server Pinged us lets reply!
          if ($get[0] == "PING") {
          //echo "\nSending pong ".$get[1]."\n";
    	fputs ($sock, "PONG ".$get[1]."\n");
          }
          //////////////BOT FUNCTIONS HERE
      
          $speech1 = explode(":", $data);
          $command12 = $speech1[2];
          $command123 = explode(" ", $command12, 2);
          $command1 = $command123[0];
      
      $username1 = explode("!", $data);
      $username2 = explode(":", $username1[0]);
      $username = $username2[1];
      
          $secondcommand12 = $command123[1];      
          $secondcommand2 = str_replace("\n", "", $secondcommand12);
          $secondcommand = str_replace("\r", "", $secondcommand2);
          $args12 = $command123[1];
      
          $args1 = str_replace("\n", "", $args12);
          $args = str_replace("\r", "", $args1);
      
          $command2 = str_replace("\n", "", $command1);
          $command = str_replace("\r", "", $command2);
      
      if(strstr($data, "PRIVMSG")){
      logw($loghandle, $username." : ".$command." ".$args."\r\n");
      if($command == "Speak"){
      echo 'received this at'.date(i);
      while(say("Debug me please mejt!", $channel, $sock)){
      echo 'echoing lol';
      }
      echo 'received this at'.date(i);
      }
      //log the words and phrases
      /*if($command[0] != "#"){
      
      $phrase = $command." ".$args;
      if($phrase != "You have not registered"){
      //sqlcon();
      //check its not there already!
          $sqlq = mysql_query("SELECT * FROM `phrases` WHERE `Phrase` = '$phrase'");
      $rose = mysql_num_rows($sqlq);
      if($rose == 0){
      mysql_query("INSERT INTO  `phrases` (
    `ID` ,
    `Phrase` ,
    `Type` ,
    `Replies`
    )
    VALUES (
    NULL ,  '$phrase',  'SetMe',  'SetMe'
    );");
    }
      }
      }*/
      }
          //echo $user." says: ".$command."\n";
      
      echo $username." says: ".$command." ".$args."\n";  
          
          if($command == "Reboot"){
          echo "Rebooting, brb!\n";
          
          say("Back in a bit, boys!", $channel, $sock);
          fputs($sock, "QUIT :Rebooting\n");
          fclose($sock);
          
          exec("main.exe");
          exec("C:\\Documents\ and\ Settings\\Administrator\\Desktop\\BIRCD\\restart.bat");
          die("Had to quit.");
          }
      
      
      if($command == "#phrases"){
      //format time nicely
      say("I'd rather like to learn some new responses, can you help me?", $channel, $sock);
      //get some phrases
      sqlcon();
      $phq = mysql_query("SELECT * FROM `phrases` WHERE `Replies` = 'SetMe' LIMIT 20");
      $random_sel = rand(0, mysql_num_rows($phq));
      //print into an array
      $xy = 0;
      while($arrey = mysql_fetch_array($phq)){
      $xy++;
      $phrase_array[$xy] = $arrey['Phrase'];
      }
      say("Can you tell me a good reply to use when someone says \"".$phrase_array[$random_sel]."\" please?", $channel, $sock);
      $lastphrase = $phrase_array[$random_sel];
      say("Say \"#respond <answer>\" to set a response for the above phrase!", $channel, $sock);
          }
          
      if($command == "#respond"){
      sqlcon();
      echo $lastphrase;
      mysql_query("UPDATE `phrases` SET `Replies` = '$args' WHERE `Phrase` = '$lastphrase'");
      }
      
          if($command == "#calc"){
          $commando1 = explode(" ", $command);
          $commando = $secondcommand;
      
      if(strstr($commando1[1], "c ans")){
      say("Unsetting \"ans\"", $channel, $sock);
      unset($ans);
      }
      
          if(strstr($commando, "+")){
          $numbers = explode("+", $secondcommand);
          $one = $numbers[0];
          $two = $numbers[1];
      
      if($one == "ans"){
      $one = $ans;
      }
      
      if($two == "ans"){
      $two = $ans;
      }
      
          $three = $one+$two;
          say("ans=".$three, $channel, $sock);
      $ans = $three;	  
          }
          
          if(strstr($commando, "-")){
          $numbers = explode("-", $secondcommand);
          $one = $numbers[0];
          $two = $numbers[1];  
      if($one == "ans"){
      $one = $ans;
      }
      
      if($two == "ans"){
      $two = $ans;
      }
          $three = $one-$two;
          say("ans=".$three, $channel, $sock);
      $ans = $three;	  
          }
          
          if(strstr($commando, "*")){
          $numbers = explode("*", $secondcommand);
          $one = $numbers[0];
          $two = $numbers[1];
        if($one == "ans"){
      $one = $ans;
      }
      
      if($two == "ans"){
      $two = $ans;
      }
          $three = $one*$two;
          say("ans=".$three, $channel, $sock);
      $ans = $three;
          }
          
          if(strstr($commando, "/")){
          $numbers = explode("/", $secondcommand);
          $one = $numbers[0];
          $two = $numbers[1];
        if($one == "ans"){
      $one = $ans;
      }
      
      if($two == "ans"){
      $two = $ans;
      }
          $three = $one/$two;
          say("ans=".$three, $channel, $sock);
      $ans = $three;
          }
      }
          
          if($command == "#reboot"){
          echo "Rebooting the realm!\n";
          
          say("See you on the flip side.", $channel, $sock);
          fclose($sock);
          exec("main.exe");
          die("Had to quit.");
          }
                
          if($command == "#quit"){
          echo "Quitcommand!\n";
          
          say("Goodbye!", $channel, $sock);
          fputs($sock, "QUIT :".$args."\n");
          fclose($sock);
      logw($loghandle, "\r\n-------------------------\r\nLOGGING ENDED AT ".date(H).":".date(i).":".date(s)."\r\n-------------------------");
      fclose($loghandle);
          die("Had to quit.");
          }
      	 
         if($command == "#clearlogs"){
     logw($loghandle, "Clearing logs from ".$args);
     fclose($loghandle);
     error_reporting(1);
     $loghandle1 = fopen($args.".txt", "w+");
     fclose($loghandle1);
     unlink($args.".txt");
     $loghandle = fopen(date(d)."-".date(m)."-".date(Y).".txt", "a+");
     }
    
     if($command == "#name"){
     say("Changing my name!", $channel, $sock);
     logw($loghandle, "Changing my name from ".$currentnick." to ".$args);  
     $currentnick = $args;
     raw("NICK :".$args, $sock);
     }
    
     if($command == "#md5"){
     $con = mysql_connect("localhost", "root", "");
     mysql_select_db("bot");
     $checkhash = mysql_query("SELECT `hash` FROM `$comm` WHERE `raw` = '$args'");
     $checkhashrows = mysql_num_rows($checkhash);
     if($checkhashrows == 0){
     logw($loghandle, strtoupper($comm)." hashing ".$args);
     $hash = md5($args);
     mysql_query("INSERT INTO `bot`.`$comm` (`ID`, `raw`, `hash`) VALUES (NULL, '$args', '$hash');");
     say(strtoupper($comm)." hash for ". $args." : ".$hash, $channel, $sock);
     }
     else{
     $row = mysql_fetch_array($checkhash);
     say(strtoupper($comm)." hash for ". $args." : ".$row['hash'], $channel, $sock);
     }
     mysql_close($con);
     }
    
     if($command == "#crackmd5"){
     $con = mysql_connect("localhost", "root", "");
     mysql_select_db("bot");
     $checkhash = mysql_query("SELECT `raw` FROM `$comm` WHERE `hash` = '$args'");
     $checkhashrows = mysql_num_rows($checkhash);
     if($checkhashrows == 0){
     say("That's not in the database, sorry!", $channel, $sock);
     }
     else{
     $row = mysql_fetch_array($checkhash);
     say("Raw string for hash ". $args." : ".$row['raw'], $channel, $sock);
     }
     }
          }
          }
    //} 
    ?>
    

  2. Website is made for a charity, but I can't seem to get the footer to stay at the bottom of the page. I don't want it so it stays at the bottom of the frame because then it just stays static when you scroll, but at the moment it is suspended in the middle of the page, but in my 800 x 600 resolution it looks fine! Just doesn't in anything else :( major frustration, can anyone help please?

     

    Footer HTML:

     

    </div>
    	</div>
    	<div class="clearfooter">
    	<div id="footer">
    	<p><a href="http://www.cqc.org.uk/guidanceforprofessionals/socialcare/careproviders/inspection/ratingsandreports/qualityratings/ratingsrules.cfm#2">CQC Regulatory Body</a>  • 
    		<a href="http://62.73.173.233/CSCI/DCA/20/ES0000072120.V2000008163.R01.S.pdf">View Our Report</a>  • 
    		<a href="cons.html">Newsletter</a>  • 
    		<a href="contact.html">Contact</a><br>
    		Company Registration Number: 6490650   •  VAT Number Issued: 724545240</p>
    	</div>
    
    </body>
    </html>

     

    CSS:

     

    * {
    border:0;
    margin:0;
    padding:0;
    }
    .left {
    float:left;
    padding:0 10px 0 0;
    }
    .right {
    float:right;
    padding:0 0 0 10px;
    }
    a {
    color:#01a5ec;
    text-decoration:none;
    }
    a:hover {
    color:#666;
    text-decoration:underline;
    }
    p {
    padding:0 0 10px;
    }
    .clearer
    {
    clear: both;
    display: block;
    height: 1px;
    margin-bottom: -1px;
    font-size: 1px;
    height: 100%;
    line-height: 1px;
    }
    
    html
    {
    	height: 100%;
    }
    
    body
    {
    	min-height: 100%;
    }
    
    #content, main
    {
    	position: relative;
    	min-height: 100%;
    }
    
    * html #page
    {
    	height: 100%;
    }
    
    #footer
    {
    	position: absolute;
    	bottom: 0;
    }
    /* body */
    html, body {
    background:#0070b8 url('images/background_body.jpg') center repeat-y;
    color:#666;
    height: auto;
    font:12px "Trebuchet ms", Helvetica, sans-serif;
    }
    
    /* header */
    #header {
    background:#0070b8 url('images/background_header.jpg') center no-repeat;
    height:100px;
    margin:0 auto;
    width:548px;
    }
    #header h1 {
    color:#fff;
    display:block;
    font:32px "Trebuchet MS",Verdana,sans-serif;
    padding:50px 0 0 25px;
    }
    .clearfooter {
       height: 4em;
       clear: both;
    }
    .dent{
    padding-left: 25px;
    }
    #header h1 span {
    color:orange;
    }
    
    /* content */
    #content {
    margin:0 auto;
    width: 550px;
            height: auto !important;
            height: 100%;
            margin-bottom: -50px;
            position: relative;
    }
    #content h1 {
    color:#01a5ec;
    font:18px Verdana,sans-serif;
    margin:15px 0 5px 0;
    }
    #main {
    float:left;
    padding:10px 10px 0 10px;
    /*width:335px;*/
    height: 100%;
    position:relative;
    }
    #sidebar {
    width:160px;
    float:right;
    padding:15px;
    }
    #sidebar .navigation {
    list-style:none;
    }
    #sidebar .navigation li {
    list-style:none;
    }
    
    /* footer */
    #block{
    height: auto;
    }
    #footer {
    background:url('images/background_footer.jpg') center no-repeat;
    clear:both;
            position: relative;
    bottom:0;
    height:50px;
    margin:0 auto;
    text-align:center;
    width:100%;
    }
    #footer p {
    color:#666;
    line-height:18px;
    padding:7px 0 0
    }
    
    /* form elements */
    form {
    margin: -6px 0px; 
    padding: 0;
    background: #;	
    }
    label {
    display:block;
    font-weight:bold;
    margin:5px 0;
    }
    input {
    padding: 2px;
    border:2px solid lightblue;
    font:12px "Trebuchet ms", Helvetica, sans-serif;
    color:#777;
    }
    textarea {
    width: 400px;
    padding:2px;
    font:12px "Trebuchet ms", Helvetica, sans-serif;
    border:2px solid lightblue;
    height:100px;
    display:block;
    color:#777;
    }
    input.button { 
    margin: 0; 
    font:12px "Trebuchet ms", Helvetica, sans-serif;
    border: 2px solid lightgrey;
    background: #FFF; 
    padding: 2px 3px; 
    color: #333;	
    }

  3. Hey guys,

     

    I am making a School Behavior Management System and have come across a small issue. Code is as follows:

     

    <?php

    include("global.php");

     

    $username = $_POST['username'];

    $password = $_POST['password'];

    $md5pass = md5($password);

     

    // check if user is a student

    $student_result = mysql_query("SELECT * FROM students WHERE `Username` = '$username' AND `Password` = '$md5pass'");

    $student_num_rows = mysql_num_rows($student_result);

     

    if ($student_num_rows == 0)

                {

      // check and see if user is a teacher

      $teacher_result = mysql_query("SELECT * FROM teachers WHERE `Username` = '$username' AND `Password` = '$md5pass'");

      $teacher_num_rows = mysql_num_rows($teacher_result);

    }

     

          if ($teacher_num_rows == 0)

        {

      // check and see if user is an admin

      $admin_result = mysql_query("SELECT * FROM admins WHERE `Username` = '$username' AND `Password` = '$md5pass'");

      $admin_num_rows = mysql_num_rows($admin_result);

    }

     

      if ($admin_num_rows == 0)

    {     

            // no user found with given username and password

            die('Login failed');

      }

     

    else if ($teacher_num_rows >= 1)

    {

            ?>

            <a href="/notices.php">Notices</a><br><br>

            <a href="/classes.php">Classes</a><br><br>

            <a href="/stusearch.php">Student Search</a><br><br>

          <a href="/timetable.php">My Timetable</a><br><br>

            <a href="/prefs.php">Prefrences</a><br><br>

            <a href="/logout.php">Logout</a>

            <?php

            }

     

    else if ($student_num_rows >= 1)

    {

            ?>

      <a href="/notices.php">Notices</a><br><br>

          <a href="/classes.php">Classes</a><br><br>

          <a href="/stusearch.php">Student Search</a><br><br>

          <a href="/timetable.php">My Timetable</a><br><br>

          <a href="/prefs.php">Prefrences</a><br><br>

            <a href="/logout.php">Logout</a>

            <?php

          }

    else if ($admin_num_rows >= 1)

    {

          ?>

          <a href="/notices.php">Notices</a><br><br>

          <a href="/Subjects">Subjects</a><br><br>

          <a href="/users.php">User List</a><br><br>

            <a href="/settings.php">System Settings</a><br><br>

            <a href="/prefs.php">Prefrences</a><br><br>

            <?php

            }

            else

    {

            echo 'System Failure. Please contact your local administrator.';

            }

    ?>

     

    This is for menu.php which is an include in index.php when users are logged in. There are three types of user, Teacher, Admin and Student. Each type has a different menu. As you can see above these menus are clearly defined. For some reason every time I log in as each type of user, it gives me "Login failed". global.php just connects to the MySQL database. Saves writing the code out for each page.

     

    Any ideas as to the problem and how to fix it?

     

    Thanks,

     

    0perator

  4. <?php
     $username = $_POST['username'];
     $password = $_POST['password'];
     $md5pass = md5($password);
     $login_check = mysql_query("SELECT * FROM students WHERE `Username` = '$username' AND `Password` = '$md5pass'");
     $login_rows = mysql_num_rows($login_check);
     if($login_rows == 0){
     $login_check_t = mysql_query("SELECT * FROM teachers WHERE `Username` = '$username' AND `Password` = '$md5pass'");
     $login_rows_t = mysql_num_rows($login_check_t);
     if($login_rows_t == 0) die('Login failed</body></html>');
     }
     elseif($login_rows_t >= 1){
     $login_array_t = mysql_fetch_array($login_check_t);
     echo 'LOL LOL LOL LOL';
     echo 'Welcome '.$login_array_t['Name'];
     }
     elseif($login_rows >= 1){
     $login_array = mysql_fetch_array($login_check);
     echo 'Welcome '.$login_array['Name'];
     }
     else{
     echo 'some sort of failure in the system';
     }
     ?>
    

     

    it wont go into the LOL LOL LOL LOL section.. no matter what, it does not echo "some sort of failure in the system either". the student login works fine..

  5. hi, i have never done this before, but is it possible to have speakers playing my music, while my headphones are playing my skype calls, obviously i have 2 different jacks, just wondering how i would go about setting the computer so it knows the speakers are in the back jack, and the headphones are in the front jack.

     

    vista btw.

     

    thanks :)

  6. this is my code

    <?php
    $allowed = array('index.php');
    $page = $_GET['page'];
    
    if(!empty($page))
    {
    $page .= '.php';
    
    if(in_array($page, $allowed))
    {
    	include($page);
    }
    }
    
    else
    {
    include($allowed[0]);
    }
    ?>
    
    <html>
    <head>
    <title>
    .:hakman:.
    </title>
    </head>
    <body>
    <body bgcolor="black">
    <font color="green">
    <center>
    text here la la la
    </font>
    </body>
    </html>
    

     

    i have tried it on another subdomain of mine and it works, just wana know how to get it to work on the one i am meant to be using.

     

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