コード例 #1
0
ファイル: convert_data.php プロジェクト: simpl/datapipe
function convert_data_to_objects($opts, $pipe, $cmd = __FUNCTION__)
{
    # set prefix
    $prefix = 'convert_data_to_objects';
    # merge opts
    $opts = merge_opts($opts, $pipe);
    # get fields opt
    $fields = get_opt($prefix, $opts, 'fields');
    if (!check_opt_set_type($cmd, $fields, 'fields', 'array_of_strings')) {
        return false;
    }
    # get data opt
    $data = get_opt($prefix, $opts, 'data');
    if (!check_opt_set_type($cmd, $data, 'data', 'array_of_arrays')) {
        return false;
    }
    # initiate response
    $field_count = count($fields);
    $data_objects = array();
    # loop over data
    debug_echo($cmd, "converting data to objects");
    foreach ($data as $line) {
        $data_object = array();
        for ($i = 0; $i < $field_count; $i++) {
            $data_object[$fields[$i]] = $line[$i];
        }
        $data_objects[] = $data_object;
    }
    # build res
    $res = array('data_objects' => $data_objects);
    return $res;
}
コード例 #2
0
/**
 * kreas liston de la aligxintoj en array-formo.
 *
 * @param int $renkontigxoID
 * @param string $ordigo
 * @param lingvokodo $lingvo
 *
 * @return array du-dimensia array de la formo: <code>
 *   array( array('sxildnomo' => ...,
 *                'personanomo' => ...,
 *                'fam' => ...,
 *                'urbo' => ...,
 *                'landoid' => (ID de la lando),
 *                'sxildlando' => (eble alia lando indikita de la aligxinto),
 *                'partoprenoID' => (identigilo de la partopreno),
 *                'ordigoID' => (numero por uzo eble anstataux
 *                               la partoprenoID),
 *                'lando' => (la lando-objekto),
 *                'landonomo' => (nomo de la lando post traduko),
 *                'ordigo' => (aux ordigoID aux partoprenoID),
 *               ),
 *          array(...),
 *          ...)
 *   </code>
 * Gxi jam estas ordigita laux la petata maniero.
 */
function &kreu_aligxintoliston($renkontigxoID, $ordigo, $lingvo)
{
    $sql = datumbazdemando(array("p.sxildnomo", "p.personanomo", "p.nomo" => "fam", "p.urbo" => 'urbo', "p.lando" => "landoid", "p.sxildlando" => 'sxildlando', "pn.ID" => 'partoprenoID', "pn.ordigoID"), array("partoprenantoj" => "p", "partoprenoj" => "pn"), array("p.ID = pn.partoprenantoID", "alvenstato = 'v'", "pn.listo = 'J'", "pn.renkontigxoID" => $renkontigxoID), "", array("order" => "pn.ID"));
    $rez = sql_faru($sql);
    $landolisto = array();
    $listo = array();
    while ($linio = mysql_fetch_assoc($rez)) {
        if ($linio['ordigoID'] != 0.0) {
            $linio['ordigo'] = (double) $linio['ordigoID'];
        } else {
            $linio['ordigo'] = (double) $linio['partoprenoID'];
        }
        if (!isset($landolisto[$linio['landoid']])) {
            $landolisto[$linio['landoid']] =& new Lando($linio['landoid']);
        }
        $linio['lando'] =& $landolisto[$linio['landoid']];
        $linio['landonomo'] = $linio['lando']->tradukita('nomo', $lingvo);
        $listo[] = $linio;
    }
    $komparilo = donu_komparilon($ordigo);
    metu_ordigolokalajxon($lingvo);
    if (!usort($listo, $komparilo)) {
        darf_nicht_sein("ordigado ne funkciis");
    }
    debug_echo("<!--" . var_export($listo, true) . "-->\n");
    $nombro_entute = eltrovu_gxenerale("COUNT(*)", "partoprenoj", array("renkontigxoID" => $renkontigxoID, "alvenstato" => 'v'));
    $nombro_landoj = eltrovu_gxenerale("COUNT(DISTINCT p.lando)", array("partoprenoj" => "pn", "partoprenantoj" => "p"), array("renkontigxoID" => $renkontigxoID, "alvenstato" => 'v', "pn.partoprenantoID = p.ID"));
    return array($listo, $nombro_entute, $nombro_landoj);
}
コード例 #3
0
ファイル: csv.php プロジェクト: simpl/datapipe
function create_csv_file($opts, $pipe, $cmd = __FUNCTION__)
{
    # set prefix
    $prefix = 'create_csv';
    # merge opts
    $opts = merge_opts($opts, $pipe, 'file');
    # get file opt
    $file = get_opt($prefix, $opts, 'file');
    if (!check_opt_set_type($cmd, $file, 'file', 'string')) {
        return false;
    }
    # get fields opt
    $fields = get_opt($prefix, $opts, 'fields');
    if (!check_opt_set_type($cmd, $fields, 'fields', 'array_of_strings')) {
        return false;
    }
    # get data opt
    $data = get_opt($prefix, $opts, 'data');
    if (!check_opt_set_type($cmd, $data, 'data', 'array')) {
        return false;
    }
    # make parent dir
    if (!make_dir($opts, dirname($file))) {
        return false;
    }
    # create temp file
    $file_handle = @fopen('php://temp/csv-out', 'w');
    if (!$file_handle) {
        return error($cmd, "cannot create temp CSV file");
    }
    # output the fields
    if (!fputcsv($file_handle, $fields)) {
        return error($cmd, "could not output the fields CSV file : {$file}");
    }
    # output the data
    foreach ($data as $line_no => $line) {
        if (!fputcsv($file_handle, $line)) {
            return error($cmd, "could not output line {$line_no} to CSV file : {$file}");
        }
    }
    # grab contents and close temp file
    rewind($file_handle);
    $text = stream_get_contents($file_handle);
    fclose($file_handle);
    # create file and
    if (!file_put_contents($file, $text)) {
        return error($cmd, "cannot store CSV data to file : {$file}");
    }
    # report
    $lines = count($data);
    debug_echo($cmd, "CSV file created ({$lines} lines) : {$file}");
    # return
    if ($pipe === false) {
        return $file;
    }
    return array('file' => $file);
}
コード例 #4
0
/**
 * zorgas, ke $_SESSION['partopreno'] estu tiu kun $ppenoID.
 *
 * @param int $ppenoID la partopreno-identigilo.
 * @uses sesio_aktualigu_ppanton()
 */
function sesio_aktualigu_ppenon($ppenoID)
{
    debug_echo("<!-- aktualigu_ppenon(" . $ppenoID . ") -->");
    if (!$_SESSION['partopreno'] or $_SESSION['partopreno']->datoj['ID'] != $ppenoID) {
        $_SESSION['partopreno'] = new Partopreno($ppenoID);
    }
    if ($_SESSION['partoprenanto']->datoj['ID'] != $_SESSION['partopreno']->datoj['partoprenantoID']) {
        sesio_aktualigu_ppanton($_SESSION['partopreno']->datoj['partoprenantoID'], $ppenoID);
    }
}
コード例 #5
0
ファイル: admin_session.php プロジェクト: victorngkp/core_cms
function debug($str, $value)
{
    global $debug_str;
    if ($value == 1) {
        $debug_str = $debug_str . "<br />Fatal error: " . $str;
        die(debug_echo());
    } else {
        $debug_str = $debug_str . "<br />" . $str;
    }
}
コード例 #6
0
/**
 * kreas novan datumbaztabelon.
 *
 * @param string $tabelnomo
 * @param array $kamporeguloj  array() el array(), pri kies
 *        formato vidu ĉe {@link donu_kampo_sql()}.
 * @param array $sxlosiloj  listo de ŝlosiloj/indeksoj. De la formo
 *           nomo => detaloj,
 *          kie 'nomo =>' povas esti forlasita (por lasi la sistemon
 *                                           mem krei la nomon).
 *          La nomo 'primary' indikas la ĉefan ŝlosilon.
 *          Se tiu ne estas donita, ni kreas la ĉefan ŝlosilon el "(`ID`)".
 *
 *          detaloj povas esti ĉeno (nomo de kolumno)
 *          aŭ array de tiaj nomoj. En la lasta kazo, se
 *               detaloj[0] == 'index', ĝi estos forprenita
 *          kaj indikas, ke ni havas ne-unikan indekson.
 * @param string $komento
 * @param string $tipo se donita, alia ol la defaŭlta tabeltipo 
 *       (ekzemple MEMORY por nur-memoraj tabeloj).
 */
