コード例 #1
1
ファイル: liga.php プロジェクト: herrlosxxx/test_parser
function parseFile($file, $type)
{
    $sql = new MySQL();
    $sql->connect('127.0.0.1', 'root', 'root');
    $objReader = PHPExcel_IOFactory::createReader($type);
    $chunkSize = 200;
    $i = 1;
    $sql->clear('price_liga');
    $r = array();
    for ($startRow = 0; $startRow <= 5000; $startRow += $chunkSize + 1) {
        $chunkFilter = new chunkReadFilter($startRow, $chunkSize);
        $objReader->setReadFilter($chunkFilter);
        $objReader->setReadDataOnly(true);
        $objPHPExcel = $objReader->load($file);
        $data = $objPHPExcel->getActiveSheet()->toArray();
        foreach ($data as $k => $v) {
            if ($data[$k][0] == '') {
                unset($data[$k]);
            } else {
                $sql->insert('price_liga', array('id' => $i, 'cat_num' => $data[$k][0], 'brand' => ucwords(strtolower($data[$k][1])), 'article' => $data[$k][2], 'descr' => str_replace("'", "\\'", $data[$k][3]), 'model' => str_replace("'", "\\'", $data[$k][4]), 'size' => $data[$k][5], 'price' => $data[$k][6], 'amount' => $data[$k][8]), true);
                $i++;
            }
        }
    }
    //print_r($r);
    $sql->close();
    return array('counter' => $i);
}
コード例 #2
0
 /**
  * Setter for the `$Database`. This will create a new Database driver
  * and then attempt to create a connection to the database using the
  * connection details provided in the Symphony configuration. If any
  * errors occur whilst doing so, a Symphony Error Page is displayed.
  *
  * @return boolean
  *  This function will return true if the `$Database` was
  *  initialised successfully.
  */
 public function initialiseDatabase()
 {
     if (self::$Database) {
         return true;
     }
     self::$Database = new MySQL();
     $details = self::$Configuration->get('database');
     try {
         if (!self::$Database->connect($details['host'], $details['user'], $details['password'], $details['port'], $details['db'])) {
             return false;
         }
         if (!self::$Database->isConnected()) {
             return false;
         }
         self::$Database->setPrefix($details['tbl_prefix']);
         if (self::$Configuration->get('runtime_character_set_alter', 'database') == '1') {
             self::$Database->setCharacterEncoding(self::$Configuration->get('character_encoding', 'database'));
             self::$Database->setCharacterSet(self::$Configuration->get('character_set', 'database'));
         }
         if (self::$Configuration->get('query_caching', 'database') == 'off') {
             self::$Database->disableCaching();
         } elseif (self::$Configuration->get('query_caching', 'database') == 'on') {
             self::$Database->enableCaching();
         }
     } catch (DatabaseException $e) {
         $error = self::$Database->getlastError();
         throw new SymphonyErrorPage($error['num'] . ': ' . $error['msg'], 'Symphony Database Error', 'database-error', array('error' => $error, 'message' => __('There was a problem whilst attempting to establish a database connection. Please check all connection information is correct. The following error was returned.')));
     }
     return true;
 }
コード例 #3
0
ファイル: Login.class.php プロジェクト: renatorabelo/PAS
 public function __construct($login, $senha)
 {
     parent::connect();
     $this->_fields['NMLOGIN'] = $login;
     $this->_fields['CDSENHA'] = $senha;
     $this->_Error = new Error();
 }
コード例 #4
0
ファイル: v8.php プロジェクト: herrlosxxx/test_parser
function parseFile($file, $type)
{
    $sql = new MySQL();
    $sql->connect('127.0.0.1', 'root', 'root');
    $objReader = PHPExcel_IOFactory::createReader($type);
    $chunkSize = 200;
    $i = 1;
    $sql->clear('price_v8');
    for ($startRow = 0; $startRow <= 5000; $startRow += $chunkSize + 1) {
        $chunkFilter = new chunkReadFilter($startRow, $chunkSize);
        $objReader->setReadFilter($chunkFilter);
        $objReader->setReadDataOnly(true);
        $objPHPExcel = $objReader->load($file);
        $data = $objPHPExcel->getActiveSheet()->toArray();
        foreach ($data as $k => $v) {
            if (trim($data[$k][0]) == 'Артикул' || $data[$k][3] == '' || strstr($data[$k][3], 'камера') || $data[$k][7] == '') {
                unset($data[$k]);
            } else {
                $descr = str_replace('Ш', 'xSTUDEDx', trim($data[$k][3]));
                $descr = preg_replace('/[а-яА-Я]/', '', $descr);
                $sql->insert('price_v8', array('id' => $i, 'article' => trim($data[$k][0]), 'descr' => str_replace("'", "\\'", $descr), 'cat_num' => trim($data[$k][6]), 'season' => trim($data[$k][7]), 'price' => trim($data[$k][9]), 'amount' => trim(preg_replace('/[а-яА-Яa-zA-Z]{0,}/', '', $data[$k][10]))), true);
                $i++;
            }
        }
    }
    $sql->close();
    return array('counter' => $i);
}
コード例 #5
0
ファイル: MySqlTest.php プロジェクト: EHER/monopolis
 /**
  * Tests that this adapter can connect to the database, and that the status is properly
  * persisted.
  *
  * @return void
  */
 public function testDatabaseConnection()
 {
     $db = new MySql(array('autoConnect' => false) + $this->_dbConfig);
     $this->assertTrue($db->connect());
     $this->assertTrue($db->isConnected());
     $this->assertTrue($db->disconnect());
     $this->assertFalse($db->isConnected());
     $db = new MySQL(array('autoConnect' => false, 'encoding' => NULL, 'persistent' => false, 'host' => 'localhost:3306', 'login' => 'garbage', 'password' => '', 'database' => 'garbage', 'init' => true) + $this->_dbConfig);
     $this->assertFalse($db->connect());
     $this->assertFalse($db->isConnected());
     $this->assertTrue($db->disconnect());
     $this->assertFalse($db->isConnected());
 }
コード例 #6
0
ファイル: m.php プロジェクト: herrlosxxx/test_parser
function parseFile($file, $type)
{
    $sql = new MySQL();
    $sql->connect('127.0.0.1', 'root', 'root');
    $objReader = PHPExcel_IOFactory::createReader($type);
    $sheets = $objReader->listWorksheetNames($file);
    $i = 1;
    $sql->clear('price_moscow');
    foreach ($sheets as $sheet) {
        $chunkSize = 200;
        if (strstr($sheet, 'Шины')) {
            $r = array();
            for ($startRow = 0; $startRow <= 4000; $startRow += $chunkSize + 1) {
                $chunkFilter = new chunkReadFilter($startRow, $chunkSize);
                $objReader->setReadFilter($chunkFilter);
                $objReader->setReadDataOnly(true);
                $objReader->setLoadSheetsOnly($sheet);
                $objPHPExcel = $objReader->load($file);
                $data = $objPHPExcel->getActiveSheet()->toArray();
                foreach ($data as $k => $v) {
                    if ($data[$k][2] == '' || $data[$k][2] == 'Модель') {
                        unset($data[$k]);
                    } else {
                        $season = strstr($data[$k][7], 'Летняя') ? 0 : (strstr($data[$k][7], 'Зимняя') ? 1 : 2);
                        $vtype = strstr($data[$k][8], 'Легковая') ? 0 : (strstr($data[$k][8], 'Грузовая') ? 1 : 2);
                        $stunds = $data[$k][10] == '' || $data[$k][10] == 'Нет' ? 0 : 1;
                        $xl = $data[$k][12] == '' || $data[$k][12] == 'Нет' ? 0 : 1;
                        $runflat = $data[$k][13] == '' || $data[$k][13] == 'Нет' ? 0 : 1;
                        $sql->insert('price_moscow', array('id' => $i, 'article' => trim($data[$k][0]), 'brand' => ucwords(strtolower(trim($data[$k][1]))), 'model' => str_replace("'", "\\'", trim($data[$k][2])), 'width' => trim($data[$k][3]), 'height' => trim($data[$k][4]), 'diameter' => (int) preg_replace('/[a-zA-Z]/', '', trim($data[$k][5])), 'weight_speed' => trim($data[$k][6]), 'season' => $season, 'v_type' => $vtype, 'studs' => $stunds, 'xl' => $xl, 'runflat' => $runflat, 'price_rrc' => $data[$k][17], 'price_opt' => $data[$k][18], 'amount' => 0), true);
                        $i++;
                    }
                }
            }
        }
    }
    $sql->close();
    return array('counter' => $i);
}
コード例 #7
0
ファイル: teamDao.php プロジェクト: reyden/FINAL
function EditTeam($inTeamId, $inSportId = null, $inTeamName = null, $inCoachId = null, $inSubCoachIds = null)
{
    $db = new MySQL("localhost", "root", "n4UVFpHeHr", "bulilit");
    $db->connect();
    $teams = GetTeam($inTeamId);
    $coaches;
    foreach ($teams as $team) {
        $coaches = $team->coachIds;
    }
    if ($coaches == null) {
        AddTeamHeadCoach($inTeamId, $inCoachId);
    } else {
        $query = $db->query("UPDATE TeamCoach SET HeadCoach='Yes' WHERE TeamID=" . $inTeamId . " and CoachID=" . $inCoachId . "") or die("Error updating team Head Coach");
    }
    if ($coaches == null) {
        AddTeamSubCoaches($inTeamId, $inSubCoachIds);
    } else {
        foreach ($inSubCoachIds as $s) {
            $query = $db->query("UPDATE TeamCoach SET HeadCoach='No' WHERE TeamID=" . $inTeamId . " and CoachID=" . $s . "") or die("Error updating team Assistant Coaches");
        }
    }
    $query = $db->query("UPDATE Team SET SportID=" . $inSportId . ", TeamName='" . $inTeamName . "' WHERE TeamID=" . $inTeamId) or die("Error updating team name");
}
コード例 #8
0
ファイル: sql_replication.php プロジェクト: uvaron/BDparser
 * Date: 08.02.2016
 * Time: 13:51
 */
