Ejemplo n.º 1
0
 public function execute($sql, $table_page, $url = null, $result_per_page = 20, $adjacents = 4)
 {
     if ($url == null) {
         $url = $_SERVER['REQUEST_URI'];
     }
     $uri_parts = explode('?', $url);
     $url = $uri_parts[0] . "?";
     $page = isset($_GET["page"]) ? $_GET["page"] : 1;
     if ($page <= 0) {
         $page = 1;
     }
     // connect to your DB:
     $link_id = mysql_connect(DB_HOST, DB_USER, DB_PASS) or die(mysql_error());
     mysql_select_db(DB_NAME, $link_id);
     // select appropriate results from DB:
     $result = mysql_query($sql, $link_id);
     // count total number of appropriate listings:
     $tcount = mysql_num_rows($result);
     // count number of pages:
     $tpages = $tcount ? ceil($tcount / $result_per_page) : 1;
     // total pages, last page number
     $count = 0;
     $i = ($page - 1) * $result_per_page;
     while ($count < $result_per_page && $i < $tcount) {
         mysql_data_seek($result, $i);
         $query = mysql_fetch_array($result);
         // output each row:
         //echo "<p>" . $query['id'] . ", " . $query['title'] . "</p>\n";
         require $table_page;
         $i++;
         $count++;
     }
     //It create the page sequence at the bottom of the result.
     echo $this->paginate_one($url, $page, $tpages, $adjacents);
 }
Ejemplo n.º 2
0
function createCelularInput($celularesMasPopulares, $selectName, $label)
{
    mysql_data_seek($celularesMasPopulares, 0);
    echo "<tr><td colspan='3'>&nbsp;</td></tr>";
    echo "<tr>";
    echo "\t<td width='20%'>" . $label . "</td>";
    echo "\t<td width='30%'>";
    echo "\t\t<select name='" . $selectName . "' id='" . $selectName . "' input='" . $inputName . "'>";
    echo "\t\t\t<option value=''>Selecciona un celular</option>";
    while ($row_celularesMasPopulares = mysql_fetch_assoc($celularesMasPopulares)) {
        echo "\t\t<option value='" . $row_celularesMasPopulares['id_celular'] . "' >" . $row_celularesMasPopulares['nombre'] . "</option>";
    }
    echo "    </select>";
    echo "  </td>";
    echo "  <td width='40%'>";
    echo "\t\t<label for='" . $selectName . "_precio_12m'>Precio 12m:</label>";
    echo "\t\t<input type='text' id='" . $selectName . "_precio_12m' name='" . $selectName . "_precio_12m' value=''/>";
    echo "\t\t<label for='" . $selectName . "_precio_18m'>Precio 18m:</label>";
    echo "  \t<input type='text' id='" . $selectName . "_precio_18m' name='" . $selectName . "_precio_18m' value=''/>";
    echo "\t\t<label for='" . $selectName . "_precio_24m'>Precio 24m:</label>";
    echo "  \t<input type='text' id='" . $selectName . "_precio_24m' name='" . $selectName . "_precio_24m' value=''/>";
    echo "\t\t<label for='" . $selectName . "_precio_prepago'>Precio Prepago:</label>";
    echo "  \t<input type='text' id='" . $selectName . "_precio_prepago' name='" . $selectName . "_precio_prepago' value=''/>";
    echo "\t</td>";
    echo "</tr>";
}
Ejemplo n.º 3
0
function display_all_music()
{
    $date_query = "SELECT date FROM music WHERE deleted = 'n' AND date > CURDATE() - INTERVAL 6 MONTH GROUP BY date ORDER BY date DESC";
    $date_result = mysql_query($date_query);
    if (!$date_result) {
        die('No results in database.');
    }
    $music_query = "SELECT * FROM music WHERE deleted = 'n' ORDER BY date DESC, artist";
    $music_result = mysql_query($music_query);
    if (!$music_result) {
        die('No results in database.');
    }
    echo "<dl class=\"new_music\">";
    for ($i = 1; $i <= mysql_num_rows($date_result); $i++) {
        $date_info = mysql_fetch_assoc($date_result);
        echo "<dt>New Music Week of " . $date_info['date'] . "</dt>";
        for ($j = 1; $j <= mysql_num_rows($music_result); $j++) {
            $music_info = mysql_fetch_assoc($music_result);
            echo "<dd>";
            if ($music_info['date'] == $date_info['date'] && $music_info['url']) {
                echo $music_info['artist'] . " - <a href=\"" . $music_info['url'] . "\" target=_new> " . $music_info['song'] . " </a>";
            }
            if ($music_info['date'] == $date_info['date'] && !$music_info['url']) {
                echo $music_info['artist'] . " - " . $music_info['song'];
            }
            echo "</dd>";
        }
        mysql_data_seek($music_result, 0);
    }
    echo "</dl>";
}
function performance($n)
{
    $query = sprintf("SELECT * \n\tFROM torrents, deltas \n\tWHERE torrents.hash = '%s' \n\tAND deltas.hash = '%s'\n\tORDER BY day desc", $n, $n);
    $r = mysql_query($query);
    $numRows = mysql_num_rows($r);
    $numRows = $numRows - 1;
    mysql_data_seek($r, 0);
    $latest = mysql_fetch_assoc($r);
    mysql_data_seek($r, $numRows);
    $earliest = mysql_fetch_assoc($r);
    $latestDay = strtotime($latest['day']);
    $earliestDay = strtotime($earliest['day']);
    $duration = $latestDay - $earliestDay;
    $duration = round($duration / 60 / 60 / 24, 2);
    if ($latest['down'] == 0) {
        $ratio = 0;
    } else {
        $ratio = round($latest['up'] / $latest['down'], 2);
    }
    if ($duration == 0) {
        $performance = 0;
    } else {
        $performance = round($ratio / $duration, 2);
    }
    $name = $latest['name'];
    $hash = $latest['hash'];
    $whitelist = $latest['whitelist'];
    $seeders = $latest['seeders'];
    $tracker = $latest['tracker'];
    $deletion = $latest['dateofdeletion'];
    $data = array($performance, $duration, $ratio, $name, $hash, $whitelist, $seeders, $latest['day'], $tracker, $deletion);
    return $data;
}
Ejemplo n.º 5
0
/**
 * List multi-level categories
 * @param int $root
 * @param int $depth
 * @param resource $sql
 * @param string $field
 * @param int $parent
 * @return string
 */