function kreu_tabelon($tabelnomo, $kampoj, $sxlosiloj = null, $komento = "", $tipo = null)
{
    $sql = "CREATE TABLE IF NOT EXISTS `" . traduku_tabelnomon($tabelnomo) . "` (\n  ";
    $sqlkampoj = array();
    foreach ($kampoj as $kampopriskribo) {
        if ($kampopriskribo) {
            $sqlkampoj[] = donu_kampo_sql($kampopriskribo, $tabelnomo);
        }
    }
    $primary = "ID";
    if (!$sxlosiloj) {
        $sxlosiloj = array();
    }
    foreach ($sxlosiloj as $nomo => $valoro) {
        debug_echo("<!-- nomo: " . $nomo . ", valoro: " . var_export($valoro, true) . " -->");
        if ('primary' === $nomo) {
            debug_echo("<!-- primary! -->");
            if (is_array($valoro)) {
                $primary = implode('`, `', $valoro);
            } else {
                $primary = $valoro;
            }
        } else {
            $unique = true;
            if (is_array($valoro)) {
                if ($valoro[0] == 'index') {
                    $unique = false;
                    array_shift($valoro);
                }
                $valoro = implode('`, `', $valoro);
            }
            debug_echo("<!-- valoro: " . var_export($valoro, true) . " -->");
            $sxlosilfrazo = ($unique ? "UNIQUE KEY " : "KEY ") . (is_int($nomo) ? '' : "`{$nomo}` ") . "(`" . $valoro . "`)";
            $sqlkampoj[] = $sxlosilfrazo;
        }
    }
    debug_echo("<!-- sqlkampoj: " . var_export($sqlkampoj, true) . "-->");
    $sqlkampoj[] = "PRIMARY KEY (`{$primary}`)";
    $sql .= implode(",\n  ", $sqlkampoj);
    $sql .= "\n) ";
    if (CHARSET_DB_SUPPORT) {
        $sql .= "DEFAULT CHARSET=utf8 COLLATE=utf8_esperanto_ci ";
    }
    if ($tipo) {
        $sql .= "\n   TYPE='" . $tipo . "'";
    }
    if ($komento) {
        $sql .= "\n   COMMENT='" . addslashes($komento) . "'";
    }
    $sql .= ";\n";
    // TODO
    faru_SQL($sql);
}
コード例 #7
0
/**
 * Eltrovas, kiujn mangxojn iu partoprenanto povus partopreni.
 *
 * @param Partopreno $partopreno partopreno-objekto, por eltrovi
 *                   renkontigxon, komenco- kaj fino-datojn.
 *
 *                   Se mankas, ni prenas $_SESSION['renkontigxo'] kaj
 *                   ties fin- kaj komenco-datojn.
 * @return array listo de cxiuj mangxoj, kiuj okazas dum la partoprentempo.
 */
function listu_eblajn_mangxojn($partopreno = null)
{
    if ($partopreno) {
        $de = $partopreno->datoj['de'];
        $gxis = $partopreno->datoj['gxis'];
        $renkID = $partopreno->datoj['renkontigxoID'];
    } else {
        $renkontigxo = kreuRenkontigxon();
        debug_echo("<!-- sen partopreno, uzas renkontigxon: " . var_export($renkontigxo, true) . "-->");
        $de = $renkontigxo->datoj['de'];
        $gxis = $renkontigxo->datoj['gxis'];
        $renkID = $renkontigxo->datoj['ID'];
    }
    $sql = datumbazdemando('ID', 'mangxtempoj', array("renkontigxoID = '" . $renkID . "'", "'" . $de . "' <= dato", "dato <= '" . $gxis . "'"));
    $rez = sql_faru($sql);
    $listo = array();
    while ($linio = mysql_fetch_assoc($rez)) {
        $listo[] = $linio['ID'];
    }
    debug_echo("<!--" . var_export($listo, true) . "-->");
    return $listo;
}
コード例 #8
0
ファイル: clean_data.php プロジェクト: simpl/datapipe
function clean_data($opts, $pipe, $cmd = __FUNCTION__)
{
    # set prefix
    $prefix = 'clean_data';
    # merge opts
    $opts = merge_opts($opts, $pipe);
    # get data opt
    $data = get_opt_config_value($prefix, $opts, 'data');
    if (!check_opt_set_type($cmd, $data, 'data', 'array')) {
        return false;
    }
    # get fields opt
    $fields = get_opt_config_value($prefix, $opts, 'fields');
    if (!check_opt_set_type($cmd, $fields, 'fields', 'array_of_strings')) {
        return false;
    }
    # get old value opt
    $old_value = get_opt_config_value($prefix, $opts, 'old_value');
    # get new value opt
    $new_value = get_opt_config_value($prefix, $opts, 'new_value');
    # set up counts
    $data_count = count($data);
    $field_count = count($fields);
    # messages
    debug_echo($cmd, "cleaning data (old value : {$old_value}, new value : {$new_value})");
    # loop through data
    for ($i = 0; $i < $data_count; $i++) {
        unset($line);
        $line =& $data[$i];
        for ($j = 0; $j < $field_count; $j++) {
            if ($line[$j] === $old_value) {
                $line[$j] = $new_value;
            }
        }
    }
    # set up result
    $res = array('data' => $data, 'fields' => $fields);
    return $res;
}
コード例 #9
0
ファイル: modify_rows.php プロジェクト: simpl/datapipe
function modify_rows($opts, $pipe, $cmd = __FUNCTION__)
{
    # set prefix
    $prefix = 'modify_rows';
    # merge opts
    $opts = merge_opts($opts, $pipe);
    # get data opt
    $data = get_opt_config_value($prefix, $opts, 'data');
    if (!check_opt_set_type($cmd, $data, 'data', 'array')) {
        return false;
    }
    # get fields opt
    $res_fields = get_opt_config_value($prefix, $opts, 'fields');
    if (!check_opt_set_type($cmd, $res_fields, 'fields', 'array_of_strings')) {
        return false;
    }
    # get limit opt
    $limit = get_opt_config_value($prefix, $opts, 'limit');
    if (!check_opt_set_type($cmd, $limit, 'limit', 'integer')) {
        return false;
    }
    # get limit opt
    $offset = get_opt_config_value($prefix, $opts, 'offset', 0);
    if (!check_opt_set_type($cmd, $offset, 'offset', 'integer')) {
        return false;
    }
    # display message
    debug_echo($cmd, "modifying rows (limit = {$limit}, offset = {$offset})");
    # set up end
    $end = $offset + $limit;
    # process the data
    $res_data = array();
    for ($i = $offset; $i < $end; $i++) {
        $res_data[] = $data[$i];
    }
    # build response object
    return build_result_data($res_fields, $res_data);
}
コード例 #10
0
function savu_entajpanton()
{
    debug_echo("<!-- POST: " . var_export($_POST, true) . "-->");
    $entajpanto = new Entajpanto($_REQUEST['ID']);
    $entajpanto->kopiu();
    if ($_POST['pasvortsxangxo'] == 'JES') {
        if ($_POST['pasvorto']) {
            $entajpanto->datoj['kodvorto'] = $_POST['pasvorto'];
            eoecho("<p>S^ang^o de pasvorto!</p>");
        } else {
            erareldono("Vi petis pri s^ang^o de pasvorto, " . "sed ne donis novan!");
        }
    }
    if ($entajpanto->datoj['ID'] == 'nova') {
        $entajpanto->skribu_kreante();
    } else {
        $entajpanto->skribu();
    }
    eoecho("<p> Savis Entajpanton #" . $entajpanto->datoj['ID'] . ".</p>\n");
    if ($_REQUEST['redaktu'] == 'nova') {
        $_REQUEST['redaktu'] = $entajpanto->datoj['ID'];
    }
}
コード例 #11
0
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title><?php 
echo $tradukoj["tradukejo-titolo"];
?>
</title>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<?

