Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F3938308
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/Nasqueron/Wikimedia.tcl b/Nasqueron/Wikimedia.tcl
index 5714366..fcac007 100644
--- a/Nasqueron/Wikimedia.tcl
+++ b/Nasqueron/Wikimedia.tcl
@@ -1,81 +1,87 @@
bind pub - .config pub:config
bind dcc - config dcc:config
# Handles .config pub command
proc pub:config {nick uhost handle chan arg} {
if {[llength $arg] < 2} {
puthelp "NOTICE $nick :Usage: .config <setting> <project>"
return 0
}
putserv "PRIVMSG $chan :[wikimedia::get_config_variable [lindex $arg 0] [lindex $arg 1] [lrange $arg 2 end]]"
return 1
}
# Handles .config dcc command
proc dcc:config {handle idx arg} {
if {[llength $arg] < 2} {
putdcc $idx "Usage: .config <setting> <project>"
return 0
}
putdcc $idx [wikimedia::get_config_variable [lindex $arg 0] [lindex $arg 1] [lrange $arg 2 end]]
return 1
}
namespace eval ::wikimedia {
# Script to get a configuration variable
set get_config_script {
<?php
error_reporting(0);
require_once('%%dir%%/wmf-config/InitialiseSettings.php');
$value = $wgConf->settings%%key%%;
if (is_array($value)) {
$values = array();
- foreach ($value as $k => $v) {
- $values[] = "$k => $v";
+ if (array_keys($value) !== range(0, count($value) - 1)) {
+ //Associative arary
+ foreach ($value as $k => $v) {
+ $values[] = "$k => $v";
+ }
+ echo implode(' / ', $values);
+ } else {
+ //Numeric array
+ echo implode(', ', $value);
}
- echo implode(' / ', $values);
} else if (is_bool($value)) {
echo $value ? 'true' : 'false';
} else {
echo $value;
}
?>
}
# Gets a configuration variable, defined in $wgConf aray
#
# @param $setting the config variable's name
# @param $project the project
# @param $args If the config variable is an array, the keys to get (facultative, specify how many you want)
# @return the config value
proc get_config_variable {setting project args} {
if {[string index $setting 0] == "\$"} {
set setting [string rang $setting 1 end]
}
if {![regexp "^\[a-z]\[A-Za-z0-9]*$" $setting]} {
return "Not a valid setting: $setting"
}
if {![regexp "^\[a-z]\[a-z0-9_]*$" $project]} {
return "Not a valid project: $project"
}
set key "\['$setting']\['$project']"
foreach arg $args {
if {$arg == ""} break
if {![regexp "^\[A-Za-z0-9]*$" $arg]} {
return "Not a valid setting: $arg"
}
append key "\['$arg']"
}
set code [string map [list %%key%% $key %%dir%% [registry get repositories.operations.mediawiki-config]] $wikimedia::get_config_script]
exec_php $code
}
# Executes inline PHP code
#
# @param code The PHP code to execute
# @return the script stdout
proc exec_php {code} {
string trim [exec -- echo $code | php]
}
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Thu, Dec 26, 01:08 (5 h, 6 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2314350
Default Alt Text
(2 KB)
Attached To
Mode
rVIPER ViperServ scripts
Attached
Detach File
Event Timeline
Log In to Comment