function traverse($root, $depth, $sql, $field, $parent = 0)
{
    $row = 0;
    $id = $field['id'];
    $name = $field['name'];
    $field_parent = $field['parent'];
    $t = '';
    while ($acat = mysql_fetch_array($sql)) {
        if ($acat[$field_parent] == $root) {
            $s = $parent == $acat[$id] ? 'selected="selected"' : '';
            $t .= "<option value='" . $acat[$id] . "' {$s}>";
            $j = 0;
            while ($j < $depth) {
                $t .= "-";
                $j++;
            }
            if ($depth > 0) {
                $t .= "-";
            }
            $t .= $acat[$name] . "</option>";
            @mysql_data_seek($sql, 0);
            $t .= traverse($acat[$id], $depth + 1, $sql, $field, $parent);
        }
        $row++;
        @mysql_data_seek($sql, $row);
    }
    return $t;
}
function csl_create_array($result, $colnumber)
{
    assert(isset($result));
    assert(isset($colnumber));
    // Make array
    $tmp = array();
    // Explode all rows into the tmp-array
    while ($row = sql_fetchrow($result)) {
        // If it's not an empty string, place a comma after the string if there isn't one already...
        $char = substr($row[$colnumber], -1);
        if ($row[$colnumber] != "" and $char != ",") {
            $row[$colnumber] = $row[$colnumber] . ",";
        }
        $tmp = array_merge($tmp, explode(",", $row[$colnumber]));
    }
    // This function makes sure we start at row 0 again. This is needed
    // so we can make a second call to explode_array without having to
    // do a whole query again...
    @mysql_data_seek($result, 0);
    // Since last char is a comma, last entry after explode is bogus
    //  echo "CSL_CREATE_ARRAY BEFORE: "; print_r($tmp); echo "<br>\n";
    if (end($tmp) == "") {
        array_pop($tmp);
    }
    reset($tmp);
    //  echo "CSL_CREATE_ARRAY AFTER : "; print_r($tmp); echo "<br>\n";
    // And return
    return $tmp;
}
Ejemplo n.º 7
0
 public function printout($width)
 {
     if (isset($this->res) && mysql_num_rows($this->res) > 0) {
         mysql_data_seek($this->res, 0);
         $num = mysql_num_fields($this->res);
         echo "<table border=l align='center' width='" . $width . "'>";
         echo "<tr>";
         for ($i = 0; $i < $num; $i++) {
             echo "<th>";
             echo mysql_field_name($this->res, $i);
             echo "</th>";
         }
         echo "</tr>";
         while ($row = mysql_fetch_row($this->res)) {
             echo "<tr>";
             foreach ($row as $elem) {
                 echo "<td>{$elem}</td>";
             }
             echo "</tr>";
         }
         echo "</table>";
     } else {
         echo "There is nothing to print!<BR>";
     }
 }
