function gain_item($item, $count, $login)
{
    global $I_SEP_C, $p;
    //$item = preg_replace ('/[^a-z0-9\._]/i', '', $item);
    $count = preg_replace('/[^0-9]/', '', $count);
    //$login = preg_replace ('/[^a-z0-9_]/', '', $login);
    if (!$item || !$count || !$login) {
        put_error('заполните усе данные (это к админу)');
    }
    $id = is_player($login);
    include_once 'modules/f_create_item.php';
    include_once 'modules/f_add_item_to_pl.php';
    include_once 'modules/f_add_item_to_loc.php';
    include_once 'modules/f_get_it_name.php';
    if (substr($item, 2, 1) == 'm') {
        $nitem = create_item($item);
        //add_item_to_pl ($login, $nitem);
        $name = get_it_name($nitem);
        $q = do_mysql("SELECT COUNT(*) FROM items WHERE belongs = '" . $login . "' AND is_in = 'inv' AND weight > 0;");
        $c = mysql_result($q, 0);
        if ($c > $I_SEP_C) {
            add_item_to_loc($p['location'], $nitem);
        } else {
            $q = do_mysql("SELECT fullname FROM items WHERE belongs = '" . $login . "' AND is_in = 'inv' AND realname = '" . $item . "';");
            if (mysql_num_rows($q)) {
                $fn = mysql_result($q, 0);
                do_mysql("UPDATE items SET on_take = on_take + " . $count . " WHERE fullname = '" . $fn . "';");
                do_mysql("DELETE FROM items WHERE fullname = '" . $nitem . "';");
            } else {
                add_item_to_pl($login, $nitem);
                do_mysql("UPDATE items SET on_take = '" . $count . "' WHERE fullname = '" . $nitem . "';");
            }
        }
        add_journal('вы получили ' . $name . '!', $login);
    } else {
        for ($i = 0; $i < $count; $i++) {
            $nitem = create_item($item);
            $name = get_it_name($nitem);
            $q = do_mysql("SELECT COUNT(*) FROM items WHERE belongs = '" . $login . "' AND is_in = 'inv' AND weight > 0;");
            $c = mysql_result($q, 0);
            if ($c > $I_SEP_C) {
                add_item_to_loc($p['location'], $nitem);
            } else {
                add_item_to_pl($login, $nitem);
            }
            add_journal('вы получили ' . $name . '!', $login);
        }
    }
    return $nitem;
}
function print_table_alcools()
{
    global $mysql, $cptTR, $itemsByPage;
    $sql = "SELECT \n\n\t\t\t\t\t\t\tt_alcools.id AS alcools_id,\n\t\t\t\t\t\t\tt_alcools.nom AS alcools_name,\n\t\t\t\t\t\t\tt_alcools.id_produit AS alcools_produit,\n\n\t\t\t\t\t\t\tt_produits_stockage.produit AS produit_stockage_produit,\n\t\t\t\t\t\t\tt_produits_stockage.stockage AS produit_stockage_stockage,\n\t\t\t\t\t\t\tt_produits_stockage.quantite AS produit_stockage_quantite,\n\n\t\t\t\t\t\t\tt_stockage.id AS stockage_id,\n\t\t\t\t\t\t\tt_stockage.emplacement AS stockage_emplacement\n\n\t\t\t\t\t\t\tFROM t_alcools\n\t\t\t\t\t\t\tLEFT JOIN t_produits_stockage ON t_alcools.id_produit = t_produits_stockage.produit\n\t\t\t\t\t\t\tLEFT JOIN t_stockage ON t_produits_stockage.stockage = t_stockage.id\n\t\t\t\t\t\t\tORDER BY \n\t\t\t\t\t\t\tt_alcools.nom ASC\n\t\t\t\t\t\t";
    $query = $mysql->sql_query($sql);
    $cpt = 0;
    $html .= '<table>';
    $html .= '	<tbody>';
    $html .= '	<tr>';
    $html .= '		<th style="width: 470px;" align="left">Produits</th>';
    $html .= '		<th colspan="34">Rangements</th>';
    $html .= '	</tr>';
    echo $html;
    while ($result = mysqli_fetch_assoc($query)) {
        if ($result['alcools_id'] == $current_id) {
            array_push($alcool['emplacement'], array('label' => $result['stockage_emplacement'], 'qty' => $result['produit_stockage_quantite']));
            // push new emplacement in current alcool array
        } else {
            if ($alcool) {
                if (count($alcool['emplacement']) > 0) {
                    create_item($alcool);
                    // print the current item in the table
                    $cpt++;
                }
                $alcool = array();
            }
            $alcool['label'] = $result['alcools_name'];
            $alcool['emplacement'] = array();
            if ($result['stockage_emplacement'] != '') {
                array_push($alcool['emplacement'], array('label' => $result['stockage_emplacement'], 'qty' => $result['produit_stockage_quantite']));
            }
        }
        $current_id = $result['alcools_id'];
    }
    if ($alcool && count($alcool['emplacement']) > 0) {
        create_item($alcool);
        // call this function for the last item of the recordset
    }
    $html = '	</tbody>';
    $html .= '</table>';
    echo $html;
    return $html;
}
Esempio n. 3
0
     $data = "'',\n\t\t\t\t\t'{$i_menu_type_id}', \n\t\t\t\t\t'{$i_name}',\n\t\t\t\t\t'{$i_original_price}',\n\t\t\t\t\t'{$i_margin_price}',\n\t\t\t\t\t'{$i_price}', \n\t\t\t\t\t'{$i_img}',\n\t\t\t\t\t'{$i_partner_id}',\n\t\t\t\t\t'{$i_out_time}'\n\t\t\t";
     //echo $data;
     create($data);
     if ($i_img) {
         move_uploaded_file($i_img_tmp, $path . $i_img);
     }
     header("Location: menu.php?page=list&did=1");
     break;
 case 'save_item':
     extract($_POST);
     $menu_id = isset($_GET['menu_id']) ? $_GET['menu_id'] : null;
     $i_item_id = get_isset($i_item_id);
     $i_item_qty = get_isset($i_item_qty);
     $data = "'',\n\t\t\t\t\t'{$menu_id}', \n\t\t\t\t\t'{$i_item_id}',\n\t\t\t\t\t'{$i_item_qty}'\n\t\t\t";
     //echo $data;
     create_item($data);
     header("Location: menu.php?page=form&id={$menu_id}");
     break;
 case 'edit':
     extract($_POST);
     $id = get_isset($_GET['id']);
     $i_name = get_isset($i_name);
     $i_menu_type_id = get_isset($i_menu_type_id);
     $i_original_price = get_isset($i_price);
     //get_isset($i_original_price);
     $i_margin_price = 0;
     //get_isset($i_margin_price);
     $i_price = get_isset($i_price);
     $i_partner_id = get_isset($i_partner_id);
     $i_out_time = get_isset($i_out_time);
     $path = "../img/menu/";
