Example #1
0
 function tag($tag)
 {
     $data['tag'] = $tag;
     $data['knowledges'] = new Knowledge();
     $data['knowledges']->where("tag like '%{$tag}%'")->get_page(limit());
     $this->template->build('knowledge_tag', $data);
 }
Example #2
0
 function tag($tag)
 {
     $data['tag'] = $tag;
     $data['informations'] = new Information();
     lang_filter($data['informations']->where("tag like '%{$tag}%'"))->get_page(limit());
     $this->template->build('information_tag', $data);
 }
 function index()
 {
     $webboard_relate_dels = new Webboard_relate_del();
     $data['webboard_relate_dels'] = $webboard_relate_dels->order_by('id', 'desc')->get_page(limit());
     $this->template->append_metadata(js_lightbox());
     $this->template->build('admin/webboard_relate_del_index', $data);
 }
Example #4
0
File: flat.php Project: akilli/qnd
/**
 * Load entity
 *
 * @param array $entity
 * @param array $crit
 * @param array $opts
 *
 * @return array
 */
function flat_load(array $entity, array $crit = [], array $opts = []) : array
{
    $stmt = db()->prepare(select($entity['attr']) . from($entity['tab']) . where($crit, $entity['attr'], $opts) . order($opts['order'] ?? [], $entity['attr']) . limit($opts['limit'] ?? 0, $opts['offset'] ?? 0));
    $stmt->execute();
    if (!empty($opts['one'])) {
        return $stmt->fetch() ?: [];
    }
    return $stmt->fetchAll();
}
Example #5
0
 function index()
 {
     $data['type'] = array('7' => 'ico_notify_03.png', '8' => 'ico_notify_06.png', '9' => 'ico_notify_08.png', '193' => 'ico_notify_10.png');
     $data['notices'] = new Notice();
     @$_GET['titlesearch'] ? $data['notices']->like('title', $_GET['titlesearch']) : '';
     @$_GET['type'] ? $data['notices']->where('category_id', $_GET['type']) : '';
     lang_filter($data['notices'])->where("start_date <= date(sysdate()) and (end_date >= date(sysdate()) or end_date = date('0000-00-00')) and status = 'approve'")->order_by('start_date', 'desc')->get_page(limit());
     $this->template->build('notice_index', $data);
 }
Example #6
0
 function index()
 {
     $data['english_zones'] = new English_zone();
     if (@$_GET['search']) {
         $data['informations']->where("title like '%" . $_GET['search'] . "%'");
     }
     auth_filter($data['english_zones'])->order_by('id', 'desc')->get_page(limit());
     $this->template->append_metadata(js_checkbox('approve'));
     $this->template->build('admin/english_zone_index', $data);
 }
Example #7
0
 function index()
 {
     $menus = new Menu();
     if (@$_GET['status']) {
         $menus->where('status', $_GET['status']);
     }
     $data['menus'] = $menus->order_by('orderlist', 'asc')->get_page(limit());
     $this->template->append_metadata(js_checkbox('approve'));
     $this->template->build('admin/menu_index', $data);
 }
Example #8
0
 function index()
 {
     $data['polls'] = new poll();
     if (isset($_POST['search'])) {
         $data['polls']->where('title like \'%' . $_POST['search'] . '%\'');
     }
     $data['polls']->order_by('id', 'desc')->get_page(limit());
     $this->template->append_metadata(js_checkbox());
     $this->template->build('admin/poll_index', $data);
 }
Example #9
0
 function index()
 {
     $webboard_quizs = new Webboard_quiz();
     if (@$_POST['category_id']) {
         $webboard_quizs->where('category_id', $_POST['category_id']);
     }
     $data['webboard_quizs'] = $webboard_quizs->order_by('id', 'desc')->get_page(limit());
     $this->template->append_metadata(js_lightbox());
     $this->template->build('admin/webboard_index', $data);
 }
Example #10
0
 function index($id = FALSE)
 {
     $data['categories'] = new Category($id);
     $galleries = new Gallery();
     if (@$_POST['category_id']) {
         $id = $_POST['category_id'];
     }
     $data['galleries'] = $galleries->where('category_id', $id)->order_by('id', 'desc')->get_page(limit());
     $this->template->append_metadata(js_lightbox());
     $this->template->build('admin/gallery_index', $data);
 }
