Example #1
0
 public function ajax_check_database()
 {
     if ($this->in->get('host') != '' && $this->in->get('user') != '' && $this->in->get('pw') != '' && $this->in->get('name') != '') {
         $error = array();
         $this->db = dbal::factory(array('dbtype' => 'mysql', 'die_gracefully' => true));
         $result = $this->db->open($this->in->get('host'), $this->in->get('name'), $this->in->get('user'), $this->in->get('pw'));
         if ($result) {
             //Schreibe die Daten in die Config
             $this->config->set('cmsbridge_host', $this->crypt->encrypt($this->in->get('host')));
             $this->config->set('cmsbridge_user', $this->crypt->encrypt($this->in->get('user')));
             $this->config->set('cmsbridge_password', $this->crypt->encrypt($this->in->get('pw', '', 'raw')));
             $this->config->set('cmsbridge_database', $this->crypt->encrypt($this->in->get('name')));
             $this->config->set('cmsbridge_notsamedb', 1);
             echo "true";
             die;
         } else {
             $this->config->del('cmsbridge_host');
             $this->config->del('cmsbridge_user');
             $this->config->del('cmsbridge_password');
             $this->config->del('cmsbridge_database');
             $this->config->del('cmsbridge_notsamedb');
         }
     }
     echo "false";
     exit;
 }
Example #2
0
 public function ajax_check_database()
 {
     header('content-type: text/html; charset=UTF-8');
     if ($this->in->get('host') != '' && $this->in->get('user') != '' && $this->in->get('pw') != '' && $this->in->get('name') != '') {
         $error = array();
         try {
             $db = dbal::factory(array('dbtype' => registry::get_const('dbtype')));
             $db->connect($this->in->get('host'), $this->in->get('name'), $this->in->get('user'), $this->in->get('pw'));
             //Schreibe die Daten in die Config
             $this->config->set('cmsbridge_host', $this->crypt->encrypt($this->in->get('host')));
             $this->config->set('cmsbridge_user', $this->crypt->encrypt($this->in->get('user')));
             $this->config->set('cmsbridge_password', $this->crypt->encrypt($this->in->get('pw', '', 'raw')));
             $this->config->set('cmsbridge_database', $this->crypt->encrypt($this->in->get('name')));
             $this->config->set('cmsbridge_notsamedb', 1);
             echo "true";
             exit;
         } catch (DBALException $e) {
             $this->config->del('cmsbridge_host');
             $this->config->del('cmsbridge_user');
             $this->config->del('cmsbridge_password');
             $this->config->del('cmsbridge_database');
             $this->config->del('cmsbridge_notsamedb');
         }
     }
     sleep(1);
     echo "false";
     exit;
 }
Example #3
0
 protected function connect2olddb()
 {
     if (!is_object($this->old[0])) {
         if ($this->step_data['old_db_data'][0] === true) {
             $this->old[0] = dbal::factory(array('dbtype' => $this->dbtype));
             $this->old[0]->open($this->step_data['old_db_data']['host'], $this->step_data['old_db_data']['name'], $this->step_data['old_db_data']['user'], $this->step_data['old_db_data']['pass']);
             $this->old[1] = $this->step_data['old_db_data']['prefix'];
             $this->old[2] = $this->step_data['old_db_data']['name'];
         } else {
             $this->old[0] = $this->new[0];
             $this->old[1] = $this->step_data['old_db_data']['prefix'];
             $this->old[2] = $this->new[2];
         }
     }
     return $this->old[0]->query("SELECT config_value FROM " . $this->old[1] . "config WHERE config_name = 'plus_version'") ? true : false;
 }
 public function __construct()
 {
     $this->code = get_class($this);
     $this->prefix = $this->config->get('cmsbridge_prefix');
     //Initialisierung der DB-Connection
     if ($this->config->get('cmsbridge_notsamedb') == '1') {
         $this->db = dbal::factory(array('dbtype' => 'mysql', 'die_gracefully' => true, 'debug_prefix' => 'bridge_', 'table_prefix' => $this->prefix));
         if (!$this->db->open($this->crypt->decrypt($this->config->get('cmsbridge_host')), $this->crypt->decrypt($this->config->get('cmsbridge_database')), $this->crypt->decrypt($this->config->get('cmsbridge_user')), $this->crypt->decrypt($this->config->get('cmsbridge_password')))) {
             $this->db = false;
         }
         //$this->deactivate_bridge();
     } else {
         $this->db = dbal::factory(array('dbtype' => $this->dbtype, 'die_gracefully' => true, 'debug_prefix' => 'bridge_', 'table_prefix' => $this->prefix));
         $this->db->open($this->dbhost, $this->dbname, $this->dbuser, $this->dbpass);
     }
 }
