예제 #1
0
    function head()
    {
        if (!isset($_GET['sql'])) {
            return;
        }
        $suggests = $tables = array_keys(tables_list());
        foreach ($tables as $table) {
            foreach (fields($table) as $field => $foo) {
                $suggests[] = "{$table}.{$field}";
            }
        }
        ?>
<script type="text/javascript" src="static/jquery.min.js"></script>
<script type="text/javascript" src="static/tabcomplete/tabcomplete.js"></script>
<style>.hint { color: #bdc3c7; }</style>
<script type="text/javascript">
$(function(){
	$('.sqlarea').tabcomplete(['<?php 
        echo implode("', '", str_replace("'\\", '', $suggests));
        ?>
']);
});
</script>
<?php 
    }
예제 #2
0
    function head()
    {
        if (!isset($_GET['sql'])) {
            return;
        }
        $tables = array_keys(tables_list());
        $suggests = array_merge($this->keywords, $tables);
        foreach ($tables as $table) {
            foreach (fields($table) as $field => $foo) {
                $suggests[] = "{$table}.{$field}";
            }
        }
        ?>
<script type="text/javascript" src="static/jquery.min.js"></script>
<script type="text/javascript" src="static/jquery.a-tools.js"></script>
<script type="text/javascript" src="static/jquery.asuggest.js"></script>
<script type="text/javascript">
$(function(){
	if (navigator.appName == 'Microsoft Internet Explorer') {
		return;
	}

    $('.sqlarea').attr('onkeydown', '').asuggest(['<?php 
        echo implode("', '", str_replace("'\\", '', $suggests));
        ?>
'], {
        stopSuggestionKeys: [$.asuggestKeys.TAB, $.asuggestKeys.RETURN, $.asuggestKeys.SPACE, 190 /* PERIOD */],
        ignoreCase: true
    });
});
</script>
<?php 
    }
예제 #3
0
    function head()
    {
        if (!isset($_GET['sql'])) {
            return;
        }
        $suggests = array();
        foreach ($this->keywords as $keyword) {
            $suggests[] = "{$keyword} ";
        }
        foreach (array_keys(tables_list()) as $table) {
            $suggests[] = $table;
            foreach (fields($table) as $field => $foo) {
                $suggests[] = "{$table}.{$field} ";
            }
        }
        ?>
<script type="text/javascript" src="static/jquery.min.js"></script>
<script type="text/javascript" src="static/tabcomplete/tabcomplete.js"></script>
<style>.hint { color: #bdc3c7; }</style>
<script type="text/javascript">
$(function(){
	$('.sqlarea').tabcomplete(<?php 
        echo json_encode($suggests);
        ?>
);
});
</script>
<?php 
    }
예제 #4
0
파일: form.php 프로젝트: JoshuaGrams/wfpl
function update($table = NULL)
{
    if (!$table) {
        $table = $GLOBALS['table'];
    }
    $id = format_int($_REQUEST['id']);
    db_update($table, fields($table), values($table), "where id={$id}");
}
예제 #5
0
파일: slugify.php 프로젝트: ly95/adminer
 function editInput($table, $field, $attrs, $value)
 {
     static $slugify;
     if (!$_GET["select"] && !$_GET["where"]) {
         if ($slugify === null) {
             $slugify = array();
             $prev = null;
             foreach (fields($table) as $name => $val) {
                 if ($prev && preg_match('~(^|_)slug(_|$)~', $name)) {
                     $slugify[$prev] = $name;
                 }
                 $prev = $name;
             }
         }
         $slug = $slugify[$field["field"]];
         if ($slug !== null) {
             return "<input value='" . h($value) . "' maxlength='{$field['length']}' size='40'{$attrs} onchange=\"var find = '{$this->from}'; var repl = '{$this->to}'; this.form['fields[{$slug}]'].value = this.value.toLowerCase().replace(new RegExp('[' + find + ']', 'g'), function (str) { return repl[find.indexOf(str)]; }).replace(/[^a-z0-9_]+/g, '-').replace(/^-|-\$/g, '').substr(0, {$field['length']});\">";
         }
     }
 }
예제 #6
0
파일: script.php 프로젝트: Knorcedger/main
			jQuery("#in-category-22").attr("checked", "checked");
		}else if(type == 'type'){
			jQuery("#in-category-8").attr("checked", "checked");
			//jQuery("#info_box").hide();
		}else if(type == 'provider'){
			jQuery("#in-category-6").attr("checked", "checked");
		}else if(type == 'new'){
			jQuery("#in-category-25").attr("checked", "checked");
			<?php 
    fields(5, "destination", "p", "", 0);
    ?>
		}else if(type == 'home'){
			jQuery("#aiosp").css("display", "none");
			<?php 
    field_group(3, "photos", "photo_title|photo_link|homepage_photo", "p|p|div", "Φωτογραφίες αρχικής σελίδας", 1);
    fields(7, "popular_destination", "p", "", 0);
    field_group(5, "proposed_travels", "proposed_travel|proposed_title", "p|p", "", 0);
    field_group(8, "types", "type|type_title", "p|p", "", 0);
    field_group(10, "banners", "banner_title|banner_link|banner_photo|banner_active", "p|p|div|div", "", 0);
    ?>
			jQuery("#banner_box").insertAfter("#titlediv");
		}
		
		
	
		<?php 
    //THIS IS NEEDED
    //if type of the entry
    //find the id of this post type (την σειρά δηλαδή με την οποία είναι στο options)
    for ($i = 0; $i < sizeof($names); $i++) {
        if ($names[$i] == $content_type) {
예제 #7
0
}
$top = 0;
$base_left = -1;
$schema = array();
// table => array("fields" => array(name => field), "pos" => array(top, left), "references" => array(table => array(left => array(source, target))))
$referenced = array();
// target_table => array(table => array(left => target_column))
$lefts = array();
// float => bool
foreach (table_status('', true) as $table => $table_status) {
    if (is_view($table_status)) {
        continue;
    }
    $pos = 0;
    $schema[$table]["fields"] = array();
    foreach (fields($table) as $name => $field) {
        $pos += 1.25;
        $field["pos"] = $pos;
        $schema[$table]["fields"][$name] = $field;
    }
    $schema[$table]["pos"] = $table_pos[$table] ? $table_pos[$table] : array($top, 0);
    foreach ($adminer->foreignKeys($table) as $val) {
        if (!$val["db"]) {
            $left = $base_left;
            if ($table_pos[$table][1] || $table_pos[$val["table"]][1]) {
                $left = min(floatval($table_pos[$table][1]), floatval($table_pos[$val["table"]][1])) - 1;
            } else {
                $base_left -= 0.1;
            }
            while ($lefts[(string) $left]) {
                // find free $left
예제 #8
0
if ($_POST) {
    $row = $_POST;
    ksort($row["source"]);
    if ($_POST["add"]) {
        $row["source"][] = "";
    } elseif ($_POST["change"] || $_POST["change-js"]) {
        $row["target"] = array();
    }
} elseif ($_GET["name"] != "") {
    $foreign_keys = foreign_keys($TABLE);
    $row = $foreign_keys[$_GET["name"]];
    $row["source"][] = "";
}
$source = array_keys(fields($TABLE));
//! no text and blob
$target = $TABLE === $row["table"] ? $source : array_keys(fields($row["table"]));
$referencable = array();
foreach (table_status() as $name => $table_status) {
    if (fk_support($table_status)) {
        $referencable[] = $name;
    }
}
?>

<form action="" method="post">
<p>
<?php 
if ($row["db"] == "" && $row["ns"] == "") {
    echo lang('Target table');
    ?>
:
$username = fields('username');
$pwd1 = fields('pwd1');
$pwd2 = fields('pwd2');
$email = fields('email');
$truename = fields('truename');
$sex = fields('sex');
if ($sex) {
    //重置性别值
    $sex = '女';
} else {
    $sex = '男';
}
//$age=fields('age');
$birthday = fields('birthday');
$phone = fields('phone');
$personalURL = fields('personalURL');
$info = fields('info');
$arr = array('帐号:' => $username, '密码:' => $pwd1, '电子邮件:' => $email, '真实姓名:' => $truename, '性别:' => $sex, '生日:' => $birthday, '手机号码:' => $phone, '个人主页:' => $personalURL, '简介:' => $info);
$str = implode('   ', $arr);
file_put_contents('result.txt', $str);
/* create image code */
$image = imagecreatefromjpeg('images/bg_font.jpg');
$white = imagecolorallocate($image, 255, 255, 255);
imagettftext($image, 60, 0, 170, 200, $white, 'images/hanyi.ttf', '帐号:' . $arr['帐号:']);
imagettftext($image, 60, 0, 170, 270, $white, 'images/hanyi.ttf', '密码:' . $arr['密码:']);
imagettftext($image, 60, 0, 170, 340, $white, 'images/hanyi.ttf', '电子邮件:' . $arr['电子邮件:']);
imagettftext($image, 60, 0, 170, 410, $white, 'images/hanyi.ttf', '生日:' . $arr['生日:']);
imagettftext($image, 60, 0, 170, 480, $white, 'images/hanyi.ttf', '性别:' . $arr['性别:']);
imagejpeg($image, 'result.jpeg');
//end create image
message('注册成功!已生成文件:', 'register.html');
예제 #10
0
                }
                $alter[] = array($index["type"], $name, $set);
            }
        }
    }
    // drop removed indexes
    foreach ($indexes as $name => $existing) {
        $alter[] = array($existing["type"], $name, "DROP");
    }
    if (!$alter) {
        redirect(ME . "table=" . urlencode($TABLE));
    }
    queries_redirect(ME . "table=" . urlencode($TABLE), lang('Indexes have been altered.'), alter_indexes($TABLE, $alter));
}
page_header(lang('Indexes'), $error, array("table" => $TABLE), h($TABLE));
$fields = array_keys(fields($TABLE));
if ($_POST["add"]) {
    foreach ($row["indexes"] as $key => $index) {
        if ($index["columns"][count($index["columns"])] != "") {
            $row["indexes"][$key]["columns"][] = "";
        }
    }
    $index = end($row["indexes"]);
    if ($index["type"] || array_filter($index["columns"], 'strlen')) {
        $row["indexes"][] = array("columns" => array(1 => ""));
    }
}
if (!$row) {
    foreach ($indexes as $key => $index) {
        $indexes[$key]["name"] = $key;
        $indexes[$key]["columns"][] = "";
예제 #11
0
파일: geo.php 프로젝트: niko-lgdcom/barrows
 $failures = "<div id='failures'>";
 echo '<div id="success">';
 foreach ($dbh->query($sql) as $row) {
     $geocode_pending = true;
     while ($geocode_pending) {
         $delay = 100;
         $base_url = "http://" . MAPS_HOST . "/maps/api/geocode/xml?address=";
         $address = $row[fields('address')];
         $request_url = $base_url . urlencode($address) . "&sensor=true";
         $xml = simplexml_load_file($request_url) or die("url not loading");
         $status = $xml->status;
         if (strcmp($status, "OK") == 0) {
             $geocode_pending = false;
             $lat = $xml->result->geometry->location->lat;
             $lng = $xml->result->geometry->location->lng;
             $update_SQL = "UPDATE " . db('tablename') . " SET " . fields('latitude') . "='{$lat}', " . fields('longitude') . "='{$lng}' WHERE " . fields('address') . "='{$address}'";
             $count = $dbh->exec($update_SQL);
             echo '<span><strong>' . $address . '</strong> - Geocode Successful (' . $lat . ',' . $lng . ')</span>';
         } elseif (strcmp($status, "OVER_QUERY_LIMIT") == 0) {
             // sent geocodes too fast
             $delay += 100000;
         } else {
             // failure to geocode
             $geocode_pending = false;
             $failures .= "<span>" . $address . " failed to geocode. ";
             $failures .= "Received status " . $status . "</span>";
         }
         usleep($delay);
     }
 }
 $dbh = null;
예제 #12
0
/** Print results of search in all tables
* @uses $_GET["where"][0]
* @uses $_POST["tables"]
* @return null
*/
function search_tables()
{
    global $adminer, $connection;
    $_GET["where"][0]["op"] = "LIKE %%";
    $_GET["where"][0]["val"] = $_POST["query"];
    $found = false;
    foreach (table_status('', true) as $table => $table_status) {
        $name = $adminer->tableName($table_status);
        if (isset($table_status["Engine"]) && $name != "" && (!$_POST["tables"] || in_array($table, $_POST["tables"]))) {
            $result = $connection->query("SELECT" . limit("1 FROM " . table($table), " WHERE " . implode(" AND ", $adminer->selectSearchProcess(fields($table), array())), 1));
            if (!$result || $result->fetch_row()) {
                if (!$found) {
                    echo "<ul>\n";
                    $found = true;
                }
                echo "<li>" . ($result ? "<a href='" . h(ME . "select=" . urlencode($table) . "&where[0][op]=" . urlencode($_GET["where"][0]["op"]) . "&where[0][val]=" . urlencode($_GET["where"][0]["val"])) . "'>{$name}</a>\n" : "{$name}: <span class='error'>" . error() . "</span>\n");
            }
        }
    }
    echo ($found ? "</ul>" : "<p class='message'>" . lang('No tables.')) . "\n";
}
예제 #13
0
파일: script.php 프로젝트: Knorcedger/main
		}else if(type == 'cruise'){
			jQuery("#in-category-5").attr("checked", "yes");
			//move boxes
			jQuery("#additional_box").insertAfter(post_excerpt);
			jQuery("#not_included_box").insertAfter(post_excerpt);
			jQuery("#included_box").insertAfter(post_excerpt);
			jQuery("#prices_box").insertAfter(post_excerpt);
			<?php 
    fields(10, "included", "p", "Στοιχεία που περιλαμβάνονται", 1);
    fields(10, "not_included", "p", "Στοιχεία που δεν περιλαμβάνονται", 1);
    ?>
		}else if(type == 'ship'){
			jQuery("#in-category-7").attr("checked", "yes");
			<?php 
    fields(5, "additional", "p", "Πρόσθετες πληροφορίες", 1);
    fields(10, "photo", "div", "Φωτογραφίες του πλοίου", 1);
    ?>
		}else if(type == 'type'){
			jQuery("#in-category-8").attr("checked", "yes");
		}else if(type == 'provider'){
			jQuery("#in-category-6").attr("checked", "yes");
		}
			
	
		<?php 
    //THIS IS NEEDED
    //if type of the entry
    //find the id of this post type (την σειρά δηλαδή με την οποία είναι στο options)
    for ($i = 0; $i < sizeof($names); $i++) {
        if ($names[$i] == $content_type) {
            $type_id = $i;
function process_data($data, $orderid)
{
    global $language;
    $data = \customer_registration\unfreeze_json($data);
    # collect input
    $input = $data;
    unset($input['js_userobject']);
    unset($input['approve']);
    # js_userobject contains data that Ruben already has set right,
    # like 'on' => title of checkbox. So they are better
    foreach ($data['js_userobject'] as $key => $value) {
        if (empty($value)) {
            continue;
        }
        $input[$key] = $value;
    }
    # these are not used
    unset($input['maz_calc_price']);
    unset($input['mazout_calc_price']);
    unset($input['antifr_calc_price']);
    unset($input['tank_inspection_calc_price']);
    unset($input['total_calc_maz_price']);
    unset($input['birth']);
    unset($input['birth']['birthday']);
    unset($input['birth']['birthmonth']);
    unset($input['birth']['birthyear']);
    # always set values for this one
    if (!empty($input['legal'])) {
        $input['legal'] = $language->language == 'fr' ? 'oui' : 'ja';
    } else {
        // $input['legal'] = ( $language->language == 'fr' ) ? 'non' : 'nee';
        unset($input['legal']);
    }
    # 'Tariefplan: Variabel' => 'Duurtijd: 1 jaar' verbergen
    if (!empty($input['indexation']) && ($input['indexation'] == 'Variabel' || $input['indexation'] == 'Variable')) {
        unset($input['runtime']);
    }
    # process hidden prices
    handle_hidden_prices($input);
    # remove all empty values
    $_input = $input;
    $input = array();
    foreach ($_input as $key => $value) {
        if (empty($value) || $value == 'empty' || preg_match('{^\\s+$}', $value)) {
            continue;
        }
        $input[$key] = $value;
    }
    # structure 'section' > 'fields'
    $fields = fields();
    # add values to the fields structure
    foreach ($input as $key => $value) {
        $main_key = main_key($fields, $key);
        $fields[$main_key][$key] = clean_value($value);
    }
    // echo '<pre>';
    // print_r(trim($fields['personal_data']['salutation']));
    // print_r(trim(tt('No salution')));
    // exit;
    # remove empty block
    if (empty($fields['company_data']['companyname']) && empty($fields['company_data']['juridical_status'])) {
        unset($fields['company_data']);
    }
    // if ( empty( $fields['other'] ) ){
    unset($fields['other']);
    //  }
    # remove unused mazout/energy blocks
    if (empty($fields['system']['productchoice_mazout'])) {
        unset($fields['mazout']);
        unset($fields['mazout_paydata']);
    }
    # remove unused mazout/energy blocks
    if (empty($fields['system']['productchoice_elek']) && empty($fields['system']['productchoice_gas'])) {
        unset($fields['energy']);
        unset($fields['additional_data_elek']);
        unset($fields['additional_data_gas']);
    }
    # annual_calculation_domiciliation
    if (!empty($fields['energy']['annual_calculation_domiciliation'])) {
        $fields['energy']['annual_calculation_domiciliation'] = $language->language == 'fr' ? 'oui' : 'ja';
    }
    # Format leveringsadres Elek and/or gas
    if (!empty($fields['energy']['energy_delivery_street'])) {
        $my_energy_address = $fields['energy']['energy_delivery_street'] . ' ' . $fields['energy']['energy_delivery_housenumber'];
        if ($fields['energy']['energy_delivery_housebus']) {
            $my_energy_address .= '/' . $fields['energy']['energy_delivery_housebus'] . ', ';
        } else {
            $my_energy_address .= ', ';
        }
        $my_energy_address .= $fields['energy']['energy_delivery_postalcode'];
        $fields['energy']['my_delivery_address'] = $my_energy_address;
        unset($fields['energy']['energy_delivery_address']);
        unset($fields['energy']['energy_delivery_street']);
        unset($fields['energy']['energy_delivery_housenumber']);
        unset($fields['energy']['energy_delivery_housebus']);
        unset($fields['energy']['energy_delivery_postalcode']);
    }
    # use correct title for the payment data of Gas and/or Electricity
    # only elek
    if (!empty($fields['system']['productchoice_elek']) && empty($fields['system']['productchoice_gas'])) {
        $fields['elek_cr_title'] = $fields['energy'];
        $fields['elek_additional'] = $fields['additional_data_elek'];
        // indien enkel elek moet blok extra gegevens elek weg + info verplaatsen
        $fields['elek_cr_title'] = array_merge($fields['elek_cr_title'], $fields['elek_additional']);
        unset($fields['energy']);
        unset($fields['additional_data_elek']);
        unset($fields['additional_data_gas']);
        unset($fields['elek_additional']);
    } elseif (empty($fields['system']['productchoice_elek']) && !empty($fields['system']['productchoice_gas'])) {
        $fields['gas_cr_title'] = $fields['energy'];
        $fields['gas_additional'] = $fields['additional_data_gas'];
        $fields['gas_additional']['indexation'] = $language->language == 'fr' ? 'Variable' : 'Variabel';
        // indien enkel gas moet blok extra gegevens gas weg + info verplaatsen
        $fields['gas_cr_title'] = array_merge($fields['gas_cr_title'], $fields['gas_additional']);
        unset($fields['energy']);
        unset($fields['additional_data_elek']);
        unset($fields['additional_data_gas']);
        unset($fields['gas_additional']);
    } elseif (!empty($fields['system']['productchoice_elek']) && !empty($fields['system']['productchoice_gas'])) {
        $fields['gas_elek_cr_title'] = $fields['energy'];
        $fields['elek_additional'] = $fields['additional_data_elek'];
        $fields['gas_additional'] = $fields['additional_data_gas'];
        $fields['gas_additional']['indexation'] = $language->language == 'fr' ? 'Variable' : 'Variabel';
        unset($fields['energy']);
        unset($fields['additional_data_elek']);
        unset($fields['additional_data_gas']);
    }
    # remove the system block
    unset($fields['system']);
    # remove 3 birthday fields
    unset($fields['other']['birthday']);
    unset($fields['other']['birthmonth']);
    unset($fields['other']['birthyear']);
    # ander adres ja/nee
    // other_addresses( $fields /* in:out */ );
    # add orderid
    $fields['personal_data']['orderid'] = $orderid;
    # add info block tankkeuring mazout if tankkeuring
    if (!empty($data['tank_inspection']) && $data['tank_inspection'] == 'yes') {
        $tank_inspection_text1 = tt('cr_tank_inspection_price_text1');
        $tank_inspection_text2 = tt('cr_tank_inspection_price_text2');
        # add price tankkeuring in text
        $tank_inspection_text2 = str_replace('%PRICE_T%', $input['hidden_tank_inspection_price'], $tank_inspection_text2);
        $fields['tank_inspection']['tank_inspection_price_label1'] = $tank_inspection_text1;
        $fields['tank_inspection']['tank_inspection_price_label2'] = $tank_inspection_text2;
    } else {
        unset($fields['tank_inspection']);
    }
    # add info block voorafbetaling mazout if voorafbetaling
    if ($data['mazout_paymethod'] == 'mazout_pay_upfront') {
        $mazout_pay_upfront_text = tt('cr_mazout_pay_upfront_info');
        # add orderid in text
        $mazout_pay_upfront_text = str_replace('%CEM_NR%', $orderid, $mazout_pay_upfront_text);
        $fields['mazout']['mazout_paymethod'] = $mazout_pay_upfront_text;
    }
    # Format birtdate
    $fields['personal_data']['birthdate'] = preg_replace('/\\//', ' ', $fields['personal_data']['birthdate']);
    # Zonnepanelen
    if (!empty($fields['elek_additional']['solar_panels'])) {
        $fields['elek_additional']['solar_panels'] = $language->language == 'fr' ? 'oui' : 'ja';
    }
    # Put extra info block at bottom
    $fields['mail_extra_info'] = $fields['sundry'];
    unset($fields['sundry']);
    # Format leveringsadres Mazout
    if (!empty($fields['mazout']['mazout_delivery_street'])) {
        $my_mazout_address = $fields['mazout']['mazout_delivery_street'] . ' ' . $fields['mazout']['mazout_delivery_housenumber'];
        if ($fields['mazout']['mazout_delivery_housebus']) {
            $my_mazout_address .= '/' . $fields['mazout']['mazout_delivery_housebus'] . ', ';
        } else {
            $my_mazout_address .= ', ';
        }
        $my_mazout_address .= $fields['mazout']['mazout_delivery_postalcode'];
        $fields['mazout']['my_delivery_address'] = $my_mazout_address;
        unset($fields['mazout']['mazout_delivery_address']);
        unset($fields['mazout']['mazout_delivery_street']);
        unset($fields['mazout']['mazout_delivery_housenumber']);
        unset($fields['mazout']['mazout_delivery_housebus']);
        unset($fields['mazout']['mazout_delivery_postalcode']);
    }
    #if no aanspreking -> remove field
    if (trim($fields['personal_data']['salutation']) == tt('No salution')) {
        unset($fields['personal_data']['salutation']);
    }
    // echo '<pre>';
    // print_r($fields);
    // exit;
    # rebuild with internationalized values
    $fields_i18n = array();
    foreach ($fields as $key1 => $fields2) {
        # set tt() values around keys
        foreach ($fields2 as $key2 => $value2) {
            if (empty($value2)) {
                continue;
            }
            # general rule: prefix with 'cr_', but some already contain '_cr_' in the middle (Bedankt hé Ruben)
            $tt_key1 = tt_key($key1);
            $tt_key2 = tt_key($key2);
            # set translations
            $fields_i18n[tt($tt_key1)][tt($tt_key2)] = tt($value2);
        }
    }
    // echo '<pre>';
    // print_r($fields_i18n);
    // exit;
    return $fields_i18n;
}
예제 #15
0
파일: db.php 프로젝트: niko-lgdcom/barrows
<?php

require_once "db.config.php";
//Query String Variables
$extendLat = $_GET['extendLat'];
$extendLng = $_GET['extendLng'];
$southWestLat = $_GET['swLat'] - $extendLat;
$northEastLat = $_GET['neLat'] + $extendLat;
$southWestLng = $_GET['swLng'] - $extendLng;
$northEastLng = $_GET['neLng'] + $extendLng;
$cat = strtolower($_GET['cat']);
try {
    $dbh = new PDO("mysql:host=" . db('hostname') . ";dbname=" . db('dbname'), db('username'), db('password'));
    header("Content-type: text/xml");
    $sql = "SELECT * FROM " . db('tablename') . " WHERE " . fields('latitude') . " BETWEEN '{$southWestLat}' AND '{$northEastLat}' AND " . fields('longitude') . " BETWEEN '{$southWestLng}' AND '{$northEastLng}' and " . fields('category') . " = '{$cat}'";
    $xml_output = "<?xml version=\"1.0\"?>\n";
    $xml_output .= "<markers>\n";
    foreach ($dbh->query($sql) as $row) {
        $xml_output .= '<marker lat="' . $row[fields('latitude')] . '" lng="' . $row[fields('longitude')] . '" title="' . $row[fields('title')] . '" address="' . $row[fields('address')] . '" url="' . htmlentities($row[fields('url')]) . '" html="' . htmlentities($row[fields('html')], ENT_QUOTES) . '" category="' . $row[fields('category')] . '" icon="' . $row[fields('icon')] . '"/>';
    }
    $xml_output .= '<marker lat="0" lng="0" title="Blank" address="" url="" html="" category="' . $row[fields('category')] . '" icon="' . $row[fields('icon')] . '"/>';
    $xml_output .= "</markers>";
    echo $xml_output;
    $dbh = null;
} catch (PDOException $e) {
    echo $e->getMessage();
}
예제 #16
0
$TABLE = $_GET["create"];
$partition_by = array();
foreach (array('HASH', 'LINEAR HASH', 'KEY', 'LINEAR KEY', 'RANGE', 'LIST') as $key) {
    $partition_by[$key] = $key;
}
$referencable_primary = referencable_primary($TABLE);
$foreign_keys = array();
foreach ($referencable_primary as $table_name => $field) {
    $foreign_keys[str_replace("`", "``", $table_name) . "`" . str_replace("`", "``", $field["field"])] = $table_name;
    // not idf_escape() - used in JS
}
$orig_fields = array();
$table_status = array();
if ($TABLE != "") {
    $orig_fields = fields($TABLE);
    $table_status = table_status($TABLE);
    if (!$table_status) {
        $error = lang('No tables.');
    }
}
$row = $_POST;
$row["fields"] = (array) $row["fields"];
if ($row["auto_increment_col"]) {
    $row["fields"][$row["auto_increment_col"]]["auto_increment"] = true;
}
if ($_POST && !process_fields($row["fields"]) && !$error) {
    if ($_POST["drop"]) {
        queries_adminer_redirect(substr(ME, 0, -1), lang('Table has been dropped.'), drop_tables(array($TABLE)));
    } else {
        $fields = array();
예제 #17
0
 }
 if ($_POST["table_style"] || $_POST["data_style"]) {
     $views = array();
     foreach (table_status('', true) as $name => $table_status) {
         $table = DB == "" || in_array($name, (array) $_POST["tables"]);
         $data = DB == "" || in_array($name, (array) $_POST["data"]);
         if ($table || $data) {
             if ($ext == "tar") {
                 $tmp_file = new TmpFile();
                 ob_start(array($tmp_file, 'write'), 100000.0);
             }
             $adminer->dumpTable($name, $table ? $_POST["table_style"] : "", is_view($table_status) ? 2 : 0);
             if (is_view($table_status)) {
                 $views[] = $name;
             } elseif ($data) {
                 $fields = fields($name);
                 $adminer->dumpData($name, $_POST["data_style"], "SELECT *" . convert_fields($fields, $fields) . " FROM " . table($name));
             }
             if ($is_sql && $_POST["triggers"] && $table && ($triggers = trigger_sql($name, $_POST["table_style"]))) {
                 echo "\nDELIMITER ;;\n{$triggers}\nDELIMITER ;\n";
             }
             if ($ext == "tar") {
                 ob_end_flush();
                 tar_file((DB != "" ? "" : "{$db}/") . "{$name}.csv", $tmp_file);
             } elseif ($is_sql) {
                 echo "\n";
             }
         }
     }
     foreach ($views as $view) {
         $adminer->dumpTable($view, $_POST["table_style"], 1);
예제 #18
0
/** Get referencable tables with single column primary key except self
* @param string
* @return array ($table_name => $field)
*/
function referencable_primary($self)
{
    $return = array();
    // table_name => field
    foreach (table_status('', true) as $table_name => $table) {
        if ($table_name != $self && fk_support($table)) {
            foreach (fields($table_name) as $field) {
                if ($field["primary"]) {
                    if ($return[$table_name]) {
                        // multi column primary key
                        unset($return[$table_name]);
                        break;
                    }
                    $return[$table_name] = $field;
                }
            }
        }
    }
    return $return;
}
예제 #19
0
<?php

require_once dirname(__FILE__) . '/../_lib/tinyTinyFw.php';
require_once dirname(__FILE__) . '/properties.php';
$modules->let('user:join', function () {
    $module = new module();
    $module->let('fields', fields('username', 'email'));
    // Called when there is no form submission.
    $module->let('whenIdle', function ($self) {
        return widget('window')->let('content', dom('div', layout2columns($self->get('fields')), dom('pre')->css(array('border' => 'solid 1px gray', 'padding' => '0.5em'))->append('$_REQUEST = ' . var_export($_REQUEST, true))));
    });
    $module->let('whenError', function ($self) {
        return widget('message:error', "Sorry, there has been an error.");
    });
    // Called after form submission and input validation is ok.
    $module->let('whenOk', function ($self, $values) {
        // $values['username']->property;
        // Each $value has already gone through
        // validators defined by the value's underlying property -- see properties.php.
        $user = user::Create($values);
        // Can return either a layout function or dom.
        return dom('div')->append(dom('message:ok', "Thank you."), dom('message:info', "Don't forget to join a club."));
    });
    return $module;
});
예제 #20
0
 /** Export table data
  * @param string
  * @param string
  * @param string
  * @return null prints data
  */
 function dumpData($table, $style, $query)
 {
     global $connection, $jush;
     $max_packet = $jush == "sqlite" ? 0 : 1048576;
     // default, minimum is 1024
     if ($style) {
         if ($_POST["format"] == "sql") {
             if ($style == "TRUNCATE+INSERT") {
                 echo truncate_sql($table) . ";\n";
             }
             $fields = fields($table);
         }
         $result = $connection->query($query, 1);
         // 1 - MYSQLI_USE_RESULT //! enum and set as numbers
         if ($result) {
             $insert = "";
             $buffer = "";
             $keys = array();
             $suffix = "";
             $fetch_function = $table != '' ? 'fetch_assoc' : 'fetch_row';
             while ($row = $result->{$fetch_function}()) {
                 if (!$keys) {
                     $values = array();
                     foreach ($row as $val) {
                         $field = $result->fetch_field();
                         $keys[] = $field->name;
                         $key = idf_escape($field->name);
                         $values[] = "{$key} = VALUES({$key})";
                     }
                     $suffix = ($style == "INSERT+UPDATE" ? "\nON DUPLICATE KEY UPDATE " . implode(", ", $values) : "") . ";\n";
                 }
                 if ($_POST["format"] != "sql") {
                     if ($style == "table") {
                         dump_csv($keys);
                         $style = "INSERT";
                     }
                     dump_csv($row);
                 } else {
                     if (!$insert) {
                         $insert = "INSERT INTO " . table($table) . " (" . implode(", ", array_map('idf_escape', $keys)) . ") VALUES";
                     }
                     foreach ($row as $key => $val) {
                         $field = $fields[$key];
                         $row[$key] = $val !== null ? unconvert_field($field, preg_match('~(^|[^o])int|float|double|decimal~', $field["type"]) && $val != '' ? $val : q($val)) : "NULL";
                     }
                     $s = ($max_packet ? "\n" : " ") . "(" . implode(",\t", $row) . ")";
                     if (!$buffer) {
                         $buffer = $insert . $s;
                     } elseif (strlen($buffer) + 4 + strlen($s) + strlen($suffix) < $max_packet) {
                         // 4 - length specification
                         $buffer .= ",{$s}";
                     } else {
                         echo $buffer . $suffix;
                         $buffer = $insert . $s;
                     }
                 }
             }
             if ($buffer) {
                 echo $buffer . $suffix;
             }
         } elseif ($_POST["format"] == "sql") {
             echo "-- " . str_replace("\n", " ", $connection->error) . "\n";
         }
     }
 }
예제 #21
0
$top = 0;
$base_left = -1;
$schema = array();
// table => array("fields" => array(name => field), "pos" => array(top, left), "references" => array(table => array(left => array(source, target))))
$referenced = array();
// target_table => array(table => array(left => target_column))
$lefts = array();
// float => bool
foreach (table_status() as $table_status) {
    if (!isset($table_status["Engine"])) {
        // view
        continue;
    }
    $pos = 0;
    $schema[$table_status["Name"]]["fields"] = array();
    foreach (fields($table_status["Name"]) as $name => $field) {
        $pos += 1.25;
        $field["pos"] = $pos;
        $schema[$table_status["Name"]]["fields"][$name] = $field;
    }
    $schema[$table_status["Name"]]["pos"] = $table_pos[$table_status["Name"]] ? $table_pos[$table_status["Name"]] : array($top, 0);
    foreach ($adminer->foreignKeys($table_status["Name"]) as $val) {
        if (!$val["db"]) {
            $left = $base_left;
            if ($table_pos[$table_status["Name"]][1] || $table_pos[$val["table"]][1]) {
                $left = min(floatval($table_pos[$table_status["Name"]][1]), floatval($table_pos[$val["table"]][1])) - 1;
            } else {
                $base_left -= 0.1;
            }
            while ($lefts[(string) $left]) {
                // find free $left
예제 #22
0
파일: functions.php 프로젝트: php-kit/tools
/**
 * Returns a function that extracts either an associative array of specific fields from its argument, or a linear array
 * of values from one field of its argument
 *
 * <p>The function argument can be `object|array|null`.
 *
 * ><p>This is meant to be used as a callback for iterable sequences.
 *
 * ><p>**Ex:**
 * ```php
 *   $x = map ($iterable, pluck ('field'))
 * ```
 *
 * @param array|string $flds If a string, it is the name of the field to extract, otherwise it must be a linear array
 *                           of field names.
 * @return Closure
 */
function pluck($flds)
{
    return is_array($flds) ? function ($e) use($flds) {
        return fields($e, $flds);
    } : function ($e) use($flds) {
        return getField($e, $flds);
    };
}
예제 #23
0
파일: phpadmin.php 프로젝트: rohdoor/ehcp
 function dump_table($table, $data = true)
 {
     global $mysql, $max_packet;
     $result = $mysql->query("SHOW CREATE TABLE " . idf_escape($table));
     if ($result) {
         echo $mysql->result($result, 1) . ";\n\n";
         if ($max_packet < 1073741824) {
             $row_size = 21 + strlen(idf_escape($table));
             foreach (fields($table) as $field) {
                 $type = $types[$field["type"]];
                 $row_size += 5 + ($field["length"] ? $field["length"] : $type) * (preg_match('~char|text|enum~', $field["type"]) ? 3 : 1);
             }
             if ($row_size > $max_packet) {
                 $max_packet = 1024 * ceil($row_size / 1024);
                 echo "SET max_allowed_packet = {$max_packet}, GLOBAL max_allowed_packet = {$max_packet};\n";
             }
         }
         $result->free();
         if ($data) {
             $result = $mysql->query("SELECT * FROM " . idf_escape($table));
             if ($result) {
                 if ($result->num_rows) {
                     $insert = "INSERT INTO " . idf_escape($table) . " VALUES ";
                     $length = 0;
                     while ($row = $result->fetch_row()) {
                         foreach ($row as $key => $val) {
                             $row[$key] = isset($val) ? "'" . $mysql->escape_string($val) . "'" : "NULL";
                         }
                         $s = "(" . implode(", ", $row) . ")";
                         if (!$length) {
                             echo $insert, $s;
                             $length = strlen($insert) + strlen($s);
                         } else {
                             $length += 2 + strlen($s);
                             if ($length < $max_packet) {
                                 echo ", ", $s;
                             } else {
                                 echo ";\n", $insert, $s;
                                 $length = strlen($insert) + strlen($s);
                             }
                         }
                     }
                     echo ";\n";
                 }
                 $result->free();
             }
             echo "\n";
         }
     }
     if ($mysql->server_info >= 5) {
         $result = $mysql->query("SHOW TRIGGERS LIKE '" . $mysql->escape_string(addcslashes($table, "%_")) . "'");
         if ($result->num_rows) {
             echo "DELIMITER ;;\n\n";
             while ($row = $result->fetch_assoc()) {
                 echo "CREATE TRIGGER " . idf_escape($row["Trigger"]) . " {$row['Timing']} {$row['Event']} ON " . idf_escape($row["Table"]) . " FOR EACH ROW {$row['Statement']};;\n\n";
             }
             echo "DELIMITER ;\n\n";
         }
         $result->free();
     }
 }
예제 #24
0
<?php

$TABLE = $_GET["edit"];
$table_status = table_status($TABLE);
$where = isset($_GET["select"]) ? count($_POST["check"]) == 1 ? where_check($_POST["check"][0]) : "" : where($_GET);
$update = isset($_GET["select"]) ? $_POST["edit"] : $where;
$fields = fields($TABLE);
foreach ($fields as $name => $field) {
    if (!isset($field["privileges"][$update ? "update" : "insert"]) || $adminer->fieldName($field) == "") {
        unset($fields[$name]);
    }
}
if ($_POST && !$error && !isset($_GET["select"])) {
    $location = $_POST["referer"];
    if ($_POST["insert"]) {
        // continue edit or insert
        $location = $update ? null : $_SERVER["REQUEST_URI"];
    } elseif (!ereg('^.+&select=.+$', $location)) {
        $location = ME . "select=" . urlencode($TABLE);
    }
    if (isset($_POST["delete"])) {
        query_redirect("DELETE" . limit1("FROM " . table($TABLE), " WHERE {$where}"), $location, array(lang('Item has been deleted.'), 'success'));
    } else {
        $set = array();
        foreach ($fields as $name => $field) {
            $val = process_input($field);
            if ($val !== false && $val !== null) {
                $set[idf_escape($name)] = $update ? "\n" . idf_escape($name) . " = {$val}" : $val;
            }
        }
        if ($update) {
예제 #25
0
 /** Export table data
  * @param string
  * @param string
  * @param string
  * @return null prints data
  */
 function dumpData($table, $style, $query)
 {
     global $connection, $jush;
     $max_packet = $jush == "sqlite" ? 0 : 1048576;
     // default, minimum is 1024
     if ($style) {
         if ($_POST["format"] == "sql" && $style == "TRUNCATE+INSERT") {
             echo truncate_sql($table) . ";\n";
         }
         if ($_POST["format"] == "sql") {
             $fields = fields($table);
         }
         $result = $connection->query($query, 1);
         // 1 - MYSQLI_USE_RESULT //! enum and set as numbers
         if ($result) {
             $insert = "";
             $buffer = "";
             while ($row = $result->fetch_assoc()) {
                 if ($_POST["format"] != "sql") {
                     if ($style == "table") {
                         dump_csv(array_keys($row));
                         $style = "INSERT";
                     }
                     dump_csv($row);
                 } else {
                     if (!$insert) {
                         $insert = "INSERT INTO " . table($table) . " (" . implode(", ", array_map('idf_escape', array_keys($row))) . ") VALUES";
                     }
                     foreach ($row as $key => $val) {
                         $row[$key] = isset($val) ? ereg('int|float|double|decimal', $fields[$key]["type"]) ? $val : q($val) : "NULL";
                         //! columns looking like functions
                     }
                     $s = implode(",\t", $row);
                     if ($style == "INSERT+UPDATE") {
                         $set = array();
                         foreach ($row as $key => $val) {
                             $set[] = idf_escape($key) . " = {$val}";
                         }
                         echo "{$insert} ({$s}) ON DUPLICATE KEY UPDATE " . implode(", ", $set) . ";\n";
                     } else {
                         $s = ($max_packet ? "\n" : " ") . "({$s})";
                         if (!$buffer) {
                             $buffer = $insert . $s;
                         } elseif (strlen($buffer) + 4 + strlen($s) < $max_packet) {
                             // 4 - length specification
                             $buffer .= ",{$s}";
                         } else {
                             echo "{$buffer};\n";
                             $buffer = $insert . $s;
                         }
                     }
                 }
             }
             if ($_POST["format"] == "sql" && $style != "INSERT+UPDATE" && $buffer) {
                 $buffer .= ";\n";
                 echo $buffer;
             }
         } elseif ($_POST["format"] == "sql") {
             echo "-- " . str_replace("\n", " ", $connection->error) . "\n";
         }
     }
 }