Example #11
0
 function index($category_id = FALSE)
 {
     $articles = new Article();
     if ($category_id) {
         $category = new Category($category_id);
         $articles->where("category_id in (select id from categories where lft >= " . $category->lft . " and rgt <= " . $category->rgt . " and module = '" . $category->module . "')");
     }
     $data['articles'] = $articles->order_by('id', 'desc')->get_page(limit());
     $this->template->append_metadata(js_lightbox());
     $this->template->build('admin/article_index', $data);
 }
Example #12
0
 function index()
 {
     $data['hilights'] = new hilight();
     if (@$_GET['status']) {
         $data['hilights']->where('status', $_GET['status']);
     }
     auth_filter($data['hilights'])->order_by('id', 'desc')->get_page(limit());
     $this->template->append_metadata(js_lightbox());
     $this->template->append_metadata(js_checkbox('approve'));
     $this->template->build('admin/hilight_index', $data);
 }
Example #13
0
 /** Select data from table
  * @param string
  * @param array result of $adminer->selectColumnsProcess()[0]
  * @param array result of $adminer->selectSearchProcess()
  * @param array result of $adminer->selectColumnsProcess()[1]
  * @param array result of $adminer->selectOrderProcess()
  * @param int result of $adminer->selectLimitProcess()
  * @param int index of page starting at zero
  * @param bool whether to print the query
  * @return Min_Result
  */
 function select($table, $select, $where, $group, $order, $limit, $page, $print = false)
 {
     global $adminer, $jush;
     $is_group = count($group) < count($select);
     $query = $adminer->selectQueryBuild($select, $where, $group, $order, $limit, $page);
     if (!$query) {
         $query = "SELECT" . limit(($_GET["page"] != "last" && +$limit && $group && $is_group && $jush == "sql" ? "SQL_CALC_FOUND_ROWS " : "") . implode(", ", $select) . "\nFROM " . table($table), ($where ? "\nWHERE " . implode(" AND ", $where) : "") . ($group && $is_group ? "\nGROUP BY " . implode(", ", $group) : "") . ($order ? "\nORDER BY " . implode(", ", $order) : ""), $limit != "" ? +$limit : null, $page ? $limit * $page : 0, "\n");
     }
     if ($print) {
         echo $adminer->selectQuery($query);
     }
     return $this->_conn->query($query);
 }
Example #14
0
 function index()
 {
     $data['weblinks'] = new Weblink();
     if (@$_GET['search']) {
         $data['weblinks']->where("title like '%" . $_GET['search'] . "%'");
     }
     if (@$_GET['category_id']) {
         $data['weblinks']->where("category_id = " . $_GET['category_id']);
     }
     $data['weblinks']->order_by('id', 'desc')->get_page(limit());
     $this->template->append_metadata(js_lightbox());
     $this->template->build('admin/weblinks_index', $data);
 }
Example #15
0
 function index()
 {
     $data['faqs'] = new Faq();
     if (@$_GET['search']) {
         $data['faqs']->where("question like '%" . $_GET['search'] . "%'");
     }
     if (@$_GET['category_id']) {
         $data['faqs']->where("category_id = " . $_GET['category_id']);
     }
     $data['faqs']->order_by('orderlist', 'asc')->get_page(limit());
     $this->template->append_metadata(js_lightbox());
     $this->template->append_metadata(js_checkbox('approve'));
     $this->template->build('admin/faqs_index', $data);
 }
Example #16
0
 function index()
 {
     $data['executives'] = new Executive();
     if (isset($_GET['search'])) {
         $data['executives']->where('title like \'%' . $_GET['search'] . '%\'');
     }
     if (@$_GET['status']) {
         $data['executives']->where('status', $_GET['status']);
     }
     auth_filter($data['executives'])->order_by('id', 'desc')->get_page(limit());
     $this->template->append_metadata(js_lightbox());
     $this->template->append_metadata(js_checkbox('approve'));
     $this->template->build('admin/executive_index', $data);
 }
