本文整理汇总了PHP中material类的典型用法代码示例。如果您正苦于以下问题:PHP material类的具体用法?PHP material怎么用?PHP material使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了material类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
public function update()
{
$data = array('id' => intval($this->input['id']), 'name' => trim($this->input['name']));
if (!$data['id']) {
$this->errorOutput("ID不能为空");
}
if (!$data['name']) {
$this->errorOutput("运势名不能为空");
}
$sql = 'SELECT * FROM ' . DB_PREFIX . 'astro_app_fortuneinfo WHERE id = ' . $data['id'];
$res = $this->db->query_first($sql);
$astrofunimg = unserialize($res['astrofunimg']) ? unserialize($res['astrofunimg']) : array();
$logo['Filedata'] = $_FILES['logo'];
if ($logo['Filedata']) {
include_once ROOT_PATH . 'lib/class/material.class.php';
$material = new material();
$re = $material->addMaterial($logo);
$logo = array();
$logo = array('host' => $re['host'], 'dir' => $re['dir'], 'filepath' => $re['filepath'], 'filename' => $re['filename']);
} else {
$logo = $astrofunimg;
}
$where = ' WHERE 1 ';
$where .= ' AND id = ' . $data['id'];
$sql = 'UPDATE ' . DB_PREFIX . 'astro_app_fortuneinfo' . ' SET astrofuncn = "' . $data['name'] . '", astrofunimg ="' . addslashes(serialize($logo)) . '"' . $where;
//$this->errorOutput($sql);
$this->db->query($sql);
$this->constellation->updatetime_orerid($data['id'], 'fortuneinfo');
$data['logo'] = $logo;
$this->addItem($data);
$this->output();
}
示例2: insert_plataccount
public function insert_plataccount($picfiles)
{
$data = array('type' => urldecode($this->input['plat_type']), 'name' => urldecode($this->input['name']), 'offiaccount' => urldecode($this->input['offiaccount']), 'akey' => urldecode($this->input['apikey']), 'skey' => urldecode($this->input['secretkey']), 'oauthurl' => urldecode($this->input['oauthurl']), 'shareurl' => urldecode($this->input['shareurl']), 'userurl' => urldecode($this->input['userurl']), 'callback' => urldecode($this->input['callback']), 'accessurl' => urldecode($this->input['accessurl']), 'followurl' => urldecode($this->input['followurl']), 'status' => urldecode($this->input['status']), 'addtime' => time());
$sql = "INSERT INTO " . DB_PREFIX . "plat SET";
$sql_extra = $space = ' ';
foreach ($data as $k => $v) {
$sql_extra .= $space . $k . "='" . $v . "'";
$space = ',';
}
$sql .= $sql_extra;
$this->db->query($sql);
$id = $this->db->insert_id();
/*将图片提交到图片服务器*/
$files['Filedata'] = $picfiles;
if ($files['Filedata']) {
$material_pic = new material();
$img_info = $material_pic->addMaterial($files, $id, $this->input['module_id'], 'img10');
$img_thumb_info = $this->get_thumb_pic($img_info['filepath'], $img_info['filename']);
//去请求一张缩略图
$data = array('platId' => $id, 'oldname' => $files['Filedata']['name'], 'newname' => $img_info['filename'], 'addtime' => time(), 'path' => $img_info['filepath']);
//判断是否存在封面 如果不存在则以第一幅图片做为封面
$sql = 'UPDATE ' . DB_PREFIX . 'plat SET picurl = "' . $data['path'] . $data['newname'] . '" WHERE id = ' . $data['platId'];
$this->db->query($sql);
$sql = "INSERT INTO " . DB_PREFIX . "pics SET";
$sql_extra = $space = ' ';
foreach ($data as $k => $v) {
$sql_extra .= $space . $k . "='" . $v . "'";
$space = ',';
}
$sql .= $sql_extra;
$this->db->query($sql);
}
return true;
}
示例3: update
public function update()
{
if (!$this->input['id']) {
$this->errorOutput(NOID);
}
$data = array('name' => $this->input['name'], 'description' => $this->input['description'], 'need_update' => intval($this->input['need_update']));
//处理logo图片
if ($_FILES['map_marker']) {
$_FILES['Filedata'] = $_FILES['map_marker'];
$material_pic = new material();
$img_info = $material_pic->addMaterial($_FILES);
if ($img_info) {
$map_marker = array('host' => $img_info['host'], 'dir' => $img_info['dir'], 'filepath' => $img_info['filepath'], 'filename' => $img_info['filename']);
$data['map_marker'] = @serialize($map_marker);
}
}
$ret = $this->mode->update($data, $this->input['id']);
if ($ret) {
$update_data = array('user_id' => $this->user['user_id'], 'user_name' => $this->user['user_name'], 'update_time' => TIMENOW, 'ip' => hg_getip());
$pre_data = $this->mode->update($update_data, $this->input['id']);
$up_data = $data + $update_data;
$this->addLogs('更新停车场类型', $pre_data, $up_data, $up_data['name']);
}
$this->addItem('success');
$this->output();
}
示例4: update
public function update()
{
if (!$this->input['id']) {
$this->errorOutput(NOID);
}
$data = array('name' => $this->input['name'], 'enterprise_nature' => $this->input['enterprise_nature'], 'description' => $this->input['description'], 'tel' => $this->input['tel'], 'parking_num' => $this->input['parking_num'], 'address' => $this->input['address']);
//处理logo图片
if ($_FILES['logo']) {
$_FILES['Filedata'] = $_FILES['logo'];
$material_pic = new material();
$img_info = $material_pic->addMaterial($_FILES);
if ($img_info) {
$logo = array('host' => $img_info['host'], 'dir' => $img_info['dir'], 'filepath' => $img_info['filepath'], 'filename' => $img_info['filename']);
$data['logo'] = @serialize($logo);
}
}
$ret = $this->mode->update($data, $this->input['id']);
if ($ret) {
$update_data = array('user_id' => $this->user['user_id'], 'user_name' => $this->user['user_name'], 'update_time' => TIMENOW, 'ip' => hg_getip());
$pre_data = $this->mode->update($update_data, $this->input['id']);
$up_data = $data + $update_data;
$this->addLogs('更新物业单位', $pre_data, $up_data, $up_data['name']);
}
$this->addItem('success');
$this->output();
}
示例5: update
public function update()
{
if (!$this->input['id']) {
$this->errorOutput(NOID);
}
$name = $this->input['name'];
$body_html = $this->input['body_html'];
if (!$name) {
$this->errorOutput(NO_TPL_NAME);
}
if (!$body_html) {
$this->errorOutput(NO_TPL_HTML);
}
$update_data = array('name' => $name, 'body_html' => $body_html, 'type' => intval($this->input['type']), 'update_time' => TIMENOW);
//更改图片
if (isset($_FILES['img_info']) && !$_FILES['img_info']['error']) {
$_FILES['Filedata'] = $_FILES['img_info'];
$material_pic = new material();
$img = $material_pic->addMaterial($_FILES);
if ($img) {
$img_info = array('host' => $img['host'], 'dir' => $img['dir'], 'filepath' => $img['filepath'], 'filename' => $img['filename'], 'imgwidth' => $img['imgwidth'], 'imgheight' => $img['imgheight']);
$update_data['img_info'] = @serialize($img_info);
}
}
$ret = $this->mode->update($this->input['id'], $update_data);
if ($ret) {
$this->addItem('success');
$this->output();
}
}
示例6: upload_img
/**
* 上传图片
*
*/
public function upload_img()
{
$logo['Filedata'] = $_FILES['pic'];
if ($logo['Filedata']) {
$material_pic = new material();
$logo_info = $material_pic->addMaterial($logo);
$logo = array();
$logo_pic = array('host' => $logo_info['host'], 'dir' => $logo_info['dir'], 'filepath' => $logo_info['filepath'], 'filename' => $logo_info['filename']);
$img_info = addslashes(serialize($logo_pic));
}
if (!$logo_pic) {
$this->errorOutput('没有上传的图片信息');
}
$logoid = intval($this->input['logoid']);
if ($logoid) {
$sql = 'SELECT id FROM ' . DB_PREFIX . "material WHERE id = " . $logoid;
$ret = $this->db->query_first($sql);
}
if ($logoid && $ret['id']) {
$sql = " UPDATE " . DB_PREFIX . "material SET img_info = '" . $img_info . "' WHERE id = " . $logoid;
$query = $this->db->query($sql);
$data['id'] = $logoid;
} else {
$sql = " INSERT INTO " . DB_PREFIX . "material SET img_info = '" . $img_info . "'";
$query = $this->db->query($sql);
$vid = $this->db->insert_id();
$data['id'] = $vid;
}
$data['img_info'] = hg_fetchimgurl($logo_pic, 200, 160);
$this->addItem($data);
$this->output();
}
示例7: upload
public function upload()
{
if ($_FILES['Filedata']) {
if ($_FILES['Filedata']['error']) {
$this->addItem(array('error' => '图片有误'));
$this->output();
} else {
/*
$tmp = getimagesize($_FILES['Filedata']['tmp_name']);
if($tmp[0]<2100)
{
$this->addItem(array('error' => '图片宽度必须大于2100'));
$this->output();
}
if($tmp[1]<1400)
{
$this->addItem(array('error' => '图片高度必须大于1400'));
$this->output();
}
*/
include_once ROOT_PATH . '/lib/class/material.class.php';
$obj_material = new material();
$ret = $obj_material->addMaterial($_FILES);
if (!empty($ret)) {
$this->addItem($ret);
$this->output();
}
}
}
}
示例8: water_config_list
public function water_config_list()
{
include_once ROOT_PATH . 'lib/class/material.class.php';
$material = new material();
$ret = $material->water_config_list();
$this->addItem($ret);
$this->output();
}
示例9: update
public function update()
{
if (!$this->input['id']) {
$this->errorOutput(NOID);
}
$update_data = array('name' => trim($this->input['name']), 'points_system' => $this->input['points_system'], 'is_login' => intval($this->input['is_login']));
//数据验证
$this->data_check($data, $this->input['old_name']);
//上传索引图
$cover['Filedata'] = $_FILES['Filedata'];
$cover2['Filedata'] = $_FILES['Filedata2'];
include_once ROOT_PATH . 'lib/class/material.class.php';
$material = new material();
if ($cover['Filedata']) {
$re = $material->addMaterial($cover);
$cover = array();
$cover = array('host' => $re['host'], 'dir' => $re['dir'], 'filepath' => $re['filepath'], 'filename' => $re['filename']);
$update_data['index_pic'] = addslashes(serialize($cover));
}
//上传默认图
if ($cover2['Filedata']) {
$re2 = $material->addMaterial($cover2);
$cover2 = array();
$cover2 = array('host' => $re2['host'], 'dir' => $re2['dir'], 'filepath' => $re2['filepath'], 'filename' => $re2['filename']);
$update_data['default_pic'] = addslashes(serialize($cover2));
}
$ret = $this->mode->update($this->input['id'], $update_data);
if ($ret) {
//如果内容有更新才更新以下内容
$update_data['update_user_name'] = $this->user['user_name'];
$update_data['update_user_id'] = $this->user['user_id'];
$update_data['update_org_id'] = $this->user['org_id'];
$update_data['update_time'] = TIMENOW;
$update_data['update_ip'] = $this->user['ip'];
$sql = "UPDATE " . DB_PREFIX . "grade_style SET \n\t\t\t\t\tupdate_user_name ='" . $update_data['update_user_name'] . "',\n\t\t\t\t\tupdate_user_id = '" . $update_data['update_user_id'] . "',\n\t\t\t\t\tupdate_org_id = '" . $update_data['update_org_id'] . "',\n\t\t\t\t\tupdate_ip = '" . $update_data['update_ip'] . "', \n\t\t\t\t\tupdate_time = '" . TIMENOW . "' WHERE id=" . $this->input['id'];
$this->db->query($sql);
//更新描述
if ($this->input['is_describe']) {
$names = $this->input['name'];
//简述词
$describes = $this->input['describe'];
//描述
if ($names || $describes) {
foreach ($names as $k => $v) {
$describe_data = array('style_id' => $vid, 'star' => $k, 'name' => trim($v), 'describes' => trim($describes[$k]));
$this->mode->update_describe($this->input['id'], $describe_data);
}
}
}
}
//$this->addLogs('更新',$ret,'','更新' . $this->input['id']);此处是日志,自己根据情况加一下
$this->addItem('success');
$this->output();
}
示例10: img_upload
public function img_upload($img_file)
{
$classfile = ROOT_PATH . 'lib/class/material.class.php';
if (is_file($classfile)) {
class_exists('material') or (include $classfile);
$material_pic = new material();
$img = array('Filedata' => $img_file);
if (!$this->settings['App_material']) {
return '';
}
$img_info = $material_pic->addMaterial($img);
$img_data = array('host' => $img_info['host'], 'dir' => $img_info['dir'], 'filepath' => $img_info['filepath'], 'filename' => $img_info['filename']);
return maybe_serialize($img_data);
}
return '';
}
示例11: events
public function events()
{
if (!env('student')) {
redirect('m=login');
}
$updisciplineId = val($_REQUEST, 'updisciplineId');
$learningMode = val($_REQUEST, 'learningMode');
if (empty($updisciplineId) || empty($learningMode)) {
throw new Exception('Missed required param', 404);
}
$updiscipline = entry_sql('SELECT * FROM updiscipline WHERE updisciplineId=:updisciplineId', array(':updisciplineId' => $updisciplineId));
if (empty($updiscipline)) {
throw new Exception('Updiscipline not found', 404);
}
$groupPeriod = entry_sql('SELECT gp.* FROM group_history gh INNER JOIN group_period gp USING(groupPeriodId) WHERE gh.studentId=:studentId AND gp.sersemester=:sersemester', array('studentId' => studentId(), 'sersemester' => $updiscipline['sersemester']));
if (empty($groupPeriod)) {
throw new Exception('Cannot detect groupPeriod', 404);
}
$events = entries_sql('SELECT * FROM event WHERE updisciplineId=:updisciplineId AND groupPeriodId=:groupPeriodId AND learningMode=:learningMode', array('groupPeriodId' => $groupPeriod['groupPeriodId'], 'updisciplineId' => $updiscipline['updisciplineId'], 'learningMode' => $learningMode));
array_walk($events, function (&$event, $k, $studentId) {
$event['c'] = material::i($event['instanceType'])->c();
$event['grade'] = material::i($event['instanceType'])->get_grade($event['instanceId'], $studentId);
}, studentId());
env('breadcrumbs', array(array(lng('up:disciplines'), '/?c=up'), array($updiscipline['disciplineName'], '/?c=up&m=events&updisciplineId=' . $updisciplineId . '&learningMode=' . $learningMode), lng('up:events')));
tpl('up/events', array('updiscipline' => $updiscipline, 'events' => $events, 'result' => entry_sql('SELECT * FROM result WHERE studentId=:studentId AND updisciplineId=:updisciplineId AND learningMode=:learningMode', array('studentId' => studentId(), 'updisciplineId' => $updiscipline['updisciplineId'], 'learningMode' => $learningMode))));
}
示例12: _up_breadcrumbs
protected function _up_breadcrumbs($event)
{
$updiscipline = entry_sql('SELECT * FROM updiscipline WHERE updisciplineId=:updisciplineId', array(':updisciplineId' => $event['updisciplineId']));
if (empty($updiscipline)) {
throw new Exception('Cannot fetch updiscipline "' . $event['updisciplineId'] . '"', 500);
}
return array(array(lng('up:disciplines'), '/?c=up'), array($updiscipline['disciplineName'], '/?c=up&m=events&updisciplineId=' . $event['updisciplineId'] . '&learningMode=' . $event['learningMode']), lng('up:events'), array($event['name'], '/?c=' . material::i($event['instanceType'])->c() . '&eventId=' . $event['eventId'] . '&id=' . $event['instanceId']));
}
示例13: upload
/**
* 上传图片
*/
public function upload()
{
if (!$_FILES['Filedata']) {
$this->errorOutput(PARAM_WRONG);
}
$material = new material();
$result = $material->addMaterial($_FILES, '', '', '', '', 'png');
if (!$result) {
$this->errorOutput(FAILED);
}
$flag = !!$this->input['flag'];
if ($flag) {
$picData = array('material_id' => $result['id'], 'name' => $result['name'], 'mark' => $result['mark'], 'type' => $result['type'], 'filesize' => $result['filesize'], 'imgwidth' => $result['imgwidth'], 'imgheight' => $result['imgheight'], 'host' => $result['host'], 'dir' => $result['dir'], 'filepath' => $result['filepath'], 'filename' => $result['filename'], 'user_id' => $this->user['user_id'], 'user_name' => $this->user['user_name'], 'org_id' => $this->user['org_id'], 'create_time' => $result['create_time'], 'ip' => $result['ip']);
$result = $this->api->create('app_material', $picData);
}
$this->addItem($result);
$this->output();
}
示例14: show
public function show()
{
$dir = TARGET_DIR . 'livesnap/';
$time = $this->input['time'] ? $this->input['time'] : TIMENOW;
$material = new material();
$handle = dir($dir);
$snaps = array();
while ($file = $handle->read()) {
if ($file == '.' || $file == '..' || !intval($file)) {
continue;
}
if (!is_dir($dir . $file . '/')) {
continue;
}
$sdir = $dir . $file . '/';
$handle1 = dir($sdir);
$i = 0;
while ($file1 = $handle1->read()) {
if (!is_file($sdir . $file1)) {
continue;
}
$vv = $sdir . $file1;
$k = $file;
@copy($vv, $dir . '/live_' . $k . '.png');
$vv = $dir . '/live_' . $k . '.png';
if (defined("TARGET_VIDEO_DOMAIN")) {
$pic = 'http://' . ltrim(TARGET_VIDEO_DOMAIN, 'http://') . '/' . 'livesnap/live_' . $k . '.png';
} else {
$pic = $this->settings['videouploads']['protocol'] . $this->settings['videouploads']['host'] . '/' . 'livesnap/live_' . $k . '.png';
}
$kk = filemtime($vv);
if (time() - $kk < 2) {
$img_info = $material->addMaterialNodb($pic, 1, 'livesnap/img/' . date('Y', $kk) . '/' . date('m', $kk));
$this->addItem($img_info[0]);
} else {
@unlink($vv);
}
$i++;
}
}
$this->output();
}
示例15: update
public function update()
{
$starttime = explode('-', $this->input['astrostart']);
$astrostart = mktime(0, 0, 0, $starttime[0], $starttime[1], 0);
unset($starttime);
$endtime = explode('-', $this->input['astroend']);
$astroend = mktime(0, 0, 0, $endtime[0], $endtime[1], 0);
unset($endtime);
$data = array('id' => intval($this->input['id']), 'name' => trim($this->input['name']), 'astrointroduction' => trim($this->input['astrointroduction']), 'astrostart' => trim($astrostart), 'astroend' => trim($astroend));
if (!$data['id']) {
$this->errorOutput("ID不能为空");
}
if (!$data['name']) {
$this->errorOutput("星座名不能为空");
}
$sql = 'SELECT astroimg FROM ' . DB_PREFIX . 'astro_app_info WHERE id = ' . $data['id'];
$res = $this->db->query_first($sql);
$astroimg = unserialize($res['astroimg']) ? unserialize($res['astroimg']) : array();
$logo['Filedata'] = $_FILES['logo'];
if ($logo['Filedata']) {
include_once ROOT_PATH . 'lib/class/material.class.php';
$material = new material();
$re = $material->addMaterial($logo);
$logo = array();
$logo = array('host' => $re['host'], 'dir' => $re['dir'], 'filepath' => $re['filepath'], 'filename' => $re['filename']);
} else {
$logo = $astroimg;
}
$where = ' WHERE 1 ';
$where .= ' AND id = ' . $data['id'];
$sql = 'UPDATE ' . DB_PREFIX . 'astro_app_info' . ' SET astrocn = "' . $data['name'] . '",astrointroduction = "' . $data['astrointroduction'] . '", astroimg ="' . addslashes(serialize($logo)) . '",astrostart = "' . $data['astrostart'] . '",astroend = "' . $data['astroend'] . '"' . $where;
//$this->errorOutput($sql);
$this->db->query($sql);
$this->constellation->updatetime_orerid($data['id'], 'info');
$data['logo'] = $logo;
$this->addItem($data);
$this->output();
}