Example #5
0
 /**
  * Initialize the Bridge Database Connection
  */
 private function connect()
 {
     if ((int) $this->config->get('cmsbridge_notsamedb') == 1) {
         try {
             $this->bridgedb = dbal::factory(array('dbtype' => registry::get_const('dbtype'), 'debug_prefix' => 'bridge_', 'table_prefix' => $this->prefix));
             $this->bridgedb->connect($this->crypt->decrypt($this->config->get('cmsbridge_host')), $this->crypt->decrypt($this->config->get('cmsbridge_database')), $this->crypt->decrypt($this->config->get('cmsbridge_user')), $this->crypt->decrypt($this->config->get('cmsbridge_password')));
             $this->status = true;
         } catch (DBALException $e) {
             $this->bridgedb = $this->status = false;
             $this->pdl->log('bridge', 'Connection error: ' . $e->getMessage());
         }
     } else {
         try {
             $this->bridgedb = dbal::factory(array('dbtype' => registry::get_const('dbtype'), 'open' => true, 'debug_prefix' => 'bridge_', 'table_prefix' => $this->prefix));
             $this->status = true;
         } catch (DBALException $e) {
             $this->bridgedb = $this->status = false;
             $this->pdl->log('bridge', 'Connection error: ' . $e->getMessage());
         }
     }
 }
 public function get_latestposts($params, $body)
 {
     $intNumber = intval($params['get']['number']) > 0 ? intval($params['get']['number']) : 10;
     $myOut = $this->pdc->get('portal.module.latestposts.exchange.' . $intNumber . '.u' . $this->user->id, false, true);
     if (!$myOut) {
         //Try a database connection
         if ($this->config->get('cmsbridge_active') == 1 && $this->config->get('dbmode', 'pmod_' . $this->module_id) == 'bridge') {
             //Bridge Connection
             $mydb = $this->bridge->bridgedb;
             //change prefix
             if (strlen(trim($this->config->get('dbprefix', 'pmod_' . $this->module_id)))) {
                 $mydb->setPrefix(trim($this->config->get('dbprefix', 'pmod_' . $this->module_id)));
             }
         } elseif ($this->config->get('dbmode', 'pmod_' . $this->module_id) == 'new') {
             //Another Database
             try {
                 $mydb = dbal::factory(array('dbtype' => registry::get_const('dbtype'), 'debug_prefix' => 'latestposts_', 'table_prefix' => trim($this->config->get('dbprefix', 'pmod_' . $this->module_id))));
                 $mydb->connect($this->crypt->decrypt($this->config->get('dbhost', 'pmod_' . $this->module_id)), $this->crypt->decrypt($this->config->get('dbname', 'pmod_' . $this->module_id)), $this->crypt->decrypt($this->config->get('dbuser', 'pmod_' . $this->module_id)), $this->crypt->decrypt($this->config->get('dbpassword', 'pmod_' . $this->module_id)));
             } catch (DBALException $e) {
                 $mydb = false;
             }
         } else {
             //Same Database
             try {
                 $mydb = dbal::factory(array('dbtype' => registry::get_const('dbtype'), 'open' => true, 'debug_prefix' => 'latestposts_', 'table_prefix' => trim($this->config->get('dbprefix', 'pmod_' . $this->module_id))));
             } catch (DBALException $e) {
                 $mydb = false;
             }
         }
         if ($mydb) {
             $black_or_white = $this->config->get('blackwhitelist', 'pmod_' . $this->module_id) == 'white' ? 'IN' : 'NOT IN';
             // include the BB Module File...
             $bbModule = $this->root_path . 'portal/latestposts/bb_modules/' . $this->config->get('bbmodule', 'pmod_' . $this->module_id) . '.php';
             if (is_file($bbModule)) {
                 include_once $bbModule;
                 $classname = 'latestpostsmodule_' . $this->config->get('bbmodule', 'pmod_' . $this->module_id);
                 $module = new $classname();
                 if (!$module || !method_exists($module, 'getBBQuery')) {
                     return $this->pex->error('boardmodule not available');
                 }
             } else {
                 return $this->pex->error('no boardmodule selected');
             }
             // Create Array of allowed/disallowed forums
             $arrUserMemberships = $this->pdh->get('user_groups_users', 'memberships', array($this->user->id));
             array_push($arrUserMemberships, 0);
             $arrForums = array();
             $visibilityGrps = $this->config->get('visibility', 'pmod_' . $this->module_id);
             foreach ($arrUserMemberships as $groupid) {
                 //only load forums for which actual settings are set
                 if (!in_array($groupid, $visibilityGrps)) {
                     continue;
                 }
                 $strForums = $this->config->get('privateforums_' . $groupid, 'pmod_' . $this->module_id);
                 if (method_exists($module, 'getBBForumQuery')) {
                     $arrForums = array_merge($arrForums, $strForums);
                 } else {
                     //comma seperated IDs
                     $arrTmpForums = $this->config->get('privateforums', 'pmod_' . $this->module_id) ? explode(",", $this->config->get('privateforums', 'pmod_' . $this->module_id)) : '';
                     if (is_array($arrTmpForums)) {
                         foreach ($arrTmpForums as $forumid) {
                             if (trim($forumid) != '') {
                                 $arrForums[] = trim($forumid);
                             }
                         }
                     }
                 }
             }
             $arrForums = array_unique($arrForums);
             $strQuery = $module->getBBQuery($arrForums, $black_or_white, $intNumber);
             $myOut['forum_url'] = htmlentities($this->config->get('url', 'pmod_' . $this->module_id));
             $strBoardURL = $this->config->get('url', 'pmod_' . $this->module_id);
             if (substr($strBoardURL, -1) != "/") {
                 $strBoardURL .= '/';
             }
             $myOut['posts'] = array();
             $sucess = false;
             $objQuery = $mydb->query($strQuery);
             if ($objQuery && $objQuery->numRows) {
                 $sucess = true;
                 while ($row = $objQuery->fetchAssoc()) {
                     $myOut['posts'][] = array('member_link' => htmlentities($strBoardURL . $module->getBBLink('member', $row)), 'topic_link' => htmlentities($strBoardURL . $module->getBBLink('topic', $row)), 'topic_title' => $row['bb_topic_title'], 'topic_replies' => intval($row['bb_replies']), 'topic_lastpost_date' => $this->time->date('Y-m-d H:i', $row['bb_posttime']), 'topic_lastpost_timestamp' => $row['bb_posttime'], 'topic_lastpost_username' => $row['bb_username']);
                 }
             } else {
                 $myOut['posts'] = array();
             }
             if ($sucess) {
                 $this->pdc->put('portal.module.latestposts.exchange.' . $intNumber . '.u' . $this->user->id, $myOut, 300, false, true);
             }
         } else {
             return $this->pex->error('connection error');
         }
     }
     return $myOut;
 }
 public function createConnection()
 {
     $arrOptions = $this->config->get('general_data', 'cmsimport');
     $db_type = $arrOptions['db_type'];
     $db_host = $arrOptions['db_host'];
     $db_user = $arrOptions['db_user'];
     $db_password = $arrOptions['db_password'];
     $db_database = $arrOptions['db_database'];
     $db_prefix = $arrOptions['db_prefix'];
     if ((int) $db_type == 0) {
         //Same DB
         try {
             $mydb = dbal::factory(array('dbtype' => registry::get_const('dbtype'), 'open' => true, 'debug_prefix' => 'cmsimport_', 'table_prefix' => trim($db_prefix)));
         } catch (DBALException $e) {
             $mydb = false;
         }
     } elseif ((int) $db_type == 1) {
         //Other DB
         try {
             $mydb = dbal::factory(array('dbtype' => registry::get_const('dbtype'), 'debug_prefix' => 'cmsimport_', 'table_prefix' => trim($db_prefix)));
             $mydb->connect($db_host, $db_database, $db_user, $db_password);
         } catch (DBALException $e) {
             $mydb = false;
         }
     } elseif ((int) $db_type == 2) {
         //Bridge
         $mydb = $this->bridge->bridgedb;
     }
     return $mydb;
 }
 public function parse_input()
 {
     $this->dbtype = $this->in->get('dbtype');
     $this->dbhost = $this->in->get('dbhost', $this->dbhost);
     $this->dbname = $this->in->get('dbname');
     $this->dbuser = $this->in->get('dbuser');
     $this->dbpass = $this->in->get('dbpass', '', 'raw');
     // Check database name
     if ($this->dbname == "") {
         $this->pdl->log('install_error', $this->lang['dbname_error']);
         return false;
     }
     $error = array();
     include_once $this->root_path . 'libraries/dbal/dbal.class.php';
     try {
         if ($this->dbtype === 'mysql') {
             $this->dbtype == 'mysqli';
         }
         $db = dbal::factory(array('dbtype' => $this->dbtype));
         $db->connect($this->dbhost, $this->dbname, $this->dbuser, $this->dbpass);
     } catch (DBALException $e) {
         $this->pdl->log('install_error', $e->getMessage());
         return false;
     }
     $this->pdl->log('install_success', $this->lang['dbcheck_success']);
     //Before writing the config-file, we have to check the writing-permissions of the tmp-folder
     if ($this->use_ftp && !$this->pfh->testWrite()) {
         $this->pdl->log('install_error', sprintf($this->lang['ftp_tmpwriteerror'], $this->pfh->get_cachefolder(true)));
         return false;
     }
     $this->configfile_fill();
     registry::$aliases['db'] = 'dbal_' . $this->dbtype;
     include_once $this->root_path . 'libraries/dbal/' . $this->dbtype . '.dbal.class.php';
     return true;
 }