Example #17
0
 function index($category_id = FALSE)
 {
     $this->template->set_layout('layout_blank');
     if ($category_id) {
         $data['categories'] = new Category($category_id);
         @$_GET['textsearch'] ? $data['categories']->academic->like('title', $_GET['textsearch']) : '';
         $data['categories']->academic->where("status = 'approve'")->order_by('id', 'desc')->get_page(limit());
         $this->template->build('academic_category_view', $data);
     } else {
         $data['categories'] = new Category();
         $data['categories']->where("module = 'academics' and parents <> 0")->get_page();
         $this->template->build('academic_index', $data);
     }
 }
Example #18
0
 function view($id, $group = FALSE)
 {
     $this->template->set_layout('layout_blank');
     $data['catagory_id'] = $id;
     $data['galleries'] = new Gallery();
     @$_POST['textsearch'] ? $data['galleries']->like('title', $_POST['textsearch']) : '';
     @$_POST['groups'] ? $data['galleries']->where_related_category('group_id', $_POST['groups']) : '';
     $data['galleries']->where("category_id = '{$id}'")->order_by('id', 'desc')->get_page(limit());
     if ($group) {
         $data['group'] = new group($data['galleries']->category->user->group_id);
         $this->template->set_layout('group_blank');
     }
     $this->template->build('gallery_view', $data);
 }
Example #19
0
 function index()
 {
     $data['notices'] = new Notice();
     if (@$_GET['search']) {
         $data['notices']->where("title like '%" . $_GET['search'] . "%'");
     }
     if (@$_GET['status']) {
         $data['notices']->where('status', $_GET['status']);
     }
     if (@$_GET['category_id']) {
         $data['notices']->where("category_id = " . $_GET['category_id']);
     }
     auth_filter($data['notices'])->order_by('id', 'desc')->get_page(limit());
     $this->template->append_metadata(js_lightbox())->append_metadata(js_checkbox('approve'));
     $this->template->build('admin/notice_index', $data);
 }
Example #20
0
 function index($id = FALSE)
 {
     if ($id) {
         $data['user'] = new User($id);
         $data['user']->executive->where("start_date <= date(sysdate()) and (end_date >= date(sysdate()) or end_date = date('0000-00-00')) and status = 'approve'")->order_by('id', 'desc')->get_page(limit());
         $this->template->build('index_id', $data);
     } else {
         $users = new User();
         $data['users'] = $users->where("level_id = 6")->order_by('id', 'desc')->get(1);
         $data['executive_infos'] = new Executive_info();
         $data['executive_infos']->order_by('id', 'desc')->get(5);
         $data['executive_its'] = new Executive_it();
         $data['executive_its']->order_by('id', 'desc')->get(5);
         $executives = new Executive();
         lang_filter($executives->where("start_date <= date(sysdate()) and (end_date >= date(sysdate()) or end_date = date('0000-00-00')) and status = 'approve'"));
         $data['executives'] = $executives->order_by('id', 'desc')->get(5);
         $data['videos'] = new Executive_video();
         $data['videos']->order_by('id', 'desc')->get(5);
         $this->template->build('index', $data);
     }
 }
Example #21
0
 function index()
 {
     $data['users'] = new User();
     if (@$_GET['first_name']) {
         $data['users']->like_related_profile('first_name', $_GET['first_name']);
     }
     if (@$_GET['last_name']) {
         $data['users']->like_related_profile('last_name', $_GET['last_name']);
     }
     if (@$_GET['email']) {
         $data['users']->like('username', $_GET['email']);
     }
     if (@$_GET['level_id']) {
         $data['users']->where('level_id', $_GET['level_id']);
     }
     if (user()->level->view == 2) {
         $data['users']->where('group_id', user()->group_id);
     } elseif (user()->level->view == 3) {
         $data['users']->where('id', user()->id);
     }
     $data['users']->order_by('id', 'desc')->get_page(limit());
     $this->template->build('admin/user_index', $data);
 }