Ejemplo n.º 8
0
 public function data_seek($pointer)
 {
     if (empty($this->result)) {
         die("You must run query first");
     }
     return mysql_data_seek($this->result, $pointer);
 }
Ejemplo n.º 9
0
/**
 * Display alternative table cell
 * @param $secondary_result   mysql result of all secondary alternatives
 *        $alternative type   the resource type of the alternative to display. Must be one of the values in resource_types.type_id
 *        $content_id         used to pass into file_manager/index.php
 *        $ps                 used to pass into file_manager/index.php
 * @return html of the table cell "<td>...</td>"
 */
function display_alternative_cell($secondary_result, $alternative_type, $content_id, $pid, $td_header_id)
{
    global $content_row;
    $found_alternative = false;
    echo '    <td headers="' . $td_header_id . '">' . "\n";
    if (mysql_num_rows($secondary_result) > 0) {
        mysql_data_seek($secondary_result, 0);
        // move the mysql result cursor back to the first row
        while ($secondary_resource = mysql_fetch_assoc($secondary_result)) {
            if ($secondary_resource['type_id'] == $alternative_type) {
                echo '    <div id="' . $pid . '_' . $alternative_type . '">' . "\n";
                echo '      <a href="' . $secondary_resource['secondary_resource'] . '" title="' . _AT('new_window') . '" target="_new">' . get_display_filename($secondary_resource['secondary_resource']) . '</a><br />' . "\n";
                echo '      <a href="#" onclick="ATutor.poptastic(\'' . AT_BASE_HREF . 'mods/_core/file_manager/index.php?framed=1' . SEP . 'popup=1' . SEP . 'cp=' . $content_row['content_path'] . SEP . 'cid=' . $content_id . SEP . 'pid=' . $pid . SEP . 'a_type=' . $alternative_type . '\');return false;" title="' . _AT('new_window') . '">' . "\n";
                echo '        <img src="' . AT_BASE_HREF . 'images/home-tests_sm.png" border="0" title="' . _AT('alter') . '" alt="' . _AT('alter') . '" />' . "\n";
                echo '      </a>' . "\n";
                echo '      <a href="#" onclick="removeAlternative(\'' . $content_row['content_path'] . '\', ' . $content_id . ',' . $pid . ',' . $alternative_type . ');return false;">' . "\n";
                echo '        <img src="' . AT_BASE_HREF . 'images/icon_delete.gif" border="0" title="' . _AT('remove') . '" alt="' . _AT('remove') . '" />' . "\n";
                echo '      </a>' . "\n";
                echo '    </div>' . "\n";
                $found_alternative = true;
                break;
            }
        }
    }
    if (!$found_alternative) {
        echo '    <div id="' . $pid . '_' . $alternative_type . '">' . "\n";
        echo '      <input type="button" value="' . _AT('add') . '" title="' . _AT('new_window') . '" onclick="ATutor.poptastic(\'' . AT_BASE_HREF . 'mods/_core/file_manager/index.php?framed=1' . SEP . 'popup=1' . SEP . 'cp=' . $content_row['content_path'] . SEP . 'cid=' . $content_id . SEP . 'pid=' . $pid . SEP . 'a_type=' . $alternative_type . '\');return false;" />' . "\n";
        echo '    </div>' . "\n";
    }
    echo '    </td>' . "\n";
}
Ejemplo n.º 10
0
function cargo_obtener_para__vista_cargo_amigable(&$r)
{
    if (!mysql_num_rows($r)) {
        return false;
    }
    $fecha_min = '99999999';
    $fecha_max = '00000000';
    $arrBuffer = array();
    $buffer = '<table class="tfija t100">';
    $buffer .= '<tr><th>Cargo</th><th>Fecha de inicio</th><th>Fecha Fin</th></tr>';
    while ($f = mysql_fetch_assoc($r)) {
        $arrBuffer[] = array('leyenda' => $f['cargo'], 'fecha_inicio' => $f['fecha_inicio'], 'fecha_fin' => $f['fecha_fin'], 'fecha_inicio_formato' => $f['fecha_inicio_formato'], 'fecha_fin_formato' => $f['fecha_fin_formato'], 'flag_cese' => $f['flag_cese'], 'titulo' => $f['cargo']);
        $fecha_minima = date('Ym01', strtotime($f['fecha_inicio']));
        $fecha_maxima = date('Ymd', strtotime($f['fecha_fin']));
        $fecha_min = min($fecha_min, $fecha_minima);
        $fecha_max = max($fecha_max, $fecha_maxima);
        if (!$f['flag_cese'] && date('Ymd', strtotime($f['fecha_fin'])) == date('Ymd')) {
            $f['fecha_fin_formato'] = 'a la fecha';
        }
        $buffer .= sprintf('<tr><td>%s</td><td>%s</td><td>%s</td></tr>', $f['cargo'], $f['fecha_inicio_formato'], $f['fecha_fin_formato']);
    }
    $buffer .= '</table>';
    mysql_data_seek($r, 0);
    $f = mysql_fetch_assoc($r);
    $tabla = '<h2>Gráfico de antecedente de cargos laborales en ' . $f['razon_social'] . '</h2>';
    mysql_data_seek($r, 0);
    $tabla .= ui_timeline($arrBuffer);
    return $buffer . $tabla;
}
 function constructTable()
 {
     $result = $this->getCourseTuples();
     $numRows = mysql_num_rows($result);
     //mysql_num_rows
     echo "<div id=\"tabs\">" . "<ul>";
     for ($i = 0; $i < $numRows; $i++) {
         $row = mysql_fetch_array($result);
         echo "<li><a href=\"#tabs-" . $i . "\">" . $row[1] . "</a></li>";
     }
     mysql_data_seek($result, 0);
     //Resetting Pointer
     echo "</ul>";
     for ($i = 0; $i < $numRows; $i++) {
         $row = mysql_fetch_array($result);
         echo "<div id=\"tabs-" . $i . "\">" . "<p id=\"p_feedback\"> Course Selected ---> " . $row[1] . "</div>";
         echo "<input type=\"hidden\" id=\"hidden_courseID{$i}\" value=\"{$row[0]}\" />";
     }
     echo "<input type=\"hidden\" id=\"hidden_courseTabIndex\" value=\"0\" />";
     echo "<div id=\"div_subjectAjaxFiller\" style=\"float: left; width=75%\">\n                        Placeholder for Subjects\n                    </div>";
     $this->initHiddenElements();
     $this->addBreaks(18);
     $this->initBackButton();
     $this->addBreaks(5);
     echo "</div>";
 }
