@@ -42,6 +42,19 @@ class SerialMessageExchanger extends Plugin implements IMessageExchanger
42
42
private $ channels ;
43
43
private $ clientsGCTime = 10 ;
44
44
45
+ /**
46
+ * Windows-ify channel name to avoid forbidden characters
47
+ * @param $channelName
48
+ * @return mixed
49
+ */
50
+ protected function channelNameToFileName ($ channelName ){
51
+ if (strtoupper (substr (PHP_OS , 0 , 3 )) === 'WIN ' ){
52
+ return str_replace (array (": " , "* " ), array ("--- " , "__ALL__ " ), $ channelName );
53
+ }else {
54
+ return $ channelName ;
55
+ }
56
+ }
57
+
45
58
/**
46
59
* @param $channelName
47
60
* @param bool $create
@@ -54,7 +67,7 @@ public function loadChannel($channelName, $create = false)
54
67
}
55
68
if (is_file ($ this ->getPluginWorkDir ()."/queues/channel- $ channelName " )) {
56
69
if (!isset ($ this ->channels )) $ this ->channels = array ();
57
- $ data = FileHelper::loadSerialFile ($ this ->getPluginWorkDir () . "/queues/channel- $ channelName" );
70
+ $ data = FileHelper::loadSerialFile ($ this ->getPluginWorkDir () . "/queues/channel- " . $ this -> channelNameToFileName ( $ channelName) );
58
71
if (is_array ($ data )) {
59
72
if (!is_array ($ data ["MESSAGES " ])) $ data ["MESSAGES " ] = array ();
60
73
if (!is_array ($ data ["CLIENTS " ])) $ data ["CLIENTS " ] = array ();
@@ -74,7 +87,7 @@ public function __destruct()
74
87
if (isSet ($ this ->channels ) && is_array ($ this ->channels )) {
75
88
foreach ($ this ->channels as $ channelName => $ data ) {
76
89
if (is_array ($ data )) {
77
- FileHelper::saveSerialFile ($ this ->getPluginWorkDir () . "/queues/channel- $ channelName" , $ data );
90
+ FileHelper::saveSerialFile ($ this ->getPluginWorkDir () . "/queues/channel- " . $ this -> channelNameToFileName ( $ channelName) , $ data );
78
91
}
79
92
}
80
93
}
0 commit comments