Jump to content

monkeytooth

Members
  • Posts

    1,129
  • Joined

  • Last visited

    Never

Posts posted by monkeytooth

  1. What you really need to do is take a giant stick and shove it up your grande ass.. I mean :confused: uh.. I mean..

     

     

    $homo= "SELECT * FROM users_logins WHERE login_date BETWEEN NOW() AND DATE_SUB(login_date , INTERVAL 5 day)"; 
    $lesbians = mysql_query($homo) or die(mysql_error());
    
    $totals = array();
    while($yourMom = mysql_fetch_array($lesbians)){
          $z = 0;
          while($x=1;$x < 5;$++)
          {
    
              $compareTimes = strtotime(date('Y-m-d H:i:s') . ' +1 day');
              if(strtotime($yourMom['login_date']) <= strtotime('-".$x." day"))
              {
                 $z++;
              }
          }
      array_push($totals, $z);
    }
    
    
    foreach($totals as $counted)
    {
         echo $counted."<br>";
    }
    

     

    now will this work? I have no idea.. just kinda came up on this in a whim its a bit sloppy but it could work..

     

     

     

  2.                     // Find out if user is locked out of their account
                        if (($row['lock_date'] != "0000-00-00 00:00:00") && strtotime($lock_date) <= time()) 
                           { 
                                $output = array('errorsExist' => $errors, 'message' => $message);
                                
                            }
    					else
    					{
                                
                                // Clear the lock
                                $query = "UPDATE users_logins_attempts SET lockDate = NULL, ip_address = NULL, failed_logins = 0 WHERE users_id = '".$users_id."'";
                                $result = mysqli_query($dbc,$query);
                                
                                // Account locked error
                                $errors = true;
                                $message = "Account is unlocked. You may now try to log in again!";
                                
                                $output = array('errorsExist' => $errors, 'message' => $message);
                                
                            } 

     

    when you initially set a lock_date, set that time 10 minutes a head of the time you are setting it at.. so if its 12:00 when your setting it, store it in the DB as 12:10

  3. SELECT *
    FROM votelog
    WHERE ipaddress = '127.0.0.1'
    AND datevoted
    BETWEEN DATE_SUB( CURDATE( ) , INTERVAL 24 HOUR )
    AND CURDATE( )
    LIMIT 0 , 30

     

    That is an example of the query I am attempting to run to find posts within the past 24 hours. I am also running a separate one for different needs for in the past 60 minutes. Issue is there is at least 4 rows in the table I am testing with 3 of which fall under the 24 hour clause.

     

    this is what the timestamp in the DB looks like, standard DATETIME.. 2011-09-01 13:20:08

     

    with that being said I am yielding no results, well as far as

    mysql_num_rows($result)

    seems to be concerned..

  4. no where in your query are you setting a session value if one isn't set. so, if the session doesn't exist it wont echo anything out. its worth mentioning also that you may wanna reconsider echoing out a straight session/cookie/post/get value also. Its always worth making sure the values are what are expected first otherwise you are opening your site up to serious security risks from exploits.

  5. well if they are saved in the db one way.. and displayed another then you need something conditional to revert the output to match what they once saw..

     

    so lets say something simplistic.. your storing numeric id's from what i gather from your post. so when you pull them out of the DB your only getting the number you stored, there is no automated logic that will convert it from what you put in vs what the end user saw.. soo you have to build the logic.. the simple concept is

     

     

    cow always equals 1 in the db

    chicken always equals 2 in the db

    cat always equals 3 in the db.... etc..

     

    $outputValue1 = $newnode->setAttribute("detectorid",$row['detectorid']);
    
    if($outputValue1 == 1){echo 'cow';}
    elseif($outputValue1 == 2){echo 'chicken';}
    elseif($outputValue1 == 3){echo 'cat';}
    else{echo 'scratch-n-sniff, something broke';}

  6. What would be the best way to compare files and or directories. Lets say I want to store files on a sever or collective of servers like a cloud based system. My users are in collaboration with one another in many cases and some not. Either way I can have upwards of a hundred people or more with the same exact file. Only key difference is they likey renamed the file or whatever. But essentially same exact data all around. Now other thing is there is no specific file type. There's pdf, doc, docx, txt, videos, audio files, etc.. but the issue boils down to the same files over and over. What i want to do is cut it down. Remove the hundreds of dupes and with the help of a database store things like the file name the user provided so I can in turn store the single file left how and where I want while still providing the info they used essentially.

     

    Now i know I can do something with md5 or sha1 or sha2 or something equivalent that will essentially give me a unique value I can use for such comparisons. But i am not exactly sure how or where to begin with that. Such as how with php can I get the sha or md5 of a file? When i look up stuff for those I get methods for strings but not files..

     

    Overall I am here looking to bounce ideas around to figuring this out not so much as a direct means.. any help would be great.

  7. Ok. I am working on a project where I guess the closest proximity to describe it would be something like

     

    http://pastebin.com/

     

    I am building the project with PHP and mySQL as the backend. But I know the combination of the two can be deadly if not handled carefully with what I want to do. I already know I can store in mySQL raw code if I so choose, but that would be stupid as the code that will be stored will be input by users and well trusting any one of them is just stupid. So with that I want to mention that this code will be used in a number of ways. From simply outputting it for display on a page to actually saving it as a file for use automatically. I will be storing all sorts of code from C# to PHP to JavaScript and everything in-between.

     

    So I guess my ultimate question here today would be whats the best and safest way I can convert code to be stored in the DB without really effecting my ability to use it for display, demo (in some cases), or writing it to a file for someone to save.

     

    Would base64_encode/decode be a good logic to work on? or should I do something like htmlentities/specialchars or I dunno. I guess I am ultimately seeking opinions on the best way to tackle it.

  8. Lets say I have a string

     

    var myString = "I was sitting at the green light thinking about the Green Hornet and thought about the greenish tints he had on the windows";

     

    I need to split the string so its broken down by spaces like a CSV but just the space.. Then I need to find every instance of "green" but case sensitive, any ideas? I thought I had an idea but I just ended up doing something entirely wrong... What I need my output to look like is

     

    20, 45, 50.. (thats not exact but just for the sake of sample). What i need to know is the indexOf() splitting it into an array is for something else. which the spliting I have an understanding of.. Its the indexOf for multiple instances thats got me confused.

  9. Fatal error: Class 'SoapClient' not found is my error.. I can't say I have ever seen this error before so I am a bit confused.

     

    I am on a local machine server is setup and running properly in my php.ini "extension=php_soap.dll" is not commented out, so I'm a bit lost can anyone help point me in the right direction?

  10. If your just trying to find matches. You can use array_diff()

    http://php.net/manual/en/function.array-diff.php

     

    You take 2 arrays (or more I think if you want)

     

    $array1 = array(1,2,3,4,5,6,7,8,9,a,b,c);
    $array2 = array(z,y,x,9,8,7,6,5,4,3,2,1);
    $difference = array_diff($array1, $array2);
    
    sort($difference);
    
    echo "<pre>";
    print_r($difference);
    echo "</pre>";
    

     

    and what $difference should output is..

     

    Array(
      [] = a,
      [] = b,
      [] = c,
      [] = x,
      [] = y,
      [] = z,
    ) 

     

    which you could then know by this array that those aren't matches between the 2. You can definitively expand on this a lot more to then turn around and rebuild a final array where its either just the matches, or the difference + the matches but removing the duplicates.. but this here is like the stepping stone Idea from what I am understanding your trying to do.

  11. Gritso I have seen that one.. It is actually a nice package. I gotta say for me it was a pain in the $*($ to use but that  may be Due to me being  in a rush to push something out when I did. Generally speaking I wouldn't advice someone at a novice level to tackle that package though. I could be wrong though might be easier to use then I remember.

  12. I'm going to say thats not highly likely (I could be wrong) But generally speaking PHP is a server side language. It renders once and its done. I know there's ways you can crawl your DOM elements and find a particular elements attributes and values there of. But I don't know how effect that is, I've never done that myself without using JavaScript at some level of the process.

     

    But you are also talking 2 individual frames. Usually what loads in one, isn't read through the other. They are independent of one another in a matter of speaking. Though again if you control both pages framed and otherwise you can pass information from one to the other with JavaScript then process any information via AJAX methods.

  13. I am not familiar with what ever code it is you have there. At a quick glance it looks like a jarbled mess. I'd personally suggest my bit of code and see how that may help ya.

     

    I did a quick check on X-Mailer however. Which your code looks like it may derive from. Found this interesting article (though didnt read through it all). This could be in part why your mail is sending so slow.

     

    http://www.mailingcheck.com/faking-x-mailer-email-field-never-rewards/

     

    Also might I suggest not sending an email per page load to someone. Thats likely to piss off your hosting provider real quick, may also invoke hourly limits your provider has to trigger stopping mail from sending as well. Example I host most of my sites on Host Gator. They will only let me send 500 emails per hour collectively from site or email account. And chances are you have limits like that unless your on a really good VPS or Dedicated box.

     

    That said if you want to log what page is being landed on and when, maybe using a database is in your best interest. Where you can then run a script daily to give you a digest of the days, weeks, months activities.

  14. On another note. What are you sending out as a message. You could be causing flags to be thrown up that are hindering it's send process. Maybe an incorrect header? To many links? something else?

     

    <?php 
    function myDomainName()
    {
    	$mydomain = $_SERVER['HTTP_HOST'];
    	$mydomain = str_replace('www.', '', $mydomain);
    	return $mydomain;
    }
    
    function mailSomeone($toWho, $fromWho, $sysSubj, $sysMsg)
    {
    	$msgTemplate = '
    	<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    	<html>
    	<head>
    	<title>'.$sysSubj.'</title>
    	</head>
    	<style type="text/css">
    		body{background: #EDEBEA;}
    		#wrapper{background:#FFF;border:4px solid #DDD;width:650px;}
    	</style>
    	</head>
    	<body>
    	<div id="wrapper">'.$sysMsg.'</div>
    	</body>
    	</html>
    	';
    	$headers  = 'MIME-Version: 1.0' . "\r\n";
    	$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    	$headers .= 'Content-type: text/html; charset=us-ascii' . "\r\n";
    	$headers .= 'From:' .$fromWho. "\r\n";
    	$headers .= 'Reply-To: ' .$fromWho. "\r\n";
    	$headers .= '1\r\nX-MSMail-Priority: High' . "\r\n";
    	$headers .= 'X-Mailer: MonkeyTooth Productions Mail Controller v2.0' . "\r\n";
    	mail($toWho, $sysSubj, $sysMsg, $headers);
    }
    
    //example
    $sysSubj = '[Chris Hacia] Demo Email';
    $sysMsg = '<img src="http://chrishacia.com/static/img/logo.png" border="0" alt="Christopher Hacia" /><br /><br />There is really nothing special about this email other than to demonstrate the HTML side of php\'s mail() function';
    
    mailSomeone($_POST['theEmail'], 'no-reply@'.myDomainName(), $sysSubj, $sysMsg);
    ?>

     

    Above is a nifty litte function I use time and time again that I made myself some time ago for sending email that can output as HTML and not just plaintext like the mail() function will do stand alone.

     

    give it a whirl see it in action: http://chrishacia.com/demo/php-mail-html.php

  15. Ahh.. well..

     

    if(!is_numeric($adsData['phone']) || strlen($adsData['phone']) < 12) {
    $error['phone'] = 'Insert a valid phone number!';
    }
    

     

    when it hits that point in the code is still checking to see if the field is whats desired. In your case numeric and a length no less than 12 char. And an empty field in this case is not one that matches numeric constraints... so

     

    i'd say wrap that in one more if statement.

     

    if((isset($adsData['phone']))AND(!empty($adsData['phone']))AND(trim($adsData['phone']) !== "")){
    if((!is_numeric($adsData['phone'])) || strlen($adsData['phone']) < 12)) {
    $error['phone'] = 'Insert a valid phone number!';
    }
    }
    

     

    This way if the field is set, and not empty it will check your constraints.. otherwise it will just pass on by.

     

     

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