| 1 | <?php |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | |
|---|
| 19 | |
|---|
| 20 | |
|---|
| 21 | |
|---|
| 22 | |
|---|
| 23 | |
|---|
| 24 | |
|---|
| 25 | |
|---|
| 26 | if(is_numeric($token[3])) |
|---|
| 27 | { |
|---|
| 28 | $id_cat = $db->getOne('SELECT id_cat FROM community WHERE id=? AND id_comm=?', array($_SESSION['my_id'], $token[3])); |
|---|
| 29 | |
|---|
| 30 | $community_values = array(); |
|---|
| 31 | |
|---|
| 32 | foreach(array_keys($table_fields['communities']) as $key) |
|---|
| 33 | { |
|---|
| 34 | if(array_key_exists($key, $_POST) ) |
|---|
| 35 | { |
|---|
| 36 | $_POST[$key] = trim($_POST[$key]); |
|---|
| 37 | $value=""; |
|---|
| 38 | if( is_array($_POST[$key]) ) |
|---|
| 39 | $value = implode(",", $_POST[$key]); |
|---|
| 40 | elseif( $_POST[$key] == "(null)" || $_POST[$key] == "" || $_POST[$key] == "http://") |
|---|
| 41 | $value = NULL; |
|---|
| 42 | else |
|---|
| 43 | $value = $_POST[$key]; |
|---|
| 44 | |
|---|
| 45 | if(($key == 'name' || |
|---|
| 46 | $key == 'categorie' || |
|---|
| 47 | $key == 'moderated' || |
|---|
| 48 | $key == 'description' ) && |
|---|
| 49 | is_null($value)) |
|---|
| 50 | { |
|---|
| 51 | header('Location: /error/record_comm'); |
|---|
| 52 | exit(); |
|---|
| 53 | } |
|---|
| 54 | |
|---|
| 55 | if(is_null($value)) |
|---|
| 56 | $community_values[$key] = NULL; |
|---|
| 57 | else |
|---|
| 58 | $community_values[$key] = stripslashes($value); |
|---|
| 59 | |
|---|
| 60 | } |
|---|
| 61 | } |
|---|
| 62 | |
|---|
| 63 | $result =& $db->autoExecute('community', $community_values, DB_AUTOQUERY_UPDATE, "id='".$_SESSION['my_id']."' AND id_comm='".$token[3]."'"); |
|---|
| 64 | if (DB::isError($result)) |
|---|
| 65 | error_log($_SERVER['HTTP_HOST'].' | '.__FILE__.' '.$result->getMessage()); |
|---|
| 66 | elseif($db->affectedRows() == 1) |
|---|
| 67 | { |
|---|
| 68 | $db->query('DELETE FROM community_keyword WHERE id_comm=?', array($token[3])); |
|---|
| 69 | |
|---|
| 70 | $array_description = explode(' ', $community_values['description']); |
|---|
| 71 | $array_name = explode(' ', $community_values['name']); |
|---|
| 72 | |
|---|
| 73 | $array = array_merge($array_description, $array_name); |
|---|
| 74 | |
|---|
| 75 | foreach($array as $elemt) |
|---|
| 76 | { |
|---|
| 77 | $elemt = ereg_replace("(.*)s$", "\\1", $elemt); |
|---|
| 78 | |
|---|
| 79 | if(strlen($elemt)>2) |
|---|
| 80 | { |
|---|
| 81 | $sndx = get_mysql_soundex($elemt); |
|---|
| 82 | $db->query('INSERT INTO community_keyword SET key_sndx=?, id_comm=?, id_cat=?', array($sndx, $token[3], $id_cat)); |
|---|
| 83 | } |
|---|
| 84 | } |
|---|
| 85 | if($id_cat != $community_values['id_cat']) |
|---|
| 86 | { |
|---|
| 87 | $db->query('UPDATE community_cat SET nb_communities=nb_communities-1 WHERE id_cat=?', $id_cat); |
|---|
| 88 | $db->query('UPDATE community_cat SET nb_communities=nb_communities+1 WHERE id_cat=?', $community_values['id_cat']); |
|---|
| 89 | } |
|---|
| 90 | } |
|---|
| 91 | |
|---|
| 92 | |
|---|
| 93 | upload_image($_FILES, 'logo', $_SESSION['my_id'], $token[3], BASEPATH, "/comm_logos", true, "/comm_logos/thumb", array(231,255,189)); |
|---|
| 94 | } |
|---|
| 95 | |
|---|
| 96 | header('Location: /communities/view/'.$token[3]); |
|---|
| 97 | |
|---|
| 98 | ?> |
|---|