ช่วยเขียนสคริป ตั้งเวลา ทำเสียว เรียงคิวรุมโทรม ให้หน่อยครับ

เริ่มโดย iamnewbies, 04 เมษายน 2007, 11:17:00

หัวข้อก่อนหน้า - หัวข้อถัดไป

0 สมาชิก และ 1 ผู้มาเยือน กำลังดูหัวข้อนี้

iamnewbies

อยากได้าสคริปตั้งเวลา เปลี่ยน ID adsense นะครับ

ผมจะเอาไปใช้กับ งานกระทู้  ทำอะไรเสียว

http://www.thaiseoboard.com/viewtopic.php?t=8130&postdays=0&postorder=asc&&start=0

มีใครช่วยเขียนได้มั้ง

จะได้เอาใส่ ไว้รอเลย ไม่ต้องมานั่งเปลี่ยนให้ทุกๆ วันอะ

เปลี่ยนวันละ 1 คนครับ

เป็นคำสั่งง่ายๆ แบบ bath ก็ได้  if ไปเรื่อยๆ
ุอิอิ  พลุบๆโพล่ๆ  เข้าๆออกๆ เสียวๆ

kahn

ใช้ php ใช่มั้ยครับ ทำแบบนี้ได้มั้ย

ตรง pubid  เขียนสคริบใส่ไป <? include(ชื่อไฟล์วันที่ที่ข้างในบรรจุ id);?>
โดยชื่อไฟล์ตั้งตามวันที่เลย เช่น 04-04-2005.php ไรประมาณนี้ โดยสคริบจะทำการตรวจสอบวันที่ก่อน include ชื่อไฟล์  คุณเอกก็ทำไฟล์ วันที่อัพโหลดไปตามคิวเรื่อย ๆ  :D   ถ้า idea นี้ work ผมอาสาทำให้
[direct=http://www.theblogmagic.com/?promocode=MQ==]>>> โปรโมชั่น Blog Magic สุดคุ้ม นาน ๆ มีที ช้าอดนะจ้าาา คลิกเลย [/direct]Blog Magic Support Forums << pm สอบถามรายละเอียดได้ที่ Support Forums จะตอบรวดเร็วกว่านะครับผม

iamnewbies

ดีครับ

ไอเดียแบบนั้นก็ได้ครับ

แต่ว่า อยากจะได้แบบ ใช้แค่ ไฟล์เดียว เลยนะครับ

เพราะมันหลายโฮส และหลายเว็บ 650 กว่าเว็บ

ก็อปหลายไฟล์เดียวจะ งง และ ก็ อ้วกแตกตายซะก่อน ต้องมานั่งทำให้ทุกๆ วันเสียเวลา
ุอิอิ  พลุบๆโพล่ๆ  เข้าๆออกๆ เสียวๆ

yak2525


iamnewbies

เอาไปใส่ ตั้งเวลา เปลี่ยน pub-id ของ adsense ให้กับ คนที่ เสี่ยง อย่างเสียวครับ


มีไอเดียดีๆ อื่นๆ อีกใหมครับ เนี่ย



<?php
putenv
&#40;"TZ=America/Los_Angeles"&#41;;
$today date&#40;"Ymd"&#41;;
$adsense $today.".inc";

echo 
$adsense;
echo 
"<hr>";

$google_ad_client "";
$google_ad_channel  "";

if &
#40;$today=="20070403"&#41; &#123;
$google_ad_client "pub-1111111111111111";
$google_ad_channel "1111111111";
&
#125;

if &#40;$today=="20070404"&#41; &#123;
$google_ad_client "pub-2222222222222222";
$google_ad_channel "2222222222";
&
#125;

if &#40;$today=="20070405"&#41; &#123;
$google_ad_client "pub-3333333333333333";
$google_ad_channel "3333333333";
&
#125;

if &#40;$today=="20070406"&#41; &#123;
$google_ad_client "pub-4444444444444444";
$google_ad_channel "4444444444";
&
#125;

if &#40;$today=="20070407"&#41; &#123;
$google_ad_client "pub-5555555555555555";
$google_ad_channel "5555555555";
&
#125;

echo $google_ad_client;
echo 
"<br>";
echo 
$google_ad_channel;
?>

ุอิอิ  พลุบๆโพล่ๆ  เข้าๆออกๆ เสียวๆ

bubbleball

เก็บใส่อาเรย์ไว้ ในแต่ละ index

แล้วตั้งวันเริ่มต้นไว้ หลังจากนั้นเช็ควันที่ปัจจุบัน หาผลต่างกับวันที่เริ่มต้น จะได้ค่า index  แล้วเอาไปดึง pubid ที่เก็บไว้ในอาเรย์มาใช้อีกที  แล้วเขียนโปรแกรมสักตัวสำหรับ push ค่าเข้าไปต่อคิว

จะเก็บไว้ใน text file ก็ได้ แล้วค่อยดึงไปใช้สร้างอาเรย์อีกทีนึง

ColdMoney

[direct=https://www.jumnong.com]รับจำนอง[/direct] [direct=https://burapasup.com]รับซื้อบ้าน[/direct] [direct=https://kadsan.com]สินค้าราคาถูก[/direct] [direct=https://checkcheap.com]เปรียบเทียบราคา[/direct]

golf98765

เวลาเรียกชื่อไฟล์ ก็ใช้ชื่อไฟล์เป็นวันที่เช่น "$date.txt"

แล้วก็ใส่ pub ในไฟล .txt ตั้งชื่อเป็นวันที่ หลายๆ ไฟล์ ง่ายดีคับ

kahn

ถ้าแบบที่ผมบอก เอาโค๊ดนี้ไปไส่ google_ad_client = "code";


<? $pubfile=date("d-m-y").".txt"; if (file_exists($pubfile)) include("$pubfile"); ?>


ส่วนชื่อไฟล์ตั้งเป็น txt ไฟล์แบบที่คุณ golf บอก ตามวันที่ วัน-เดือน-ปี.txt เช่น 04-04-07.txt
ข้างในไฟล์บรรจุ pub_id 1 บรรทัดเพียว ๆ

แต่ถ้าคุณเอกจะเอาไปใช้ 650 เวบ  คงต้องกำหนดเวบใดเวบหนึ่งเป็นเว็บแม่สำหรับดึง id  คุณเอกจะได้อัพไฟล์ใส่ไว้แค่โฮสเดียว
[direct=http://www.theblogmagic.com/?promocode=MQ==]>>> โปรโมชั่น Blog Magic สุดคุ้ม นาน ๆ มีที ช้าอดนะจ้าาา คลิกเลย [/direct]Blog Magic Support Forums << pm สอบถามรายละเอียดได้ที่ Support Forums จะตอบรวดเร็วกว่านะครับผม

golf98765

อ่าว ไอเดียเหมือนคุณ kahn เลย หุๆๆ ไม่ได้อ่านตั้งแต่แรก หะๆๆ

golf98765

น่าทำ tool อัพโหลด ไฟล์เดียวได้หลายๆ เว็บนะครับ ทีเดียวเลย อิๆ

ผมเขียนไม่เป็นอ่ะ แต่ฝันเอาไว้ว่าอยากได้  :lol:

bubbleball

ถ้าวิธีของผมที่หาส่วนต่างของวันแล้วดึงค่าจากอาเรย์ ก็ใส่ไว้ใน php file ตัวเดียว แล้วให้ทุกตัว include ท php file ตัวนั้น โดยอ้างอิงจาก root

iamnewbies

อ้างถึงจาก: bubbleballถ้าวิธีของผมที่หาส่วนต่างของวันแล้วดึงค่าจากอาเรย์ ก็ใส่ไว้ใน php file ตัวเดียว แล้วให้ทุกตัว include ท php file ตัวนั้น โดยอ้างอิงจาก root

คุณ bubbleball เขียนให้หน่อยจิ อิอิ
ุอิอิ  พลุบๆโพล่ๆ  เข้าๆออกๆ เสียวๆ

bubbleball

ยังไม่เคยลองครับ ไ่ม่เชี่ยว php รู้ว่าทำได้แล้วก็ไม่ยากมาก ใครเขียนได้ลองดูก่อนละกันยังไม่เลิกงาน

Tee++;

@putenv("TZ=Europe/London");
$tz = +7;
$timestamp = time()+3600*($tz);

include_once ('publisher.php');
$google_ad_client = $publisher[gmdate('d-m-y', $timestamp)]['google_ad_client'];
$google_ad_channel = $publisher[gmdate('d-m-y', $timestamp)]['google_ad_channel'];



File publisher.php

$publisher = array(
   '04-04-07'=>array('google_ad_client'=>'11111', 'google_ad_channel'=>'2222'),
   '05-04-07'=>array('google_ad_client'=>'33333', 'google_ad_channel'=>'4444'),
);
[direct=http://laravel.in.th]Laravel in Thai[/direct]
[direct=http://jquerytips.com]jQueryTips by Tee++;[/direct]
[direct=https://www.facebook.com/jQueryTips]jQueryTips Page[/direct]
[direct=https://www.facebook.com/Laravel.in.th]Laravel in Thai Page[/direct]
[direct=https://twitter.com/Teepluss]Teepluss's Twitter[/direct]


nutthadej

อ้างถึงจาก: Tee++;@putenv("TZ=Europe/London");
$tz = +7;
$timestamp = time()+3600*($tz);

include_once ('publisher.php');
$google_ad_client = $publisher[gmdate('d-m-y', $timestamp)]['google_ad_client'];
$google_ad_channel = $publisher[gmdate('d-m-y', $timestamp)]['google_ad_channel'];



File publisher.php

$publisher = array(
   '04-04-07'=>array('google_ad_client'=>'11111', 'google_ad_channel'=>'2222'),
   '05-04-07'=>array('google_ad_client'=>'33333', 'google_ad_channel'=>'4444'),
);

แบบนี้ก็กำหนดล่วงหน้าไปได้เลยสินะครับ
ว่าใครจะได้วันไหน
จะมีให้วนกลับยังได้เลย อิอิ
[direct=http://www.ns8.biz]Sublime Directory Services[/direct][direct=http://www.indexbargains.com/]Index Bargains Sublime Directory[/direct][direct=http://www.thecandydirectory.com/]The Candy Sublime Directory[/direct][direct=http://offerbestprice.com/]Best Buy Store[/direct][direct=http://bestbuystores.ws/]Best Buy Stores[/direct]

Tee++;

อืมม์ ครับ ถ้าจะให้วนกลับก็เอาปีออกไป แล้วใช่วันที่ 1-30 ก็พอครับ วันที่ 31 ผมขอนะ  :lol:  :lol:
[direct=http://laravel.in.th]Laravel in Thai[/direct]
[direct=http://jquerytips.com]jQueryTips by Tee++;[/direct]
[direct=https://www.facebook.com/jQueryTips]jQueryTips Page[/direct]
[direct=https://www.facebook.com/Laravel.in.th]Laravel in Thai Page[/direct]
[direct=https://twitter.com/Teepluss]Teepluss's Twitter[/direct]


nutthadej

แอบ pm ไปขอวันที่ 23 แระ
พอดีวันเกิดพอดี อิอิ :lol:
ไม่รู้จะทันไหรือเปล่า
[direct=http://www.ns8.biz]Sublime Directory Services[/direct][direct=http://www.indexbargains.com/]Index Bargains Sublime Directory[/direct][direct=http://www.thecandydirectory.com/]The Candy Sublime Directory[/direct][direct=http://offerbestprice.com/]Best Buy Store[/direct][direct=http://bestbuystores.ws/]Best Buy Stores[/direct]

Tee++;

หรือถ้าจะเอาแบบที่คุณบอลบอกก็ง่ายดี

@putenv("TZ=Europe/London");
$tz = +7; // Time Zone
$start_date = mktime(0, 0, 0, 4, 1, 2007); // Start at 4/1/2007 (m/d/Y)
$file = @file("publisher.txt"); // Data file

$timestamp = time()+3600*($tz);
for ($i=0; $i<count($file); $i++) {
   $movenext = $start_date+(86400*$i);
   if (gmdate("d/m/Y", $movenext) == gmdate("d/m/Y", $timestamp)) {
       list ($google_ad_client, $google_ad_channel) = explode("|", $file[$i]);
       break;
   }
}

echo $google_ad_client;
echo "<br />";
echo $google_ad_channel;


โดยที่ file publisher.txt เราใส่ข้อมุลแค่นี้ เดี๋ยวมันเรียงกันไปเอง

id1|chanel1
id2|chanel2
id3|chanel3
id4|chanel4
id5|chanel5


โดยที่ ผม set ค่าเริ่มต้นให้เป็นวันที่ 1/4/2007

1/4/2007 = id1
2/4/2007 = id2

เรียงมาเรื่อยๆแบบนี้  :lol:
[direct=http://laravel.in.th]Laravel in Thai[/direct]
[direct=http://jquerytips.com]jQueryTips by Tee++;[/direct]
[direct=https://www.facebook.com/jQueryTips]jQueryTips Page[/direct]
[direct=https://www.facebook.com/Laravel.in.th]Laravel in Thai Page[/direct]
[direct=https://twitter.com/Teepluss]Teepluss's Twitter[/direct]


bubbleball

อิอิ สบายเรา ไม่ต้องเหนื่อยให้เมื่อยตุ้ม :lol: แต่แบบนี้มันเหมือนบวกเข้าไปจากวันตั้งต้นแฮะ

php มันต้องแปลงเป็น mktime ก่อน ไม่เหมือน flash มี class date ดึงวันมาแล้วลบได้เลย  สมมุติกำหนดแค่วัน แบบนี้

var $pub_array = Array("id1","id2","id3");
var $initDate = 4;
var $today  = 5; //ให้ใชฟังก์ชั่นดึงวันมา จำไม่ได้ยกตัวอย่าง 5 เลยละกัน
var $diff =$today - $initDate;  //ไ้ด้ 1
var $pub_id = $pub_array[$diff];  //ไม่แน่ใจต้องลบ 1 หรือเปล่า ถ้า index เริ่มต้นคือ 0 ก็ต้องลบ
echo $pub_id;


อะไรประมาณนี้ ไม่ต้องจริงจังเรื่องความถูกต้องมากครับ ผมไม่ได้เขียนจริงจำ syntax ไม่ได้

แบบแรกของคุณตี๋ผมก็คิดเหมือนกัน ใช้ associative array แต่ถึกๆนั่งใส่ index แบบวันหน่อย พอๆกับสร้างไฟล์ตั้งชื่อตามวัน แต่ดีตรงที่กำหนดล่วงหน้าได้