コード例 #1
0
ファイル: ajax_unique.php プロジェクト: nasirahamed/WebAppDev
<?php

//Code extracted from http://www.smarttutorials.net/ and altered
require_once 'config.php';
if ($_GET['data'] == 'name') {
    $value = unique_name($_GET['name']);
}
if ($_GET['data'] == 'email') {
    $value = unique_email($_GET['email']);
}
function unique_name($name = '')
{
    $query = "select count(name) from user where name='{$name}'";
    $response = mysql_query($query);
    $result = mysql_fetch_array($response);
    if ($result[0] > 0) {
        echo 'false';
    } else {
        echo 'true';
    }
}
function unique_email($email = '')
{
    $query = "select count(email) from user where email='{$email}'";
    $response = mysql_query($query);
    $result = mysql_fetch_array($response);
    if ($result[0] > 0) {
        echo 'false';
    } else {
        echo 'true';
    }
コード例 #2
0
ファイル: lib_api.php プロジェクト: Ryan007/mybb
/**
 * 上传图片
 *
 * @param string $str 二进制字符串
 * @param string $dir 目录路径
 * @param string $img_name 图片名称
 * @return 图片名称 或 假值
 */
function upload_image($str, $dir = '', $img_name = '')
{
    if (empty($str['Data'])) {
        return false;
    }
    $allow_file_type = array('jpg', 'jpeg', 'png', 'gif', 'bmp');
    if (empty($dir)) {
        /* 创建当月目录 */
        $dir = date('Ym');
        $dir = ROOT_PATH . '/images/' . $dir;
    } else {
        /* 创建目录 */
        $dir = ROOT_PATH . '/' . $dir;
        if ($img_name) {
            /* 判断$img_name文件后缀与路径 */
            $img_name = basename($img_name);
            $img_name_ext = substr($img_name, strrpos($img_name, '.') + 1);
            if (!in_array($img_name_ext, $allow_file_type)) {
                return false;
            }
            $img_name = $dir . '/' . $img_name;
            // 将图片定位到正确地址
        }
    }
    if (!file_exists($dir)) {
        if (!make_dir($dir)) {
            /* 创建目录失败 */
            return false;
        }
    }
    if (empty($img_name)) {
        $img_name = unique_name($dir);
        $img_name = $dir . '/' . $img_name . '.' . $str['Type'];
    }
    $binary_data = base64_decode($str['Data']);
    if ($fp = @fopen($img_name, 'wb')) {
        @fwrite($fp, $binary_data);
        @fclose($fp);
        return str_replace(ROOT_PATH . '/', '', $img_name);
    } else {
        return false;
    }
}
コード例 #3
0
ファイル: sendfax.php プロジェクト: recluze/WebFax
					"RetryTime: 60\n" . 
					"WaitTime: 60\n"  . 
					"Archive: yes\n"  . 
					"Context: $outboundfax_context \n"  . 
					"Extension: s\n" . 
					"Priority: 1\n" . 
					"Set: FAXFILE=$input_file_tif\n" . 
					"Set: FAXHEADER=$faxHeader\n" . 
					"Set: TIMESTAMP=" . date("d/m/y : H:i:s",time()) . "\n" .
					"Set: DESTINATION=$dest\n". 
					"Set: LOCALID=$localID\n" . 
					"Set: EMAIL=$email\n";
		
		// echo $callfile; 
		// create the call file in /tmp 
		$callfilename = unique_name("/tmp", ".call"); 
		$f = fopen($callfilename, "w"); 
		fwrite($f, $callfile); 
		fclose($f); 
		
		// move the file to asterisk outgoing spool directory 
		// stopping the call to asterisk for now .. TODO: uncomment before deploying .. 
		rename($callfilename, $asterisk_spool_folder .  "/" . substr($callfilename,4));
	
	//------------------------- END CREATE CALL FILE -----------------------------------------------------------
	} 
}
// if no error, display that notification will be sent. 