Ejemplo n.º 12
0
 /**
  * Standard modular run function.
  *
  * @return tempcode	Results
  */
 function run()
 {
     $out = new ocp_tempcode();
     $tables = $GLOBALS['SITE_DB']->query_select('db_meta', array('DISTINCT m_table'));
     if (count($GLOBALS['SITE_DB']->connection_write) > 4) {
         $GLOBALS['SITE_DB']->connection_write = call_user_func_array(array($GLOBALS['SITE_DB']->static_ob, 'db_get_connection'), $GLOBALS['SITE_DB']->connection_write);
         _general_db_init();
     }
     list($db, $db_name) = $GLOBALS['SITE_DB']->connection_write;
     mysql_select_db($db_name, $db);
     foreach ($tables as $table) {
         if ($table['m_table'] == 'sessions') {
             continue;
         }
         // HEAP, so can't be repaired
         $table = get_table_prefix() . $table['m_table'];
         // Check/Repair
         $result = mysql_query('CHECK TABLE ' . $table . ' FAST', $db);
         echo mysql_error($db);
         mysql_data_seek($result, mysql_num_rows($result) - 1);
         $status_row = mysql_fetch_assoc($result);
         if ($status_row['Msg_type'] != 'status') {
             $out->attach(paragraph(do_lang_tempcode('TABLE_ERROR', escape_html($table), escape_html($status_row['Msg_type']), array(escape_html($status_row['Msg_text']))), 'dfsdgdsgfgd'));
             $result2 = mysql_query('REPAIR TABLE ' . $table, $db);
             mysql_data_seek($result2, mysql_num_rows($result2) - 1);
             $status_row_2 = mysql_fetch_assoc($result2);
             $out->attach(paragraph(do_lang_tempcode('TABLE_FIXED', escape_html($table), escape_html($status_row_2['Msg_type']), array(escape_html($status_row_2['Msg_text']))), 'dfsdfgdst4'));
         }
         // Optimise
         mysql_unbuffered_query('OPTIMIZE TABLE ' . $table, $db);
     }
     return $out;
 }
