Anlık Çoklu Resim Yüklemek

index.php dosyası oluşturup jquery kütüphanemizi script tagı ile ekleyin.

Markdown
1 lines
http://code.jquery.com/jquery-1.10.2.js
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

style tagı içerisine bu kodları ekleyin.

CSS
30 lines
.btn {
display: inline-block;
padding: 6px 12px;
margin-bottom: 0;
color: #ffffff;
font-size: 14px;
font-weight: bold;
line-height: 1.428571429;
text-align: center;
white-space: nowrap;
vertical-align: middle;
cursor: pointer;
border: 1px solid transparent;
border-radius: 4px;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
-o-user-select: none;
user-select: none;
}
.btn-add {
color: #ffffff;
background-color: #428bca;
border-color: #357ebd;
}
.btn-add:hover, .btn-add:focus, .btn-add:active, .btn-add.active {
color: #ffffff;
background-color: #3276b1;
border-color: #285e8e;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

script tagı içerisine bu kodları ekleyin.

JavaScript
23 lines
$(document).ready(function(){
//Dosya Yükle
$("#form").bind("submit",function(){
$("#sonuclar").empty();
$(this).attr("target","gelenBilgi");
$("<img />").attr("src","yukleniyor.gif").appendTo($("#sonuclar"));
$("#gelenBilgi").bind("load", function(){
var deger = $("#gelenBilgi").contents().find("body").html();
$("#sonuclar").html(deger);
$("#sonuclar2").val($("#sonuclar img").attr("src"));
});
});
});
var dosya = $("input[name=dosya[]]").val();
var file = "dosya="+dosya;
$.ajax({
type: "POST",
url: "dosyayukle.php",
data: file,
success: function(sonuc){
$("#gelenBilgi").append(sonuc);
}
});
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

istediğiniz bir yere bu kodları ekleyin.

HTML
29 lines
<table class="table">
<tr>
<td>
<strong>Resim:</strong>
</td>
<td>
<form action="dosyayukle.php" method="post" enctype="multipart/form-data" id="form">
<input type="file" style="width:80px;" name="dosya[]" />
<input type="submit" value="Yükle" />
</form>
</td>
<td rowspan="2" align="center">
<iframe id="gelenBilgi" name="gelenBilgi" src style="display:none;">
</iframe>
<div id="sonuclar"></div>
</td>
</tr>
<tr>
<form action="" method="post">
<td colspan="3" >
<iframe id="gelenBilgi" name="gelenBilgi" src style="display:none;">
</iframe>
<input name="resim" id="sonuclar2" ><br>
<input name="update" type="submit" class="btn btn-edit" value="Yüklenen url yi gönder" />
</td>
</form>
</tr>
</table>
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

yukleniyor.gif adlı bir resim oluşturun.

dosyayukle.php adlı bir dosya oluşturun ve içine bu kodları ekleyin.

PHP
29 lines
<?php
function rasgeleharf($kackarakter){
$s="";
$char="abcdefghijklmnoprstuwvyzqx1234567890–__"; /// İzin verilen karakterler ?
for ($k=1;$k<=$kackarakter;$k++){
$h=substr($char,mt_rand(0,strlen($char)-1),1);
$s.=$h;
}
return $s;
}
$toplam = count($_FILES["dosya"]["name"]);
$formatlar = array("image/png","image/jpeg","image/gif","image/bmp");
for($i= 0;$i < $toplam; $i++){
if (in_array($_FILES["dosya"]["type"][$i],$formatlar)){
$uzanti =substr($_FILES["dosya"]["name"][$i],-4,4);
$ad =substr($_FILES["dosya"]["name"][$i],0,-4);
$isim = rasgeleharf(5);
$dizin = "img/".$ad."_".$isim.$uzanti;
if(move_uploaded_file($_FILES["dosya"]["tmp_name"][$i],$dizin)){
echo '<img height="100" src="'.$dizin.'" alt="" class="resim" />';
}else{
echo '<font color="red">Dosya Yüklenemedi!!</form>';
}
}else{
echo '<font color="red">Geçersiz Dosya Formatı.</font>';
}
}
?>
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Son olarak img diye resimlerin saklanacağı bir klasör oluşturun.

Basit sohbet robotu yapmak

index.php dosyası oluşturup jquery kütüphanesini script tagıyla ekleyin

Markdown
1 lines
http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

altına style tagı açarak içerisine bu kodları ekleyin.

CSS
14 lines
.kutu {
background:#eee;
border: 1px solid #ddd;
padding:10px;
margin-bottom:10px;
height:200px;
weight:200px;
}
#sorular {
height:150px;
padding:10px;
overflow:scroll;
overflow-x:hidden;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

altına script tagı açarak içerisine bu kodları ekleyin.

JavaScript
11 lines
function sor() {
var soru = $("#konus :input").val();
if(soru != '') {
$.post("bot.php",$('#konus').serialize(), function(gelen) {
$("#sorular").append("Misafir:"+soru+"<br />Bot:"+gelen+"<br />");
$("#soru").val("");
});
}else{
alert("Birşeyler yazmayı deneyebilirsiniz?");
}
return false; }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

sayfa içerisine istediğiniz yere bu kodları yerleştirin.

HTML
10 lines
<div class="kutu">Sanal Bot ile Konuşun!
<div id="sorular">Bir şeyler yazın;<br /></div>
<form id="konus" name="form1" method="post" action="javascript:void(0);">
<label>
<input name="soru" type="text" id="soru" value="" size="30" />
</label>
<label>
<input type="submit" name="button" id="button" value="Konuş" onclick="sor()"/>
</label>
</form></div>
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

bot.php dosyası oluşturup içine bu kodları ekleyin.

PHP
13 lines
<?php
$soru = htmlspecialchars($_POST["soru"]);
$cevaplar = array("selam"=>"sana da selam","merhaba"=>"merhaba","naber"=>"iyidir senden","iyi"=>"sevindim","sa"=>"as","nasılsın?"=>"teşekkürler siz?","adın ne"=>"yapay zeka");
$anlamadim = array("anlayamadım?","afedersiniz?","bu konuyu bilmiyorum");
$sonuc=array_key_exists($_POST["soru"],$cevaplar);
if($sonuc){
die($cevaplar[$_POST["soru"]]);
}else{
echo $anlamadim[rand(0,count($anlamadim)-1)];
}
?>
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

 

Stackoverflow Tarzı Aynı Etiketleri Sayarak Yazdırmak

Öncelikle tags isimli bir veritabanınızın olması ve içinde name adlı sütun bulunması gereklidir.

CSS
13 lines
.tag a{
color: #3e6d8e;
background-color: #e0eaf1;
border-bottom: 1px solid #b3cee1;
border-right: 1px solid #b3cee1;
padding: 3px 4px 3px 4px;
margin: 2px 2px 2px 0;
text-decoration: none;
font-size: 90%;
line-height: 1.4;
white-space: nowrap;
display: inline-block;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
PHP
32 lines
<?php header('Content-Type: text/html; charset=utf-8');
$dbhost = "localhost";
$dbkullanici= "root";
$dbsifre = "";
$dbname = "test";
$baglan = mysql_connect($dbhost, $dbkullanici, $dbsifre);
mysql_select_db($dbname, $baglan);
mysql_query("SET NAMES 'utf8'");
$result = mysql_query("select name from tags");
$tags = array();
while ($row = mysql_fetch_array($result)) {
$kodlar = "•,-, ,|,>,<,(,),/,≈,",',\,/,[,],{,},*,1,2,3,4,5,6,7,8,9,0,’,“,”,.,:,;,#,$,!,+,%,&,=,?,_,~,¨,´,`,^";
$kodlar=array_filter(explode(",", $kodlar));
$bosalt =",";
$row[0] = str_replace($kodlar, $bosalt, $row[0]);
$row_tag_array = @split(",", $row[0]);
foreach ($row_tag_array as $newtag) {
asort($row_tag_array);
if (array_key_exists($newtag, $tags)) {
if ($tags[$newtag] < 200) {
$tags[$newtag] = $tags[$newtag] + 1;
}
}
else {
$tags[$newtag] = 1;
}
}
}
foreach ($tags as $tag => $size) {
echo '<div class="tag"><a href="http://localhost/search/'.$tag.'.html">'.$tag.'</a><span> x '.$size.'</span>';
}
?>
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX