api_client->stream_publish($message); global $current_user; get_currentuserinfo(); /* check if user has connected accounts */ $queryifisconnected = mysql_query('SELECT * FROM wp_usermeta WHERE user_id="'.$current_user->ID.'" AND meta_key="fbuid"') or die(mysql_error()); if(mysql_num_rows($queryifisconnected)!=0){ $row3 = mysql_fetch_array($queryifisconnected); $id = $row3['meta_value']; } /* end of checking if user has connected accounts */ //$pageURL = $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; //$url = explode("/", $pageURL); //$serverurl = $url[0].'/'.$url[1]; $address = get_bloginfo('url').'/wp-content/themes/default/images/userdog'; /* adding dog into a database + form validating*/ $echo = ''; $dognameclass = 'dog-field'; $dogweightclass = 'dog-field'; $dogbreedclass = 'dog-field'; $dogageclass = 'dog-field'; if($_POST['add-dog']){ $dogname = $_POST['dog-name']; $dogweight = $_POST['dog-weight']; $dogbreed = $_POST['dog-breed']; $dogage = $_POST['dog-age']; $dogpregnant = $_POST['dog-pregnant']; $showcv = $_POST['show-cv']; $validate=1; if($dogpregnant=='on'){ $checked = 'checked'; $dogpregnant = 1; } if($dogname==''){$dognameclass = 'dog-field-error"'; $echo .= '
Nime väli tühi!
'; $validate=0;} $dogweight = str_replace(',','.',$dogweight); if($dogweight=='' || !is_numeric($dogweight)){$dogweightclass = 'dog-field-error'; $echo .= '
Kaalu väli on tühi või ei koosne numbritest!
'; $validate=0;} if($dogbreed==''){$dogbreedclass = 'dog-field-error'; $echo .= '
Koeratõu väli tühi!
'; $validate=0;} if($dogage=='' || !preg_match("/([0-2][0-9]|[0-3][0-1])\/([1][0-2]|[0][0-9])\/([0-9][0-9][0-9][0-9])/i", $dogage)){$dogageclass = 'dog-field-error'; $echo .= '
Koera sünnipäev valimata või vale formaat!
'; $validate=0;} if($dogname!='' && $dogweight!='' && $dogbreed!='' && $dogage!='' && $validate==1){ $dogage = strtotime($dogage); $querybreed = mysql_query('SELECT * FROM wp_dog_breed WHERE breed="'.$dogbreed.'" LIMIT 1'); if(mysql_num_rows($querybreed)!=0){ $row = mysql_fetch_array($querybreed); $breedid = $row['id']; } else { mysql_query('INSERT INTO wp_dog_breed SET breed="'.$dogbreed.'"') or die(mysql_error()); $querybreed = mysql_query('SELECT * FROM wp_dog_breed WHERE breed="'.$dogbreed.'" LIMIT 1'); $row = mysql_fetch_array($querybreed); $breedid = $row['id']; } mysql_query('INSERT INTO wp_dog_base SET fbuid="'.$id.'", owners_id="'.$current_user->ID.'", dog_name="'.$dogname.'", dog_weight="'.$dogweight.'", dog_breed="'.$breedid.'", dog_age="'.$dogage.'", dog_pregnant="'.$dogpregnant.'", date_added="'.time().'"') or die(mysql_error()); $echo .= 'Teie koer on lisatud meie andmebaasi!'; } } /* end of adding dog into a database + form validating*/ if($_GET['user']==$current_user->user_nicename || $current_user->user_nicename!='' && $_GET['user']==''){ $userid = $current_user->ID; $iscurrent = 'yes'; } else { $queryuser = mysql_query('SELECT * FROM wp_users WHERE user_nicename="'.$_GET['user'].'" LIMIT 1'); if(mysql_num_rows($queryuser)!=0){ $row = mysql_fetch_array($queryuser); $userid = $row['ID']; } } if($_POST['update-dog-data']){ $dogage = strtotime($_POST['dog-age']); $dogpregnant = $_POST['dog-pregnant']; $showcv = $_POST['show-cv']; if($dogpregnant=='on'){ $dogpregnant=1; } else { $dogpregnant=0; } if($showcv=='on'){ $showcv=1; } else { $showcv=0; } $microchip = $_POST['microchip']; $allergies = $_POST['allergies']; $nutritioninfo = $_POST['nutrition-info']; if($nutritioninfo==''){$nutritioninfo=0;} mysql_query('UPDATE wp_dog_base SET dog_name="'.$_POST['dog-name'].'", dog_weight='.$_POST['dog-weight'].', dog_pregnant='.$dogpregnant.', microchip="'.$microchip.'", allergies="'.$allergies.'", nutrition_info="'.$nutritioninfo.'", vaccine="'.$_POST['vaccine'].'", sex="'.$_POST['sex'].'", location="'.$_POST['location'].'", lifestyle="'.$_POST['lifestyle'].'", description="'.$_POST['description'].'", color="'.$_POST['color'].'", owners_address="'.$_POST['owners-address'].'", show_cv='.$showcv.', dog_age="'.$dogage.'" WHERE id='.$_POST['dog-id'].'') or die(mysql_error()); } if($_POST['delete-dog-data']){ $querydogpicture = mysql_query('SELECT dog_picture FROM wp_dog_base WHERE id='.$_POST['dog-id'].''); $row = mysql_fetch_array($querydogpicture); if($row['dog_picture']!=''){ unlink('wp-content/themes/default/images/userdog/'.$row['dog_picture']); } mysql_query('DELETE FROM wp_dog_base WHERE id='.$_POST['dog-id'].'') or die(mysql_error()); mysql_query('DELETE FROM wp_dog_events WHERE id='.$_POST['dog-id'].'') or die(mysql_error()); } if($_GET['action']=='delete-event'){ mysql_query('DELETE FROM wp_dog_events WHERE id='.$_GET['id'].'') or die(mysql_error()); } if($_POST['insert-event']){ $validate=1; if($_POST['event-date']=='' || !preg_match("/([0-2][0-9]|[0-3][0-1])\/([1][0-2]|[0][0-9])\/([0-9][0-9][0-9][0-9])/i", $_POST['event-date'])){$echo2 .= '
Viga ürituse kuupäevas!
';$validate=0;} $dogid = $_POST['dog-id']; $event = $_POST['dog-event']; $eventdesc = $_POST['dog-event-desc']; if($event==''){$echo2 .= '
Ürituse nimi puudub!
';$validate=0;} if($eventdesc==''){$echo2 .= '
Ürituse kirjeldus puudub!
';$validate=0;} if($validate==1){ $eventdate = str_replace('/','.',$_POST['event-date']); $eventdate = strtotime($eventdate); mysql_query('INSERT INTO wp_dog_events SET dog_id="'.$dogid.'", event="'.$event.'", event_description="'.$eventdesc.'", event_date="'.$eventdate.'", date_added="'.time().'"') or die(mysql_error()); } } /* picture measures */ function measures($pilt){ $max = 150; list($width, $height) = getimagesize($pilt); if($width > $max or $height > $max){ if($width > $height){ $height = round(($max/$width)*$height); $width = $max; }elseif($width < $height){ $width = round(($max/$height)*$width); $height = $max; }else{ $width = $max; $height = $max; } } return 'width = "'.$width.'" height = "'.$height.'"'; } /* end of picture measures */ get_header(); ?>
nickname!=''){ ?> ID.' ja minu FB id on '.$current_user->fbuid.'


'; echo '

Halda oma koeri

'; ?>
id="add-dog">

Lisa koer





 


kg


pp/kk/aaaa

või tühista

Muuda olemasolevate koerte andmeid


'; } /*koera pilt*/ echo '
'; if($row['dog_picture']==''){ echo '
'; if($iscurrent=='yes'){ echo '
lae pilt
'; } } else { echo '
'; if($iscurrent=='yes'){ echo ' '; } else { echo ''.$row['dog_name'].''; } } echo '
'; /*koera nimi*/ if($iscurrent=='yes'){ echo ''; } else { echo $row['dog_name']; } echo '

'; /*koera tõug*/ if($iscurrent=='yes'){ echo ''; } else { echo $row['breed']; } echo '

'; /*koera vanus*/ $agestamp = time()-$row['dog_age']; if($iscurrent=='yes'){ echo ' ('.ceil($agestamp/60/60/24/365).' a.)'; } else { echo date('d.m.Y',$row['dog_age']).' ('.ceil($agestamp/60/60/24/365).' a.)'; } echo '

'; /*koera kaal*/ echo '
Kaal:
'; if($iscurrent=='yes'){ echo ''; } else { echo $row['dog_weight']; } echo ' kg
'; /*koera mikrokiip*/ if($row['microchip']!='' || $iscurrent!=''){ echo '
Mikrokiip:
'; if($iscurrent=='yes'){ echo ''; } else { echo $row['microchip']; } echo '
'; } /*koera allergia*/ if($row['allergies']!='' || $iscurrent!=''){ echo '
Allergiate info:
'; if($iscurrent=='yes'){ echo ''; } else { echo $row['allergies']; } echo '
'; } /*koera toidualane info*/ if($row['nutrition_info']!='' || $iscurrent!=''){ echo '
Toitumislaane teave:
'; if($iscurrent=='yes'){ echo ''; } else { echo $row['nutrition_info']; } echo '
'; } /*koera vaktsiin*/ if($row['vaccine']!='' || $iscurrent!=''){ echo '
Vaktsineerimiste info:
'; if($iscurrent=='yes'){ echo ''; } else { echo $row['vaccine']; } echo '
'; } /*koera sugu*/ if($row['sex']!='' || $iscurrent!=''){ echo '
Sugu:
'; if($row['sex']=='Isane'){ $malecheck='selected'; } elseif($row['sex']=='Emane'){ $femalecheck='selected'; } else { $nosexcheck='selected'; } if($iscurrent=='yes'){ echo ''; } else { echo $row['location']; } echo '
'; } /*koera eluviis*/ if($row['lifestyle']!='' || $iscurrent!=''){ echo '
Eluviis:
'; if($iscurrent=='yes'){ echo ''; } else { echo $row['lifestyle']; } echo '
'; } /*koera lühikirjeldus*/ if($row['description']!='' || $iscurrent!=''){ echo '
Lühikirjeldus:
'; if($iscurrent=='yes'){ echo ''; } else { echo $row['descrition']; } echo '
'; } /*koera värvus*/ if($row['color']!='' || $iscurrent!=''){ echo '
Värvus:
'; if($iscurrent=='yes'){ echo ''; } else { echo $row['color']; } echo '
'; } /*koera tiinus*/ if($row['dog_pregnant']==1){ echo '
Tiine:
'; if($iscurrent=='yes'){ echo ''; } else { echo 'Jah'; } echo '
'; } else { echo '
Tiine:
'; if($iscurrent=='yes'){ echo ''; } else { echo 'Ei'; } echo '
'; } /*koera omaniku nimi*/ $queryownername = mysql_query('SELECT * FROM wp_dog_base AS wdb INNER JOIN wp_users AS wu ON wu.ID='.$row['owners_id'].' LIMIT 1'); $rowname = mysql_fetch_array($queryownername); echo '
Omaniku nimi:
'.$rowname['display_name'].'
'; /*koera omaniku aadress*/ if($row['owners_address']!='' || $iscurrent!=''){ echo '
Omaniku aadress:
'; if($iscurrent=='yes'){ echo ''; } else { echo $row['owners_address']; } echo '
'; } /*koera cv ligipääs*/ if($row['show_cv']==1){ echo '
Näitan seda CV-d:
'; if($iscurrent=='yes'){ echo ''; } echo '
'; } else { echo '
Näitan seda CV-d:
'; if($iscurrent=='yes'){ echo ''; } echo '
'; } echo '

Koera saavutused

'; $querydogevents = mysql_query('SELECT * FROM wp_dog_events WHERE dog_id="'.$row['id'].'" ORDER BY event_date DESC'); if(mysql_num_rows($querydogevents)!=0){ while($row = mysql_fetch_array($querydogevents)){ echo '
Üritus:
'.$row['event'].'
Ürituse lühikirjeldus:
'.$row['event_description'].'
Ürituse toimumise aeg:
'.date('d.m.Y',$row['event_date']).'
'; echo '
'; } } else { echo 'Üritusi ja näitusi pole.
'; } echo '
Lisa uus üritus
Üritus:
Ürituse lühikirjeldus, saavutatud kohad, äramärgitud saavutused:
Kuupäev (pp/kk/aaaa):
'; echo $echo2; if($iscurrent=='yes'){ echo '
'; } echo '
'; $i++; } } else { echo 'Hetkel ei ole te veel ühtegi koera lisanud!'; } } else { echo '

Logige sisse!

'; } ?>