Ejemplo n.º 13
0
function query_to_csv($query, $filename, $attachment = false, $headers = true)
{
    if ($attachment) {
        // send response headers to the browser
        header('Content-Type: text/csv');
        header('Content-Disposition: attachment;filename=' . $filename);
        $fp = fopen('php://output', 'w');
    } else {
        $fp = fopen($filename, 'w');
    }
    $result = mysql_query($query) or die(mysql_error());
    if ($headers) {
        // output header row (if at least one row exists)
        $row = mysql_fetch_assoc($result);
        if ($row) {
            fputcsv($fp, array_keys($row));
            // reset pointer back to beginning
            mysql_data_seek($result, 0);
        }
    }
    while ($row = mysql_fetch_assoc($result)) {
        fputcsv($fp, $row);
    }
    fclose($fp);
}
 function fetchRow($rownum = null)
 {
     if ($rownum !== null) {
         mysql_data_seek($this->db_result, $rownum);
     }
     return mysql_fetch_array($this->db_result);
 }
Ejemplo n.º 15
0
 public function query($vbe571b25caf2bbed46f6e47182670bf7, $v3ede331cca63faafb68a34acb42767c6 = false)
 {
     if (!$this->open()) {
         return false;
     }
     $vbe571b25caf2bbed46f6e47182670bf7 = trim($vbe571b25caf2bbed46f6e47182670bf7, " \t\n");
     if (defined('SQL_QUERY_DEBUG') && SQL_QUERY_DEBUG) {
         echo $vbe571b25caf2bbed46f6e47182670bf7, "\r\n";
     }
     if (strtoupper(substr($vbe571b25caf2bbed46f6e47182670bf7, 0, 6)) != "SELECT" || defined('MYSQL_DISABLE_CACHE')) {
         $result = mysql_query($vbe571b25caf2bbed46f6e47182670bf7, $this->conn);
         if ($this->errorOccured()) {
             throw new databaseException($this->errorDescription($vbe571b25caf2bbed46f6e47182670bf7));
         }
         return $result;
     }
     $v0800fc577294c34e0b28ad2839435945 = md5($vbe571b25caf2bbed46f6e47182670bf7);
     if (isset($this->queryCache[$v0800fc577294c34e0b28ad2839435945]) && $v3ede331cca63faafb68a34acb42767c6 == false) {
         $result = $this->queryCache[$v0800fc577294c34e0b28ad2839435945][0];
         if ($this->queryCache[$v0800fc577294c34e0b28ad2839435945][1]) {
             mysql_data_seek($result, 0);
         }
     } else {
         $result = mysql_query($vbe571b25caf2bbed46f6e47182670bf7, $this->conn);
         if ($this->errorOccured()) {
             $this->queryCache[$v0800fc577294c34e0b28ad2839435945] = false;
             throw new databaseException($this->errorDescription($vbe571b25caf2bbed46f6e47182670bf7));
         } else {
             if (SQL_QUERY_CACHE) {
                 $this->queryCache[$v0800fc577294c34e0b28ad2839435945] = array($result, mysql_num_rows($result));
             }
         }
     }
     return $result;
 }