// Подключение к базе данных;
require_once $_SERVER['DOCUMENT_ROOT'] . '/systems/connect.php';
// Проверяем роли;
check_role(basename($_SERVER['SCRIPT_NAME'], ".php"));
if (count($_POST) == 0 && count($_GET) == 0) {
    $html = '';
    // Заголовок страницы;
    $html .= $elements->title(basename($_SERVER['SCRIPT_NAME'], ".php"));
    // Создаем объекты для подключения в базам с репликацией;
    $db_replica1 = new MySQL();
    $db_replica1->connect('192.168.7.8', 'mysql', 'root', 'xfFMC85ty16R4iHZS3))J');
    $db_replica2 = new MySQL();
    $db_replica2->connect('192.168.168.165', 'mysql', 'root', 'xfFMC85ty16R4iHZS3))J');
    // Запрашиваем данные и там и там;
    $replica_data_1 = $db_replica1->row('SHOW SLAVE STATUS');
    $replica_data_2 = $db_replica2->row('SHOW SLAVE STATUS');
    $html .= '<table>';
    $html .= '<tr>';
    $html .= '<td class="row_top">Сервер</td>';
    $html .= '<td class="row_top inf_row">Текущее состояние</td>';
    $html .= '<td class="row_top inf_row">Запущена ли репликация</td>';
    $html .= '<td class="row_top inf_row">Последняя ошибка</td>';
    $html .= '</tr>';
    $html .= '<tr>';
    $html .= '<td class="row_1" align="center">192.168.7.8</td>';
    $html .= '<td class="row_1 inf_row" align="center">' . $replica_data_1['Slave_IO_State'] . '</td>';
    $html .= '<td class="row_1 inf_row" align="center">' . $replica_data_1['Slave_IO_Running'] . ' / ' . $replica_data_1['Slave_SQL_Running'] . '</td>';
    $html .= '<td class="row_1 inf_row" align="center">' . $replica_data_1['Last_SQL_Errno'] . ' / ' . $replica_data_1['Last_SQL_Error'] . '</td>';
コード例 #9
0
<?php

// Подхватываем сессию главной страницы для получения ID пользователя работающего в сессии;
session_start();
// Подключение основных функций;
include $_SERVER['DOCUMENT_ROOT'] . '/systems/image_content.php';
// Подключение к базе данных;
include $_SERVER['DOCUMENT_ROOT'] . '/systems/connect.php';
// Создание объекта MySQL;
$db_shop = new MySQL();
$db_shop->connect($db_shop_host, $db_shop_name, $db_shop_user, $db_shop_password);
// Путь к временному хранилищу фотографий;
$path = '../files/uploads/';
// Функция ответа родительской страницы загрузки файлов
function ParentReply($val)
{
    // Формируем js-файл информирующего о загрузке файла;
    $res = '<script type="text/javascript">';
    $res .= "var data = new Object;";
    foreach ($val as $key => $value) {
        $res .= 'data.' . $key . ' = "' . $value . '";';
    }
    $res .= 'window.parent.handleResponse(data);';
    $res .= "</script>";
    echo $res;
}
// Функция создание иотображения превьющек для фотографий;
function ThumbMaker()
{
    global $path;
    // Создаем массив с которым будем работать;
コード例 #10
0
ファイル: connect.php プロジェクト: uvaron/RemontoffSystem
<?php

// Подключение настроек;
include $_SERVER['DOCUMENT_ROOT'] . '/config.php';
// Подключение библиотеки MySQL;
include $_SERVER['DOCUMENT_ROOT'] . '/systems/mysql.php';
// Создание объекта MySQL;
$db = new MySQL();
$db->connect($db_host, $db_name, $db_user, $db_password);
$db_inproject = new MySQL();
$db_inproject->connect($db_inproject_host, $db_inproject_name, $db_inproject_user, $db_inproject_password);
// Кодировка;
$db->query("SET NAMES `UTF8`");
// Часовой пояс;
$db->query("SET TIME_ZONE='+06:00'");
// Кодировка;
$db_inproject->query("SET NAMES `UTF8`");
// Часовой пояс;
$db_inproject->query("SET TIME_ZONE='+06:00'");
// Функцию подключения базов элементов к рабочему столу;
function create_user_element($element_id = '')
{
    global $db_inproject;
    $result = '';
    $symbol = "'";
    $sql = "SELECT `elements`.`id` AS `id`, `elements_types`.`type_name` AS `type_name`, `elements`.`name` AS `name`, `elements`.`option` AS `option` FROM `elements`, `elements_types` WHERE `elements`.`type_id` = `elements_types`.`id` AND `elements`.`user_id` = '" . $_SESSION['user_session_login'] . "' " . ($element_id != '' ? 'AND `elements`.`id` = ' . $element_id : '') . ";";
    $user_elements = $db_inproject->all($sql);
    foreach ($user_elements as $elements) {
        // Грузим параметры каждого элемента и создаем его на рабочем столе;
        $sql = "SELECT * FROM `elements_position` WHERE `element_id` = '" . $elements['id'] . "';";
        $element_pos = $db_inproject->row($sql);
コード例 #11
0
ファイル: connect.php プロジェクト: caiodavinis/dvinesweb
<?php

include "class/class.MySQL.php";
$mySQL = new MySQL();
$mySQL->connect();
コード例 #12
0
ファイル: update.php プロジェクト: uvaron/RemontoffSystem
// Определение свободного модема;
function get_modem()
{
    $modem_id = 1101;
    return $modem_id;
}
// Создание объекта MySQL;
$db = new MySQL();
$db->connect($db_host, $db_name, $db_user, $db_password);
// Кодировка;
$db->query("SET NAMES `UTF8`");
// Часовой пояс;
$db->query("SET TIME_ZONE='+06:00'");
// Создание объекта MySQL;
$db_site = new MySQL();
$db_site->connect($db_site_host, $db_site_name, $db_site_user, $db_site_password);
// Кодировка;
$db_site->query("SET NAMES `UTF8`");
// Часовой пояс;
$db_site->query("SET TIME_ZONE='+06:00'");
// Счетчики;
$count_payments = 0;
$count_actions = 0;
$count_messages = 0;
$count_goods_delete = 0;
$count_actions_delete = 0;
$count_companies_delete = 0;
$count_money = 0;
// Срок действия акции;
$_date = date("d.m.Y", mktime(0, 0, 0, date("n"), date("j") + 14));
$_date_real = date("Y-m-d H:i:s", mktime(0, 0, 0, date("n"), date("j") + 28));
コード例 #13
0
ファイル: connect.php プロジェクト: uvaron/GUI
<?php

// Подключение настроек;
include $_SERVER['DOCUMENT_ROOT'] . '/config.php';
// Подключение библиотеки MySQL;
include $_SERVER['DOCUMENT_ROOT'] . '/systems/mysql.php';
// Создание объекта MySQL;
$db = new MySQL();
$db->connect(isset($db_localhost_force) ? $db_localhost : $db_host, $db_name, $db_user, $db_password);
// Кодировка;
$db->query("SET NAMES `UTF8`");
// Часовой пояс;
$db->query("SET TIME_ZONE='+06:00'");
// Загрузка параметров;
$sql = "CALL options()";
$options = $db->assoc($sql);
// Загрузка локальных параметров;
if (isset($options_club_id)) {
    $options['club_id'] = $options_club_id;
}
if (isset($options_cash_id)) {
    $options['cash_id'] = $options_cash_id;
}
if (isset($_COOKIE['club_id'])) {
    $options['club_id'] = $_COOKIE['club_id'];
}
if (isset($_COOKIE['cash_id'])) {
    $options['cash_id'] = $_COOKIE['cash_id'];
}
// Проверка параметров;
if (isset($_GET['terminal_id'])) {
コード例 #14
0
ファイル: connect.php プロジェクト: uvaron/RemontoffSystem
<?php

// Подключение настроек;
include $_SERVER['DOCUMENT_ROOT'] . '/config.php';
// Подключение библиотеки MySQL;
include $_SERVER['DOCUMENT_ROOT'] . '/mysql.php';
// Создание объекта MySQL;
$db = new MySQL();
$db->connect($db_host, $db_name, $db_user, $db_password);
$db->query("SET NAMES `UTF8`");
// Подключение дополнительных функций;
include $_SERVER['DOCUMENT_ROOT'] . '/functions.php';
コード例 #15
0
ファイル: users.php プロジェクト: activehelper/core
<?php

ob_start('ob_gzhandler');
include_once '../import/constants.php';
include '../import/config_database.php';
include '../import/class.mysql.php';
include '../import/functions.php';
checkSession();
// Open MySQL Connection
$SQL = new MySQL();
$SQL->connect();
if (!isset($_REQUEST['ACTION'])) {
    $_REQUEST['ACTION'] = '';
} else {
    $_REQUEST['ACTION'] = htmlspecialchars((string) $_REQUEST['ACTION'], ENT_QUOTES);
}
if (!isset($_REQUEST['ID'])) {
    $_REQUEST['ID'] = '';
} else {
    $_REQUEST['ID'] = (int) $_REQUEST['ID'];
}
if (!isset($_REQUEST['TRANSFER'])) {
    $_REQUEST['TRANSFER'] = '';
} else {
    $_REQUEST['TRANSFER'] = htmlspecialchars((string) $_REQUEST['TRANSFER'], ENT_QUOTES);
}
$action = $_REQUEST['ACTION'];
$login_id = $_REQUEST['ID'];
$transfer_id = $_REQUEST['TRANSFER'];
$id_service = isset($_REQUEST['IDSERVICE']) ? (int) $_REQUEST['IDSERVICE'] : "";
$operator_login_id = $_REQUEST['OPERATORID'] = (int) $_REQUEST['OPERATORID'];
コード例 #16
0
ファイル: Orders.php プロジェクト: atoledov/siglab
 public function generateHeader()
 {
     $_db = new MySQL();
     $_db->connect();
     $_html = "";
     $_sql = "SELECT PacIdentificacion, PacApellido, PacNombre, PacFechaNac, GeneroDescripcion,\r\n                        OrdId, OrdTurno, DATE_FORMAT(OrdFecha, '%d-%m-%Y') AS OrdFecha, MedApellido, \r\n                        MedNombre, SalaHospDescripcion, LabAreaDescripcion, CamaDescripcion,\r\n                        CASE WHEN OrdFechaIngreso!='' AND OrdFechaIngreso!='0000-00-00 00:00:00' THEN \r\n                        DATE_FORMAT(OrdFechaIngreso, '%d-%m-%Y') ELSE '' END AS OrdFechaIngreso\r\n                 FROM {$this->_table}";
     $_db->prepare($_sql);
     $_result = $_db->execute();
     if ($_db->num_rows($_result) > 0) {
         @($data = $_db->fetch_array($_result));
         $this->setOrderId($data["OrdId"]);
         $this->setTurn($data["OrdTurno"]);
         $_html .= "<table width='100%'>";
         $_html .= "<thead>";
         $_html .= "<tr>";
         $_html .= "<td width='15%'>Paciente:</td>";
         $_html .= "<td width='25%'>" . ucwords(strtolower(utf8_encode($data["PacApellido"] . " " . $data["PacNombre"]))) . "</td>";
         $_html .= "<td width='10%'>Sala:</td>";
         $_html .= "<td width='15%'>{$data["SalaHospDescripcion"]}</td>";
         $_html .= "<td width='15%'>An&aacute;isis:</td>";
         $_html .= "<td width='20%'>{$data["OrdTurno"]}</td>";
         $_html .= "</tr>";
         $_html .= "<tr>";
         $_html .= "<td>Fecha Orden:</td>";
         $_html .= "<td>{$data["OrdFecha"]}</td>";
         $_html .= "<td>Cama:</td>";
         $_html .= "<td>{$data["CamaDescripcion"]}</td>";
         $_html .= "<td>CI:</td>";
         $_html .= "<td>{$data["PacIdentificacion"]}</td>";
         $_html .= "</tr>";
         $_html .= "<tr>";
         $_html .= "<td>Fecha Ingreso:</td>";
         $_html .= "<td>{$data["OrdFechaIngreso"]}</td>";
         $_html .= "<td>Area:</td>";
         $_html .= "<td>{$data["LabAreaDescripcion"]}</td>";
         $_html .= "<td>Edad:</td>";
         $_html .= "<td>" . Util::getAge($data["PacFechaNac"]) . " a&ntilde;os</td>";
         $_html .= "</tr>";
         $_html .= "<tr>";
         $_html .= "<td>Medico:</td>";
         $_html .= "<td>" . ucwords(strtolower(utf8_encode($data["MedApellido"] . " " . $data["MedNombre"]))) . "</td>";
         $_html .= "<td></td>";
         $_html .= "<td></td>";
         $_html .= "<td>Sexo:</td>";
         $_html .= "<td>" . ucwords(strtolower($data["GeneroDescripcion"])) . "</td>";
         $_html .= "</tr>";
         $_html .= "</thead>";
         $_html .= "</table>";
     }
     return $_html;
 }
コード例 #17
0
ファイル: PromoteSquadMember.php プロジェクト: reyden/FINAL
        $nav_admin_menu = "<a href='PromoteSquadMember.php'>Promote Squad Member</a>";
    } else {
        $err_flag = TRUE;
        //Location("header : index.php");
        //exit();
    }
}
if (!$err_flag) {
    //states : View, Start Promotion, Checking Done
    //transitions: view-> edit, edit ->update, update->views,  or *->view * (default)
    $form_opt_menu_open = "";
    $form_opt_menu_close = "";
    //Connect to database and make connection
    $con = new MySQL("localhost", MYSQL_USERNAME, MYSQL_PASSWORD, MYSQL_DATABASE);
    try {
        $con->connect();
    } catch (Exception $e) {
        echo $e->getMessage();
    }
    $sqd = new SquadDao($con);
    $result_array = $sqd->getAllCandidateForPromotion();
    //initialize parameter for content generations
    $table_head = "";
    $table = "";
    $i = 0;
    $c = count($result_array);
    $page_state = "";
    $candidates = array();
    //view => edit
    //	if(isset($_POST['submit'])){
    //		print "<p>Post Captured value: $_POST['submit']</p>";
コード例 #18
0
ファイル: connect.php プロジェクト: uvaron/BDparser
// Подключаем объекты для работы с базой SERV4;
if (!isset($db)) {
    $db = new MySQL();
    if ($use_training_bd == true) {
        $db->connect($training_remontoff_host, $training_remontoff_db, $training_remontoff_user, $training_remontoff_password);
    } else {
        $db->connect($production_remontoff_host, $production_remontoff_db, $production_remontoff_user, $production_remontoff_password);
    }
    // Кодировка;
    $db->query("SET NAMES `UTF8`");
    write_log('DB Для SERV4 подключили');
}
if (!isset($db_rs)) {
    $db_rs = new MySQL();
    if ($use_training_bd == true) {
        $db_rs->connect($training_remontoff_host, $training_remontoff_db_system, $training_remontoff_user, $training_remontoff_password);
    } else {
        $db_rs->connect($production_remontoff_host, $production_remontoff_db_system, $production_remontoff_user, $production_remontoff_password);
    }
    // Кодировка;
    $db_rs->query("SET NAMES `UTF8`");
    write_log('DB Для Системы Remontoff подключили');
}
/*
 *
 * Подключение объекты классов;
 *
 * */
if (!isset($elements)) {
    $elements = new page_elements();
}
コード例 #19
0
ファイル: db_parser.php プロジェクト: uvaron/BDparser
/**
 * Created by PhpStorm.
 * User: admin64
 * Date: 17.01.2016
 * Time: 11:47
 */
error_reporting(E_ALL);
session_start();
// Подключение к базе данных;
include $_SERVER['DOCUMENT_ROOT'] . '/connect.php';
$db_rem = new MySQL();
$db_rem->connect($db_remontoff_host, $db_remontoff_name, $db_remontoff_user, $db_remontoff_password);
$db_rem->query("SET NAMES `UTF8`");
$db_new = new MySQL();
$db_new->connect($db_new_host, $db_new_name, $db_new_user, $db_new_password);
$db_new->query("SET NAMES `UTF8`");
// Собираем данные со всей таблицы и готовим ее к экспорту;
$sql = "SELECT * FROM `remont` LIMIT 500";
$remontoff_old_data_array = $db_rem->all($sql);
// Объявляем резльутируюий массив;
$result_array = array();
// Пробегаемся по каждой записи массива;
foreach ($remontoff_old_data_array as $remontoff_old_data) {
    // Самая главная плюшка;
    $numm = $remontoff_old_data['numm'];
    echo $numm . '<br>';
    // Проверяем есть ли у же такая запись о ремонте;
    $sql = "SELECT `numm` FROM `remont` WHERE `numm` = '" . $numm . "';";
    $exist_numm = $db_new->one($sql);
    if ($exist_numm != '') {
コード例 #20
0
    function install(&$Page, $fields)
    {
        global $warnings;
        $database_connection_error = false;
        try {
            $db = new MySQL();
            $db->connect($fields['database']['host'], $fields['database']['username'], $fields['database']['password'], $fields['database']['port']);
            $tables = $db->fetch(sprintf("SHOW TABLES FROM `%s` LIKE '%s'", mysql_escape_string($fields['database']['name']), mysql_escape_string($fields['database']['prefix']) . '%'));
        } catch (DatabaseException $e) {
            $database_connection_error = true;
        }
        ## Invalid path
        if (!@is_dir(rtrim($fields['docroot'], '/') . '/symphony')) {
            $Page->log->pushToLog("Configuration - Bad Document Root Specified: " . $fields['docroot'], E_NOTICE, true);
            define("kENVIRONMENT_WARNING", true);
            if (!defined("ERROR")) {
                define("ERROR", 'no-symphony-dir');
            }
        } elseif (is_file(rtrim($fields['docroot'], '/') . '/.htaccess')) {
            $Page->log->pushToLog("Configuration - Existing '.htaccess' file found: " . $fields['docroot'] . '/.htaccess', E_NOTICE, true);
            define("kENVIRONMENT_WARNING", true);
            if (!defined("ERROR")) {
                define("ERROR", 'existing-htaccess');
            }
        } elseif (is_dir(rtrim($fields['docroot'], '/') . '/workspace') && !is_writable(rtrim($fields['docroot'], '/') . '/workspace')) {
            $Page->log->pushToLog("Configuration - Workspace folder not writable: " . $fields['docroot'] . '/workspace', E_NOTICE, true);
            define("kENVIRONMENT_WARNING", true);
            if (!defined("ERROR")) {
                define("ERROR", 'no-write-permission-workspace');
            }
        } elseif (!is_writable(rtrim($fields['docroot'], '/'))) {
            $Page->log->pushToLog("Configuration - Root folder not writable: " . $fields['docroot'], E_NOTICE, true);
            define("kENVIRONMENT_WARNING", true);
            if (!defined("ERROR")) {
                define("ERROR", 'no-write-permission-root');
            }
        } elseif ($database_connection_error) {
            $Page->log->pushToLog("Configuration - Could not establish database connection", E_NOTICE, true);
            define("kDATABASE_CONNECTION_WARNING", true);
            if (!defined("ERROR")) {
                define("ERROR", 'no-database-connection');
            }
        } elseif (version_compare($db->fetchVar('version', 0, "SELECT VERSION() AS `version`;"), '4.1', '<')) {
            $version = $db->fetchVar('version', 0, "SELECT VERSION() AS `version`;");
            $Page->log->pushToLog('Configuration - MySQL Version is not correct. ' . $version . ' detected.', E_NOTICE, true);
            define("kDATABASE_VERSION_WARNING", true);
            $warnings['database-incorrect-version'] = __('Symphony requires <code>MySQL 4.1</code> or greater to work, however version <code>%s</code> was detected. This requirement must be met before installation can proceed.', array($version));
            if (!defined("ERROR")) {
                define("ERROR", 'database-incorrect-version');
            }
        } elseif (!$db->select($fields['database']['name'])) {
            $Page->log->pushToLog("Configuration - Database '" . $fields['database']['name'] . "' Not Found", E_NOTICE, true);
            define("kDATABASE_CONNECTION_WARNING", true);
            if (!defined("ERROR")) {
                define("ERROR", 'no-database-connection');
            }
        } elseif (is_array($tables) && !empty($tables)) {
            $Page->log->pushToLog("Configuration - Database table prefix clash with '" . $fields['database']['name'] . "'", E_NOTICE, true);
            define("kDATABASE_PREFIX_WARNING", true);
            if (!defined("ERROR")) {
                define("ERROR", 'database-table-clash');
            }
        } elseif (trim($fields['user']['username']) == '') {
            $Page->log->pushToLog("Configuration - No username entered.", E_NOTICE, true);
            define("kUSER_USERNAME_WARNING", true);
            if (!defined("ERROR")) {
                define("ERROR", 'user-no-username');
            }
        } elseif (trim($fields['user']['password']) == '') {
            $Page->log->pushToLog("Configuration - No password entered.", E_NOTICE, true);
            define("kUSER_PASSWORD_WARNING", true);
            if (!defined("ERROR")) {
                define("ERROR", 'user-no-password');
            }
        } elseif ($fields['user']['password'] != $fields['user']['confirm-password']) {
            $Page->log->pushToLog("Configuration - Passwords did not match.", E_NOTICE, true);
            define("kUSER_PASSWORD_WARNING", true);
            if (!defined("ERROR")) {
                define("ERROR", 'user-password-mismatch');
            }
        } elseif (trim($fields['user']['firstname']) == '' || trim($fields['user']['lastname']) == '') {
            $Page->log->pushToLog("Configuration - Did not enter First and Last names.", E_NOTICE, true);
            define("kUSER_NAME_WARNING", true);
            if (!defined("ERROR")) {
                define("ERROR", 'user-no-name');
            }
        } elseif (!preg_match('/^\\w(?:\\.?[\\w%+-]+)*@\\w(?:[\\w-]*\\.)+?[a-z]{2,}$/i', $fields['user']['email'])) {
            $Page->log->pushToLog("Configuration - Invalid email address supplied.", E_NOTICE, true);
            define("kUSER_EMAIL_WARNING", true);
            if (!defined("ERROR")) {
                define("ERROR", 'user-invalid-email');
            }
        } else {
            $config = $fields;
            $kDOCROOT = rtrim($config['docroot'], '/');
            $database = array_map("trim", $fields['database']);
            if (!isset($database['host']) || $database['host'] == "") {
                $database['host'] = "localhost";
            }
            if (!isset($database['port']) || $database['port'] == "") {
                $database['port'] = "3306";
            }
            if (!isset($database['prefix']) || $database['prefix'] == "") {
                $database['prefix'] = "sym_";
            }
            $install_log = $Page->log;
            $start = time();
            $install_log->writeToLog(CRLF . '============================================', true);
            $install_log->writeToLog('INSTALLATION PROCESS STARTED (' . DateTimeObj::get('c') . ')', true);
            $install_log->writeToLog('============================================', true);
            $install_log->pushToLog("MYSQL: Establishing Connection...", E_NOTICE, true, false);
            $db = new MySQL();
            if (!$db->connect($database['host'], $database['username'], $database['password'], $database['port'])) {
                define('_INSTALL_ERRORS_', "There was a problem while trying to establish a connection to the MySQL server. Please check your settings.");
                $install_log->pushToLog("Failed", E_NOTICE, true, true, true);
                installResult($Page, $install_log, $start);
            } else {
                $install_log->pushToLog("Done", E_NOTICE, true, true, true);
            }
            $install_log->pushToLog("MYSQL: Selecting Database '" . $database['name'] . "'...", E_NOTICE, true, false);
            if (!$db->select($database['name'])) {
                define('_INSTALL_ERRORS_', "Could not connect to specified database. Please check your settings.");
                $install_log->pushToLog("Failed", E_NOTICE, true, true, true);
                installResult($Page, $install_log, $start);
            } else {
                $install_log->pushToLog("Done", E_NOTICE, true, true, true);
            }
            $db->setPrefix($database['prefix']);
            $conf = getDynamicConfiguration();
            if ($conf['database']['runtime_character_set_alter'] == '1') {
                $db->setCharacterEncoding($conf['database']['character_encoding']);
                $db->setCharacterSet($conf['database']['character_set']);
            }
            $install_log->pushToLog("MYSQL: Importing Table Schema...", E_NOTICE, true, false);
            $error = NULL;
            if (!fireSql($db, getTableSchema(), $error, $config['database']['high-compatibility'] == 'yes' ? 'high' : 'normal')) {
                define('_INSTALL_ERRORS_', "There was an error while trying to import data to the database. MySQL returned: {$error}");
                $install_log->pushToLog("Failed", E_ERROR, true, true, true);
                installResult($Page, $install_log, $start);
            } else {
                $install_log->pushToLog("Done", E_NOTICE, true, true, true);
            }
            $author_sql = sprintf("INSERT INTO  `tbl_authors` (\n\t\t\t\t\t\t`id` , \n\t\t\t\t\t\t`username` , \n\t\t\t\t\t\t`password` , \n\t\t\t\t\t\t`first_name` , \n\t\t\t\t\t\t`last_name` , \n\t\t\t\t\t\t`email` , \n\t\t\t\t\t\t`last_seen` , \n\t\t\t\t\t\t`user_type` , \n\t\t\t\t\t\t`primary` , \n\t\t\t\t\t\t`default_section` , \n\t\t\t\t\t\t`auth_token_active`\n\t\t\t\t\t)\n\t\t\t\t\tVALUES (\n\t\t\t\t\t\t1,\n\t\t\t\t\t\t'%s',\n\t\t\t\t\t\tMD5('%s'),\n\t\t\t\t\t\t'%s',  \n\t\t\t\t\t\t'%s',  \n\t\t\t\t\t\t'%s', \n\t\t\t\t\t\tNULL ,  \n\t\t\t\t\t\t'developer',  \n\t\t\t\t\t\t'yes',  \n\t\t\t\t\t\t'6',  \n\t\t\t\t\t\t'no'\n\t\t\t\t\t);", $db->cleanValue($config['user']['username']), $db->cleanValue($config['user']['password']), $db->cleanValue($config['user']['firstname']), $db->cleanValue($config['user']['lastname']), $db->cleanValue($config['user']['email']));
            $install_log->pushToLog("MYSQL: Creating Default Author...", E_NOTICE, true, false);
            if (!$db->query($author_sql)) {
                $error = $db->getLastError();
                define('_INSTALL_ERRORS_', "There was an error while trying create the default author. MySQL returned: " . $error['num'] . ': ' . $error['msg']);
                $install_log->pushToLog("Failed", E_ERROR, true, true, true);
                installResult($Page, $install_log, $start);
            } else {
                $install_log->pushToLog("Done", E_NOTICE, true, true, true);
            }
            $conf = array();
            if (@is_dir($fields['docroot'] . '/workspace')) {
                foreach (getDynamicConfiguration() as $group => $settings) {
                    if (!is_array($conf['settings'][$group])) {
                        $conf['settings'][$group] = array();
                    }
                    $conf['settings'][$group] = array_merge($conf['settings'][$group], $settings);
                }
            } else {
                $conf['settings']['admin']['max_upload_size'] = '5242880';
                $conf['settings']['symphony']['pagination_maximum_rows'] = '17';
                $conf['settings']['symphony']['allow_page_subscription'] = '1';
                $conf['settings']['symphony']['lang'] = defined('__LANG__') ? __LANG__ : 'en';
                $conf['settings']['symphony']['pages_table_nest_children'] = 'no';
                $conf['settings']['log']['archive'] = '1';
                $conf['settings']['log']['maxsize'] = '102400';
                $conf['settings']['image']['cache'] = '1';
                $conf['settings']['image']['quality'] = '90';
                $conf['settings']['database']['driver'] = 'mysql';
                $conf['settings']['database']['character_set'] = 'utf8';
                $conf['settings']['database']['character_encoding'] = 'utf8';
                $conf['settings']['database']['runtime_character_set_alter'] = '1';
                $conf['settings']['public']['display_event_xml_in_source'] = 'no';
            }
            $conf['settings']['symphony']['version'] = kVERSION;
            $conf['settings']['symphony']['cookie_prefix'] = 'sym-';
            $conf['settings']['general']['useragent'] = 'Symphony/' . kVERSION;
            $conf['settings']['general']['sitename'] = strlen(trim($config['general']['sitename'])) > 0 ? $config['general']['sitename'] : __('Website Name');
            $conf['settings']['file']['write_mode'] = $config['permission']['file'];
            $conf['settings']['directory']['write_mode'] = $config['permission']['directory'];
            $conf['settings']['database']['host'] = $database['host'];
            $conf['settings']['database']['port'] = $database['port'];
            $conf['settings']['database']['user'] = $database['username'];
            $conf['settings']['database']['password'] = $database['password'];
            $conf['settings']['database']['db'] = $database['name'];
            $conf['settings']['database']['tbl_prefix'] = $database['prefix'];
            $conf['settings']['region']['time_format'] = $config['region']['time_format'];
            $conf['settings']['region']['date_format'] = $config['region']['date_format'];
            $conf['settings']['region']['timezone'] = $config['region']['timezone'];
            ## Create Manifest directory structure
            #
            $install_log->pushToLog("WRITING: Creating 'manifest' folder (/manifest)", E_NOTICE, true, true);
            if (!GeneralExtended::realiseDirectory($kDOCROOT . '/manifest', $conf['settings']['directory']['write_mode'])) {
                define('_INSTALL_ERRORS_', "Could not create 'manifest' directory. Check permission on the root folder.");
                $install_log->pushToLog("ERROR: Creation of 'manifest' folder failed.", E_ERROR, true, true);
                installResult($Page, $install_log, $start);
                return;
            }
            $install_log->pushToLog("WRITING: Creating 'logs' folder (/manifest/logs)", E_NOTICE, true, true);
            if (!GeneralExtended::realiseDirectory($kDOCROOT . '/manifest/logs', $conf['settings']['directory']['write_mode'])) {
                define('_INSTALL_ERRORS_', "Could not create 'logs' directory. Check permission on /manifest.");
                $install_log->pushToLog("ERROR: Creation of 'logs' folder failed.", E_ERROR, true, true);
                installResult($Page, $install_log, $start);
                return;
            }
            $install_log->pushToLog("WRITING: Creating 'cache' folder (/manifest/cache)", E_NOTICE, true, true);
            if (!GeneralExtended::realiseDirectory($kDOCROOT . '/manifest/cache', $conf['settings']['directory']['write_mode'])) {
                define('_INSTALL_ERRORS_', "Could not create 'cache' directory. Check permission on /manifest.");
                $install_log->pushToLog("ERROR: Creation of 'cache' folder failed.", E_ERROR, true, true);
                installResult($Page, $install_log, $start);
                return;
            }
            $install_log->pushToLog("WRITING: Creating 'tmp' folder (/manifest/tmp)", E_NOTICE, true, true);
            if (!GeneralExtended::realiseDirectory($kDOCROOT . '/manifest/tmp', $conf['settings']['directory']['write_mode'])) {
                define('_INSTALL_ERRORS_', "Could not create 'tmp' directory. Check permission on /manifest.");
                $install_log->pushToLog("ERROR: Creation of 'tmp' folder failed.", E_ERROR, true, true);
                installResult($Page, $install_log, $start);
                return;
            }
            $install_log->pushToLog("WRITING: Configuration File", E_NOTICE, true, true);
            if (!writeConfig($kDOCROOT . '/manifest/', $conf, $conf['settings']['file']['write_mode'])) {
                define('_INSTALL_ERRORS_', "Could not write config file. Check permission on /manifest.");
                $install_log->pushToLog("ERROR: Writing Configuration File Failed", E_ERROR, true, true);
                installResult($Page, $install_log, $start);
            }
            $rewrite_base = trim(dirname($_SERVER['PHP_SELF']), '/');
            if (strlen($rewrite_base) > 0) {
                $rewrite_base .= '/';
            }
            $htaccess = '
### Symphony 2.0.x ###
Options +FollowSymlinks

<IfModule mod_rewrite.c>

	RewriteEngine on
	RewriteBase /' . $rewrite_base . '

	### DO NOT APPLY RULES WHEN REQUESTING "favicon.ico"
	RewriteCond %{REQUEST_FILENAME} favicon.ico [NC]
	RewriteRule .* - [S=14]	

	### IMAGE RULES	
	RewriteRule ^image\\/(.+\\.(jpg|gif|jpeg|png|bmp))$ extensions/jit_image_manipulation/lib/image.php?param=$1 [L,NC]

	### CHECK FOR TRAILING SLASH - Will ignore files
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteCond %{REQUEST_URI} !/$
	RewriteCond %{REQUEST_URI} !(.*)/$
	RewriteRule ^(.*)$ $1/ [L,R=301]

	### ADMIN REWRITE
	RewriteRule ^symphony\\/?$ index.php?mode=administration&%{QUERY_STRING} [NC,L]

	RewriteCond %{REQUEST_FILENAME} !-d
	RewriteCond %{REQUEST_FILENAME} !-f	
	RewriteRule ^symphony(\\/(.*\\/?))?$ index.php?symphony-page=$1&mode=administration&%{QUERY_STRING}	[NC,L]

	### FRONTEND REWRITE - Will ignore files and folders
	RewriteCond %{REQUEST_FILENAME} !-d
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteRule ^(.*\\/?)$ index.php?symphony-page=$1&%{QUERY_STRING}	[L]
	
</IfModule>
######
';
            $install_log->pushToLog("CONFIGURING: Frontend", E_NOTICE, true, true);
            if (!GeneralExtended::writeFile($kDOCROOT . "/.htaccess", $htaccess, $conf['settings']['file']['write_mode'])) {
                define('_INSTALL_ERRORS_', "Could not write .htaccess file. Check permission on " . $kDOCROOT);
                $install_log->pushToLog("ERROR: Writing .htaccess File Failed", E_ERROR, true, true);
                installResult($Page, $install_log, $start);
            }
            if (@(!is_dir($fields['docroot'] . '/workspace'))) {
                ### Create the workspace folder structure
                #
                $install_log->pushToLog("WRITING: Creating 'workspace' folder (/workspace)", E_NOTICE, true, true);
                if (!GeneralExtended::realiseDirectory($kDOCROOT . '/workspace', $conf['settings']['directory']['write_mode'])) {
                    define('_INSTALL_ERRORS_', "Could not create 'workspace' directory. Check permission on the root folder.");
                    $install_log->pushToLog("ERROR: Creation of 'workspace' folder failed.", E_ERROR, true, true);
                    installResult($Page, $install_log, $start);
                    return;
                }
                $install_log->pushToLog("WRITING: Creating 'data-sources' folder (/workspace/data-sources)", E_NOTICE, true, true);
                if (!GeneralExtended::realiseDirectory($kDOCROOT . '/workspace/data-sources', $conf['settings']['directory']['write_mode'])) {
                    define('_INSTALL_ERRORS_', "Could not create 'workspace/data-sources' directory. Check permission on the root folder.");
                    $install_log->pushToLog("ERROR: Creation of 'workspace/data-sources' folder failed.", E_ERROR, true, true);
                    installResult($Page, $install_log, $start);
                    return;
                }
                $install_log->pushToLog("WRITING: Creating 'events' folder (/workspace/events)", E_NOTICE, true, true);
                if (!GeneralExtended::realiseDirectory($kDOCROOT . '/workspace/events', $conf['settings']['directory']['write_mode'])) {
                    define('_INSTALL_ERRORS_', "Could not create 'workspace/events' directory. Check permission on the root folder.");
                    $install_log->pushToLog("ERROR: Creation of 'workspace/events' folder failed.", E_ERROR, true, true);
                    installResult($Page, $install_log, $start);
                    return;
                }
                $install_log->pushToLog("WRITING: Creating 'pages' folder (/workspace/pages)", E_NOTICE, true, true);
                if (!GeneralExtended::realiseDirectory($kDOCROOT . '/workspace/pages', $conf['settings']['directory']['write_mode'])) {
                    define('_INSTALL_ERRORS_', "Could not create 'workspace/pages' directory. Check permission on the root folder.");
                    $install_log->pushToLog("ERROR: Creation of 'workspace/pages' folder failed.", E_ERROR, true, true);
                    installResult($Page, $install_log, $start);
                    return;
                }
                $install_log->pushToLog("WRITING: Creating 'utilities' folder (/workspace/utilities)", E_NOTICE, true, true);
                if (!GeneralExtended::realiseDirectory($kDOCROOT . '/workspace/utilities', $conf['settings']['directory']['write_mode'])) {
                    define('_INSTALL_ERRORS_', "Could not create 'workspace/utilities' directory. Check permission on the root folder.");
                    $install_log->pushToLog("ERROR: Creation of 'workspace/utilities' folder failed.", E_ERROR, true, true);
                    installResult($Page, $install_log, $start);
                    return;
                }
            } else {
                $install_log->pushToLog("MYSQL: Importing Workspace Data...", E_NOTICE, true, false);
                $error = NULL;
                if (!fireSql($db, getWorkspaceData(), $error, $config['database']['high-compatibility'] == 'yes' ? 'high' : 'normal')) {
                    define('_INSTALL_ERRORS_', "There was an error while trying to import data to the database. MySQL returned: {$error}");
                    $install_log->pushToLog("Failed", E_ERROR, true, true, true);
                    installResult($Page, $install_log, $start);
                } else {
                    $install_log->pushToLog("Done", E_NOTICE, true, true, true);
                }
            }
            if (@(!is_dir($fields['docroot'] . '/extensions'))) {
                $install_log->pushToLog("WRITING: Creating 'campfire' folder (/extensions)", E_NOTICE, true, true);
                if (!GeneralExtended::realiseDirectory($kDOCROOT . '/extensions', $conf['settings']['directory']['write_mode'])) {
                    define('_INSTALL_ERRORS_', "Could not create 'extensions' directory. Check permission on the root folder.");
                    $install_log->pushToLog("ERROR: Creation of 'extensions' folder failed.", E_ERROR, true, true);
                    installResult($Page, $install_log, $start);
                    return;
                }
            }
            $install_log->pushToLog("Installation Process Completed In " . max(1, time() - $start) . " sec", E_NOTICE, true);
            installResult($Page, $install_log, $start);
            redirect('http://' . rtrim(str_replace('http://', '', _INSTALL_DOMAIN_), '/') . '/symphony/');
        }
    }
コード例 #21
0
ファイル: install.php プロジェクト: symphonycms/symphony-1.7
    function install(&$Page, $fields)
    {
        $db = new MySQL();
        $db->connect($fields['database']['host'], $fields['database']['username'], $fields['database']['password'], $fields['database']['port']);
        if ($db->isConnected()) {
            $tables = $db->fetch("SHOW TABLES FROM `" . $fields['database']['name'] . "` LIKE '" . mysql_escape_string($fields['database']['prefix']) . "%'");
        }
        ## Invalid path
        if (!@is_dir(rtrim($fields['docroot'], '/') . '/symphony')) {
            $Page->log->pushToLog("Configuration - Bad Document Root Specified: " . $fields['docroot'], SYM_LOG_NOTICE, true);
            define("kENVIRONMENT_WARNING", true);
            if (!defined("ERROR")) {
                define("ERROR", 'no-symphony-dir');
            }
        } elseif (is_file(rtrim($fields['docroot'], '/') . '/.htaccess')) {
            $Page->log->pushToLog("Configuration - Existing '.htaccess' file found: " . $fields['docroot'] . '/.htaccess', SYM_LOG_NOTICE, true);
            define("kENVIRONMENT_WARNING", true);
            if (!defined("ERROR")) {
                define("ERROR", 'existing-htaccess');
            }
        } elseif (is_dir(rtrim($fields['docroot'], '/') . '/workspace') && !is_writable(rtrim($fields['docroot'], '/') . '/workspace')) {
            $Page->log->pushToLog("Configuration - Workspace folder not writable: " . $fields['docroot'] . '/workspace', SYM_LOG_NOTICE, true);
            define("kENVIRONMENT_WARNING", true);
            if (!defined("ERROR")) {
                define("ERROR", 'no-write-permission-workspace');
            }
        } elseif (!is_writable(rtrim($fields['docroot'], '/'))) {
            $Page->log->pushToLog("Configuration - Root folder not writable: " . $fields['docroot'], SYM_LOG_NOTICE, true);
            define("kENVIRONMENT_WARNING", true);
            if (!defined("ERROR")) {
                define("ERROR", 'no-write-permission-root');
            }
        } elseif (!$db->isConnected()) {
            $Page->log->pushToLog("Configuration - Could not establish database connection", SYM_LOG_NOTICE, true);
            define("kDATABASE_CONNECTION_WARNING", true);
            if (!defined("ERROR")) {
                define("ERROR", 'no-database-connection');
            }
        } elseif (!$db->select($fields['database']['name'])) {
            $Page->log->pushToLog("Configuration - Database '" . $fields['database']['name'] . "' Not Found", SYM_LOG_NOTICE, true);
            define("kDATABASE_CONNECTION_WARNING", true);
            if (!defined("ERROR")) {
                define("ERROR", 'no-database-connection');
            }
        } elseif (is_array($tables) && !empty($tables)) {
            $Page->log->pushToLog("Configuration - Database table prefix clash with '" . $fields['database']['name'] . "'", SYM_LOG_NOTICE, true);
            define("kDATABASE_PREFIX_WARNING", true);
            if (!defined("ERROR")) {
                define("ERROR", 'database-table-clash');
            }
        } elseif (trim($fields['user']['username']) == '') {
            $Page->log->pushToLog("Configuration - No username entered.", SYM_LOG_NOTICE, true);
            define("kUSER_USERNAME_WARNING", true);
            if (!defined("ERROR")) {
                define("ERROR", 'user-no-username');
            }
        } elseif (trim($fields['user']['password']) == '') {
            $Page->log->pushToLog("Configuration - No password entered.", SYM_LOG_NOTICE, true);
            define("kUSER_PASSWORD_WARNING", true);
            if (!defined("ERROR")) {
                define("ERROR", 'user-no-password');
            }
        } elseif ($fields['user']['password'] != $fields['user']['confirm-password']) {
            $Page->log->pushToLog("Configuration - Passwords did not match.", SYM_LOG_NOTICE, true);
            define("kUSER_PASSWORD_WARNING", true);
            if (!defined("ERROR")) {
                define("ERROR", 'user-password-mismatch');
            }
        } elseif (trim($fields['user']['firstname']) == '' || trim($fields['user']['lastname']) == '') {
            $Page->log->pushToLog("Configuration - Did not enter First and Last names.", SYM_LOG_NOTICE, true);
            define("kUSER_NAME_WARNING", true);
            if (!defined("ERROR")) {
                define("ERROR", 'user-no-name');
            }
        } elseif (!ereg('^[a-zA-Z0-9_\\.\\-]+@[a-zA-Z0-9\\-]+\\.[a-zA-Z0-9\\-\\.]+$', $fields['user']['email'])) {
            $Page->log->pushToLog("Configuration - Invalid email address supplied.", SYM_LOG_NOTICE, true);
            define("kUSER_EMAIL_WARNING", true);
            if (!defined("ERROR")) {
                define("ERROR", 'user-invalid-email');
            }
        } else {
            $config = $fields;
            $kDOCROOT = rtrim($config['docroot'], '/');
            $database = array_map("trim", $fields['database']);
            if (!isset($database['host']) || $database['host'] == "") {
                $database['host'] = "localhost";
            }
            if (!isset($database['port']) || $database['port'] == "") {
                $database['port'] = "3306";
            }
            if (!isset($database['prefix']) || $database['prefix'] == "") {
                $database['prefix'] = "sym_";
            }
            $install_log = $Page->log;
            $start = time();
            $install_log->writeToLog(CRLF . '============================================', true);
            $install_log->writeToLog('INSTALLATION PROCESS STARTED (' . date("d.m.y H:i:s") . ')', true);
            $install_log->writeToLog('============================================', true);
            $db = new MySQL();
            $install_log->pushToLog("MYSQL: Establishing Connection...", SYM_LOG_NOTICE, true, false);
            $db = new MySQL();
            if (!$db->connect($database['host'], $database['username'], $database['password'], $database['port'])) {
                define("_INSTALL_ERRORS_", "There was a problem while trying to establish a connection to the MySQL server. Please check your settings.");
                $install_log->pushToLog("Failed", SYM_LOG_NOTICE, true, true, true);
                installResult($Page, $install_log, $start);
            } else {
                $install_log->pushToLog("Done", SYM_LOG_NOTICE, true, true, true);
            }
            $install_log->pushToLog("MYSQL: Selecting Database '" . $database['name'] . "'...", SYM_LOG_NOTICE, true, false);
            if (!$db->select($database['name'])) {
                define("_INSTALL_ERRORS_", "Could not connect to specified database. Please check your settings.");
                $install_log->pushToLog("Failed", SYM_LOG_NOTICE, true, true, true);
                installResult($Page, $install_log, $start);
            } else {
                $install_log->pushToLog("Done", SYM_LOG_NOTICE, true, true, true);
            }
            $db->setPrefix($database['prefix']);
            $install_log->pushToLog("MYSQL: Creating Tables...", SYM_LOG_NOTICE, true, false);
            $error = NULL;
            if (!fireSql($db, getTableSchema(), $error, $config['database']['high-compatibility'] == 'yes' ? 'high' : 'normal')) {
                define("_INSTALL_ERRORS_", "There was an error while trying to create tables in the database. MySQL returned: {$error}");
                $install_log->pushToLog("Failed", SYM_LOG_ERROR, true, true, true);
                installResult($Page, $install_log, $start);
            } else {
                $install_log->pushToLog("Done", SYM_LOG_NOTICE, true, true, true);
            }
            $author_sql = "INSERT INTO `tbl_authors` " . "(username, password, firstname, lastname, email, superuser, owner, textformat) " . "VALUES (" . "'" . $config['user']['username'] . "', " . "'" . md5($config['user']['password']) . "', " . "'" . $config['user']['firstname'] . "', " . "'" . $config['user']['lastname'] . "', " . "'" . $config['user']['email'] . "', " . "'1', '1', 'simplehtml' )";
            $error = NULL;
            $db->query($author_sql, $error);
            if (!empty($error)) {
                define("_INSTALL_ERRORS_", "There was an error while trying create the default author. MySQL returned: {$error}");
                $install_log->pushToLog("Failed", SYM_LOG_ERROR, true, true, true);
                installResult($Page, $install_log, $start);
            } else {
                $install_log->pushToLog("Done", SYM_LOG_NOTICE, true, true, true);
            }
            $conf = array();
            $conf['define'] = array('DOCROOT' => $kDOCROOT, 'DOMAIN' => str_replace("http://", "", _INSTALL_DOMAIN_));
            $conf['require'] = array($kDOCROOT . '/symphony/lib/boot/bundle.php');
            $conf['settings']['admin']['max_upload_size'] = '5242880';
            $conf['settings']['admin']['handle_length'] = '50';
            $conf['settings']['filemanager']['filetype_restriction'] = 'bmp, jpg, gif, png, doc, rtf, pdf, zip';
            $conf['settings']['filemanager']['enabled'] = 'yes';
            $conf['settings']['filemanager']['log_all_upload_attempts'] = 'yes';
            $conf['settings']['symphony']['build'] = kBUILD;
            $conf['settings']['symphony']['acct_server'] = kSUPPORT_SERVER;
            $conf['settings']['symphony']['update'] = '5';
            $conf['settings']['symphony']['lastupdatecheck'] = time();
            $conf['settings']['symphony']['prune_logs'] = '1';
            $conf['settings']['symphony']['allow_page_subscription'] = '1';
            $conf['settings']['symphony']['strict_section_field_validation'] = '1';
            $conf['settings']['symphony']['allow_primary_field_handles_to_change'] = '1';
            $conf['settings']['symphony']['pagination_maximum_rows'] = '17';
            $conf['settings']['symphony']['cookie_prefix'] = 'sym_';
            $conf['settings']['xsl']['exclude-parameter-declarations'] = 'off';
            if ($config['theme'] == 'yes') {
                $conf['settings']['general']['sitename'] = 'Symphony Web Publishing System';
            } else {
                $conf['settings']['general']['sitename'] = 'Website Name';
            }
            $conf['settings']['general']['useragent'] = 'Symphony/' . kBUILD;
            $conf['settings']['image']['cache'] = '1';
            $conf['settings']['image']['quality'] = '70';
            $conf['settings']['file']['extend_timeout'] = 'off';
            $conf['settings']['file']['write_mode'] = $config['permission']['file'];
            $conf['settings']['directory']['write_mode'] = $config['permission']['directory'];
            $conf['settings']['database']['driver'] = 'MySQL';
            $conf['settings']['database']['host'] = $database['host'];
            $conf['settings']['database']['port'] = $database['port'];
            $conf['settings']['database']['user'] = $database['username'];
            $conf['settings']['database']['password'] = $database['password'];
            $conf['settings']['database']['db'] = $database['name'];
            $conf['settings']['database']['tbl_prefix'] = $database['prefix'];
            $conf['settings']['database']['character_set'] = 'utf8';
            $conf['settings']['database']['character_encoding'] = 'utf8';
            $conf['settings']['database']['runtime_character_set_alter'] = '0';
            $conf['settings']['public']['status'] = 'online';
            $conf['settings']['public']['caching'] = 'on';
            $conf['settings']['public']['excerpt-length'] = '100';
            $conf['settings']['region']['time_zone'] = '10';
            $conf['settings']['region']['time_format'] = 'g:i a';
            $conf['settings']['region']['date_format'] = 'j F Y';
            $conf['settings']['region']['dst'] = 'no';
            $conf['settings']['workspace']['config_checksum'] = '';
            $conf['settings']['commenting']['allow-by-default'] = 'on';
            $conf['settings']['commenting']['email-notify'] = 'off';
            $conf['settings']['commenting']['allow-duplicates'] = 'off';
            $conf['settings']['commenting']['maximum-allowed-links'] = '3';
            $conf['settings']['commenting']['banned-words'] = '';
            $conf['settings']['commenting']['banned-words-replacement'] = '*****';
            $conf['settings']['commenting']['hide-spam-flagged'] = 'on';
            $conf['settings']['commenting']['formatting-type'] = 'simplehtml';
            $conf['settings']['commenting']['add-nofollow'] = 'off';
            $conf['settings']['commenting']['convert-urls'] = 'off';
            $conf['settings']['commenting']['check-referer'] = 'on';
            $conf['settings']['commenting']['nuke-spam'] = 'on';
            $conf['settings']['commenting']['ip-blacklist'] = '';
            ## Create Manifest directory structure
            #
            $install_log->pushToLog("WRITING: Creating 'manifest' folder (/manifest)", SYM_LOG_NOTICE, true, true);
            if (!GeneralExtended::realiseDirectory($kDOCROOT . '/manifest', $conf['settings']['directory']['write_mode'])) {
                define("_INSTALL_ERRORS_", "Could not create 'manifest' directory. Check permission on the root folder.");
                $install_log->pushToLog("ERROR: Creation of 'manifest' folder failed.", SYM_LOG_ERROR, true, true);
                installResult($Page, $install_log, $start);
                return;
            }
            $install_log->pushToLog("WRITING: Creating 'logs' folder (/manifest/logs)", SYM_LOG_NOTICE, true, true);
            if (!GeneralExtended::realiseDirectory($kDOCROOT . '/manifest/logs', $conf['settings']['directory']['write_mode'])) {
                define("_INSTALL_ERRORS_", "Could not create 'logs' directory. Check permission on /manifest.");
                $install_log->pushToLog("ERROR: Creation of 'logs' folder failed.", SYM_LOG_ERROR, true, true);
                installResult($Page, $install_log, $start);
                return;
            }
            $install_log->pushToLog("WRITING: Creating 'cache' folder (/manifest/cache)", SYM_LOG_NOTICE, true, true);
            if (!GeneralExtended::realiseDirectory($kDOCROOT . '/manifest/cache', $conf['settings']['directory']['write_mode'])) {
                define("_INSTALL_ERRORS_", "Could not create 'cache' directory. Check permission on /manifest.");
                $install_log->pushToLog("ERROR: Creation of 'cache' folder failed.", SYM_LOG_ERROR, true, true);
                installResult($Page, $install_log, $start);
                return;
            }
            $install_log->pushToLog("WRITING: Creating 'tmp' folder (/manifest/tmp)", SYM_LOG_NOTICE, true, true);
            if (!GeneralExtended::realiseDirectory($kDOCROOT . '/manifest/tmp', $conf['settings']['directory']['write_mode'])) {
                define("_INSTALL_ERRORS_", "Could not create 'tmp' directory. Check permission on /manifest.");
                $install_log->pushToLog("ERROR: Creation of 'tmp' folder failed.", SYM_LOG_ERROR, true, true);
                installResult($Page, $install_log, $start);
                return;
            }
            $install_log->pushToLog("WRITING: Configuration File", SYM_LOG_NOTICE, true, true);
            if (!writeConfig($kDOCROOT . "/manifest/", $conf, $conf['settings']['file']['write_mode'])) {
                define("_INSTALL_ERRORS_", "Could not write config file. Check permission on /manifest.");
                $install_log->pushToLog("ERROR: Writing Configuration File Failed", SYM_LOG_ERROR, true, true);
                installResult($Page, $install_log, $start);
            }
            $rewrite_base = dirname($_SERVER['PHP_SELF']);
            $rewrite_base = trim($rewrite_base, '/');
            if ($rewrite_base != "") {
                $rewrite_base .= '/';
            }
            $htaccess = '
### Symphony 1.7 - Do not edit ###

<IfModule mod_rewrite.c>
	RewriteEngine on
	RewriteBase /' . $rewrite_base . '

	### DO NOT APPLY RULES WHEN REQUESTING "favicon.ico"
	RewriteCond %{REQUEST_FILENAME} favicon.ico [NC]
	RewriteRule .* - [S=14]

	### IMAGE RULES
	RewriteRule ^image/([0-9]+)\\/([0-9]+)\\/(0|1)\\/([a-fA-f0-9]{1,6})\\/external/([\\W\\w]+)\\.(jpg|gif|jpeg|png|bmp)$   /' . $rewrite_base . 'symphony/image.php?width=$1&height=$2&crop=$3&bg=$4&_f=$5.$6&external=true [L]
	RewriteRule ^image/external/([\\W\\w]+)\\.(jpg|gif|jpeg|png|bmp)$   /' . $rewrite_base . 'symphony/image.php?width=0&height=0&crop=0&bg=0&_f=$1.$2&external=true [L]

	RewriteRule ^image/([0-9]+)\\/([0-9]+)\\/(0|1)\\/([a-fA-f0-9]{1,6})\\/external/(.*)\\.(jpg|gif|jpeg|png|bmp)$   /' . $rewrite_base . 'symphony/image.php?width=$1&height=$2&crop=$3&bg=$4&_f=$5.$6&external=true [L]
	RewriteRule ^image/external/(.*)\\.(jpg|gif|jpeg|png|bmp)$  /' . $rewrite_base . 'symphony/image.php?width=0&height=0&crop=0&bg=0&_f=$1.$2&external=true [L]

	RewriteRule ^image/([0-9]+)\\/([0-9]+)\\/(0|1)\\/([a-fA-f0-9]{1,6})\\/([\\W\\w]+)\\.(jpg|gif|jpeg|png|bmp)$   /' . $rewrite_base . 'symphony/image.php?width=$1&height=$2&crop=$3&bg=$4&_f=$5.$6 	[L]
	RewriteRule ^image/([\\W\\w]+)\\.(jpg|gif|jpeg|png|bmp)$   /' . $rewrite_base . 'symphony/image.php?width=0&height=0&crop=0&bg=0&_f=$1.$2 	[L]

	RewriteRule ^image/([0-9]+)\\/([0-9]+)\\/(0|1)\\/([a-fA-f0-9]{1,6})\\/(.*)\\.(jpg|gif|jpeg|png|bmp)$   /' . $rewrite_base . 'symphony/image.php?width=$1&height=$2&crop=$3&bg=$4&_f=$5.$6 	[L]
	RewriteRule ^image/(.*)\\.(jpg|gif|jpeg|png|bmp)$   /' . $rewrite_base . 'symphony/image.php?width=0&height=0&crop=0&bg=0&_f=$1.$2 	[L]

	### CHECK FOR TRAILING SLASH - Will ignore files
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteCond %{REQUEST_URI} !/' . trim($rewrite_base, '/') . '$
	RewriteCond %{REQUEST_URI} !(.*)/$
	RewriteRule ^(.*)$ /' . $rewrite_base . '$1/ [L,R=301]

	### MAIN REWRITE - This will ignore directories
	RewriteCond %{REQUEST_FILENAME} !-d
	RewriteRule ^(.*)\\/$ /' . $rewrite_base . 'index.php?page=$1&%{QUERY_STRING}	[L]

</IfModule>

DirectoryIndex index.php
IndexIgnore *

######
';
            $install_log->pushToLog("CONFIGURING: Frontend", SYM_LOG_NOTICE, true, true);
            if (!GeneralExtended::writeFile($kDOCROOT . "/.htaccess", $htaccess, $conf['settings']['file']['write_mode'])) {
                define("_INSTALL_ERRORS_", "Could not write .htaccess file. Check permission on " . $kDOCROOT);
                $install_log->pushToLog("ERROR: Writing .htaccess File Failed", SYM_LOG_ERROR, true, true);
                installResult($Page, $install_log, $start);
            }
            if (@is_file($fields['docroot'] . '/workspace/workspace.conf')) {
                $install_log->pushToLog("CONFIGURING: Importing Workspace", SYM_LOG_NOTICE, true, false);
                if (!fireSql($db, file_get_contents($fields['docroot'] . '/workspace/workspace.conf') . getDefaultTableData(), $error, $config['database']['high-compatibility'] == 'yes' ? 'high' : 'normal')) {
                    define("_INSTALL_ERRORS_", "There was an error while trying to import the workspace data. MySQL returned: {$error}");
                    $install_log->pushToLog("Failed", SYM_LOG_ERROR, true, true, true);
                    installResult($Page, $install_log, $start);
                } else {
                    $install_log->pushToLog("Done", SYM_LOG_NOTICE, true, true, true);
                }
            } elseif (@(!is_dir($fields['docroot'] . '/workspace'))) {
                ### Create the workspace folder structure
                #
                $install_log->pushToLog("WRITING: Creating 'workspace' folder (/workspace)", SYM_LOG_NOTICE, true, true);
                if (!GeneralExtended::realiseDirectory($kDOCROOT . '/workspace', $conf['settings']['directory']['write_mode'])) {
                    define("_INSTALL_ERRORS_", "Could not create 'workspace' directory. Check permission on the root folder.");
                    $install_log->pushToLog("ERROR: Creation of 'workspace' folder failed.", SYM_LOG_ERROR, true, true);
                    installResult($Page, $install_log, $start);
                    return;
                }
                $install_log->pushToLog("WRITING: Creating 'data-sources' folder (/workspace/data-sources)", SYM_LOG_NOTICE, true, true);
                if (!GeneralExtended::realiseDirectory($kDOCROOT . '/workspace/data-sources', $conf['settings']['directory']['write_mode'])) {
                    define("_INSTALL_ERRORS_", "Could not create 'workspace/data-sources' directory. Check permission on the root folder.");
                    $install_log->pushToLog("ERROR: Creation of 'workspace/data-sources' folder failed.", SYM_LOG_ERROR, true, true);
                    installResult($Page, $install_log, $start);
                    return;
                }
                $install_log->pushToLog("WRITING: Creating 'events' folder (/workspace/events)", SYM_LOG_NOTICE, true, true);
                if (!GeneralExtended::realiseDirectory($kDOCROOT . '/workspace/events', $conf['settings']['directory']['write_mode'])) {
                    define("_INSTALL_ERRORS_", "Could not create 'workspace/events' directory. Check permission on the root folder.");
                    $install_log->pushToLog("ERROR: Creation of 'workspace/events' folder failed.", SYM_LOG_ERROR, true, true);
                    installResult($Page, $install_log, $start);
                    return;
                }
                $install_log->pushToLog("WRITING: Creating 'masters' folder (/workspace/masters)", SYM_LOG_NOTICE, true, true);
                if (!GeneralExtended::realiseDirectory($kDOCROOT . '/workspace/masters', $conf['settings']['directory']['write_mode'])) {
                    define("_INSTALL_ERRORS_", "Could not create 'workspace/masters' directory. Check permission on the root folder.");
                    $install_log->pushToLog("ERROR: Creation of 'workspace/masters' folder failed.", SYM_LOG_ERROR, true, true);
                    installResult($Page, $install_log, $start);
                    return;
                }
                $install_log->pushToLog("WRITING: Creating 'pages' folder (/workspace/pages)", SYM_LOG_NOTICE, true, true);
                if (!GeneralExtended::realiseDirectory($kDOCROOT . '/workspace/pages', $conf['settings']['directory']['write_mode'])) {
                    define("_INSTALL_ERRORS_", "Could not create 'workspace/pages' directory. Check permission on the root folder.");
                    $install_log->pushToLog("ERROR: Creation of 'workspace/pages' folder failed.", SYM_LOG_ERROR, true, true);
                    installResult($Page, $install_log, $start);
                    return;
                }
                $install_log->pushToLog("WRITING: Creating 'text-formatters' folder (/workspace/text-formatters)", SYM_LOG_NOTICE, true, true);
                if (!GeneralExtended::realiseDirectory($kDOCROOT . '/workspace/text-formatters', $conf['settings']['directory']['write_mode'])) {
                    define("_INSTALL_ERRORS_", "Could not create 'workspace/text-formatters' directory. Check permission on the root folder.");
                    $install_log->pushToLog("ERROR: Creation of 'workspace/text-formatters' folder failed.", SYM_LOG_ERROR, true, true);
                    installResult($Page, $install_log, $start);
                    return;
                }
                $install_log->pushToLog("WRITING: Creating 'upload' folder (/workspace/upload)", SYM_LOG_NOTICE, true, true);
                if (!GeneralExtended::realiseDirectory($kDOCROOT . '/workspace/upload', $conf['settings']['directory']['write_mode'])) {
                    define("_INSTALL_ERRORS_", "Could not create 'workspace/upload' directory. Check permission on the root folder.");
                    $install_log->pushToLog("ERROR: Creation of 'workspace/upload' folder failed.", SYM_LOG_ERROR, true, true);
                    installResult($Page, $install_log, $start);
                    return;
                }
                $install_log->pushToLog("WRITING: Creating 'utilities' folder (/workspace/utilities)", SYM_LOG_NOTICE, true, true);
                if (!GeneralExtended::realiseDirectory($kDOCROOT . '/workspace/utilities', $conf['settings']['directory']['write_mode'])) {
                    define("_INSTALL_ERRORS_", "Could not create 'workspace/utilities' directory. Check permission on the root folder.");
                    $install_log->pushToLog("ERROR: Creation of 'workspace/utilities' folder failed.", SYM_LOG_ERROR, true, true);
                    installResult($Page, $install_log, $start);
                    return;
                }
            }
            if (@(!is_dir($fields['docroot'] . '/campfire'))) {
                $install_log->pushToLog("WRITING: Creating 'campfire' folder (/campfire)", SYM_LOG_NOTICE, true, true);
                if (!GeneralExtended::realiseDirectory($kDOCROOT . '/campfire', $conf['settings']['directory']['write_mode'])) {
                    define("_INSTALL_ERRORS_", "Could not create 'campfire' directory. Check permission on the root folder.");
                    $install_log->pushToLog("ERROR: Creation of 'campfire' folder failed.", SYM_LOG_ERROR, true, true);
                    installResult($Page, $install_log, $start);
                    return;
                }
            }
            $install_log->pushToLog("Installation Process Completed In " . max(1, time() - $start) . " sec", SYM_LOG_NOTICE, true);
            installResult($Page, $install_log, $start);
            GeneralExtended::redirect('http://' . rtrim(str_replace('http://', '', _INSTALL_DOMAIN_), '/') . '/symphony/');
        }
    }
コード例 #22
0
ファイル: printer.php プロジェクト: atoledov/siglab
<link href="css/main.css" type="text/css" rel="stylesheet" media="screen" /> 
<?php 
require "../config/system.php";
require "../model/Util.php";
require "../model/MySql.php";
$Orden = explode("@", $_POST["Orden"]);
$TurnId = $Orden[0];
$OrdId = $Orden[1];
$tbl_name = $Orden[2];
$_db = new MySQL();
$_db->connect();
$ex = array();
$_sql = "SELECT CASE\r\n\t\t\t    WHEN TestPadrePadre!='' THEN TestPadrePadre\r\n\t\t\t    WHEN TestPadreDescripcion!='' THEN TestPadreDescripcion\r\n\t\t       END AS test\r\n\t\t FROM {$tbl_name} WHERE EstadoProcesa='V' GROUP BY test ORDER BY test ";
$_db->prepare($_sql);
$_result = $_db->execute();
while (@($data = $_db->fetch_array($_result))) {
    $ex[] = $data["test"];
}
$_db->free($_result);
$exams = array_unique($ex);
?>
<div style="margin: 20px">
    <div id="_image">
        <img src="../images/logo_msp.png?>" />&nbsp;<div style="float:right"><h3><?php 
echo CLIENT_NAME;
?>
</h3></div>		
    </div>
    	
    <div id="_header">
		<?php 
コード例 #23
0
ファイル: printer_pdf.php プロジェクト: atoledov/siglab
 function DetalleOrden($header, $TurnId, $OrdId, $tbl_name)
 {
     $_db = new MySQL();
     $_db->connect();
     /* Consulto los Examenes - Nuevo Esquema para generar el Menu */
     $ex = array();
     $_sql = "SELECT CASE\r\n\t\t\t\t\tWHEN TestPadrePadre!='' THEN TestPadrePadre\r\n\t\t\t\t\tWHEN TestPadreDescripcion!='' THEN TestPadreDescripcion\r\n\t\t\t\t\tEND AS test\r\n\t\t\t\t FROM {$tbl_name} WHERE EstadoProcesa='V' GROUP BY test ORDER BY test";
     $_db->prepare($_sql);
     //echo $_sql;
     $_result = $_db->execute();
     while (@($data = $_db->fetch_array($_result))) {
         $ex[] = $data["test"];
     }
     $_db->free($_result);
     //Verifico elementos repetidos en el array
     $exams = array_unique($ex);
     /* Barro Todos los Test Padres */
     $np = 0;
     foreach ($exams as $key => $value) {
         // Test Descripcion
         $this->Ln();
         $this->SetFont('Arial', 'B', 10);
         $this->Cell(10, 10, ucwords(strtolower(str_replace(":", " ", $value))), '', 0, 'L', false);
         $this->Ln();
         // Colores, ancho de linea y fuente en negrita
         $this->SetFillColor(101, 101, 101);
         $this->SetTextColor(255);
         $this->SetDrawColor(80, 80, 80);
         $this->SetLineWidth(0.3);
         $this->SetFont('Arial', '', 9);
         // Cabecera
         $w = array(60, 50, 25, 60);
         for ($i = 0; $i < count($header); $i++) {
             $this->Cell($w[$i], 6, $header[$i], 1, 0, 'C', true);
         }
         $this->Ln();
         // Consulto Resultados
         //$this->SetFont('Arial','',9);
         $fill = false;
         $test = trim(str_replace(":", " ", $value));
         $resultados = array();
         $_sql = "SELECT OrdId, OrdTurno, OrdFecha, CONCAT(PacNombre,' ',PacApellido) as Paciente, \r\n\t\t\t\t\t  CONCAT(MedNombre,' ',MedApellido)as Medico, TestDescripcion, Resultado, Unidad, \r\n\t\t\t\t\t  RanValInf, RanValSup, RanMultiple, TestPadre, TestPadreDescripcion, EmpId, EmpDescripcion,\r\n\t\t\t\t\t  TestNivel, TestPadrePadre, '' AS TestPadrePadrePadre, OrdDiagnostico\r\n\t\t\t\t\tFROM `{$tbl_name}` \r\n\t\t\t\t\tWHERE OrdTurno='{$TurnId}' AND OrdId='{$OrdId}' AND EstadoProcesa='V'  \r\n\t\t\t\t\t  AND (TestPadreDescripcion like '%{$test}%' Or TestPadrePadre like '%{$test}%') ";
         if ($test == 'BACTERIOLOGIA') {
             //$_sql .= " ORDER BY TestNivel, TestSubNivel, TestPadreDescripcion ";
             $_sql .= " ORDER BY TestPadre, TestNivel, TestSubNivel ";
         } else {
             if ($test == 'ORINA') {
                 $_sql .= " ORDER BY TestNivel ";
             } else {
                 $_sql .= " ORDER BY TestPadreDescripcion, TestNivel, TestSubNivel ";
             }
         }
         //echo $_sql;
         $_db->prepare($_sql);
         $_result = $_db->execute();
         while (@($data = $_db->fetch_array($_result))) {
             $resultados[] = $data;
         }
         $_db->free($_result);
         /* Muestra los Resultados */
         $i = 1;
         $j = 1;
         $limite = 26;
         foreach ($resultados as $k => $val) {
             $nivel = $val["TestNivel"];
             //Nivel del Examen
             if ($val["TestPadreDescripcion"] != $desc) {
                 $i = 1;
                 //Inicializo i
                 $j = 1;
                 //Inicializo j
             }
             /* Seteo el Formato drl Texto en las cabeceras de los Resultados */
             $this->SetFillColor(255, 255, 255);
             $this->SetTextColor(0);
             $this->SetFont('Arial', 'B', 9);
             if ($nivel > 1) {
                 switch ($nivel) {
                     case "2":
                         if ($i == 1) {
                             $this->Cell($w[0], 6, ucwords(strtolower(str_replace(":", " ", $val["TestPadreDescripcion"]))), '', 0, 'L', false);
                             $this->Ln();
                             //Salto de Linea
                         }
                         $i++;
                         break;
                     case "3":
                         if ($i == 1) {
                             if ($tpp != $val["TestPadrePadre"]) {
                                 $this->Cell($w[0], 6, ucwords(strtolower(str_replace(":", " ", $val["TestPadrePadre"]))), '', 0, 'L', false);
                                 $this->Ln();
                                 //Salto de Linea
                             }
                         }
                         if ($j == 1) {
                             $this->Cell($w[0], 6, ucwords(strtolower(str_replace(":", " ", $val["TestPadreDescripcion"]))), '', 0, 'L', false);
                             $this->Ln();
                             //Salto de Linea
                         }
                         $i++;
                         $j++;
                         break;
                 }
             }
             // Restauracion de colores y fuentes
             $this->SetFillColor(224, 235, 255);
             $this->SetTextColor(0);
             $this->SetFont('Arial', '', 9);
             /* Presenta los Resultados */
             $flag = false;
             $exa = "";
             $resul = "";
             $rango = "";
             # Verifica la Longitud del Examen
             if (strlen($val["TestDescripcion"]) >= $limite) {
                 if (strstr($val["TestDescripcion"], '<br>')) {
                     $exa = $val["TestDescripcion"];
                 } else {
                     $exa = FormatString($val["TestDescripcion"], $limite);
                     $flag = true;
                 }
             } else {
                 $exa = $val["TestDescripcion"];
             }
             # Verifica la Longitud del Resultado
             if (strlen($val["Resultado"]) >= $limite) {
                 if (strstr($val["Resultado"], '<br>')) {
                     $resul = $val["Resultado"];
                 } else {
                     $resul = FormatString($val["Resultado"], $limite);
                     $flag = true;
                 }
             } else {
                 $resul = $val["Resultado"];
             }
             # Verifica los rangos referenciales
             if (!empty($val["RanValInf"]) || !empty($val["RanValSup"])) {
                 $rango = $val["RanValInf"] . " - " . $val["RanValSup"];
             } else {
                 if (!empty($val["RanMultiple"])) {
                     $rango = str_replace("<br>", "\n", $val["RanMultiple"]);
                     $flag = true;
                 }
             }
             if (!$flag) {
                 $this->Cell($w[0], 6, $exa, 'LR', 0, 'L', $fill);
                 // Nombre del Examen
                 $this->Cell($w[1], 6, $resul, 'LR', 0, 'C', $fill);
                 // Resultado
                 $this->Cell($w[2], 6, $val["Unidad"], 'LR', 0, 'C', $fill);
                 // Unidad
                 $this->Cell($w[3], 6, $rango, 'LR', 0, 'C', $fill);
                 // Rango Minimo - Rango Maximo
             } else {
                 $this->SetFont('Arial', '', 9);
                 $this->SetWidths(array(60, 50, 25, 60));
                 if (strlen($rango) < $limite) {
                     $this->SetAligns(array('L', 'C', 'C', 'C'));
                 } else {
                     $this->SetAligns(array('L', 'C', 'C', 'L'));
                 }
                 $this->Row(array(utf8_decode(str_replace("<br/>", "\n", $exa)), utf8_decode(str_replace("<br/>", "\n", $resul)), utf8_decode($val["Unidad"]), $rango));
             }
             $this->Ln();
             $fill = !$fill;
             $desc = $val["TestPadreDescripcion"];
             // Guardo El Test Anterior - TestPadreDescripcion
             $tpp = $val["TestPadrePadre"];
             // TestPadrePadre
             $diagnostico = $val["OrdDiagnostico"];
             // Diagnostico
         }
         $this->Cell(array_sum($w), 0, '', 'T');
         $this->Ln();
         $this->Cell(200, 10, '* Sin valor legal, para ese efecto acerquese al Laboratorio Principal', 0, 0, 'C');
         $np++;
         if (count($exams) - $np != 0) {
             $this->AddPage();
         }
     }
     # Imprimo el Diagnostico
     if (!empty($diagnostico)) {
         $this->Ln(20);
         $this->SetFont('Arial', 'B', 10);
         $this->Cell(80, 6, "Observaciones y Comentarios a la Solicitud:", '', 'L', $fill);
         $this->SetFont('Arial', '', 10);
         $this->Cell(120, 6, $diagnostico, '', 'L', $fill);
     }
     $_db->close();
 }
コード例 #24
0
    }
    public function query($sql)
    {
        $this->result = mysql_query($sql);
    }
    public function fetch()
    {
        $arr = array();
        while ($row = mysql_fetch_assoc($this->result)) {
            $arr[] = $row;
        }
        return $arr;
    }
    public function iterate($sql, $data_type = MySQLResultSet::DATA_OBJECT)
    {
        return new MySQLResultSet($sql, $data_type, $this->db);
    }
    public function close()
    {
        mysql_close($this->db);
    }
}
$obj = new MySQL();
$obj->connect("localhost", "root", "", "blogtastic");
try {
    foreach ($obj->iterate("SELECT * from person", 1) as $row) {
        echo $row->codep . '-' . $row->name . '-' . $row->phone1 . '<br/>';
    }
} catch (Exception $ex) {
    echo $ex->getMessage();
}
コード例 #25
0
ファイル: cc_stats.php プロジェクト: uvaron/BDparser
<?php

/**
 * Created by PhpStorm.
 * User: Герман
 * Date: 31.03.2016
 * Time: 14:06
 */
// Подключение к базе данных;
require_once $_SERVER['DOCUMENT_ROOT'] . '/systems/connect.php';
// Проверяем роли;
check_role(basename($_SERVER['SCRIPT_NAME'], ".php"));
// Здесь подключаем основной объект по работе с базой КЦ;
if ($user_phone_db == true) {
    $db_phone = new MySQL();
    $db_phone->connect($phone_host, $phone_db, $phone_user, $phone_password);
}
if ($user_phone_db == false) {
    print '<h3>Подключение к базе данных VOIP сервера отключено в конфигурационном файле</h3><br>';
    exit;
}
if (count($_POST) == 0 && count($_GET) == 0) {
    $html = '';
    // Заголовок страницы;
    $html .= $elements->title(basename($_SERVER['SCRIPT_NAME'], ".php"));
    $html .= '<div class="page_caption">Выберите диапозон дат для отчета</div><br>';
    $html .= '<div style="display: inline-block; margin-right: 5px; margin-left: 5px;">';
    $html .= '<div class="page_caption">Дата от:</div><br>';
    $html .= '<input id="selected_date_from" type="date" name="calendar" value="' . date('Y-m-d') . '" style="text-align: center;padding-left: 50px;width: 11em;padding-right: 0px;">';
    $html .= '</div>';
    $html .= '<div style="display: inline-block; margin-right: 5px; margin-left: 5px;">';