Changeset 464 for trunk/web/addons
- Timestamp:
- 02/20/08 16:42:41 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/web/addons/job_monarch/libtoga.php
r463 r464 126 126 } 127 127 128 /**129 * Replace stripos()130 *131 * @category PHP132 * @package PHP_Compat133 * @link http://php.net/function.stripos134 * @author Aidan Lister <aidan@php.net>135 * @version $Revision: 1.1.1.1 $136 * @since PHP 5137 * @require PHP 4.0.1 (trigger_error)138 */139 if (!function_exists('stripos'))140 {141 function stripos ($haystack, $needle, $offset = null)142 {143 if (!is_scalar($haystack)) {144 trigger_error('stripos() expects parameter 1 to be string, ' . gettype($haystack) . ' given', E_USER_WARNING);145 return false;146 }147 148 if (!is_scalar($needle)) {149 trigger_error('stripos() needle is not a string or an integer.', E_USER_WARNING);150 return false;151 }152 153 if (!is_null($offset) && !is_numeric($offset)) {154 trigger_error('stripos() expects parameter 3 to be long, ' . gettype($offset) . ' given', E_USER_WARNING);155 return false;156 }157 158 // Manipulate the string if there is an offset159 $fix = 0;160 if (!is_null($offset))161 {162 if ($offset > 0)163 {164 $haystack = substr($haystack, $offset, strlen($haystack) - $offset);165 $fix = $offset;166 }167 }168 169 $segments = explode (strtolower($needle), strtolower($haystack), 2);170 $position = strlen($segments[0]) + $fix;171 172 return $position;173 }174 }175 176 128 class TarchDbase { 177 129 … … 1241 1193 $y_present = false; 1242 1194 1243 if(stripos( $SORTBY_HOSTNAME, "{x}" ) != false ) 1244 { 1195 // Should we scan by X, Y or both 1196 // 1197 if(strpos( $SORTBY_HOSTNAME, "{x}" ) != false ) 1198 { 1199 $x_str = "{x}"; 1245 1200 $x_present = true; 1246 1201 } 1247 if(stripos( $SORTBY_HOSTNAME, "{y}" ) != false ) 1248 { 1202 else if(strpos( $SORTBY_HOSTNAME, "{X}" ) != false ) 1203 { 1204 $x_str = "{X}"; 1205 $x_present = true; 1206 } 1207 if(strpos( $SORTBY_HOSTNAME, "{y}" ) != false ) 1208 { 1209 $y_str = "{y}"; 1249 1210 $y_present = true; 1250 1211 } 1251 1252 if(( strpos( $SORTBY_HOSTNAME, "{x}" ) < strpos( $SORTBY_HOSTNAME, "{y}" ) ) && ( $x_present && $y_present )) 1212 else if(strpos( $SORTBY_HOSTNAME, "{Y}" ) != false ) 1213 { 1214 $y_str = "{Y}"; 1215 $y_present = true; 1216 } 1217 1218 // If we should scan for both X and Y: see which one is first 1219 // 1220 if(( strpos( $SORTBY_HOSTNAME, $x_str ) < strpos( $SORTBY_HOSTNAME, $y_str ) ) && ( $x_present && $y_present )) 1253 1221 { 1254 1222 1255 1223 $x_first = 1; 1256 1224 } 1257 else if(( strpos( $SORTBY_HOSTNAME, "{x}" ) > strpos( $SORTBY_HOSTNAME, "{y}") ) && ( $x_present && $y_present ))1225 else if(( strpos( $SORTBY_HOSTNAME, $x_str ) > strpos( $SORTBY_HOSTNAME, $y_str ) ) && ( $x_present && $y_present )) 1258 1226 { 1259 1227 $y_first = 1; … … 1269 1237 } 1270 1238 1239 // Now replace our {x} and {y} with %d for sscanf parsing 1240 // 1271 1241 if(( $x_first ) && ( $x_present && $y_present ) ) 1272 1242 { 1273 $skan_str = str_replace( "{x}", "%d", $skan_str );1274 $skan_str = str_replace( "{y}", "%d", $skan_str );1243 $skan_str = str_replace( $x_str, "%d", $skan_str ); 1244 $skan_str = str_replace( $y_str, "%d", $skan_str ); 1275 1245 } 1276 1246 else if( $x_present) 1277 1247 { 1278 $skan_str = str_replace( "{x}", "%d", $skan_str );1248 $skan_str = str_replace( $x_str, "%d", $skan_str ); 1279 1249 } 1280 1250 else if( $y_present) 1281 1251 { 1282 $skan_str = str_replace( "{y}", "%d", $skan_str );1252 $skan_str = str_replace( $y_str, "%d", $skan_str ); 1283 1253 } 1284 1254 … … 1288 1258 $y_max = null; 1289 1259 1260 // Now let's walk through all our nodes and see which one are valid for our scan pattern 1261 // 1290 1262 foreach( $nodes as $hostname => $node ) 1291 1263 {
Note: See TracChangeset
for help on using the changeset viewer.