Example #1
0
function getUserLang()
{
    global $langs;
    // read out language from header as array
    $langlist = getLangs();
    // choose most matching language from available langs
    foreach ($langlist as $value) {
        if (array_key_exists($value, $langs)) {
            return $value;
        }
    }
    // if no matching language could be found, choose english
    return "en";
}
Example #2
0
// include translation file
includeLocale($_GET['lang']);
$format = $_GET['format'];
$id = $_GET['id'];
$type = $_GET['type'];
// offset of user's timezone to UTC
$offset = offset($_GET['offset']);
$callback = $_GET['callback'];
date_default_timezone_set('UTC');
// protection of sql injections
if (!isValidType($type) || !isValidId($id)) {
    echo "NULL";
    exit;
}
// get the most important langs of the user
$langs = getLangs();
if ($_GET['lang']) {
    $langs[0] = $_GET['lang'];
}
if (!getDetails($db, $id, $type, $langs, $offset)) {
    echo "NULL";
}
function getDetails($db, $id, $type, $langs, $offset)
{
    global $format, $callback;
    // request
    $request = "SELECT\n\t\t\t\ttags->'addr:street' AS \"street\",\n\t\t\t\ttags->'addr:housenumber' AS \"housenumber\",\n\t\t\t\ttags->'addr:housename' AS \"housename\",\n\t\t\t\ttags->'addr:country' AS \"country\",\n\t\t\t\ttags->'addr:postcode' AS \"postcode\",\n\t\t\t\ttags->'addr:city' AS \"city\",\n\t\t\t\ttags->'addr:suburb' AS \"suburb\",\n\t\t\t\ttags->'addr:province' AS \"province\",\n\t\t\t\ttags->'addr:unit' AS \"unit\",\n\t\t\t\ttags->'addr:floor' AS \"floor\",\n\t\t\t\ttags->'addr:door' AS \"door\",\n\t\t\t\ttags->'phone' AS \"phone1\",\n\t\t\t\ttags->'contact:phone' AS \"phone2\",\n\t\t\t\ttags->'addr:phone' AS \"phone3\",\n\t\t\t\ttags->'fax' AS \"fax1\",\n\t\t\t\ttags->'contact:fax' AS \"fax2\",\n\t\t\t\ttags->'addr:fax' AS \"fax3\",\n\t\t\t\ttags->'website' AS \"website1\",\n\t\t\t\ttags->'url' AS \"website2\",\n\t\t\t\ttags->'url:official' AS \"website3\",\n\t\t\t\ttags->'contact:website' AS \"website4\",\n\t\t\t\ttags->'operator' AS \"operator\",\n\t\t\t\ttags->'email' AS \"email1\",\n\t\t\t\ttags->'contact:email' AS \"email2\",\n\t\t\t\ttags->'addr:email' AS \"email3\",\n\t\t\t\ttags->'opening_hours' AS \"openinghours\",\n\t\t\t\ttags->'service_times' AS \"servicetimes\",\n\t\t\t\ttags->'image' AS \"image\"\n\t\t\tFROM " . $type . "s WHERE (id = " . $id . ");";
    $wikipediarequest = "SELECT\n\t\t\t\t\t\t\t\tfoo.keys, foo.values\n\t\t\t\t\t\t\tFROM (\n\t\t\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\t\t\tskeys(tags) AS keys,\n\t\t\t\t\t\t\t\t\tsvals(tags) AS values\n\t\t\t\t\t\t\t\tFROM " . $type . "s\n\t\t\t\t\t\t\t\tWHERE (id = " . $id . ")\n\t\t\t\t\t\t\t) AS foo\n\t\t\t\t\t\t\tWHERE substring(foo.keys from 1 for 9) = 'wikipedia';";
    $namerequest = "SELECT\n\t\t\t\t\t\t\t\tfoo.keys, foo.values\n\t\t\t\t\t\t\tFROM (\n\t\t\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\t\t\tskeys(tags) AS keys,\n\t\t\t\t\t\t\t\t\tsvals(tags) AS values\n\t\t\t\t\t\t\t\tFROM " . $type . "s\n\t\t\t\t\t\t\t\tWHERE (id = " . $id . ")\n\t\t\t\t\t\t\t) AS foo\n\t\t\t\t\t\t\tWHERE substring(foo.keys from 1 for 4) = 'name';";
    // connnecting to database
    $connection = connectToDatabase($db);
Example #3
0
_e('set_title_descr');
?>
</span></th>
<td> <input name="title" value="<?php 
echo htmlspecialchars(_c('title'));
?>
" class="in350" /> </td>
</tr>

<tr>
<th><?php 
_e('set_language');
?>
:</th>
<td> <select name="lang"><?php 
echo selectOptionsA(getLangs(1), _c('lang'));
?>
</select> </td>
</tr>

<tr>
<th><?php 
_e('set_protection');
?>
:</th>
<td>
<label><input type="radio" name="allowpassword" value="1" <?php 
if (_c('password') != '') {
    echo 'checked="checked"';
}
?>
<?php

//$languages = array("ar","bg","bn","ca","cs","de","el","en","es","eu","fr","ga","hi","hr","hu","it","ja","ko","nl","pl","pt","ru","sl","tr");
require 'scraperwiki/scraperwiki.php';
require 'scraperwiki/simple_html_dom.php';
$languages = getLangs();
function getLangs()
{
    $url = "http://mappings.dbpedia.org/server/statistics/";
    $html = scraperwiki::scrape($url);
    $dom = new simple_html_dom();
    $dom->load($html);
    $i = 0;
    $langs = array();
    foreach ($dom->find('/html/body/p/a') as $result) {
        $lang = str_replace("/", "", trim($result->href));
        $langs[] = $lang;
    }
    return $langs;
}
Example #5
0
function getReceivers($db)
{
    $receivers = array();
    if (isset($_POST["users_ids"]) && $_POST["users_ids"] != "") {
        print "Spacific ids = " . $_POST["users_ids"] . "<br>";
        $arr = explode(";", $_POST["users_ids"]);
        $ids = "";
        for ($i = 0; $i < count($arr); $i++) {
            if ($arr[$i] != "") {
                if ($i == 0) {
                    $ids = "id=" . $arr[$i];
                } else {
                    $ids .= " or id=" . $arr[$i];
                }
            }
        }
        $result = $db->getUsersOfCond($ids);
        while ($row = mysql_fetch_array($result)) {
            $receivers[] = $row["registration_id"];
            print "selected  = " . $row["registration_id"] . "<br>";
        }
        if (count($receivers) > 0) {
            return $receivers;
        }
    }
    $send_method = $_POST["send_method"];
    if (!isset($_POST["send_method"])) {
        $send_method = 1;
    }
    switch ($send_method) {
        case 1:
            $result = $db->getAllUsers();
            while ($row = mysql_fetch_array($result)) {
                $receivers[] = $row["registration_id"];
            }
            break;
        case 2:
            $users = getRegions();
            for ($i = 0; $i < count($users); $i++) {
                $subusers = $db->getUsersByRegionId($users[$i]);
                while ($row = mysql_fetch_array($subusers)) {
                    $receivers[] = $row["registration_id"];
                }
            }
            /*
                        if(count($receivers) == 0){
                            $result = $db->getAllUsers();
                            while ($row = mysql_fetch_array($result)){
                                $receivers[] = $row["registration_id"];
                            }
                        }*/
            break;
        case 3:
            $users = getLangs();
            for ($i = 0; $i < count($users); $i++) {
                $subusers = $db->getUsersByLangId($users[$i]);
                while ($row = mysql_fetch_array($subusers)) {
                    $receivers[] = $row["registration_id"];
                }
            }
            /*
                        if(count($receivers) == 0){
                            $result = $db->getAllUsers();
                            while ($row = mysql_fetch_array($result)){
                                $receivers[] = $row["registration_id"];
                            }
                        }*/
            break;
    }
    return $receivers;
}