Example #1
0
 /**
  * Returns all relevant articles for a FAQ record with the same language
  *
  * @param integer $record_id FAQ ID
  * @param string  $thema     FAQ title
  * 
  * @return string
  */
 public function getAllRelatedById($record_id, $article_name, $keywords)
 {
     global $sids;
     $relevantslisting = '';
     $begriffe = str_replace('-', ' ', $article_name) . $keywords;
     $search = PMF_Search_Factory::create($this->language, array('database' => PMF_Db::getType()));
     $i = $last_id = 0;
     $search->setDatabaseHandle($this->db)->setTable(SQLPREFIX . 'faqdata AS fd')->setResultColumns(array('fd.id AS id', 'fd.lang AS lang', 'fcr.category_id AS category_id', 'fd.thema AS thema', 'fd.content AS content'))->setJoinedTable(SQLPREFIX . 'faqcategoryrelations AS fcr')->setJoinedColumns(array('fd.id = fcr.record_id', 'fd.lang = fcr.record_lang'))->setConditions(array('fd.active' => "'yes'", 'fd.lang' => "'" . $this->language->getLanguage() . "'"))->setMatchingColumns(array('fd.thema', 'fd.content', 'fd.keywords'));
     $result = $search->search($begriffe);
     while (($row = $this->db->fetchObject($result)) && $i < PMF_Configuration::getInstance()->get('records.numberOfRelatedArticles')) {
         if ($row->id == $record_id || $row->id == $last_id) {
             continue;
         }
         $relevantslisting .= '' == $relevantslisting ? '<ul>' : '';
         $relevantslisting .= '<li>';
         $url = sprintf('%saction=artikel&amp;cat=%d&amp;id=%d&amp;artlang=%s', $sids, $row->category_id, $row->id, $row->lang);
         $oLink = new PMF_Link(PMF_Link::getSystemRelativeUri() . '?' . $url);
         $oLink->itemTitle = $row->thema;
         $oLink->text = $row->thema;
         $oLink->tooltip = $row->thema;
         $relevantslisting .= $oLink->toHtmlAnchor() . '</li>';
         $i++;
         $last_id = $row->id;
     }
     $relevantslisting .= $i > 0 ? '</ul>' : '';
     return '' == $relevantslisting ? '-' : $relevantslisting;
 }
Example #2
0
 /**
  * Returns the sticky records with URL and Title
  * 
  * @return array
  */
 private function getStickyRecordsData()
 {
     global $sids;
     if ($this->groupSupport) {
         $permPart = sprintf("AND\n                ( fdg.group_id IN (%s)\n            OR\n                (fdu.user_id = %d AND fdg.group_id IN (%s)))", implode(', ', $this->groups), $this->user, implode(', ', $this->groups));
     } else {
         $permPart = sprintf("AND\n                ( fdu.user_id = %d OR fdu.user_id = -1 )", $this->user);
     }
     $now = date('YmdHis');
     $query = sprintf("\n            SELECT\n                fd.id AS id,\n                fd.lang AS lang,\n                fd.thema AS thema,\n                fcr.category_id AS category_id\n            FROM\n                %sfaqdata fd\n            LEFT JOIN\n                %sfaqcategoryrelations fcr\n            ON\n                fd.id = fcr.record_id\n            AND\n                fd.lang = fcr.record_lang\n            LEFT JOIN\n                %sfaqdata_group AS fdg\n            ON\n                fd.id = fdg.record_id\n            LEFT JOIN\n                %sfaqdata_user AS fdu\n            ON\n                fd.id = fdu.record_id\n            WHERE\n                fd.lang = '%s'\n            AND \n                fd.date_start <= '%s'\n            AND \n                fd.date_end   >= '%s'\n            AND \n                fd.active = 'yes'\n            AND \n                fd.sticky = 1\n            %s", SQLPREFIX, SQLPREFIX, SQLPREFIX, SQLPREFIX, $this->language, $now, $now, $permPart);
     $result = $this->db->query($query);
     $sticky = array();
     $data = array();
     $oldId = 0;
     while ($row = $this->db->fetch_object($result)) {
         if ($oldId != $row->id) {
             $data['thema'] = $row->thema;
             $title = $row->thema;
             $url = sprintf('%saction=artikel&amp;cat=%d&amp;id=%d&amp;artlang=%s', $sids, $row->category_id, $row->id, $row->lang);
             $oLink = new PMF_Link(PMF_Link::getSystemRelativeUri() . '?' . $url);
             $oLink->itemTitle = $row->thema;
             $oLink->tooltip = $title;
             $data['url'] = $oLink->toString();
             $sticky[] = $data;
         }
         $oldId = $row->id;
     }
     return $sticky;
 }
