header('content-type: application/json; charset=utf-8'); switch ($in_cmd) { case 'hbeat': echo handle_heartbeat_cmd($PARAMS); break; case 'bind': echo handle_bind_account($PARAMS); break; case 'kword': echo handle_bind_keyword($PARAMS); break; case 'reset': echo handle_reset(); break; case 'debug': echo handle_debug(); break; default: echo 'unreconized cmd.'; } exit; function handle_heartbeat_cmd($PARAMS) { /****************************************** 例外处理,一次心跳完成账户绑定,关键字搜集等 ******************************************/ //支持微信等不支持cookies的客户端,一次请求完成心跳和账户绑定 if (isset($PARAMS['plat'])) { handle_bind_account($PARAMS); } if (count($cmd_que = msg_queue())) {
function assign() { global $g_debug_mode; global $g_code_area; global $g_code_source; // Clear any styles or instructions left over from previous rows foreach ( $this->columns as $col ) { $col->output_cell_styles = false; $col->output_images = false; $col->output_hyperlinks = false; } // Perform assignments foreach ( $this->assignment as $assign ) { $col = get_query_column($assign->query_name, $this->columns ) ; if ( !$col ) { continue; } $g_code_area = "Assignment"; $g_code_source = "<BR>In Assignment if ".$assign->criteria."<BR>"; $g_code_source = "<BR>In Assignment ".$assign->query_name."=".$assign->expression; if ( $this->test($assign->criteria) ) { if ( $assign->non_assignment_operation ) $a = $assign->expression.';'; else $a = '$col->column_value = '.$assign->expression.';'; $r = eval($a); if ( /*SW_DEBUG ||*/ $g_debug_mode ) handle_debug ("Assignment ".$assign->query_name." = ". $assign->expression. " => ".$col->column_value, SW_DEBUG_HIGH ); } } }
return; } } if (!is_writeable($proj_dir)) { if (!chmod($proj_dir, "u+rwx")) { trigger_error("Failed to make project directory {$proj_dir} writeable "); return; } } $txt = file_get_contents($proj_template); $txt = preg_replace("/<<BASEURL>>/", $baseurl, $txt); $txt = preg_replace("/<<DRIVER>>/", $type, $txt); $txt = preg_replace("/<<DBPASSWORD>>/", $password, $txt); $txt = preg_replace("/<<DBHOST>>/", $host, $txt); $txt = preg_replace("/<<DBSERVER>>/", $server, $txt); $txt = preg_replace("/<<DBNAME>>/", $name, $txt); $txt = preg_replace("/<<DBPROTOCOL>>/", $protocol, $txt); $txt = preg_replace("/<<DBUSER>>/", $user, $txt); echo "<PRE>"; echo $txt; echo "</PRE>"; trigger_error("Failed to create project directory {$proj_dir}"); return; $retval = file_put_contents($proj_conf, $txt); $txt = file_get_contents($menu_template); $txt = preg_replace("/<<PROJTITLE>>/", $title, $txt); $retval = file_put_contents($proj_menu, $txt); $txt = file_get_contents($lang_template); $retval = file_put_contents($proj_lang, $txt); handle_debug("Project Created", 0);
$paramval = "true"; } else { $paramval = "false"; } $txt = preg_replace("/(define.*?{$paramkey}',).*\\);/", "\$1{$paramval});", $txt); } else { $paramval = $paramval; $txt = preg_replace("/define\\('{$paramkey}', *'.*'\\);/", "define('{$paramkey}', '{$paramval}');", $txt); } } } $retval = file_put_contents($proj_conf, $txt); if ($_configure_mode == "CREATE" || $_configure_mode == "CREATETUTORIALS") { $txt = file_get_contents($menu_template); $retval = file_put_contents($proj_menu, $txt); $txt = file_get_contents($lang_template); $retval = file_put_contents($proj_lang, $txt); } if (!$configparams["SW_PROJECT_PASSWORD"]) { handle_debug("Warning - Project password not set - any user will be able to run reports in this project", 0); } if ($_configure_mode == "CREATETUTORIALS") { handle_debug("Tutorials Created Successfully", 0); } else { if ($_configure_mode == "CREATE") { handle_debug("Project Created Successfully", 0); } else { handle_debug("Project Configuration Updated Successfully", 0); } } $g_debug_mode = false;
function remove_file($filename) { global $g_project; if (!$filename) { trigger_error(template_xlate("UNABLE_TO_REMOVE") . template_xlate("SPECIFYXML"), E_USER_ERROR); return false; } if (!preg_match("/\\.xml\$/", $filename)) { $filename = $filename . ".xml"; } $projdir = $this->query->projects_folder . "/" . $g_project; if (!is_file($projdir)) { find_file_to_include($projdir, $projdir); } if ($projdir && is_dir($projdir)) { $fn = $projdir . "/" . $filename; if (!is_file($fn)) { trigger_error(template_xlate("UNABLE_TO_REMOVE") . " {$filename} - " . template_xlate("NOFILE"), E_USER_ERROR); } else { if (!is_writeable($fn)) { trigger_error(template_xlate("UNABLE_TO_REMOVE") . " {$filename} - " . template_xlate("NOWRITE"), E_USER_ERROR); } else { if (!unlink($fn)) { trigger_error(template_xlate("UNABLE_TO_REMOVE") . " {$filename} - " . template_xlate("NOWRITE"), E_USER_ERROR); } else { handle_debug(template_xlate("REPORTFILE") . " {$filename} " . template_xlate("DELETEOKACT"), 0); } } } } else { trigger_error("Unable to open project area {$g_project} to save file {$filename} " . $this->query->reports_path . "/" . $filename . " Not Found", E_USER_ERROR); } }
function parse_column($in_colno, $in_string, &$auto_gen_alias, $warn_empty_aliases) { $err = false; $colalias = ""; $colname = ""; $coltable = ""; $colexp = ""; // Check for an alias ( any final word which is preceded by any non // numeric or expression character // Split out the last two elements if (preg_match("/(.+\\))([^\\s]*)\\s*\$/s", $in_string, $out_match)) { if (preg_match("/^[[:alpha:]]\\w+\$/s", $out_match[2])) { $colalias = $out_match[2]; $colname = $out_match[1]; $colexp = $colname; } else { if (preg_match("/[^0-9A-Za-z_\r\n\t .]/", $in_string)) { $colalias = "column" . $in_colno; $auto_gen_alias = $colalias; if ($warn_empty_aliases) { handle_debug("Expression <b>({$in_string})</b> is unnamed and will be given the name <b>{$colalias}</b>. You might like to provide your own column alias for this expression.", 0); } } $colname = $in_string; $colexp = $in_string; } } else { if (preg_match("/(.+)\\s+(.*)\\s*\$/s", $in_string, $out_match)) { if (preg_match("/^[[:alpha:]]\\w+\$/s", $out_match[2])) { $colalias = $out_match[2]; $colname = $out_match[1]; $colexp = $colname; } else { if (preg_match("/^[a-zA-Z]\$/s", $out_match[2])) { $colalias = $out_match[2]; $colname = $out_match[1]; $colexp = $colname; } else { if (preg_match("/[^0-9A-Za-z_\r\n\t .]/", $in_string)) { $colalias = "column" . $in_colno; $auto_gen_alias = $colalias; if ($warn_empty_aliases) { handle_debug("Expression <b>({$in_string})</b> is unnamed and will be given the name <b>{$colalias}</b>. You might like to provide your own column alias for this expression.", 0); } } $colname = $in_string; $colexp = $in_string; } } } else { // Single column value only so assume no alias if (preg_match("/[^0-9A-Za-z_\r\n\t .]/", $in_string)) { $colalias = "column" . $in_colno; $auto_gen_alias = $colalias; if ($warn_empty_aliases) { handle_debug("Expression <b>({$in_string})</b> is unnamed and will be given the name <b>{$colalias}</b>. You might like to provide your own column alias for this expression.", 0); } } $colname = $in_string; $colexp = $in_string; } } // Now with what's left of the column try to ascertain a table name // and column part if (preg_match("/^(\\w+)\\.(\\w+)\$/", $colname, $out_match)) { $coltable = $out_match[1]; $colname = $out_match[2]; } $this->columns[] = array("name" => $colname, "table" => $coltable, "alias" => $colalias, "expression" => $colexp); return true; }