Jump to content

DJMurtz

Members
  • Posts

    10
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

DJMurtz's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. [!--quoteo(post=367029:date=Apr 21 2006, 12:49 AM:name=AndyB)--][div class=\'quotetop\']QUOTE(AndyB @ Apr 21 2006, 12:49 AM) [snapback]367029[/snapback][/div][div class=\'quotemain\'][!--quotec--] The simple solution is to set the 'to' address to your own address and put ALL recipients in the BCC group. [/quote] That would still mean that all users see my email in the To address but I want it to show only their own address?
  2. I've been trying to get the mail function working with the Cc and Bcc headers. Basicly what I want is an admin to be able to send out an email to all users in the database. However, I do not want all those email addresses to be shown in the To list like this: email1@test.com, email2@test.com, email3@test.com, etc I wanted only to show the email of the user in the To list. Now I can accomlish this by doing a while loop with a new email address in each mail send. However, I was under the impression that the Bcc header exsisted to solve this problem. I figured, that if I put the first email address it gets from the database in the standard place of the mail() funcion, and put the rest of the email addresses in the Bcc header it would all work out, like this: [code]        while($aSendToAddresses = mysql_fetch_array($qSendToAddresses)) {             $sSendToAddresses .= ', ' . $aSendToAddresses['email'];         }         $sSendToAddresses = substr($sSendToAddresses, 2);         $sSendToFirstAddress = explode(', ', $sSendToAddresses);         $sSendToAddresses = str_replace($sSendToFirstAddress[0], '', $sSendToAddresses );         $sSendToAddresses = substr($sSendToAddresses, 2);         $sSendToAddresses = 'Bcc: ' . $sSendToAddresses . "\r\n";                  mail($sSendToFirstAddress[0], $_POST['mailtitle'], $_POST['mailmessage'], $sSendToAddresses);[/code] However, the result of this script was that indeed all the emails where send, and indeed not all the users where listed in the 'to' list. But the problem was that each email address had the email of the first receipe (defined in $sSendToFirstAddress) in the 'To:' line... Can anyone help me out to fix this? or is the only solution a while loop of the mail function
  3. [!--quoteo(post=366121:date=Apr 18 2006, 08:58 PM:name=Barand)--][div class=\'quotetop\']QUOTE(Barand @ Apr 18 2006, 08:58 PM) [snapback]366121[/snapback][/div][div class=\'quotemain\'][!--quotec--] DON'T nest Mysql functions like that. Every time you fetch a row you repeat the query! [/quote] I understand that, but I dont see how else to get the right data for each user, right now I have this: [code]     $qMembersInfo = mysql_query("SELECT NOW() AS now, plans.unixtime, plans.id, membership.*                                 FROM membership, plans " . $sWhere . $sWherePlans . "                                 ORDER BY " . $sSortDatabase . " " . $_GET['sort'] . "                                 LIMIT " . $sStart . "," . $sEnd;     // Parse selected members in the table.     while($aMembersInfo = mysql_fetch_assoc($qMembersInfo)) {         // Get plan info for member         $aPlanInfo = mysql_fetch_assoc(mysql_query("SELECT term, type FROM plans WHERE id = " . $aMembersInfo['plan']));     } [/code] I don't see another way to get the information I need from the selected user in the while loop...
  4. [!--quoteo(post=366019:date=Apr 18 2006, 04:40 PM:name=Jean M)--][div class=\'quotetop\']QUOTE(Jean M @ Apr 18 2006, 04:40 PM) [snapback]366019[/snapback][/div][div class=\'quotemain\'][!--quotec--] Thanks alot :) That works great, stupid of me not to think of the 'simple math' stuff ;) [/quote] Looking deeper into it it seems your technique is basicly the same as mine. After implementing it it gave me the same slow parse time. After commenting out other lines in the while loop I found the problem (but didn't solve it yet): [code] $aPlanInfo = mysql_fetch_assoc(mysql_query("SELECT term, type FROM plans WHERE id = " . $aMembersInfo['plan'])); [/code] I have no clue why a simple query could slow the script down by almost 1 second. I [b]am[/b] testing this localy but I never had this kind of problem before? Could it be that me running the script localy might be causing the delay? Or should I look elsewhere for the problem?
  5. Thanks alot :) That works great, stupid of me not to think of the 'simple math' stuff ;)
  6. [!--quoteo(post=365781:date=Apr 18 2006, 02:31 AM:name=poirot)--][div class=\'quotetop\']QUOTE(poirot @ Apr 18 2006, 02:31 AM) [snapback]365781[/snapback][/div][div class=\'quotemain\'][!--quotec--] I am afraid you can't, these functions are for programs being executed by the server if I am not wrong... So, you can't simply use it in Windows, for example; [/quote] I was asuming the topic starter was talking about a server he was running on his PC. Obviously PHP is serverside and can't run/detect programs clientside. If the server is running localy then you can do this, even in windows.
  7. Yes you can with php. Check: [a href=\"http://www.php.net/manual/en/function.proc-get-status.php\" target=\"_blank\"]http://www.php.net/manual/en/function.proc-get-status.php[/a]
  8. After messing around with php I got what I needed: [code] <?php         // Calculate time left till deactivation account and echo in cel.                  // Extract variables from expire date/time         $aExpireDate = explode(' ', $aMembersInfo['expiredate']);         $aExpireTime = $aExpireDate[1];         $aExpireDate = $aExpireDate[0];                  $aExpireDate = explode('-', $aExpireDate);         $aExpireTime = explode(':', $aExpireTime);         // Extract variables from current date/time         $aCurrentDate = explode(' ', $aMembersInfo['now']);         $aCurrentTime = $aCurrentDate[1];         $aCurrentDate = $aCurrentDate[0];                  $aCurrentDate = explode('-', $aCurrentDate);         $aCurrentTime = explode(':', $aCurrentTime);                  // Calculate differences between now and expire date         $iDiffYears  = $aExpireDate[0] - $aCurrentDate[0];         $iDiffMonths = $aExpireDate[1] - $aCurrentDate[1];         $iDiffDays   = $aExpireDate[2] - $aCurrentDate[2];              $iDiffHours  = $aExpireTime[0] - $aCurrentTime[0];         $iDiffMins   = $aExpireTime[1] - $aCurrentTime[1];         $iDiffSecs   = $aExpireTime[2] - $aCurrentTime[2];              // Make sure correct number of days, months and years are shown         if($iDiffDays < 0) {             $iDiffMonths--;             $iDiffDays += date("t",mktime(0,0,0,date("m")-1));         }         if($iDiffMonths < 0) {             $iDiffYears--;             $iDiffMonths += 12;         }         // We don't use months, convert them to days         while($iDiffMonths != 0) {             $iDiffMonths--;             $iDiffDays += date("t",mktime(0,0,0,date("m")));         }         // Calculate time differences         if($iDiffSecs < 0) {             $iDiffMins--;             $iDiffSecs += 60;         }         if($iDiffMins < 0) {             $iDiffHours--;             $iDiffMins += 60;         }                           if($iDiffYears != 0) {             $iTimeLeft = $iDiffYears . 'y ' . $iDiffDays . 'd';         } elseif($iDiffDays != 0 && $iDiffDays != 1) {             $iTimeLeft = $iDiffDays . 'd';         } elseif($iDiffDays == 1) {             $iTimeLeft = $iDiffDays . 'd ' . $iDiffHours . 'h';         } elseif($iDiffHours != 0) {             $iTimeLeft = $iDiffHours . 'h ' . $iDiffMins . 'm';         } elseif($iDiffMins != 0) {             $iTimeLeft = $iDiffMins . 'm ' . $iDiffSecs . 's';         } elseif($iDiffSecs != 0) {             $iTimeLeft = $iDiffSecs . 's';         }         if ($iTimeLeft{0} == '-') {             $iTimeLeft = 'Disabled';         } ?> [/code] Only problem with this method is, it's kind of a processorhog. It took php to parse 10 rows dates with the difference between them via this method [b]0.8 seconds[/b]. Maybe I can find a better way to do what I did in the above script in the future. But for now it works :)
  9. [!--quoteo(post=365736:date=Apr 18 2006, 01:08 AM:name=poirot)--][div class=\'quotetop\']QUOTE(poirot @ Apr 18 2006, 01:08 AM) [snapback]365736[/snapback][/div][div class=\'quotemain\'][!--quotec--] Well, you can use strtotime() to convert "English" dates to UNIX timestamps; then subtract them [a href=\"http://us3.php.net/manual/en/function.strtotime.php\" target=\"_blank\"]http://us3.php.net/manual/en/function.strtotime.php[/a] [/quote] Thanks for the suggestion, but you can see that I already did this in my example.. Just to make it more clear: Here I convert everything to UNIX timestamps: $iTimeLeft = strtotime($aMembersInfo['expiredate']) - time(); After that I start substracting 31536000 seconds (1 year): while($iTimeLeft >= 31536000) { $iTimeLeft -= 31536000; $iYears += 1; } After that days, hours, minutes and seconds. But as I stated above, this is inacurate, because a year isn't always 365 days and a month isnt always 30 days. I'm on to something tho, I think I figured it out, just making some final tweaks right now
  10. Hi, Right now I have two dates. One date is (for example) [b]2007-04-15 00:00:00[/b] The other date is the current date. I want to substract the current date from the '2007-04-15 00:00:00' date. I did this by converting both dates to a UNIX timestamp and then substracting them from eachother. Next thing I did was this: [code] <?php         $iTimeLeft = strtotime($aMembersInfo['expiredate']) - time();         $iYears = 0;         $iDays = 0;         $iHours = 0;         $iMinutes = 0;         $iSeconds = 0;                  while($iTimeLeft >= 31536000) {             $iTimeLeft -= 31536000;             $iYears += 1;         }         while($iTimeLeft >= 86400) {             $iTimeLeft -= 86400;             $iDays += 1;         }         while($iTimeLeft >= 3600) {             $iTimeLeft -= 3600;             $iHours += 1;         }         while($iTimeLeft >= 60) {             $iTimeLeft -= 60;             $iMinutes += 1;         }         if($iTimeLeft >= 0) {             $iSeconds = $iTimeLeft;         }         if($iYears != 0) {             $iTimeLeft = $iYears . 'y ' . $iDays . 'd';         } elseif($iDays != 0 && $iDays != 1) {             $iTimeLeft = $iDays . 'd';         } elseif($iDays == 1) {             $iTimeLeft = $iDays . 'd ' . $iHours . 'h';         } elseif($iHours != 0) {             $iTimeLeft = $iHours . 'h ' . $iMinutes . 'm';         } elseif($iMinutes != 0) {             $iTimeLeft = $iMinutes . 'm ' . $iSeconds . 's';         } elseif($iSeconds != 0) {             $iTimeLeft = $iSeconds . 's';         } else {             $iTimeLeft = 'Disabled';         } ?> [/code] As you can see I started counting how many years, months, days, hours, minutes and finally seconds fit into the UNIX timestamp I got from substracting the two dates. After this I started putting the number of years, months, etc into their own variables and parse them in the way I want on the screen. All of this works great, with one downside. It's inacurate. As you can see in my code I presume that a month has always 30 days, and a year 365 days. This isn't correct and thus the output is false. I've been trying to think of a way to get the same output, but with correct numbers but have so far found nothing that will help me do this. Does anyone of you know a solution to my problem? I thank you in advance!
×
×
  • 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.