Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- #init :D
- $branch_full = explode("//",$_POST["ref"]);
- $branch = $branch_full[sizeof($branch_full) -1];
- $messages = $_POST["messages"];
- $project_PWD = explode("//", $_POST["folder"]);
- $project = str_replace(".git", "", $project_PWD[sizeOf($project_PWD) -1]);
- #setting up the connection
- $dbconn = pg_connect("host=localhost dbname=SunBird user=commitAdd")
- or die('Could not connect: ' . pg_last_error()); #password=foo
- $query_begining = "INSERT INTO commits VALUES (";
- $query_ending = ");";
- $values = getMessages($messages);
- for ( $i = 1; $i < sizeof($values); $i++)
- {
- pg_send_query($dbconn, $query_begining."\'".$project."\',\'".$branch."\',\'".$values[$i]);
- }
- pg_close($dbconn);
- function getMessages($msg)
- {
- $msgs = explode("Author:", $msg);
- $count = 0;
- $retur = array();
- foreach($msgs as $Msg)
- {
- $tmpLines = explode('\n', $Msg);
- $tmp = "\'".str_replace("commit ", "", $tmpLines[0])."\'".",\'".str_replace("Author: ", "", $tmpLines[1])."\'".",\'".str_replace("Date: ", "", $tmpLines[2])."\'".",\'";
- $tmp2 = "";
- for( $i = 3; $i < sizeOf(tmpLines); $i++)
- {
- $tmp2 .= str_replace("\n", "<br />", $tmpLines[i]);
- }
- $retur[$count] = $tmp.$tmp2."\'";
- $count += 1;
- }
- return $retur;
- }
- function beginsWith($str, $sub) {
- return (strncmp($str, $sub, strlen($sub)) == 0);
- }
- ?>
Add Comment
Please, Sign In to add comment