Jump to content

jonsjava

Members
  • Posts

    1,579
  • Joined

  • Last visited

Everything posted by jonsjava

  1. I had someone on a budget once (read: $10/month). My solution, while not elegant, worked. Ensure your code is in Git Configure the deploy user to have access to Git via SSH Clone the repo into the directory you wish to serve it out of Create a cron that runs ever x minutes/hours that will do the following: cd /path/to/your/code && git reset --hard && git pull origin master This solved their problem. There are better solutions (Jenkins, for example), but if you want simple, cron + git works.
  2. Just for fun, here's a different approach to hashing: function DeepCrypt($salt,$string){ $first_run = md5($string.$salt); $second_run = str_replace(array("a","2","3"),"",$first_run); $third_run = md5($second_run.$salt); return $third_run; } Don't really need to do this, but if you're worried about having your hashes reversed, this should clear that up.
  3. Without going into code, I will tell you my experience with writing SOAP calls. When I first started writing them, I had issues, because their SOAP calls didn't always conform to the standards. I found a tool (soapui) to help me build the basic calls, and then reverse-engineered the calls for PHP. What I would recommend you do is find a good SOAP client, get the hang of it, get used to calls, and then build from there. You can do calls from SOAPui without much work at all. it will even build the call templates for you.
  4. noticed that I didn't see you executing the queries: <?php echo "<h1>Register</h1>"; $submit = $_POST['submit']; $username = ucfirst(strip_tags($_POST['username'])); $password = strip_tags($_POST['password']); $confpassword = strip_tags($_POST['confpassword']); $email = strip_tags($_POST['email']); $fname = ucfirst(strip_tags($_POST['fname'])); //$ref = strip_tags($_POST['ref']); $joindate = date("Y-m-d"); //I should only give the 50 credits once the user has surfed OR activated email? $credits = 50.000; $ip = $_SERVER['REMOTE_ADDR']; $level = 1; if ($submit) { include('inc/connect.php'); $namecheck = mysql_query("SELECT username FROM users WHERE username='$username'"); $usernamecount = mysql_num_rows($namecheck); $emailcheck = mysql_query("SELECT email FROM users WHERE email='$email'"); $emailcount = mysql_num_rows($emailcheck); if ($usernamecount!=0) { die("Username already taken!"); } if ($emailcount!=0) { die("E-mail already being used"); } function validEmail($email) { $isValid = true; $atIndex = strrpos($email, "@"); if (is_bool($atIndex) && !$atIndex) { $isValid = false; } else { $domain = substr($email, $atIndex+1); $local = substr($email, 0, $atIndex); $localLen = strlen($local); $domainLen = strlen($domain); if ($localLen < 1 || $localLen > 64) { // local part length exceeded $isValid = false; } else if ($domainLen < 1 || $domainLen > 255) { // domain part length exceeded $isValid = false; } else if ($local[0] == '.' || $local[$localLen-1] == '.') { // local part starts or ends with '.' $isValid = false; } else if (preg_match('/\\.\\./', $local)) { // local part has two consecutive dots $isValid = false; } else if (!preg_match('/^[A-Za-z0-9\\-\\.]+$/', $domain)) { // character not valid in domain part $isValid = false; } else if (preg_match('/\\.\\./', $domain)) { // domain part has two consecutive dots $isValid = false; } else if (!preg_match('/^(\\\\.|[A-Za-z0-9!#%&`_=\\/$\'*+?^{}|~.-])+$/', str_replace("\\\\","",$local))) { // character not valid in local part unless // local part is quoted if (!preg_match('/^"(\\\\"|[^"])+"$/', str_replace("\\\\","",$local))) { $isValid = false; } } if ($isValid && !(checkdnsrr($domain,"MX") || checkdnsrr($domain,"A"))) { // domain not found in DNS $isValid = false; } } return $isValid; } // Check for filled out form if ($username&&$password&&$confpassword&&$email&&$fname) { //Encrypt password if ($password==$confpassword) { if (strlen($username)>25) { echo "Max limit for Username is 25 characters"; } if (strlen($password)>32||strlen($password)<6) { echo "Password must be between 6 and 32 characters"; } else { //Register the user $password = md5($password); $confpassword = md5($confpassword); echo "Success!"; mysql_query("INSERT INTO users VALUES ('','$username','$email','$fname','','','','$joindate','$password','$ip')"); mysql_query("INSERT INTO userstats VALUES ('','$username','$level','','$credits','','','','')"); header("location:index.php"); } if (strlen($email)>25) { echo "Max limit for E-mail is 64 characters"; } if (strlen($fname)>25) { echo "Max limit for First Name is 25 characters"; } /*if (strlen($lname)>25) { echo "Max limit for Last Name is 25 characters"; }*/ } else echo "Your passwords do not match!"; } else echo "Please fill in <strong>all</strong> fields!"; } ?> <html> <head> <link rel="stylesheet" type="text/css" href="style.css" /> <script type="text/javascript" language="javascript"> function inputLimiter(e,allow) { var AllowableCharacters = ''; if (allow == 'FirstNameChar'){AllowableCharacters='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';} if (allow == 'UsernameChar'){AllowableCharacters='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890';} var k; k=document.all?parseInt(e.keyCode): parseInt(e.which); if (k!=13 && k!=8 && k!=0){ if ((e.ctrlKey==false) && (e.altKey==false)) { return (AllowableCharacters.indexOf(String.fromCharCode(k))!=-1); } else { return true; } } else { return true; } } </script> </head> <body> <form action="register.php" method="POST"> <div id="register">Username: <input type="text" id="UsernameChar" onkeypress="return inputLimiter(event,'UsernameChar')" name="username" maxlength="25" value="<?php echo $username ?>"><br /> Password: <input type="password" maxlength="32" name="password"><br /> Confirm Password: <input type="password" maxlength="32" name="confpassword"><br /> First Name: <input type="text" id="FirstNameChar" onkeypress="return inputLimiter(event,'FirstNameChar')" name="fname" maxlength="25" value="<?php echo $fname ?>"><br /> E-mail: <input type="text" name="email" maxlength="64" value="<?php echo $email ?>"><br /> <input type="submit" name="submit" value="Register"></div> </form> </body> </html>
  5. try something like this: set a session variable, that once set flags the system to not re-check the IP: <?php session_start(); if (!isset($_SESSION['ip_checked']) || $_SESSION['ip_checked'] != true){ //run the check } Now, on the script that does the check with fsockopen() <?php session_start(); if (!isset($_SESSION['ip_check']) || $_SESSION['ip_check'] != true){ // check them $_SESSION['ip_check'] = true; $_SESSION['location'] = $LOCATION_FOUND_FROM_WEB_SERVICE; } Complete pseudocode, but it should point you in the right direction.
  6. A breakdown of your script, as read: run a query, and return everything in the table. While parsing through the results, assign variable $id to equal column "transid". Insert into the table named `table_2` at columns name, city the values "john" and "london", respectively. Delete all occurneces from `table_1` where the `id`=$id, even though it's true name is `transid`. Ok, I think you see the issue here: <?php $var1= mysql_query("SELECT `transid` FROM table1"); while ($var2= @mysql_fetch_assoc($var1)) { $id = $var2['transid']; mysql_query("INSERT INTO table 2(name, city) VALUES ('John', 'London')") or die (error25); mysql_query("DELETE FROM table1 WHERE `transid` = '$id' ") or die(mysql_error()); } ?>
  7. is the sidebar the first thing to be included? If session_start isn't the first thing you outupt, you can't use it.
  8. Mail group Solution It's a newsletter script.
  9. <?php include("header.php"); $eaglelegend = "eaglelegend.com"; //Your site url without http:// $eaglelegend2 = "www.eaglelegend.com"; //Type your domain with www. this time $referer = $_SERVER['HTTP_REFERER']; //Check if browser sends referrer url or not if ($referer == "") //If not, set referrer as your domain $domain = $yoursite; } else $domain = parse_url($referer); //If yes, parse referrer } if($domain['host'] == $eaglelegend || $domain['host'] == $eaglelegend2) { //Run your dowloading code here normally } else { //The referrer is not your site, we redirect to your home page header("Location: http://www.eaglelegend.com"); exit(); //Stop running the script } @$username = strip_tags(stripslashes($_POST['username'])); //assuming 'username' is the name of your form var @$password = strip_tags(stripslashes(md5($_POST['password']))); // ditto on 'password' if($username && $password) { $check = mysql_num_rows(mysql_query("SELECT * FROM `members` WHERE `username`='$username' AND `password`='$password'")); if($check == 1) { $_SESSION['ELv2'] = $username; if(session_register('ELv2')){ $sql = mysql_query("UPDATE members SET ip ='{$_SERVER['REMOTE_ADDR']}' WHERE username='$username' LIMIT 1"); Header("Location: index.php"); } else { print "Cant set cookie"; } } else { print "Sorry, username/password mismatch!"; } } else { ?> You were missing 2 brackets
  10. <?php include("dbinfo.inc.php"); mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query = "SELECT YEAR(Date) FROM auctions GROUP BY YEAR(Date)"; $result = mysql_query ($query); echo "<select name=Date>"; // printing the list box select command while($nt=mysql_fetch_array($result)) { //Array or records stored in $nt $date = $nt['date']; echo "<option value='$date'>$date</option>"; /* Option values are added by looping through the array */ } echo "</select>";// Closing of list box ?>
  11. Well, I'm going to stop helping for a while (wife wants me to go do stuff) can someone else take over this one for me?
  12. have you tried doing a different query, something like (I'm just using examples, mind you) SELECT `user`, `hours` FROM `vamsys_pireps` ORDER BY `hours` DESC; This would give you all your users, from most hours to least hours. You could then add them into 2 arrays (or a multi dimensional array), and update their rank from there.
  13. leave out the else. If neither is true, then it will do nothing.
  14. if($row_hour_count['hour_count'] > $row_rank['hours']) where are you setting $row_hour_count ?
  15. the problem was that he was failing the if statement. If he had passed the if statement, he wouldn't have gotten the resource id. He reused $rank (which was originally the query), so when he failed the if statement, $rank became the query, instead of a result element.
  16. ah, I see. then try this: <?php mysql_select_db($database_vamsys, $vamsys); $query_rank = sprintf("SELECT * FROM vamsys_ranks"); $rank = mysql_query($query_rank, $vamsys) or die(mysql_error()); $row_rank = mysql_fetch_assoc($rank); $totalRows_rank = mysql_num_rows($rank); if($row_hour_count['hour_count'] > $row_rank['hours']) { $rank1 = $row_rank['title']; print $rank1; } else{ print "Row Hour count is not greater than row_rank(Hours)"; //this will tell you if you're not meeting the requirements. } ?>
  17. Try this: <?php print_r($rank); ?>
×
×
  • 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.