Example #9
0
 public function parse_input()
 {
     $this->dbtype = $this->in->get('dbtype');
     $this->dbhost = $this->in->get('dbhost', $this->dbhost);
     $this->dbname = $this->in->get('dbname');
     $this->dbuser = $this->in->get('dbuser');
     $this->table_prefix = $this->in->get('table_prefix', $this->table_prefix);
     $this->dbpass = $this->in->get('dbpass', '', 'raw');
     // check table_prefix
     if (!$this->table_prefix || !preg_match('/^[a-zA-Z]+$/', substr($this->table_prefix, 0, 1))) {
         $this->pdl->log('install_error', $this->lang['prefix_error']);
         return false;
     }
     $error = array();
     include_once $this->root_path . 'libraries/dbal/dbal.class.php';
     try {
         $db = dbal::factory(array('dbtype' => $this->dbtype));
         $db->connect($this->dbhost, $this->dbname, $this->dbuser, $this->dbpass);
     } catch (DBALException $e) {
         $this->pdl->log('install_error', $e->getMessage());
         return false;
     }
     //Check the Table Prefix
     if (strpos($this->table_prefix, '.') !== false || strpos($this->table_prefix, '\\') !== false || strpos($this->table_prefix, '/') !== false) {
         $this->pdl->log('install_error', $this->lang['INST_ERR_PREFIX_INVALID']);
         return false;
     }
     //Check for existing Installation
     $arrTables = $db->listTables();
     foreach ($arrTables as $tbl) {
         if (strncasecmp($tbl, $this->table_prefix, strlen($this->table_prefix)) == 0) {
             $this->pdl->log('install_error', $this->lang['INST_ERR_PREFIX']);
             return false;
         }
     }
     $this->pdl->log('install_success', $this->lang['dbcheck_success']);
     //Before writing the config-file, we have to check the writing-permissions of the tmp-folder
     if ($this->use_ftp && !$this->pfh->testWrite()) {
         $this->pdl->log('install_error', sprintf($this->lang['ftp_tmpwriteerror'], $this->pfh->get_cachefolder(true)));
         return false;
     }
     $this->configfile_fill();
     registry::$aliases['db'] = 'dbal_' . $this->dbtype;
     include_once $this->root_path . 'libraries/dbal/' . $this->dbtype . '.dbal.class.php';
     return true;
     //maybe show version?
     #$server_version	= mysql_get_server_info();
     #$client_version	= mysql_get_client_info();
 }
 public function output()
 {
     $myOut = $this->pdc->get('portal.module.latestposts.u' . $this->user->id, false, true);
     if (!$myOut) {
         // do the link-thing..
         $myTarget = $this->config('linktype') == '1' ? '_blank' : '';
         $strBoardURL = $this->config('url');
         if (substr($this->config('url'), -1) != "/") {
             $strBoardURL .= '/';
         }
         //Try a database connection
         if ($this->config->get('cmsbridge_active') == 1 && $this->config('dbmode') == 'bridge') {
             //Bridge Connection
             $mydb = $this->bridge->bridgedb;
             //change prefix
             if (strlen(trim($this->config('dbprefix')))) {
                 $mydb->setPrefix(trim($this->config('dbprefix')));
             }
         } elseif ($this->config('dbmode') == 'new') {
             //Another Database
             try {
                 $mydb = dbal::factory(array('dbtype' => registry::get_const('dbtype'), 'debug_prefix' => 'latestposts_', 'table_prefix' => trim($this->config('dbprefix'))));
                 $mydb->connect($this->encrypt->decrypt($this->config('dbhost')), $this->encrypt->decrypt($this->config('dbname')), $this->encrypt->decrypt($this->config('dbuser')), $this->encrypt->decrypt($this->config('dbpassword')));
             } catch (DBALException $e) {
                 $mydb = false;
             }
         } else {
             //Same Database
             try {
                 $mydb = dbal::factory(array('dbtype' => registry::get_const('dbtype'), 'open' => true, 'debug_prefix' => 'latestposts_', 'table_prefix' => trim($this->config('dbprefix'))));
             } catch (DBALException $e) {
                 $mydb = false;
             }
         }
         if (!$mydb) {
             return $this->user->lang('latestposts_connerror');
         }
         // Set some Variables we're using in the BB Modules..
         $topicnumber = $this->config('amount') ? $this->config('amount') : 5;
         $black_or_white = $this->config('blackwhitelist') == 'white' ? 'IN' : 'NOT IN';
         // include the BB Module File...
         $bbModule = $this->root_path . 'portal/latestposts/bb_modules/' . $this->config('bbmodule') . '.php';
         if (is_file($bbModule)) {
             include_once $bbModule;
             $classname = 'latestpostsmodule_' . $this->config('bbmodule');
             $module = new $classname();
             if (!$module || !method_exists($module, 'getBBQuery')) {
                 return $this->user->lang('portal_latestposts_invmodule');
             }
         } else {
             return $this->user->lang('portal_latestposts_nomodule');
         }
         // Create Array of allowed/disallowed forums
         $arrUserMemberships = $this->pdh->get('user_groups_users', 'memberships', array($this->user->id));
         array_push($arrUserMemberships, 0);
         $arrForums = array();
         $visibilityGrps = $this->config('visibility');
         foreach ($arrUserMemberships as $groupid) {
             //only load forums for which actual settings are set
             if (!in_array($groupid, $visibilityGrps)) {
                 continue;
             }
             $strForums = $this->config('privateforums_' . $groupid);
             if (method_exists($module, 'getBBForumQuery')) {
                 if (is_array($strForums)) {
                     $arrForums = array_merge($arrForums, $strForums);
                 }
             } else {
                 //comma seperated IDs
                 $arrTmpForums = $this->config('privateforums_' . $groupid) ? explode(",", $this->config('privateforums_' . $groupid)) : '';
                 if (is_array($arrTmpForums)) {
                     foreach ($arrTmpForums as $forumid) {
                         if (trim($forumid) != '') {
                             $arrForums[] = trim($forumid);
                         }
                     }
                 }
             }
         }
         $arrForums = array_unique($arrForums);
         //d($arrForums);
         // if there are no forums selected and its whitelist
         if (count($arrForums) == 0 && $black_or_white == 'IN') {
             return $this->user->lang('portal_latestposts_noselectedboards');
         }
         $strQuery = $module->getBBQuery($arrForums, $black_or_white, $topicnumber);
         // Wide Content
         if ($this->wide_content) {
             $objQuery = $mydb->query($strQuery);
             if ($objQuery) {
                 $sucess = true;
                 $blnForumName = false;
                 $arrResult = $objQuery->fetchAllAssoc();
                 if (count($arrResult)) {
                     foreach ($arrResult as $row) {
                         $strMemberlinkWrapper = $this->routing->build('external', $row['bb_username'] . '-' . $row['bb_user_id'], 'User');
                         $strTopiclinkWrapper = $this->routing->build('external', $row['bb_topic_title'] . '-' . $row['bb_post_id'] . '-' . $row['bb_topic_id'], 'Topic');
                         $member_link = in_array($this->config('linktype'), range(0, 1)) ? $strBoardURL . $module->getBBLink('member', $row) : $strMemberlinkWrapper;
                         $topic_link = in_array($this->config('linktype'), range(0, 1)) ? $strBoardURL . $module->getBBLink('topic', $row) : $strTopiclinkWrapper;
                         $myOut .= "<tr valign='top'>\n\t\t\t\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t\t\t\t<a href='" . htmlentities($topic_link) . "' target='" . $myTarget . "'>" . $row['bb_topic_title'] . "</a>\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t</td>";
                         if (isset($row['bb_forum_name'])) {
                             $myOut .= "<td>" . $row['bb_forum_name'] . "</td>";
                             $blnForumName = true;
                         }
                         $myOut .= "</td>\n\t\t\t\t\t\t\t\t\t\t<td align='center'>" . $row['bb_replies'] . "</td>\n\t\t\t\t\t\t\t\t\t\t<td><a href='" . htmlentities($topic_link) . "' target='" . $myTarget . "'>" . $this->time->createTimeTag($row['bb_posttime'], $this->time->user_date($row['bb_posttime'], true)) . "</a>, \n\t\t\t\t\t\t\t\t\t\t<a href='" . htmlentities($member_link) . "' target='" . $myTarget . "'>" . $row['bb_username'] . "</a> <a href='" . htmlentities($topic_link) . "' target='" . $myTarget . "'></a>\n\t\t\t\t\t\t\t\t\t\t<a href='" . htmlentities($topic_link) . "' target='" . $myTarget . "'><i class=\"fa fa-chevron-right\"></i></a>\n\t\t\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t\t\t</tr>";
                     }
                 } else {
                     $myOut .= "<tr valign='top'>\n\t\t\t\t\t\t\t\t\t<td colspan='3'>" . $this->user->lang('latestposts_noentries') . "</td>\n\t\t\t\t\t\t\t\t</tr>";
                 }
                 $myOut = "<table class='table fullwidth colorswitch'>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<th width='50%'>" . $this->user->lang('latestposts_title') . "</th>\n\t\t\t\t\t\t\t\t" . ($blnForumName ? '<th class="nowrap" width="10%">' . $this->user->lang('latestposts_forum') . '</th>' : '') . "\n\t\t\t\t\t\t\t\t<th width='10%'>" . $this->user->lang('latestposts_posts') . "</th>\n\t\t\t\t\t\t\t\t<th width='20%'>" . $this->user->lang('latestposts_lastpost') . "</th>\n\t\t\t\t\t\t\t</tr>" . $myOut;
                 $myOut .= "</table>";
             } else {
                 $myOut = "An error occured. Please check your settings.";
             }
         } else {
             // Sidebar Output
             $objQuery = $mydb->query($strQuery);
             if ($objQuery) {
                 $myOut = "<table class='table fullwidth colorswitch'>";
                 $arrResult = $objQuery->fetchAllAssoc();
                 if (count($arrResult)) {
                     $sucess = true;
                     $myTitleLength = $this->config('trimtitle') ? $this->config('trimtitle') : 40;
                     foreach ($arrResult as $row) {
                         if (strlen($row['bb_topic_title']) > $myTitleLength) {
                             $short_title = substr($row['bb_topic_title'], 0, $myTitleLength) . "...";
                         } else {
                             $short_title = $row['bb_topic_title'];
                         }
                         $strMemberlinkWrapper = $this->routing->build('external', $row['bb_username'] . '-' . $row['bb_user_id'], 'User');
                         $strTopiclinkWrapper = $this->routing->build('external', $row['bb_topic_title'] . '-' . $row['bb_post_id'] . '-' . $row['bb_topic_id'], 'Topic');
                         $member_link = in_array($this->config('linktype'), range(0, 1)) ? $strBoardURL . $module->getBBLink('member', $row) : $strMemberlinkWrapper;
                         $topic_link = in_array($this->config('linktype'), range(0, 1)) ? $strBoardURL . $module->getBBLink('topic', $row) : $strTopiclinkWrapper;
                         $myOut .= "<tr valign='top'>\n\t\t\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t\t\t<a href='" . $topic_link . "' target='" . $myTarget . "'>" . $short_title . "</a> (" . $row['bb_replies'] . ")<br/>\n\t\t\t\t\t\t\t\t\t\t" . $this->time->createTimeTag($row['bb_posttime'], $this->time->user_date($row['bb_posttime'], true)) . ", <a href='" . $member_link . "' target='" . $myTarget . "'>" . sanitize($row['bb_username']) . "</a>\n\t\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t\t</tr>";
                     }
                     $myOut .= "</table>";
                     $sucess = true;
                 } else {
                     $myOut = $this->user->lang('latestposts_noentries');
                 }
             }
         }
         //reset prefix
         if ($this->config('dbmode') == 'bridge') {
             $mydb->resetPrefix();
         }
         if (isset($sucess)) {
             $this->pdc->put('portal.module.latestposts.u' . $this->user->id, $myOut, 300, false, true);
         }
     }
     return $myOut;
 }