Ejemplo n.º 16
0
function cleanupRequests($location, $table)
{
    global $gSkipRuns, $gbActuallyDoit;
    $query = "select * from crawls where location = '{$location}' and finishedDateTime is not null order by crawlid desc limit " . ($gSkipRuns + 1) . ";";
    $results = doQuery($query);
    mysql_data_seek($results, $gSkipRuns);
    $row = mysql_fetch_assoc($results);
    if ($gbActuallyDoit) {
        $nUnfinished = doSimpleQuery("select count(*) from crawls where location = '{$location}' and finishedDateTime is null;");
        if (0 < $nUnfinished) {
            echo "SORRY! There is an unfinished crawl for location '{$location}'. Skipping the cleanup while the crawl is running.\n";
            return;
        }
        // Actually delete rows and optimize the table.
        echo "Delete requests from \"{$table}\" table starting with crawl \"{$row['label']}\" crawlid={$row['crawlid']} minPageid={$row['minPageid']} maxPageid={$row['maxPageid']}...\n";
        $cmd = "delete from {$table} where crawlid <= {$row['crawlid']};";
        echo "{$cmd}\n";
        doSimpleCommand($cmd);
        echo "DONE\nOptimize table \"{$table}\"...\n";
        doSimpleCommand("optimize table {$table};");
        echo "DONE\n";
    } else {
        echo "WOULD delete requests from \"{$table}\" table starting with crawl \"{$row['label']}\" crawlid={$row['crawlid']} minPageid={$row['minPageid']} maxPageid={$row['maxPageid']}...\n";
    }
}
Ejemplo n.º 17
0
function GetThumbnails($dbh, $order, $crono, $c, $exc)
{
    //returns an array of 3 strings
    //each one contains: "attachmentfilename,query_pointer" (use mysql_data_seek to move to pointer)
    $thumb[0] = "";
    $thumb[1] = "";
    $thumb[2] = "";
    if ($crono == 1) {
        $query = "SELECT filename,message_date\n\t\tFROM attachment,message,channel\n\t\tWHERE content_type = '1' AND\n\t\tattachment.message_id = message.message_id AND\n\t\tchannel.channel_id = message.channel_id AND\n\t\tchannel.is_visible = 1 AND\n\t\tchannel.channel_id NOT IN ({$channels_excluded_from_crono})\n\t\tORDER BY message_date " . $order;
    } else {
        $query = "SELECT filename,message_order\n\t\tFROM attachment,message\n\t\tWHERE content_type = '1' AND\n\t\tattachment.message_id = message.message_id AND\n\t\tmessage.channel_id = {$c}\n\t\tORDER BY message_order " . $order;
    }
    $result = mysql_query($query, $dbh);
    $n = mysql_num_rows($result);
    if ($n > 0) {
        if ($n <= 3) {
            for ($i = 0; $i < $n; $i++) {
                $row = mysql_fetch_array($result, MYSQL_NUM);
                $thumb[$i] = "channels/" . $row[0] . "," . $row[1];
            }
        } else {
            $row = mysql_fetch_array($result, MYSQL_NUM);
            $thumb[0] = "channels/" . $row[0] . "," . $row[1];
            $x = intval($n / 2);
            mysql_data_seek($result, $x);
            $row = mysql_fetch_array($result, MYSQL_NUM);
            $thumb[1] = "channels/" . $row[0] . "," . $row[1];
            $n--;
            mysql_data_seek($result, $n);
            $row = mysql_fetch_array($result, MYSQL_NUM);
            $thumb[2] = "channels/" . $row[0] . "," . $row[1];
        }
    }
    return $thumb;
}
 function rewind()
 {
     if ($this->resource && mysql_num_rows($this->resource) > 0) {
         mysql_data_seek($this->resource, 0);
     }
     $this->number = 0;
 }
Ejemplo n.º 19
0
function n1dependentDropdown($v)
{
    global $KT_n1dddSW, $KT_relPath, $KT_dd;
    if (!isset($KT_n1dddSW)) {
        $KT_n1dddSW = true;
    }
    $ret = "";
    if ($KT_n1dddSW) {
        $ret .= "<script language=\"JavaScript\" src=\"" . $KT_relPath . "includes/widgets/n1dependentDropdown.js\"></script>\n";
        $KT_n1dddSW = false;
    }
    $KT_dd++;
    $ret .= '<input type="text" readonly="yes" id="' . $v['name'] . '" ';
    while (list($key, $value) = each($v)) {
        switch ($key) {
            case "type":
            case "subtype":
            case "triggerrs":
            case "tpkey":
            case "tfkey":
            case "pkey":
            case "display":
            case "recordset":
            case "boundto":
            case "id":
            case "selected":
                break;
            default:
                $ret .= " " . $key . '="' . $value . '"';
        }
    }
    $ret .= '></input>';
    $ret .= '
	<script>
		ddfks_' . $v['name'] . ' = new Array();
		ddnames_' . $v['name'] . ' = new Array();
		dddefval_' . $v['name'] . ' = "' . @$v['selected'] . '";
		';
    global ${$v['triggerrs']};
    $rs = ${$v['triggerrs']};
    $row_rs = mysql_data_seek($rs, 0);
    do {
        $ret .= 'ddfks_' . $v['name'] . '["' . $row_rs[$v['tpkey']] . '"]="' . $row_rs[$v['tfkey']] . '";
			';
    } while ($row_rs = mysql_fetch_assoc($rs));
    global ${$v['recordset']};
    $rs =& ${$v['recordset']};
    $row_rs = mysql_data_seek($rs, 0);
    do {
        $value = $row_rs[$v['display']];
        $value = str_replace("\\", "\\\\", $value);
        $value = str_replace("\"", "\\\"", $value);
        $ret .= 'ddnames_' . $v['name'] . '["' . $row_rs[$v['pkey']] . '"]="' . $value . '";
			';
    } while ($row_rs = mysql_fetch_assoc($rs));
    $ret .= '
		registerN1Menu("' . $v['name'] . '", "' . $v['boundto'] . '");	
	</script>';
    return $ret;
}
 /**
  * Seek
  *
  * @param   int offset
  * @return  bool success
  * @throws  rdbms.SQLException
  */
 public function seek($offset)
 {
     if (!mysql_data_seek($this->handle, $offset)) {
         throw new SQLException('Cannot seek to offset ' . $offset);
     }
     return TRUE;
 }
