| 1 | <?php |
| 2 | |
| 3 | switch ($_POST['event']) { |
| 4 | case 'pridaj dennik': |
| 5 | $status=eventz::addJournaux(); |
| 6 | if ($status) { |
| 7 | Header("Location:".SCRIPT."?action=journaux"); |
| 8 | } |
| 9 | |
| 10 | break; |
| 11 | |
| 12 | case 'zmaz dennik': |
| 13 | $status=eventz::deleteJournaux(); |
| 14 | if ($status) { |
| 15 | Header("Location:".SCRIPT."?action=journaux"); |
| 16 | } |
| 17 | |
| 18 | break; |
| 19 | } |
| 20 | |
| 21 | class eventz { |
| 22 | |
| 23 | function addJournaux() { |
| 24 | |
| 25 | global $kyberia; |
| 26 | global $user_id; |
| 27 | global $user_name; |
| 28 | $dennik_text=$_POST['dennik_text']; |
| 29 | $type=$_POST['type']; |
| 30 | $nadpis=$_POST['dennik_title']; |
| 31 | $journaux_access=$_POST['journaux_access']; |
| 32 | |
| 33 | if (empty($nadpis)) { |
| 34 | $error="musis zadat nazov denniku"; |
| 35 | return false; |
| 36 | } |
| 37 | |
| 38 | elseif (empty($dennik_text)) { |
| 39 | $error="dennik je prazdny"; |
| 40 | return false; |
| 41 | } |
| 42 | |
| 43 | |
| 44 | else { |
| 45 | $dennik_text = EregI_Replace("((( )|(\n)|(^))+)(http://|ftp://|https://)([[:alnum:]][^,[:space:]]*)","\\2<a target='_blank' href=\"\\6\\7\">\\6\\7</a>",$dennik_text); |
| 46 | $dennik_text=strip_tags($dennik_text,'<a><b><i><u><img><br><p><font>'); |
| 47 | $dennik_text=str_replace("\n","<br>",$dennik_text); |
| 48 | $dennik_text=addslashes($dennik_text); |
| 49 | |
| 50 | $result=$kyberia->query("insert into dennik set autor='$user_id',zapis='$dennik_text',nadpis='$nadpis',datum=NOW(),type='$type'"); |
| 51 | $journaux_id=$kyberia->getLastInsertId(); |
| 52 | |
| 53 | $q="select friends.* from friends where friend_id='$user_id'"; |
| 54 | $set=$kyberia->query($q); |
| 55 | while($set->next()){ |
| 56 | $send_bin=$set->getString('send_mail'); |
| 57 | $u_id=$set->getString('user_id'); |
| 58 | $s_forum=floor($send_bin/2); |
| 59 | $pp=$send_bin%2; |
| 60 | $s_journaux=floor($pp/1); |
| 61 | if ($s_journaux){ |
| 62 | $sprava="<b>".$user_name."</b> napisal novy dennik s nazvom <br>\"<a href='?action=journaux&node_id=$journaux_id' target='_blank'>".$nadpis."</a>\""; |
| 63 | $kyberia->ubikMail($u_id,$sprava); |
| 64 | |
| 65 | } |
| 66 | |
| 67 | } |
| 68 | |
| 69 | } |
| 70 | |
| 71 | if (!empty($journaux_access) and $type=="private") { |
| 72 | $access=explode(";",$journaux_access); |
| 73 | foreach($access as $user_access) { |
| 74 | $q="select id from user where login like '%$user_access%'"; |
| 75 | $set=$kyberia->query($q); |
| 76 | $set->next(); |
| 77 | $access_id=$set->getString('id'); |
| 78 | if ($access_id) { |
| 79 | $q="insert into node_access set user_id='$access_id',node_id='$journaux_id',node_type='journaux',access_type='access'"; |
| 80 | $kyberia->query($q); |
| 81 | } |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | |
| 86 | } |
| 87 | |
| 88 | function deleteJournaux() { |
| 89 | global $kyberia; |
| 90 | global $user_id; |
| 91 | global $user_name; |
| 92 | $journaux_id=$_POST['journaux_id']; |
| 93 | |
| 94 | $kyberia->update("delete from dennik where autor='$user_id' and id='$journaux_id'"); |
| 95 | } |
| 96 | |
| 97 | } |