function news__edit() { $out = aikiGetForm($_GET["form"], $_GET["mode"]); $Item = aikiReadItem("news", $_GET["id"]); if ($_GET["id"] == "_new") { $Item["id"] = newIdRnd(); } $Item = _newsBeforeShowItem($Item); $out->contentSetData($Item); return $out->htmlOuter(); }
function prod__edit() { $out = aikiGetForm($_GET["form"], $_GET["mode"]); $Item = aikiReadItem($_GET["form"], $_GET["id"]); $Item["form"] = $_GET["form"]; if ($_GET["id"] == "_new") { $Item["id"] = newIdRnd(); } $out->contentSetData($Item); return $out->outerHtml(); }
function page__getajax() { $out = aikiGetForm($_GET["form"], $_GET["mode"]); if (!is_object($out)) { $out = aikiGetForm($_GET["form"], "show"); } $Item = aikiReadItem($_GET["form"], $_GET["item"]); $out = aikiFromString(page__show($out, $Item)); if (is_callable("pageChangeHtml")) { pageChangeHtml($out, $Item); } return $out->outerHtml(); }
function dict__edit() { $form = $_GET["form"]; $out = ki::fromFile("http://{$_SERVER["HTTP_HOST"]}/engine/forms/{$form}/{$form}_edit.php"); $Item = aikiReadItem("dict", $_GET["id"]); if ($_GET["id"] == "_new") { $Item["id"] = newIdRnd(); } else { $out->find("#dictEditForm .nav-tabs li:eq(1)")->addClass("set_active"); } $out->find("form button[data-formsave]")->parents(".form-group")->remove(); $Item["form"] = $form; if (isset($Item["data"])) { $Item["data"] = json_encode($Item["data"]); } $out->contentSetData($Item); return $out->outerHtml(); }
function _ordersMail($Item = null) { if ($Item == null) { $Item = aikiReadItem("orders", $_GET["item"]); } $out = aikiGetForm("orders", "mail", true); $out->contentSetData($Item); $out->find(".data-grand-total")->remove(); $subject = $out->find("title")->text(); $to = "<{$Item["person"]["email"]}>, "; $to .= "<{$_SESSION["settings"]["email"]}> "; $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=windows-1251\r\n"; $headers .= "From: {$_SERVER["HTTP_HOST"]} <{$_SESSION["settings"]["email"]}>\r\n"; $body = iconv("UTF-8", "WINDOWS-1251", $out->outerHtml()); $subject = iconv("UTF-8", "WINDOWS-1251", $subject); mail($to, $subject, $body, $headers); return $out; }
function pay2pay__checkout() { $order = aikiReadItem("orders", $_SESSION["order_id"]); $form = aikiGetForm($_GET["form"], $_GET["mode"]); $SETT = $_SESSION["settings"][$_GET["form"]]; $test_mode = $SETT['test']; if ($test_mode == "on") { $test_mode = 1; } $success_url = "http://{$_SERVER['HTTP_HOST']}/{$_GET["form"]}/success/{$order['id']}.htm"; $fail_url = "http://{$_SERVER['HTTP_HOST']}/{$_GET["form"]}/fail/{$order['id']}.htm"; $result_url = "http://{$_SERVER['HTTP_HOST']}/{$_GET["form"]}/result/{$order['id']}.htm"; $mch = array(); $mch["merchant_id"] = $SETT['id']; $mch["merchant_url"] = $SETT['url']; $mch["secret_key"] = $SETT['secret_key']; $mch["currency"] = "RUB"; $mch["description"] = "Кафе Купон"; $mch["order_id"] = $order["id"]; $mch["amount"] = $order["total"]; $mch["secret_key"] = $SETT["key"]; $xml = '<?xml version="1.0" encoding="UTF-8"?> <request> <version>1.3</version> <merchant_id>' . $mch["merchant_id"] . '</merchant_id> <order_id>' . $mch["order_id"] . '</order_id> <amount>' . $mch["amount"] . '</amount> <currency>' . $mch["currency"] . '</currency> <description>' . $mch["description"] . '</description> <success_url><![CDATA[' . $success_url . ']]></success_url> <fail_url><![CDATA[' . $fail_url . ']]></fail_url> <result_url><![CDATA[' . $result_url . ']]></result_url> <test_mode>' . $test_mode . '</test_mode> </request> '; $sign = md5($mch["secret_key"] . $xml . $mch["secret_key"]); $mch["sign_encoded"] = base64_encode($sign); $mch["xml_encoded"] = base64_encode($xml); $form->contentSetValues($mch); return $form->outerHtml(); }
function common__show($Item = array()) { $out = ""; if (isset($_GET["form"]) && $_GET["form"] > "") { $Item = aikiReadItem($_GET["form"], $_GET["id"]); if ($_SESSION["error"] == "noitem") { header($_SERVER['SERVER_PROTOCOL'] . " 404 Not Found"); if (is_file($_SESSION["app_path"] . "/tpl/404.php")) { $out = aikiGetTpl("404.php"); } else { $out = ki::fromString("[Ошибка 404] Страница отсутствует"); } } else { if (isset($Item["template"]) && $Item["template"] > "") { $out = aikiGetTpl($Item["template"]); } else { $out = aikiGetForm(); } if ($out == "") { $out = ki::fromString("<html><div><h2>{{header}}</h2>{{text}}</div></html>"); } } if (isset($Item["form"])) { formCurrentInclude($Item["form"]); $call = "_{$Item["form"]}BeforeShowItem"; if (is_callable($call)) { $Item = @$call($Item); } $call = "{$Item["form"]}BeforeShowItem"; if (is_callable($call)) { $Item = @$call($Item); } } } if (!is_object($out)) { $out = ki::fromString($out); } $out->contentSetData($Item); return $out->outerHtml(); }
function comments__getajax() { switch ($_GET["view"]) { case "modal": $out = aikiGetForm($_GET["form"], "show"); $Item = _commentsBeforeShowItem(aikiReadItem("comments", $_GET["item"])); $out->contentSetData($Item); return $out->outerHtml(); break; case "new": $out = aikiGetForm($_GET["form"], "edit"); $Item["id"] = newIdRnd(); if ($_SESSION["User"] != "Admin") { $out->find("textarea[name=reply]")->parents(".form-group")->remove(); $out->find("input[type=checkbox]")->parents(".form-group")->remove(); } else { $out->find(".modal-body button[formsave]")->parents(".form-group")->remove(); } $out->contentSetData($Item); return clearValueTags($out->outerHtml()); break; } }
$item = $_GET["item"]; } else { $_GET["item"] = $item; } if (isset($_GET["id"]) && $_GET["id"] > "") { $item = $_GET["id"]; } else { $_GET["id"] = $item; } if ($_SERVER["REQUEST_URI"] == "/" && $mode == "show" && $form == "page") { $item = "home"; } if (isset($form) && isset($item)) { formCurrentInclude($form); include_once "{$_SESSION["engine_path"]}/forms/common/common.php"; $Item = $_SESSION["Item"] = aikiReadItem($form, $item); if ($_SESSION["error"] == "noitem") { $error = "noitem"; } else { if (isset($Item["template"])) { $tpl = $Item["template"]; } } } if ($_SESSION["error"] == "noitem") { $empty = 1; } else { $empty = 0; } if ($form == "page" && $mode == "show" && $item == "home" && $tpl == "") { if (is_file($_SESSION["app_path"] . "/tpl/home.php")) {
function users__activation() { $res = true; $user = aikiReadItem("users", $_GET["item"]); unset($user["firstImg"]); if (isset($_GET["code"]) and isset($user["verify"]) and $_GET["code"] == $user["verify"]) { unset($user["verify"]); $user["active"] = "on"; $user["role"] = "user"; aikiSaveItem("users", $user); header("Location: http://{$_SERVER['HTTP_HOST']}/"); } else { echo "Error!!!"; $res = false; } }
function tagForeach($Item = array()) { if (!$this->is("[data-template]")) { $this->addTemplate(); } $srcItem = $Item; $pagination = ""; $sort = $this->attr("sort"); $dsort = $this->attr("data-sort"); $pagination = "ajax"; if ($this->attr("data-pagination") > "") { $size = $this->attr("data-pagination"); $pagination = "js"; } if ($this->attr("data-size") > "") { $size = $this->attr("data-size"); $pagination = "ajax"; } else { $size = "false"; } $mode = $this->attr("mode"); $dmode = $this->attr("data-mode"); if ($dmode == "") { $dmode = "list"; } $desc = $this->attr("desc"); $ddesc = $this->attr("data-desc"); $rand = $this->attr("rand"); $step = $this->attr("step"); $page = $this->attr("data-page"); if ($page == "") { $page = 1; } $cache = $this->attr("data-cache"); $dList = $this->attr("data-list"); if ($dList == "") { $dList = false; } else { $dList = aikiReadList($dList); } $limit = $this->attr("limit"); $call = $this->attr("call"); $oconv = $this->attr("oconv"); $item = $this->attr("item"); $where = $this->attr("where"); if ($where == "") { $where = NULL; } $field = $this->attr("field"); $from = $this->attr("from"); $find = $this->attr("data-find"); // контекстный поиск $tplid = $this->attr("data-template"); $beforeShow = $this->attr("data-before-show"); if ($from > "" && !isset($Item[$from])) { $tmp = ""; eval('$tmp=$Item' . $from . ";"); if ($tmp > "") { $Item[$from] = $tmp; } } if ($from > "" && isset($Item[$from]) && $this->hasRole("foreach") && $cache == "") { if ($this->attr("form") == "" && isset($Item["form"])) { $form = $Item["form"]; } else { $form = ""; } if ($this->attr("item") == "" && isset($Item["id"])) { $item = $Item["id"]; } else { $item = ""; } $Item = $Item[$from]; if (!is_array($Item)) { $Item = json_decode($Item, true); } if ($field > "") { $Item = $Item[$field]; } if (!is_array($Item)) { $Item = json_decode($Item, true); } if ($where > "") { $Item = aikiWhere($Item); } } else { $Item = array(); } $vars = $this->attr("vars"); if ($vars > "") { $Item = attrAddData($vars, $Item); } $json = $this->attr("json"); if ($json > "") { $Item = json_decode($json, true); } $index = $this->attr("index"); if (($this->attr("form") > "" or $this->attr("data-form") > "") && $from == "" && $cache == "") { $form = $this->attr("form"); if ($form == "") { $form = $this->attr("data-form"); } $type = $this->attr("data-type"); if ($type > "") { $_SESSION[$form]["data-type-tmp"] = $type; } formCurrentInclude($form); $datatype = "file"; $func = $form . "DataType"; if (is_callable($func)) { $datatype = $func(); } if ($item > "") { $Item[0] = aikiReadItem($form, $item); if ($field > "") { $Item = $Item[0][$field]; if (is_string($Item)) { $Item = json_decode($Item, true); } if (isset($Item[0]["img"]) && isset($Item[0]["visible"])) { $Item = array_filter_value($Item, "visible", "1"); } } } else { $list = aikiListItems($form, $where); $Item = array(); $Item = $list["result"]; } } if (is_string($Item)) { $Item = json_decode($Item, true); } if (!is_array($Item)) { $Item = array($Item); } if ($cache > "" && isset($_SESSION["data"]["foreach"][$cache])) { $Item = $_SESSION["data"]["foreach"][$cache]; $first = array_shift($Item); array_unshift($Item, $first); if (isset($first["form"])) { $form = $first["form"]; formCurrentInclude($form); } } if ($sort > "") { // старый формат if ($desc == "true") { $stype = SORT_DESC; } else { $stype = SORT_ASC; } $Item = array_sort($Item, $sort, $stype); } if ($dsort > "") { $Item = array_sort_multi($Item, $dsort); if ($cache !== "") { $_SESSION["data"]["foreach"][$cache] = $Item; } } if ($ddesc == "true") { $Item = array_reverse($Item); } if ($rand == "true") { shuffle($Item); } if (is_callable($call)) { $Item = $call($Item); } $tpl = $this->innerHtml(); $inner = ""; $this->html(""); if ($step > 0) { $steptpl = $this->clone(); $stepcount = 0; } if ($tplid == "") { $tplid = "tpl" . newIdRnd(); } $ndx = 0; $fdx = 0; $n = 0; $count = count($Item); if ($size == "false") { $pagination = "js"; } if ($this->tag() !== "select" && $size == "" && $count > 200) { $pagination = "ajax"; $size = 10; $page = 1; $this->attr("data-size", $size); } if ($count && $Item !== array(0 => "")) { $cacheList = array(); $inner = ""; $srcVal = array(); foreach ($srcItem as $k => $v) { $srcVal["%{$k}"] = $v; } unset($v); $ndx = 0; $n = 0; $f = 0; $tmptpl = aikiFromString($tpl); foreach ($Item as $key => $val) { if (!isset($val["id"])) { $lid = $key; } else { $lid = $val["id"]; } if ($dList == false or in_array($lid, $dList)) { $n++; $cacheVal = $val; if ($limit == "" or $limit * 1 > $ndx * 1) { if (!is_array($val)) { $tmp = json_decode($val, true); if ($tmp) { $val = $tmp; } else { $val = array($val); } } // именно так и никак иначе if ($vars > "") { $val = attrAddData($vars, $val); } if ($val !== NULL && ($where == NULL or aikiWhereItem($val, $where))) { // если не обнулено в вызываемой ранее функцией (например, если стоит флаг скрытия в списке) if ($cache == "" && $size !== "false" && $size !== "") { $cacheList[$key] = $cacheVal; } if ($pagination == "ajax" && ($size == "false" or $size == "")) { $size = 999999999; } if ($pagination == "ajax" and ($size > "" && $cache > "" && ($n > $page * $size - $size && $n <= $page * $size) or $size > "" && $cache == "" && $ndx < $size or $find > "") or $size == "" or $pagination == "js") { $itemform = ""; if (isset($val["form"])) { $itemform = $val["form"]; } else { $itemform = $_GET["form"]; } $text = $tmptpl->clone(); $val = (array) $srcVal + (array) $val; // сливаем массивы if ($beforeShow !== "false") { $val = aikiBeforeShowItem($val, $dmode, $itemform); } if (is_callable($oconv)) { $val = $oconv($val); } $text->find(":first")->attr("idx", $key); $val["_idx"] = $_SESSION["foreach_idx"] = $key; $val["_ndx"] = $_SESSION["foreach_ndx"] = $ndx; $val["_num"] = $_SESSION["foreach_num"] = $ndx + 1; $text->contentSetData($val); if ($find == "") { $flag = true; } else { $flag = aikiInString(strip_tags($text->innerHtml()), $find); if ($flag) { $f++; } } if ($find == "" or $size == "false" or $size == "" or $find > "" && ($f > $page * $size - $size && $f <= $page * $size)) { $tmp; } else { $flag = false; } if ($flag == true) { $ndx++; if ($step > 0) { // если степ, то работаем с объектом if ($stepcount == 0) { $t_step = $steptpl->clone(); $t_step->addClass($tplid); $this->append($t_step); } $this->find(".{$tplid}:last")->append(clearValueTags($text->outerHtml())); $stepcount++; //$stepcount=$this->find(".{$tplid}:last")->children()->length; if ($stepcount == $step) { $stepcount = 0; } } else { // иначе строим строку $inner .= clearValueTags($text->outerHtml()); } } else { $n--; } $text->remove(); } } } } } if ($step > 0) { foreach ($this->find(".{$tplid}") as $tid) { $tid->removeClass($tplid); } unset($tid); } else { $this->html($inner); } unset($val, $ndx, $t_step, $string, $text, $func, $inner, $tmptpl); } if ($this->tag() == "select") { if (!is_array($result)) { $this->outerHtml(""); } $plhr = $this->attr("placeholder"); if ($plhr > "") { $this->prepend("<option value=''>{$plhr}</option>"); } } else { $data_group = $this->attr("data-group"); $data_total = $this->attr("data-total"); if ($data_total > "" or $data_group > "") { aikiTableProcessor($this); $size = ""; } if ($size > "" && $size !== "false" && $pagination == "js") { $this->tagDataPagination($size); } if ($size > "" && $size !== "false" && $pagination == "ajax") { if ($cache > "") { $cacheId = $cache; } else { $cacheId = md5($from . $form . $where . $tplid . $sort . $rand . $dsort . $limit . $item . $field . $call . $oconv . $vars . $json . implode("-", $_GET)); } if ($cache == "" && isset($cacheList)) { $_SESSION["data"]["foreach"][$cacheId] = $cacheList; } unset($cacheList); if ($find > "") { $count = $f; } else { $count = count($_SESSION["data"]["foreach"][$cacheId]); } $pages = ceil($count / $size); //if (round($pages)<$pages) {$pages=round($pages)+1;} $this->tagDataPagesAjax($size, $page, $pages, $cacheId, $count, $find); } } unset($Item, $tpl); gc_collect_cycles(); }
function aikiDeleteItem($form, $id) { $Item = aikiReadItem($form, $id); $before = $form . "BeforeDeleteItem"; if (is_callable($before)) { $Item = aikiReadItem($form, $id); $Item = $before($Item); } if ($_SESSION["settings"]["store"] == "on") { $datatype = "mysql"; } else { $datatype = "file"; } $res = array(); $res["error"] = 0; $dir = formPathGet($_GET["form"], $_GET["item"]); if ($_GET["upl"] == "true" or !isset($_GET["ulp"])) { $res1 = DeleteDir($dir["uplitem"]); } $call = "{$datatype}DeleteItem"; $del = $call($form, $id); if ($del == false) { $res["error"] = 1; } $after = $form . "AfterDeleteItem"; if (is_callable($after)) { $Item = $after($Item); } return $res; }