Example #1
0
 public function __construct($page, $title = false) {
   $this->page = $page;
   $this->domain = 'http://' . $_SERVER['HTTP_HOST'];
   $this->akismet_file = dirname(__FILE__) . '/' . $GLOBALS['akismet_file'];
   $this->wpAPIkey = $GLOBALS['wpAPIkey'];
   $this->email_owner = $GLOBALS['email_owner'];
   $this->from = $GLOBALS['commentator_from'];
   $this->password = $GLOBALS['commentator_password'];
   $this->gravatars = $GLOBALS['gravatars'];
   $this->allowed_html = $GLOBALS['allowed_html'];
   $this->depth = '    ';
   $this->here = preg_replace(array('/&?show=[a-z]+/', '/\?&/'), array('','?'), $this->domain . $_SERVER['REQUEST_URI']);
   $this->newest_first = $_GET['first'] ? $_GET['first'] === 'newest' : (bool)$GLOBALS['newest_first'];
   $this->title = $title ? $title : $this->here;
   if (function_exists('mysql_connection')) {
     $this->link = mysql_connection();
     $create_q = "CREATE TABLE commentator_comments (id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, page VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, email VARCHAR(255) NOT NULL, uri VARCHAR(255) NOT NULL, ip TINYTEXT NOT NULL, timestamp INTEGER NOT NULL, comment TEXT NOT NULL, notify TINYINT(1) NOT NULL DEFAULT 0, spam TINYINT(1) NOT NULL DEFAULT 0) ENGINE = MyISAM CHARACTER SET utf8 COLLATE utf8_unicode_ci;";
     $q = mysqli_query($this->link, $create_q);
     $this->process_login();
     if ($_GET['unsubscribe']) $this->unsubscribe($_GET['unsubscribe']);
     elseif ($_POST['mark_comment'] || $_POST['delete_spam']) $this->delete_comments($_POST['mark_comment'], (bool)$_POST['delete_spam']);
     elseif (($_POST['unspam'] || $_POST['spam'] || $_POST['delete_comments']) && empty($_POST['mark_comment'])) $this->alert('No comments selected.');
     else $this->check_submission();
   }
   else echo '<p><strong>No MySQL connection set up!</strong></p><p>Make sure you have provided a <code>mysql_connection</code> function for the script to use. There is a sample one for you to use at the bottom of the script - all you need to do is change the parameters to your own.</p>';
   $this->get_comments();
 }
Example #2
0
 /**
  * Read configuration parameters from config file
  *
  * Establish connection to server
  * Open database
  *
  * @param $db - database name
  * @param $dbrequired - if false only connect to server (for database list)
  * @return true on success
  */
 public function init($db, $dbrequired = true)
 {
     if ($db) {
         $this->dbname = $db;
         if (!(strpos($db, HEURIST_DB_PREFIX) === 0)) {
             $db = HEURIST_DB_PREFIX . $db;
         }
         $this->dbname_full = $db;
     } else {
         if ($dbrequired) {
             $this->addError(HEURIST_INVALID_REQUEST, "Database parameter not defined");
             $this->mysqli = null;
             return false;
         }
     }
     //dbutils
     $res = mysql_connection(HEURIST_DBSERVER_NAME, ADMIN_DBUSERNAME, ADMIN_DBUSERPSWD);
     if (is_array($res)) {
         //connection to server failed
         $this->addError($res[0], $res[1]);
         $this->mysqli = null;
         return false;
     } else {
         $this->mysqli = $res;
         if ($this->dbname_full) {
             $res = mysql__usedatabase($this->mysqli, $this->dbname_full);
             if (is_array($res)) {
                 //open of database failed
                 $this->addError($res[0], $res[1]);
                 return false;
             }
             if (!$this->get_system()) {
                 return false;
             }
             $this->start_my_session();
             if (!defined('HEURIST_DBNAME')) {
                 define('HEURIST_DBNAME', $this->dbname);
                 define('HEURIST_DBNAME_FULL', $this->dbname_full);
             }
             //@todo  - test upload and thumb folder exist and writeable
             if (!$this->initPathConstants()) {
                 $this->addError(HEURIST_SYSTEM_FATAL, "Cannot access filestore directory for this database: <b>" . HEURIST_FILESTORE_DIR . "</b><br/>Either the directory does not exist (check setting in heuristConfigIni.php file), or it is not writeable by PHP (check permissions).<br>" . "On a multi-tier service, the file server may not have restarted correctly or may not have been mounted on the web server.</p>");
                 return false;
             }
             $this->login_verify();
             //load user info from session
             //consts
             $this->defineConstants();
             //@todo - we do not need to init all constans for every system init - call it as separate method
         }
         $this->is_inited = true;
         return true;
     }
 }
Example #3
0
 function connect()
 {
     $ini_array = parse_ini_file("config.ini");
     $base = $ini_array["db"];
     $host = $ini_array["host"];
     $user = $ini_array["user"];
     $pass = $ini_array["password"];
     $port = $ini_array["port"];
     $this->my_connection = mysql_connection($host . ':' . $port, $user, $pass) or die("Could not connect: " . mysql_error());
     mysql_select_db($base);
     mysql_query("SET NAMES 'cp1251'");
 }
