'PHP'에 해당되는 글 30건
- 2012/02/09 visualp php current page 주소 고하기
- 2012/01/30 visualp mp3, mp4,.. 미디어파일 정보, getid3
- 2012/01/27 visualp mobile device detection
- 2012/01/24 visualp [그누보드] 동일 아이피 중복 체크
- 2011/11/07 visualp apm환경에서 로그인 안되는 문제
- 2011/08/11 visualp 그누보드 , 하루에 한번 글쓰기
- 2011/08/08 visualp php , RSS Reader
- 2011/07/26 visualp javascript uriincode in php , rawurlencode , utf-8 한글 쿼리 스트링 넘기기
- 2011/07/09 visualp css in php
- 2011/06/21 visualp mysql to json
댓글+트랙백 RSS :: http://blog.visualp.com/rss/response/453
댓글+트랙백 ATOM :: http://blog.visualp.com/atom/response/453
//mp3 duration (재생시간 구하기)
$getID3 = new getID3;
$ThisFileInfo = $getID3->analyze($real_file);
getid3_lib::CopyTagsToComments($ThisFileInfo);
$movie_duration = @$ThisFileInfo['playtime_string'];
댓글+트랙백 RSS :: http://blog.visualp.com/rss/response/450
댓글+트랙백 ATOM :: http://blog.visualp.com/atom/response/450
[원문]- http://www.schiffner.com/index.php/programming-php-classes/php-mobile-device-detection/
//Detect special conditions devices $iPod = stripos($_SERVER['HTTP_USER_AGENT'],"iPod"); $iPhone = stripos($_SERVER['HTTP_USER_AGENT'],"iPhone"); $iPad = stripos($_SERVER['HTTP_USER_AGENT'],"iPad"); if(stripos($_SERVER['HTTP_USER_AGENT'],"Android") && stripos($_SERVER['HTTP_USER_AGENT'],"mobile")){ $Android = true; }else if(stripos($_SERVER['HTTP_USER_AGENT'],"Android")){ $Android = false; $AndroidTablet = true; }else{ $Android = false; $AndroidTablet = false; } $webOS = stripos($_SERVER['HTTP_USER_AGENT'],"webOS"); $BlackBerry = stripos($_SERVER['HTTP_USER_AGENT'],"BlackBerry"); $RimTablet= stripos($_SERVER['HTTP_USER_AGENT'],"RIM Tablet"); //do something with this information if( $iPod || $iPhone ){ //were an iPhone/iPod touch -- do something here }else if($iPad){ //were an iPad -- do something here }else if($Android){ //were an Android Phone -- do something here }else if($AndroidTablet){ //were an Android Phone -- do something here }else if($webOS){ //were a webOS device -- do something here }else if($BlackBerry){ //were a BlackBerry phone -- do something here }else if($RimTablet){ //were a RIM/BlackBerry Tablet -- do something here }
댓글+트랙백 RSS :: http://blog.visualp.com/rss/response/449
댓글+트랙백 ATOM :: http://blog.visualp.com/atom/response/449
$sql = "select count(*) as cnt from $g4[member_table] where mb_ip='$_SERVER[REMOTE_ADDR]'";
$row = sql_fetch($sql);
if($row[cnt]>0) alert("이미 동일IP로 가입되어있습니다.");
/*동일 아이피 중복 체크_end() */
댓글+트랙백 RSS :: http://blog.visualp.com/rss/response/448
댓글+트랙백 ATOM :: http://blog.visualp.com/atom/response/448
서버상태 : apm 사용 (apache2.2 php5 mysql5)
내용 : 로컬개발시 도메인에 '_'가 들어갈경우 세션이 무한정 생성되는 문제가 있다.
도메인에 '_'를 사용하지 말자!
댓글+트랙백 RSS :: http://blog.visualp.com/rss/response/421
댓글+트랙백 ATOM :: http://blog.visualp.com/atom/response/421
$table_names ="forum";
//테이블명을만들고
$bo_table_names ="".$g4[write_prefix]."".$table_names."";
//새글등록후 24시간 전에는 글쓰기를 못하며 시간변경은 (60 * 60 * 24) 부분에서 수정합니다.
$udatatime = date("Y-m-d H:i:s", time() - (int)(60 * 60 * 24));
//지정한 게시판에서 수정은 가능하고 관리자는 제한이 없고 회원일 경우만 체크
if(($member[mb_id] && !$is_admin && $w != "u") && $bo_table == $table_names){
//코멘트 종류와 답글종류는 전부 제외하고 원글만 오늘 올라온글이 있는지
$ab_boards =mysql_fetch_array(mysql_query("select count(*) from $bo_table_names where wr_is_comment ='0' and wr_reply ='' and wr_datetime >= '$udatatime'"));
$rowmembers =$ab_boards[0];
// 오늘올라온 글이 1개라도 존재 한다면
if($rowmembers > 0){
alert("이게시판에 오늘 $rowmembers 개의 글이 등록이 되었으므로 \\n오늘은 글쓰기를 하실수가 없으며 코멘트만 가능합니다.");
}
}
[원문 ] http://www.sir.co.kr/bbs/board.php?bo_table=g4_tiptech&wr_id=2100&sca=&sfl=wr_subject%7C%7Cwr_content&stx=%C3%DF%C3%B5+%C0%CC%B5%BF&sop=and
댓글+트랙백 RSS :: http://blog.visualp.com/rss/response/416
댓글+트랙백 ATOM :: http://blog.visualp.com/atom/response/416
<?php
$url = “http://pwnthecode.org/home/feed”;
$rss = simplexml_load_file($url);
if($rss)
{
echo ‘<h1>’.$rss->channel->title.’</h1>’;
echo ‘<li>’.$rss->channel->pubDate.’</li>’;
$items = $rss->channel->item;
foreach($items as $item)
{
$title = $item->title;
$link = $item->link;
$published_on = $item->pubDate;
$description = $item->description;
echo ‘<h3><a href=”‘.$link.’”>’.$title.’</a></h3>’;
echo ‘<span>(‘.$published_on.’)</span>’;
echo ‘<p>’.$description.’</p>’;
}
}
?>
댓글+트랙백 RSS :: http://blog.visualp.com/rss/response/415
댓글+트랙백 ATOM :: http://blog.visualp.com/atom/response/415
댓글+트랙백 RSS :: http://blog.visualp.com/rss/response/414
댓글+트랙백 ATOM :: http://blog.visualp.com/atom/response/414
CSS Colors: Take Control Using PHP
Neo: Do you always look at it encoded?
Cypher: Well, you have to ... there's way too much information.
While many web sites use powerful programming environments to create HTML, these same tools are usually ignored when it comes to creating Cascading Style Sheets (CSS). This article describes how to take control of your colors in CSS using PHP. You will learn how to:
- Centralize your color definitions using variables.
- Separate presentation and content by referring to colors using abstract names such as base and highlight.
- Automatically generate a color gradient from a single base color:
-5-4-3-2-10+1+2+3+4+5 - Automatically adjust the contrast of foreground colors so they can viewed on top of your background colors:
-5-4-3-2-10+1+2+3+4+5
Using PHP to Generate CSS
To use PHP in your CSS file:
- Rename your
style.cssfile tostyle.php, then add the following to the top of the file:<?php header("Content-type: text/css"); ?>This line tells the browser that the file is CSS instead of HTML.
- In your HTML files, change the stylesheet references from
style.csstostyle.php. For example:<link rel="stylesheet" type="text/css" media="screen" href="style.php">
Centralizing Your Color Definitions
I don't even see the code. All I see is blonde... brunette... redhead...
In a typical CSS file, color codes are scattered throughout the page, and the same colors are used in multiple places. Unless you have a talent for visualizing hex color codes, it can be hard to determine which colors belong to which codes.
Our first goal is to name the color codes and define them in a central location. Then if we want to change a color, we can change it once and the change will be propagated throughout the stylesheet.
Let's start with the following sample stylesheet:
body {
background:#fff;
color:#333;
}
h1, h2, h3, h4 {
color:#00840;
}
blockquote {
color:#008400;
}
And transform it into this:
<?php
header("Content-type: text/css");
$white = '#fff';
$dkgray = '#333';
$dkgreen = '#008400';
?>
body {
background:<?=$white?>;
color:<?=$dkgray?>;
}
h1, h2, h3, h4 {
color:<?=$dkgreen?>;
}
blockquote {
color:<?=$dkgreen?>;
}
Abstracting Your Colors
Try to realize the truth... there is no spoon.
What if we wanted to make our headings red? If we changed the value of $dkgreen, then the variable name would not reflect the actual color. Furthermore, if we change $dkgreen, both the heading elements and the blockquote element would change color.
We need to change the way we name our colors, and create variables according to the function of the color instead of the value of the color:
<?php
header("Content-type: text/css");
$pageBG = '#fff';
$pageFG = '#333';
$heading = '#a00000'
$quote = '#008400';
?>
body {
background:<?=$pageBG?>;
color:<?=$pageFG?>;
}
h1, h2, h3, h4 {
color:<?=$heading?>;
}
blockquote {
color:<?=$quote?>;
}
For a more complex, real-word example, read my Case Study: Abstracting Colors for Hewlett-Packard Company.
Generating Palettes With PHP
We're supposed to start with these operation programs first. That's major boring shit. Let's do something a little more fun.
Now let's take this a step further, and use PHP to generate new colors. We'll start with a base color and a highlight color, then generate a palette of lighter and darker shades:
Notice that the text is not readable on some of the swatches. Let's use PHP to adjust the foreground color, using color visibility guidelines recommended by the W3C:
To define these colors in our CSS file, simply add the following lines:
<?php
include_once("csscolor.php");
$base = new CSS_Color('C9E3A6');
$highlight = new CSS_Color('746B8E');
?>
Then to use the colors, do something like this:
/* Use the base color, two shades darker */ background:#<?= $base->bg['-2'] ?>; /* Use the corresponding foreground color */ color:#<?= $base->fg['-2'] ?>; /* Use the highlight color as a border */ border:5px solid #<?= $highlight->bg['0'] ?>
Here is an example of the style in action.
Download
You can download csscolor.php here:
댓글+트랙백 RSS :: http://blog.visualp.com/rss/response/413
댓글+트랙백 ATOM :: http://blog.visualp.com/atom/response/413
function mysql2json($mysql_result,$name){
$json="{\n\"$name\": [\n";
$field_names = array();
$fields = mysql_num_fields($mysql_result);
for($x=0;$x<$fields;$x++){
$field_name = mysql_fetch_field($mysql_result, $x);
if($field_name){
$field_names[$x]=$field_name->name;
}
}
$rows = mysql_num_rows($mysql_result);
for($x=0;$x<$rows;$x++){
$row = mysql_fetch_array($mysql_result);
$json.="{\n";
for($y=0;$y<count($field_names);$y++) {
$json.="\"$field_names[$y]\" : \"$row[$y]\"";
if($y==count($field_names)-1){
$json.="\n";
}
else{
$json.=",\n";
}
}
if($x==$rows-1){
$json.="\n}\n";
}
else{
$json.="\n},\n";
}
}
$json.="]\n};";
return($json);
} function mysql2json($mysql_result,$name){
$json="{\n\"$name\": [\n";
$field_names = array();
$fields = mysql_num_fields($mysql_result);
for($x=0;$x<$fields;$x++){
$field_name = mysql_fetch_field($mysql_result, $x);
if($field_name){
$field_names[$x]=$field_name->name;
}
}
$rows = mysql_num_rows($mysql_result);
for($x=0;$x<$rows;$x++){
$row = mysql_fetch_array($mysql_result);
$json.="{\n";
for($y=0;$y<count($field_names);$y++) {
$json.="\"$field_names[$y]\" : \"$row[$y]\"";
if($y==count($field_names)-1){
$json.="\n";
}
else{
$json.=",\n";
}
}
if($x==$rows-1){
$json.="\n}\n";
}
else{
$json.="\n},\n";
}
}
$json.="]\n};";
return($json);
}





글