if (!mysql_num_rows($q) && !mysql_num_rows($q2)) {
    put_g_error('возьмите в руки нож!');
}
if (!mysql_num_rows($q)) {
    $weapon = '';
} else {
    $weapon = mysql_result($q, 0);
}
if (!mysql_num_rows($q2)) {
    $w2 = '';
} else {
    $w2 = mysql_result($q2, 0);
}
if (substr($weapon, 0, 7) != 'i.w.kni' && substr($w2, 0, 7) != 'i.w.kni') {
    put_g_error('возьмите в руки нож!');
}
// esli vse estq, to togda osvezhivaem - sozdaem veshi i puskaem ih na has
if (strpos($di['hunt'], '|')) {
    $di['hunt'] = explode('|', $di['hunt']);
} else {
    $di['hunt'] = explode('~', $di['hunt']);
}
$c = count($di['hunt']);
for ($i = 0; $i < $c; $i++) {
    include_once 'modules/f_create_item.php';
    $trof = create_item($di['hunt'][$i]);
    do_mysql("UPDATE items SET map = '" . $di['map'] . "', belongs = '" . $dead . "' WHERE fullname = '" . $trof . "';");
}
do_mysql("UPDATE dead SET hunt = '' WHERE fullname = '" . $di['fullname'] . "';");
$OSVEZH = 1;
include 'modules/s_take_dead.php';
function create_dead_body($who)
{
    //$who = preg_replace ('/[^a-z\._0-9]/i', '', $who);
    $id = is_player($who);
    if ($id) {
        // veshi:
        $q = do_mysql("SELECT id_player, status1, location, karma, name FROM players WHERE id_player = '" . $id . "';");
        $p = mysql_fetch_assoc($q);
        // imja trupa:
        $d_name = $p['name'] . ' (труп)';
        $d_map = substr($p['location'], 0, 4);
        // polnoenimja
        $time = time();
        $tmp = 'n';
        if ($p['status1'][0] > 0) {
            $tmp = 'p';
        }
        $d_fullname = 'd.' . $tmp . '.' . $p['id_player'] . '.' . $time;
        // veshi
        $q = do_mysql("SELECT COUNT(*) FROM items WHERE is_in = 'inv' AND belongs = '" . $who . "';");
        $c = mysql_result($q, 0);
        if ($p['status1'][0] == 0) {
            $c = round($c / 3);
        }
        do_mysql("UPDATE items SET belongs = '" . $d_fullname . "', is_in = '' WHERE belongs = '" . $who . "' AND is_in = 'inv' AND realname <> 'i.q.que.wind_sign' LIMIT " . $c . ";");
        if ($p['status1'][0] > 0) {
            do_mysql("UPDATE items SET belongs = '" . $d_fullname . "', is_in = '' WHERE belongs = '" . $who . "' AND is_in = 'wea';");
        }
        if ($p['karma'] < 300) {
            $num = rand(0, 10);
            $q = do_mysql("SELECT fullname, on_use FROM items WHERE belongs = '" . $who . "' AND is_in = 'a" . $num . "';");
            if (mysql_num_rows($q)) {
                $a = mysql_fetch_assoc($q);
                $prt = substr($a['fullname'], 4, 3);
                if ($prt == 'amu' || $prt == 'rin') {
                    $q = do_mysql("SELECT skills FROM players WHERE id_player = '" . $id . "';");
                    $p2 = mysql_fetch_assoc($q);
                    $p2['skills'] = explode('|', $p2['skills']);
                    $jew = explode('~', $a['on_use']);
                    $p2['skills'][0] -= $jew[0];
                    $p2['skills'][1] -= $jew[1];
                    $p2['skills'][2] -= $jew[2];
                    $p2['skills'][3] -= $jew[3];
                    $sk = implode('|', $p2['skills']);
                    do_mysql("UPDATE players SET skills = '" . $sk . "' WHERE id_player = '" . $id . "';");
                }
            }
            do_mysql("UPDATE items SET belongs = '" . $d_fullname . "', is_in = '' WHERE belongs = '" . $who . "' AND is_in = 'a" . $num . "';");
        }
        // trofei -
        $d_hunt = '';
        // lokacija
        $d_location = $p['location'];
    } else {
        $id = is_npc($who);
        // tozh samoe dlja npc
        // veshi:
        $q = do_mysql("SELECT id_npc, name, drop2, hunt, location FROM npc WHERE id_npc = '" . $id . "';");
        $n = mysql_fetch_assoc($q);
        // imja trupa:
        $d_name = $n['name'] . ' (труп)';
        // polnoe imja
        $time = time();
        $d_fullname = 'd.p.' . $n['id_npc'] . $time;
        // sozdaem veshi
        if ($n['drop2']) {
            if (substr($n['drop2'], 2, 1) == 'm') {
                include_once 'modules/f_create_item_m.php';
                $itc = create_item_m($n['drop2'], 1);
            } else {
                include_once 'modules/f_create_item.php';
                $itc = create_item($n['drop2']);
            }
            do_mysql("UPDATE items SET belongs = '" . $d_fullname . "', map = '' WHERE fullname = '" . $itc . "';");
        }
        $d_hunt = $n['hunt'];
        // lokacija
        $d_location = $n['location'];
        $d_map = substr($d_location, 0, 4);
    }
    // sozdaem:
    do_mysql("INSERT INTO dead VALUES ('" . $d_name . "', '" . $d_fullname . "', '" . $d_hunt . "', '" . $d_location . "', '" . $d_map . "', NOW());");
    return 1;
}
<?php 
// pustoj svitok. pri prjamom ispolqzovanii ego mozhno pometitq pod portal, vtoroj raz portal sozdaetsja
$q = do_mysql("SELECT on_take FROM items WHERE fullname = '" . $item . "';");
$loc = mysql_result($q, 0);
if ($loc) {
    // sozdaem portal
    // maksimalqnyj navyk magii
    $max = -1;
    $sk = -1;
    for ($i = 22; $i < 30; $i++) {
        if ($p['skills'][$i] > $max) {
            $sk = $i;
            $max = $p['skills'][$sk];
        }
    }
    if (rand(0, 100) <= $p['skills'][2] * 5 + $p['skills'][$sk] * 4 + $p['skills'][4] && $sk) {
        $t = ($p['skills'][2] + $p['skills'][$sk] + $p['skills'][4]) * 2;
        $itn = 'i.o.sta.portal~' . $loc . '~' . $p['location'] . '~' . $t;
        include_once 'modules/f_create_item.php';
        $portal = create_item($itn);
        include_once 'modules/f_add_item_to_loc.php';
        add_item_to_loc($p['location'], $portal);
        add_journal('Вы долго вглядывались в намалеванный пейзаж, пока тот четко не возник перед глазами.', $LOGIN);
        add_journal('<b>Вдруг воздух расступился, и появилась пустота. Через какое-то мгновенье пустота привратилась в пейзаж, отличный от укружающей вас местности.</b>', 'l.' . $p['location']);
        add_journal('<b>Вдруг воздух расступился, и появилась пустота. Через какое-то мгновенье пустота привратилась в пейзаж, отличный от укружающей вас местности.</b>', 'l.' . $loc);
    } else {
        include_once 'modules/f_delete_item.php';
        delete_item($item);
        add_journal('Вы долго любовались намалеванным пейзажом, и решили что ему самое место в фондах эрмитажа. Тут свиток изщез.', $LOGIN);
    }
}
function process_new_item()
{
    $name = $_POST['item_name'];
    $description = $_POST['item_description'];
    $price = $_POST['item_price'];
    $type_id = $_POST['item_type_id'];
    if (!empty($_FILES['item_image']['name'])) {
        $image_file = wp_upload_bits($_FILES['item_image']['name'], null, @file_get_contents($_FILES['item_image']['tmp_name']));
        $image_file_name = $image_file['file'];
        $pos = strpos($image_file_name, 'upload');
        $image = substr_replace($image_file_name, '', 0, $pos);
    }
    create_item($name, $description, $image, $price, $type_id);
    wp_redirect(admin_url('admin.php?page=items_settings&settings-saved'));
}
 // mozhno pristupitq
 for ($i = 0; $i < $c_ins; $i++) {
     check_in_has($ins[$i]);
 }
 for ($i = 0; $i < $c_ing; $i++) {
     check_in_has($ing[$i]);
 }
 include_once 'modules/f_delete_count.php';
 for ($i = 0; $i < $c_ing; $i++) {
     use_in_has($ing[$i]);
 }
 include_once 'modules/f_delete_item.php';
 delete_item($item);
 include_once 'modules/f_create_item.php';
 if ($p['skills'][32] && rand(0, 100) <= $p['skills'][32] * 5 * 100 / $diff) {
     $it = create_item($what);
     $qpp = 1;
     $n = '';
     $rnd = rand(0, $qp * 10 + $p['skills'][32] * 10);
     if ($rnd < 100) {
         $qpp = 1;
         $n = 'слабый';
     } else {
         if ($rnd < 150) {
             $qpp = 2;
             $n = 'малый';
         } else {
             if ($rnd < 200) {
                 $qpp = 3;
                 $n = '';
             } else {
Esempio n. 9
0
require_once '../inc/mysql.inc.php';
require_once '../inc/joke.inc.php';
$content = '<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
	   <url>
			<loc>http://joke.setin.cn</loc>
			<lastmod>' . date('c') . '</lastmod>
			<changefreq>daily</changefreq>
			<priority>1</priority>
		</url>
';
$Joke_dao = new Joke();
$total_num = $Joke_dao->count_online("");
$jokes = $Joke_dao->select_4_sitemap();
foreach ($jokes as $item) {
    $content .= create_item($item);
}
$content .= '</urlset>';
echo $content;
Mysql::closeConn();
function create_item($data)
{
    $item = "<url>\n";
    $item .= "<loc>http://joke.setin.cn/" . $data['j_id'] . ".html</loc>\n";
    $item .= "<priority>" . 0.9 . "</priority>\n";
    $item .= "<lastmod>" . date("c", strtotime($data['j_time'])) . "</lastmod>\n";
    $item .= "<changefreq>" . 'daily' . "</changefreq>\n";
    $item .= "</url>\n";
    return $item;
}
Esempio n. 10
0
function part_items($items, &$prod_id, &$date_mod, $start_pos)
{
    $start_time = time();
    for ($i = $start_pos; $i < count($items) && $i < $start_pos + 30; $i++) {
        $item_id = get_id_by_sku(get_article($items[$i]->No));
        if ($item_id) {
            $prod_id[$items[$i]->No] = $item_id;
            $date_mod[$items[$i]->No] = get_post_meta($item_id, '_last_time_modified', true);
            if ($date_mod[$items[$i]->No] < $items[$i]->Last_time_modified) {
                //если дата последнего изменения товара в бд меньше, чем дата изменения выгруженного товара, то обновляем
                set_main_information($items[$i], $item_id);
                update_post_meta($item_id, '_last_time_modified', $items[$i]->Last_time_modified);
            }
        } else {
            //новый продукт добавляем в базу
            create_item($items[$i], $prod_id);
        }
        if (time() - $start_time > 25 || $i == $start_pos + 29) {
            restart_load_items($items, $prod_id, $date_mod, ++$i);
            break;
        }
        error_log(current_time('mysql') . " Added item " . $i . ": " . $prod_id[$items[$i]->No] . ": " . $items[$i]->No . " \r\n", 3, "connect.log");
    }
}
Esempio n. 11
0
 }
 $sql = "select distinct *  from tracks where id_user={$id_user}";
 $stmt = $connexion->prepare($sql);
 $stmt->execute();
 $data_array = $stmt->fetchAll(PDO::FETCH_ASSOC);
 $implementation = new DOMImplementation();
 $dtd = $implementation->createDocumentType('playlist', "", 'playlist.dtd');
 $dom = $implementation->createDocument('', '', $dtd);
 $dom->encoding = 'utf-8';
 //$dom=new DomDocument('1.0', 'utf-8');
 $playlist = $dom->createElement('playlist');
 $dom->appendchild($playlist);
 foreach ($data_array as $data) {
     $item = $dom->createElement('item');
     $playlist->appendchild($item);
     create_item($dom, $item, $data);
 }
 $dom->save("playlist.xml");
 if ($dom->validate()) {
     $file_name = "playlist.xml";
     if (file_exists($file_name)) {
         $fp = fopen($file_name, 'r');
         $file_size = filesize($file_name);
         header("Content-type: application/octect-stream");
         header("Accept-Ranges: bytes");
         header("Accept-Length: {$file_size}");
         header("Content-Disposition: attachment; filename=" . $file_name);
         $buffer = 1024;
         while (!feof($fp)) {
             $file_data = fread($fp, $buffer);
             echo $file_data;
Esempio n. 12
0
    $param[6] *= $numb;
}
if ($p['money'] - $param[6] < 0) {
    put_g_error('у вас недостаточно денег, надо ' . $param[6] . ' серебра');
}
$q = do_mysql("SELECT COUNT(*) FROM items WHERE belongs = '" . $LOGIN . "' AND is_in = 'inv' AND weight > 0;");
$c = mysql_result($q, 0);
if ($param[6] > 0 && $c + $count - 1 > $I_SEP_C) {
    put_g_error('<p>в рюгзаке нехватает места</p>');
}
// esli vse horosho, udalim veshq iz spiska tovarov prodovca, zamenim ee novoj
// sozdadim takuju v inventare igroka
//-
$p['money'] -= $param[6];
do_mysql("UPDATE players SET money = '" . $p['money'] . "' WHERE id_player = '" . $p['id_player'] . "';");
include_once 'modules/f_create_item.php';
include_once 'modules/f_add_item_to_pl.php';
for ($i = 0; $i < $count; $i++) {
    $nitem = create_item($item);
    add_item_to_pl($LOGIN, $nitem);
    if (isset($numb)) {
        do_mysql("UPDATE items SET on_take = '" . $numb . "' WHERE fullname = '" . $nitem . "';");
    }
}
$f = gen_header('торг');
$f .= '<div class="y" id="oaidy"><b>купля:</b></div><p>';
$f .= 'вы купили ' . $count . ' ' . $param[0] . ' за ' . $param[6] . ' серебра!<br/>';
$f .= '<a class="blue" href="game.php?sid=' . $sid . '&action=trade&npc=' . $npc . '&start=' . $_GET['start'] . '&start2=' . $_GET['start2'] . '">торг</a><br/>';
$f .= '<a class="blue" href="game.php?sid=' . $sid . '">в игру</a></p>';
$f .= gen_footer();
exit($f);
Esempio n. 13
0
     $count = count($c);
     $data = array();
     for ($i = 0; $i < $count; $i++) {
         $sql = "SELECT * FROM " . $ecs->table('order_info') . " WHERE order_sn = {$c[$i]}";
         $data[$i] = $db->getAll($sql);
         // create_item($data);
     }
     //    echo "<pre>";
     // var_dump($data);
     //   echo "</pre>";
     header("Content-type: text/xml");
     $xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
     $xml .= "<orders xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>\n";
     foreach ($data as $key => $value) {
         foreach ($value as $k => $v) {
             $xml .= create_item($v['consignee'], $v['address'], $v['city'], $v['zipcode'], $v['email'], $v['mobile'], $v['order_sn']);
         }
     }
     $xml .= "</orders>\n";
     echo $xml;
     die;
 }
 if ($_POST['imformat'] == '获取导入格式') {
     alert("获取导入格式");
 }
 $order_id = '';
 /* 检查权限 */
 admin_priv('order_os_edit');
 /* 取得订单id(可能是多个,多个sn)和操作备注(可能没有) */
 if (isset($_REQUEST['order_id'])) {
     $order_id = $_REQUEST['order_id'];
function print_table_wines()
{
    global $mysql, $cptTR, $itemsByPage, $itemsByPays, $pays_count;
    $sql = "SELECT \n\t\t\t\t\t\tv_all_produits_vins.id_produit AS all_produit_produit,\n\t\t\t\t\t\tv_all_produits_vins.label AS all_produit_label,\n\t\t\t\t\t\t\n\t\t\t\t\t\tt_vins.id AS vins_id,\n\t\t\t\t\t\tt_vins.region_du_monde AS region_monde_vins,\n\t\t\t\t\t\tt_vins.pays AS pays_vins,\n\t\t\t\t\t\tt_vins.region AS region_vins,\n\t\t\t\t\t\tt_vins.categorie AS category_vins,\n\t\t\t\t\t\t\n\t\t\t\t\t\tt_stockage.id AS stockage_id,\n\t\t\t\t\t\tt_stockage.emplacement AS stockage_emplacement,\n\t\t\t\t\t\t\n\t\t\t\t\t\tt_produits_stockage.quantite AS produit_quantite,\n\t\t\t\t\t\t\n\t\t\t\t\t\tt_categories_vins.nom AS category_name,\n\t\t\t\t\t\t\n\t\t\t\t\t\tt_region_du_monde.nom AS region_du_monde_nom,\n\t\t\t\t\t\tt_pays.nom AS pays_nom,\n\t\t\t\t\t\tt_regions.nom AS region_nom\n\t\t\t\t\t\t\n\t\t\t\t\t\tFROM v_all_produits_vins\n\t\t\t\t\t\tINNER JOIN t_vins\tON v_all_produits_vins.id_vin = t_vins.id\n\t\t\t\t\t\tINNER JOIN t_categories_vins ON t_vins.categorie = t_categories_vins.id\n\t\t\t\t\t\tINNER JOIN t_region_du_monde ON t_vins.region_du_monde = t_region_du_monde.id\n\t\t\t\t\t\tLEFT JOIN t_pays ON t_vins.pays = t_pays.id\n\t\t\t\t\t\tLEFT JOIN t_regions ON t_vins.region = t_regions.id\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\tLEFT JOIN t_produits_stockage ON t_produits_stockage.produit = v_all_produits_vins.id_produit\n\t\t\t\t\t\tLEFT JOIN t_stockage ON t_produits_stockage.stockage = t_stockage.id\n\t\t\t\t\t\tORDER BY \n\t\t\t\t\t\tt_vins.categorie ASC, \n\t\t\t\t\t\tt_vins.region_du_monde ASC, \n\t\t\t\t\t\tt_vins.pays ASC, \n\t\t\t\t\t\tt_vins.region ASC, \n\t\t\t\t\t\tv_all_produits_vins.label ASC\n\t\t\t\t\t\t";
    $query = $mysql->sql_query($sql);
    $cpt = 0;
    $current_category = '';
    $current_monde = '';
    $html .= '<table>';
    $html .= '	<tbody>';
    $html .= '	<tr>';
    $html .= '		<th style="width: 470px;" align="left">Produits</th>';
    $html .= '		<th colspan="34">Rangements</th>';
    $html .= '	</tr>';
    echo $html;
    while ($result = mysqli_fetch_assoc($query)) {
        if ($result['all_produit_produit'] == $current_id) {
            array_push($wine['emplacement'], array('label' => $result['stockage_emplacement'], 'qty' => $result['produit_quantite']));
            // push new emplacement in current wine array
        } else {
            if ($wine) {
                $category = $result['category_vins'];
                $monde = $result['region_monde_vins'];
                $pays = $result['pays_vins'];
                $region = $result['region_vins'];
                if ($cpt == 0) {
                    $current_category = $category;
                    $current_monde = $monde;
                    $current_pays = $pays;
                    $current_region = $region;
                    create_separator_row('Vins ' . $result['category_name'], 'categorie');
                    create_separator_row($result['pays_nom'], 'pays');
                    create_separator_row($result['region_nom'], 'region');
                }
                if (count($wine['emplacement']) > 0) {
                    create_item($wine);
                    // print the current item in the table
                    $cpt++;
                }
                if ($cpt > 0) {
                    if ($current_category != $category && $category != '') {
                        $current_category = $category;
                        // set the current category to be able to add separator (ORDER BY t_vins.categorie)
                        if ($current_category == 2 || $current_category == 3) {
                            create_page_break();
                        }
                        create_separator_row('Vins ' . $result['category_name'], 'categorie');
                    }
                    if ($current_pays != $pays && $pays != '') {
                        $current_pays = $pays;
                        // set the current pays to be able to add separator (ORDER BY t_vins.pays)
                        create_separator_row($result['pays_nom'], 'pays');
                    }
                    $count = search_pays_count($current_category, $pays);
                    // get number of wines in the current country
                    if ($count > $itemsByPays) {
                        // check the minimum of wines required
                        if ($current_region != $region && $region != '') {
                            $current_region = $region;
                            // set the current region to be able to add separator (ORDER BY t_vins.region)
                            create_separator_row($result['region_nom'], 'region');
                        }
                    }
                }
                $wine = array();
            }
            $wine['label'] = $result['all_produit_label'];
            $wine['emplacement'] = array();
            if ($result['stockage_emplacement'] != '') {
                array_push($wine['emplacement'], array('label' => $result['stockage_emplacement'], 'qty' => $result['produit_quantite']));
            }
        }
        $current_id = $result['all_produit_produit'];
    }
    if ($wine && count($wine['emplacement']) > 0) {
        create_item($wine);
        // call this function for the last item of the recordset
    }
    $html = '	</tbody>';
    $html .= '</table>';
    return $html;
}
Esempio n. 15
0
<!DOCTYPE html>
<?php 
$data_array = array(array('title' => 'title1', 'content' => 'content1', 'pubdate' => '2009-10-11'), array('title' => 'title2', 'content' => 'content2', 'pubdate' => '2009-11-11'));
//  属性数组
$attribute_array = array('title' => array('size' => 1));
//  创建一个XML文档并设置XML版本和编码。。
$dom = new DomDocument('1.0', 'utf-8');
//  创建根节点
$article = $dom->createElement('article');
$dom->appendchild($article);
foreach ($data_array as $data) {
    $item = $dom->createElement('item');
    $article->appendchild($item);
    create_item($dom, $item, $data, $attribute_array);
}
echo $dom->saveXML();
function create_item($dom, $item, $data, $attribute)
{
    if (is_array($data)) {
        foreach ($data as $key => $val) {
            //  创建元素
            ${$key} = $dom->createElement($key);
            $item->appendchild(${$key});
            //  创建元素值
            $text = $dom->createTextNode($val);
            ${$key}->appendchild($text);
            if (isset($attribute[$key])) {
                //  如果此字段存在相关属性需要设置
                foreach ($attribute[$key] as $akey => $row) {
                    //  创建属性节点
                    ${$akey} = $dom->createAttribute($akey);
function get_category_content(&$xmlElement, &$resources, $id, $name, $exportpath, $export_dir, $identifier, &$ridentifier, $viewid)
{
    global $USER, $CFG, $COURSE;
    $bookmarks = get_category_items($id, $viewid, 'link');
    $hasItems = false;
    if ($bookmarks) {
        $hasItems = true;
        foreach ($bookmarks as $bookmark) {
            unset($filecontent);
            unset($filename);
            $filecontent = '';
            $filecontent .= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' . "\n";
            $filecontent .= '<html xmlns="http://www.w3.org/1999/xhtml">' . "\n";
            $filecontent .= '<head>' . "\n";
            $filecontent .= '  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />' . "\n";
            $filecontent .= '  <title>' . spch(format_string($bookmark->name)) . '</title>' . "\n";
            $filecontent .= '<!-- ' . get_string("exportcomment", "block_exabis_eportfolio") . ' -->';
            $filecontent .= '</head>' . "\n";
            $filecontent .= '<body>' . "\n";
            $filecontent .= '  <h1 id="header">' . spch(format_string($bookmark->name)) . '</h1>' . "\n";
            $filecontent .= '  <div id="url"><a href="' . spch($bookmark->url) . '"><!--###BOOKMARK_EXT_URL###-->' . spch($bookmark->url) . '<!--###BOOKMARK_EXT_URL###--></a></div>' . "\n";
            $filecontent .= '  <div id="description"><!--###BOOKMARK_EXT_DESC###-->' . spch_text($bookmark->intro) . '<!--###BOOKMARK_EXT_DESC###--></div>' . "\n";
            $filecontent .= add_comments('block_exabeporitemcomm', $bookmark->id);
            $filecontent .= '</body>' . "\n";
            $filecontent .= '</html>' . "\n";
            $filename = clean_param($bookmark->name, PARAM_ALPHANUM);
            $ext = ".html";
            $i = 0;
            if ($filename == "") {
                $filepath = $export_dir . $filename . $i . $ext;
            } else {
                $filepath = $export_dir . $filename . $ext;
            }
            if (is_file($exportpath . $filepath) || is_dir($exportpath . $filepath) || is_link($exportpath . $filepath)) {
                do {
                    $i++;
                    $filepath = $export_dir . $filename . $i . $ext;
                } while (is_file($exportpath . $filepath) || is_dir($exportpath . $filepath) || is_link($exportpath . $filepath));
            }
            file_put_contents($exportpath . $filepath, $filecontent);
            create_ressource($resources, 'RES-' . $ridentifier, $filepath);
            create_item($xmlElement, 'ITEM-' . $identifier, $bookmark->name, 'RES-' . $ridentifier);
            $identifier++;
            $ridentifier++;
        }
    }
    $files = get_category_items($id, $viewid, 'file');
    if ($files) {
        $hasItems = true;
        foreach ($files as $file) {
            unset($filecontent);
            unset($filename);
            $i = 0;
            $content_filename = $file->attachment;
            if (is_file($exportpath . $export_dir . $content_filename) || is_dir($exportpath . $export_dir . $content_filename) || is_link($exportpath . $export_dir . $content_filename)) {
                do {
                    $i++;
                    $content_filename = $i . $file->attachment;
                } while (is_file($exportpath . $export_dir . $content_filename) || is_dir($exportpath . $export_dir . $content_filename) || is_link($exportpath . $export_dir . $content_filename));
            }
            if ($file->attachment != '') {
                copy($CFG->dataroot . "/" . block_exabis_eportfolio_file_area_name($file) . "/" . $file->attachment, $exportpath . $export_dir . $content_filename);
            }
            $filecontent = '';
            $filecontent .= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' . "\n";
            $filecontent .= '<html xmlns="http://www.w3.org/1999/xhtml">' . "\n";
            $filecontent .= '<head>' . "\n";
            $filecontent .= '  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />' . "\n";
            $filecontent .= '  <title>' . spch($file->name) . '</title>' . "\n";
            $filecontent .= '<!-- ' . get_string("exportcomment", "block_exabis_eportfolio") . ' -->';
            $filecontent .= '</head>' . "\n";
            $filecontent .= '<body>' . "\n";
            $filecontent .= '  <h1 id="header">' . spch($file->name) . '</h1>' . "\n";
            $filecontent .= '  <div id="url"><a href="' . spch($content_filename) . '"><!--###BOOKMARK_FILE_URL###-->' . spch($content_filename) . '<!--###BOOKMARK_FILE_URL###--></a></div>' . "\n";
            $filecontent .= '  <div id="description"><!--###BOOKMARK_FILE_DESC###-->' . spch_text($file->intro) . '<!--###BOOKMARK_FILE_DESC###--></div>' . "\n";
            $filecontent .= add_comments('block_exabeporitemcomm', $file->id);
            $filecontent .= '</body>' . "\n";
            $filecontent .= '</html>' . "\n";
            $filename = clean_param($file->name, PARAM_ALPHANUM);
            $ext = ".html";
            $i = 0;
            if ($filename == "") {
                $filepath = $export_dir . $filename . $i . $ext;
            } else {
                $filepath = $export_dir . $filename . $ext;
            }
            if (is_file($exportpath . $filepath) || is_dir($exportpath . $filepath) || is_link($exportpath . $filepath)) {
                do {
                    $i++;
                    $filepath = $export_dir . $filename . $i . $ext;
                } while (is_file($exportpath . $filepath) || is_dir($exportpath . $filepath) || is_link($exportpath . $filepath));
            }
            file_put_contents($exportpath . $filepath, $filecontent);
            create_ressource($resources, 'RES-' . $ridentifier, $filepath);
            create_item($xmlElement, 'ITEM-' . $identifier, $file->name, 'RES-' . $ridentifier);
            $identifier++;
            $ridentifier++;
        }
    }
    $notes = get_category_items($id, $viewid, 'note');
    if ($notes) {
        $hasItems = true;
        foreach ($notes as $note) {
            unset($filecontent);
            unset($filename);
            $filecontent = '';
            $filecontent .= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' . "\n";
            $filecontent .= '<html xmlns="http://www.w3.org/1999/xhtml">' . "\n";
            $filecontent .= '<head>' . "\n";
            $filecontent .= '  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />' . "\n";
            $filecontent .= '  <title>' . spch($note->name) . '</title>' . "\n";
            $filecontent .= '<!-- ' . get_string("exportcomment", "block_exabis_eportfolio") . ' -->';
            $filecontent .= '</head>' . "\n";
            $filecontent .= '<body>' . "\n";
            $filecontent .= '  <h1 id="header">' . spch($note->name) . '</h1>' . "\n";
            $filecontent .= '  <div id="description"><!--###BOOKMARK_NOTE_DESC###-->' . spch_text($note->intro) . '<!--###BOOKMARK_NOTE_DESC###--></div>' . "\n";
            $filecontent .= add_comments('block_exabeporitemcomm', $note->id);
            $filecontent .= '</body>' . "\n";
            $filecontent .= '</html>' . "\n";
            $filename = clean_param($note->name, PARAM_ALPHANUM);
            $ext = ".html";
            $i = 0;
            if ($filename == "") {
                $filepath = $export_dir . $filename . $i . $ext;
            } else {
                $filepath = $export_dir . $filename . $ext;
            }
            if (is_file($exportpath . $filepath) || is_dir($exportpath . $filepath) || is_link($exportpath . $filepath)) {
                do {
                    $i++;
                    $filepath = $export_dir . $filename . $i . $ext;
                } while (is_file($exportpath . $filepath) || is_dir($exportpath . $filepath) || is_link($exportpath . $filepath));
            }
            file_put_contents($exportpath . $filepath, $filecontent);
            create_ressource($resources, 'RES-' . $ridentifier, $filepath);
            create_item($xmlElement, 'ITEM-' . $identifier, $note->name, 'RES-' . $ridentifier);
            $identifier++;
            $ridentifier++;
        }
    }
    return $hasItems;
}
     // sozdaem veshq
     if (!is_array($items[$a[1]])) {
         $items[$a[1]] = explode(':', $items[$a[1]]);
     }
     if (substr($items[$a[1]][0], 2, 1) == 'm') {
         include_once 'modules/f_create_item_m.php';
         if (!$items[$a[1]][1]) {
             $iloc = gen_rnd_loc($pl_map);
         } else {
             $iloc = gen_rnd_loc($pl_map, $items[$a[1]][1]);
         }
         $nitem = create_item_m($items[$a[1]][0], $items[$a[1]][2], $iloc, 0);
         add_item_to_loc($iloc, $nitem);
         unset($act[$i]);
     } else {
         $nitem = create_item($items[$a[1]][0]);
         // esli vtoraja chastq pusta, generiruem sluchajno iz vsej karty
         // esli net to iz ukazanyh
         if (!$items[$a[1]][1]) {
             $iloc = gen_rnd_loc($pl_map);
         } else {
             $iloc = gen_rnd_loc($pl_map, $items[$a[1]][1]);
         }
         // dobavljaem veshq v lokaciju i vse
         add_item_to_loc($iloc, $nitem);
         unset($act[$i]);
     }
 }
 if ($a[0] == 'npc' && $a[2] < $now) {
     // npc
     include_once 'modules/f_create_npc.php';