Example #3
0
 /**
  * Constructor
  *
  */
 public function __construct()
 {
     global $PMF_LANG;
     $this->db = PMF_Db::getInstance();
     $this->language = PMF_Language::$language;
     $this->pmf_lang = $PMF_LANG;
 }
Example #4
0
 /**
  * Returns all relevant Articles for a FAQ record
  *
  * @param   integer $record_id
  * @param   string  $thema
  * @return   string
  * @since   2006-08-29
  * @author  Thomas Zeithaml <*****@*****.**>
  */
 public function getAllRelatedById($record_id, $article_name, $keywords)
 {
     global $sids, $PMF_CONF;
     $relevantslisting = '';
     $begriffe = str_replace('-', ' ', $article_name) . $keywords;
     $i = $last_id = 0;
     $result = $this->db->search(SQLPREFIX . "faqdata", array(SQLPREFIX . "faqdata.id AS id", SQLPREFIX . "faqdata.lang AS lang", SQLPREFIX . "faqcategoryrelations.category_id AS category_id", SQLPREFIX . "faqdata.thema AS thema", SQLPREFIX . "faqdata.content AS content"), SQLPREFIX . "faqcategoryrelations", array(SQLPREFIX . "faqdata.id = " . SQLPREFIX . "faqcategoryrelations.record_id", SQLPREFIX . "faqdata.lang = " . SQLPREFIX . "faqcategoryrelations.record_lang"), array(SQLPREFIX . "faqdata.thema", SQLPREFIX . "faqdata.content", SQLPREFIX . "faqdata.keywords"), $begriffe, array(SQLPREFIX . "faqdata.active" => "'yes'"));
     while (($row = $this->db->fetch_object($result)) && $i < $PMF_CONF['records.numberOfRelatedArticles']) {
         if ($row->id == $record_id || $row->id == $last_id) {
             continue;
         }
         $relevantslisting .= '' == $relevantslisting ? '<ul>' : '';
         $relevantslisting .= '<li>';
         $url = sprintf('%saction=artikel&amp;cat=%d&amp;id=%d&amp;artlang=%s', $sids, $row->category_id, $row->id, $row->lang);
         $oLink = new PMF_Link(PMF_Link::getSystemRelativeUri() . '?' . $url);
         $oLink->itemTitle = $row->thema;
         $oLink->text = $row->thema;
         $oLink->tooltip = $row->thema;
         $relevantslisting .= $oLink->toHtmlAnchor() . '</li>';
         $i++;
         $last_id = $row->id;
     }
     $relevantslisting .= $i > 0 ? '</ul>' : '';
     return '' == $relevantslisting ? '-' : $relevantslisting;
 }
Example #5
0
 /**
  * Returns the single instance
  *
  * @return PMF_DB_Driver
  */
 public static function getInstance()
 {
     if (null == self::$instance) {
         $className = __CLASS__;
         self::$instance = new $className();
     }
     return self::$instance;
 }
