Jump to content

nonexistentera

Members
  • Posts

    45
  • Joined

  • Last visited

    Never

Everything posted by nonexistentera

  1. I have a very large table, ~100 million rows, and many times when I connect to it, the server shutsdown from exceeding CPU quota(shared host). Is there anyway to do this better. I still need to search through it too, so Im wondering If I could do a file with all the data, like an XML file. Im not sure, and I REALLy don't want to over do it. Thanks in advance for any options.
  2. Nevermind. After going through over and over I finally got something that works. I just said screw everything and fixed the SQL $sql = "INSERT INTO users (username, passhash, secret, editsecret, email, status, added) VALUES (" . implode(",", array_map("sqlesc", array($wantusername, $wantpasshash, $secret, $editsecret, $email, 'pending'))) . ", NOW())"; Now I have a Date/Time so I don't have to worry about random other codes.
  3. It might be the SQL statement. $sql = "INSERT INTO users (username, passhash, secret, editsecret, email, status, added) VALUES (" . implode(",", array_map("sqlesc", array($wantusername, $wantpasshash, $secret, $editsecret, $email, 'pending'))) . ",'date('l jS \of F Y h:i:s A')')"; I get You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'l jS \of F Y h:i:s A')')' at line 1 I not sure how I can do the current date/time
  4. Hello there. I have a page that was apart of a package that I got. I keep receiving errors about the headers already being sent, but as far as I know, I need them there to redirect the page as there is no real output. <? require_once("include/bittorrent.php"); hit_start(); dbconn(); $res = mysql_query("SELECT COUNT(*) FROM users") or sqlerr(__FILE__, __LINE__); $arr = mysql_fetch_row($res); if ($arr[0] >= $maxusers) stderr("Error", "Sorry, user limit reached. Please try again later."); if (!mkglobal("wantusername:wantpassword:passagain:email")) die(); function bark($msg) { stdhead(); stdmsg("Signup failed!", $msg); stdfoot(); exit; } function validusername($username) { if ($username == "") return false; // The following characters are allowed in user names $allowedchars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; for ($i = 0; $i < strlen($username); ++$i) if (strpos($allowedchars, $username[$i]) === false) return false; return true; } function isportopen($port) { global $HTTP_SERVER_VARS; $sd = @fsockopen($HTTP_SERVER_VARS["REMOTE_ADDR"], $port, $errno, $errstr, 1); if ($sd) { fclose($sd); return true; } else return false; } /* function isproxy() { $ports = array(80, 88, 1075, 1080, 1180, 1182, 2282, 3128, 3332, 5490, 6588, 7033, 7441, 8000, 8080, 8085, 8090, 8095, 8100, 8105, 8110, 8888, 22788); for ($i = 0; $i < count($ports); ++$i) if (isportopen($ports[$i])) return true; return false; } */ if (empty($wantusername) || empty($wantpassword) || empty($email)) bark("Don't leave any fields blank."); if (strlen($wantusername) > 12) bark("Sorry, username is too long (max is 12 chars)"); if ($wantpassword != $passagain) bark("The passwords didn't match! Must've typoed. Try again."); if (strlen($wantpassword) < 6) bark("Sorry, password is too short (min is 6 chars)"); if (strlen($wantpassword) > 40) bark("Sorry, password is too long (max is 40 chars)"); if ($wantpassword == $wantusername) bark("Sorry, password cannot be same as user name."); if (!validemail($email)) bark("That doesn't look like a valid email address."); if (!validusername($wantusername)) bark("Invalid username."); // make sure user agrees to everything... if ($HTTP_POST_VARS["rulesverify"] != "yes" || $HTTP_POST_VARS["faqverify"] != "yes" || $HTTP_POST_VARS["ageverify"] != "yes") stderr("Signup failed", "Sorry, you're not qualified to become a member of this site."); // check if email addy is already in use $a = (@mysql_fetch_row(@mysql_query("select count(*) from users where email='$email'"))) or die(mysql_error()); if ($a[0] != 0) bark("The e-mail address $email is already in use."); /* // do simple proxy check if (isproxy()) bark("You appear to be connecting through a proxy server. Your organization or ISP may use a transparent caching HTTP proxy. Please try and access the site on <a href=http://torrentbits.org:81/signup.php>port 81</a> (this should bypass the proxy server). <p><b>Note:</b> if you run an Internet-accessible web server on the local machine you need to shut it down until the sign-up is complete."); */ hit_count(); $secret = mksecret(); $wantpasshash = md5($secret . $wantpassword . $secret); $editsecret = mksecret(); $sql = "INSERT INTO users (username, passhash, secret, editsecret, email, status, added) VALUES (" . implode(",", array_map("sqlesc", array($wantusername, $wantpasshash, $secret, $editsecret, $email, 'pending'))) . ",'date('l jS \of F Y h:i:s A')')"; $ret = mysql_query($sql); if (!$ret) { if (mysql_errno() == 1062) bark("Username already exists!"); bark("borked"); } $id = mysql_insert_id(); //write_log("User account $id ($wantusername) was created"); $psecret = md5($editsecret); $body = <<<EOD You have requested a new user account on $SITENAME and you have specified this address ($email) as user contact. If you did not do this, please ignore this email. The person who entered your email address had the IP address {$_SERVER["REMOTE_ADDR"]}. Please do not reply. To confirm your user registration, you have to follow this link: $DEFAULTBASEURL/confirm.php?id=$id&secret=$psecret After you do this, you will be able to use your new account. If you fail to do this, you account will be deleted within a few days. We urge you to read the RULES and FAQ before you start using torrentbits. EOD; mail($email, "$SITENAME user registration confirmation", $body, "From: $SITEEMAIL", "-f$SITEEMAIL"); header("Refresh: 0; url=ok.php?type=signup&email=" . urlencode($email)); hit_end(); ?> Heres the code. Once everything is done, It is suppose to go to ok.php which is there to tell them that they need to confirm their account. Any help on how I could do this differently. ???
  5. No problem. I get helped, and I give help. Glad to see you found the problem though. Good Job
  6. From what I know about sessions, you have to call session_destroy(); which will remove all data registered to a session. Try <?php session_start(); //allows session include "config.php"; //checks there trying to logout if(isset($_GET['logout'])) { //deletes the sessions unset($_SESSION['id']); unset($_SESSION['password']); session_destroy(); //RIGHT HERE //loggedout message echo "You are now logged out. Redirecting you to homepage.."; //redriects them to index echo "<meta http-equiv='Refresh' content='2; URL=http://www.douglas-elemex.net'/>"; } ?> I see that it unsets it, but to my knowledge, session_destroy(); should remove anything else that may be lingering. If not, we will try something else
  7. Yeah. To my knowledge the `table`.`x1` means that it will insert into the database named table, and the table named x1. Not sure, just got it from phpMyAdmin. include('db_connect.inc.php'); function md5this($length,$limit){ $_GLOBALS[$evalinsert]; while ($length<$limit){ set_time_limit(0); $charset = "abcd"; // Do not edit beyond this point! for($i=0;$i<strlen($charset);$i++) $x[]=$charset[$i]; for($i=0,$z="",$e="echo ";$i<$length;$i++){ $z.="foreach(\$x as \$y[$i])"; $e.="\$y[$i]."; } $evalinsert = eval($z.$e."\"<br />\";"); mysql_query("INSERT INTO `md5Sums` ( `id` , `anValue`, `md5Sum` ) VALUES ( NULL , '$exits', '".md5($exits)."')") or die(mysql_error()); $length++; } } md5this(1, 3); Here is what I have after the fix in the SQL and setting evalinsert to global. Anything look wrong, as it still is just inserting a blank. 1 (blank) d41d8cd98f00b204e9800998ecf8427e
  8. Not that this would be the case, but your config.php file has the logged in time to 200 miliseconds. $logout_time = 200; //mili seconds to stay logged in $current = time(); //current time $offline = ($current - $logout_time); //do the math for the logout time So it seems that your database knows that they are logged in, but the Session thinks they are only logged in for 200 miliseconds, so once they log in, they are automatically logged out once the script is done executing. I would just experiment with changing it to something higher.
  9. Hello there. I have a script that makes a permutation. ex. a b c aa ab ...and so on function md5this($length,$limit){ while ($length<$limit){ set_time_limit(0); $charset = "abcd"; for($i=0;$i<strlen($charset);$i++) $x[]=$charset{$i}; //Right below for($i=0,$z="",$e="echo ";$i<$length;$i++){ $z.="foreach(\$x as \$y[$i])"; $e.="\$y[$i]."; } $evalinsert = eval($z.$e."\"<br />\";"); //To Here $length++; } } I am wondering if anyone can help me changing the eval part. I am trying to keep everything nice and simple. and I also need to be able to insert it into MySQL and with how it is now I cannot do so. Any help is much appreciated.
  10. Hello. I have the script below that creates a list of random alphanumeric combinations. include('db_connect.inc.php'); function md5this($length,$limit){ while ($length<$limit){ set_time_limit(0); $charset = "abcdefghijklmnopqrstuvwxyz0123456789"; // Do not edit beyond this point! for($i=0;$i<strlen($charset);$i++) $x[]=$charset{$i}; for($i=0,$z="",$e="echo ";$i<$length;$i++){ $z.="foreach(\$x as \$y[$i])"; $e.="\$y[$i]."; } $evalinsert = eval($z.$e."\"<br />\";"); $length++; mysql_query("INSERT INTO `table`.`x1` ( `id` , `ancode` ) VALUES ( NULL , '$evalinsert' );"); } } md5this(1,3); I know that it is connecting to the database and inserting data, but not the data I need. With how it is now it just inserts a blank space. I am trying to input all of the data that the script displays. Anyone know what to change. Script output is Here
  11. Hello. I am wondering how I can get the script below to produce a list of random alphanumeric strings that are less that 10 characters in length and contain all possible combinations. Such as "a, b, c... aa,ab,ac" until it goes through the full list of available characters. <?PHP $length = 2; $complete = 10; $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; $charslength = strlen($chars); $randomstring = ''; mysql_connect("localhost","tylerper_root","tperroux") or die("No connection"); while ($t < $length) { while ($i < $complete) { $randomstring .= substr($chars, rand(0, $charslength - 1), 1); mysql_query(" INSERT INTO `tylerper_cookbook2`.`xl` ( `id` , `md5` ) VALUES ( '', '$randomstring' ); "); echo $randomstring. " <br> "; $i++; } $t++; } ?> It produces some what what I would like but not as repeatative for each string length. 0 01 018 0181 01817 01817T 01817TV 01817TVS 01817TVSN 01817TVSN5 It only does the length once then goes up, but I need it to do the length the number of times of how many characters there are eg. 26. and have it change instead of just adding another random letter/number. Any help is much appreciated. Thanks
  12. Hello. I am wondering if anyone knows of a script similair to the one found http://www.phpizabi.net/index.php?L=support.codesearch Thanks in advance Tyler
  13. OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO Thank you so much. I kept going over what you said and my code wondering what you ment. Thank you. I would have been stuck on this forever. I guess this was going to happen someday. I never really spent much time learning how to make functions.
  14. Ahhh... Well I did that. I changed it to myFunction(); instead of echo myFunction(); But im still not getting anything I receive an error Fatal error: Function name must be a string in /my/path/root.php on line 27 Which is $myFunction();
  15. Alright Here is the main page code <div class="main" id="two-columns"> <div class="col2"> <div class="left"> <div class="content"> <h1>Recent Post</h1> <?PHP //Query from table//////////////////////////////////////// $sql = " SELECT * FROM `add` WHERE `date` < NOW() ORDER BY `add`.`date` DESC LIMIT 0 , 20 "; $query = mysql_query($sql); //While array gives new results in past 10 minutes//////// echo "<ul class=\"block\">"; while ($row = mysql_fetch_assoc($query)) { echo "<li><span>".$row["name"].""; echo " in ".$row["city"]." wrote</span>"; echo "<em>\"". $path = $row['sentencePath']; $file = fopen($path, "r", TRUE); $lines = 3; /*enter the number of lines you want from the file */ $count = 1; if($file){ while($count < $lines){ $buffer = fgets($file, 50); echo "<b>".$buffer."<b/>"; $count++; } fclose($file); } "\"</em>"; echo "</li>"; } echo "</ul>"; ?> </table> The form <div class="contentForm" id="contentForm" style="position: relative; float: left;"> <form action="postContent.php?ampersand=2010" method="POST"> <table> <tr> <td> <input type="hidden" name="random" value="<?= $captchas->random () ?>" /> </td> </tr> <tr> <td> <input name="name" size="20" value="Name" onfocus="if( this.value==this.defaultValue ) this.value='';" onblur="if( this.value=='' ) this.value=this.defaultValue;" type="text"><BR> </td> </tr> <tr> <td> <input name="city" size="20" value="City, State, Zip" onfocus="if( this.value==this.defaultValue ) this.value='';" onblur="if( this.value=='' ) this.value=this.defaultValue;" type="text"><BR> </td> </tr> <tr> <td> <input name="mood" size="20" value="Current Mood" onfocus="if( this.value==this.defaultValue ) this.value='';" onblur="if( this.value=='' ) this.value=this.defaultValue;" type="text"><BR> </td> </tr> <tr> <td> <textarea rows="5" cols="20" name="sentence" onfocus="if( this.value==this.defaultValue ) this.value='';" onblur="if( this.value=='' ) this.value=this.defaultValue;">Write something. Thats the point of this :]</textarea><br /> <?= $captchas->image () ?> <br> <a href="<?= $captchas->audio_url () ?>">Phonetic spelling (mp3)</a> </td> </tr> <tr> <td> Enter What You See: <input name="password" size="6" /> </td> </tr> <tr> <td> <input value="Submit" type="submit"> </table> </form> </div> The script that inserts the data <?php // See query.php for documentation // Check the random string to be valid and return an error message // otherwise. if (!$captchas->validate ($random_string)) { echo 'Every CAPTCHA can only be used once. The current CAPTCHA has already been used. Try again.'; } // Check, that the right CAPTCHA password has been entered and // return an error message otherwise. elseif (!$captchas->verify ($password)) { echo 'You entered the wrong password. Aren\'t you human? Please use back button and reload.'; } // Return a success message else { include('./fnc_filter.php'); include('db.php'); $amp = $_GET["ampersand"]; $name = $_POST["name"]; $city = $_POST["city"]; $mood = $_POST["mood"]; $words = $_POST["sentence"]; if(!isset($amp)){ exit("Form not submitted"); } else { } $not_allowed = array("******"); // List of bad words $nameFilter = filter_words($_POST['name'], $not_allowed, $strict = $strict); $cityFilter = filter_words($_POST['city'], $not_allowed, $strict = $strict); $moodFilter = filter_words($_POST['mood'], $not_allowed, $strict = $strict); $wordsFilter = filter_words($_POST['sentence'], $not_allowed, $strict = $strict); $randNum = rand(0,50000); $file = $_SERVER['DOCUMENT_ROOT']."/articles/".$randNum.".php"; $fp = fopen($file, 'w'); fwrite($fp, $wordsFilter); fclose($fp); mysql_query("INSERT INTO `tylerper_cookbook2`.`add` ( `id` , `name` , `city` , `mood` , `date` , `sentenceFile` , `sentencePath` ) VALUES ( NULL , '$nameFilter', '$cityFilter', '$moodFilter', CURRENT_TIMESTAMP , '$randNum.php', '$file')"); echo "Thank you :] <br />"; echo "Please return to our <a href=\"http://add.tylerperroux.com/\">home page</a> to view your post"; } ?> And the MySQL Table Layout -- -- Table structure for table `add` -- CREATE TABLE IF NOT EXISTS `add` ( `id` bigint( NOT NULL auto_increment, `name` varchar(64) NOT NULL, `city` varchar(64) NOT NULL, `date` timestamp NOT NULL default CURRENT_TIMESTAMP, `articleFile` varchar(20) NOT NULL, `articlePath` longtext NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `id` (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=23 ; -- -- Dumping data for table `add` -- INSERT INTO `add` (`id`, `name`, `city`, `mood`, `date`, `articleFile`, `articlePath`) VALUES (1, 'Name', 'City', '2008-06-11 09:38:14', '49488.php', '/my/path/to/articles/49488.php'), My Function looks like <?PHP function myFunction(){ $user = "root"; $pass = "pass"; $host = "localhost"; $db = "tablename"; $cxn = mysql_connect($host, $user, $pass) or die; mysql_select_db($db, $cxn); $sql = " SELECT * FROM `add` WHERE `date` < NOW() ORDER BY `add`.`date` DESC LIMIT 0 , 20 "; $query = mysql_query($sql); $row = mysql_fetch_assoc($query); $path = $row['sentencePath']; $file = fopen($path, "r", TRUE); $lines = 3; /*enter the number of lines you want from the file */ $count = 1; if($file){ while($count < $lines){ $buffer = fgets($file, 50); echo "<b>".$buffer."<b/>"; $count++; } fclose($file); } } echo $myFunction; ?> And there is no output, just a blank Screen. If I remove the code from the function, it works fine. And there appears to be no errors either in the page or in error_log. Im Thinking I messed up somewhere.
  16. Alright I have every thing out of the DB. They are all stored in files with the names rand(0,5000);.".php". Now I am having some other issues. I am trying to put all of this in a function $user = "root_user"; $pass = "pass"; $host = "localhost"; $db = "db"; $cxn = mysql_connect($host, $user, $pass) or die; mysql_select_db($db, $cxn); $sql = " SELECT * FROM `add` WHERE `date` < NOW() ORDER BY `add`.`date` DESC LIMIT 0 , 20 "; $query = mysql_query($sql); $row = mysql_fetch_assoc($query); $path = $row['sentencePath']; $file = fopen($path, "r", TRUE); $lines = 3; /*enter the number of lines you want from the file */ $count = 1; if($file){ while($count < $lines){ $buffer = fgets($file, 50); echo "<b>".$buffer."<b/>"; $count++; } fclose($file); } And when i do I get no output. But it works fine on its own. I am doing this because of how my script is setup, the output seems to be the complete file path and all the contents. Here is the code that gives me the output /system/file/path/rand.phpArticleContent <?PHP //Query from table//////////////////////////////////////// $sql = " SELECT * FROM `add` WHERE `date` < NOW() ORDER BY `add`.`date` DESC LIMIT 0 , 20 "; $query = mysql_query($sql); //While array gives new results in past 10 minutes//////// echo "<ul class=\"block\">"; while ($row = mysql_fetch_assoc($query)) { echo "<li><span>".$row["name"].""; echo " in ".$row["city"]." wrote</span>"; echo "<em>\"". $path = $row['sentencePath']; $file = fopen($path, "r", TRUE); $lines = 3; /*enter the number of lines you want from the file */ $count = 1; if($file){ while($count < $lines){ $buffer = fgets($file, 50); echo "<b>".$buffer."<b/>"; $count++; } fclose($file); } "\"</em>"; echo "</li>"; } echo "</ul>"; ?> I'm not sure what to fix, or if I show go a different way with outputing the data.
  17. Nice code but with how i have it that wont word. with how it is now I have the entire article being store in the db. There is no files being used to store the articles. Is there any way I can cut it down using Php before it is inserted?
  18. Hello. I have a current script that displays the contents of my MySQL table. Because of the length of the article I am wondering how I can have the out put display only a certain number of letters before it quits, as to not overload the page. Basically just a preview. What I have is $sql = " SELECT * FROM `table` WHERE `date` < NOW() ORDER BY `table`.`date` DESC LIMIT 0 , 4"; $query = mysql_query($sql); while ($row = mysql_fetch_assoc($query)) { echo "<li><a href=\"httpPage\"><span>".$row["name"]."</span><em>".$row["article"]."</em></a></li>"; } I just can't think of what I could use. All Help is very much appreciated.
×
×
  • 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.