Example #11
0
 public function get_latestposts($params, $body)
 {
     $intNumber = intval($params['get']['number']) > 0 ? intval($params['get']['number']) : 10;
     $myOut = $this->pdc->get('portal.modul.latestposts.exchange.' . $intNumber . '.u' . $this->user->id, false, true);
     if (!$myOut) {
         // Select the Database to use.. (same, bridged mode, other)
         if ($this->config->get('cmsbridge_active') == 1 && $this->config->get('pk_latestposts_dbmode') == 'bridge') {
             $mydb = $this->bridge->db;
             //change prefix
             if (strlen(trim($this->config->get('pk_latestposts_dbprefix')))) {
                 $mydb->set_prefix(trim($this->config->get('pk_latestposts_dbprefix')));
             }
         } elseif ($this->config->get('pk_latestposts_dbmode') == 'new') {
             $mydb = dbal::factory(array('dbtype' => 'mysqli', 'die_gracefully' => true, 'debug_prefix' => 'latestposts_', 'table_prefix' => trim($this->config->get('pk_latestposts_dbprefix'))));
             $mydb->open($this->crypt->decrypt($this->config->get('pk_latestposts_dbhost')), $this->crypt->decrypt($this->config->get('pk_latestposts_dbname')), $this->crypt->decrypt($this->config->get('pk_latestposts_dbuser')), $this->crypt->decrypt($this->config->get('pk_latestposts_dbpassword')));
         } else {
             $mydb = dbal::factory(array('dbtype' => 'mysqli', 'die_gracefully' => true, 'debug_prefix' => 'latestposts_', 'table_prefix' => trim($this->config->get('pk_latestposts_dbprefix'))));
             $mydb->open($this->dbhost, $this->dbname, $this->dbuser, $this->dbpass);
         }
         $black_or_white = $this->config->get('pk_latestposts_blackwhitelist') == 'white' ? 'IN' : 'NOT IN';
         // include the BB Module File...
         $bbModule = $this->root_path . 'portal/latestposts/bb_modules/' . $this->config->get('pk_latestposts_bbmodule') . '.php';
         if (is_file($bbModule)) {
             include_once $bbModule;
             $classname = 'latestpostsmodule_' . $this->config->get('pk_latestposts_bbmodule');
             $module = new $classname();
             if (!$module || !method_exists($module, 'getBBQuery')) {
                 return $this->pex->error('boardmodule not available');
             }
         } else {
             return $this->pex->error('no boardmodule selected');
         }
         // Create Array of allowed/disallowed forums
         $arrUserMemberships = $this->pdh->get('user_groups_users', 'memberships', array($this->user->id));
         array_push($arrUserMemberships, 0);
         $arrForums = array();
         foreach ($arrUserMemberships as $groupid) {
             $strForums = $this->config->get('pk_latestposts_privateforums_' . $groupid);
             if (method_exists($module, 'getBBForumQuery')) {
                 //serialized IDs
                 $arrTmpForums = @unserialize($strForums);
                 if (is_array($arrTmpForums)) {
                     foreach ($arrTmpForums as $forumid) {
                         $arrForums[] = $forumid;
                     }
                 }
             } else {
                 //comma seperated IDs
                 $arrTmpForums = $this->config->get('pk_latestposts_privateforums') ? explode(",", $this->config->get('pk_latestposts_privateforums')) : '';
                 if (is_array($arrTmpForums)) {
                     foreach ($arrTmpForums as $forumid) {
                         if (trim($forumid) != '') {
                             $arrForums[] = trim($forumid);
                         }
                     }
                 }
             }
         }
         $strQuery = $module->getBBQuery($arrForums, $black_or_white, $intNumber);
         $myOut['forum_url'] = htmlentities($this->config->get('pk_latestposts_url'));
         $strBoardURL = $this->config->get('pk_latestposts_url');
         if (substr($this->config->get('pk_latestposts_url'), -1) != "/") {
             $strBoardURL .= '/';
         }
         $myOut['posts'] = array();
         $sucess = false;
         if ($bb_result = $mydb->query($strQuery)) {
             $sucess = true;
             while ($row = $mydb->fetch_record($bb_result)) {
                 $myOut['posts'][] = array('member_link' => htmlentities($strBoardURL . $module->getBBLink('member', $row)), 'topic_link' => htmlentities($strBoardURL . $module->getBBLink('topic', $row)), 'topic_title' => $row['bb_topic_title'], 'topic_replies' => intval($row['bb_replies']), 'topic_lastpost_date' => $this->time->date('Y-m-d H:i', $row['bb_posttime']), 'topic_lastpost_timestamp' => $row['bb_posttime'], 'topic_lastpost_username' => $row['bb_username']);
             }
         } else {
             $myOut['posts'] = array();
         }
         if ($sucess) {
             $this->pdc->put('portal.modul.latestposts.exchange.' . $intNumber . '.u' . $this->user->id, $myOut, 300, false, true);
         }
     }
     return $myOut;
 }
 public function createConnection($db_type, $db_host, $db_user, $db_password, $db_database, $db_prefix)
 {
     if ((int) $db_type == 0) {
         //Same DB
         try {
             $mydb = dbal::factory(array('dbtype' => registry::get_const('dbtype'), 'open' => true, 'debug_prefix' => 'sso_connector_', 'table_prefix' => trim($db_prefix)));
         } catch (DBALException $e) {
             $mydb = false;
         }
     } elseif ((int) $db_type == 1) {
         //Other DB
         try {
             $mydb = dbal::factory(array('dbtype' => registry::get_const('dbtype'), 'debug_prefix' => 'sso_connector_', 'table_prefix' => trim($db_prefix)));
             $mydb->connect($db_host, $db_database, $db_user, $db_password);
         } catch (DBALException $e) {
             $mydb = false;
         }
     } elseif ((int) $db_type == 2) {
         //Bridge
         $mydb = $this->bridge->bridgedb;
     }
     return $mydb;
 }
 public function output()
 {
     $myOut = $this->pdc->get('portal.modul.latestposts.u' . $this->user->id . '.' . $this->root_path, false, true);
     if (!$myOut) {
         // do the link-thing..
         $myTarget = $this->config->get('pk_latestposts_linktype') == '1' ? '_blank' : '';
         $strBoardURL = $this->config->get('pk_latestposts_url');
         if (substr($this->config->get('pk_latestposts_url'), -1) != "/") {
             $strBoardURL .= '/';
         }
         $myWrapper = in_array($this->config->get('pk_latestposts_linktype'), range(0, 1)) ? $strBoardURL : $this->root_path . 'wrapper.php' . $this->SID . '&id=lp&l=' . rawurlencode($strBoardURL);
         // Select the Database to use.. (same, bridged mode, other)
         if ($this->config->get('cmsbridge_active') == 1 && $this->config->get('pk_latestposts_dbmode') == 'bridge') {
             $mydb = $this->bridge->db;
             //change prefix
             if (strlen(trim($this->config->get('pk_latestposts_dbprefix')))) {
                 $mydb->set_prefix(trim($this->config->get('pk_latestposts_dbprefix')));
             }
         } elseif ($this->config->get('pk_latestposts_dbmode') == 'new') {
             $mydb = dbal::factory(array('dbtype' => 'mysql', 'die_gracefully' => true, 'debug_prefix' => 'latestposts_', 'table_prefix' => trim($this->config->get('pk_latestposts_dbprefix'))));
             $mydb->open($this->crypt->decrypt($this->config->get('pk_latestposts_dbhost')), $this->crypt->decrypt($this->config->get('pk_latestposts_dbname')), $this->crypt->decrypt($this->config->get('pk_latestposts_dbuser')), $this->crypt->decrypt($this->config->get('pk_latestposts_dbpassword')));
         } else {
             $mydb = dbal::factory(array('dbtype' => 'mysqli', 'die_gracefully' => true, 'debug_prefix' => 'latestposts_', 'table_prefix' => trim($this->config->get('pk_latestposts_dbprefix'))));
             $mydb->open($this->dbhost, $this->dbname, $this->dbuser, $this->dbpass);
         }
         if (!$mydb) {
             return $this->user->lang('pk_latestposts_connerror');
         }
         // Set some Variables we're using in the BB Modules..
         $topicnumber = $this->config->get('pk_latestposts_amount') ? $this->config->get('pk_latestposts_amount') : 5;
         $black_or_white = $this->config->get('pk_latestposts_blackwhitelist') == 'white' ? 'IN' : 'NOT IN';
         // include the BB Module File...
         $bbModule = $this->root_path . 'portal/latestposts/bb_modules/' . $this->config->get('pk_latestposts_bbmodule') . '.php';
         if (is_file($bbModule)) {
             include_once $bbModule;
             $classname = 'latestpostsmodule_' . $this->config->get('pk_latestposts_bbmodule');
             $module = new $classname();
             if (!$module || !method_exists($module, 'getBBQuery')) {
                 return $this->user->lang('portal_latestposts_invmodule');
             }
         } else {
             return $this->user->lang('portal_latestposts_nomodule');
         }
         // Create Array of allowed/disallowed forums
         $arrUserMemberships = $this->pdh->get('user_groups_users', 'memberships', array($this->user->id));
         array_push($arrUserMemberships, 0);
         $arrForums = array();
         $visibilityGrps = $this->pdh->get('portal', 'visibility', array($this->id));
         foreach ($arrUserMemberships as $groupid) {
             //only load forums for which actual settings are set
             if (!in_array($groupid, $visibilityGrps)) {
                 continue;
             }
             $strForums = $this->config->get('pk_latestposts_privateforums_' . $groupid);
             if (method_exists($module, 'getBBForumQuery')) {
                 //serialized IDs
                 $arrTmpForums = @unserialize($strForums);
                 if (is_array($arrTmpForums)) {
                     foreach ($arrTmpForums as $forumid) {
                         $arrForums[] = $forumid;
                     }
                 }
             } else {
                 //comma seperated IDs
                 $arrTmpForums = $this->config->get('pk_latestposts_privateforums') ? explode(",", $this->config->get('pk_latestposts_privateforums')) : '';
                 if (is_array($arrTmpForums)) {
                     foreach ($arrTmpForums as $forumid) {
                         if (trim($forumid) != '') {
                             $arrForums[] = trim($forumid);
                         }
                     }
                 }
             }
         }
         // if there are no forums selected and its whitelist
         if (count($arrForums) == 0 && $black_or_white == 'IN') {
             return $this->user->lang('portal_latestposts_noselectedboards');
         }
         $strQuery = $module->getBBQuery($arrForums, $black_or_white, $topicnumber);
         // Middle Output
         if ($this->position == 'middle' || $this->position == 'bottom') {
             $myOut = "<table cellpadding='3' cellspacing='2' width='100%' class='colorswitch'>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<th width='50%'>" . $this->user->lang('pk_latestposts_title') . "</th>\n\t\t\t\t\t\t\t\t<th width='10%'>" . $this->user->lang('pk_latestposts_posts') . "</th>\n\t\t\t\t\t\t\t\t<th width='40%' colspan='2'>" . $this->user->lang('pk_latestposts_lastpost') . "</th>\n\t\t\t\t\t\t\t</tr>";
             if ($bb_result = $mydb->query($strQuery)) {
                 $sucess = true;
                 while ($row = $mydb->fetch_record($bb_result)) {
                     $member_link = in_array($this->config->get('pk_latestposts_linktype'), range(0, 1)) ? $myWrapper . $module->getBBLink('member', $row) : $myWrapper . rawurlencode($module->getBBLink('member', $row));
                     $topic_link = in_array($this->config->get('pk_latestposts_linktype'), range(0, 1)) ? $myWrapper . $module->getBBLink('topic', $row) : $myWrapper . rawurlencode($module->getBBLink('topic', $row));
                     $myOut .= "<tr valign='top'>\n\t\t\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t\t\t\t<a href='" . htmlentities($topic_link) . "' target='" . $myTarget . "'>" . $row['bb_topic_title'] . "</a>\n\t\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t\t\t<td align='center'>" . $row['bb_replies'] . "</td>\n\t\t\t\t\t\t\t\t\t<td>" . $this->time->user_date($row['bb_posttime'], true) . "</td>\n\t\t\t\t\t\t\t\t\t<td><a href='" . htmlentities($member_link) . "' target='" . $myTarget . "'>" . $row['bb_username'] . "</a> <a href='" . htmlentities($topic_link) . "' target='" . $myTarget . "'><img src='" . $this->root_path . "portal/latestposts/images/icon_topic_latest.png' alt='' /></a></td>\n\t\t\t\t\t\t\t\t</tr>";
                 }
             } else {
                 $myOut .= "<tr valign='top'>\n\t\t\t\t\t\t\t\t\t<td colspan='3'>" . $this->user->lang('pk_latestposts_noentries') . "</td>\n\t\t\t\t\t\t\t\t</tr>";
             }
             $myOut .= "</table>";
         } else {
             // Sidebar Output
             $myOut = "<table cellpadding='3' cellspacing='2' width='100%' class='colorswitch'>";
             if ($bb_result = $mydb->query($strQuery)) {
                 $sucess = true;
                 $myTitleLength = $this->config->get('pk_latestposts_trimtitle') ? $this->config->get('pk_latestposts_trimtitle') : 40;
                 while ($row = $mydb->fetch_record($bb_result)) {
                     if (strlen($row['bb_topic_title']) > $myTitleLength) {
                         $short_title = substr($row['bb_topic_title'], 0, $myTitleLength) . "...";
                     } else {
                         $short_title = $row['bb_topic_title'];
                     }
                     $member_link = in_array($this->config->get('pk_latestposts_linktype'), range(0, 1)) ? $myWrapper . $module->getBBLink('member', $row) : $myWrapper . rawurlencode($module->getBBLink('member', $row));
                     $topic_link = in_array($this->config->get('pk_latestposts_linktype'), range(0, 1)) ? $myWrapper . $module->getBBLink('topic', $row) : $myWrapper . rawurlencode($module->getBBLink('topic', $row));
                     $myOut .= "<tr valign='top'>\n\t\t\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t\t\t<a href='" . $topic_link . "' target='" . $myTarget . "'>" . $short_title . "</a> (" . $row['bb_replies'] . ")<br/>\n\t\t\t\t\t\t\t\t\t\t" . date('d.m.y, H:i', $row['bb_posttime']) . ", <a href='" . $member_link . "' target='" . $myTarget . "'>" . $row['bb_username'] . "</a>\n\t\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t\t</tr>";
                 }
             }
             $myOut .= "</table>";
             $sucess = true;
         }
         $mydb->free_result($bb_result);
         if ($this->config->get('pk_latestposts_dbmode') == 'new') {
             $mydb->close();
         }
         if ($this->config->get('pk_latestposts_dbmode') == 'bridge') {
             //reset prefix
             $mydb->reset_prefix();
         }
         if (isset($sucess)) {
             $this->pdc->put('portal.modul.latestposts.u' . $this->user->id . '.' . $this->root_path, $myOut, 300, false, true);
         }
     }
     return $myOut;
 }