Example #6
0
 /**
  * Returns all relevant articles for a FAQ record with the same language
  *
  * @param integer $recordId FAQ ID
  * @param string  $question FAQ title
  * @param string  $keywords FAQ keywords
  *
  * @return array
  */
 public function getAllRelatedById($recordId, $question, $keywords)
 {
     $terms = str_replace('-', ' ', $question) . $keywords;
     $search = PMF_Search_Factory::create($this->_config, array('database' => PMF_Db::getType()));
     $search->setTable(PMF_Db::getTablePrefix() . 'faqdata AS fd')->setResultColumns(array('fd.id AS id', 'fd.lang AS lang', 'fcr.category_id AS category_id', 'fd.thema AS question', 'fd.content AS answer'))->setJoinedTable(PMF_Db::getTablePrefix() . 'faqcategoryrelations AS fcr')->setJoinedColumns(array('fd.id = fcr.record_id', 'fd.lang = fcr.record_lang'))->setConditions(array('fd.active' => "'yes'", 'fd.lang' => "'" . $this->_config->getLanguage()->getLanguage() . "'"))->setMatchingColumns(array('fd.thema', 'fd.content', 'fd.keywords'));
     $result = $search->search($terms);
     return $this->_config->getDb()->fetchAll($result);
 }
Example #7
0
 /**
  * Deletes logging data older than 30 days
  *
  * @return boolean
  */
 public function delete()
 {
     $query = sprintf("DELETE FROM\n                %sfaqadminlog\n            WHERE\n                time < %d", SQLPREFIX, $_SERVER['REQUEST_TIME'] - 30 * 86400);
     if ($this->db->query($query)) {
         return true;
     }
     return false;
 }
Example #8
0
 /**
  * Connects to the database.
  *
  * This function connects to a ibase database
  *
  * @param   string $host
  * @param   string $username
  * @param   string $password
  * @param   string $db_name
  * @return  boolean true, if connected, otherwise false
  * @access  public
  * @author  Thorsten Rinne <*****@*****.**>
  * @since   2005-04-16
  */
 function connect($host, $user, $passwd, $db)
 {
     $this->conn = ibase_connect($db, $user, $passwd);
     if (false == $this->conn) {
         PMF_Db::errorPage(ibase_errmsg());
         die;
     }
     return true;
 }
Example #9
0
 /**
  * Connects to the database.
  *
  * @param   string $host
  * @param   string $username
  * @param   string $password
  * @param   string $db_name
  * @return  boolean TRUE, if connected, otherwise FALSE
  */
 function connect($host, $user, $passwd, $db)
 {
     $this->conn = mssql_pconnect($host, $user, $passwd);
     if (empty($db) or $this->conn == false) {
         PMF_Db::errorPage(mssql_get_last_message());
         die;
     }
     return mssql_select_db($db, $this->conn);
 }
Example #10
0
 /**
  * Connects to the database.
  *
  * @param   string
  * @return  boolean
  */
 public function connect($host, $user = false, $passwd = false, $db = false)
 {
     $this->conn = new SQLite3($host);
     if (!$this->conn) {
         PMF_Db::errorPage($this->conn->lastErrorMsg());
         die;
     }
     return true;
 }
Example #11
0
 /**
  * Constructor
  *
  * @param resource$result Resultset
  */
 public function __construct($result)
 {
     $this->db = PMF_Db::getInstance();
     $arrayObject = new ArrayObject();
     while ($row = $this->db->fetch_assoc($result)) {
         $arrayObject[] = $row;
     }
     $this->iterator = $arrayObject->getIterator();
 }
Example #12
0
 /**
  * Connects to the database.
  *
  * @param   string
  * @return  boolean
  */
 public function connect($host, $user = false, $passwd = false, $db = false)
 {
     $this->conn = sqlite_open($host, 0666);
     if (!$this->conn) {
         PMF_Db::errorPage(sqlite_error_string(sqlite_last_error($this->conn)));
         die;
     }
     return true;
 }
Example #13
0
 /**
  * Connects to the database.
  *
  * This function connects to a MySQL database
  *
  * @param  string  $host     Hostname
  * @param  string  $username Username
  * @param  string  $password Password
  * @param  string  $db_name  Database name
  * @return boolean TRUE, if connected, otherwise false
  */
 public function connect($host, $user, $password, $db)
 {
     $this->conn = mysql_connect($host, $user, $password);
     if (empty($db) || $this->conn == false) {
         PMF_Db::errorPage($this->error());
         die;
     }
     return mysql_select_db($db, $this->conn);
 }
