$ch = curl_init($url); curl_setopt_array($ch, $options); curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: text/xml; charset=utf-8")); $content = curl_exec($ch); $err = curl_errno($ch); $errmsg = curl_error($ch); $header = curl_getinfo($ch); curl_close($ch); $header['errno'] = $err; $header['errmsg'] = $errmsg; $header['content'] = $content; return $header; } function JEncode($node) { if (version_compare(PHP_VERSION, "5.2", "<")) { require_once "JSON.php"; $json = new Services_JSON(); $data = $json->encode($node); } else { $data = json_encode($node); } return $data; } $tc = F3::get('PARAMS["tc"]'); $info = tc2info($tc); $info = array_map("utf8_encode", $info); //print_r( $info); //echo json_encode($info); echo JEncode($info);
while ($row = mysql_fetch_array($result)) { $destdiv[] = array($i, $row['div_id'], $row['divname'], $row['percent']); $i++; } $query = "SELECT d.div_id, d.divname FROM `div` d JOIN divext de ON d.div_id = de.div_id AND de.dl_id = 4"; $result = mysql_query($query); $i = 1; $sourcediv = array(); $sourcediv[] = array($i, 0, 'Не выбран', ''); $i++; while ($row = mysql_fetch_array($result)) { $sourcediv[] = array($i, $row['div_id'], iconv("Windows-1251", "UTF-8", $row['divname'])); $i++; } $data = array('destdivdata' => $destdiv, 'sourcedivdata' => $sourcediv); echo JEncode($data); function JEncode($arr) { if (version_compare(PHP_VERSION, "5.2", "<")) { require_once "JSON.php"; //if php<5.2 need JSON class $json = new Services_JSON(); //instantiate new json object $data = $json->encode($arr); //encode the data in json format } else { require_once "JSON.php"; //if php<5.2 need JSON class $json = new Services_JSON(); //instantiate new json object $data = $json->encode($arr);
$rows = mysql_num_rows($rs); if ($rows > 0) { $i = 0; while ($rec = mysql_fetch_array($rs)) { $rec['id'] = $rec['id']; $rec['cnv_type'] = $rec['cnv_type']; $rec['filedata'] = iconv("Windows-1251", "UTF-8", $rec['filedata']); $rec['cnvstr'] = iconv("Windows-1251", "UTF-8", $rec['cnvstr']); //$rec['cnvstr']=$rec['cnvstr']; $rec['isready'] = $rec['isready']; $rec['import'] = $rec['import']; $rec['packetrc'] = $rec['packetrc']; $rec['loadrc'] = $rec['loadrc']; $arr[] = $rec; } $jsonresult = JEncode($arr); //$data = JEncode($arr1); echo '({"totalCount":"' . $rows . '","q" :"' . $_GET['div_id'] . '", "rows":' . $jsonresult . '})'; } else { $rows = 0; $jsonresult = '[]'; echo '({"totalCount":"' . $rows . '","q" :"' . $_GET['div_id'] . '", "rows":' . $jsonresult . '})'; } function codeDate($date) { $tab = explode("-", $date); $r = $tab[2] . "." . $tab[1] . "." . $tab[0]; return $r; } function JEncode($arr) {
function getYearMobile() { mysql_query('SET CHARACTER SET utf8'); $result = mysql_query(" SELECT YearName YearId,YearName FROM tyear Order By YearId"); $nbrows = mysql_num_rows($result); if ($nbrows > 0) { while ($rec = mysql_fetch_array($result)) { $arr[] = $rec; } $jsonresult = JEncode($arr); echo '{"total":"' . $nbrows . '","results":' . $jsonresult . '}'; } else { echo '{"total":"0", "results":""}'; } }
$id = $param[1]; //"208";//$_GET['id']; $tablo = "adres_" . $getir; $secim = $getir; if (!$id) { $id = 0; } if ($getir == "il") { $xx = "ulke"; } if ($getir == "ilce") { $xx = "il"; } if ($getir == "semt") { $xx = "ilce"; } if ($getir == "ulke") { $x1 = "SELECT {$secim},no from {$tablo} order by sira"; $vtSorgu = mysql_query("SELECT {$secim},no from {$tablo} order by ulke"); } else { $x2 = "SELECT {$secim},no from {$tablo} where {$xx}={$id} order by sira"; $vtSorgu = mysql_query("SELECT {$secim},no from {$tablo} where {$xx}={$id} order by {$secim}"); } //echo $x2; while ($listele = mysql_fetch_array($vtSorgu)) { $node[$secim] = $listele[$secim]; $node['no'] = $listele['no']; $t[] = $node; } echo JEncode($t);
$error = "Выдаваемая сумма больше долга!"; } else { $success = true; list($year_gi, $mon_gi, $day_gi) = explode(".", $_POST['letgetdate']); $strdategive = "{$day_gi}-{$mon_gi}-{$year_gi}"; if ($row['dept'] == $_POST['dept']) { $query = "update letters set los_id='6', dept='0', deliverdate='{$strdategive}' where let_id=" . $_POST['let_id']; $res = mysql_query($query) or die("<script>alert('2');</script>"); } else { $dept = $row['dept'] - $_POST['dept']; $query = "update letters set dept='{$dept}' where let_id=" . $_POST['let_id']; $res = mysql_query($query) or die("<script>alert('1');</script>"); } } $o = array("success" => $success, "error" => $error); echo JEncode($o); } if ($_GET['cmd'] == 'delete') { $sql = "update requests set status_id=" . $_GET['state'] . " where id=" . $_GET['id']; $rs = mysql_query($sql); $o = array("success" => true); echo '1'; } function codeDate($date) { $tab = explode("-", $date); $r = $tab[2] . "." . $tab[1] . "." . $tab[0]; return $r; } function encodeDate($date) {
function getDirList($dir) { $ary = array(); if ($current = opendir($dir)) { while ($file = readdir($current)) { if (is_dir("{$dir}/{$file}") && !($file == "." || $file == "..")) { $ary[] = array("date" => $file); } } closedir($current); } if (count($ary) > 0) { sort($ary); $dates = JEncode($ary); echo '({"total":"' . count($ary) . '","results":' . $dates . '})'; } else { echo '({"total":"0","results":"$dir"})'; } }
require "func.php"; $link = mysql_connect("localhost", "dobro", "bitdobru") or die("Could not connect"); mysql_select_db("dobro_db1") or die("Could not select database"); function generateTree($parent_id) { $sql = "SELECT * FROM articles WHERE div_id = " . $_GET['div_id'] . " AND parent_id = " . $parent_id . " ORDER BY artname COLLATE latin1_general_ci"; $result = mysql_query($sql) or die(mysql_error()); $arr = array(); while ($row = mysql_fetch_array($result)) { $children = generateTree($row['art_id']); $arr[] = array('id' => $row['art_id'], 'text' => iconv("Windows-1251", "UTF-8", $row['artname']), 'leaf' => !(bool) count($children), 'children' => $children); } return $arr; } $treeArr = generateTree(0); echo JEncode($treeArr); //$nodes = array(); //$treeArr[] = array(id=>-1,div_id=>-1, inout=>0, 'text'=>"<b>Входящие"." "."(".$total_in.")</b>", leaf=>false, children=>$arr_in); //$treeArr[] = array(id=>-2 ,div_id=>-2, inout=>1, 'text'=>"<b>Исходящие"." "."(".$total_out.")</b>", leaf=>false,children=>$arr_out); //$treeArr[] = array(id=>-4 ,div_id=>-4, inout=>-2, 'text'=>"<b>Черновики"." "."(".$total_del_empty.")</b>", leaf=>false,children=>$nodes); //$treeArr[] = array(id=>-3 ,div_id=>-3, inout=>-1, 'text'=>"<b>Удаленные"." "."(".$total_del_cnt.")</b>", leaf=>false,children=>$nodes); //$jsonresult =json_encode($treeArr); //echo $jsonresult; //echo "[{id: '1', text: 'No Children', leaf: true},{ id: '2', text: 'Has Children',children: [{id: '3', text: 'Youngster',leaf: true}]}]"; function JEncode($arr) { if (version_compare(PHP_VERSION, "5.2", "<")) { require_once "JSON.php"; //if php<5.2 need JSON class $json = new Services_JSON(); //instantiate new json object
$link = mysql_connect("localhost", "dobro", "bitdobru") or die("Could not connect"); mysql_select_db("dobro_db1") or die("Could not select database"); $sql_count = "SELECT l.let_id, i.user_id, i.username, i.userpass,i.div_id FROM iusers i, letters l where l.user_id=i.user_id and l.let_id>59000 order by user_id"; $sql_count = "SELECT i.user_id, i.username, i.userpass FROM iusers i, letters l where l.user_id=i.user_id and i.user_id>" . $_POST['uid'] . " and l.let_id>59000 order by user_id"; $sql_count = "SELECT div_id, divname from `div` where parentdiv_id=-1"; $sql = $sql_count; $rs = mysql_query($sql); while ($rec = mysql_fetch_array($rs)) { $rec['id'] = $rec[0]; $rec['text'] = iconv("Windows-1251", "UTF-8", $rec['divname']); $rec['leaf'] = "true"; //$rec['username']=$rec[1]; $arr[] = $rec; } $treeArr = array(id => -1, 'text' => iconv("Windows-1251", "UTF-8", "<b>Все</b>"), leaf => false, children => $arr); $jsonresult = "[" . JEncode($treeArr) . "]"; echo $jsonresult; // $sampleArr = array( id=>"1", text=>"Node 1", leaf=>"false", children=>array( array(id=>2, text=>"Child 1", leaf=>"true"), array(id=>"3", text=>"Child 2", leaf=>"true"))); // echo JEncode($sampleArr); //echo "[{id: '1', text: 'No Children', leaf: false},{ id: '2', text: 'Has Children', children: [{id: '3', text: 'Youngster',leaf: true}]}]"; function JEncode($arr) { if (version_compare(PHP_VERSION, "5.2", "<")) { require_once "JSON.php"; //if php<5.2 need JSON class $json = new Services_JSON(); //instantiate new json object $data = $json->encode($arr); //encode the data in json format } else { require_once "JSON.php";
if (!$result) { $success = 0; $error = $query; } else { $success = 1; } $o = array("success" => $success, "error" => $error); echo JEncode($o); } if (!empty($_POST['cmd']) && $_POST['cmd'] == 'load') { $query = "SELECT l.*, c.clientname, p.payee_name, t.ltassumm AS letpercsum, lp.letper AS percent\n FROM letters l\n JOIN clients c ON l.client_id = c.client_id\n JOIN payee p ON l.payee_id = p.payee_id\n JOIN total_addsum t ON l.let_id = t.let_id\n JOIN letperdiv lp ON l.sourcediv_id = lp.sourcediv_id AND l.div_id = lp.destdiv_id\n WHERE l.let_id =" . $_POST['let_id']; $result = mysql_query($query) or die(mysql_error()); if ($result) { $rec = mysql_fetch_array($result); $row = array('success' => true, 'data' => array('destdiv' => $rec['div_id'], 'hdestdiv' => $rec['div_id'], 'client_id' => $rec['client_id'], 'hclientcombo' => iconv("Windows-1251", "UTF-8", $rec['clientname']), 'payee_id' => $rec['payee_id'], 'payeename' => iconv("Windows-1251", "UTF-8", $rec['payee_name']), 'letsum' => $rec['letsum'], 'letpercsum' => $rec['letpercsum'], 'totalletsum' => $rec['letpercsum'] + $rec['letsum'], 'percent' => $rec['percent'], 'letnote' => iconv("Windows-1251", "UTF-8", $rec['letnote']), 'getdate' => implode('.', array_reverse(explode('-', $rec['letgetdate']))), 'givedate' => implode('.', array_reverse(explode('-', $rec['letgivedate']))), 'let_id' => $rec['let_id'], 'sourcediv_id' => $rec['sourcediv_id'])); echo JEncode($row); } } function JEncode($arr) { if (version_compare(PHP_VERSION, "5.2", "<")) { require_once "JSON.php"; //if php<5.2 need JSON class $json = new Services_JSON(); //instantiate new json object $data = $json->encode($arr); //encode the data in json format } else { require_once "JSON.php"; //if php<5.2 need JSON class $json = new Services_JSON();