function toArray($xml) { if (is_string($xml)) { $xml = new SimpleXMLElement($xml); } $children = $xml->children(); if (!$children) { return (string) $xml; } $arr = array(); foreach ($children as $key => $node) { $node = toArray($node); // support for 'anon' non-associative arrays if ($key == 'anon') { $key = count($arr); } // if the node is already set, put it into an array if (isset($arr[$key])) { if (!is_array($arr[$key]) || $arr[$key][0] == null) { $arr[$key] = array($arr[$key]); } $arr[$key][] = $node; } else { $arr[$key] = $node; } } return $arr; }
/** * Saves a category to the database * Or updates an existing category * * @url POST / * @url PUT /$id */ public function SaveCategory($id = null, $data) { // Only process valid data if ($this->ValidateCategory($data)) { // Format for update/insert query $dbData = array('name' => $data->Name); // Update existing user? if ($id) { $this->Db()->where('id', $id); if ($this->Db()->update('Categories', $dbData)) { $category = new CategoryModel($id, $data->Name); } else { throw new RestException(500, 'Update mislukt: ' . $this->Db()->getLastError()); } // Add new user } else { $id = $this->Db()->insert('Categories', $dbData); if ($id) { $category = new CategoryModel($id, $data->Name); } else { throw new RestException(500, 'Toevoegen mislukt: ' . $this->Db()->getLastError()); } } return $category > toArray(); } }
function parseWebVTT($captionUrl = NULL, $descUrl = NULL) { if ($captionUrl) { $captionFile = @file_get_contents($captionUrl); if ($captionFile) { $captionArray = toArray('captions', $captionFile); } else { echo '1'; // unable to read caption file; } if ($descUrl) { $descFile = @file_get_contents($descUrl); if ($descFile) { $descArray = toArray('desc', $descFile); } else { // do nothing // description file is not required } } if (sizeof($captionArray) > 0) { writeOutput($captionArray, $descArray); } else { // do nothing // an error has occurred (and hopefully an error code was displayed) } } else { echo '0'; // insuficcient parameters were passed by URL } }
public function testFindAllUsersByDepartmentAndRoles() { $this->users = $this->em->getRepository('AppBundle:User')->findAllUsersByDepartmentAndRoles(1, $this->em->getRepository('AppBundle:Role')->findOneByRole('ROLE_USER')); foreach ($this->users as $this->user) { $this->assertEquals(1, $this->user->getFieldOfStudy()->getDepartment()->getId()); $this->assertContains(toArray('ROLE_USER'), $this->user->getRoles()); } }
function importUsers($users, $questions) { $rows = array(); foreach ($users as $user) { $username = arrayExtract($user, "username"); if(!$username) continue; $username = str_replace(" ", "", $username); if(!$username) continue; //1 insert into user $userRow = array(); $userRow["table"] = "user"; $userRow["username"] = $username; $userRow["password"] = md5($username); $rows[] = $userRow; //2 insert into user_answer 1 row per user column foreach ($user as $column => $userValues) { if(!isset($questions[$column]) || !$userValues) continue; $q = $questions[$column]; //TODO: if question type == multiple, $userValue is array: insert several rows $userValues = toArray($userValues, ";"); foreach ($userValues as $key => $userValue) { $row = array(); $row["table"] = "user_answer"; $row["username"] = $username; // $row["field"] = $column; // $row["value"] = $userValue; $row["question_id"] = $q["id"]; $answer = findAnswer($q, $userValue); if($answer) { $row["answer_id"] = $answer["id"]; // $row["answer"] = $answer; if(@$answer["value"]) $row["answer_value"] = $answer["value"]; else if(@$answer["data_type"] == "number") $row["answer_value"] = $userValue; else if(@$answer["data_type"] == "text") $row["answer_text"] = $userValue; } else if(@$q["data_type"] == "number") $row["answer_value"] = $userValue; else if(@$q["data_type"] == "text") $row["answer_text"] = $userValue; if(@$row["answer_id"] || @$row["answer_text"] || @$row["answer_value"]) $rows[] = $row; } } } return $rows; }
function submit($option) { global $stack, $mainframe; // get values from gui of script $website = JRequest::getVar('http_host', 'none', 'POST', 'STRING', JREQUEST_ALLOWHTML); if (substr($website, -1) != "/") { $website = $website . "/"; } $page_root = JRequest::getVar('document_root', 'none', 'POST', 'STRING', JREQUEST_ALLOWHTML); $sitemap_file = $page_root . JRequest::getVar('sitemap_url', 'none', 'POST', 'STRING', JREQUEST_ALLOWHTML); $sitemap_url = $website . JRequest::getVar('sitemap_url', 'none', 'POST', 'STRING', JREQUEST_ALLOWHTML); $sitemap_form = JRequest::getVar('sitemap_url', 'none', 'POST', 'STRING', JREQUEST_ALLOWHTML); $priority = JRequest::getVar('priority', '1.0', 'POST', 'STRING', JREQUEST_ALLOWHTML); $forbidden_types = toArray(JRequest::getVar('forbidden_types', 'none', 'POST', 'STRING', JREQUEST_ALLOWHTML)); $exclude_names = toArray(JRequest::getVar('exclude_names', 'none', 'POST', 'STRING', JREQUEST_ALLOWHTML)); $freq = JRequest::getVar('freq', 'none', 'POST', 'STRING', JREQUEST_ALLOWHTML); $modifyrobots = JRequest::getVar('robots', 'none', 'POST', 'STRING', JREQUEST_ALLOWHTML); $method = JRequest::getVar('method', 'none', 'POST', 'STRING', JREQUEST_ALLOWHTML); $level = JRequest::getVar('levels', 'none', 'POST', 'STRING', JREQUEST_ALLOWHTML); $maxcon = JRequest::getVar('maxcon', 'none', 'POST', 'STRING', JREQUEST_ALLOWHTML); $timeout = JRequest::getVar('timeout', 'none', 'POST', 'STRING', JREQUEST_ALLOWHTML); $whitelist = JRequest::getVar('whitelist', 'none', 'POST', 'STRING', JREQUEST_ALLOWHTML); $priority >= 1 ? $priority = "1.0" : null; $xmlconfig = genConfig($priority, $forbidden_types, $exclude_names, $freq, $method, $level, $maxcon, $sitemap_form, $page_root, $timeout); if (substr($page_root, -1) != "/") { $page_root = $page_root . "/"; } $robots = @JFile::read($page_root . 'robots.txt'); preg_match_all("/Disallow:(.*?)\n/", $robots, $pos); if ($exclude_names[0] == "") { unset($exclude_names[0]); } foreach ($pos[1] as $disallow) { $disallow = trim($disallow); if (strpos($disallow, $website) === false) { $disallow = $website . $disallow; } $exclude_names[] = $disallow; } $forbidden_strings = array("print=1", "format=pdf", "option=com_mailto", "component/mailto", "/mailto/", "mailto:", "login", "register", "reset", "remind"); foreach ($exclude_names as $name) { $name != "" ? $forbidden_strings[] = $name : null; } $stack = array(); $s = microtime(true); if ($whitelist == "yes") { AntiFloodControl($website); } $file = genSitemap($priority, getlinks($website, $forbidden_types, $level, $forbidden_strings, $method, $maxcon, $timeout), $freq, $website); writeXML($file, $sitemap_file, $option, $sitemap_url); writeXML($xmlconfig, $page_root . "/administrator/components/com_jcrawler/config.xml", $option, $sitemap_url); $mainframe->enqueueMessage("total time: " . round(microtime(true) - $s, 4) . " seconds"); if ($modifyrobots == 1) { modifyrobots($sitemap_url, $page_root); } HTML_jcrawler::showNotifyForm($option, $sitemap_url); }
public function check_fee() { $sms = new transport(); $params = array("OperID" => $this->sms['user_name'], "OperPass" => $this->sms['password']); $url = "http://221.179.180.158:9000/QxtSms/surplus"; $result = $sms->request($url, $params); $result = toArray($result['body'], "resRoot"); $str = "企信通短信平台,剩余:" . $result['rcode'][0] . "条"; return $str; }
public function index(array $params) { // the page of planets we are looking at $page = array_val($params, 'page', 1); // get a list of the planets (for this page) list($pagination, $planet_models) = get_paginated_models('planet', $page); $pagination['base_url'] = '/planet/'; $planet_data = toArray($planet_models); $tpl_vars = array('pagination' => $pagination, 'planets' => $planet_data); v('page/planet/planet_list', $tpl_vars); }
function toArray($xml) { $array = json_decode(json_encode($xml), TRUE); foreach (array_slice($array, 0) as $key => $value) { if (empty($value)) { $array[$key] = NULL; } elseif (is_array($value)) { $array[$key] = toArray($value); } } return $array; }
function objectToArray($object) { if (is_array($object)) { foreach ($object as $k => $v) { if (is_object($v)) { $object[$k] = toArray($v); } } } else { $object = toArray($object); } return $object; }
public function inhabitant_dialog(array $params) { $tpl_vars = array(); $planets = get_models('planet'); $tpl_vars['planets'] = toArray($planets); // are we editing an existing inhabitant if ($inhabitantID = array_val($params, 'inhabitantID')) { $inhabitant = m('inhabitant', $inhabitantID); $tpl_vars['inhabitantID'] = $inhabitant->getID(); $tpl_vars['name'] = $inhabitant->get_name(); $tpl_vars['inhabitant_planet'] = $inhabitant->get_planet()->toArray(); } v('partial/inhabitant/inhabitant_form', $tpl_vars); }
function toArray($obj) { if (is_object($obj)) { $obj = (array) $obj; } if (is_array($obj)) { $new = array(); foreach ($obj as $key => $val) { $new[$key] = toArray($val); } } else { $new = $obj; } return $new; }
function insertQuestion($varname, $vardesc, $vartype, $club_id, $database, $whereString) { //basic error checking include_once includePath() . "/apply_gen.php"; $typeArray = toArray($vartype); if (!isset($typeArray['type'])) { return "type map does not contain required 'type' attribute"; } if ($typeArray['type'] == "select" && $vardesc == '') { return "description (required for select) left blank"; } //add spaces to type array $vartype = str_replace(";", "; ", $vartype); $vartype = str_replace("|", "| ", $vartype); if ($database != "supplements" && $database != "baseapp" && $database != "custom") { return "internal error: invalid database {$database}"; } $varname = escape($varname); $vardesc = escape($vardesc); $vartype = escape($vartype); $club_id = escape($club_id); //increment from highest orderId $result = mysql_query("SELECT MAX(orderId) FROM {$database} WHERE {$whereString}"); if ($row = mysql_fetch_array($result)) { if (is_null($row[0])) { $orderId = 1; } else { $orderId = escape($row[0] + 1); } if ($database != "supplements") { mysql_query("INSERT INTO {$database} (orderId, varname, vardesc, vartype, category) VALUES ('{$orderId}', '{$varname}', '{$vardesc}', '{$vartype}', '" . $_SESSION['category'] . "')"); } else { mysql_query("INSERT INTO supplements (orderId, varname, vardesc, vartype, club_id) VALUES ('{$orderId}', '{$varname}', '{$vardesc}', '{$vartype}', '{$club_id}')"); } return true; } else { return "internal error"; //this shouldn't occur, since MAX would return null if no rows are found } }
function latexAppendQuestion($name, $desc, $type, $answer) { $typeArray = getTypeArray($type); $question_string = ""; if ($typeArray['type'] == "text") { if ($name != "") { $question_string .= '\\textbf{' . latexSpecialChars($name) . '}'; //add main in bold } if ($desc != "") { if ($name != "") { $question_string .= '\\newline'; } $question_string .= '\\emph{' . latexSpecialChars($desc) . '}'; //add description in italics } $question_string .= '\\newline\\newline'; return $question_string; } else { if ($typeArray['type'] == "latex") { $question_string .= $desc; return $question_string; } else { if ($typeArray['type'] == "code") { $question_string .= '\\text{' . get_html_to_latex(page_convert($desc)) . '}'; return $question_string; } else { if ($typeArray['type'] == "repeat") { $num = $typeArray['num']; $subtype_array = explode("|", $typeArray['subtype']); $desc_array = explode("|", $desc); $name_array = explode("|", $name); if ($answer != '') { $answer_array = toArray($answer, "|", "="); } else { $answer_array = array_fill(0, count($name_array) * $num, ''); } //find minimum length, which will be the number to repeat for $min_length = min(count($subtype_array), count($desc_array), count($name_array)); for ($i = 0; $i < $min_length * $num; $i++) { $index = $i % $min_length; $n = intval($i / $min_length); $thisName = getRepeatThisValue($name_array, $index, $n); $thisDesc = getRepeatThisValue($desc_array, $index, $n); $thisType = str_replace(",", ";", getRepeatThisValue($subtype_array, $index, $n)); $question_string .= latexAppendQuestion($thisName, $thisDesc, $thisType, $answer_array[$i]); } } else { if ($name != "") { $question_string .= '\\textbf{' . latexSpecialChars($name) . '}'; //add question in bold } //add description (in bold) for essays and short answer if (($typeArray['type'] == "essay" || $typeArray['type'] == "short") && $desc != "") { if ($name != "") { $question_string .= '\\newline'; } $question_string .= '\\emph{' . latexSpecialChars($desc) . '}'; //add description in italics } //add a separator depending on main type of the question if ($typeArray['type'] == "essay") { $question_string .= "\n\n"; } if ($typeArray['type'] == "select" && $typeArray['method'] != "dropdown") { //in this case, we add tick marks and check the correct ones $choices = explode(";", $desc); //get answer as array in case we're using multiple selection $config = $GLOBALS['config']; $answerArray = explode($config['form_array_delimiter'], $answer); //this is used to indent the answer choices $question_string .= "\n\\begin{quote}\n"; //output each choice with check box before it on a separate line in the quote for ($i = 0; $i < count($choices); $i++) { $choice = $choices[$i]; if ($i != 0) { $question_string .= "\\\\\n "; } if (in_array($choice, $answerArray)) { $question_string .= '\\xbox'; } else { $question_string .= '\\tickbox'; } $question_string .= " \\hspace{4pt} " . latexSpecialChars($choice); } $question_string .= "\\end{quote}"; } else { //append the response if ($typeArray['type'] == "essay") { if ($answer != "") { $question_string .= '\\begin{quote} ' . latexSpecialChars($answer) . '\\end{quote}'; } else { $question_string .= '\\vspace{5ex}'; } } else { if ($answer != "") { $question_string .= '\\begin{quote} ' . latexSpecialChars($answer) . ' \\end{quote}'; } else { $question_string .= '\\vspace{1ex}'; } } } $question_string .= "\n\n"; } } } } return $question_string; }
public function do_send_goods($payment_notice_id, $delivery_notice_sn) { require_once APP_ROOT_PATH . "system/utils/XmlBase.php"; $payment_notice = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "payment_notice where id = " . $payment_notice_id); $order_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal_order where id = " . $payment_notice['order_id']); $payment = $GLOBALS['db']->getRow("select id,config from " . DB_PREFIX . "payment where class_name='AlipayBank'"); $payment['config'] = unserialize($payment['config']); $gateway = "https://www.alipay.com/cooperate/gateway.do"; $parameter = array('service' => 'send_goods_confirm_by_platform', 'partner' => $payment['config']['alipay_partner'], '_input_charset' => 'utf-8', 'invoice_no' => $delivery_notice_sn, 'transport_type' => 'EXPRESS', 'logistics_name' => 'NONE', 'trade_no' => $payment_notice['outer_notice_sn']); ksort($parameter); reset($parameter); $sign = ''; $param = ''; foreach ($parameter as $key => $val) { $sign .= "{$key}={$val}&"; $param .= "{$key}=" . urlencode($val) . "&"; } $param = substr($param, 0, -1); $sign = substr($sign, 0, -1) . $payment['config']['alipay_key']; $sign_md5 = md5($sign); $gateway = $gateway . "?" . $param . "&sign=" . $sign_md5 . "&sign_type=MD5"; $result = file_get_contents($gateway); $result = toArray($result, "alipay"); if ($result['is_success'][0] == 'T') { return "支付宝发货成功"; } else { if ($result['error'] == 'ILLEGAL_ARGUMENT') { return $result['error'] . ' 参数不正确'; } elseif ($result['error'] == 'TRADE_NOT_EXIST') { return $result['error'] . ' 交易单号有误'; } elseif ($result['error'] == 'GENERIC_FAILURE') { return $result['error'] . ' 执行命令错误'; } else { return $result['error']; } } }
* corresponding variable is defined; e.g., $account->field_example has a * variable $field_example defined. When needing to access a field's raw * values, developers/themers are strongly encouraged to use these * variables. Otherwise they will have to explicitly specify the desired * field language, e.g. $account->field_example['en'], thus overriding any * language negotiation rule that was previously applied. * * @see user-profile-category.tpl.php * Where the html is handled for the group. * @see user-profile-item.tpl.php * Where the html is handled for each item in the group. * @see template_preprocess_user_profile() * * @ingroup themeable */ $perfil = toArray($user_profile); $fotoPerfil = $perfil['field_imagen_perfil']['#object']['field_imagen_perfil']['und'][0]['uri']; ?> <div class="row"> <div class="col-lg-4 col-md-4 col-sm-8 col-xs-12"> <figure class="img-perfil img-circle center-block"> <img src="<?php print file_create_url($fotoPerfil); ?>
* - $page['highlighted']: Items for the highlighted content region. * - $page['banner']: Items for the banner content region. * - $page['content']: The main content of the current page. * - $page['sidebar_first']: Items for the first sidebar. * - $page['sidebar_second']: Items for the second sidebar. * - $page['header']: Items for the header region. * - $page['footer']: Items for the footer region. * * @see template_preprocess() * @see template_preprocess_page() * @see template_process() * @see html.tpl.php * * @ingroup themeable */ $linksPerfil = toArray($tabs); echo '<pre>'; print_r(array_keys($tabs['#primary'][1])); //*print_r($tabs); echo '</pre>'; ?> <header> <div class="container-fluid login"> <!--Wrapper login--> <div class="row"> <div class="col-lg-4 col-md-4 col-sm-8 col-xs-12 col-lg-offset-4 col-md-offset-4 col-sm-offset-4"> <?php if ($logged_in) { ?>
function bfa_get_options() { global $options, $bfa_ata; if (get_option('bfa_ata4') === FALSE) { // 268 Old ATA 3.X options: $bfa_ata3 = array("start_here", "import_settings", "use_bfa_seo", "homepage_meta_description", "homepage_meta_keywords", "add_blogtitle", "title_separator_code", "archive_noindex", "cat_noindex", "tag_noindex", "h1_on_single_pages", "nofollow", "body_style", "link_color", "link_hover_color", "link_default_decoration", "link_hover_decoration", "link_weight", "layout_width", "layout_min_width", "layout_max_width", "layout_style", "layout_style_leftright_padding", "favicon_file", "configure_header", "logoarea_style", "logo", "logo_style", "blog_title_show", "blog_title_style", "blog_title_weight", "blog_title_color", "blog_title_color_hover", "blog_tagline_show", "blog_tagline_style", "show_search_box", "searchbox_style", "searchbox_text", "horbar1", "horbar2", "header_image_info", "header_image_javascript", "header_image_javascript_preload", "header_image_clickable", "headerimage_height", "headerimage_alignment", "header_opacity_left", "header_opacity_left_width", "header_opacity_left_color", "header_opacity_right", "header_opacity_right_width", "header_opacity_right_color", "overlay_blog_title", "overlay_blog_tagline", "overlay_box_style", "rss_settings_info", "rss_box_width", "show_posts_icon", "post_feed_link", "post_feed_link_title", "show_comments_icon", "comment_feed_link", "comment_feed_link_title", "show_email_icon", "email_subscribe_link", "email_subscribe_link_title", "feedburner_email_id", "feedburner_old_new", "animate_page_menu_bar", "home_page_menu_bar", "exclude_page_menu_bar", "levels_page_menu_bar", "sorting_page_menu_bar", "titles_page_menu_bar", "page_menu_1st_level_not_linked", "anchor_border_page_menu_bar", "page_menu_bar_background_color", "page_menu_bar_background_color_hover", "page_menu_bar_background_color_parent", "page_menu_font", "page_menu_bar_link_color", "page_menu_bar_link_color_hover", "page_menu_transform", "page_menu_arrows", "page_menu_submenu_width", "animate_cat_menu_bar", "home_cat_menu_bar", "exclude_cat_menu_bar", "levels_cat_menu_bar", "sorting_cat_menu_bar", "order_cat_menu_bar", "titles_cat_menu_bar", "add_descr_cat_menu_links", "default_cat_descr_text", "anchor_border_cat_menu_bar", "cat_menu_bar_background_color", "cat_menu_bar_background_color_hover", "cat_menu_bar_background_color_parent", "cat_menu_font", "cat_menu_bar_link_color", "cat_menu_bar_link_color_hover", "cat_menu_transform", "cat_menu_arrows", "cat_menu_submenu_width", "center_column_style", "content_above_loop", "content_inside_loop", "content_below_loop", "content_not_found", "next_prev_orientation", "home_multi_next_prev", "home_single_next_prev", "multi_next_prev_newer", "multi_next_prev_older", "single_next_prev_newer", "single_next_prev_older", "comments_next_prev_newer", "comments_next_prev_older", "location_comments_next_prev", "next_prev_style_comments_above", "next_prev_style_comments_below", "next_prev_comments_pagination", "location_multi_next_prev", "location_single_next_prev", "next_prev_style_top", "next_prev_style_middle", "next_prev_style_bottom", "leftcol_on", "left_col_pages_exclude", "left_col_cats_exclude", "leftcol2_on", "left_col2_pages_exclude", "left_col2_cats_exclude", "rightcol_on", "right_col_pages_exclude", "right_col_cats_exclude", "rightcol2_on", "ight_col2_pages_exclude", "right_col2_pages_exclude", "right_col2_cats_exclude", "left_sidebar_width", "left_sidebar2_width", "right_sidebar_width", "right_sidebar2_width", "left_sidebar_style", "left_sidebar2_style", "right_sidebar_style", "right_sidebar2_style", "widget_container", "widget_title_box", "widget_title", "widget_content", "widget_lists", "widget_lists2", "widget_lists3", "category_widget_display_type", "select_font_size", "widget_areas_reset", "widget_areas_info", "post_kicker_home", "post_kicker_multi", "post_kicker_single", "post_kicker_page", "post_byline_home", "post_byline_multi", "post_byline_single", "post_byline_page", "post_footer_home", "post_footer_multi", "post_footer_single", "post_footer_page", "post_container_style", "post_container_sticky_style", "post_kicker_style", "post_kicker_style_links", "post_kicker_style_links_hover", "post_headline_style", "post_headline_style_text", "post_headline_style_links", "post_headline_style_links_hover", "post_byline_style", "post_byline_style_links", "post_byline_style_links_hover", "post_bodycopy_style", "post_footer_style", "post_footer_style_links", "post_footer_style_links_hover", "excerpt_length", "dont_strip_excerpts", "custom_read_more", "excerpts_home", "full_posts_homepage", "excerpts_category", "excerpts_archive", "excerpts_tag", "excerpts_search", "excerpts_author", "post_thumbnail_width", "post_thumbnail_height", "post_thumbnail_crop", "post_thumbnail_css", "more_tag", "author_highlight", "author_highlight_color", "author_highlight_border_color", "comment_background_color", "comment_alt_background_color", "comment_border", "comment_author_size", "comment_reply_link_text", "comment_edit_link_text", "comment_moderation_text", "comments_are_closed_text", "comments_on_pages", "separate_trackback", "avatar_size", "avatar_style", "show_xhtml_tags", "comment_form_style", "submit_button_style", "comment_display_order", "footer_style", "footer_style_links", "footer_style_links_hover", "footer_style_content", "sticky_layout_footer", "footer_show_queries", "table", "table_caption", "table_th", "table_td", "table_tfoot_td", "table_zebra_stripes", "table_zebra_td", "table_hover_rows", "table_hover_td", "form_input_field_style", "form_input_field_background", "highlight_forms", "highlight_forms_style", "button_style", "button_style_hover", "blockquote_style", "blockquote_style_2nd_level", "post_image_style", "post_image_caption_style", "image_caption_text", "html_inserts_header", "html_inserts_body_tag", "html_inserts_body_top", "html_inserts_body_bottom", "html_inserts_css", "archives_page_id", "archives_date_show", "archives_date_title", "archives_date_type", "archives_date_limit", "archives_date_count", "archives_category_show", "archives_category_title", "archives_category_count", "archives_category_depth", "archives_category_orderby", "archives_category_order", "archives_category_feed", "css_external", "javascript_external", "pngfix_selectors", "css_compress", "allow_debug"); // If no old settings exit, use the new 'default' style $old_setting_exists = 'no'; foreach ($bfa_ata3 as $old_option) { if (get_option('bfa_ata_' . $old_option) !== FALSE) { $old_setting_exists = 'yes'; } } // Separate option bfa_widget_areas if (get_option('bfa_widget_areas') !== FALSE) { $all_old_widget_areas = get_option('bfa_widget_areas'); foreach ($all_old_widget_areas as $old_widget_area) { if (isset($old_widget_area)) { $old_setting_exists = 'yes'; } } } // toArray: turn object into array for PHP < 5.1 - included JSON.php does not return array with ,TRUE if ($old_setting_exists == 'yes') { $bfa_ata_default = toArray(json_decode(file_get_contents(TEMPLATEPATH . '/styles/ata-classic.txt'), TRUE)); } else { $bfa_ata_default = toArray(json_decode(file_get_contents(TEMPLATEPATH . '/styles/ata-classic.txt'), TRUE)); } foreach ($options as $value) { if ($value['type'] != 'info') { if (get_option('bfa_ata_' . $value['id']) === FALSE) { $bfa_ata4[$value['id']] = $bfa_ata_default[$value['id']]; } else { $bfa_ata4[$value['id']] = get_option('bfa_ata_' . $value['id']); } } } /* foreach ($options as $value) { if ($value['type'] != 'info') { if ( $value['escape'] == "yes" ) { if( get_option( 'bfa_ata_' . $value['id'] ) === FALSE ) $bfa_ata[ $value['id'] ] = stripslashes(bfa_escape($_REQUEST[ $value['id'] ] )); else unset ($bfa_ata[ $value['id'] ]); } elseif ($value['stripslashes'] == "no") { if( get_option( 'bfa_ata_' . $value['id'] ) === FALSE ) $bfa_ata[ $value['id'] ] = $_REQUEST[ $value['id'] ] ; else unset ($bfa_ata[ $value['id'] ]); } else { if( get_option( 'bfa_ata_' . $value['id'] ) === FALSE ) $bfa_ata[ $value['id'] ] = stripslashes($_REQUEST[ $value['id'] ] ); else unset ($bfa_ata[ $value['id'] ]); } } } */ // Separate option bfa_widget_areas $bfa_ata4['bfa_widget_areas'] = get_option('bfa_widget_areas'); update_option('bfa_ata4', $bfa_ata4); } $bfa_ata = get_option('bfa_ata4'); if (is_page()) { global $wp_query; $current_page_id = $wp_query->get_queried_object_id(); } //figure out sidebars and "colspan=XX", based on theme options and type or ID of page that we are currently on: $cols = 1; $left_col = ''; $left_col2 = ''; $right_col = ''; $right_col2 = ''; if (is_page() and function_exists('is_front_page') ? !is_front_page() : '' and !is_home()) { if ($bfa_ata['left_col_pages_exclude'] != "") { $pages_exlude_left = explode(",", str_replace(" ", "", $bfa_ata['left_col_pages_exclude'])); if (isset($bfa_ata['leftcol_on']['page']) and !in_array($current_page_id, $pages_exlude_left)) { $cols++; $left_col = "on"; } } else { if (isset($bfa_ata['leftcol_on']['page'])) { $cols++; $left_col = "on"; } } if ($bfa_ata['left_col2_pages_exclude'] != "") { $pages_exlude_left2 = explode(",", str_replace(" ", "", $bfa_ata['left_col2_pages_exclude'])); if (isset($bfa_ata['leftcol2_on']['page']) and !in_array($current_page_id, $pages_exlude_left2)) { $cols++; $left_col2 = "on"; } } else { if (isset($bfa_ata['leftcol2_on']['page'])) { $cols++; $left_col2 = "on"; } } if ($bfa_ata['right_col_pages_exclude'] != "") { $pages_exlude_right = explode(",", str_replace(" ", "", $bfa_ata['right_col_pages_exclude'])); if (isset($bfa_ata['rightcol_on']['page']) and !in_array($current_page_id, $pages_exlude_right)) { $cols++; $right_col = "on"; } } else { if (isset($bfa_ata['rightcol_on']['page'])) { $cols++; $right_col = "on"; } } if ($bfa_ata['right_col2_pages_exclude'] != "") { $pages_exlude_right2 = explode(",", str_replace(" ", "", $bfa_ata['right_col2_pages_exclude'])); if (isset($bfa_ata['rightcol2_on']['page']) and !in_array($current_page_id, $pages_exlude_right2)) { $cols++; $right_col2 = "on"; } } else { if (isset($bfa_ata['rightcol2_on']['page'])) { $cols++; $right_col2 = "on"; } } } elseif (is_category()) { $current_cat_id = get_query_var('cat'); if ($bfa_ata['left_col_cats_exclude'] != "") { $cats_exlude_left = explode(",", str_replace(" ", "", $bfa_ata['left_col_cats_exclude'])); if (isset($bfa_ata['leftcol_on']['category']) and !in_array($current_cat_id, $cats_exlude_left)) { $cols++; $left_col = "on"; } } else { if (isset($bfa_ata['leftcol_on']['category'])) { $cols++; $left_col = "on"; } } if ($bfa_ata['left_col2_cats_exclude'] != "") { $cats_exlude_left2 = explode(",", str_replace(" ", "", $bfa_ata['left_col2_cats_exclude'])); if (isset($bfa_ata['leftcol2_on']['category']) and !in_array($current_cat_id, $cats_exlude_left2)) { $cols++; $left_col2 = "on"; } } else { if (isset($bfa_ata['leftcol2_on']['category'])) { $cols++; $left_col2 = "on"; } } if ($bfa_ata['right_col_cats_exclude'] != "") { $cats_exlude_right = explode(",", str_replace(" ", "", $bfa_ata['right_col_cats_exclude'])); if (isset($bfa_ata['rightcol_on']['category']) and !in_array($current_cat_id, $cats_exlude_right)) { $cols++; $right_col = "on"; } } else { if (isset($bfa_ata['rightcol_on']['category'])) { $cols++; $right_col = "on"; } } if ($bfa_ata['right_col2_cats_exclude'] != "") { $cats_exlude_right2 = explode(",", str_replace(" ", "", $bfa_ata['right_col2_cats_exclude'])); if (isset($bfa_ata['rightcol2_on']['category']) and !in_array($current_cat_id, $cats_exlude_right2)) { $cols++; $right_col2 = "on"; } } else { if (isset($bfa_ata['rightcol2_on']['category'])) { $cols++; $right_col2 = "on"; } } } else { if (is_home() && isset($bfa_ata['leftcol_on']['homepage']) or function_exists('is_front_page') ? is_front_page() and isset($bfa_ata['leftcol_on']['frontpage']) : '' or is_single() && isset($bfa_ata['leftcol_on']['single']) or is_date() and isset($bfa_ata['leftcol_on']['date']) or is_tag() && isset($bfa_ata['leftcol_on']['tag']) or is_archive() and !(is_tag() or is_author() or is_date() or is_category()) && isset($bfa_ata['leftcol_on']['taxonomy']) or is_search() and isset($bfa_ata['leftcol_on']['search']) or is_author() && isset($bfa_ata['leftcol_on']['author']) or is_404() and isset($bfa_ata['leftcol_on']['404']) or is_attachment() && isset($bfa_ata['leftcol_on']['attachment'])) { $cols++; $left_col = "on"; } if (is_home() && isset($bfa_ata['leftcol2_on']['homepage']) or function_exists('is_front_page') ? is_front_page() and isset($bfa_ata['leftcol2_on']['frontpage']) : '' or is_single() && isset($bfa_ata['leftcol2_on']['single']) or is_date() and isset($bfa_ata['leftcol2_on']['date']) or is_tag() && isset($bfa_ata['leftcol2_on']['tag']) or is_archive() and !(is_tag() or is_author() or is_date() or is_category()) && isset($bfa_ata['leftcol2_on']['taxonomy']) or is_search() and isset($bfa_ata['leftcol2_on']['search']) or is_author() && isset($bfa_ata['leftcol2_on']['author']) or is_404() and isset($bfa_ata['leftcol2_on']['404']) or is_attachment() && isset($bfa_ata['leftcol2_on']['attachment'])) { $cols++; $left_col2 = "on"; } if (is_home() && isset($bfa_ata['rightcol_on']['homepage']) or function_exists('is_front_page') ? is_front_page() and isset($bfa_ata['rightcol_on']['frontpage']) : '' or is_single() && isset($bfa_ata['rightcol_on']['single']) or is_date() and isset($bfa_ata['rightcol_on']['date']) or is_tag() && isset($bfa_ata['rightcol_on']['tag']) or is_archive() and !(is_tag() or is_author() or is_date() or is_category()) && isset($bfa_ata['rightcol_on']['taxonomy']) or is_search() and isset($bfa_ata['rightcol_on']['search']) or is_author() && isset($bfa_ata['rightcol_on']['author']) or is_404() and isset($bfa_ata['rightcol_on']['404']) or is_attachment() && isset($bfa_ata['rightcol_on']['attachment'])) { $cols++; $right_col = "on"; } if (is_home() && isset($bfa_ata['rightcol2_on']['homepage']) or function_exists('is_front_page') ? is_front_page() and isset($bfa_ata['rightcol2_on']['frontpage']) : '' or is_single() && isset($bfa_ata['rightcol2_on']['single']) or is_date() and isset($bfa_ata['rightcol2_on']['date']) or is_tag() && isset($bfa_ata['rightcol2_on']['tag']) or is_archive() and !(is_tag() or is_author() or is_date() or is_category()) && isset($bfa_ata['rightcol2_on']['taxonomy']) or is_search() and isset($bfa_ata['rightcol2_on']['search']) or is_author() && isset($bfa_ata['rightcol2_on']['author']) or is_404() and isset($bfa_ata['rightcol2_on']['404']) or is_attachment() && isset($bfa_ata['rightcol2_on']['attachment'])) { $cols++; $right_col2 = "on"; } } // $bfa_ata['h1_on_single_pages'] turn the blogtitle to h2 and the post/page title to h1 on single post pages and static "page" pages if ($bfa_ata['h1_on_single_pages'] == "Yes" and (is_single() or is_page())) { $bfa_ata['h_blogtitle'] = 2; $bfa_ata['h_posttitle'] = 1; } else { $bfa_ata['h_blogtitle'] = 1; $bfa_ata['h_posttitle'] = 2; } $result = array($bfa_ata, $cols, $left_col, $left_col2, $right_col, $right_col2, $bfa_ata['h_blogtitle'], $bfa_ata['h_posttitle']); return $result; }
<form method="post" action="getClassDescriptions.php"> Source Name: <input type="text" size="25" name="sName"/><br/> Password: <input type="password" size="25" name="password"/><br/> SiteID: <input type="text" size="5" name="siteID" value="-99"/><br/> <input type="submit" value="submit" name="submit"/> </form> <?php } else { $sourcename = $_POST["sName"]; $password = $_POST["password"]; $siteID = $_POST["siteID"]; // initialize default credentials $creds = new SourceCredentials($sourcename, $password, array($siteID)); $classService = new MBClassService(); $classService->SetDefaultCredentials($creds); $result = $classService->GetClassDescriptions(array(), array(), array(), null, null, 10, 0); $cdsHtml = '<table><tr><td>ID</td><td>Name</td></tr>'; $cds = toArray($result->GetClassDescriptionsResult->ClassDescriptions->ClassDescription); foreach ($cds as $cd) { $cdsHtml .= sprintf('<tr><td>%d</td><td>%s</td></tr>', $cd->ID, $cd->Name); } $cdsHtml .= '</table>'; echo $cdsHtml; } ?> </body> </html>
<i class="fa fa-circle-o"></i> <span>User Management</span> </a> </li> </ul> </li> <?php } // Select all entries from the menu table $result = $db->fetch_custom("select sys_menu.*,sys_menu_role.read_act,sys_menu_role.insert_act,sys_menu_role.update_act,sys_menu_role.delete_act,sys_menu_role.group_id from sys_menu\nleft join sys_menu_role on sys_menu.id=sys_menu_role.id_menu\nwhere sys_menu_role.group_id=? and sys_menu_role.read_act=? ORDER BY parent, urutan_menu", array('sys_menu_role.group_id' => $_SESSION['level'], 'sys_menu_role.read_act' => 'Y')); // Create a multidimensional array to list items and parents $menu = array('items' => array(), 'parents' => array()); // Builds the array lists with data from the menu table foreach ($result as $items) { $items = toArray($items); // Creates entry into items array with current menu item id ie. $menu['items'][$items['id']] = $items; // Creates entry into parents array. Parents array contains a list of all items with children $menu['parents'][$items['parent']][] = $items['id']; } echo $db->buildMenu($path_url, 0, $menu); ?> </ul> </section> <!-- /.sidebar --> </aside> <!-- Content Wrapper. Contains page content --> <div class="content-wrapper">
function clearEmptyKey($input) { if (!is_array($input)) { $input = toArray($input); } foreach ($input as $key => $val) { if (is_array($val)) { $val = clearEmptyKey($val); } if ($key == "_empty_") { $input[""] = $val; unset($input[$key]); } } return $input; }
/** * Set header. * * @param array $v value * * @return mixed */ public function setHeader($v) { if (empty($v)) { return; } return set($this->_header, toArray($v)); }
public function jsonSerialize() { return toArray('full'); }
public function findByOverleg(PDO $db) { $overlegid = $this->getOverlegId(); $query = 'SELECT `id`, `overleg_id`, `lokaal_algemeen`, `lokaal_doelstellingen` FROM `listel5`.`overleglok` WHERE `overleg_id`= :overleg_id'; $statement = $db->prepare($query); $statement->bindValue(':overleg_id', $overlegid); $statement->execute(); $resultInstances = array(); while ($result = $statement->fetch(PDO::FETCH_ASSOC)) { $resultInstances[] = toArray($result); } $statement->closeCursor(); return $resultInstances; }
} return $response->getBody()->write(json_encode($res)); }); /** * Biblio detile * * @path /biblio/id/token * * @param integer id * @param string token * * @return json */ $app->get('/{id:[0-9]+}/{token}', function ($request, $response, $args) { $datas = Biblio::find('all', array('conditions' => array('biblio_id = ?', $args['id']))); $datas = toArray($datas); return $response->getBody()->write(json_encode($datas)); }); /** * Biblio Create * * @path /biblio/create/token * * @param string token * * @return boolean */ $app->put('/create/{token}', function ($request, $response, $args) { /*coming soon*/ }); /**
$password = $_POST["password"]; $siteID = $_POST["siteID"]; // initialize default credentials $creds = new SourceCredentials($sourcename, $password, array($siteID)); $usercreds = new UserCredentials('*****@*****.**', 'test123', array()); // initialize the services you are going to use $finderService = new MBFinderService(true); $finderService->SetDefaultCredentials($creds); $finderService->SetDefaultUserCredentials($usercreds); $searchLat = 35.238; $searchLon = -120.621; $partnerID = 101; // get a list of upcoming classes $result = $finderService->GetClassesWithinRadius($searchLat, $searchLon, 20, new DateTime(), new DateTime(), null, null, null, null, null, 15, 0); $classHtml = '<table><tr><td>ID</td><td>Name</td><td>Start Time</td><td>Price</td><td>Bookable</td></tr>'; $classes = toArray($result->GetClassesWithinRadiusResult->FinderClasses->FinderClass); foreach ($classes as $class) { $classHtml .= sprintf('<tr><td>%d</td><td>%s</td><td>%s</td><td>%f</td><td>%b</td></tr>', $class->MBFClassID, $class->ClassName, $class->StartDateTime, $class->Price, $class->Bookable); if ($class->Bookable) { $selectedClass = $class; } } $classHtml .= '</table>'; // pick a classID to sign a client into ?> <h2>Class List</h2> <?php echo $classHtml; ?>
/** * 递归转换为数组 */ function toArray($obj) { $value = (array) $obj; foreach ($value as $k => $v) { if (is_object($v)) { $value[$k] = toArray($v); } } return $value; }
}); function toArray($val) { return is_array($val) ? array_diff($val, array(NULL)) : preg_split('#\\s+#', $val, -1, PREG_SPLIT_NO_EMPTY); } // start deploy $logger->log("Started at " . date('[Y/m/d H:i]')); $logger->log("Config file is {$configFile}"); foreach ($config as $section => $cfg) { $logger->log("\nDeploying {$section}"); $cfg = array_change_key_case($cfg, CASE_LOWER) + array('local' => dirname($configFile), 'ignore' => '', 'allowdelete' => TRUE, 'purge' => '', 'before' => '', 'after' => ''); if (empty($cfg['remote'])) { throw new Exception("Missing 'remote' in config."); } $deployment = new Deployment($cfg['remote'], $cfg['local'], $logger); $deployment->ignoreMasks = array_merge(array('*.bak', '.svn', '.git*'), toArray($cfg['ignore'])); $deployment->deploymentFile = empty($cfg['deploymentfile']) ? $deployment->deploymentFile : $cfg['deploymentfile']; $deployment->testMode = !empty($cfg['test']) || isset($options['t']) || isset($options['test']); $deployment->allowDelete = $cfg['allowdelete']; $deployment->toPurge = toArray($cfg['purge']); $deployment->runBefore = toArray($cfg['before']); $deployment->runAfter = toArray($cfg['after']); if ($deployment->testMode) { $logger->log('Test mode'); } if (!$deployment->allowDelete) { $logger->log('Deleting disabled'); } $deployment->deploy(); } $logger->log("\nFinished at " . date('[Y/m/d H:i]'));
/** * 返回$needle在$haystack中的序号(起始序号为0),失败返回-1 * 如果指定了$field,这$needle将与$haystack中的$field字段作比较 * @param array $haystack * @param string $needle * @param string $field * @return int * @static */ function indexOf(&$haystack, $needle, $field = '') { toArray($haystack); foreach ($haystack as $index => $value) { if ($field != '' && $value == $needle || $value[$field] === $needle) { $result = $index; break; } } return -1; }
} if (strcmp($so, $DN) == 0) { } if (strcmp($so, $BUY) == 0) { $soWeight--; } if (strcmp($so, $SELL) == 0) { $soWeight++; } } } } } } echo "TP:" . $tpWeight . "<br>5DMA " . $dma_5Weight . "<br>10DMA " . $dma_10Weight . "<br>20DMA " . $dma_20Weight . "<br>50DMA " . $dma_50Weight . "<br>100DMA " . $dma_100Weight . "<br>SO " . $soWeight . "<br>CMI " . $cmiWeight . "<br>RSI " . $rsiWeight; toArray(); function toArray() { global $tpWeight, $dma_5Weight, $dma_10Weight, $dma_20Weight, $dma_50Weight, $dma_100Weight, $soWeight, $cmiWeight, $rsiWeight; $indicators = array(0 => $tpWeight, 1 => $dma_5Weight, 2 => $dma_10Weight, 3 => $dma_20Weight, 4 => $dma_50Weight, 5 => $dma_100Weight, 6 => $cmiWeight, 7 => $rsiWeight, 8 => $soWeight * 2); $minValue = min($indicators); $minValue = abs($minValue) * 2; $length = count($indicators); $weights = array(); for ($i = 0; $i < $length; $i++) { $indicators[$i] = $indicators[$i] + $minValue; // echo " ".$indicators[$i] . " "; array_push($weights, $indicators[$i] / 40); } insertIntoWeightsTable($weights); //print_r($weights);