Example #14
0
 /**
  * Connects to the database.
  *
  * This function connects to a MySQL database
  *
  * @param   string $host
  * @param   string $username
  * @param   string $password
  * @param   string $db_name
  * @return  boolean TRUE, if connected, otherwise FALSE
  * @access  public
  * @author  Adam Greene <*****@*****.**>
  * @since   2004-12-10
  */
 function connect($host, $user, $passwd, $db)
 {
     $this->conn = @sybase_pconnect($host, $user, $passwd);
     if (empty($db) || $this->conn === false) {
         PMF_Db::errorPage('An unspecified error occurred.');
         die;
     }
     return @sybase_select_db($db, $this->conn);
 }
Example #15
0
 /**
  * Connects to the database.
  *
  * This function connects to a MySQL database
  *
  * @param   string $host
  * @param   string $username
  * @param   string $password
  * @param   string $db_name
  * @return  boolean true, if connected, otherwise false
  * @access  public
  * @author  Thorsten Rinne <*****@*****.**>
  * @since   2005-02-21
  */
 public function connect($host, $user, $passwd, $db)
 {
     $this->conn = new mysqli($host, $user, $passwd, $db);
     if (mysqli_connect_errno()) {
         PMF_Db::errorPage(mysqli_connect_error());
         die;
     }
     return true;
 }
Example #16
0
 /**
  * This function connects to a DB2 database
  *
  * @param   string $host
  * @param   string $username
  * @param   string $password
  * @param   string $db_name
  * @return  boolean TRUE, if connected, otherwise FALSE
  * @access  public
  * @author  Thorsten Rinne <*****@*****.**>
  * @since   2005-04-16
  */
 function connect($host, $user, $passwd, $db)
 {
     $this->conn = db2_pconnect($db, $user, $passwd, $this->options);
     if (false == $this->conn) {
         PMF_Db::errorPage(db2_conn_errormsg());
         die;
     }
     return true;
 }
Example #17
0
 /**
  * Connects to the database.
  *
  * @param string $host     Hostname
  * @param string $user     Username
  * @param string $password Password
  * @param string $database Database name
  *
  * @return  boolean true, if connected, otherwise false
  */
 public function connect($host, $user, $password, $database = '')
 {
     try {
         $this->conn = new PDO('mysql:host=' . $host . ';dbname=' . $database . ';charset=UTF8', $user, $password);
         $this->conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
     } catch (PDOException $e) {
         PMF_Db::errorPage('Database connection failed: ' . $e->getMessage());
     }
     return true;
 }
 /**
  * Get an array with minimalistic attachment meta data
  *
  * @return array
  */
 public function getBreadcrumbs()
 {
     $retval = array();
     $query = sprintf("\n            SELECT\n                fa.id AS ID,\n                fa.record_id AS record_id,\n                fa.record_lang AS record_lang,\n                fa.filename AS filename,\n                fa.filesize AS filesize,\n                fa.mime_type AS mime_type,\n                fd.thema AS thema\n            FROM\n                %s fa\n            JOIN\n                %s fd\n            ON\n                fa.record_id = fd.id\n            GROUP BY\n                fa.id", PMF_Db::getTablePrefix() . 'faqattachment', PMF_Db::getTablePrefix() . 'faqdata');
     $result = $this->config->getDb()->query($query);
     if ($result) {
         $retval = $this->config->getDb()->fetchAll($result);
     }
     return $retval;
 }
Example #19
0
 /**
  * Connects to the database.
  *
  * @param   string $host
  * @param   string $username
  * @param   string $password
  * @param   string $db_name
  * @return  boolean TRUE, if connected, otherwise FALSE
  * @access  public
  * @author  Thorsten Rinne <*****@*****.**>
  * @since   2005-09-20
  */
 public function connect($host, $user, $passwd, $db)
 {
     $this->conn = oci_connect($user, $passwd, $db);
     if (empty($db) or $this->conn == true) {
         $error = oci_error();
         PMF_Db::errorPage($error['message']);
         return false;
     }
     return true;
 }