Example #22
0
 echo "</div>\n";
 $adminer->selectColumnsPrint($select, $columns);
 $adminer->selectSearchPrint($where, $columns, $indexes);
 $adminer->selectOrderPrint($order, $columns, $indexes);
 $adminer->selectLimitPrint($limit);
 $adminer->selectLengthPrint($text_length);
 $adminer->selectActionPrint($indexes);
 echo "</form>\n";
 $page = $_GET["page"];
 if ($page == "last") {
     $found_rows = $connection->result("SELECT COUNT(*) FROM " . table($TABLE) . ($where ? " WHERE " . implode(" AND ", $where) : ""));
     $page = floor(max(0, $found_rows - 1) / $limit);
 }
 $query = $adminer->selectQueryBuild($select, $where, $group, $order, $limit, $page);
 if (!$query) {
     $query = "SELECT" . limit((+$limit && $group && $is_group && $jush == "sql" ? "SQL_CALC_FOUND_ROWS " : "") . $from, ($where ? "\nWHERE " . implode(" AND ", $where) : "") . $group_by, $limit != "" ? +$limit : null, $page ? $limit * $page : 0, "\n");
 }
 echo $adminer->selectQuery($query);
 $result = $connection->query($query);
 if (!$result) {
     echo "<p class='error'>" . error() . "\n";
 } else {
     if ($jush == "mssql") {
         $result->seek($limit * $page);
     }
     $email_fields = array();
     echo "<form action='' method='post' enctype='multipart/form-data'>\n";
     $rows = array();
     while ($row = $result->fetch_assoc()) {
         if ($page && $jush == "oracle") {
             unset($row["RNUM"]);
	<div class="topic"><img src="<?php 
echo topic("topic_weblink.png");
?>
"></div>
		<div id="data" style="margin:5px 0 0 0;">

			<div id="mediaitem">
				<div class="groupname"><?php 
echo lang_decode($categories->name, '');
?>
</div>
				
				<div class="tbmedia">
				<table><tbody>
					<?php 
foreach ($categories->weblink->get_page(limit()) as $weblink) {
    ?>
					<tr>
						<td><a href="<?php 
    echo $weblink->url;
    ?>
" target="<?php 
    echo $weblink->target;
    ?>
"><img src="uploads/weblinks/<?php 
    echo $weblink->image;
    ?>
" height="90" width="98"></a></td>
						<td style="padding: 10px; font-size:12px;" valign="top">
						<?php 
    echo lang_decode($weblink->description);
Example #24
0
function checkBoxList($table, $id_field, $value_field, $id_value, $field_name, $condition = '', $chars = 25)
{
    $out = '';
    $uneq_string = randomStringUtil(5);
    if ($condition) {
        $condition = " where " . $condition;
    }
    $sql = "select {$id_field} , {$value_field} from {$table} {$condition} order by {$value_field} ASC";
    $res = mysql_query($sql);
    $rows = mysql_num_rows($res);
    if ($rows > 0) {
        $i = 0;
        while ($i < $rows) {
            $id = mysql_result($res, $i, $id_field);
            $name = mysql_result($res, $i, $value_field);
            $class = 'chebox_0';
            $che = '';
            if (is_array($id_value)) {
                if (in_array($id, $id_value)) {
                    $class = 'chebox_1';
                    $che = ' checked ';
                }
            }
            $out .= '<div class="' . $class . '" onclick="chekBoxSel(\'' . $uneq_string . '\',' . $i . ')" id="chDiv' . $uneq_string . $i . '">
			<input type="checkbox" ' . $che . ' name="' . $field_name . '[]" id="ch' . $uneq_string . $i . '" value="' . $id . '" style="display:none" /> 
			<b>' . ucfirst(limit($name, $chars)) . '</b></div>';
            $i++;
        }
    }
    return $out;
}
Example #25
0
function getWidget($widget_id, $page_id, $condition)
{
    $wid_settings = getWidgetSettings($widget_id);
    $widget_title = lookupField('cms_widgets', 'id', 'title', $widget_id);
    $module_id = lookupField('cms_widgets', 'id', 'module_id', $widget_id);
    $table_name = lookupField('cms_modules', 'id', 'table_name', $module_id);
    $temp_html = getTemplate($widget_id, $wid_settings['template_id']);
    $template_main_html = $temp_html['main_html'];
    $template_item_html = $temp_html['item_html'];
    $final_condition = $wid_settings['condition'];
    if ($final_condition && $condition) {
        $final_condition = $wid_settings['condition'] . ' AND ' . $condition;
    } elseif ($condition) {
        $final_condition = ' WHERE ' . $condition;
    }
    $widget_sql = "SELECT * FROM `{$table_name}` " . $final_condition . " " . $wid_settings['limit'];
    $widget_result = mysql_query($widget_sql);
    $widget_numrows = mysql_num_rows($widget_result);
    $widget_total_numrows = mysql_num_rows(mysql_query("SELECT * FROM `{$table_name}` " . $final_condition));
    if ($widget_numrows) {
        $s = 0;
        while ($s < $widget_numrows) {
            $sql = "SELECT * FROM cms_widget_fields wid_fields, cms_template_fields temp_fields \n\t\t\tWHERE wid_fields.widget_id='{$widget_id}' and temp_fields.id=wid_fields.template_field_id";
            $result = mysql_query($sql);
            $numrows = mysql_num_rows($result);
            if ($numrows) {
                $i = 0;
                $item_html = $template_item_html;
                while ($i < $numrows) {
                    $template_field_id = mysql_result($result, $i, 'wid_fields.template_field_id');
                    $template_field_title = mysql_result($result, $i, 'temp_fields.title');
                    $temp_feild_settings = getTempFieldSettings($template_field_id);
                    $module_field_id = mysql_result($result, $i, 'wid_fields.module_field_id');
                    $module_field_title = lookupField('cms_module_fields', 'id', 'title', $module_field_id);
                    $module_field_type = lookupField('cms_module_fields', 'id', 'type', $module_field_id);
                    $item_val = mysql_result($widget_result, $s, $module_field_title);
                    $sub_page_id = mysql_result($widget_result, $s, 'page_id');
                    $sub_page_title = lookupField('cms_pages', 'id', 'title', $sub_page_id);
                    $sub_page_link = _PREF . $_SESSION['pLang'] . '/page' . $sub_page_id . '/' . $sub_page_title;
                    if ($module_field_type == 'photo') {
                        if ($temp_feild_settings['resize_type'] == 'crop' || $temp_feild_settings['resize_type'] == 'resize') {
                            $thumb = viewPhoto($item_val, $temp_feild_settings['resize_type'], $temp_feild_settings['width'], $temp_feild_settings['height'], 'css', 1, $_SESSION['dots'], 0);
                        } else {
                            $thumb = viewPhoto($item_val, 'full', '', '', 'css', 1, $_SESSION['dots'], 0);
                        }
                        $thumb = str_replace(');', '', str_replace('background-image:url(', '', $thumb));
                        $item_val = $thumb;
                    } else {
                        if ($temp_feild_settings['limit']) {
                            $item_val = limit($item_val, $temp_feild_settings['limit']);
                        }
                    }
                    $item_html = str_replace("##{$template_field_title}##", $item_val, $item_html);
                    $item_html = str_replace("##sub_link##", $sub_page_link, $item_html);
                    $i++;
                }
                $extra_widgets_arr = getContents($item_html, '##wid_start##', '##wid_end##');
                foreach ($extra_widgets_arr as $widget_content) {
                    $sub_widget_id = getContents($widget_content, '##wid_id_start##', '##wid_id_end##')[0];
                    $widget_condition = getContents($widget_content, '##wid_con_start##', '##wid_con_end##')[0];
                    $con_fields_arr = getContents($widget_condition, '##', '##');
                    foreach ($con_fields_arr as $field) {
                        $widget_condition = str_replace("##{$field}##", mysql_result($widget_result, $s, $field), $widget_condition);
                    }
                    $extra_widgets = getWidget($sub_widget_id, '', $widget_condition);
                    $item_html = replaceContents($item_html, '##ws' . $sub_widget_id . '##', '##we' . $sub_widget_id . '##', $extra_widgets);
                    $item_html = str_replace('##ws' . $sub_widget_id . '##', '', str_replace('##we' . $sub_widget_id . '##', '', $item_html));
                }
                $widget_items_html .= $item_html;
            }
            $s++;
        }
    }
    $extra_widgets_arr = getContents($template_main_html, '##wid_start##', '##wid_end##');
    foreach ($extra_widgets_arr as $widget_content) {
        $widget_id = getContents($widget_content, '##wid_id_start##', '##wid_id_end##')[0];
        $widget_condition = getContents($widget_content, '##wid_con_start##', '##wid_con_end##')[0];
        $con_fields_arr = getContents($widget_condition, '##', '##');
        foreach ($con_fields_arr as $field) {
            $widget_condition = str_replace("##{$field}##", mysql_result($widget_result, 0, $field), $widget_condition);
        }
        $extra_widgets = getWidget($widget_id, '', $widget_condition);
        $template_main_html = replaceContents($template_main_html, '##ws' . $widget_id . '##', '##we' . $widget_id . '##', $extra_widgets);
        $template_main_html = str_replace('##ws' . $widget_id . '##', '', str_replace('##we' . $widget_id . '##', '', $template_main_html));
    }
    $link = _PREF . $_SESSION['pLang'] . '/page' . $page_id . '/pn^/' . $widget_title;
    $main_page_title = lookupField('cms_pages', 'id', 'title', $page_id);
    $final_html = str_replace("##main_page_title##", $main_page_title, $template_main_html);
    $final_html = str_replace("##site_pref##", _PREF, $final_html);
    $final_html = str_replace("##template_items##", $widget_items_html, $final_html);
    $final_html .= getPagination($wid_settings['pagination_id'], $widget_total_numrows, $wid_settings['limit_num'], $link);
    if (!$final_html) {
        $final_html = '';
    }
    return $final_html;
}
Example #26
0
 public function _load_child($child, $id)
 {
     if ($this->_stack == '_search_index' && $child == 'object') {
         if ($this->count() == 0) {
             return null;
         }
         $objects = array();
         for ($key = 0; $key < count($this->_data); $key++) {
             $this->_data[$key]->object = NULL;
             $row = $this->_data[$key];
             if (!isset($objects[$row->object_name])) {
                 $objects[$row->object_name] = array();
             }
             $objects[$row->object_name][$row->object_id] = $key;
         }
         $return = null;
         foreach ($objects as $object_name => $ids) {
             foreach (where('id IN %$', array_keys($ids))->get($object_name) as $child_object) {
                 if (isset($ids[$child_object->id])) {
                     $key = $ids[$child_object->id];
                     $this->_data[$key]->object = $child_object;
                     if ($this->_data[$key]->id == $id) {
                         $return =& $this->_data[$key]->object;
                     }
                 }
             }
         }
         return $return;
     } else {
         if (isset($this->_relations[$child])) {
             if ($this->count() == 0) {
                 return array();
             }
             $objects = array();
             $local_key = $this->_relations[$child]['local_key'];
             $foreign_key = $this->_relations[$child]['foreign_key'];
             if ($local_key == 'id') {
                 $local_keys = $this->_ids;
             } else {
                 $local_keys = array();
                 for ($i = 0; $i < count($this->_data); $i++) {
                     $local_keys[] = $this->_data[$i]->{$local_key};
                 }
             }
             if (isset($this->_relations[$child]['link_table'])) {
                 $child_ids = $relation_ids = array();
                 $link_local_key = $this->_relations[$child]['link_local_key'];
                 $link_foreign_key = $this->_relations[$child]['link_foreign_key'];
                 if ($local_key == 'id') {
                     $local_keys = $this->_ids;
                 } else {
                     $local_keys = array();
                     foreach ($this->_data as $row) {
                         $local_keys[] = $row->{$local_key};
                     }
                 }
                 $child_objects = where($link_local_key . ' IN %$', $local_keys);
                 if (isset($this->_relations[$child]['order'])) {
                     $child_objects->order_by($this->_relations[$child]['order']);
                 }
                 $child_objects = $child_objects->get($this->_relations[$child]['link_table']);
                 if ($child_objects->count() > 0) {
                     foreach ($child_objects as $child_object) {
                         $child_ids[] = array($child_object->{$link_local_key}, $child_object->{$link_foreign_key});
                         $relation_ids[] = $child_object->{$link_foreign_key};
                     }
                     $child_objects = where($foreign_key . ' IN %$', $relation_ids)->get($this->_relations[$child]['source']);
                     $children = array();
                     foreach ($child_objects as $child_object) {
                         $children[$child_object->{$foreign_key}] = $child_object;
                         //$child_object->_set_resultset($this);
                     }
                     foreach ($child_ids as $child_object) {
                         if (!isset($objects[$child_object[0]])) {
                             $objects[$child_object[0]] = array();
                         }
                         $objects[$child_object[0]][$children[$child_object[1]]->id] = $children[$child_object[1]];
                     }
                 }
                 for ($key = 0; $key < count($this->_data); $key++) {
                     $resultset = new Resultset($child_objects, $this->_stack . '/' . $child, $child);
                     $resultset->_data = isset($objects[$this->_data[$key]->id]) ? array_values($objects[$this->_data[$key]->id]) : array();
                     $resultset->_rowcount = count($resultset->_data);
                     $resultset->_ids = isset($objects[$this->_data[$key]->id]) ? array_keys($objects[$this->_data[$key]->id]) : array();
                     $this->_data[$key]->{$child} = $resultset;
                     if ($this->_data[$key]->id == $id) {
                         $return =& $this->_data[$key]->{$child};
                     }
                 }
             } else {
                 $child_objects = where($foreign_key . ' IN %$', $local_keys);
                 if (isset($this->_relations[$child]['order'])) {
                     $child_objects->order_by($this->_relations[$child]['order']);
                 }
                 $child_objects = $child_objects->get($this->_relations[$child]['source']);
                 foreach ($child_objects as $child_object) {
                     if ($foreign_key == 'id') {
                         $objects[$child_object->id] = $child_object;
                     } else {
                         if (!isset($objects[$child_object->parent_id])) {
                             $objects[$child_object->parent_id] = array();
                         }
                         $objects[$child_object->parent_id][$child_object->id] = $child_object;
                     }
                 }
                 for ($key = 0; $key < count($this->_data); $key++) {
                     if ($foreign_key == 'id') {
                         $this->_data[$key]->{$child} = isset($objects[$this->_data[$key]->{$local_key}]) ? $objects[$this->_data[$key]->{$local_key}] : NULL;
                     } else {
                         $resultset = new Resultset($child_objects, $this->_relations[$child]['source'], $child);
                         $resultset->_data = isset($objects[$this->_data[$key]->{$local_key}]) ? array_values($objects[$this->_data[$key]->{$local_key}]) : array();
                         $resultset->_rowcount = count($resultset->_data);
                         $resultset->_ids = isset($objects[$this->_data[$key]->{$local_key}]) ? array_keys($objects[$this->_data[$key]->{$local_key}]) : array();
                         $this->_data[$key]->{$child} = $resultset;
                     }
                     if ($this->_data[$key]->id == $id) {
                         $return =& $this->_data[$key]->{$child};
                     }
                 }
             }
             return $return;
         } else {
             if (isset($this->_children[$child])) {
                 if ($this->count() == 0) {
                     return array();
                 }
                 $objects = array();
                 $parent_key = $this->_name . '_id';
                 $query = is_bool($this->_children[$child]) ? limit(false) : $this->_children[$child];
                 if ($limit = $query->limit()) {
                     $query->limit(false);
                 }
                 $child_objects = $query->where($parent_key . ' IN %$', $this->_ids)->get($this->_stack . '>' . $child);
                 foreach ($child_objects as $child_object) {
                     if (!isset($objects[$child_object->{$parent_key}])) {
                         $objects[$child_object->{$parent_key}] = array();
                     }
                     //$child_object->_set_resultset($this);
                     if (!$limit || count($objects[$child_object->{$parent_key}]) < $limit) {
                         $objects[$child_object->{$parent_key}][$child_object->id] = $child_object;
                     }
                 }
                 $return = array();
                 for ($key = 0; $key < count($this->_data); $key++) {
                     $resultset = new Resultset($child_objects, $this->_stack . '/' . $child, $child);
                     $resultset->_data = isset($objects[$this->_data[$key]->id]) ? array_values($objects[$this->_data[$key]->id]) : array();
                     $resultset->_rowcount = count($resultset->_data);
                     $resultset->_ids = isset($objects[$this->_data[$key]->id]) ? array_keys($objects[$this->_data[$key]->id]) : array();
                     $this->_data[$key]->{$child} = $resultset;
                     if ($this->_data[$key]->id == $id) {
                         $return =& $this->_data[$key]->{$child};
                     }
                 }
                 return $return;
             }
         }
     }
     return false;
 }
 function limit1($query, $where)
 {
     return limit($query, $where, 1);
 }
Example #28
0
/** Print results of search in all tables
* @uses $_GET["where"][0]
* @uses $_POST["tables"]
* @return null
*/
function search_tables()
{
    global $adminer, $connection;
    $_GET["where"][0]["op"] = "LIKE %%";
    $_GET["where"][0]["val"] = $_POST["query"];
    $found = false;
    foreach (table_status('', true) as $table => $table_status) {
        $name = $adminer->tableName($table_status);
        if (isset($table_status["Engine"]) && $name != "" && (!$_POST["tables"] || in_array($table, $_POST["tables"]))) {
            $result = $connection->query("SELECT" . limit("1 FROM " . table($table), " WHERE " . implode(" AND ", $adminer->selectSearchProcess(fields($table), array())), 1));
            if (!$result || $result->fetch_row()) {
                if (!$found) {
                    echo "<ul>\n";
                    $found = true;
                }
                echo "<li>" . ($result ? "<a href='" . h(ME . "select=" . urlencode($table) . "&where[0][op]=" . urlencode($_GET["where"][0]["op"]) . "&where[0][val]=" . urlencode($_GET["where"][0]["val"])) . "'>{$name}</a>\n" : "{$name}: <span class='error'>" . error() . "</span>\n");
            }
        }
    }
    echo ($found ? "</ul>" : "<p class='message'>" . lang('No tables.')) . "\n";
}
Example #29
0
    $select = array();
    foreach ($fields as $name => $field) {
        if (isset($field["privileges"]["select"])) {
            $as = convert_field($field);
            if ($_POST["clone"] && $field["auto_increment"]) {
                $as = "''";
            }
            if ($jush == "sql" && ereg("enum|set", $field["type"])) {
                $as = "1*" . idf_escape($name);
            }
            $select[] = ($as ? "{$as} AS " : "") . idf_escape($name);
        }
    }
    $row = array();
    if ($select) {
        $rows = get_rows("SELECT" . limit(implode(", ", $select) . " FROM " . table($TABLE), " WHERE {$where}", isset($_GET["select"]) ? 2 : 1));
        $row = isset($_GET["select"]) && count($rows) != 1 ? null : reset($rows);
    }
}
if ($row === false) {
    echo "<p class='error'>" . lang('No rows.') . "\n";
}
?>

<form action="" method="post" enctype="multipart/form-data" id="form">
<?php 
if ($fields) {
    echo "<table cellspacing='0' onkeydown='return editingKeydown(event);'>\n";
    foreach ($fields as $name => $field) {
        echo "<tr><th>" . $adminer->fieldName($field);
        $default = $_GET["set"][bracket_escape($name)];
Example #30
0
            }
            $textwithlinks .= "</tr>\n";
        }
        $textwithlinks .= "</table>\n";
    }
    if ($cleantext != "" && isset($_REQUEST['pastebin'])) {
        $url = pastebin($cleantext, $name);
        $pastebin = "Pastebin url: <a href=\"{$url}\" target=\"_blank\">{$url}</a>";
    }
    $cleantext = "<h1>translated for copy and paste</h1>\n<pre>{$cleantext}</pre>";
    return array('PASTEBIN' => $pastebin, 'RESULTCLEAN' => $cleantext, 'RESULTHTML' => $textwithlinks);
}
$res['PASTEBIN'] = "";
/*initianlize vars for template*/
$res['RESULTHTML'] = "";
$res['RESULTCLEAN'] = "";
$res['TEXTAREA'] = getinfolog();
$res['TRANSLATOR'] = "http://springrts.com:8000";
$res['INFO'] = "";
if ($res['TEXTAREA'] != "") {
    limit();
    $tmp = xmlrpcrequest($res['TRANSLATOR'], $res['TEXTAREA']);
    /*	if (array_key_exists('faultString',$tmp)){
    		$res['INFO']="<h1>Warning: using local translator, as remote can't translate</h1>";
    		$res['TRANSLATOR']="http://abma.de:8000";
    		$tmp=xmlrpcrequest($res['TRANSLATOR'],$res['TEXTAREA']);
    	}*/
    $res = array_merge($res, parse_result($tmp, getVersion($res['TEXTAREA'])));
}
$res['ACTION'] = $_SERVER['SCRIPT_NAME'];
echo parse_template("index.tpl", $res);