Ejemplo n.º 21
0
 function rewind()
 {
     if (isset($this->queryId) && is_resource($this->queryId) && mysql_num_rows($this->queryId)) {
         if (mysql_data_seek($this->queryId, 0) === false) {
             $this->connection->_raiseError();
         }
     } elseif (!$this->queryId) {
         $query = $this->query;
         if (is_array($this->sort_params)) {
             if (preg_match('~(?<=FROM).+\\s+ORDER\\s+BY\\s+~i', $query)) {
                 $query .= ',';
             } else {
                 $query .= ' ORDER BY ';
             }
             foreach ($this->sort_params as $field => $order) {
                 $query .= $this->connection->quoteIdentifier($field) . " {$order},";
             }
             $query = rtrim($query, ',');
         }
         if ($this->limit) {
             $query .= ' LIMIT ' . $this->offset . ',' . $this->limit;
         }
         $this->queryId = $this->connection->execute($query);
     }
     $this->key = 0;
     $this->next();
 }
Ejemplo n.º 22
0
 /**
  * Constructor method for the adapter.  This constructor implements the setting of the
  * 3 required properties for the object.
  * 
  * @param resource $d The datasource resource
  */
 function mysqlfAdapter($d)
 {
     $f = $d['filter'];
     $d = $d['data'];
     parent::RecordSetAdapter($d);
     $fieldcount = count($f);
     $truefieldcount = mysql_num_fields($d);
     $be = $this->isBigEndian;
     $isintcache = array();
     for ($i = 0; $i < $truefieldcount; $i++) {
         //mysql_fetch_* usually returns only strings,
         //hack it into submission
         $type = mysql_field_type($d, $i);
         $name = mysql_field_name($d, $i);
         $isintcache[$name] = in_array($type, array('int', 'real', 'year'));
     }
     $isint = array();
     for ($i = 0; $i < $fieldcount; $i++) {
         $this->columnNames[$i] = $this->_charsetHandler->transliterate($f[$i]);
         $isint[$i] = isset($isintcache[$f[$i]]) && $isintcache[$f[$i]];
     }
     //Start fast serializing
     $ob = "";
     $fc = pack('N', $fieldcount);
     if (mysql_num_rows($d) > 0) {
         mysql_data_seek($d, 0);
         while ($line = mysql_fetch_assoc($d)) {
             //Write array flag + length
             $ob .= "\n" . $fc;
             $i = 0;
             foreach ($f as $key) {
                 $value = $line[$key];
                 if (!$isint[$i]) {
                     $os = $this->_directCharsetHandler->transliterate($value);
                     //string flag, string length, and string
                     $len = strlen($os);
                     if ($len < 65536) {
                         $ob .= "" . pack('n', $len) . $os;
                     } else {
                         $ob .= "\f" . pack('N', $len) . $os;
                     }
                 } else {
                     $b = pack('d', $value);
                     // pack the bytes
                     if ($be) {
                         // if we are a big-endian processor
                         $r = strrev($b);
                     } else {
                         // add the bytes to the output
                         $r = $b;
                     }
                     $ob .= "" . $r;
                 }
                 $i++;
             }
         }
     }
     $this->numRows = mysql_num_rows($d);
     $this->serializedData = $ob;
 }
