| 1 | <?php |
|---|
| 2 | |
|---|
| 3 | // link some infoarena API |
|---|
| 4 | // |
|---|
| 5 | // WARNING: |
|---|
| 6 | // This is really dirty practice! We can't do anything but hope there are |
|---|
| 7 | // no serious name clashes between infoarena and SMF. |
|---|
| 8 | // Somebody, please code some namespaces in PHP! |
|---|
| 9 | |
|---|
| 10 | define("IA_FROM_SMF", true); |
|---|
| 11 | |
|---|
| 12 | require_once(IA_ROOT_DIR . 'common/common.php'); |
|---|
| 13 | require_once(IA_ROOT_DIR . 'common/external_libs/recaptchalib.php'); |
|---|
| 14 | require_once(IA_ROOT_DIR . 'common/log.php'); |
|---|
| 15 | check_requirements(); |
|---|
| 16 | require_once(IA_ROOT_DIR . 'common/security.php'); |
|---|
| 17 | require_once(IA_ROOT_DIR . 'www/utilities.php'); |
|---|
| 18 | require_once(IA_ROOT_DIR . 'www/identity.php'); |
|---|
| 19 | |
|---|
| 20 | // init SMF hooks to integrate with infoarena |
|---|
| 21 | // These are native integration features built into SMF. Sweet! |
|---|
| 22 | $ia_integration = array( |
|---|
| 23 | 'integrate_verify_user' => 'ia_verify_user', |
|---|
| 24 | 'securityDisable' => true, |
|---|
| 25 | 'databaseSession_enable' => false, |
|---|
| 26 | 'theme_default' => 1, |
|---|
| 27 | ); |
|---|
| 28 | |
|---|
| 29 | define("SMF_INTEGRATION_SETTINGS", serialize($ia_integration)); |
|---|
| 30 | |
|---|
| 31 | // Determine which SMF user is logged based on infoarena |
|---|
| 32 | // identity information. |
|---|
| 33 | // This is an integration hook. |
|---|
| 34 | function ia_verify_user() { |
|---|
| 35 | global $identity_user; |
|---|
| 36 | global $db_prefix; |
|---|
| 37 | |
|---|
| 38 | if (!$identity_user) { |
|---|
| 39 | // When infoarena session is no longer active, |
|---|
| 40 | // destroy any SMF session still hanging active |
|---|
| 41 | global $cookiename; |
|---|
| 42 | unset($_COOKIE[$cookiename]); |
|---|
| 43 | unset($_SESSION['login_'.$cookiename]); |
|---|
| 44 | |
|---|
| 45 | return false; |
|---|
| 46 | } |
|---|
| 47 | |
|---|
| 48 | // relate ia_user with SMF member |
|---|
| 49 | $result = db_query(" |
|---|
| 50 | SELECT ID_MEMBER |
|---|
| 51 | FROM {$db_prefix}members |
|---|
| 52 | WHERE memberName = '" . addslashes($identity_user['username']) . "' |
|---|
| 53 | LIMIT 1", __FILE__, __LINE__); |
|---|
| 54 | $member_id = null; |
|---|
| 55 | list($member_id) = mysql_fetch_row($result); |
|---|
| 56 | mysql_free_result($result); |
|---|
| 57 | |
|---|
| 58 | if ($member_id) { |
|---|
| 59 | return $member_id; |
|---|
| 60 | } |
|---|
| 61 | else { |
|---|
| 62 | global $webmaster_email; |
|---|
| 63 | fatal_error("Utilizatorul {$identity_user['username']} nu are " |
|---|
| 64 | ."echivalent in SMF! Va rugam sa contactati " |
|---|
| 65 | ."administratorul la adresa " |
|---|
| 66 | .$webmaster_email); |
|---|
| 67 | } |
|---|
| 68 | } |
|---|
| 69 | |
|---|
| 70 | // Call this function whenever you want to make sure a feature is disabled |
|---|
| 71 | // because of integration with infoarena. |
|---|
| 72 | function ia_disabled() { |
|---|
| 73 | // Feature disabled for integration with infoarena |
|---|
| 74 | log_print('This feature was disabled for integration with infoarena.'); |
|---|
| 75 | log_backtrace(); |
|---|
| 76 | die(); |
|---|
| 77 | } |
|---|
| 78 | |
|---|
| 79 | ?> |
|---|