?>
END HTML HACK to supress errors appearing on screen. 
コード例 #4
0
ファイル: album.php プロジェクト: dalinhuang/hteacher
require dirname(__FILE__) . '/includes/init.php';
if ($_REQUEST['act'] == 'list') {
    $album_types = get_album_types();
    $smarty->assign("album_types", $album_types);
    $smarty->display('album_list.htm');
    exit;
} elseif ($_REQUEST['act'] == 'ajax_list') {
    $list = album_list();
    make_json($list);
} elseif ($_REQUEST['act'] == 'upload') {
    //获取文件上传的目录
    $targetPath = '../resource/data/album/' . $_REQUEST['atype_id'];
    $verifyToken = md5('unique_salt' . $_REQUEST['timestamp']);
    if (!empty($_FILES) && $_REQUEST['token'] == $verifyToken) {
        $tempFile = $_FILES['Filedata']['tmp_name'];
        $image_name = unique_name($targetPath . '/') . '.' . get_prefix($_FILES['Filedata']['name']);
        $targetFile = rtrim($targetPath, '/') . '/' . $image_name;
        move_uploaded_file($tempFile, $targetFile);
        $sql = "insert into " . $ecs->table("album") . " (class_code, type, name, path, filesize, creator, created) \r\n\t\tvalues ('" . $_SESSION['class_code'] . "','" . $_REQUEST['atype_id'] . "', '" . $_REQUEST['Filename'] . "',\r\n\t\t\t'" . $targetFile . "','" . $_FILES['Filedata']['size'] . "','" . $_SESSION['admin_id'] . "',now()) ";
        $db->query($sql);
        admin_log(addslashes($_REQUEST['Filename']), 'upload', "album_picture");
        make_json_result("上传“" . $_REQUEST['Filename'] . "”成功!");
    }
    make_json_error("上传" . $_REQUEST['Filename'] . "失败!");
} elseif ($_REQUEST['act'] == 'ajax_save') {
    $id = !empty($_REQUEST['album_id']) ? intval($_REQUEST['album_id']) : 0;
    $sql = "update " . $ecs->table("album") . " set name='" . $_REQUEST["name"] . "',\r\n\t\t\tsort='" . $_REQUEST["sort"] . "'\r\n\t\t\twhere album_id=" . $id;
    $db->query($sql);
    admin_log(addslashes($_REQUEST["name"] . $id), 'update', $sql);
    make_json_result("修改成功!");
} elseif ($_REQUEST['act'] == 'ajax_delete') {
コード例 #5
0
function format_item_name_html($item)
{
    $displayname = $item['type'];
    $bold = $endbold = '';
    // just for testing
    if (isset($item['quantity'])) {
        $displayname = $item['quantity'] . " " . $displayname;
    }
    //  $qualitylist = array('', 'low', 'normal', 'high', 'magical', 'set', 'rare', 'unique', 'crafted');
    $qualitylist = array('', '', '', 'Superior ', '', '', '', '', '');
    $qualitycolors = array('', 'ffffff', 'ffffff', 'ffffff', '4850b8', '00c400', 'yellow', '908858', 'orange');
    if (!isset($item['quality'])) {
        $color = 'ffffff';
    } else {
        $displayname = $qualitylist[$item['quality']] . $displayname;
        $color = $qualitycolors[$item['quality']];
        if ($item['quality'] > 3 || $item['hasruneword'] == 1) {
            $bold = '<b>';
            $endbold = '</b>';
        }
        switch ($item['quality']) {
            case 1:
                // low quality
                switch ($item['quality2']) {
                    case 0:
                        $displayname = "Crude " . $displayname;
                        break;
                    case 1:
                        $displayname = "Cracked " . $displayname;
                        break;
                    case 2:
                        $displayname = "Damaged " . $displayname;
                        break;
                    case 3:
                        $displayname = "Low Quality " . $displayname;
                        break;
                }
                break;
            case 2:
            case 3:
                break;
            case 4:
                // magic
                if ($item['magicprefix'] > 0) {
                    $displayname = magic_prefix($item['magicprefix']) . " " . $displayname;
                }
                if ($item['magicsuffix'] > 0) {
                    $displayname = $displayname . " " . magic_suffix($item['magicsuffix']);
                }
                break;
            case 5:
                // set
                $displayname = set_name($item['setid'], $item['type']);
                break;
            case 6:
                // rare
                $displayname = rare_name($item['rareword1']) . " " . rare_name($item['rareword2']) . " " . $displayname;
                break;
            case 7:
                // unique
                $displayname = unique_name($item['uniqueid'], $item['type']);
                break;
            case 8:
                // crafted (same as rare)
                $displayname = rare_name($item['rareword1']) . " " . rare_name($item['rareword2']) . " " . $displayname;
                break;
        }
    }
    //  if ($item['isquest'] == 1) $color = '908858';
    if ($color == 'ffffff' && $item['issocketed'] == 1) {
        $color = 'gray';
    }
    if ($color == 'ffffff' && $item['isethereal'] == 1) {
        $color = 'darkgray';
    }
    if ($item['hasruneword'] == 1) {
        $displayname = $item['runeword'] . " " . $displayname;
        $color = '908858';
    } elseif ($item['issocketed'] == 1 && $item['quality'] < 4 && $item['itemsinsockets'] > 0) {
        $displayname = "Gemmed " . $displayname;
    }
    if ($item['isear'] == 1) {
        $color = 'ffffff';
        $displayname = $item['earname'] . "'s ear";
    }
    if ($item['ispersonalized'] == 1) {
        $displayname = $item['itemname'] . "'s " . $displayname;
    }
    $prefix = '';
    // just for testing
    if (isset($item['defense'])) {
        $displayname = $displayname . " " . $item['defense'];
    }
    /*
      if (isset($item['maxdurability'])) {
        if ($item['maxdurability'] == 0) {
          $displayname = $displayname ." Indestructable";
        } else {
          $displayname = $displayname ." ". $item['curdurability'] ." / ". $item['maxdurability'];
        }
      }
    */
    return $bold . "<font color=" . $color . ">" . $displayname . "</font>" . $endbold;
}