summaryrefslogtreecommitdiff
path: root/plugins/smf2/smf2.module
blob: 1f91bf0ebe413489d2a9a7c3150ae4e1a2e306c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php

function smf2_bootstrap($config) {
  $smf_root_path = $config['root_path'];
  if (file_exists($smf_root_path . 'SSI.php')) {
    include_once $smf_root_path . 'SSI.php';
  }
  else {
    file_put_contents('php://stderr', "SMF not found at <{$smf_root_path}>.\n");
    exit;
  }
}

function smf2_init($config) {
  smf2_bootstrap($config);
  require_once __DIR__ . '/BridgeSMF2.php';
  return new BridgeSMF2();
}

function smf2_session($config) {
  smf2_bootstrap($config);
  $user = smf_ssi('welcome', NULL);
  return (empty($user['is_guest']) && !empty($user['name'])) ? $user['name'] : FALSE;
}

function smf_ssi($function) {
  $args = func_get_args();
  array_shift($args);

  ob_start();
  $result = call_user_func_array("ssi_$function", $args);
  file_put_contents('php://stderr', ob_get_clean());
  return $result;
}