- Timestamp:
- Sep 17, 2009, 9:41:40 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/NBC_UserAdvManager/trunk/include/functions_UserAdvManager.inc.php
r3845 r3858 3 3 load_language('plugin.lang', NBC_UserAdvManager_PATH); 4 4 5 /* Function called from main.inc.php to send validation email */ 5 6 function SendMail2User($typemail, $id, $username, $password, $email, $confirm) 6 7 { … … 72 73 /* debugging */ 73 74 /* ********************** */ 74 MailLog($email,$subject);75 // MailLog($email,$subject); 75 76 /* ********************** */ 76 77 } 77 } 78 78 79 79 80 /* Email sending debugger function */ 80 function MailLog ($to, $subject)81 {82 $fo=fopen (NBC_UserAdvManager_PATH.'admin/maillog.txt','a') ;83 fwrite($fo,"======================\n") ;84 fwrite($fo,'le ' . date('D, d M Y H:i:s') . "\r\n");85 fwrite($fo,$to . "\n" . $subject . "\r\n") ;86 fclose($fo) ;81 //function MailLog ($to, $subject) 82 //{ 83 // $fo=fopen (NBC_UserAdvManager_PATH.'admin/maillog.txt','a') ; 84 // fwrite($fo,"======================\n") ; 85 // fwrite($fo,'le ' . date('D, d M Y H:i:s') . "\r\n"); 86 // fwrite($fo,$to . "\n" . $subject . "\r\n") ; 87 // fclose($fo) ; 87 88 //return mail ($to,$subject) ; 88 } 89 90 89 //} 90 91 92 /* Function called from UserAdvManager_admin.php to resend validation email with or without new validation key */ 91 93 function ResendMail2User($typemail, $user_id, $username, $email, $confirm) 92 94 { … … 137 139 /* debugging */ 138 140 /* ********************** */ 139 MailLog($email,$subject);141 // MailLog($email,$subject); 140 142 /* ********************** */ 141 142 } 143 144 143 } 144 145 146 /* Function called from functions AddConfirmMail and ResetConfirmMail for validation key generation */ 145 147 function FindAvailableConfirmMailID() 146 148 { … … 161 163 162 164 163 165 /* Function called from functions SendMail2User to process unvalidated users and generate validation key link */ 164 166 function AddConfirmMail($user_id, $email) 165 167 { … … 170 172 list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();')); 171 173 172 if ( isset($Confirm_Mail_ID))174 if (isset($Confirm_Mail_ID)) 173 175 { 174 176 $query = " … … 192 194 AND ( 193 195 group_id = '".$conf_nbc_UserAdvManager[3]."' 194 196 OR 195 197 group_id = '".$conf_nbc_UserAdvManager[4]."' 196 198 ) … … 198 200 pwg_query($query); 199 201 200 if ( !is_admin() and $conf_nbc_UserAdvManager[9] <> -1)202 if (!is_admin() and $conf_nbc_UserAdvManager[9] <> -1) 201 203 { 202 204 $query = " … … 224 226 225 227 228 /* Function called from UserAdvManager_admin.php to reset validation key */ 226 229 function ResetConfirmMail($user_id) 227 230 { … … 232 235 list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();')); 233 236 234 if ( isset($Confirm_Mail_ID))237 if (isset($Confirm_Mail_ID)) 235 238 { 236 239 $query = " … … 253 256 254 257 258 /* Function called from main.inc.php - Triggered on user deletion */ 255 259 function DeleteConfirmMail($user_id) 256 260 { … … 263 267 264 268 265 269 /* Function called from ConfirmMail.php to verify validation key used by user according time limit */ 266 270 function VerifyConfirmMail($id) 267 271 { … … 302 306 if (!empty($registration_date)) 303 307 { 304 // Verify Confirmmail with time limit ON305 if (isset ($conf_nbc_UserAdvManager_ConfirmMail[1]))306 {307 // dates formating and compare308 $today = date("d-m-Y"); // Get today's date309 list($day, $month, $year) = explode('-', $today); // explode date of today310 308 // Verify Confirmmail with time limit ON 309 if (isset ($conf_nbc_UserAdvManager_ConfirmMail[1])) 310 { 311 // dates formating and compare 312 $today = date("d-m-Y"); // Get today's date 313 list($day, $month, $year) = explode('-', $today); // explode date of today 314 $daytimestamp = mktime(0, 0, 0, $month, $day, $year);// Generate UNIX timestamp 311 315 312 list($regdate, $regtime) = explode(' ', $registration_date); // Explode date and time from registration date313 list($regyear, $regmonth, $regday) = explode('-', $regdate); // Explode date from registration date314 $regtimestamp = mktime(0, 0, 0, $regmonth, $regday, $regyear);// Generate UNIX timestamp316 list($regdate, $regtime) = explode(' ', $registration_date); // Explode date and time from registration date 317 list($regyear, $regmonth, $regday) = explode('-', $regdate); // Explode date from registration date 318 $regtimestamp = mktime(0, 0, 0, $regmonth, $regday, $regyear);// Generate UNIX timestamp 315 319 316 $deltasecs = $daytimestamp - $regtimestamp;// Compare the 2 UNIX timestamps 317 $deltadays = floor($deltasecs / 86400);// Convert result from seconds to days 318 319 // Condition with the value set for time limit 320 if ($deltadays <= $conf_nbc_UserAdvManager_ConfirmMail[1]) // If Nb of days is less than the set limit 321 { 322 list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();')); 323 324 $query = ' 325 UPDATE '.USER_CONFIRM_MAIL_TABLE.' 326 SET date_check="'.$dbnow.'" 327 WHERE id = "'.$id.'" 320 $deltasecs = $daytimestamp - $regtimestamp;// Compare the 2 UNIX timestamps 321 $deltadays = floor($deltasecs / 86400);// Convert result from seconds to days 322 323 // Condition with the value set for time limit 324 if ($deltadays <= $conf_nbc_UserAdvManager_ConfirmMail[1]) // If Nb of days is less than the limit set 325 { 326 list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();')); 327 328 $query = ' 329 UPDATE '.USER_CONFIRM_MAIL_TABLE.' 330 SET date_check="'.$dbnow.'" 331 WHERE id = "'.$id.'" 332 ;'; 333 pwg_query($query); 334 335 if ($conf_nbc_UserAdvManager[3] <> -1) 336 { 337 $query = " 338 DELETE FROM ".USER_GROUP_TABLE." 339 WHERE user_id = '".$data['user_id']."' 340 AND group_id = '".$conf_nbc_UserAdvManager[3]."' 341 ;"; 342 pwg_query($query); 343 } 344 345 if ($conf_nbc_UserAdvManager[4] <> -1) // Change user's group 346 { 347 $query = " 348 DELETE FROM ".USER_GROUP_TABLE." 349 WHERE user_id = '".$data['user_id']."' 350 AND group_id = '".$conf_nbc_UserAdvManager[4]."' 351 ;"; 352 pwg_query($query); 353 354 $query = " 355 INSERT INTO ".USER_GROUP_TABLE." 356 (user_id, group_id) 357 VALUES 358 ('".$data['user_id']."', '".$conf_nbc_UserAdvManager[4]."') 359 ;"; 360 pwg_query($query); 361 } 362 363 if (($conf_nbc_UserAdvManager[5] <> -1 or isset($data['status']))) // Change user's status 364 { 365 $query = " 366 UPDATE ".USER_INFOS_TABLE." 367 SET status = '".(isset($data['status']) ? $data['status'] : $conf_nbc_UserAdvManager[5])."' 368 WHERE user_id = '".$data['user_id']."' 369 ;"; 370 pwg_query($query); 371 } 372 // Refresh user's category cache 373 invalidate_user_cache(); 374 375 return true; 376 } 377 elseif ($deltadays > $conf_nbc_UserAdvManager_ConfirmMail[1]) // If timelimit exeeds 378 { 379 return false; 380 } 381 } 382 // Verify Confirmmail with time limit OFF 383 else 384 { 385 list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();')); 386 387 $query = ' 388 UPDATE '.USER_CONFIRM_MAIL_TABLE.' 389 SET date_check="'.$dbnow.'" 390 WHERE id = "'.$id.'" 328 391 ;'; 329 pwg_query($query);330 331 if ( $conf_nbc_UserAdvManager[3] <> -1)332 {333 $query = "334 DELETE FROM ".USER_GROUP_TABLE."335 WHERE user_id = '".$data['user_id']."'336 AND group_id = '".$conf_nbc_UserAdvManager[3]."'392 pwg_query($query); 393 394 if ($conf_nbc_UserAdvManager[3] <> -1) 395 { 396 $query = " 397 DELETE FROM ".USER_GROUP_TABLE." 398 WHERE user_id = '".$data['user_id']."' 399 AND group_id = '".$conf_nbc_UserAdvManager[3]."' 337 400 ;"; 338 pwg_query($query); 401 pwg_query($query); 402 } 403 404 if ($conf_nbc_UserAdvManager[4] <> -1) 405 { 406 $query = " 407 DELETE FROM ".USER_GROUP_TABLE." 408 WHERE user_id = '".$data['user_id']."' 409 AND group_id = '".$conf_nbc_UserAdvManager[4]."' 410 ;"; 411 pwg_query($query); 412 413 $query = " 414 INSERT INTO ".USER_GROUP_TABLE." 415 (user_id, group_id) 416 VALUES 417 ('".$data['user_id']."', '".$conf_nbc_UserAdvManager[4]."') 418 ;"; 419 pwg_query($query); 420 } 421 422 if (($conf_nbc_UserAdvManager[5] <> -1 or isset($data['status']))) 423 { 424 $query = " 425 UPDATE ".USER_INFOS_TABLE." 426 SET status = '".(isset($data['status']) ? $data['status'] : $conf_nbc_UserAdvManager[5])."' 427 WHERE user_id = '".$data['user_id']."' 428 ;"; 429 pwg_query($query); 430 } 431 // Refresh user's category cache 432 invalidate_user_cache(); 433 434 return true; 339 435 } 340 341 if ( $conf_nbc_UserAdvManager[4] <> -1 ) // Change user's group342 {343 $query = "344 DELETE FROM ".USER_GROUP_TABLE."345 WHERE user_id = '".$data['user_id']."'346 AND group_id = '".$conf_nbc_UserAdvManager[4]."'347 ;";348 pwg_query($query);349 350 $query = "351 INSERT INTO ".USER_GROUP_TABLE."352 (user_id, group_id)353 VALUES354 ('".$data['user_id']."', '".$conf_nbc_UserAdvManager[4]."')355 ;";356 pwg_query($query);357 }358 359 if (($conf_nbc_UserAdvManager[5] <> -1 or isset($data['status']))) // Change user's status360 {361 $query = "362 UPDATE ".USER_INFOS_TABLE."363 SET status = '".(isset($data['status']) ? $data['status'] : $conf_nbc_UserAdvManager[5])."'364 WHERE user_id = '".$data['user_id']."'365 ;";366 pwg_query($query);367 }368 // Refresh user's category cache369 invalidate_user_cache();370 371 return true;372 }373 elseif ($deltadays > $conf_nbc_UserAdvManager_ConfirmMail[1]) // If timelimit exeeds374 {375 return false;376 436 } 377 437 } 378 // Verify Confirmmail with time limit OFF 379 else 380 { 438 } 439 else 440 return false; 441 } 442 443 /* Function called from UserAdvManager_admin.php to force users validation by admin */ 444 function ForceValidation($id) 445 { 446 global $conf; 447 448 include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); 449 450 $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array(); 451 452 $query = " 453 SELECT COUNT(*) 454 FROM ".USER_CONFIRM_MAIL_TABLE." 455 WHERE user_id = '".$id."' 456 ;"; 457 list($count) = mysql_fetch_row(pwg_query($query)); 458 459 if ($count == 1) 460 { 461 $query = " 462 SELECT user_id, status, date_check 463 FROM ".USER_CONFIRM_MAIL_TABLE." 464 WHERE user_id = '".$id."' 465 ;"; 466 $data = mysql_fetch_array(pwg_query($query)); 467 468 if (!empty($data) and isset($data['user_id']) and !isset($data['date_check'])) 469 { 381 470 list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();')); 382 471 383 $query = '384 UPDATE '.USER_CONFIRM_MAIL_TABLE.'385 SET date_check= "'.$dbnow.'"386 WHERE id = "'.$id.'"387 ;';472 $query = " 473 UPDATE ".USER_CONFIRM_MAIL_TABLE." 474 SET date_check='".$dbnow."' 475 WHERE user_id = '".$data['user_id']."' 476 ;"; 388 477 pwg_query($query); 389 390 if ( $conf_nbc_UserAdvManager[3] <> -1)478 479 if ($conf_nbc_UserAdvManager[3] <> -1) 391 480 { 392 481 $query = " … … 394 483 WHERE user_id = '".$data['user_id']."' 395 484 AND group_id = '".$conf_nbc_UserAdvManager[3]."' 396 485 ;"; 397 486 pwg_query($query); 398 487 } 399 400 if ( $conf_nbc_UserAdvManager[4] <> -1)488 489 if ($conf_nbc_UserAdvManager[4] <> -1) 401 490 { 402 491 $query = " … … 404 493 WHERE user_id = '".$data['user_id']."' 405 494 AND group_id = '".$conf_nbc_UserAdvManager[4]."' 406 495 ;"; 407 496 pwg_query($query); 408 497 409 498 $query = " 410 499 INSERT INTO ".USER_GROUP_TABLE." … … 412 501 VALUES 413 502 ('".$data['user_id']."', '".$conf_nbc_UserAdvManager[4]."') 414 503 ;"; 415 504 pwg_query($query); 416 505 } 417 506 418 if ( ( $conf_nbc_UserAdvManager[5] <> -1 or isset($data['status']) ))507 if (($conf_nbc_UserAdvManager[5] <> -1 or isset($data['status']))) 419 508 { 420 509 $query = " … … 422 511 SET status = '".(isset($data['status']) ? $data['status'] : $conf_nbc_UserAdvManager[5])."' 423 512 WHERE user_id = '".$data['user_id']."' 424 513 ;"; 425 514 pwg_query($query); 426 515 } 427 // Refresh user's category cache516 // Refresh user's category cache 428 517 invalidate_user_cache(); 429 430 518 return true; 431 519 } 432 } 433 } 434 } 435 else 436 return false; 437 } 438 439 520 } 521 } 522 523 /* Function called from main.inc.php - Get username case insensitive */ 440 524 function NotSensibleSearchUsername($username) 441 525 { 442 526 global $conf; 443 527 444 if ( isset($username))528 if (isset($username)) 445 529 { 446 530 $query = " … … 456 540 457 541 542 /* Obsolete function - Check for single email in database */ 458 543 function SearchMail($email) 459 544 { 460 545 global $conf, $lang; 461 546 462 if ( isset($email))547 if (isset($email)) 463 548 { 464 549 $query = " … … 473 558 } 474 559 560 561 /* Function called from main.inc.php - Check if username matches forbidden caracters */ 475 562 function ValidateUsername($login) 476 563 { … … 479 566 $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array(); 480 567 481 if ( isset($login) and isset($conf_nbc_UserAdvManager[8]) and $conf_nbc_UserAdvManager[8] <> '')568 if (isset($login) and isset($conf_nbc_UserAdvManager[8]) and $conf_nbc_UserAdvManager[8] <> '') 482 569 { 483 570 $pattern = '/'.$conf_nbc_UserAdvManager[8].'/'; … … 494 581 495 582 583 /* Obsolete function - Check for no forbidden email provider */ 584 /* This don't work on function call */ 496 585 function ValidateEmailProvider($email) 497 586 { … … 515 604 516 605 606 /* Function called from UserAdvManager.php - Get unvalidated users according time limit */ 517 607 function get_unvalid_user_list() 518 608 { … … 520 610 521 611 /* Get ConfirmMail configuration */ 522 612 $conf_nbc_UserAdvManager_ConfirmMail = isset($conf['nbc_UserAdvManager_ConfirmMail']) ? explode(";" , $conf['nbc_UserAdvManager_ConfirmMail']) : array(); 523 613 524 614 /* Get UserAdvManager configuration */ 525 615 $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array(); 526 616 527 617 $users = array(); 528 618 529 619 /* search users depending expiration date */ 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 620 $query = ' 621 SELECT DISTINCT u.'.$conf['user_fields']['id'].' AS id, 622 u.'.$conf['user_fields']['username'].' AS username, 623 u.'.$conf['user_fields']['email'].' AS email, 624 ui.status, 625 ui.adviser, 626 ui.enabled_high, 627 ui.level, 628 ui.registration_date, 629 ug.group_id 630 FROM '.USERS_TABLE.' AS u 631 INNER JOIN '.USER_INFOS_TABLE.' AS ui 632 ON u.'.$conf['user_fields']['id'].' = ui.user_id 633 INNER JOIN '.USER_GROUP_TABLE.' AS ug 634 ON u.'.$conf['user_fields']['id'].' = ug.user_id 635 WHERE u.'.$conf['user_fields']['id'].' >= 0 636 AND ug.group_id = "'.$conf_nbc_UserAdvManager[3].'" 637 AND TO_DAYS(NOW()) - TO_DAYS(ui.registration_date) >= "'.$conf_nbc_UserAdvManager_ConfirmMail[1].'" 638 ORDER BY id ASC 639 ;'; 550 640 551 641 $result = pwg_query($query); 552 642 553 554 555 556 557 558 643 while ($row = mysql_fetch_array($result)) 644 { 645 $user = $row; 646 $user['groups'] = array(); 647 648 array_push($users, $user); 559 649 } 560 650 561 651 /* add group lists */ 562 563 564 565 652 $user_ids = array(); 653 foreach ($users as $i => $user) 654 { 655 $user_ids[$i] = $user['id']; 566 656 } 567 657 568 658 $user_nums = array_flip($user_ids); 569 659 570 571 572 573 660 if (count($user_ids) > 0) 661 { 662 $query = ' 663 SELECT user_id, group_id 574 664 FROM '.USER_GROUP_TABLE.' 575 576 665 WHERE user_id IN ('.implode(',', $user_ids).') 666 ;'; 577 667 578 668 $result = pwg_query($query); 579 669 580 581 582 583 584 585 586 670 while ($row = mysql_fetch_array($result)) 671 { 672 array_push( 673 $users[$user_nums[$row['user_id']]]['groups'], 674 $row['group_id'] 675 ); 676 } 587 677 } 588 678 589 return $users;679 return $users; 590 680 } 591 681 ?>
Note: See TracChangeset
for help on using the changeset viewer.