Example #4
0
function mysql_insert($insert, $into)
{
    $link = mysql_connection();
    $columns = implode(", ", array_keys($insert));
    $escaped_values = array_map(function ($n) {
        $n = "'" . $n . "'";
        return $n;
    }, array_values($insert));
    $values = implode(", ", $escaped_values);
    $query = mysqli_query($link, "INSERT INTO `{$into}`({$columns}) VALUES ({$values});");
    mysql_close($link);
    //$array = [
    // 'name' => 'test',
    // 'value' => 'testvalue',
    // 'description' => 'Testbeschreibung'
    // ];
    // $insert = mysql_insert($array, 'config');
}
Example #5
0
function new_get_posts()
{
    $num = 0;
    $link = mysql_connection();
    mysqli_select_db($link, "test");
    $result = mysqli_query($link, "SELECT id FROM content WHERE type = 'post'");
    while ($row = mysqli_fetch_object($result)) {
        $ID = $row->id;
        $num = $num + 1;
        if ($num % 2 != 0) {
            if (has_thumbnail($ID)) {
                echo '<div class="parallax-window" data-parallax="scroll" data-bleed="50" data-speed="0.1" data-image-src="' . get_thumbnail_link($ID) . '"></div>' . "\n";
            }
            echo '<section id="post-' . $ID . '" class="post bright">' . "\n" . '<article>' . "\n" . '<h2><a href="' . get_post_link($ID) . '">' . get_post_title($ID) . '</a></h2>' . "\n" . '<p>' . get_post_preview($ID) . '<p>' . "\n" . '</article>' . "\n" . '</section>' . "\n";
        } else {
            if (has_thumbnail($ID)) {
                echo '<div class="parallax-window" data-parallax="scroll" data-bleed="50" data-speed="0.1" data-image-src="' . get_thumbnail_link($row->id) . '"></div>' . "\n";
            }
            echo '<section id="post-' . $ID . '" class="post dark">' . "\n" . '<article>' . "\n" . '<h2><a href="' . get_post_link($ID) . '">' . get_post_title($ID) . '</a></h2>' . "\n" . '<p>' . get_post_preview($ID) . '<p>' . "\n" . '</article>' . "\n" . '</section>' . "\n";
        }
    }
}
<?php

//The following header is to overwrite the default behvaior of browser's same-site rescritions
//allowing for cross-site HTTP requests
header('Access-Control-Allow-Origin: *');
header('Content-Type: application/json; charset=UTF-8');
//error_reporting(E_ALL ^ E_NOTICE);
//ini_set('display_errors', true);
include '../../../includes/connect.php';
$db = mysql_connection();
$profiles = $db->query("SELECT user,roles,fname,lname,gender FROM profiles WHERE FIND_IN_SET('Become Peer Mentor',roles) > 0 OR FIND_IN_SET('Become Professional Mentor',roles) > 0")->fetchAll();
$output = '';
foreach ($profiles as $profile) {
    $any_mentees = $db->query("SELECT COUNT(*) FROM flack_matches WHERE mentor = '{$profile['user']}'")->fetchColumn();
    if ($output != '') {
        $output .= ',';
    }
    $roles = explode(',', $profile['roles']);
    $output .= '{"username":"******",';
    $output .= '"roles":[';
    for ($i = 0; $i < count($roles); $i++) {
        switch ($roles[$i]) {
            case 'Become Peer Mentor':
                $output .= '"Peer Mentor"';
                break;
            case 'Become Professional Mentor':
                $output .= '"Professional Mentor"';
                break;
            case 'Request Peer Mentor':
                $output .= '"Mentee - Peer"';
                break;
Example #7
0
<?php

$num = 0;
$link = mysql_connection();
mysqli_select_db($link, "test");
$result = mysqli_query($link, "SELECT id FROM content WHERE type = 'post'");
while ($row = mysqli_fetch_object($result)) {
    $ID = $row->id;
    ////////////////////////////////////////////////////////////////////////////
    $O1 = '<div class="mbd-layout-col mbd-layout-col-8-8 mbd-layout-post matchheight">' . "\n";
    if (has_thumbnail($ID)) {
        $O1 .= '<div class="mbd-layout-post-image-title" style="background-image: url(' . get_thumbnail_link($ID) . ');">' . "\n";
        $O1 .= '<h2>Lorem ipsum</h2>' . "\n";
        $O1 .= '</div>' . "\n";
    } else {
        $O1 .= '<div class="mbd-layout-post-title">' . "\n";
        $O1 .= '<h2>Lorem ipsum</h2>' . "\n";
        $O1 .= '</div>' . "\n";
    }
    $O1 .= '<div class="mbd-layout-post-content">' . "\n";
    $O1 .= 'CONTENT' . "\n";
    $O1 .= '</div>' . "\n";
    $O1 .= '<div class="mbd-layout-post-meta">' . "\n";
    $O1 .= '<img src="http://localhost/b2-net-cms-alpha/B2-NET-CMS/content/themes/material/img/meta-image.jpg" class="mbd-layout-post-meta-image"/>' . "\n";
    $O1 .= '<p class="mbd-layout-post-meta-autor">The Meta</p>' . "\n";
    $O1 .= '<p class="mbd-layout-post-meta-date">2 days ago</p>' . "\n";
    $O1 .= '</div>' . "\n";
    $O1 .= '</div>' . "\n";
    ////////////////////////////////////////////////////////////////////////////
    $O2 = '<div class="mbd-layout-col mbd-layout-col-3-8 mbd-layout-post matchheight">' . "\n";
    if (has_thumbnail($ID)) {
Example #8
0
function menu($data)
{
    $link = mysql_connection();
    $result = mysqli_query($link, "SELECT id FROM menus WHERE theme = '" . THEME . "' AND position = '" . $data['position'] . "'");
    while ($row = mysqli_fetch_object($result)) {
        $ID = $row->id;
        echo '<li><a href="' . get_menu_url($ID) . '">' . get_menu_value($ID) . '</a></li>' . "\n";
    }
}
Example #9
0
<?php

mysql_connection('localhost', 'root', '');
mysql_select_db('nama');