Example #1
0
<?php

/**
 * @copyright 2005-2008 OpenPNE Project
 * @license   http://www.php.net/license/3_01.txt PHP License 3.01
 */
# OPENPNE_DIR/bin/tool_create_member.php
# cd OPENPNE_DIR/bin/
# php tool_create_member.php
require_once './config.inc.php';
require_once OPENPNE_WEBAPP_DIR . '/init.inc';
print "start\n";
$want_member_num = 380000;
$db =& db_get_instance();
$matome_num = 1000;
for ($i = 0; $i < $want_member_num; $i += $matome_num) {
    $sql = "INSERT INTO `c_member` (c_member_id, nickname, birth_year, birth_day, c_password_query_id, c_member_id_invite, is_receive_mail, is_receive_ktai_mail, is_receive_daily_news, public_flag_birth_year, public_flag_birth_month_day) VALUES ";
    $sql2 = "INSERT INTO `c_member_secure` (c_member_id, hashed_password, pc_address, regist_address) VALUES ";
    $is_first = true;
    for ($j = 0; $j < $matome_num; $j++) {
        if ($is_first == true) {
            $is_first = false;
        } else {
            $sql .= ",";
            $sql2 .= ",";
        }
        $member_id = 1 + ($i + $j);
        $sql .= '(' . $member_id . ',"hoge",2001,10,10,0,1,1,1,"public","public")';
        $pc_address = t_encrypt("sns" . $member_id . "@example.com");
        $regist_address = t_encrypt("sns" . $member_id . "@example.com");
        $sql2 .= '(' . $member_id . ',md5("pohigepoihge"),"' . $pc_address . '","' . $regist_address . '")';
/**
 * 登録済み画像のファイルサイズを求める
 */
function get_image_size($category, $params, $handle)
{
    // request
    $table = $params[0];
    $filename = $params[1];
    $c_member_id = $params[2];
    // c_image 参照先
    $image_dsn = array('main', 'image');
    foreach ($image_dsn as $key => $dsn) {
        if (!isset($GLOBALS['_OPENPNE_DSN_LIST'][$dsn])) {
            continue;
        }
        $imagedb =& db_get_instance($dsn);
        // 取り出し
        $sql = 'SELECT ';
        if ($table != 'biz_shisetsu') {
            $sql .= $c_member_id . ' as c_member_id, ';
        }
        $sql .= $filename . ' as image_filename ';
        if ($table == 'c_member') {
            $sql .= ',r_date ';
        } elseif ($table != 'biz_group' && $table != 'biz_shisetsu') {
            $sql .= ',r_datetime ';
        }
        $sql .= 'FROM ' . $table;
        $sql .= ' WHERE ' . $filename . ' <> ""';
        $sql .= ' AND ' . $filename . ' is not NULL';
        $data_list = db_get_all($sql);
        $lines = 0;
        if ($data_list) {
            fwrite($handle, 'INSERT INTO c_image_size VALUES');
        }
        foreach ($data_list as $data) {
            // get image size
            $sql = 'SELECT bin FROM c_image WHERE filename = ?';
            $params = array($data['image_filename']);
            $c_image_list = $imagedb->get_all($sql, $params);
            foreach ($c_image_list as $c_image) {
                $filesize = strlen(base64_decode($c_image['bin']));
            }
            $ins_data = '';
            if ($lines) {
                $ins_data .= ',';
            }
            $ins_data .= '(';
            if ($GLOBALS['_OPENPNE_DSN_LIST']['main']['dsn']['phptype'] == 'pgsql') {
                $ins_data .= " nextval('c_image_size_c_image_size_id_seq')";
            } else {
                $ins_data .= ' null';
            }
            $ins_data .= ",'" . $data['image_filename'] . "'";
            $ins_data .= ",'" . $data['c_member_id'] . "'";
            $ins_data .= ",'" . $filesize . "'";
            $ins_data .= ",'" . $category . "'";
            if ($table == 'biz_group' || $table == 'biz_shisetsu') {
                $ins_data .= ",'" . db_now() . "'";
            } elseif ($table == 'c_member') {
                $ins_data .= ",'" . $data['r_date'] . "'";
            } else {
                $ins_data .= ",'" . $data['r_datetime'] . "'";
            }
            $ins_data .= ')';
            fwrite($handle, $ins_data);
            $lines++;
        }
        if ($lines) {
            fwrite($handle, ";\n");
        }
    }
}
Example #3
0
function db_affected_rows()
{
    $db =& db_get_instance();
    return $db->affectedRows();
}
Example #4
0
function db_image_data_copy($filename, $new_filename, $c_member_id, $filesize)
{
    if (!$filename) {
        return false;
    }
    $db =& db_get_instance('image');
    $sql = 'SELECT * FROM c_image WHERE filename = ?';
    $params = array($filename);
    $c_image[] = $db->get_row($sql, $params);
    if (!$c_image[0]) {
        return false;
    }
    $bin = base64_decode($c_image[0]['bin']);
    $type = $c_image[0]['type'];
    return db_image_insert_c_image($new_filename, $bin, $filesize, $c_member_id, null, $type);
}
Example #5
0
function db_admin_c_album_image_list4c_album_image_id($page, $page_size, &$pager, $c_album_image_id)
{
    $db =& db_get_instance('image');
    $sql = 'SELECT cai.c_album_image_id, cai.image_filename, cai.r_datetime, cai.image_description, cai.c_album_id, ca.subject' . ' FROM c_album_image AS cai' . ' INNER JOIN c_album AS ca ON cai.c_album_id = ca.c_album_id' . ' WHERE cai.c_album_image_id = ?' . ' ORDER BY cai.c_album_image_id DESC';
    $params = array($c_album_image_id);
    $c_image_album_list = db_get_all_page($sql, $page, $page_size, $params);
    $sql = 'SELECT COUNT(*) FROM c_album_image' . ' WHERE c_album_image_id = ?';
    $total_num = $db->get_one($sql, $params);
    $pager = util_make_pager($page, $page_size, $total_num);
    return $c_image_album_list;
}
Example #6
0
function db_image_is_c_album_image4filename($filename)
{
    if (!$filename) {
        return false;
    }
    $db =& db_get_instance('image');
    $sql = 'SELECT c_image_id FROM c_image WHERE filename = ?';
    $params = array($filename);
    return (bool) $db->get_one($sql, $params);
}