Example #20
0
 /**
  * Connects to the database.
  *
  * This function connects to a MySQL database
  *
  * @param  string $host     A string specifying the name of the server to which a connection is being established
  * @param  string $user     Specifies the User ID to be used when connecting with SQL Server Authentication
  * @param  string $passwd   Specifies the password associated with the User ID to be used when connecting with 
  *                          SQL Server Authentication
  * @param  string $database Specifies the name of the database in use for the connection being established
  * @return boolean true, if connected, otherwise false
  */
 public function connect($host, $user, $passwd, $database)
 {
     $this->setConnectionOptions($user, $passwd, $database);
     $this->conn = sqlsrv_connect($host, $this->connectionOptions);
     if (!$this->conn) {
         PMF_Db::errorPage(sqlsrv_errors());
         die;
     }
     return true;
 }
 /**
  * Connects to the database.
  *
  * @param string $host     Database hostname
  * @param string $user     Database username
  * @param string $password Password
  * @param string $database Database name
  *
  * @return boolean true, if connected, otherwise false
  */
 public function connect($host, $user, $password, $database = '')
 {
     $connectionString = sprintf('host=%s port=5432 dbname=%s user=%s password=%s', $host, $database, $user, $password);
     $this->conn = pg_pconnect($connectionString);
     if (empty($database) || $this->conn == false) {
         PMF_Db::errorPage(pg_last_error($this->conn));
         die;
     }
     $this->query("SET standard_conforming_strings=on");
     return true;
 }
Example #22
0
 /**
  * Connects to the database.
  *
  * This function connects to a MySQL database
  *
  * @param   string $host
  * @param   string $username
  * @param   string $password
  * @param   string $db_name
  * @return  boolean true, if connected, otherwise false
  * @access  public
  * @author  Thorsten Rinne <*****@*****.**>
  * @author  Tom Rochester <*****@*****.**>
  * @since   2003-02-24
  */
 public function connect($host, $user, $passwd, $db)
 {
     /* if you use mysql_pconnect(), remove the next line: */
     $this->conn = pg_pconnect('host=' . $host . ' port=5432 dbname=' . $db . ' user='******' password=' . $passwd);
     /* comment out for more speed with mod_php or on Windows */
     // $this->conn = @pg_pconnect("host=$host port=5432 dbname=$db user=$user password=$passwd");
     if (empty($db) || $this->conn == false) {
         PMF_Db::errorPage(pg_last_error($this->conn));
         die;
     }
     return true;
 }
Example #23
0
 /**
  * Connects to the database.
  *
  * @param   string $host
  * @param   string $user
  * @param   string $password
  * @param   string $database
  *
  * @return  boolean TRUE, if connected, otherwise FALSE
  */
 public function connect($host, $user, $password, $database = '')
 {
     $this->conn = mssql_pconnect($host, $user, $password);
     if ($this->conn === false) {
         PMF_Db::errorPage(mssql_get_last_message());
         die;
     }
     if ('' !== $database) {
         return mssql_select_db($database, $this->conn);
     }
     return true;
 }
Example #24
0
 /**
  * Returns all comments with their categories
  *
  * @param  string $type Type of comment: faq or news
  * @return array
  */
 public function getAllComments($type = self::COMMENT_TYPE_FAQ)
 {
     $comments = array();
     $query = sprintf("\n            SELECT\n                fc.id_comment AS comment_id,\n                fc.id AS record_id,\n                %s\n                fc.usr AS username,\n                fc.email AS email,\n                fc.comment AS comment,\n                fc.datum AS comment_date\n            FROM\n                %sfaqcomments fc\n            %s\n            WHERE\n                type = '%s'", $type == self::COMMENT_TYPE_FAQ ? "fcg.category_id,\n" : '', SQLPREFIX, $type == self::COMMENT_TYPE_FAQ ? "LEFT JOIN\n                " . SQLPREFIX . "faqcategoryrelations fcg\n            ON\n                fc.id = fcg.record_id\n" : '', $type);
     $result = $this->db->query($query);
     if ($this->db->num_rows($result) > 0) {
         while ($row = $this->db->fetch_object($result)) {
             $comments[] = array('comment_id' => $row->comment_id, 'record_id' => $row->record_id, 'category_id' => isset($row->category_id) ? $row->category_id : null, 'content' => $row->comment, 'date' => $row->comment_date, 'username' => $row->username, 'email' => $row->email);
         }
     }
     return $comments;
 }
 /**
  * Connects to the database
  *
  * @param string $host     MySQL Hostname
  * @param string $user     MySQL Username
  * @param string $password MySQL Password
  * @param string $database       MySQL Database name
  *
  * @return boolean
  */
 public function connect($host, $user, $password, $database = '')
 {
     $this->conn = mysql_connect($host, $user, $password);
     if ($this->conn === false) {
         PMF_Db::errorPage($this->error());
         die;
     }
     mysql_set_charset('utf8', $this->conn);
     if ('' !== $database) {
         return $this->selectDb($database);
     }
     return true;
 }
