Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- if ($_SERVER["SERVER_NAME"]=='localhost')
- require 'alinc.php';
- else
- require 'baser_i.inc.php';
- if (!isset($_COOKIE["timeget"]))
- setcookie('timeget',date('d.m.Y H:i:s'),time()+60);
- if (!isset($_COOKIE["infget"]))
- setcookie('infget',serialize($_GET), time()+60);
- if ($_SERVER["SERVER_NAME"]=='localhost')
- $baser= Baser_i::init('localhost', '', '', '');
- else if (strpos($_SERVER["SERVER_NAME"],'dmkim1.bget.ru')!=-1)
- $baser= Baser_i::init ('localhost',
- '','','');
- else
- $baser= Baser_i::init('localhost', '', '', '');
- $baser=Baser_i::getInstance();
- if (!isset($_REQUEST["req"])) {
- ?>
- <form method="post" action="<?=$_SERVER["PHP_SELF"]?>" enctype="application/x-www-form-urlencoded">
- <textarea name="sqlin" cols="60" rows="10"></textarea>
- <input type="hidden" name="req" value="cvsout" />
- <input type="submit" name="submit" value="go" />
- </form>
- <?php
- exit();
- }
- $req=@$_REQUEST["req"];
- //-------------------------------------------------------------------------
- //-------------------------------------------------------------------------
- switch ($req) {
- case "cvsout":
- //header("Content-type:text/plain; charset=windows-1251");
- header("Content-type: application/vnd.ms-excel");
- header("Content-disposition:attachment;filename=\"inquery.csv\"");
- $fn='../tempinfo.dat';
- $fz=fopen($fn,'wb');
- $arr=$baser->getQuery($_REQUEST["sqlin"]);
- foreach ($arr as $el) {
- fputcsv($fz,$el);
- }
- fclose($fz);
- $s=file_get_contents($fn);
- echo $s;
- break;
- //-------------------------------
- case "testplain":
- header("Content-type:text-plain");
- header("Content-disposition:attachment;filename=\"testfile.txt\"");
- break;
- //-------------------------------
- //-------------------------------
- case "showlog":
- header('Content-type:text/plain; charset=utf-8');
- ob_implicit_flush();
- $fz=fopen($baser->logfile,'rb');
- if ($fz) {
- $strs=array();
- fseek($fz,max(-6000,-filesize($baser->logfile)),SEEK_END);
- $i=0;
- $str_i=fgets($fz,4096);
- do {
- $str_i=fgets($fz,4096);
- if ($str_i!==false)
- $strs[]=$str_i;
- }
- while ($str_i!==false);
- if (!feof($fz))
- echo "Error reading file \r\n";
- fclose($fz);
- $strs_rev=array_reverse($strs);
- function output_z($item,$key) {
- echo "$item";
- }
- array_walk($strs_rev,"output_z");
- //echo (fread($fz, filesize($baser->logfile)));
- }
- break;
- //--------------------------------
- case "checkstr":
- $test_str='apples and oranges';
- echo $test_str;
- break;
- //--------------------------------
- case "instest":
- $baser->insertQuery('insert into regs(%fields%) values(%values%)',
- array('reg_name'), array('\'testtest\''));
- break;
- //--------------------------------
- case "instest4":
- $baser->insertQuery('insert into regs(reg_name) values(?)',null,array('test888'));
- break;
- //--------------------------------
- case "exectest":
- $baser->execQuery("update regs set reg_name=? where id=116",array('testinfo'));
- break;
- case "seltest":
- header('Content-type:text/plain; charset=utf-8');
- echo print_r( $baser->getQuery("select * from regs",2,3));
- echo print_r( $baser->getQuery("select * from regs",2,3,'inf'));
- break;
- case "seltest4":
- header('Content-type:text/plain; charset=utf-8');
- echo print_r( $baser->getQueryAll("select * from regs where id=?",array(116,117,118)) );
- echo print_r( $baser->getQueryAll("select * from regs where id=?",119) );
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement