/** * Get all tokens attached to a user * * @param int $user_guid The user GUID * * @return false if none available or array of stdClass objects * (see users_apisessions schema for available variables in objects) * @since 1.7.0 */ function get_user_tokens($user_guid) { $dbprefix = elgg_get_config('dbprefix'); $user_guid = (int) $user_guid; $tokens = get_data("SELECT * from {$dbprefix}users_apisessions\n\t\twhere user_guid={$user_guid}"); return $tokens; }
public function table_settings() { $table = z(t(v('table'))); $tables = get_table_list(db()); if (!in_array($table, $tables)) { return info_page('<a href="javascript:history.back(1);">table不存在,点击返回</a>'); } $data['fields'] = get_fields_info($table); $data['actions'] = array('list' => 'List', 'insert' => 'Insert', 'update' => 'Update', 'remove' => 'Remove'); $data['table'] = $table; $data['my_actions'] = get_data("SELECT * FROM `__meta_code` WHERE `table` = '" . s($table) . "' ORDER BY `id` DESC"); //print_r( $fields ); $data['title'] = $data['top_title'] = 'API设置'; $data['js'][] = 'codemirror.js'; $data['js'][] = 'util/runmode.js'; $data['js'][] = 'mode/php/php.js'; $data['js'][] = 'mode/htmlmixed/htmlmixed.js'; $data['js'][] = 'mode/css/css.js'; $data['js'][] = 'mode/javascript/javascript.js'; $data['js'][] = 'mode/xml/xml.js'; $data['js'][] = 'mode/clike/clike.js'; $data['css'][] = 'codemirror.css'; $data['css'][] = 'theme/night.css'; render($data); }
/** * return Piece from Pieces Return * * $.ajax({ method:'return', table:'Pieces', barcode:9...9, ...}; * * @return string '' */ function JKY_return_piece($the_data) { $db = Zend_Registry::get('db'); $my_barcode = get_data($the_data, 'barcode'); $my_inspected_by = get_data($the_data, 'inspected_by'); $my_weighed_by = get_data($the_data, 'weighed_by'); $my_remarks = get_data($the_data, 'remarks'); $my_checkin_weight = get_data($the_data, 'checkin_weight'); $my_checkin_location = get_data($the_data, 'checkin_location'); $sql = 'UPDATE Pieces' . ' SET ' . get_updated() . ', status="Check In"' . ', inspected_by= ' . $my_inspected_by . ', weighed_by= ' . $my_weighed_by . ', remarks=\'' . $my_remarks . '\'' . ', checkin_weight= ' . $my_checkin_weight . ', checkin_location=\'' . $my_checkin_location . '\'' . ', checkin_at=\'' . get_time() . '\'' . ' WHERE id =' . $my_barcode; log_sql('Pieces', 'update', $sql); $db->query($sql); insert_changes($db, 'Pieces', $my_barcode); $my_order_id = get_table_value('Pieces', 'order_id', $my_barcode); $my_set = ', produced_at=\'' . get_time() . '\'' . ', produced_pieces = produced_pieces + 1'; if ($my_remarks != 'boa') { $my_set = ', rejected_pieces = rejected_pieces + 1'; } $my_field_name = $my_remarks == 'boa' ? 'produced_pieces' : 'rejected_pieces'; $sql = 'UPDATE Orders' . ' SET ' . get_updated() . $my_set . ' WHERE id = ' . $my_order_id; log_sql('Orders', 'update', $sql); $db->query($sql); insert_changes($db, 'Orders', $my_order_id); return ''; }
/** * 获取目标链接列表 * * @author boxcore * @date 2014-10-23 * @param array $configs 配置条件 * @param string $limit * @param string $table_name 表名 * @return array|bool */ public function getUrlList($configs, $limit = 'LIMIT 20 ', $table_name = 'task_url') { $where = $this->__getWhere($configs); $sql = 'SELECT * FROM ' . $table_name . ' ' . $where . 'ORDER BY id ' . $limit; $data = get_data($sql); return $data; }
function get_files_by_cat($filecat) { $sql_pre = "SELECT `id` , `filecat` , `filename` , `filepath` FROM `yxy_downloadfile` WHERE `filecat` = ?i LIMIT 5 "; $array = array($filecat); $sql = prepare($sql_pre, $array); return get_data($sql); }
function westorElggMan_cron_handler($hook, $entity_type, $returnvalue, $params) { global $CONFIG; // old elgg bevore 1.7.0 global $is_admin; $is_admin = true; if (function_exists("elgg_set_ignore_access")) { // new function for access overwrite elgg_set_ignore_access(true); } $context = westorElggMan_get_context(); westorElggMan_set_context('westorElggMan'); $prefix = $CONFIG->dbprefix; $sql = "SELECT {$prefix}metadata.entity_guid\nFROM (({$prefix}metadata AS {$prefix}metadata_1 INNER JOIN {$prefix}metastrings AS {$prefix}metastrings_3\nON {$prefix}metadata_1.name_id = {$prefix}metastrings_3.id) INNER JOIN {$prefix}metastrings\nAS {$prefix}metastrings_2 ON {$prefix}metadata_1.value_id = {$prefix}metastrings_2.id) INNER JOIN (({$prefix}metadata INNER JOIN {$prefix}metastrings ON {$prefix}metadata.name_id = {$prefix}metastrings.id) INNER JOIN {$prefix}metastrings AS {$prefix}metastrings_1 ON {$prefix}metadata.value_id = {$prefix}metastrings_1.id) ON {$prefix}metadata_1.entity_guid = {$prefix}metadata.entity_guid\nWHERE ((({$prefix}metastrings.string)='waitForSend') AND (({$prefix}metastrings_1.string)='1')\nAND (({$prefix}metastrings_3.string)='hiddenTo') AND (({$prefix}metastrings_2.string)<>'1'))"; // and (scheduled is null || scheduled <= now()); try { $result = get_data($sql); } catch (Exception $e) { westorElggMan_set_context($context); throw new Exception($e); } if (is_array($result)) { $elggMan = new class_elggMan(); $now = date("Y-m-d H:i:s"); foreach ($result as $row) { $message = westorElggMan_get_entity($row->entity_guid); if (is_object($message) && $message->getSubtype() == "messages" && ($message->scheduled == null || $message->scheduled <= $now)) { $elggMan->sendMsgNow($message); } } } westorElggMan_set_context($context); }
/** * Return an array reporting the number of various entities in the system. * * @param int $owner_guid Optional owner of the statistics * * @return array */ function get_entity_statistics($owner_guid = 0) { global $CONFIG; $entity_stats = array(); $owner_guid = (int) $owner_guid; $query = "SELECT distinct e.type,s.subtype,e.subtype as subtype_id\n\t\tfrom {$CONFIG->dbprefix}entities e left\n\t\tjoin {$CONFIG->dbprefix}entity_subtypes s on e.subtype=s.id"; $owner_query = ""; if ($owner_guid) { $query .= " where owner_guid={$owner_guid}"; $owner_query = "and owner_guid={$owner_guid} "; } // Get a list of major types $types = get_data($query); foreach ($types as $type) { // assume there are subtypes for now if (!isset($entity_stats[$type->type]) || !is_array($entity_stats[$type->type])) { $entity_stats[$type->type] = array(); } $query = "SELECT count(*) as count\n\t\t\tfrom {$CONFIG->dbprefix}entities where type='{$type->type}' {$owner_query}"; if ($type->subtype) { $query .= " and subtype={$type->subtype_id}"; } $subtype_cnt = get_data_row($query); if ($type->subtype) { $entity_stats[$type->type][$type->subtype] = $subtype_cnt->count; } else { $entity_stats[$type->type]['__base__'] = $subtype_cnt->count; } } return $entity_stats; }
function ucd_list_shortcode() { ob_start(); get_data(); html(); return ob_get_clean(); }
function module_comment_edit() { global $global, $smarty; $obj = new comment(); $obj->set_where('com_id = ' . $global['id']); $one = $obj->get_one(); $one['channel'] = ''; $one['title'] = ''; $obj = new channel(); $list = $obj->get_list(); for ($i = 0; $i < count($list); $i++) { if ($list[$i]['cha_id'] == $one['com_channel_id']) { $one['channel'] = $list[$i]['cha_code']; $original = $list[$i]['cha_code']; if ($list[$i]['cha_original'] != 0) { for ($j = 0; $j < count($list); $j++) { if ($list[$i]['cha_original'] == $list[$j]['cha_id']) { $original = $list[$j]['cha_code']; } } } if ($original == 'goods') { $table = 'goods'; } else { $table = 'article'; } $one['title'] = get_data($table, $one['com_page_id'], substr($table, 0, 3) . '_title'); } } $smarty->assign('comment', $one); }
function facebook_init() { require 'src/facebook.php'; global $facebook; $facebook = new Facebook(array('appId' => FB_KEY, 'secret' => FB_SECRET)); if (!empty($_SESSION) && !empty($_SESSION['fb_code'])) { $url = "https://graph.facebook.com/oauth/access_token?"; $params = array(); $params[] = 'client_id=' . $facebook->getAppId(); $params[] = 'redirect_uri=' . 'http://' . HOST . get_url('/facebook/auth/'); $params[] = 'client_secret=' . $facebook->getApiSecret(); $params[] = 'code=' . $_SESSION['fb_code']; $url .= implode('&', $params); $data = explode('&', get_data($url)); foreach ($data as &$d) { $d = explode('=', $d); if ($d[0] == 'access_token') { $_SESSION['fb_access_token'] = $d[1]; } elseif ($d[0] == 'expires') { $_SESSION['fb_at_expires'] = time() + $d[1]; } } } if (array_key_exists('fb_access_token', $_SESSION)) { if ($_SESSION['fb_at_expires'] > time()) { $facebook->setAccessToken($_SESSION['fb_access_token']); unset($_SESSION['fb_code']); } } }
function module_sheet() { global $global, $smarty; $prefix = $global['channel'] . '/mod-sheet'; if (isset($global['field'])) { $prefix = $prefix . '/field-' . $global['field']; } if (isset($global['key'])) { $prefix = $prefix . '/key-' . $global['key']; } $obj = new article(); $obj->set_where('art_channel_id = ' . $global['channel_id']); if (isset($global['key'])) { $obj->set_where($global['field'] . " like '%" . url_decode($global['key']) . "%'"); } $obj->set_page_size(10); $obj->set_page_num($global['page']); $sheet = $obj->get_sheet(); for ($i = 0; $i < count($sheet); $i++) { $sheet[$i]['cat_name'] = get_data('cat_art', $sheet[$i]['art_cat_id'], 'cat_name'); } set_link($obj->get_page_sum()); $smarty->assign('article', $sheet); $smarty->assign('prefix', $prefix); }
function module_article_list() { global $smarty; $obj = new cat_art(); $obj->set_where('cat_best = 1'); $best_cat = $obj->get_list(); $art_list = array(); if (count($best_cat) > 0) { $smarty->assign('show_all_art', 0); $list_len = get_varia('index_art_list_len'); for ($i = 0; $i < count($best_cat); $i++) { $cat_id = $best_cat[$i]['cat_id']; $best_cat[$i]['channel'] = get_data('channel', $best_cat[$i]['cat_channel_id'], 'cha_code'); $family = implode(',', get_cat_family('cat_art', $cat_id)); $obj = new article(); $obj->set_field('art_id,art_title,art_add_time'); $obj->set_where("art_cat_id in ({$family})"); $obj->set_page_size($list_len ? $list_len : 5); $list = $obj->get_list(); for ($j = 0; $j < count($list); $j++) { $list[$j]['short_title'] = cut_str($list[$j]['art_title'], 22); } $art_list[$cat_id] = $list; unset($obj); } $smarty->assign('best_art_cat', $best_cat); $smarty->assign('art_list', $art_list); } else { $smarty->assign('show_all_art', 1); } }
function backpack_viewer($sid) { globalSchemas(440); $profile = json_decode(get_data('http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=' . AKey() . '&steamids=' . $sid . '&format=json'), true); $profile = $profile['response']['players'][0]; $bp = ''; $hours = getHours($sid); $backpack = json_decode(get_data('http://api.steampowered.com/IEconItems_440/GetPlayerItems/v0001/?key=' . AKey() . '&SteamID=' . $sid . '&format=json'), true); if (isset($backpack) && $backpack['result']['status'] == 1) { usort($backpack['result']['items'], "sortInvPos"); $mplace = ''; $itemCount = array(); //misplaced items foreach ($backpack['result']['items'] as $key => $item) { if ($item['inventory'] == 3221225475) { item_prepare($item); item_price($item); $mplace .= item_image($item); $itemCount[$item['defindex']] = 1; } } if ($mplace != '') { $bp .= '<div class="bp-mplaced">' . $mplace . '</div><br>'; } $inv_pos = 2147483649; $total_items = 0; //start normal items foreach ($backpack['result']['items'] as $key => $item) { if ($item['inventory'] == 3221225475) { //end-of-backpack handler, writes out empty slots until we reach the max slots in the backpack. while ($backpack['result']['num_backpack_slots'] >= $total_items) { $bp .= '<div><img alt="empty" class="mt" src="img/mt.gif"></div>'; $total_items++; $bp .= pg_chk($total_items); // echoes empty backpack slots. } break; } while ($item['inventory'] > $inv_pos + 1) { $bp .= '<div><img alt="empty" class="mt" src="img/mt.gif"></div>'; $total_items++; $inv_pos++; $bp .= pg_chk($total_items); } item_prepare($item); item_price($item); $bp .= item_image($item); $inv_pos = $item['inventory']; $total_items++; $bp .= pg_chk($total_items); $itemCount[$item['defindex']] = 1; } } else { $bp .= 'problem retrieving backpack.'; } echo '<div class="bp-container w800">', '<div class="bp-head">', '<img src=', $profile['avatarfull'], ' />', '<h1>', htmlspecialchars($profile['personaname']), '</h1>', '<h3>TF2: ', $hours[440], ' / DOTA 2: ', $hours[570], ' / CSGO: ', $hours[730], '</h3>', '</div>', '<div class="bp-mweapons">'; fav_class_weapons_box($sid, $itemCount); echo '</div>', '<div class="bp-info">', '</div>', '<div class="bp-content">', $bp, '</div></div>'; //end bp container. }
function getStations() { global $l_stations; $l_stations = array(); $nbCh = 0; $url = "http://api.irail.be/stations/"; $stationsF = get_data($url); $sizef = strlen($stationsF); $station = ""; for ($i = 0; $i < $sizef; $i++) { if (substr($stationsF, $i, 1) == chr(62) or substr($stationsF, $i, 1) == chr(60)) { $nbCh = $nbCh + 1; if (strlen($station) > 3) { for ($j = 0; $j < strlen($station); $j++) { if (substr($station, $j, 1) == "/") { $station = substr($station, $j + 1); } } $station = mb_convert_encoding($station, "ISO-8859-1", "auto"); echo $station . "<br>"; array_push($l_stations, $station); } $station = ''; } if ($nbCh % 2 == 0 and $nbCh > 2 and substr($stationsF, $i, 1) != chr(62)) { $station = $station . substr($stationsF, $i, 1); } } return $l_stations; }
function module_cat_edit() { global $global, $smarty; $list = array(); $obj = new cat_art(); $obj->set_where('cat_channel_id = ' . $global['channel_id']); $arr = $obj->get_list(); if (count($arr) > 0) { $list = $obj->set_cat_order($arr); for ($i = 0; $i < count($list); $i++) { $list[$i]['parent_name'] = get_data('cat_art', $list[$i]['cat_parent_id'], 'cat_name'); $obj->set_where(''); $obj->set_where('cat_parent_id = ' . $list[$i]['cat_id']); if ($obj->get_count() > 0) { $list[$i]['exist_child'] = 1; } else { $list[$i]['exist_child'] = 0; } $list[$i]['show'] = 1; } } $family = get_cat_family('cat_art', $global['id']); for ($i = 0; $i < count($family); $i++) { for ($j = 0; $j < count($list); $j++) { if ($family[$i] == $list[$j]['cat_id']) { $list[$j]['show'] = 0; } } } $smarty->assign('cat_list', $list); $obj = new cat_art(); $obj->set_where('cat_id = ' . $global['id']); $one = $obj->get_one(); $smarty->assign('cat', $one); }
function getLatLongFromAddressGeoCoder($address) { $addressExp = explode(",", $address); if (count($addressExp) == 3) { $addr = urlencode($addressExp[0]); $city = urlencode($addressExp[1]); $stateZip = explode(" ", $addressExp[2]); $state = urlencode($stateZip[0]); $zip = urlencode($stateZip[1]); //$address = urlencode($address); $url = "http://geocoder.maplarge.com/geocoder/json?address={$addr}&city={$city}&state={$state}&zip={$zip}&country=USA"; //$details_url = "http://maps.googleapis.com/maps/api/geocode/json?address=".$address."&key=AIzaSyAehpaOE86x5u7jBMa3TlhjzDwZ4_6rU68"; $data = getCachedContent($url, get_data($url)); $data = json_decode($data, true); // If Status Code is ZERO_RESULTS, OVER_QUERY_LIMIT, REQUEST_DENIED or INVALID_REQUEST if (!$data['lat']) { return null; } $lat = $data['lat']; $lng = $data['lng']; $response = array(); $response['latitude'] = $lat; $response['longitude'] = $lng; } else { $response['latitude'] = 0.0; $response['longitude'] = 0.0; } return $response; }
function get_laws_by_cat($casecat) { $sql_pre = "SELECT `id` , `title` , `lawcat` , `time` , `description` FROM `yxy_laws` WHERE `lawcat` = ?i ORDER BY time DESC "; $array = array($casecat); $sql = prepare($sql_pre, $array); return get_data($sql); }
/** * $.ajax({ method: generate, table: x...x, id: x...x }); * * return: [ x...x, ..., x...x ] */ function JKY_generate($data) { $table = get_data($data, 'table'); $id = get_data($data, 'id'); $count = 0; switch ($table) { case 'CheckOut': $count = JKY_generate_checkout($id); break; case 'Order': $count = JKY_generate_order($id); break; case 'OSA': $count = JKY_generate_osa($id); break; case 'Purchase': $count = JKY_generate_purchase($id); break; case 'Sale': $count = JKY_generate_sale($id); break; case 'TDyer': $count = JKY_generate_tdyer($id); break; } $return = array(); if ($count > 0) { $return['status'] = 'ok'; $return['count'] = $count; } else { $return['status'] = 'error'; $return['message'] = 'no record generated'; } return $return; }
function birthdays_get_upcoming_user_guids() { $site = elgg_get_site_entity(); $today = (int) date("z"); $field = birthdays_get_configured_birthday_field(); if (!$field) { return false; } if (date("w") == 1) { // Mondays $today -= 2; } elseif (date("w") == 2) { // Tuesdays $today -= 1; } $dbprefix = elgg_get_config('dbprefix'); $field_id = (int) get_metastring_id($field); $sql = "SELECT\n\t\te.guid,\n\t\tDAYOFYEAR(DATE(msv.string)) AS birthday\n\t\tFROM {$dbprefix}entities e\n\t\tJOIN {$dbprefix}entity_relationships r ON r.guid_one = e.guid\n\t\tJOIN {$dbprefix}metadata m ON e.guid = m.entity_guid\n\t\tJOIN {$dbprefix}metastrings msv ON m.value_id = msv.id\n\t\tWHERE\n\t\te.type = 'user' AND\n\t\tr.relationship = 'member_of_site' AND\n\t\tr.guid_two = {$site->guid} AND\n\t\tm.name_id = {$field_id}\n\t\tHAVING birthday >= {$today}\n\t\tORDER BY birthday\n\t\tLIMIT 25"; $users = get_data($sql); $return = array(); foreach ($users as $user) { $return[] = $user->guid; } return $return; }
function update_730($players) { foreach ($players as $k => $profile) { $hours = getHours($profile['steamid']); sleep(0.4); $bp = json_decode(get_data('http://steamcommunity.com/profiles/' . $profile['steamid'] . '/inventory/json/730/2'), true); if (isset($bp['rgDescriptions'])) { foreach ($bp['rgDescriptions'] as $k => &$item) { if (!isset($item['market_hash_name']) | !isset($item['classid']) || !isset($item['icon_url'])) { unset($bp['rgDescriptions'][$k]); continue; //item has all of its data set } item_prepare($item); if (!isset($item['price'])) { unset($bp['rgDescriptions'][$k]); continue; } unset($item['descriptions']); unset($item['actions']); unset($item['market_actions']); unset($item['tags']); } } usort($bp['rgDescriptions'], "cmpItems"); $bp = array_slice($bp['rgDescriptions'], 0, 9); if ($bp != null) { archive_save($profile, $hours, $bp); } } }
function standard() { if (empty($meta = get_data())) { return; } // Initialize $output = []; // Setup basic metadata; the only information we have for sure is type, date, and author if ($meta['updated']) { $output[] = sprintf(wp_kses(__('%1$s %2$s was published %3$s<span class="last-updated"> and updated %4$s</span><span class="by-author"> by %5$s</span>', 'ubik'), ['span' => ['class' => []]]), sprintf('<a href="%s" rel="bookmark">%s</a>', get_permalink(), esc_html__('This', 'ubik')), strtolower($meta['type']), $meta['published'], $meta['updated'], $meta['author']); } else { $output[] = sprintf(wp_kses(__('%1$s %2$s was published %3$s<span class="by-author"> by %4$s</span>', 'ubik'), ['span' => ['class' => []]]), sprintf('<a href="%s" rel="bookmark">%s</a>', get_permalink(), esc_html__('This', 'ubik')), strtolower($meta['type']), $meta['published'], $meta['author']); } if ($meta['categories']) { $output[] = sprintf(esc_html__('Category: %s', 'ubik'), $meta['categories']); } if ($meta['tags']) { $output[] = sprintf(esc_html__('Tags: %s', 'ubik'), '<span itemprop="keywords">' . $meta['tags'] . '</span>'); } if ($meta['taxonomies']) { $output[] = $meta['taxonomies']; } // Put it all together if ($output) { $output = implode($output, '. '); } return apply_filters('ubik_meta_standard', $output . '.'); }
function todo_flow_view() { $data['top'] = $data['top_title'] = '团队TODO一览'; $data['uids'] = get_data("SELECT `id` FROM `user` WHERE `is_closed` = 0 AND `level` > 0 "); $data['js'][] = 'jquery.masonry.min.js'; return render($data, 'web', 'plugin', 'todo_flow'); }
/** * show Error messages * */ function showMessage() { if (is_numeric($_GET['msg'])) { switch ($_GET['msg']) { case 1: echo "Please fill both fields."; break; case 2: echo "Incorrect Login Details"; break; case 3: //$response=file_get_contents("http://www.tritonetech.com/php_uploads/rnd/logout_api.php"); //$array=json_decode($response,true); //echo $array['Result']['Data'][0]['Status']; $Url = "./logout_api.php"; //$ch = curl_init($url); //curl_setopt($ch, CURLOPT_RETURNTRANSFER, true) //$recived_content = curl_exec($ch); //$data = json_decode($recived_content); //var_dump($data); //print_r($data); $data = get_data($Url); //var_dump(json_decode($data)); //echo "<pre>"; $jsonobj = json_decode($data); //print_r($jsonobj); //echo ($jsonobj->Result->Data[0]->Status); //print $data['Result']['Data']; //var_dump($data['Result']['Data'][0]['Status']); break; } } }
public function generate() { $documentationPages = array('Reporting' => 'https://developer.frontdeskhq.com/docs/reporting/v3', 'Core' => 'https://developer.frontdeskhq.com/docs/api/v2'); foreach ($documentationPages as $api => $documentationUrl) { $html = get_data($documentationUrl); } }
function module_comment_sheet() { global $global, $smarty; $obj = new comment(); $obj->set_page_size(10); $obj->set_page_num($global['page']); $sheet = $obj->get_sheet(); set_link($obj->get_page_sum()); for ($i = 0; $i < count($sheet); $i++) { $sheet[$i]['channel'] = ''; $sheet[$i]['title'] = ''; $obj = new channel(); $list = $obj->get_list(); for ($j = 0; $j < count($list); $j++) { if ($list[$j]['cha_id'] == $sheet[$i]['com_channel_id']) { $sheet[$i]['channel'] = $list[$j]['cha_code']; $original = $list[$j]['cha_code']; if ($list[$j]['cha_original'] != 0) { for ($k = 0; $k < count($list); $k++) { if ($list[$j]['cha_original'] == $list[$k]['cha_id']) { $original = $list[$k]['cha_code']; } } } if ($original == 'goods') { $table = 'goods'; } else { $table = 'article'; } $sheet[$i]['title'] = get_data($table, $sheet[$i]['com_page_id'], substr($table, 0, 3) . '_title'); } } } $smarty->assign('comment', $sheet); }
function create_xml($table, $conn) { //получаем названия столбцов $fields = get_fields($table, $conn); //получаем данные $data_from_table = get_data($table, $conn); //создаем объект документа $dom = new DOMDocument('1.0', 'UTF-8'); //создаем корневой элемент по имени таблицы $catalog = $dom->createElement("catalog"); $dom->appendChild($catalog); //создаем контейнер для обектов $entities = $dom->createElement("entities"); $catalog->appendChild($entities); //создаем и добавляем объекты foreach ($data_from_table as $value) { $entity = $dom->createElement("entity"); $attribute_id = $dom->createAttribute('id'); $attribute_id->value = $value[0]; $entity->appendChild($attribute_id); for ($k = 0, $i = count($fields); $k < $i; $k++) { $name_tag = $dom->createElement($fields[$k], $value[$k]); $entity->appendChild($name_tag); } $entities->appendChild($entity); } //сохраняем документ $dom->save("files/xml/" . $table . ".xml"); }
public function getArticle() { header('Content-type: application/json'); $_out = array('status' => 'error', 'msg' => '参数错误!', 'eo' => '0'); $keygen = input('keygen'); $token = input('token'); if ($keygen == '19890110001aFk5' && $token == 'yjmhntgbYyhGTByjghTG45H') { $limit = input('limit') ? input('limit') : 20; $order = input('order') ? input('order') : ''; $configs = array('date' => input('date') ? input('order') : '', 'cid' => 4, 'has_pic' => input('has_pic') ? input('has_pic') : 0); $where = $this->_getWhere($configs); $sql = 'select * from task_contents ' . $where . 'order by created_time desc ' . 'limit ' . $limit; $data = get_data($sql); if (!empty($data)) { foreach ($data as $v) { $_list[] = array('id' => $v['id'], 'title' => $v['title'], 'keywords' => $v['keywords'], 'description' => $v['description'], 'image' => $v['pic'], 'content' => $v['content'], 'hash' => $v['url_hash'], 'utc_time' => $v['created_time']); } $_out['list_data'] = $_list; $_out['status'] = 'success'; $_out['msg'] = '成功获取数据'; } else { $_out['msg'] = '暂无数据'; } } else { $_out['msg'] = '验证错误'; } echo json_encode($_out, true); }
/** * @TODO - is there a way we can target them directly instead of iterating through all? * * @param type $h * @param type $t * @param type $r * @param type $p * @return type */ function weekly_cron($h, $t, $r, $p) { $ia = elgg_set_ignore_access(true); // check for abandoned acls $dbprefix = elgg_get_config('dbprefix'); // try to make this as light as possible $options = array('type' => 'object', 'subtype' => 'granular_access', 'limit' => false); $batch = new ElggBatch('elgg_get_entities', $options); foreach ($batch as $b) { $sql = "SELECT COUNT(guid) as total FROM {$dbprefix}entities WHERE access_id = {$b->acl_id}"; $result = get_data($sql); if ($result[0]->total) { continue; } $sql = "SELECT COUNT(id) as total FROM {$dbprefix}metadata WHERE access_id = {$b->acl_id}"; $result = get_data($sql); if ($result[0]->total) { continue; } $sql = "SELECT COUNT(id) as total FROM {$dbprefix}annotations WHERE access_id = {$b->acl_id}"; $result = get_data($sql); if ($result[0]->total) { continue; } // this appears to be orphaned delete_access_collection($b->acl_id); $b->delete(); } elgg_set_ignore_access($ia); return $r; }
function delete_data($id) { $data = get_data(); unset($data[$id]); $data = array_values($data); store_data($data); }
/** * Get the admin user (returns the first admin user) * There is no API in elgg 1.8.5 to get the admin user */ function get_admin_user_details() { global $CONFIG; $query = "SELECT * FROM {$CONFIG->dbprefix}users_entity as e WHERE ( e.admin = 'yes')"; $info = get_data($query); return $info[0]; }