Ejemplo n.º 23
0
function GenerSelect1Attr($WidthSelect, $Requete, $NomSelect, $Option, $LibOption, $ValOptionSelected, $WithDecod = 1, $LibOptionSuppl = '', $OptionSuppl = 0, $Entete = 1)
{
    print '<select name="' . $NomSelect . '">';
    if ($LibOptionSuppl != '' && $Entete) {
        print '<option value="' . $OptionSuppl . '"';
        if ($OptionSuppl == $ValOptionSelected) {
            print ' selected ';
        }
        print ' >' . ($WithDecod ? FromBd2Html($LibOptionSuppl) : $LibOptionSuppl) . '</option>';
    }
    mysql_data_seek($Requete, 0);
    while ($Line = mysql_fetch_array($Requete)) {
        print '<option value="' . $Line[$Option] . '"';
        if ($ValOptionSelected == $Line[$Option]) {
            print ' selected ';
        }
        print ' >' . ($WithDecod ? FromBd2Html($Line[$LibOption]) : $Line[$LibOption]) . '</option>';
    }
    if ($LibOptionSuppl != '' && !$Entete) {
        print '<option value="' . $OptionSuppl . '"';
    }
    if ($OptionSuppl == $ValOptionSelected) {
        print ' selected ';
    }
    print ' >' . ($WithDecod ? FromBd2Html($LibOptionSuppl) : $LibOptionSuppl) . '</option>';
    print '</select>';
}
Ejemplo n.º 24
0
function ExportExcel($table)
{
    $filename = "uploads/" . strtotime("now") . '.csv';
    $sql = mysql_query("SELECT * FROM {$table}") or die(mysql_error());
    $num_rows = mysql_num_rows($sql);
    if ($num_rows >= 1) {
        $row = mysql_fetch_assoc($sql);
        $fp = fopen($filename, "w");
        $seperator = "";
        $comma = "";
        foreach ($row as $name => $value) {
            $seperator .= $comma . '' . str_replace('', '""', $name);
            $comma = ",";
        }
        $seperator .= "\n";
        fputs($fp, $seperator);
        mysql_data_seek($sql, 0);
        while ($row = mysql_fetch_assoc($sql)) {
            $seperator = "";
            $comma = "";
            foreach ($row as $name => $value) {
                $seperator .= $comma . '' . str_replace('', '""', $value);
                $comma = ",";
            }
            $seperator .= "\n";
            fputs($fp, $seperator);
        }
        fclose($fp);
        echo "Your file is ready. You can download it from <a href='{$filename}'>here!</a>";
    } else {
        echo "There is no record in your Database";
    }
}
Ejemplo n.º 25
0
 function htmlitize($showFields = true)
 {
     $content = "";
     if ($showFields) {
         $fields = "";
         for ($i = 0; $i < $this->fieldCnt; ++$i) {
             $fields .= "<td><b>" . mysql_fetch_field($this->result, $i)->name . "</b></td>";
         }
         $content .= "<tr>{$fields}</tr>";
     }
     mysql_data_seek($this->result, 0);
     while (true) {
         $rowData = mysql_fetch_row($this->result);
         if ($rowData === false) {
             break;
         }
         $row = "";
         foreach ($rowData as $value) {
             $row .= "<td>{$value}</td>";
         }
         $content .= "<tr>{$row}</tr>";
     }
     // restore previous iterator position
     mysql_data_seek($this->result, $this->rowIter);
     return "<table border=\"1\" class=\"pure-table pure-table-bordered\">{$content}</table>";
 }
 /**
  * @brief Zur ersten Zeile in der Ergebnismenge springen
  * @return array
  */
 public function rewind()
 {
     // Zum Anfang springen
     //
     $this->pointer = 0;
     mysql_data_seek($this->resource, 0);
     return $this->current();
 }
Ejemplo n.º 27
0
 function seek($pos)
 {
     $status = mysql_data_seek($this->Query_ID, $pos);
     if ($status) {
         $this->Row = $pos;
     }
     return;
 }
 public function valid()
 {
     if ($this->position < mysql_num_rows($this->result)) {
         return mysql_data_seek($this->result, $this->position);
     } else {
         return false;
     }
 }
Ejemplo n.º 29
0
 public function rewind()
 {
     if ($this->num_rows > 0) {
         mysql_data_seek($this->result, 0);
         $this->index = -1;
         $this->fetch();
     }
 }
Ejemplo n.º 30
0
 public function rowSeek($rowNum)
 {
     $re = @mysql_data_seek($this->query_result, $rowNum);
     if (!$re) {
         throw new Exception($this->errorInfo());
     }
     return $re;
 }