function ExtractLog($log) { global $listacts; $i = strpos($log, '-', strpos($log, '-') + 1); if ($i > 0) { $log = trim(substr($log, $i)); } $nboucle = 0; $nactions = 0; while (strlen($log) > 0 && $nboucle < 100000) { $i = strpos($log, 13); if ($i <= 0) { $i = strlen($log); } $tmp = trim(substr($log, 1, $i)); $log = trim(substr($log, $i + 1)); if (!empty($tmp)) { $j = null; foreach ($listacts as $key => $value) { if (strpos($tmp, $value) !== false) { $j = $key; break; } } if (is_null($j)) { pdebug('UNKNOW_ACTION{' . $tmp . '}'); } else { $i = strpos($tmp, $listacts[$j]); switch ($j) { case ACT_DESTROY: // a été détruit $actions[$nactions]['Source'] = trim(substr($tmp, 0, $i - 1)); $actions[$nactions]['Action'] = ACT_DESTROY; break; case ACT_MISS: // a raté son tir $i2 = strlen($listacts[ACT_MISS]); $actions[$nactions]['Source'] = trim(substr($tmp, 0, $i - 1)); $actions[$nactions]['Target'] = trim(substr($tmp, $i + $i2, strlen($tmp) - $i - $i2 - 1)); $actions[$nactions]['Action'] = ACT_MISS; break; case ACT_JOIN: // troupe a rejoint le combat $actions[$nactions]['Source'] = trim(substr($tmp, 10, $i - 10)); $actions[$nactions]['Action'] = ACT_JOIN; break; case ACT_RETREAT: // troupe a fait retraite $actions[$nactions]['Source'] = trim(substr($tmp, 0, $i - 1)); $actions[$nactions]['Action'] = ACT_RETREAT; break; case ACT_HIT: // a touché $actions[$nactions]['Source'] = trim(substr($tmp, 0, $i - 1)); $actions[$nactions]['Action'] = ACT_HIT; $tmp = trim(substr($tmp, $i + strlen($listacts[ACT_HIT]))); $i = strpos($tmp, $listacts[ACT_DAMAGE]); $actions[$nactions]['Target'] = trim(substr($tmp, 0, $i - 1)); $tmp = trim(substr($tmp, $i + strlen($listacts[ACT_DAMAGE]))); $ndam = 0; $nboucle2 = 0; while (strlen($tmp) > 0 && $nboucle2 < 5) { $i = strpos($tmp, ','); if ($i !== false) { $dam[$ndam] = trim(substr($tmp, 0, $i)); $tmp = trim(substr($tmp, $i + 1)); $ndam++; } else { $dam[$ndam] = $tmp; $tmp = ''; $ndam++; } $nboucle2++; } for ($i = 0; $i < $ndam; $i++) { $deg = (int) trim(substr($dam[$i], 0, strpos($dam[$i], $listacts[ACT_DOMAGE]))); if (strpos($dam[$i], $listacts[ACT_STRUCT]) !== false) { $actions[$nactions]['Coque'] = $deg; } elseif (strpos($dam[$i], $listacts[ACT_SHILD]) !== false) { $actions[$nactions]['Bouclier'] = $deg; } else { $actions[$nactions]['Ion'] = $deg; } } break; } $nactions++; } } $nboucle++; } return $actions; }
public function repin($pinId, $boardId, $description) { $query_string = array("access_token" => $this->accessToken); $data = array("board_id" => $board_id, "place" => "", "share_facebook" => "0", "share_twitter" => "0", "description" => $description); $url = "/users/pins/" . $pinId . "/repin/?" . http_build_query($query_string); $response = $this->api("POST", $url, $data); if ($response->status != "success") { pdebug($response->message); return false; } else { if ($response->message == "ok") { return $response; } else { pdebug($response->message); return false; } } }