Example #26
0
 /**
  * Connects to the database.
  *
  * This function connects to a MySQL database
  *
  * @param   string $host
  * @param   string $username
  * @param   string $password
  * @param   string $db_name
  * @return  boolean true, if connected, otherwise false
  */
 public function connect($host, $user, $passwd, $db)
 {
     $this->conn = new mysqli($host, $user, $passwd, $db);
     if (mysqli_connect_errno()) {
         PMF_Db::errorPage(mysqli_connect_error());
         die;
     }
     /* change character set to UTF-8 */
     if (!$this->conn->set_charset('utf8')) {
         PMF_Db::errorPage($this->error());
     }
     return true;
 }
Example #27
0
 /**
  * Check if at least one faq has been tagged with a tag
  *
  * @return boolean
  */
 public function existTagRelations()
 {
     $query = sprintf('
         SELECT
             COUNT(record_id) AS n
         FROM
             %sfaqdata_tags', SQLPREFIX);
     $result = $this->db->query($query);
     if ($row = $this->db->fetchObject($result)) {
         return $row->n > 0;
     }
     return false;
 }
Example #28
0
 /**
  * Connects to the database
  * 
  * @param string $host     MySQL Hostname
  * @param string $username MySQL Username
  * @param string $password MySQL Password
  * @param string $db_name  MySQL Database name
  * 
  * @return boolean TRUE, if connected, otherwise false
  */
 public function connect($host, $user, $password, $db)
 {
     $this->conn = mysql_connect($host, $user, $password);
     if (empty($db) || $this->conn == false) {
         PMF_Db::errorPage($this->error());
         die;
     }
     if (version_compare(PHP_VERSION, '5.2.3', '>')) {
         mysql_set_charset('utf8', $this->conn);
     } else {
         $this->query('SET NAMES utf8');
     }
     return mysql_select_db($db, $this->conn);
 }
Example #29
0
 /**
  * Connects to the database.
  *
  * @param string $host     Database hostname
  * @param string $username Database username
  * @param string $password Password
  * @param string $database Database name
  *
  * @return boolean true, if connected, otherwise false
  */
 public function connect($host, $user, $password, $database)
 {
     $connectionString = sprintf('host=%s port=5432 dbname=%s user=%s password=%s', $host, $database, $user, $password);
     /* if you use mysql_pconnect(), remove the next line: */
     $this->conn = pg_pconnect($connectionString);
     /* comment out for more speed with mod_php or on Windows */
     // $this->conn = @pg_pconnect($connectionString);
     if (empty($database) || $this->conn == false) {
         PMF_Db::errorPage(pg_last_error($this->conn));
         die;
     }
     $this->query("SET standard_conforming_strings=on");
     return true;
 }
Example #30
0
 /**
  * Retrieve all the stop words by a certain language
  * 
  * @param string $lang Language to retrieve stop words by
  * @param boolean wordsOnly
  * 
  * @return array
  */
 public function getByLang($lang = null, $wordsOnly = false)
 {
     $lang = is_null($lang) ? $this->language : $lang;
     $sql = sprintf("SELECT id, lang, LOWER(stopword) AS stopword FROM {$this->table_name} WHERE lang = '%s'", $lang);
     $result = $this->db->query($sql);
     $retval = array();
     if ($wordsOnly) {
         while (($row = $this->db->fetch_object($result)) == true) {
             $retval[] = $row->stopword;
         }
     } else {
         return $this->db->fetchAll($result);
     }
     return $retval;
 }