Changeset 35 for trunk/manage-us3-pipe.php
- Timestamp:
- Apr 8, 2018, 4:41:57 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/manage-us3-pipe.php
r26 r35 55 55 56 56 // We need the gfacID 57 $resource = mysql _connect( $dbhost, $user, $passwd);57 $resource = mysqli_connect( $dbhost, $user, $passwd, $db ); 58 58 59 59 if ( ! $resource ) 60 60 { 61 write_log( "$self process(): Could not connect to MySQL - " . mysql _error() );61 write_log( "$self process(): Could not connect to MySQL - " . mysqli_error($resource) ); 62 62 write_log( "$self process(): original msg - $msg" ); 63 63 return; 64 }65 66 if ( ! mysql_select_db( $db, $resource ) )67 {68 write_log( "$self: Could not select DB $db " . mysql_error( $resource ) );69 write_log( "$self process(): original msg - $msg" );70 return;71 64 } 72 65 … … 76 69 "LIMIT 1"; 77 70 78 $result = mysql _query( $query, $resource);71 $result = mysqli_query( $resource, $query ); 79 72 80 73 if ( ! $result ) … … 86 79 87 80 // Set flags for Airavata/Thrift and "Finished..." 88 list( $gfacID ) = mysql _fetch_row( $result );89 mysql _close( $resource );81 list( $gfacID ) = mysqli_fetch_row( $result ); 82 mysqli_close( $resource ); 90 83 91 84 $is_athrift = preg_match( "/^US3-A/i", $gfacID ); … … 164 157 global $self; 165 158 166 $resource = mysql _connect( $dbhost, $user, $passwd);159 $resource = mysqli_connect( $dbhost, $user, $passwd, $db ); 167 160 168 161 if ( ! $resource ) 169 162 { 170 write_log( "$self: Could not connect to DB" ); 171 return; 172 } 173 174 if ( ! mysql_select_db( $db, $resource ) ) 175 { 176 write_log( "$self: Could not select DB $db " . mysql_error( $resource ) ); 163 write_log( "$self: Could not connect to DB $db " . mysqli_error( $resource ) ); 177 164 return; 178 165 } … … 183 170 "LIMIT 1"; 184 171 185 $result = mysql _query( $query, $resource);172 $result = mysqli_query( $resource, $query ); 186 173 187 174 if ( ! $result ) … … 191 178 } 192 179 193 list( $resultID ) = mysql _fetch_row( $result );180 list( $resultID ) = mysqli_fetch_row( $result ); 194 181 195 182 $query = "UPDATE HPCAnalysisResult SET "; … … 219 206 } 220 207 221 $query .= "lastMessage='" . mysql _real_escape_string($message ) . "'" .208 $query .= "lastMessage='" . mysqli_real_escape_string( $resource, $message ) . "'" . 222 209 "WHERE HPCAnalysisResultID=$resultID"; 223 210 224 mysql _query( $query, $resource);225 mysql _close( $resource );211 mysqli_query( $resource, $query ); 212 mysqli_close( $resource ); 226 213 } 227 214 … … 242 229 243 230 // Get data from global GFAC DB 244 $gLink = mysql _connect( $dbhost, $guser, $gpasswd);245 if ( ! mysql_select_db( $gDB, $gLink ))246 { 247 write_log( "$self: Could not select DB $gDB " . mysql _error( $gLink ) );231 $gLink = mysqli_connect( $dbhost, $guser, $gpasswd, $gDB ); 232 if ( ! $gLink ) 233 { 234 write_log( "$self: Could not select DB $gDB " . mysqli_error( $gLink ) ); 248 235 return; 249 236 } … … 260 247 { 261 248 $query = "UPDATE analysis " . 262 "SET queue_msg='" . mysql _real_escape_string($message ) . "' " .249 "SET queue_msg='" . mysqli_real_escape_string( $gLink, $message ) . "' " . 263 250 "WHERE gfacID='$gfacID'"; 264 251 265 252 //write_log( "$self process(): updgf-u : status=$status" ); 266 mysql _query( $query, $gLink);253 mysqli_query( $gLink, $query ); 267 254 } 268 255 … … 270 257 { 271 258 $query = "UPDATE analysis SET status='$status', " . 272 "queue_msg='" . mysql _real_escape_string($message ) . "' " .259 "queue_msg='" . mysqli_real_escape_string( $gLink, $message ) . "' " . 273 260 "WHERE gfacID='$gfacID'"; 274 261 275 262 //write_log( "$self process(): updgf-s : status=$status" ); 276 mysql _query( $query, $gLink);263 mysqli_query( $gLink, $query ); 277 264 } 278 265 … … 280 267 $query = "SELECT id FROM analysis " . 281 268 "WHERE gfacID = '$gfacID'"; 282 $result = mysql _query( $query, $gLink);269 $result = mysqli_query( $gLink, $query ); 283 270 if ( ! $result ) 284 271 { 285 write_log( "$self: bad query: $query " . mysql _error( $gLink ) );286 return; 287 } 288 289 if ( mysql _num_rows( $result ) == 0 )272 write_log( "$self: bad query: $query " . mysqli_error( $gLink ) ); 273 return; 274 } 275 276 if ( mysqli_num_rows( $result ) == 0 ) 290 277 { 291 278 write_log( "$self: can't find $gfacID in GFAC db" ); … … 293 280 } 294 281 295 list( $aID ) = mysql _fetch_array( $result );282 list( $aID ) = mysqli_fetch_array( $result ); 296 283 297 284 $query = "INSERT INTO queue_messages " . 298 285 "SET analysisID = $aID, " . 299 "message = '" . mysql _real_escape_string($message ) . "'";300 $result = mysql _query( $query, $gLink);286 "message = '" . mysqli_real_escape_string( $gLink, $message ) . "'"; 287 $result = mysqli_query( $gLink, $query ); 301 288 if ( ! $result ) 302 289 { 303 write_log( "$self: bad query: $query " . mysql _error( $gLink ) );304 return; 305 } 306 307 mysql _close( $gLink );290 write_log( "$self: bad query: $query " . mysqli_error( $gLink ) ); 291 return; 292 } 293 294 mysqli_close( $gLink ); 308 295 } 309 296 … … 353 340 354 341 // Get data from global GFAC DB 355 $gLink = mysql _connect( $dbhost, $guser, $gpasswd);356 if ( ! mysql_select_db( $gDB, $gLink ))357 { 358 write_log( "$self: Could not select DB $gDB " . mysql_error( $gLink ) );342 $gLink = mysqli_connect( $dbhost, $guser, $gpasswd, $gDB ); 343 if ( ! $gLink ) 344 { 345 write_log( "$self: Could not connect to DB $gDB " . mysqli_error( $gLink ) ); 359 346 return; 360 347 } … … 362 349 // Update message and update status to 'FINISHED' 363 350 $query = "UPDATE analysis SET status='FINISHED', " . 364 "queue_msg='" . mysql _real_escape_string($message ) . "' " .351 "queue_msg='" . mysqli_real_escape_string( $gLink, $message ) . "' " . 365 352 "WHERE gfacID='$gfacID'"; 366 353 367 mysql _query( $query, $gLink);354 mysqli_query( $gLink, $query ); 368 355 write_log( "$self: Status FINISHED and 'Finished...' message updated" ); 369 356 … … 371 358 $query = "SELECT id FROM analysis " . 372 359 "WHERE gfacID = '$gfacID'"; 373 $result = mysql _query( $query, $gLink);360 $result = mysqli_query( $gLink, $query ); 374 361 if ( ! $result ) 375 362 { 376 write_log( "$self: bad query: $query " . mysql _error( $gLink ) );377 return; 378 } 379 380 if ( mysql _num_rows( $result ) == 0 )363 write_log( "$self: bad query: $query " . mysqli_error( $gLink ) ); 364 return; 365 } 366 367 if ( mysqli_num_rows( $result ) == 0 ) 381 368 { 382 369 // write_log( "$self: can't find $gfacID in GFAC db" ); … … 384 371 } 385 372 386 list( $aID ) = mysql _fetch_array( $result );373 list( $aID ) = mysqli_fetch_array( $result ); 387 374 388 375 $query = "INSERT INTO queue_messages " . 389 376 "SET analysisID = $aID, " . 390 "message = '" . mysql _real_escape_string($message ) . "'";391 $result = mysql _query( $query, $gLink);377 "message = '" . mysqli_real_escape_string( $gLink, $message ) . "'"; 378 $result = mysqli_query( $gLink, $query ); 392 379 if ( ! $result ) 393 380 { 394 write_log( "$self: bad query: $query " . mysql _error( $gLink ) );395 return; 396 } 397 398 mysql _close( $gLink );381 write_log( "$self: bad query: $query " . mysqli_error( $gLink ) ); 382 return; 383 } 384 385 mysqli_close( $gLink ); 399 386 } 400 387 ?>
Note:
See TracChangeset
for help on using the changeset viewer.