$result = mysql_query($sql) or $done = false; $hex = ""; while ($row = mysql_fetch_array($result)) { $hex = $row['color']; } $sql = $QUERIES->insertPerson($_REQUEST['people_id'], $_SESSION['frame_id'], $_SESSION['camera_id'], $bb->x, $bb->y, $bb->width, $bb->height, $bbV->x, $bbV->y, $bbV->width, $bbV->height, 'null', 'null', 'null', 'null', $hex, 0, $_SESSION['user'], 0); $result = mysql_query($sql) or $done = false; if ($done) { $person = array("id" => $_REQUEST["people_id"], "color" => $hex, "angle_face" => null, "angle_face_z" => null, "angle_body" => null, "angle_body_z" => null, "group" => 0, "artwork" => 0, "prev_frame" => true, "bb" => array($bb->x, $bb->y, $bb->width, $bb->height), "bbV" => array($bbV->x, $bbV->y, $bbV->width, $bbV->height)); } } else { //Generate random HEX color $hex = getRandomColorHEX(); $sql = $QUERIES->insertGroup(0, 'No group', 0, $_SESSION['user']); $result = mysql_query($sql); $sql = $QUERIES->insertAvatar(0, 0, $config->realPeopleDefaultImg); $result = mysql_query($sql) or $done = false; if ($done) { $my_id = mysql_insert_id(); $sql = $QUERIES->insertPerson($my_id, $_SESSION['frame_id'], $_SESSION['camera_id'], $bb->x, $bb->y, $bb->width, $bb->height, $bbV->x, $bbV->y, $bbV->width, $bbV->height, 'null', 'null', 'null', 'null', $hex, 0, $_SESSION['user'], 0); $result = mysql_query($sql) or $done = false; if ($done) { $person = array("id" => $my_id, "color" => $hex, "angle_face" => null, "angle_face_z" => null, "angle_body" => null, "angle_body_z" => null, "group" => 0, "artwork" => 0, "prev_frame" => true, "bb" => array($bb->x, $bb->y, $bb->width, $bb->height), "bbV" => array($bbV->x, $bbV->y, $bbV->width, $bbV->height)); } } } //Econding person to json jecho($person); break; /** * Updates person attributes