function append_configs($conf_arr, $system_arr) { //准备配置数据 $setings_str = ''; foreach ($conf_arr as $key => $item) { $setings_str .= "var {$key} = " . indent(json_encode($item)) . ";\n\n"; } $system_str = 'var system = ' . indent(json_encode($system_arr)) . ";\n\n"; //查找模板 $append_arr = []; foreach (glob(__DIR__ . '/modules/*_template.js') as $filename) { if (!preg_match('~/modules/(\\w+)_template\\.js$~', $filename, $matches)) { continue; } $base_name = $matches[1]; $append_arr[] = [$filename, __DIR__ . '/' . $base_name . '.js']; } //替换模板中的标签 foreach ($append_arr as $item) { $src_settings_js = $item[0]; $settings_js = $item[1]; $src_settings_content = file_get_contents($src_settings_js); $new_content = preg_replace('/\\/\\*CONFIGS_POSITION\\*\\//i', $setings_str, $src_settings_content); $new_content = preg_replace('/\\/\\*SYSTEM_CONFIGS\\*\\//i', $system_str, $new_content); file_put_contents($settings_js, $new_content); } }
/** * 生成select下拉框 * @param string $name 下拉框的name * @param array $list 下拉框的可选项 * @param int $seleced 默认项 * @param string $class css类 * @return string */ function genSelect($name, array $list, $selected = 0, $class = '') { $html = "<select name='{$name}' class='{$class}'>"; $i = 0; foreach ($list as $text => $value) { $html .= indent() . "<option value='{$value}' "; if ($i == $selected) { $html .= " selected='selected' "; } $html .= ">{$text}</option>"; $i++; } $html .= "</select>"; return $html; }
function convert_xml($file) { ($old = simplexml_load_file($file)) || die("Unable to Load MIDI XML File: {$file}\n"); // Create the file with default values $new = simplexml_load_string("<MixxxMIDIPreset schemaVersion=\"1\" mixxxVersion=\"1.7.0+\">\n <info>\n <name>{$file}</name>\n <author>Auto-converted by madjesta's PHP script</author>\n <description>Auto-conversion of the file {$file}</description>\n </info>\n <controller id=\"" . fileToControllerName($file) . "\" port=\"\">\n </controller>\n </MixxxMIDIPreset>\n "); // Add Controls to Controller Node $controls = $new->controller->addChild("controls"); // get the control children $oldControls = $old->children(); // Here we perfom the actual conversion and moving of the values to the // new file. foreach ($oldControls->children() as $oldControl) { $control = $controls->addChild("control"); foreach ($oldControl->children() as $k => $v) { if ($k == "options") { $options = $control->addChild("options"); foreach ($v as $ko => $vo) { $options->addChild($ko, $vo); } continue; } if (($k == "midino" || $k == "midichan") && !preg_match('/0x\\d*/', $v)) { $v = sprintf("0x%02x", (int) $v); } $control->addChild($k, $v); } } if (isset($old->lights)) { // Add outputs to the new XML file $outputs = $new->controller->addChild("outputs"); $lights = $old->lights->children(); foreach ($lights as $light) { $output = $outputs->addChild("output"); foreach ($light as $k => $v) { $output->addChild($k, $v); } } } return indent($new); }
function run_files($file) { if (is_link($file)) { return; } if (is_dir($file . '/.')) { $dh = opendir($file); $files = array(); while (false !== ($f = readdir($dh))) { if ($f[0] != '.') { $files[] = $file . '/' . $f; } } closedir($dh); foreach ($files as $f) { run_files($f); } } else { if (preg_match('/\\.php$/', $file)) { indent($file); } } }
$dbnaam = "koffientnl"; $fout = "fout: openen database is mislukt"; $db = mysql_connect($host, $username, $password) or die($fout); mysql_select_db($dbnaam, $db) or die($fout); //query voor het ophalen van de gegevens uit de mysql server $query = mysql_query('SELECT * FROM `plukroute`'); //opbouwen begin van de json $json = '{ "type":"ok",'; //Dit geeft aan of er eventueel een fout zit in de gegevens van de json, op dit moment niet dynamisch $json = $json . '"fotos": ['; //hierin worden de foto objecten genest $i = 0; while ($row = mysql_fetch_assoc($query)) { if ($i != 0) { $json = $json . ","; //na de eerste keer wordt er een komma geplaatst voor het object } else { $i = 1; //eerste keer de komma overslaan } $json = $json . '{'; $json = $json . '"name":"' . 'http://www.koffient.nl/plukroute/image/' . $row['name'] . '.jpeg",'; $json = $json . '"id":"' . $row['id'] . '",'; $json = $json . '"longitude":"' . $row['longitude'] . '",'; $json = $json . '"latitude":"' . $row['latitude'] . '",'; $json = $json . '"soort":"' . $row['soort'] . '"}'; } $json = $json . ']}'; //afsluiting van de json echo indent($json);
function stringify($response, $format) { if ($format == "xml") { @header('Content-type: application/xml'); return XMLSerializer::generateValidXmlFromArray($response); } else { @header('Content-type: application/json'); return indent(json_encode($response)); } }
<tr> <td align="right">Identifier:</td> <td><input type="text" name="identifier" value="<?php print $account->identifier; ?> " /></td> </tr> <tr> <td align="right" valign="top">Contact:</td> <td> <select name="contactid"> <?php $contact->rebuild_cache(); foreach ($contact->contacts as $contactid => $name) { print indent(10) . '<option value="' . $contactid . '"'; if ($contactid == $account->contactid) { print ' selected="selected"'; } print '>' . $name . '</option>' . "\n"; } ?> </select> </td> </tr> <tr> <td><a href="manage.php?what=account&type=overview&accountid=<?php print $account->accountid; ?> ">Cancel</a></td> <td align="right"><input type="submit" value=" Save » " /></td>
function export_property($ret) { if (!is_array($ret)) { return var_export($ret, true); } $code = ''; foreach ($ret as $key => $value) { $code .= var_export($key, true) . ' => ' . export_property($value) . ",\n"; } return "array(\n" . indent($code) . ")"; }
} else { $sortdirection = "desc"; } $sort = array($_GET['sort-by'] => array("order" => $sortdirection)); //order by clause $query->setSort($sort); } $query->setFrom($_GET['from'])->setLimit($_GET['size']); if (isset($_GET['debug'])) { echo '<pre>'; print_r($query); echo '</pre>'; } // Configure and execute the search // Create the search object and inject the client $resultSet = $searchThrough->search($query); $data = array(); foreach ($resultSet as $result) { $itemdata = $result->getData(); $itemdata['id'] = $result->getId(); $data[] = $itemdata; } $response = array(); $response['data'] = $data; $response['total'] = $resultSet->getTotalHits(); } break; } echo indent(json_encode($response)); } }
if (!isset($page_variables['layout'])) { $htmlwarrior->layout = 'default'; } else { $htmlwarrior->layout = $page_variables['layout']; } // Get full layout path $layout_path = $htmlwarrior->config['basepath'] . '/' . $htmlwarrior->runtime['site_dir'] . $htmlwarrior->config["path_templates_layouts"] . '/' . $htmlwarrior->layout . '.tpl'; // Get all variables indents so we can indent the content right // We're after the $yield variable indent now $variable_indents = get_indents_for_variables(file_get_contents($layout_path)); // set variables // should these be added to layout template object (which we don't have yet) foreach ($page_variables as $key => $var) { $smarty->assign($key, $var); } $yield = indent(remove_variables($page_content), $variable_indents['yield']); $yield = ltrim($yield); $smarty->assign('yield', $yield); unset($yield); // add access log; must be after frontpage so we don't log that if ($htmlwarrior->config['log']) { add_access_log(array('site_dir' => $htmlwarrior->runtime['site_dir'], 'url' => $_SERVER['REQUEST_URI'])); } //require_once('filelist.php'); ob_start('callback'); if ($page_variables['layout'] === false) { $layout_path = $htmlwarrior->config['code_path'] . $htmlwarrior->config['path_templates_layouts'] . '/' . 'empty.tpl'; } $smarty->display($layout_path); $htmlwarrior->config['devmode'] = false; $content = $smarty->fetch($layout_path);
function _PHP_FUNC_htmlblock($obj) { $name = _LISP_get_string($obj, 1, 1); $params = $obj[2]; $ret = "<{$name}"; $have_line_breaks = false; foreach ($params as $param) { $thename[] = $tmp1 = substr($param[0], 4); $namelen = max($namelen, strlen($tmp1)); $thevalue[] = $tmp = htmlspecialchars(substr(_LISP_evalobject($param[1]), 4)); if (strstr($tmp, chr(10))) { $have_line_breaks = true; } } if ($have_line_breaks) { $paramindent = strlen($ret); for ($item = 0; $item < sizeof($thename); $item++) { if ($item != 0) { $ret .= "\n" . str_repeat(' ', $paramindent); } $ret .= ' ' . str_pad($thename[$item], $namelen + 1) . "= \""; if (strstr($thevalue[$item], chr(10))) { $the_indent = last_line_length($ret); $valuelinestmp = split("\n", $thevalue[$item]); foreach ($valuelinestmp as $valueline) { if ($valueline != ' ') { $valuelines[] = $valueline; } } $ret .= $valuelines[0] . "\n"; // first line just goes on.. for ($i = 1; $i < sizeof($valuelines); $i++) { if ($valuelines[$i] != '') { $ret .= str_repeat(' ', $the_indent) . $valuelines[$i]; if ($i < sizeof($valuelines) - 1) { $ret .= "\n"; } } } $ret .= "\""; } else { $ret .= "{$thevalue[$item]}\""; } } $ret .= ">"; } else { for ($item = 0; $item < sizeof($thename); $item++) { $ret .= " {$thename[$item]}=\"{$thevalue[$item]}\""; } $ret .= ">"; } for ($i = 3; $i < sizeof($obj); $i++) { $block .= _LISP_princ(_LISP_evalobject($obj[$i])); if ($i < sizeof($obj) - 1) { $block .= "\n"; } } //$ret is now "<[tag] [params...]>\n" $outblock = indent($block); $ret .= "{$outblock}\n</{$name}>\n"; return "str:{$ret}"; }
function expxml($filter = array(), $mailback = false, $translate = false) { global $ff_compath, $ff_version, $mosConfig_fileperms; jimport('joomla.version'); $version = new JVersion(); $_version = $version->getShortVersion(); $tz = 'UTC'; if (version_compare($_version, '3.2', '>=')) { $tz = new DateTimeZone(JFactory::getApplication()->getCfg('offset')); } if ($this->dying) { return ''; } mt_srand(); $xmlname = $ff_compath . '/exports/ffexport-' . date('YmdHis') . '-' . mt_rand(0, mt_getrandmax()) . '.xml'; $xml = '<?xml version="1.0" encoding="utf-8" ?>' . nl() . '<FacileFormsExport type="records" version="' . $ff_version . '">' . nl() . indent(1) . '<exportdate>' . date('Y-m-d H:i:s') . '</exportdate>' . nl(); if ($this->record_id != '') { $xml .= indent(1) . '<record id="' . $this->record_id . '">' . nl(); } else { $xml .= indent(1) . '<record>' . nl(); } $title_translated = $this->getFormTitleTranslated(); $submitted = $this->submitted; if (version_compare($_version, '3.2', '>=')) { $date_ = JFactory::getDate($this->submitted, $tz); $submitted = $date_->format('Y-m-d H:i:s'); } $xml .= indent(2) . '<submitted>' . $submitted . '</submitted>' . nl() . indent(2) . '<form>' . $this->form . '</form>' . nl() . indent(2) . '<title>' . htmlspecialchars($title_translated != '' ? $title_translated : $this->formrow->title, ENT_QUOTES, 'UTF-8') . '</title>' . nl() . indent(2) . '<name>' . $this->formrow->name . '</name>' . nl() . indent(2) . '<ip>' . $this->ip . '</ip>' . nl() . indent(2) . '<browser>' . htmlspecialchars($this->browser, ENT_QUOTES, 'UTF-8') . '</browser>' . nl() . indent(2) . '<opsys>' . htmlspecialchars($this->opsys, ENT_QUOTES, 'UTF-8') . '</opsys>' . nl() . indent(2) . '<provider>' . $this->provider . '</provider>' . nl() . indent(2) . '<viewed>0</viewed>' . nl() . indent(2) . '<exported>0</exported>' . nl() . indent(2) . '<archived>0</archived>' . nl(); $processed = array(); $xmldata = $this->xmldata; if ($mailback) { $xmldata = $this->mb_xmldata; } if (count($xmldata)) { foreach ($xmldata as $data) { if ($translate) { $title_translated = ''; $this->getFieldTranslated('label', $data[_FF_DATA_NAME], $title_translated); } if (!in_array($data[_FF_DATA_NAME], $filter) && !in_array($data[_FF_DATA_NAME], $processed)) { $xml .= indent(2) . '<subrecord>' . nl() . indent(3) . '<element>' . $data[_FF_DATA_ID] . '</element>' . nl() . indent(3) . '<name>' . $data[_FF_DATA_NAME] . '</name>' . nl() . indent(3) . '<title>' . htmlspecialchars($title_translated != '' ? $title_translated : $data[_FF_DATA_TITLE], ENT_QUOTES, 'UTF-8') . '</title>' . nl() . indent(3) . '<type>' . $data[_FF_DATA_TYPE] . '</type>' . nl() . indent(3) . '<value>' . htmlspecialchars(is_array($data[_FF_DATA_VALUE]) ? implode('|', $data[_FF_DATA_VALUE]) : $data[_FF_DATA_VALUE], ENT_QUOTES, 'UTF-8') . '</value>' . nl() . indent(2) . '</subrecord>' . nl(); //$processed[] = $data[_FF_DATA_NAME]; } } } // foreach $xml .= indent(1) . '</record>' . nl() . '</FacileFormsExport>' . nl(); JFile::makeSafe($xmlname); if (!JFile::write($xmlname, $xml)) { $this->status = _FF_STATUS_ATTACHMENT_FAILED; } // if return $xmlname; }
/** recursive function to construct the role tree ui * @param $hrarray -- Hierarchial role tree array with only the roleid:: Type array * @param $roleout -- html string ouput of the constucted role tree ui:: Type varchar * @param $role_det -- Roledetails array got from calling getAllRoleDetails():: Type array * @returns $role_out -- html string ouput of the constucted role tree ui:: Type string * */ function indent($hrarray, $roleout, $role_det) { global $theme, $mod_strings, $app_strings; $theme_path = "themes/" . $theme . "/"; $image_path = $theme_path . "images/"; foreach ($hrarray as $roleid => $value) { //retreiving the vtiger_role details $role_det_arr = $role_det[$roleid]; $roleid_arr = $role_det_arr[2]; $rolename = $role_det_arr[0]; $roledepth = $role_det_arr[1]; $roleout .= '<ul class="uil" id="' . $roleid . '" style="display:block;list-style-type:none;">'; $roleout .= '<li ><table border="0" cellpadding="0" cellspacing="0" onMouseOver="fnVisible(\'layer_' . $roleid . '\')" onMouseOut="fnInVisible(\'layer_' . $roleid . '\')">'; $roleout .= '<tr><td nowrap>'; if (sizeof($value) > 0 && $roledepth != 0) { $roleout .= '<b style="font-weight:bold;margin:0;padding:0;cursor:pointer;">'; $roleout .= '<img src="' . vtiger_imageurl('minus.gif', $theme) . '" id="img_' . $roleid . '" border="0" alt="' . $app_strings['LBL_EXPAND_COLLAPSE'] . '" title="' . $app_strings['LBL_EXPAND_COLLAPSE'] . '" align="absmiddle" onClick="showhide(\'' . $roleid_arr . '\',\'img_' . $roleid . '\')" style="cursor:pointer;">'; } else { if ($roledepth != 0) { $roleout .= '<img src="' . vtiger_imageurl('vtigerDevDocs.gif', $theme) . '" id="img_' . $roleid . '" border="0" alt="' . $app_strings['LBL_EXPAND_COLLAPSE'] . '" title="' . $app_strings['LBL_EXPAND_COLLAPSE'] . '" align="absmiddle">'; } else { $roleout .= '<img src="' . vtiger_imageurl('menu_root.gif', $theme) . '" id="img_' . $roleid . '" border="0" alt="' . $app_strings['LBL_ROOT'] . '" title="' . $app_strings['LBL_ROOT'] . '" align="absmiddle">'; } } if ($roledepth == 0) { $roleout .= ' <b class="genHeaderGray">' . $rolename . '</b></td>'; $roleout .= '<td nowrap><div id="layer_' . $roleid . '" class="drag_Element"><a href="index.php?module=Settings&action=createrole&parenttab=Settings&parent=' . $roleid . '"><img src="' . vtiger_imageurl('Rolesadd.gif', $theme) . '" align="absmiddle" border="0" alt="' . $mod_strings['LBL_ADD_ROLE'] . '" title="' . $mod_strings['LBL_ADD_ROLE'] . '"></a></div></td></tr></table>'; } else { $roleout .= ' <a href="javascript:put_child_ID(\'user_' . $roleid . '\');" class="x" id="user_' . $roleid . '">' . $rolename . '</a></td>'; $roleout .= '<td nowrap><div id="layer_' . $roleid . '" class="drag_Element"> <a href="index.php?module=Settings&action=createrole&parenttab=Settings&parent=' . $roleid . '"><img src="' . vtiger_imageurl('Rolesadd.gif', $theme) . '" align="absmiddle" border="0" alt="' . $mod_strings['LBL_ADD_ROLE'] . '" title="' . $mod_strings['LBL_ADD_ROLE'] . '"></a> <a href="index.php?module=Settings&action=createrole&roleid=' . $roleid . '&parenttab=Settings&mode=edit"><img src="' . vtiger_imageurl('RolesEdit.gif', $theme) . '" align="absmiddle" border="0" alt="' . $mod_strings['LBL_EDIT_ROLE'] . '" title="' . $mod_strings['LBL_EDIT_ROLE'] . '"></a>'; if ($roleid != 'H1' && $roleid != 'H2') { $roleout .= '<a href="index.php?module=Settings&action=RoleDeleteStep1&roleid=' . $roleid . '&parenttab=Settings"><img src="' . vtiger_imageurl('RolesDelete.gif', $theme) . '" align="absmiddle" border="0" alt="' . $mod_strings['LBL_DELETE_ROLE'] . '" title="' . $mod_strings['LBL_DELETE_ROLE'] . '"></a>'; } $roleout .= '<a href="javascript:;" class="small" onClick="get_parent_ID(this,\'user_' . $roleid . '\')"><img src="' . vtiger_imageurl('RolesMove.gif', $theme) . '" align="absmiddle" border="0" alt="' . $mod_strings['LBL_MOVE_ROLE'] . '" title="' . $mod_strings['LBL_MOVE_ROLE'] . '"></a> </div></td></tr></table>'; // $roleout .= ' <a href="index.php?module=Users&action=createrole&parenttab=Settings&parent='.$roleid.'">Add</a> | <a href="index.php?module=Users&action=createrole&roleid='.$roleid.'&parenttab=Settings&mode=edit">Edit</a> | <a href="index.php?module=Users&action=RoleDeleteStep1&roleid='.$roleid.'&parenttab=Settings">Delete</a> | <a href="index.php?module=Users&action=RoleDetailView&parenttab=Settings&roleid='.$roleid.'">View</a>'; } $roleout .= '</li>'; if (sizeof($value) > 0) { $roleout = indent($value, $roleout, $role_det); } $roleout .= '</ul>'; } return $roleout; }
/** * Create a new response of JSON'd Eloquent models. * * <code> * // Create a new response instance with Eloquent models * return Response::eloquent($data, 200, array('header' => 'value')); * </code> * * @param Eloquenet|array $data * @param int $status * @param array $headers * @return Response */ public static function eloquent($data, $status = 200, $headers = array()) { $headers['Content-Type'] = 'application/json'; return new static(indent(eloquent_to_json($data)), $status, $headers); }
/** * Footer content * * @return string * @author Jared Lang **/ function footer_($tabs = 2) { ob_start(); wp_footer(); $html = ob_get_clean(); return indent($html, $tabs); }
/** * Clean up source code * * @param string $source * @return string */ function phptidy($source) { // Replace non-Unix line breaks // http://pear.php.net/manual/en/standards.file.php // Windows line breaks -> Unix line breaks $source = str_replace("\r\n", "\n", $source); // Mac line breaks -> Unix line breaks $source = str_replace("\r", "\n", $source); $tokens = get_tokens($source); if ($GLOBALS['command'] == "tokens") { print_tokens($tokens); exit; } // Simple formatting if ($GLOBALS['fix_token_case']) { fix_token_case($tokens); } if ($GLOBALS['fix_builtin_functions_case']) { fix_builtin_functions_case($tokens); } if ($GLOBALS['replace_inline_tabs']) { replace_inline_tabs($tokens); } if ($GLOBALS['replace_phptags']) { replace_phptags($tokens); } if ($GLOBALS['replace_shell_comments']) { replace_shell_comments($tokens); } if ($GLOBALS['fix_statement_brackets']) { fix_statement_brackets($tokens); } if ($GLOBALS['fix_separation_whitespace']) { fix_separation_whitespace($tokens); } if ($GLOBALS['fix_comma_space']) { fix_comma_space($tokens); } if ($GLOBALS['fix_round_bracket_space']) { fix_round_bracket_space($tokens); } // PhpDocumentor if ($GLOBALS['add_doctags']) { list($usestags, $paramtags, $returntags) = collect_doctags($tokens); //print_r($usestags); //print_r($paramtags); //print_r($returntags); } if ($GLOBALS['add_file_docblock']) { add_file_docblock($tokens); } if ($GLOBALS['add_function_docblocks']) { add_function_docblocks($tokens); } if ($GLOBALS['add_doctags']) { add_doctags($tokens, $usestags, $paramtags, $returntags, $GLOBALS['seetags']); } if ($GLOBALS['fix_docblock_format']) { fix_docblock_format($tokens); } if ($GLOBALS['fix_docblock_space']) { fix_docblock_space($tokens); } if ($GLOBALS['add_blank_lines']) { add_blank_lines($tokens); } // Indenting if ($GLOBALS['indent']) { indent($tokens); strip_closetag_indenting($tokens); } $source = combine_tokens($tokens); // Strip trailing whitespace $source = preg_replace("/[ \t]+\n/", "\n", $source); if (substr($source, -1) != "\n") { // Add one line break at the end of the file // http://pear.php.net/manual/en/standards.file.php $source .= "\n"; } else { // Strip empty lines at the end of the file while (substr($source, -2) == "\n\n") { $source = substr($source, 0, -1); } } return $source; }
function send_reminder($id, $event_date) { global $names, $emails, $site_extras, $debug, $only_testing, $server_url, $languages, $tzoffset, $application_name; global $EXTRA_TEXT, $EXTRA_MULTILINETEXT, $EXTRA_URL, $EXTRA_DATE, $EXTRA_EMAIL, $EXTRA_USER, $EXTRA_REMINDER, $LANGUAGE, $LOG_REMINDER; global $allow_external_users, $external_reminders; $pri[1] = translate("Low"); $pri[2] = translate("Medium"); $pri[3] = translate("High"); // get participants first... $sql = "SELECT cal_login FROM webcal_entry_user " . "WHERE cal_id = {$id} AND cal_status IN ('A','W') " . "ORDER BY cal_login"; $res = dbi_query($sql); $participants = array(); $num_participants = 0; if ($res) { while ($row = dbi_fetch_row($res)) { $participants[$num_participants++] = $row[0]; } } // get external participants $ext_participants = array(); $num_ext_participants = 0; if (!empty($allow_external_users) && $allow_external_users == "Y" && !empty($external_reminders) && $external_reminders == "Y") { $sql = "SELECT cal_fullname, cal_email FROM webcal_entry_ext_user " . "WHERE cal_id = {$id} AND cal_email IS NOT NULL " . "ORDER BY cal_fullname"; $res = dbi_query($sql); if ($res) { while ($row = dbi_fetch_row($res)) { $ext_participants[$num_ext_participants] = $row[0]; $ext_participants_email[$num_ext_participants++] = $row[1]; } } } if (!$num_participants && !$num_ext_participants) { if ($debug) { echo "No participants found for event id: {$id} <br />\n"; } return; } // get event details $res = dbi_query("SELECT cal_create_by, cal_date, cal_time, cal_mod_date, " . "cal_mod_time, cal_duration, cal_priority, cal_type, cal_access, " . "cal_name, cal_description FROM webcal_entry WHERE cal_id = {$id}"); if (!$res) { echo "Db error: could not find event id {$id}.\n"; return; } if (!($row = dbi_fetch_row($res))) { echo "Error: could not find event id {$id} in database.\n"; return; } // send mail. we send one user at a time so that we can switch // languages between users if needed. $mailusers = array(); $recipients = array(); if (isset($single_user) && $single_user == "Y") { $mailusers[] = $emails[$single_user_login]; $recipients[] = $single_user_login; } else { for ($i = 0; $i < count($participants); $i++) { if (strlen($emails[$participants[$i]])) { $mailusers[] = $emails[$participants[$i]]; $recipients[] = $participants[$i]; } else { if ($debug) { echo "No email for user {$participants[$i]} <br />\n"; } } } for ($i = 0; $i < count($ext_participants); $i++) { $mailusers[] = $ext_participants_email[$i]; $recipients[] = $ext_participants[$i]; } } if ($debug) { echo "Found " . count($mailusers) . " with email addresses <br />\n"; } for ($j = 0; $j < count($mailusers); $j++) { $recip = $mailusers[$j]; $user = $participants[$j]; if (!empty($languages[$user])) { $userlang = $languages[$user]; } else { $userlang = $LANGUAGE; } // system default if ($userlang == "none") { $userlang = "English-US"; } // gotta pick something if ($debug) { echo "Setting language to \"{$userlang}\" <br />\n"; } reset_language($userlang); // reset timezone setting for current user if (empty($tzoffset[$user])) { $GLOBALS["TZ_OFFSET"] = 0; } else { $GLOBALS["TZ_OFFSET"] = $tzoffset[$user]; } $body = translate("This is a reminder for the event detailed below.") . "\n\n"; $create_by = $row[0]; $name = $row[9]; $description = $row[10]; // add trailing '/' if not found in server_url if (!empty($server_url)) { if (substr($server_url, -1, 1) == "/") { $body .= $server_url . "view_entry.php?id=" . $id . "\n\n"; } else { $body .= $server_url . "/view_entry.php?id=" . $id . "\n\n"; } } $body .= strtoupper($name) . "\n\n"; $body .= translate("Description") . ":\n"; $body .= indent($description) . "\n"; $body .= translate("Date") . ": " . date_to_str($event_date) . "\n"; if ($row[2] >= 0) { $body .= translate("Time") . ": " . display_time($row[2]) . "\n"; } if ($row[5] > 0) { $body .= translate("Duration") . ": " . $row[5] . " " . translate("minutes") . "\n"; } if (!empty($disable_priority_field) && !$disable_priority_field) { $body .= translate("Priority") . ": " . $pri[$row[6]] . "\n"; } if (!empty($disable_access_field) && !$disable_access_field) { $body .= translate("Access") . ": " . ($row[8] == "P" ? translate("Public") : translate("Confidential")) . "\n"; } if (!empty($single_user_login) && $single_user_login == false) { $body .= translate("Created by") . ": " . $row[0] . "\n"; } $body .= translate("Updated") . ": " . date_to_str($row[3]) . " " . display_time($row[4]) . "\n"; // site extra fields $extras = get_site_extra_fields($id); for ($i = 0; $i < count($site_extras); $i++) { $extra_name = $site_extras[$i][0]; $extra_descr = $site_extras[$i][1]; $extra_type = $site_extras[$i][2]; if ($extras[$extra_name]['cal_name'] != "") { $body .= translate($extra_descr) . ": "; if ($extra_type == $EXTRA_DATE) { $body .= date_to_str($extras[$extra_name]['cal_date']) . "\n"; } else { if ($extra_type == $EXTRA_MULTILINETEXT) { $body .= "\n" . indent($extras[$extra_name]['cal_data']) . "\n"; } else { if ($extra_type == $EXTRA_REMINDER) { $body .= ($extras[$extra_name]['cal_remind'] > 0 ? translate("Yes") : translate("No")) . "\n"; } else { // default method for $EXTRA_URL, $EXTRA_TEXT, etc... $body .= $extras[$extra_name]['cal_data'] . "\n"; } } } } } if (!empty($single_user) && $single_user != "Y" && !empty($disable_participants_field) && !$disable_participants_field) { $body .= translate("Participants") . ":\n"; for ($i = 0; $i < count($participants); $i++) { $body .= " " . $names[$participants[$i]] . "\n"; } for ($i = 0; $i < count($ext_participants); $i++) { $body .= " " . $ext_participants[$i] . " (" . translate("External User") . ")\n"; } } $subject = translate("Reminder") . ": " . $name; if (strlen($GLOBALS["email_fallback_from"])) { $extra_hdrs = "From: " . $GLOBALS["email_fallback_from"] . "\r\n" . "X-Mailer: " . translate($application_name); } else { $extra_hdrs = "X-Mailer: " . translate($application_name); } if ($debug) { echo "Sending mail to {$recip} (in {$userlang})\n"; } if ($only_testing) { if ($debug) { echo "<hr /><pre>To: {$recip}\nSubject: {$subject}\n{$extra_hdrs}\n\n{$body}\n\n</pre>\n"; } } else { mail($recip, $subject, $body, $extra_hdrs); activity_log($id, "system", $user, $LOG_REMINDER, ""); } } }
<div id="page"> <div id="header"> <a href="/"><img src="/images/plumline.png" width="300" height="109" alt="Plumline" /></a> <div id="links"> <ul> <li class="first"><a href="/">Home</a></li> <li><a href="/practice/mindfulness">Mindfulness practice</a></li> <li><a href="/practice/links">Useful links</a></li> <li><a href="/contact/form">Contact form</a></li> </ul> </div> </div> <div id="content"> <?php echo indent(8, "<h3>{$title}</h3>"); echo $flash->notice ? indent(8, "<div id=\"flash\">{$flash->notice}</div>") : ''; echo indent(8, $content); ?> </div> <div id="footer"> Copyright © <?php echo strftime('%Y'); ?> Plumline Sangha </div> </div>
</ol> </div> <br/><br/><br/><br/><?php } else { if ($_GET['m'] == 2) { ?> <div class='error'> <ol> <?php $emailmessage .= "<b>Request Details</b>=" . json_encode($_REQUEST); if (isset($this->context)) { $emailmessage .= @json_encode($this->context); } $emailmessage .= "<b><br><br>Error Number</b>=" . $this->error_no; $emailmessage .= "<b><br><br>Message </b>= " . $this->message; $emailmessage .= "<b><br><br>Location </b>= " . $this->error_file; $emailmessage .= "<b><br><br>Line No. </b>= " . $this->error_line; $emailmessage .= "<b><br><br>Details. </b>= <br/>\n" . stripslashes(indent(json_encode(debug_backtrace()))); echo $emailmessage; ?> <li>Sorry, Localhost run can't Send Error Message</li> </ol> </div> <?php } } } ?> </body> </html>
//людей выше анона echo "Рост анона: {$anonHeight}<br><br>"; foreach ($classMatesHeight as $name => $height) { echo "Имя: {$name}, рост: {$height} см. <br>"; if ($height > $anonHeight) { $numberOfClassMatesThatBiggerThanAnon++; echo "{$name} выше анона.<br>"; } else { echo "{$name} не выше анона<br>"; } echo "<br>"; } echo "В классе {$numberOfClassMatesThatBiggerThanAnon} человек выше анона<br><br><br>"; //------------------------------------------------------------------------------------------------------// //Задача 3 $answers = array('да', 'нет', 'не знаю', 'никогда', 'зависит от тебя', 'спроси анона'); $question = "Выучу ли я пхп?"; echo "Вопрос: ", $question, "<br>"; echo "Ответ: {$answers[mt_rand(0, 5)]} <br>"; indent(); //------------------------------------------------------------------------------------------------------// //Задача 4 $nameLetters = array('ко', 'и', 'дзу', 'ми', 'са', 'ку', 'ра', 'да', 'чи', 'а', 'ки', 'ми', 'на', 'го', 'ха', 'ру', 'хи', 'ча', 'но', 'н', 'дзи', 'ма', 'до', 'ре', 'фа', 'соль', 'си', 'диез'); //да, я аутист. $generatedName = ''; for ($i = 0; $i < mt_rand(4, count($nameLetters)); $i++) { $generatedName = $generatedName . $nameLetters[mt_rand(0, count($nameLetters))]; } echo "Сгенерированное имя: {$generatedName}"; indent();
function js($name, $data) { $json = trim(indent(json_encode($data, JSON_PRETTY_PRINT))); return <<<EOF (function(window, factory) { if (typeof define === 'function' && define.amd) { define([], function() { return factory(); }); } else if (typeof module === 'object' && typeof module.exports === 'object') { module.exports = factory(); } else { (window.LocaleData || (window.LocaleData = {}))['{$name}'] = factory(); } }(typeof window !== "undefined" ? window : this, function() { return {$json}; })); EOF; }
function create_subquery($id, $year, $alias = null) { require SERVER_ROOT . '/php/dist/constant.php'; require_once SERVER_ROOT . '/php/dist/extension.php'; require_once SERVER_ROOT . '/module/definition/module.php'; //Initialize. $where_realistic_all = ''; if (!$alias) { $alias = $id; } //End: Initialize. //Test whether subqueries are needed ($hasSubfield). if (count(idMultiStrToArr($id)) === 1) { //If there's only 1 field to select (i.e. no subqueries needed). $def_obj = definitionCreate($id, $year); $thisQuery_obj = clone $def_obj; $id_arr = $thisQuery_obj->sql->id_arr; if (count($id_arr) > 1) { //If there was only 1 field to select, but that field is actually made up of multiple fields (e.g. temp_diff). $hasSubfield = true; } else { //If there was only 1 field to select and it IS NOT actually made up of multiple fields. $hasSubfield = false; } } else { //If there are multiple fields to select (i.e. subqueries needed). $hasSubfield = true; $thisQuery_obj->sql->field = $id; $id_arr = idMultiStrToArr($id); } //End: Test whether subqueries are needed. //Generating subqueries (if necessary). if (!$hasSubfield) { //If subqueries are NOT needed. $from = $thisQuery_obj->sql->from; $db = $thisQuery_obj->sql->db; if (!$thisQuery_obj->sql->fromPseudoTable) { $thisQuery_obj->sql->from = "{$db}.{$from} {$from} "; } else { $thisQuery_obj->sql->from = "( \n {$from} \n ) sub "; } } else { //If subqueries are needed. $from_sub = ''; $where = "where 1 = 1 "; foreach ($id_arr as $key => $value) { //Loop thru each subfield. $subquery_obj = definitionCreate($value, $year); $id = $subquery_obj->sql->id; $where_realistic = $subquery_obj->sql->where_realistic; $sub_alias = 'sub' . ($key + 1); if ($subquery_obj->sql->nullToZero) { //If it's a null-to-zero field. $where_realistic = str_replace($id, "isNull({$id}, 0)", $where_realistic); } else { $where_realistic = str_replace($alias, $id, $where_realistic); } if ($where_realistic) { if ($where_realistic_all !== '') { $where_realistic_all .= " \n" . "and "; } $where_realistic_all .= "( {$where_realistic} )"; } $join = $subquery_obj->sql->join; if ($from_sub !== '') { $join_type = "{$join} join"; $join_field = "on sub1.{$const->field_heat} = {$sub_alias}.{$const->field_heat} \n" . "and sub1.{$const->field_year} = {$sub_alias}.{$const->field_year} "; $join_field = indent($join_field, 2); } else { $join_type = ''; $join_field = ''; } $obj = create_subquery($value, $year); $query = $obj->query; $from_sub .= "{$join_type} ( \n" . indent($query, 1) . " \n" . ") {$sub_alias} \n" . $join_field; } $thisQuery_obj->sql->from = $from_sub; } //End: Generating subqueries (if necessary). //Getting necessary variables ready. $field = $thisQuery_obj->sql->field; $id = $thisQuery_obj->sql->id; $from = $thisQuery_obj->sql->from; $db = $thisQuery_obj->sql->db; $where_local = $thisQuery_obj->sql->where_local; $where_realistic = $thisQuery_obj->sql->where_realistic; if ($thisQuery_obj->sql->nullToZero) { //If it's a null-to-zero field. $where_realistic = str_replace($id, "isNull({$id}, 0)", $where_realistic); } else { $where_realistic = str_replace($alias, $id, $where_realistic); } if ($thisQuery_obj->sql->select_distinct) { $select = 'select distinct'; } else { $select = 'select'; } $where = "where {$const->field_year} >= '{$year}'"; //End: Getting necessary variables ready. //Create local where clause. if ($where_local) { $where_local = "and ( \n" . indent($where_local, 1) . " \n" . ")"; $where = $where . " \n" . indent($where_local, 1); } //End: Create local where clause. //Create realistic where clause. This will be part of the where clause in the parent query (not this query). if ($where_realistic_all) { $where_realistic_all = "and ( \n" . indent($where_realistic_all, 1) . " \n" . ")"; $where = $where . " \n" . indent($where_realistic_all, 1); } //End: Create realistic where clause. //Create this query. $query = "{$select} {$field} as {$alias}, {$const->field_heat}, {$const->field_year} \n" . "from {$from} \n" . $where; //End: Create this query. //Handle output. $output = new stdClass(); $output->query = $query; $output->where_realistic = $where_realistic; return $output; //End: Handle output. }
function mkPackage($option, $caller, $pkg) { global $ff_admpath, $ff_version, $mosConfig_fileperms; $id = $pkg; $name = JRequest::getVar( 'pkg_name', ''); $title = JRequest::getVar( 'pkg_title', ''); $version = JRequest::getVar( 'pkg_version', ''); $created = date('Y-m-d H:i:s'); $author = JRequest::getVar( 'pkg_author', ''); $email = JRequest::getVar( 'pkg_email', ''); $url = JRequest::getVar( 'pkg_url', ''); $description = JRequest::getVar( 'pkg_description', ''); $copyright = JRequest::getVar( 'pkg_copyright', ''); savePackage($id, $name, $title, $version, $created, $author, $email, $url, $description, $copyright); $xmlname = $ff_admpath.'/packages/'.$name.'.xml'; $existed = file_exists($xmlname); if ($existed) if (!is_writable($xmlname)) die('XML file is not writable!'); $file= fopen($xmlname, "w"); $xml = '<?xml version="1.0" encoding="utf-8" ?>'.nl(). '<FacileFormsPackage'; if ($id != '') $xml .= ' id="'.$id.'"'; if ($id == '') $xml .= ' id="'.$name.'"'; $xml .= ' type="autoincrement" version="'.$ff_version.'">'.nl(). indent(1).'<name>'.expstring($name).'</name>'.nl(). indent(1).'<title>'.expstring($title).'</title>'.nl(). indent(1).'<version>'.expstring($version).'</version>'.nl(). indent(1).'<creationDate>'.$created.'</creationDate>'.nl(). indent(1).'<author>'.expstring($author).'</author>'.nl(). indent(1).'<authorEmail>'.expstring($email).'</authorEmail>'.nl(). indent(1).'<authorUrl>'.expstring($url).'</authorUrl>'.nl(). indent(1).'<description>'.expstring($description).'</description>'.nl(). indent(1).'<copyright>'.expstring($copyright).'</copyright>'.nl(); if ($id == '') $ids = JRequest::getVar( 'scriptsel', array()); else { $ids = array(); $rows = _ff_select( "select id from #__facileforms_scripts ". "where package = '$id' ". "order by id" ); if (count($rows)) foreach ($rows as $row) $ids[] = $row->id; } // if if (count($ids) > 0) { $ids = implode(',', $ids); $scripts = _ff_select( "select * from #__facileforms_scripts where id in ($ids) order by package, name, id" ); for ($s = 0; $s < count($scripts); $s++) { $script = $scripts[$s]; $xml .= indent(1).'<script id="'.$script->id.'">'.nl(); if ($script->published != 1) $xml .= indent(2).'<published>'.$script->published.'</published>'.nl(); if ($script->package != '') $xml .= indent(2).'<package>'.expstring($script->package).'</package>'.nl(); $xml .= indent(2).'<name>'.expstring($script->name).'</name>'.nl(). indent(2).'<title>'.expstring($script->title).'</title>'.nl(); if ($script->type != 'Untyped') $xml .= indent(2).'<type>'.expstring($script->type).'</type>'.nl(); $script->description = trim($script->description); if ($script->description != '') $xml .= indent(2).'<description>'.expstring($script->description).'</description>'.nl(); $script->code = trim($script->code); if ($script->code != '') $xml .= indent(2).'<code>'.expstring($script->code).'</code>'.nl(); $xml .= indent(1).'</script>'.nl(); } // for } // if if ($id == '') $ids = JRequest::getVar( 'piecesel', array()); else { $ids = array(); $rows = _ff_select( "select id from #__facileforms_pieces ". "where package = '$id' ". "order by id" ); if (count($rows)) foreach ($rows as $row) $ids[] = $row->id; } // if if (count($ids) > 0) { $ids = implode(',', $ids); $pieces = _ff_select( "select * from #__facileforms_pieces where id in ($ids) order by package, name, id" ); for ($p = 0; $p < count($pieces); $p++) { $piece = $pieces[$p]; $xml .= indent(1).'<piece id="'.$piece->id.'">'.nl(); if ($piece->published != 1) $xml .= indent(2).'<published>'.$piece->published.'</published>'.nl(); if ($piece->package != '') $xml .= indent(2).'<package>'.expstring($piece->package).'</package>'.nl(); $xml .= indent(2).'<name>'.expstring($piece->name).'</name>'.nl(). indent(2).'<title>'.expstring($piece->title).'</title>'.nl(); if ($piece->type != 'Untyped') $xml .= indent(2).'<type>'.expstring($piece->type).'</type>'.nl(); $piece->description = trim($piece->description); if ($piece->description != '') $xml .= indent(2).'<description>'.expstring($piece->description).'</description>'.nl(); $piece->code = trim($piece->code); if ($piece->code != '') $xml .= indent(2).'<code>'.expstring($piece->code).'</code>'.nl(); $xml .= indent(1).'</piece>'.nl(); } // for } // if if ($id == '') $ids = JRequest::getVar( 'formsel', array()); else { $ids = array(); $rows = _ff_select( "select id from #__facileforms_forms ". "where package = '$id' ". "order by id" ); if (count($rows)) foreach ($rows as $row) $ids[] = $row->id; } // if if (count($ids) > 0) { $ids = implode(',', $ids); $forms = _ff_select( "select * from #__facileforms_forms where id in ($ids) order by package, ordering, id" ); for ($f = 0; $f < count($forms); $f++) { $form = $forms[$f]; $xml .= indent(1).'<form id="'.$form->id.'">'.nl(); if ($form->published != 1) $xml .= indent(2).'<published>'.$form->published.'</published>'.nl(); if ($form->runmode != 0) $xml .= indent(2).'<runmode>'.$form->runmode.'</runmode>'.nl(); if ($form->package != '') $xml .= indent(2).'<package>'.expstring($form->package).'</package>'.nl(); $xml .= indent(2).'<name>'.expstring($form->name).'</name>'.nl(). indent(2).'<title>'.expstring($form->title).'</title>'.nl(); if ($form->description != '') $xml .= indent(2).'<description>'.expstring($form->description).'</description>'.nl(); if ($form->class1 != '') $xml .= indent(2).'<class1>'.expstring($form->class1).'</class1>'.nl(); if ($form->class2 != '') $xml .= indent(2).'<class2>'.expstring($form->class2).'</class2>'.nl(); $xml .= indent(2).'<width>'.$form->width.'</width>'.nl(); if ($form->widthmode != 0) $xml .= indent(2).'<widthmode>'.$form->widthmode.'</widthmode>'.nl(); $xml .= indent(2).'<height>'.$form->height.'</height>'.nl(); if ($form->heightmode != 0) $xml .= indent(2).'<heightmode>'.$form->heightmode.'</heightmode>'.nl(); if ($form->pages != 1) $xml .= indent(2).'<pages>'.$form->pages.'</pages>'.nl(); if ($form->emailntf != 1) $xml .= indent(2).'<emailntf>'.$form->emailntf.'</emailntf>'.nl(); if ($form->emaillog != 1) $xml .= indent(2).'<emaillog>'.$form->emaillog.'</emaillog>'.nl(); if ($form->emailxml != 0) $xml .= indent(2).'<emailxml>'.$form->emailxml.'</emailxml>'.nl(); if ($form->emailntf == 2) { $form->emailadr = expstring($form->emailadr); if ($form->emailadr != '') $xml .= indent(2).'<emailadr>'.$form->emailadr.'</emailadr>'.nl(); } // if if($form->template_code != '')$xml.=indent(2).'<template_code>'.base64_encode($form->template_code).'</template_code>'; if($form->template_code_processed != '')$xml.=indent(2).'<template_code_processed>'.base64_encode($form->template_code_processed).'</template_code_processed>'; if($form->template_areas != '')$xml.=indent(2).'<template_areas>'.base64_encode($form->template_areas).'</template_areas>'; if ($form->dblog != 1) $xml .= indent(2).'<dblog>'.$form->dblog.'</dblog>'.nl(); $form->description = trim($form->description); if ($form->prevmode != 2) $xml .= indent(2).'<prevmode>'.$form->prevmode.'</prevmode>'.nl(); if ($form->prevmode != 0 && $form->widthmode != 0 && $form->prevwidth != '') $xml .= indent(2).'<prevwidth>'.$form->prevwidth.'</prevwidth>'.nl(); $this->exportScript( 'script1', '#__facileforms_scripts', $form->script1cond, $form->script1id, $form->script1code, 2, $xml ); $this->exportScript( 'script2', '#__facileforms_scripts', $form->script2cond, $form->script2id, $form->script2code, 2, $xml ); $this->exportScript( 'piece1', '#__facileforms_pieces', $form->piece1cond, $form->piece1id, $form->piece1code, 2, $xml ); $this->exportScript( 'piece2', '#__facileforms_pieces', $form->piece2cond, $form->piece2id, $form->piece2code, 2, $xml ); $this->exportScript( 'piece3', '#__facileforms_pieces', $form->piece3cond, $form->piece3id, $form->piece3code, 2, $xml ); $this->exportScript( 'piece4', '#__facileforms_pieces', $form->piece4cond, $form->piece4id, $form->piece4code, 2, $xml ); $elems = _ff_select( "select * from #__facileforms_elements where form=$form->id order by page, ordering, id" ); for ($e = 0; $e < count($elems); $e++) { $elem = $elems[$e]; $xml .= indent(2).'<element id="'.$elem->id.'">'.nl(); if ($elem->page != 1) $xml .= indent(3).'<page>'.$elem->page.'</page>'.nl(); if ($elem->published != 1) $xml .= indent(3).'<published>'.$elem->published.'</published>'.nl(); $xml .= indent(3).'<name>'.expstring($elem->name).'</name>'.nl(). indent(3).'<title>'.expstring($elem->title).'</title>'.nl(); if ($elem->type != 'Static Text/HTML') $xml .= indent(3).'<type>'.$elem->type.'</type>'.nl(); if ($elem->class1 != '') $xml .= indent(3).'<class1>'.expstring($elem->class1).'</class1>'.nl(); if ($elem->class2 != '') $xml .= indent(3).'<class2>'.expstring($elem->class2).'</class2>'.nl(); if (isInputElement($elem->type)) { if ($elem->logging != 1) $xml .= indent(3).'<logging>'.$elem->logging.'</logging>'.nl(); } // if if (isVisibleElement($elem->type)) { if ($elem->posx != NULL) $xml .= indent(3).'<posx>'.$elem->posx.'</posx>'.nl(); if ($elem->posx != NULL && $elem->posxmode!=0) $xml .= indent(3).'<posxmode>'.$elem->posxmode.'</posxmode>'.nl(); if ($elem->posy != NULL) $xml .= indent(3).'<posy>'.$elem->posy.'</posy>'.nl(); if ($elem->posy != NULL && $elem->posymode!=0) $xml .= indent(3).'<posymode>'.$elem->posymode.'</posymode>'.nl(); if ($elem->width != NULL) $xml .= indent(3).'<width>'.$elem->width.'</width>'.nl(); if ($elem->width != NULL && $elem->widthmode!=0) $xml .= indent(3).'<widthmode>'.$elem->widthmode.'</widthmode>'.nl(); if ($elem->height != NULL) $xml .= indent(3).'<height>'.$elem->height.'</height>'.nl(); if ($elem->height != NULL && $elem->heightmode!=0) $xml .= indent(3).'<heightmode>'.$elem->heightmode.'</heightmode>'.nl(); } // if $xml .= indent(3).'<mailback>'.$elem->mailback.'</mailback>'.nl(); $xml .= indent(3).'<mailbackfile>'.$elem->mailbackfile.'</mailbackfile>'.nl(); if ($elem->flag1) $xml .= indent(3).'<flag1>'.$elem->flag1.'</flag1>'.nl(); if ($elem->flag2) $xml .= indent(3).'<flag2>'.$elem->flag2.'</flag2>'.nl(); $elem->data1 = expstring($elem->data1); if ($elem->data1 != '') $xml .= indent(3).'<data1>'.$elem->data1.'</data1>'.nl(); $elem->data2 = expstring($elem->data2); if ($elem->data2 != '') $xml .= indent(3).'<data2>'.$elem->data2.'</data2>'.nl(); $elem->data3 = expstring($elem->data3); if ($elem->data3 != '') $xml .= indent(3).'<data3>'.$elem->data3.'</data3>'.nl(); $this->exportScript( 'script1', '#__facileforms_scripts', $elem->script1cond, $elem->script1id, $elem->script1code, 3, $xml ); if ($elem->script1cond > 0) { if ($elem->script1flag1) $xml .= indent(3).'<script1flag1>'.$elem->script1flag1.'</script1flag1>'.nl(); if ($elem->script1flag2) $xml .= indent(3).'<script1flag2>'.$elem->script1flag2.'</script1flag2>'.nl(); } // if $this->exportScript( 'script2', '#__facileforms_scripts', $elem->script2cond, $elem->script2id, $elem->script2code, 3, $xml ); if ($elem->script2cond > 0) { if ($elem->script2flag1) $xml .= indent(3).'<script2flag1>'.$elem->script2flag1.'</script2flag1>'.nl(); if ($elem->script2flag2) $xml .= indent(3).'<script2flag2>'.$elem->script2flag2.'</script2flag2>'.nl(); if ($elem->script2flag3) $xml .= indent(3).'<script2flag3>'.$elem->script2flag3.'</script2flag3>'.nl(); if ($elem->script2flag4) $xml .= indent(3).'<script2flag4>'.$elem->script2flag4.'</script2flag4>'.nl(); if ($elem->script2flag5) $xml .= indent(3).'<script2flag5>'.$elem->script2flag5.'</script2flag5>'.nl(); } // if $this->exportScript( 'script3', '#__facileforms_scripts', $elem->script3cond, $elem->script3id, $elem->script3code, 3, $xml ); if ($elem->script3cond > 0) { if ($elem->script3msg != '') $xml .= indent(3).'<script3msg>'.expstring($elem->script3msg).'</script3msg>'.nl(); } // if $xml .= indent(2).'</element>'.nl(); } // for $xml .= indent(1).'</form>'.nl(); } // for } // if if ($id == '') $ids = JRequest::getVar( 'menusel', array()); else { $ids = array(); $rows = _ff_select( "select id from #__facileforms_compmenus ". "where package = '$id' and parent = 0 ". "order by id" ); if (count($rows)) foreach ($rows as $row) $ids[] = $row->id; } // if if (count($ids) > 0) { $ids = implode(',', $ids); $menus = _ff_select( "select * from #__facileforms_compmenus where id in ($ids) order by package, ordering, id" ); for ($m = 0; $m < count($menus); $m++) { $menu = $menus[$m]; $xml .= indent(1).'<compmenu id="'.$menu->id.'">'.nl(); if ($menu->published != 1) $xml .= indent(2).'<published>'.$menu->published.'</published>'.nl(); $menu->img = trim($menu->img); if ($menu->img != '') $xml .= indent(2).'<img>'.expstring($menu->img).'</img>'.nl(); if ($menu->package != '') $xml .= indent(2).'<package>'.expstring($menu->package).'</package>'.nl(); $xml .= indent(2).'<title>'.expstring($menu->title).'</title>'.nl(); $menu->name = trim($menu->name); if ($menu->name != '') $xml .= indent(2).'<name>'.expstring($menu->name).'</name>'.nl(); if ($menu->page != 1 && $menu->page!='') $xml .= indent(2).'<page>'.$menu->page.'</page>'.nl(); if ($menu->frame != 0) $xml .= indent(2).'<frame>'.$menu->frame.'</frame>'.nl(); if ($menu->border != 0) $xml .= indent(2).'<border>'.$menu->border.'</border>'.nl(); $menu->params = trim($menu->params); if ($menu->params != '') $xml .= indent(2).'<params>'.expstring($menu->params).'</params>'.nl(); $submenus = _ff_select( "select * from #__facileforms_compmenus where parent=$menu->id order by ordering, id" ); for ($s = 0; $s < count($submenus); $s++) { $submenu = $submenus[$s]; $xml .= indent(2).'<compmenu id="'.$submenu->id.'">'.nl(); if ($submenu->published != 1) $xml .= indent(3).'<published>'.$submenu->published.'</published>'.nl(); $submenu->img = trim($submenu->img); if ($submenu->img != '') $xml .= indent(3).'<img>'.expstring($submenu->img).'</img>'.nl(); if ($menu->package != '') $xml .= indent(3).'<package>'.expstring($submenu->package).'</package>'.nl(); $xml .= indent(3).'<title>'.expstring($submenu->title).'</title>'.nl(); $submenu->name = trim($submenu->name); if ($submenu->name != '') $xml .= indent(3).'<name>'.expstring($submenu->name).'</name>'.nl(); if ($submenu->page != 1 && $submenu->page!='') $xml .= indent(3).'<page>'.$submenu->page.'</page>'.nl(); if ($submenu->frame != 0) $xml .= indent(3).'<frame>'.$submenu->frame.'</frame>'.nl(); if ($submenu->border != 0) $xml .= indent(3).'<border>'.$submenu->border.'</border>'.nl(); $submenu->params = trim($submenu->params); if ($submenu->params != '') $xml .= indent(3).'<params>'.expstring($submenu->params).'</params>'.nl(); $xml .= indent(2).'</compmenu>'.nl(); } // for $xml .= indent(1).'</compmenu>'.nl(); } // for } // if $xml .= '</FacileFormsPackage>'.nl(); fwrite($file, $xml); fclose($file); if (!$existed) { $filemode = NULL; if (isset($mosConfig_fileperms)) { if ($mosConfig_fileperms!='') $filemode = octdec($mosConfig_fileperms); } else $filemode = 0644; if (isset($filemode)) @chmod($xmlname, $filemode); } // if HTML_facileFormsConf::edit($option, $caller, $pkg, $xmlname); } // mkPackage
function appand_to_settings($conf_arr) { $setings_str = ''; foreach ($conf_arr as $key => $item) { $setings_str .= "var {$key} = " . indent(json_encode($item)) . ";\n\n"; } $settings_file = 'settings.js'; $src_settings_js = __DIR__ . '/js/' . $settings_file; $src_settings_content = file_get_contents($src_settings_js); $new_content = preg_replace('/main\\(\\);}\\)\\(\\);}/i', '', $src_settings_content); $new_content .= $setings_str; $new_content .= 'main();})();}'; $settings_js = get_cached_path() . $settings_file; file_put_contents($settings_js, $new_content); }
function processtransaction($tx, $blockhash, $blocknum) { //returns tx value global $db; $txhash = $tx->hash; $txsize = $tx->size; $rawtx = indent(json_encode($tx)); if (pg_num_rows(pg_query_params($db, "SELECT hash FROM transactions WHERE hash=decode(\$1,'hex');", array($txhash))) === 0) { pg_query_params($db, "INSERT INTO transactions(hash,block,raw,size) VALUES (decode(\$1,'hex'),decode(\$2,'hex'),\$3,\$4);", array($txhash, $blockhash, $rawtx, $txsize)); } else { if (pg_num_rows(pg_query_params($db, "SELECT hash FROM transactions WHERE hash=decode(\$1,'hex') AND block<>decode(\$2,'hex');", array($txhash, $blockhash))) == 1) { echo "***Duplicate transaction: adding special record***"; sleep(30); pg_query_params($db, "INSERT INTO special VALUES (decode(\$1,'hex'),decode(\$2,'hex'),'Duplicate');", array($txhash, $blockhash)); return "0"; } else { die("Can't insert tx"); } } foreach ($tx->in as $input) { $type = NULL; $prev = NULL; $previndex = NULL; $hash160 = NULL; $scriptsig = NULL; $index = NULL; $value = NULL; echo "INPUT\n"; if (isset($input->coinbase)) { $type = "Generation"; $value = bcdiv("50", floor(pow(2, floor($blocknum / 210000))), 8); $scriptsig = $input->coinbase; } else { $prev = $input->prev_out->hash; $index = $input->prev_out->n; $scriptsig = $input->scriptSig; $simplescriptsig = simplifyscript($scriptsig); echo "Simplescriptsig: " . $simplescriptsig . "\$\n"; $prevtx = pg_fetch_assoc(pg_query_params($db, "SELECT value,type,encode(hash160,'hex') AS hash160 FROM outputs WHERE index=\$1 AND tx=decode(\$2,'hex');", array($index, $prev))); if (!$prevtx) { error_log("testnet critical failure"); die("Error: Failed getting prev tx..."); } $value = $prevtx["value"]; $type = $prevtx["type"]; $hash160 = $prevtx["hash160"]; if ($type == "Address") { if (preg_match("/^[0-9a-f]+ [0-9a-f]{66,130}\$/", $simplescriptsig)) { $pubkey = preg_replace("/^[0-9a-f]+ ([0-9a-f]{66,130})\$/", "\$1", $simplescriptsig); $hash160 = strtolower(hash160($pubkey)); updateKeys($hash160, $pubkey, $blockhash); } } if (is_null($type)) { error_log("testnet critical failure"); die("Error: No input type"); } } pg_query_params($db, "INSERT INTO inputs (tx,prev,index,value,scriptsig,hash160,type,block) VALUES (decode(\$1,'hex'),decode(\$2,'hex'),\$3,\$4,\$5,decode(\$6,'hex'),\$7,decode(\$8,'hex'))", array($txhash, $prev, $index, $value, $scriptsig, $hash160, $type, $blockhash)); echo "Type: " . $type . "\$\n"; echo "Value: " . $value . "\$\n"; echo "Prev: " . $prev . "\$\n"; echo "TxHash: " . $txhash . "\$\n"; echo "Index: " . $index . "\$\n"; echo "ScriptSig: " . $scriptsig . "\$\n"; echo "Hash160: " . $hash160 . "\$\n"; } $index = -1; $txvalue = "0"; foreach ($tx->out as $output) { $hash160 = NULL; $type = NULL; $index++; echo "OUTPUT\n"; $value = $output->value; $txvalue = bcadd($txvalue, $value, 8); $scriptpubkey = $output->scriptPubKey; $simplescriptpk = simplifyscript($scriptpubkey); echo "Simplescriptpubkey: " . $simplescriptpk . "\$\n"; //To pubkey if (preg_match("/^[0-9a-f]{66,130} OP_CHECKSIG\$/", $simplescriptpk)) { $type = "Pubkey"; $pubkey = preg_replace("/^([0-9a-f]{66,130}) OP_CHECKSIG\$/", "\$1", $simplescriptpk); $hash160 = strtolower(hash160($pubkey)); updateKeys($hash160, $pubkey, $blockhash); } //To BC address if (preg_match("/^OP_DUP OP_HASH160 [0-9a-f]{40} OP_EQUALVERIFY OP_CHECKSIG\$/", $simplescriptpk)) { $type = "Address"; $hash160 = preg_replace("/^OP_DUP OP_HASH160 ([0-9a-f]{40}) OP_EQUALVERIFY OP_CHECKSIG\$/", "\$1", $simplescriptpk); updateKeys($hash160, NULL, $blockhash); } if (is_null($type)) { $type = "Strange"; } pg_query_params($db, "INSERT INTO outputs (tx,index,value,scriptpubkey,hash160,type,block) VALUES (decode(\$1,'hex'),\$2,\$3,\$4,decode(\$5,'hex'),\$6,decode(\$7,'hex'));", array($txhash, $index, $value, $scriptpubkey, $hash160, $type, $blockhash)); echo "Hash160: " . $hash160 . "\$\n"; echo "Type: " . $type . "\$\n"; echo "Index: " . $index . "\$\n"; echo "Value: " . $value . "\$\n"; echo "Scriptpubkey: " . $scriptpubkey . "\$\n"; } pg_query_params($db, "UPDATE transactions SET fee=(SELECT (SELECT sum(value) FROM inputs WHERE tx=decode(\$1,'hex'))-(SELECT sum(value) from outputs WHERE tx=decode(\$1,'hex'))) WHERE hash=decode(\$1,'hex');", array($txhash)); return $txvalue; }
continue; } if ($tokens[0] == "INSERT" || $tokens[0] == "DELETE" || $tokens[0] == "UPDATE" || $tokens[0] == "CREATE" || $tokens[0] == "REPLACE" || $tokens[0] == "DROP") { $sql = ""; foreach ($tokens as $token) { if (substr($token, 0, 2) == "v_") { $sql .= "'\$" . $token . "'"; } else { if ($token[0] != "(") { $sql .= " "; } $sql .= $token; } } indent("\$exec_sql = \"{$sql}\";\n", $depth); indent("mysql_query(\$exec_sql);\n", $depth); continue; } #unknown syntax print_r($tokens); exit; } $stmt = ""; } else { if ($stmt) { $stmt .= " "; } $stmt .= $line; } } function indent($text, $depth, $newline = true)
# Params iniciales $params_peticion = array("idioma" => 'es', "dispatch" => 'doRastreoInternet'); # Agrega numero de guia o codigo de rastreo a params POST if (!isset($_GET['numero'])) { $fields = array("error" => 1, "mensaje_error" => "No existe el parámetro numero en la peticion GET"); die(indent(json_encode($fields))); } if (valida('guia')) { $params_peticion['guias'] = $_GET['numero']; $params_peticion['tipoGuia'] = 'ESTAFETA'; } elseif (valida('rastreo')) { $params_peticion['guias'] = $_GET['numero']; $params_peticion['tipoGuia'] = 'REFERENCE'; } else { $fields = array("error" => 2, "mensaje_error" => "Número de guía o código de rastreo no válidos"); die(indent(json_encode($fields))); } $hunter = new DomHunter('http://rastreo3.estafeta.com/RastreoWebInternet/consultaEnvio.do', 1); $hunter->arrParamsPeticion = $params_peticion; # TODO: Cuando hay respuesta de "No hay informacion disponible" # Busca coordenadas de origen y destino $presas = array(); $presas[] = array('numero_guia', new KeyValue('numero de guia')); $presas[] = array('codigo_rastreo', new KeyValue('digo de rastreo')); $presas[] = array('origen', new KeyValue('origen')); $presas[] = array('destino', new KeyValue('destino', TRUE, TRUE)); $presas[] = array('cp_destino', new IdUnico(5, 'num')); $presas[] = array('servicio', new KeyValue('entrega garantizada', FALSE)); $presas[] = array('estatus', new NodoDom(array('find' => '.respuestasazul'), 'plaintext', 1)); $presas[] = array('fecha_recoleccion', new KeyValue('fecha de recoleccion')); $presas[] = array('fecha_programada', new KeyValue('de entrega', TRUE, TRUE));
function emit($args) { echo indent(); if (!is_array($args)) { $args = func_get_args(); } for ($i = 0, $l = count($args); $l > $i; ++$i) { echo $args[$i]; } echo "\n"; }
if ($top["name"] !== $pagen[0] && $done == false) { $index++; } else { $done = true; } } /*$index = 0; while($wiki[$index]["name"] !== $page[0]){ $index++; }*/ $wiki[$index]["children"] = array_merge($wiki[$index]["children"], $page); } else { $page = array(array("name" => $_POST["page"], "deleted" => false, "contents" => $contents, "comments" => array(), "children" => array())); $wiki = array_merge($wiki, $page); } file_put_contents("wiki.json", indent(json_encode($wiki))); $edits = file_get_contents("edits.txt"); $edits = $_POST['page'] . ":::" . time() . ":::" . $_COOKIE["user"] . "\n" . $edits; file_put_contents("edits.txt", $edits); $url = "../Wiki/?p=" . $_POST['page']; header("Location: {$url}"); function indent($json) { $result = ''; $pos = 0; $strLen = strlen($json); $indentStr = ' '; $newLine = "\n"; $prevChar = ''; $outOfQuotes = true; for ($i = 0; $i <= $strLen; $i++) {
$result[$child->nodeName] = dom_to_array($child); } else { if (!isset($group[$child->nodeName])) { $tmp = $result[$child->nodeName]; $result[$child->nodeName] = array($tmp); $group[$child->nodeName] = 1; } $result[$child->nodeName][] = dom_to_array($child); } } } $trimmed = trim($text); if ($trimmed != "") { $result['#text'] = $text; } return $result; } /** * takes a file name of an xml document and returns an json representation * * @param string $fileName */ function convert($fileName) { $d = new DOMDocument(1, "UTF-8"); $d->load($fileName); $ret[$d->documentElement->nodeName] = dom_to_array($d->documentElement); return json_encode($ret); } echo indent(str_replace("\\/", "/", convert($argv[1])));