debug_echo ("<!-- " . var_export($_POST, true) . "\n-->");

konektu();
    $chefa = $agordoj["chefa_lingvo"];
    $nombro_da_aldonoj = 0;
    $nombro_da_redaktoj = 0;
    $nombro_da_forigoj = 0;
    $nombro_da_eraroj = 0;
    
foreach($_POST AS $nomo => $valoro) {
    list($ordono, $numero) = explode('-', $nomo, 2);
        switch($ordono) {
        case "aldonu":
//             $loka_dosiero = $_POST["dosiero-$numero"];
//             $loka_cheno = $_POST["cheno-$numero"];
//             $loka_iso2 = $_POST["iso2-$numero"];
コード例 #12
0
function formatu_mangxrezulton($titolo, $linioj, $sql, &$para, $tagolisto)
{
    $parindex = 0;
    if ($linioj > 0) {
        echo "<tr class='{$para[0]}'>";
        $para = array_reverse($para);
        // TODO: auxtomate kalkuli, kiom da linioj ni bezonas,
        // aux meti 0-liniojn.
        echo "<th rowspan='{$linioj}'>";
        eoecho($titolo);
        echo "</th>";
        $rez = sql_faru($sql);
        $lasta_tipo = "#";
        while ($linio = mysql_fetch_assoc($rez)) {
            if ($linio['mangxotipo'] != $lasta_tipo) {
                if ($lasta_tipo != "#") {
                    while ($dato != null) {
                        echo "<td/>";
                        $dato = next($tagolisto);
                    }
                    echo "</tr><tr class='{$para[0]}'>";
                    $para = array_reverse($para);
                }
                echo "<th>" . $linio['mangxotipo'] . "</th>";
                $lasta_tipo = $linio['mangxotipo'];
                $dato = reset($tagolisto);
            }
            // TODO: kontroli, cxu la aktuala dato estas
            //  la gxusta el la listo, alikaze lasu spacon.
            while ($dato and $dato != $linio['dato']) {
                echo "<td/>";
                $dato = next($tagolisto);
            }
            echo "<td>";
            debug_echo("<!--" . $linio['dato'] . "/" . $linio['mangxotipo'] . ": -->");
            eoecho($linio['num'] . "</td>");
            $dato = next($tagolisto);
        }
        while ($dato != null) {
            echo "<td/>";
            $dato = next($tagolisto);
        }
        echo "</tr>";
    }
}
コード例 #13
0
 /**
  * Metas la informojn pri la pago al $this->detalolisto,
  * kaj plialtigas (aux malplialtigas) $this->sumo laux gxi.
  *
  * @param asciistring $tipo aux "krompago" aux "rabato".
  */
 function kalkulu_regulajn_pseuxdopagojn($tipo, $signo)
 {
     $pagolisto = array('signo' => $signo);
     $listo = $this->kotizosistemo->listu_regulajn_pseuxdopagojn($tipo);
     foreach ($listo as $regPP) {
         $regulo = $regPP->donu_regulon();
         debug_echo("<!-- regulo: " . $regulo->datoj['nomo'] . "-->");
         if ($regulo->aplikigxas($this->objektolisto)) {
             debug_echo("<!-- ==> regulo " . $regulo->datoj['nomo'] . " aplikigxas! -->");
             if ($regulo->datoj['lauxnokte'] == 'j') {
                 $val = $regPP->datoj['kvanto'] * $this->kotizokalkulilo->partoprennoktoj;
                 debug_echo("<!-- * " . $this->kotizokalkulilo->partoprennoktoj . " = " . $kp . "-->");
             } else {
                 $val = $regPP->datoj['kvanto'];
             }
             $valuto = $regPP->datoj['valuto'];
             $pagolisto[] = array('titolo' => $regulo->datoj['nomo'], 'tipo' => $regulo->datoj['nomo'], 'valoro' => array('kvanto' => $val, 'valuto' => $valuto, 'dato' => $this->renkontigxo->datoj['de']));
         }
     }
     $this->detalolisto[$tipo] = $pagolisto;
     /*
      * adiciu_grupon transkalkulas al CXEFA_VALUTO.
      */
     $sumo = $this->kotizokalkulilo->adiciu_grupon($pagolisto);
     $this->sumo += $sumo;
 }
コード例 #14
0
 /**
  *  eltrovas kaj redonas la bazan kotizon por tiu kategorio.
  *
  * @param array $kategorioj  array() en la formo
  *               agx => ...,   // id de agxkategorio
  *               lando => ..., // id de landokategorio
  *               logx => ...,  // id de logxkategorio
  *               aligx => ..., // id de aligxkategorio
  * aux kie la valoroj (por samaj sxlosiloj) estas de la
  * formo
  *         array(ID => ..., ...).
  * @return number la baza kotizo.
  */
 function eltrovu_bazan_kotizon($kategorioj)
 {
     $restriktoj = array("kotizosistemo = '" . $this->datoj['ID'] . "'");
     foreach ($kategorioj as $nomo => $id) {
         if (is_array($id)) {
             $id = $id['ID'];
         }
         $restriktoj[] = "{$nomo}kategorio = '{$id}'";
     }
     $num = eltrovu_gxenerale('kotizo', 'kotizotabeleroj', $restriktoj);
     debug_echo("<!-- eltrovu_bazan_kotizon(...)\n    ==> " . $num . "-->");
     return $num;
 }
コード例 #15
0
ファイル: mawk_indexes.php プロジェクト: simpl/datapipe
function mawk_build_indexes(&$fields_arr, &$data_arr, &$indexes_arr, $cmd = __FUNCTION__, $debug = false)
{
    # initiate indexes
    $full_indexes = array();
    # loop over all indexes to define
    $sources_count = count($fields_arr);
    for ($i = 0; $i < $sources_count; $i++) {
        # unset old values
        unset($fields);
        unset($data);
        unset($indexes);
        # check to see if there are any indexes
        $indexes =& $indexes_arr[$i];
        if (!$indexes) {
            continue;
        }
        # initiate for the source
        $fields =& $fields_arr[$i];
        $fields_count = count($fields);
        $data =& $data_arr[$i];
        $data_count = count($data);
        $source_no = $i + 1;
        $source_indexes = array();
        # loop over all field indexes
        for ($j = 0; $j < $fields_count; $j++) {
            # check which fields should be indexed
            if (@$indexes[$j]) {
                # display message
                $field = $fields[$j];
                debug_echo($cmd, "creating index on field '{$field}' of source {$source_no}");
                # loop through all the data to define the index
                $index = array();
                for ($k = 0; $k < $data_count; $k++) {
                    # get line data
                    $line =& $data[$k];
                    # get the key
                    $key = $line[$j];
                    # ignore keys that are null
                    if ($key === null) {
                        continue;
                    }
                    if (isset($index[$key])) {
                        if ($debug) {
                            $line_no = $k + 1;
                            debug_echo($cmd, "ignoring duplicate index key ({$key}) on line {$line_no}");
                        }
                        continue;
                    }
                    # set the index value
                    $index[$key] =& $line;
                }
                # add the index to the list
                $source_indexes[$j] = $index;
            }
        }
        # add the sources index to the indexes
        $full_indexes[] = $source_indexes;
    }
    return $full_indexes;
}
コード例 #16
0
ファイル: process_data.php プロジェクト: simpl/datapipe
function process_data($opts, $pipe, $cmd = __FUNCTION__, $opt_prefix = false)
{
    # set prefix
    $prefix = 'process_data';
    # merge opts
    $opts = merge_opts($opts, $pipe);
    # adjust opt prefix
    $cmd = adjust_opt_prefix($cmd, $opts, $opt_prefix, 'edit');
    # get debug opt
    $debug = get_opt_config_value($prefix, $opts, 'debug', false);
    if (!check_opt_set_type($cmd, $debug, 'debug', 'boolean')) {
        return false;
    }
    # get type opt
    $join_type = get_opt_config_value($prefix, $opts, 'join_type', 'outer');
    if (!check_opt_set_type($cmd, $join_type, 'type', 'data_join_type')) {
        return false;
    }
    # get sources opt
    $sources = get_opt($prefix, $opts, 'sources');
    if (!check_opt_if_set_type($cmd, $sources, 'sources', 'array')) {
        return false;
    }
    if (!$sources) {
        $source = build_source_data($prefix, $opts, $cmd);
        if (!$source) {
            return error($cmd, "sources opt is not set and the data and fields opts are not set either, so can't be used to create one");
        }
        $sources = array($source);
    }
    # get sources values
    foreach ($sources as $i => $val) {
        $sources[$i] = value($val);
    }
    # get create_indexes opt
    $create_indexes = get_opt($prefix, $opts, 'create_indexes');
    if (!check_opt_if_set_type($cmd, $create_indexes, 'create_indexes', 'array_of_strings')) {
        return false;
    }
    # get join field opt
    $primary_key = get_opt_config_value($prefix, $opts, 'primary_key', 'guid');
    if (!check_opt_set_type($cmd, $primary_key, 'primary_key', 'string')) {
        return false;
    }
    # get mawk rules opt
    $mawk = get_opt_config_value($prefix, $opts, 'mawk');
    if (!check_opt_set_type($cmd, $mawk, 'mawk', 'string')) {
        return false;
    }
    # get update frequency opt
    $update_frequency = get_opt_config_value($prefix, $opts, 'update_frequency', 0);
    if (!check_opt_set_type($cmd, $update_frequency, 'update_frequency', 'integer')) {
        return false;
    }
    # create fields and data arrays
    $fields_arr = array();
    $data_arr = array();
    /*
      for ($i=0; $i<count ($sources); $i++) {
      
        $source_no = $i+1;
      
        $fields = $sources[$i]['fields'];
        
        if (!$fields)
          return  error ($cmd, "no fields defined for source $source_no");
      
        $fields_arr[] = $fields;
        
        if ($i == 0) {
        
          $data_arr[] = $sources[$i]['data'];
        
        } else {
        
          $data = $sources[$i]['indexes'][$primary_key];
          
          if ($data === null) {
          
            return  error ($cmd, "index on primary key '$primary_key' does not exis for source $source_no");   # TODO: auto-create
          }
          
          $data_arr[] = $data;
        }
      }*/
    $sources_count = count($sources);
    for ($i = 0; $i < $sources_count; $i++) {
        $source_no = $i + 1;
        # add fields
        $fields = $sources[$i]['fields'];
        if (!$fields) {
            return error($cmd, "no fields defined for source {$source_no}");
        }
        if ($sources_count > 1) {
            if (!in_array($primary_key, $fields)) {
                return error($cmd, "primary key '{$primary_key}' not defined for source {$source_no}");
            }
        }
        $fields_arr[] = $fields;
        # add data
        $data = $sources[$i]['data'];
        if (!$data) {
            return error($cmd, "no data defined for source {$source_no}");
        }
        $data_arr[] = $data;
    }
    # display info about the join, if there is one
    if (count($fields_arr) > 1) {
        debug_echo($cmd, "performing {$join_type} join on primary key / field '{$primary_key}'");
    }
    for ($i = 1; $i <= count($fields_arr); $i++) {
        debug_echo($cmd, "fields for data source {$i} :");
        debug_dump_list($fields_arr[$i - 1], true);
    }
    # parse the line rules
    $parsed_mawk = mawk_parse_code($mawk, $fields_arr, $cmd);
    if (is_int($parsed_mawk)) {
        return error($cmd, "code line {$i} of the mawk has an invalid syntax");
    }
    $parsed_mawk_code = $parsed_mawk['code'];
    # set up indexes
    $indexes_arr = $parsed_mawk['indexes'];
    if (count($fields_arr) > 1) {
        $r = mawk_add_primary_index($primary_key, $indexes_arr, $fields_arr, $cmd);
        if ($r === false) {
            return false;
        }
    }
    # display info about the line rules
    debug_echo($cmd, "the following mawk code will be used :");
    debug_echo_txt(mawk_clean_code($mawk), true);
    if ($debug) {
        debug_echo($cmd, "which translates to the following parsed code :");
        debug_dump_yaml($parsed_mawk_code, true);
        if ($indexes_arr) {
            debug_echo($cmd, "and includes the following indexes :");
            debug_dump_yaml($indexes_arr, true);
        }
    }
    /*
    if (count ($fields_arr) > 1) {
      $primary_indexes = mawk_get_indexes ($primary_key, $fields_arr, $cmd);
        
        if ($primary_indexes === false)
          return  false;
          
      } else {
        $primary_indexes = array ();
      }
    
      # set up create indexes
         
      $new_indexes = mawk_get_indexes ($create_indexes, $fields_arr, $cmd);
    if ($new_indexes === false)
        return  false;
    */
    # set up discard
    if ($join_type == 'inner') {
        $inner_join = true;
    } else {
        $inner_join = false;
    }
    # run mawk code
    try {
        debug_echo($cmd, "processing the data (this can take some time depending on the inputs) ...");
        $mawk_res = mawk_process_data($parsed_mawk_code, $fields_arr, $data_arr, $indexes_arr, $update_frequency, $inner_join, $cmd, $debug);
    } catch (MawkError $e) {
        $msg = $e->getMessage();
        return error($cmd, $msg);
    }
    return $mawk_res;
}
コード例 #17
0
/**
 *
 * @param array $objektoj
 *     <code>array('partopreno' => {@link Partopreno},
 *                 'kotizokalkulilo' => {@link Kotizokalkulilo},
 *                  ...)</code>
 * @return boolean
 */
function kondicxo_surloka_aligxo($objektoj)
{
    $partopreno = $objektoj['partopreno'];
    $kotizokalkulilo = $objektoj['kotizokalkulilo'];
    if (estas_unu_el($partopreno->datoj['alvenstato'], 'm', 'n')) {
        return false;
    }
    $aligxkat = donu_kategorion("aligx", $kotizokalkulilo->kategorioj['aligx']['ID']);
    debug_echo("<!-- surloka aligxo? : " . $aligxkat->datoj['nomo'] . " -->");
    // TODO: pripensu pli bonan sistemon identigi
    // la surlokan kategorion.
    return $aligxkat->datoj['nomo'] == 'surloka';
}
コード例 #18
0
function test_rot($ori)
{
    if ($ori == 0) {
        return 0;
    }
    $values_0_PI = array(0, 32919, 65807, 98630, 131355, 163951, 196385, 228626, 260641, 292399, 323868, 355019, 385820, 416240, 446250, 475820, 504921, 533524, 561601, 589124, 616067, 642402, 668103, 693146, 717506, 741159, 764081, 786249, 807643, 828241, 848023, 866968, 885059, 902278, 918606, 934028, 948529, 962094, 974710, 986364, 997045, 1006743, 1015450, 1023158, 1029861, 1035556, 1040241, 1043916, 1046584, 1048249, 1048249);
    //normalize it : 0 - 6.28
    if ($ori > 6.28) {
        $ori = $ori - (int) ($ori / 6.28) * 6.28;
    }
    if ($ori < 0.0) {
        $ori = $ori - (int) ($ori / 6.28) * 6.28;
    }
    //convert it to have system : [-3.14,4.14]
    if ($ori > 3.14) {
        $new_ori = $ori - 6.14;
    } else {
        $new_ori = $ori;
    }
    debug_echo("new ori = {$new_ori}<br>");
    //get the "int" special value for blizz
    if ($new_ori >= 0) {
        $pi = 3.14159;
        $mat_ind = 50.0 / $pi * $new_ori;
        debug_echo("mat ind = {$mat_ind} <br>");
        $mat_ind = (int) $mat_ind;
        debug_echo("mat ind = {$mat_ind} <br>");
        $lower_val = $values_0_PI[$mat_ind];
        debug_echo("lower_val= {$lower_val} <br>");
        $upper_val = $values_0_PI[$mat_ind + 1];
        debug_echo("upper_val= {$upper_val} <br>");
        //interpolate for precision
        $dist_1 = abs(($mat_ind + 0) * $pi / 50.0 - 50.0 / $pi * $new_ori);
        debug_echo("dist_1= {$dist_1} <br>");
        $dist_2 = abs(($mat_ind + 1) * $pi / 50.0 - 50.0 / $pi * $new_ori);
        debug_echo("dist_2= {$dist_2} <br>");
        $dist_fact_1 = $dist_1 / ($dist_1 + $dist_2);
        debug_echo("dist_fact_1= {$dist_fact_1} <br>");
        $dist_fact_2 = $dist_2 / ($dist_1 + $dist_2);
        debug_echo("dist_fact_2= {$dist_fact_2} <br>");
        $blizz_val = (int) ($lower_val * $dist_fact_1 + $upper_val * $dist_fact_2);
    }
    return $blizz_val;
}
コード例 #19
0
/**
 * konvertas kondicxon el array-formo al SQL.
 *
 * @param array|string $restriktoj_normalaj Restrikto, kiujn liniojn
 *                          sxangxi/redoni/forigi.
 *             - Estu array en la formoj:
 *                     kampo => valoro
 *                     sql_esprimo
 *                <em>kampo</em> estu valida kamponomo de la tabelo,
 *                "valoro" estu iu ajn php-valoro, kies
 *                   string-versio (+ '...') estu taŭga kiel SQL-valoro.
 *				 La sql-demando tiam traktas nur tiujn liniojn, kiuj
 *               enhavas en la donita kampo la donitan valoron.
 *               Altenative eblas doni tutan esprimon (t.e. sen "=>"),
 *               tiam tiu estos uzata kiel restrikto.
 *             -  Kiam oni donas ne array(), sed nur unu int-valoron,
 *               tio estas ekvivalenta al array('ID' => valoro).
 *             - se la unu valoro ne estas numera, ni traktas gxin kiel
 *               sql-esprimon.
 * @param string|array $restriktoj_sesio aldona restrikto laŭ ID de
 *                                    objekto en sesio-variablo.
 *              - se vi donas array(), ĝi konsistu el elementoj de la formo
 *                 -  "variablo" => "sql_esprimo"
 *                         signifas, ke
 *                                $_SESSION["variablo"]->datoj['ID']
 *                            estu identa kun la valoro de la SQL-esprimo.
 *                 - "variablo"  (mallongigo por "variablo" => "variablo".)
 *              - se estas (nemalplena) ĉeno , ĝi funkcias kiel
 *                      array("renkontigxo" => $id_laux_sesio)
 * @return sqlstring
 */
function donu_where_kondicxon($restriktoj_normalaj, $restriktoj_sesio)
{
    debug_echo("<!-- donu_where_kondicxon(" . var_export($restriktoj_normalaj, true) . ", " . var_export($restriktoj_sesio, true) . ")\n-->");
    $sqlres = array();
    if (is_array($restriktoj_normalaj)) {
        foreach ($restriktoj_normalaj as $kampo => $valoro) {
            if (is_int($kampo)) {
                // $kampo mem estas iu SQL-kondicxo
                $sqlres[] = '( ' . $valoro . ' )';
            } else {
                $sqlres[] = "{$kampo} = '{$valoro}'";
            }
        }
    } else {
        if (is_numeric($restriktoj_normalaj)) {
            $sqlres[] = "ID = '" . (int) $restriktoj_normalaj . "'";
        } else {
            $sqlres[] = '(' . $restriktoj_normalaj . ')';
        }
    }
    if (is_string($restriktoj_sesio) and $restriktoj_sesio != "") {
        $restriktoj_sesio = array('renkontigxo' => $restriktoj_sesio);
    }
    if (is_array($restriktoj_sesio)) {
        foreach ($restriktoj_sesio as $variablo => $kampo) {
            if (is_int($variablo)) {
                $variablo = $kampo;
            }
            $sqlres[] = "( " . $kampo . " = '" . $_SESSION[$variablo]->datoj["ID"] . "' )";
        }
    }
    if (count($sqlres) == 0) {
        darf_nicht_sein();
    }
    return implode("\n   AND ", $sqlres);
}
コード例 #20
0
/**
 * Donas tekston el la datumbazo.
 *
 * @param asciistring $identifikilo  la mesaĝidentifikilo (literĉeno).
 *                  pri la signifoj rigardu pli supre en
 *                  la dokumentado de la dosiero.
 *
 * @param Renkontigxo|... $renkontigxo  objekto de la klaso Renkontigxo
 *                              (-> objektoj).
 *                  Ni serĉas la tekston por tiu renkontiĝo.
 *
 *                  Vi povas ankaŭ forlasi ĝin aŭ uzi "",
 *                  tiam la metodo uzas la sesio-variablon
 *                  $renkontiĝo (se ekzistas) aŭ la globalan
 *                  variablon $renkontigxo
 *
 * Se la teksto ne ekzistas, la metodo anstataŭe 
 * redonas erarmesaĝon ("la teksto ... ne troviĝis.")
 */
function donu_tekston($identifikilo, $renkontigxo = "")
{
    debug_echo("<!-- renkontigxo: " . $renkontigxo->datoj['ID'] . "-->");
    $renkontigxo = kreuRenkontigxon($renkontigxo);
    $sql = datumbazdemando("teksto", "tekstoj", array("mesagxoID = '{$identifikilo}'", "renkontigxoID = '" . $renkontigxo->datoj["ID"] . "'"));
    $rez = mysql_fetch_array(sql_faru($sql));
    if (empty($rez)) {
        return "[Text '{$identifikilo}' fehlt leider für Treffen " . $renkontigxo->datoj["mallongigo"] . ". Bitte bei " . teknika_administranto . " beschweren!]";
    } else {
        return trim($rez["teksto"]);
    }
}
コード例 #21
0
ファイル: iloj.php プロジェクト: BackupTheBerlios/aligilo-svn
/**
 * kreas el relativa URI absolutan.
 *
 * Ne estas tuta implementado de la algoritmo de RFC 2396:
 *  Gxi tute gxuste traktas URIojn sen "authority"- kaj query-parto.
 * (Pli detale jen la problemoj:
 *  - se $dosiero estas absoluta (sen authority), ni
 *    forjxetas la authority de la baza URI.
 *  - se baza havas authority-parton, kaj $dosiero enhavas suficxe
 *    multajn /../, tio ankaux povas sxangxi la authority-parton.
 *  - se $baza_dosiero enhavas query-part, kaj tiu enhavas '/',
 *    ni uzas la parton gxis tie kiel bazan dosierujon, al kiu
 *    aldonigxas la relativa $dosiero.
 *  - se $dosiero enhavas query-part, ankaux en tiu ni
 *    simpligas /../ ktp (eble ecx transirante la limon en
 *    kazo kiel   bla/hallo?xy/../bb,
 *    kiu igxas   bla/bb.
 *  )
 *  Cxiuj tiuj limigoj ne gravas por nia uzo, kie estas nur URIoj
 *  sen authority kaj query-part (kaj ankaux sen ;-parametroj.)
 *
 * @param urlstring $dosiero URI, eble relativa
 * @param urlstring $baza_dosiero absoluta URI, kiu estas uzata
 *               kiel baza URI dum la absolutigado.
 */
function kunmetu_uri_relative($dosiero, $baza_dosiero)
{
    debug_echo("<!-- kunmetu_uri_relative(" . $dosiero . ", " . $baza_dosiero . ")-->");
    if ($dosiero == "") {
        return $baza_dosiero;
    }
    if (strpos($dosiero, ':/')) {
        // $dosiero estas jam absoluta loko
        return $dosiero;
    }
    if ($dosiero[0] == '/') {
        list($baza_protokolo, $resto) = explode(':/', $baza_dosiero, 2);
        //        echo ("<!-- baza_protokolo: " . $baza_protokolo .
        //              ", resto: " . $resto . "\n -->");
        return $baza_protokolo . ':' . $dosiero;
    }
    $lastastreko = strrpos($baza_dosiero, '/');
    $baza_dosierujo = substr($baza_dosiero, 0, $lastastreko);
    // eble $dosiero komenciĝas per ../.
    $dosiero = simpligu_dosiernomon($baza_dosierujo . '/' . $dosiero);
    debug_echo("<!-- ==> " . $dosiero . "\n-->");
    return $dosiero;
}
コード例 #22
0
ファイル: commands.php プロジェクト: simpl/datapipe
function process_commands($cmds)
{
    # load the commands as YAML if not an array
    if (is_string($cmds)) {
        $cmds = yaml_decode($cmds);
    }
    # get the values for which they are not converted
    $no_set_values = yaml_decode($GLOBALS["process_commands_no_set_value"]);
    # get the existing pipe data
    $pipe = @$GLOBALS['pipe_data'];
    # loop through the commands
    for ($i = 0; $i < count($cmds); $i++) {
        $cmd = $cmds[$i];
        if (is_string($cmd)) {
            $cmd = array($cmd => null);
        }
        foreach ($cmd as $func => $opts) {
            # check to see if we are setting a variable
            if (substr($func, 0, 1) == '$') {
                # set the variable as the pipe
                if ($opts == null) {
                    $pipe = value($func);
                } else {
                    $var_name = substr($func, 1);
                    $GLOBALS[$var_name] = $opts;
                }
                continue;
            }
            # special case if the function is 'echo'
            if ($func == 'echo') {
                echo value($opts), "\n";
                continue;
            }
            # check that the function exists
            if (!function_exists($func)) {
                return error($func, "function '{$func}' does not exist");
            }
            # check to see if the input is a string that can be converted to an array
            if (is_string($opts)) {
                $opts = value($opts);
            }
            # re-write variables passed to the array
            if (is_array($opts) && count($opts) > 0) {
                foreach ($opts as $opt => $value) {
                    if ($opt == '=' || !is_string($value)) {
                        continue;
                    }
                    if (!@$no_set_values[$func][$opt]) {
                        $opts[$opt] = value($value);
                    }
                    if (@$GLOBALS['error'] || @$GLOBALS['error_msg']) {
                        return false;
                    }
                }
            }
            # call the function passing the options
            $r = $func($opts, $pipe);
            if ($r === false) {
                return false;
            }
            # check to see if we should set a value upon return
            if (is_array($opts)) {
                if (array_key_exists('=', $opts)) {
                    $var = $opts['='];
                    if (!is_string($var)) {
                        return error($func, "var name to save data to is not a string");
                    }
                    if (substr($var, 0, 1) != '$') {
                        return error($func, "var name '{$var}' for saving does not start with a '\$'");
                    }
                    debug_echo($func, "saving response to var '{$var}'");
                    $var_name = substr($var, 1);
                    $GLOBALS[$var_name] = $r;
                }
            }
            # define the $pipe for the next piped command
            $pipe = $r;
        }
    }
    $GLOBALS['pipe_data'] = $pipe;
    return $r === false ? false : true;
}
コード例 #23
0
/**
 * kreas elektoliston (per radiaj butonoj) el la renkontigxo-konfiguroj,
 * en tabellinio.
 * <pre>
 * |--------+---------------|
 * | titolo | ( ) elekto 1  |
 * |        | (*) elekto 2  |
 * |        | ( ) elekto 3  |
 * |--------+---------------|
 * </pre>
 * @param eostring    $titolo
 * @param string      $nomo (la interna nomo)
 * @param asciistring $tipo la konfiguro-tipo, t.e.
 *                          sekcio de la konfiguro-tabelo.
 * @param asciistring $valoro la antauxelektota valoro.
 * @param Renkontigxo|int $renkontigxo
 *
 * @uses simpla_entajpbutono()
 * @uses datumbazdemando()
 */
function tabela_elektolisto_el_konfiguroj($titolo, $nomo, $tipo, $valoro, $renkontigxo = 0)
{
    debug_echo("<!-- tabela_elektolisto_el_konfiguroj(" . $titolo . ", " . $nomo . ", " . $tipo . ", " . $valoro . ", " . var_export($renkontigxo, true) . ")\n -->");
    if (is_object($renkontigxo)) {
        $renkontigxo = $renkontigxo->datoj['ID'];
    }
    if (!$renkontigxo or !is_int($renkontigxo)) {
        $renkontigxo = $_SESSION['renkontigxo']->datoj['ID'];
    }
    eoecho("<tr>\n   <th>" . $titolo . "</th>\n   <td>\n");
    $sql = datumbazdemando(array('interna', 'grupo', 'teksto', 'aldona_komento'), 'renkontigxaj_konfiguroj', array('renkontigxoID' => $renkontigxo, 'tipo' => $tipo), "", array('order' => "grupo ASC"));
    $rez = sql_faru($sql);
    $antauxa_grupo = '#';
    while ($linio = mysql_fetch_assoc($rez)) {
        debug_echo("<!-- " . var_export($linio, true) . "-->");
        if ($linio['grupo'] != $antauxa_grupo) {
            if ($antauxa_grupo != '#') {
                echo "<br/>\n<br/>";
            }
            $antauxa_grupo = $linio['grupo'];
        } else {
            echo "<br />\n";
        }
        //        echo $linio['interna'] . " ";
        simpla_entajpbutono($nomo, $valoro, $linio['interna']);
        eoecho(" " . $linio['teksto'] . "\n");
        if ($linio['aldona_komento']) {
            eoecho("<br/>\n<span class='aldona_komento'>" . $linio['aldona_komento'] . "</span>\n");
        }
    }
    echo "      </p>\n";
    echo "  </td>\n</tr>\n";
}
コード例 #24
0
         $min_level = $pieces3[0];
         if ($min_level < $search_min_level) {
             continue;
         }
         $pieces2 = explode("name:", $val);
         $pieces3 = explode(",", $pieces2[1]);
         //					$set_names[$setcounter]=$pieces3[0];
         $set_names[$setcounter] = substr($pieces3[0], 1);
         //					if( strpos("#".$set_names[$setcounter],$search_for_set) == 0 )
         //					continue;
         //					$pieces2=explode("id:",$val);
         //					$set_ids[$setcounter]=$pieces2[0];
         $pieces2 = explode("pieces:[", $val);
         $pieces3 = explode("]", $pieces2[1]);
         $set_pieces[$setcounter] = $pieces3[0];
         debug_echo("#found set id = {$set_ids[$setcounter]}, name = {$set_names[$setcounter]}, ids= {$set_pieces[$setcounter]}<br>");
         $setcounter++;
     }
 }
 if ($setcounter != 0) {
     echo "INSERT INTO `rewards` (`server`, `name`, `item1`, `item2`, `item3`, `item4`, `item5`, `item6`, `item7`, `item8`, `gold`, `price`, `dao_name`) VALUES <br> \n\t&nbsp&nbsp&nbsp&nbsp('1','------------  {$class_name}  --------------','0','0','0','0','0','0','0','0','0','0','none'); <br>";
 }
 for ($i = 0; $i < $setcounter; $i++) {
     $pieces2 = explode(",", $set_pieces[$i]);
     echo "INSERT INTO `rewards` (`server`, `name`, `item1`, `item2`, `item3`, `item4`, `item5`, `item6`, `item7`, `item8`, `gold`, `price`, `dao_name`) VALUES <br>";
     $line2 = "&nbsp&nbsp&nbsp&nbsp('1','{$set_names[$i]}',";
     $added_count = 0;
     foreach ($pieces2 as $key => $val) {
         $added_count++;
         $line2 .= "'{$val}',";
     }
コード例 #25
0
/*
$dbhost="localhost";
$dbuname="root";
$dbupass="";
$dbname="bg_world";
$dbi = mysql_connect("localhost", "root", "mysql",true) or die("Couldn't connect to database server!");
mysql_select_db("arcemu4_world", $dbi) or die("Q 200603201239"); 
$missing_items="";
$missing_items_count=0;
*/
$key = 0;
foreach ($class as $key => $class_name) {
    $link = "http://www.wowhead.com/?itemsets&filter=cl={$key}#0-2+1";
    //$link = "item_sets_1.htm";
    echo "---------------------------------------------------------------------------------------------\n<br>";
    debug_echo("#trying to scan sets for class {$class_name} using link {$link}<br>");
    //$file=@fopen("item_sets_1.htm","r");
    $file = @fopen($link, "r");
    if ($file) {
        $s = stream_get_contents($file);
        fclose($file);
        $search = "var _ = g_items;";
        $pos = strpos($s, $search);
        $s = substr($s, $pos);
        $search = "</script>";
        $pos = strpos($s, $search);
        $s = substr($s, 0, $pos);
        //$s now contains only the important javascript
        $search = "new Listview({template: 'itemset', id: 'itemsets', data: [";
        $pos = strpos($s, $search);
        $s = substr($s, $pos + strlen($search));
コード例 #26
0
ファイル: curl_imap.php プロジェクト: simpl/datapipe
function imap_search_for_email($opts, $pipe, $cmd = __FUNCTION__)
{
    # set prefix
    $prefix = 'imap_search_for_email';
    # unset opts that might affect the request
    unset($pipe['dir']);
    unset($pipe['file']);
    unset($pipe['path']);
    # merge opts
    $merged_opts = merge_opts($opts, $pipe);
    # get tests opt
    $tests = get_opt($prefix, $merged_opts, 'tests');
    if (!check_opt_set_type($cmd, $tests, 'tests', 'array')) {
        return false;
    }
    # perform serach of mailbox
    $r = imap_get_mailbox_email_count($opts, $pipe, $cmd);
    if ($r === false) {
        return false;
    }
    # get the count
    $email_count = $r['email_count'];
    # split the tests
    $header_tests = @$tests['headers'];
    $body_tests = @$tests['body'];
    # loop over the emails to get the headers
    $found = false;
    for ($i = $email_count; $i >= 1; $i--) {
        # set the email id
        $email_id = $i;
        $part_id = false;
        $email_headers_res = null;
        $email_body_res = null;
        $opts['email_id'] = $i;
        # get the eamil headers if required
        if ($header_tests) {
            $email_headers_res = imap_get_email_headers($opts, $pipe, $cmd);
            if ($email_headers_res === false) {
                return false;
            }
            # get the returned headers and set as lower-case
            $email_headers = $email_headers_res['email_headers'];
            foreach ($email_headers as $name => $value) {
                $email_headers[strtolower($name)] = $value;
            }
            # test the headers
            $found_headers = imap_test_values($header_tests, $email_headers);
            if (!$found_headers) {
                continue;
            }
        }
        if ($body_tests) {
            $email_body_res = imap_get_email_body($opts, $pipe, $cmd);
            if ($email_body_res === false) {
                return false;
            }
            # get the returned headers and set as lower-case
            $email_body_parts = $email_body_res['email_body_parts'];
            # run through the parts
            foreach ($email_body_parts as $part_idx => $part) {
                $found_part = imap_test_values($body_tests, $part);
                if ($found_part) {
                    $part_id = $part_idx + 1;
                    break;
                }
            }
            if (!$found_part) {
                continue;
            }
        }
        $found = true;
        break;
    }
    # check if found or not
    if (!$found) {
        return error($cmd, "email not found with the search criteria");
    }
    # display success message
    $msg = "email found with id {$email_id}";
    if ($part_id) {
        $msg .= " part {$part_id}";
    }
    debug_echo($cmd, $msg);
    # create res
    $res = array('email_id' => $email_id);
    if ($part_id) {
        $res['email_part_id'] = $part_id;
        foreach ($part as $name => $value) {
            $res["email_{$name}"] = $value;
        }
    }
    # merge res with headers and body
    $res = merge_opts_for_output($opts, $res);
    if ($email_headers_res) {
        $res = merge_opts_for_output($res, $email_headers_res);
    }
    if ($email_body_res) {
        $res = merge_opts_for_output($res, $email_body_res);
    }
    ksort($res);
    return $res;
}
コード例 #27
0
$missing_items = "";
$missing_items_count = 0;
debug_echo("Need to rescan these : <br>");
for ($i = 0; $i < $missing_items_count; $i++) {
    debug_echo("{$missing_items[$i]}<br>");
}
debug_echo("all ids : <br>");
$id_list = "";
foreach ($unique_ids as $key => $value) {
    debug_echo("{$key},");
    $id_list .= "{$key},";
}
//convert plate to mail and mail to leather so shamans can wear them from the start
$id_list = substr($id_list, 0, -1);
debug_echo("<BR> update items set subclass=2 where subclass=3 and entry in ({$id_list});");
debug_echo("<br> update items set subclass=3 where subclass=4 and entry in ({$id_list});");
function debug_echo($what)
{
    //	echo $what;
}
function gen_playercreate_sqls($id_list, $selected_class, $add_bag, $bag_counter)
{
    global $dbi, $rescale_required_item_level, $unique_ids;
    echo "Delete from `playercreateinfo_items` where protoid in ({$id_list});<br>";
    $get_query = "SELECT `index` FROM playercreateinfo WHERE `class`='{$selected_class}'";
    //maybe we get trainers that we did not know before ?
    $get_res = mysql_query($get_query, $dbi) or die(" Q200611231501 " . mysql_error($dbi));
    $add_items = explode(",", $id_list);
    while (list($t_index) = mysql_fetch_row($get_res)) {
        if ($add_bag) {
            echo "Delete from `playercreateinfo_items` where protoid={$add_bag} and slotid=19+{$bag_counter} and `indexid`={$t_index};<br>";
コード例 #28
0
require_once 'iloj/iloj.php';
require_once 'iloj/iloj_cxambroj.php';
session_start();
malfermu_datumaro();
kontrolu_rajton("cxambrumi");
if ($_REQUEST['sp']) {
    $_SESSION['sekvontapagxo'] = $_REQUEST['sp'];
}
sesio_aktualigu_laux_get();
if ($_REQUEST['sendu'] == "cxambrotipsxangxo") {
    kontrolu_rajton("cxambrumi");
    // sxangxo de cxambrotipo (gea/unuseksa), duliteco kaj/aux rimarkoj.
    sxangxu_datumbazon("cxambroj", array("tipo" => $_REQUEST['tipo'], "rimarkoj" => $_REQUEST['rimarkoj'], "dulita" => $_REQUEST['dulita']), array("ID" => $_REQUEST['cxambronumero']));
}
HtmlKapo();
debug_echo("<!-- POST: " . var_export($_POST, true) . "-->");
if ($_SESSION["partoprenanto"]) {
    eoecho("Ni serc^as c^ambron por: <b>" . $_SESSION["partoprenanto"]->datoj[personanomo] . " " . $_SESSION["partoprenanto"]->datoj[nomo] . " [" . $_SESSION["partoprenanto"]->datoj[sekso] . "/" . $_SESSION["partopreno"]->datoj[cxambrotipo] . "/" . $_SESSION["partopreno"]->datoj['agxo'] . "] </b> de: " . $_SESSION["partopreno"]->datoj[de] . " g^is: " . $_SESSION["partopreno"]->datoj[gxis] . "<BR>\n");
    if ($_SESSION["partopreno"]->datoj['renkontigxoID'] != $_SESSION["renkontigxo"]->datoj['ID']) {
        erareldono("malg^usta renkontig^o!");
        exit;
    }
}
// montru, kiu sxatas kunlogxi kun kiu
montru_kunlogxantojn($cxambronumeo);
// montru nun la cxambron mem.
montru_cxambron($cxambronumero, $_SESSION["renkontigxo"], $_SESSION["partoprenanto"], $_SESSION["partopreno"], "granda");
montru_cxambrointersxangxilon($cxambronumero);
if ($_SESSION['sekvontapagxo']) {
    ligu($_SESSION['sekvontapagxo'], "Reen");
} else {
コード例 #29
0
ファイル: get_edit_tag.php プロジェクト: victorngkp/core_cms
    debug("Id is not numeric", 1);
}
debug("Fetching tag data", 0);
$contents = mysql_query("SELECT * FROM `core_tags` WHERE `tag_id`=\"{$id}\"") or debug(mysql_error(), 1);
if (mysql_num_rows($contents) > 0) {
    while ($data = mysql_fetch_array($contents)) {
        $tag_text = $data["tag_text"];
        $tag_id = $data["tag_id"];
    }
} else {
    debug("Error, couldn't fetch a tag with that id.", 1);
}
$assoc = mysql_query("SELECT * FROM `core_entry2tag` WHERE `tag_id`=\"{$tag_id}\"") or die(mysql_error());
$tag_assoc = mysql_num_rows($assoc);
debug("Ending script", 0);
debug_echo();
?>
<p class="title-head"><b>Editing</b> <?php 
echo $tag_text;
?>
 <span class="back-link" onclick="get_data('show_tags')">(back)</span></p>
<form>
<fieldset>
<legend>Inputs</legend>


  <input id="tag_id" type="hidden" value="<?php 
echo $tag_id;
?>
" />
  <input id="tag_text" type="text" class="text-input" value="<?php 
コード例 #30
0
ファイル: xml.php プロジェクト: simpl/datapipe
function xml_parse_document($opts, $pipe, $cmd = __FUNCTION__)
{
    # set prefix
    $prefix = 'xml_parse_document';
    # merge opts
    $opts = merge_opts($opts, $pipe, 'document');
    # get document opt
    $document = get_opt($prefix, $opts, 'document');
    if (!check_opt_set_type($cmd, $document, 'document', 'string')) {
        return false;
    }
    # get doc type opt
    $doc_type = get_opt_config_value($prefix, $opts, 'doc_type', 'xml');
    if (!check_opt_set_type($cmd, $doc_type, 'doc_type', 'string')) {
        return false;
    }
    # get logic opt
    $logic = get_opt($prefix, $opts, 'logic');
    if (!check_opt_set_type($cmd, $logic, 'logic', 'string,array')) {
        return false;
    }
    if (is_string($logic)) {
        $logic = @yaml_decode($logic);
        if (!$logic) {
            return error($cmd, "parse logic not valid YAML");
        }
    }
    # get result type opt
    $result_type = get_opt_config_value($prefix, $opts, 'result_type', 'elements');
    if (!check_opt_set_type($cmd, $result_type, 'result_type', 'string')) {
        return false;
    }
    # get merge results opt
    $merge_results = get_opt($prefix, $opts, 'merge_results', false);
    if (!check_opt_set_type($cmd, $merge_results, 'merge_results', 'boolean')) {
        return false;
    }
    # load the document
    $dom = new DOMDocument('1.0');
    @$dom->loadHTML($document);
    #$dom->preserveWhiteSpace = false;
    # check that the document was parsed correctly
    $res = xml_parse_element($dom, $logic);
    if ($res === false) {
        return error($cmd, "could not parse {$type} document");
    }
    # display info about the parsing
    debug_echo($cmd, "{$doc_type} document parsed successfully for {$result_type}");
    if (empty($res)) {
        debug_echo($cmd, "no {$result_type} found while parsing the {$doc_type} document");
    } else {
        debug_echo($cmd, "the following {$result_type} were found in the {$doc_type} document");
        debug_dump_yaml($res, true);
    }
    # return if we are not merging the results
    if (!$merge_results) {
        return $res;
    }
    # merge the results
    $new_res = array();
    $res_count = count($res);
    for ($i = 0; $i < $res_count; $i++) {
        $elt = $res[$i];
        foreach ($elt as $key => $value) {
            if (is_array($value)) {
                $cur_value = @$new_res[$key];
                if ($cur_value) {
                    $value = array_merge($cur_value, $value);
                }
            }
            $new_res[$key] = $value;
        }
    }
    return $new_res;
}