Example #1
0
 /**
  * 微信处理图片
  */
 public static function fitImage($obj, Users $user)
 {
     #判断图片是否开启
     $pic_save_status = Yii::app()->cache->get("qys_pic_save_" . $user->user_id);
     $count = Pic::model()->count("user_id=:user_id", array(":user_id" => $user->user_id));
     if ($pic_save_status == false) {
         $content = "没有开启保存图片功能,该图片不会被服务器保存.";
     } elseif ($count >= 20) {
         $content = "图片已经超过20张,不再做保存。";
     } else {
         $count = Pic::model()->count("user_id=:user_id", array(":user_id" => $user->user_id));
         #获得图片地址
         $pic = file_get_contents($obj->PicUrl);
         $picname = time() . "_" . $user->user_id . ($count + 1) . ".gif";
         $pic_path = Yii::getPathOfAlias('webroot') . '/date/uplaod/';
         $pic_show_path = '/date/uplaod/';
         file_put_contents($pic_path . $picname, $pic);
         if (file_exists($pic_path . $picname)) {
             #小图保存
             $simage = Yii::app()->image->load($pic_path . $picname);
             $simage->resize(80, 80);
             $simage->save($pic_path . "s_" . $picname);
             #中图保存
             $mimage = Yii::app()->image->load($pic_path . $picname);
             $mimage->resize(240, 240);
             $mimage->save($pic_path . "m_" . $picname);
             #大图保存
             $bimage = Yii::app()->image->load($pic_path . $picname);
             $bimage->save($pic_path . "b_" . $picname);
             $userPic = new Pic();
             $picArray = array('user_id' => $user->user_id, 'pic_type' => 0, 'pic_s_img' => $pic_show_path . "s_" . $picname, 'pic_m_img' => $pic_show_path . "m_" . $picname, 'pic_b_img' => $pic_show_path . "n_" . $picname);
             $userPic->setAttributes($picArray);
             if ($userPic->validate() && $userPic->save()) {
                 $content = "图片已经保存。";
             } else {
                 $content = "图片保存失败,请重新发送。";
             }
         } else {
             $content = "保存失败。";
         }
         unlink($pic_path . $picname);
     }
     WechatCheck::_transmitText($obj, $content);
 }
Example #2
0
 /**
  * 
  * @return string
  */
 public static function getPRepay($object, Users $weixinuser)
 {
     $count = Pic::model()->count("user_id=:user_id", array(":user_id" => $weixinuser->user_id));
     if ($count < 20) {
         Yii::app()->cache->set("qys_pic_save_" . $weixinuser->user_id, $count);
         $content = "亲爱的用户,已经为你开启保存图片服务,当前已经保存了" . $count . "张,还能保存" . (20 - $count) . "张。";
     } else {
         $content = "亲爱的用户,您已经保存了20张图片,将不再给予保存。";
     }
     WechatCheck::_transmitText($object, $content);
 }
Example #3
0
function save_pic($url, $nick, $comment, $saved_file, $ext)
{
    global $fetch_log;
    $file_name = md5_file($saved_file);
    $path = STORAGE_PATH . $file_name . '.' . $ext;
    rename($saved_file, $path);
    $thumb_path = THUMB_PATH . $file_name . '.jpg';
    list($w, $h) = create_thumb($path, $thumb_path);
    chmod($path, 0664);
    chmod($thumb_path, 0664);
    $pic = new Pic(array('nick' => $nick, 'original_url' => $url, 'path' => $path, 'comment' => $comment, 'thumb' => $thumb_path, 'width' => $w, 'height' => $h, 'ctime' => date('Y-m-d H:i:s', $_SERVER['REQUEST_TIME'])));
    if (ORM::all('pic', array('checksum' => $pic->checksum))->count() === 0) {
        if ($pic->save()) {
            file_put_contents($fetch_log, "[" . date('Y-m-d H:i:s') . "]\t{$nick}\tpic save SUCCESS\t{$url}\n", FILE_APPEND);
        } else {
            file_put_contents($fetch_log, "[" . date('Y-m-d H:i:s') . "]\t{$nick}\terror saving image: " . var_export($pic->errors(), true) . "\t{$url}\n", FILE_APPEND);
        }
    } else {
        file_put_contents($fetch_log, "[" . date('Y-m-d H:i:s') . "]\t{$nick}\tduplicate image\t{$url}\n", FILE_APPEND);
    }
}
Example #4
0
 /**
  * This function builds the part of supporter logos.
  *
  * @access protected
  * @author kalmer
  * @param string                          $parameters['folder']       the
  * 		folder for the TPL-files
  * @param string                          $parameters['file']         the
  * 		TPL-file name without the ending
  * @param integer|string[string][integer] $parameters['logos']        the
  * 		logos, whereas the lowest-level-indexes are <code>hrefOLogo</code>,
  * 		<code>idInquiry</code> and <code>nimi</code>
  * @param string                          $parameters['block']        the
  * 		template block name
  * @param string                          $parameters['category']     the
  * 		supporter category
  * @param integer[string]                 $parameters['sizes']        the
  * 		<code>width</code> and <code>height</code> of the target logos
  * @param integer                         $parameters['minimalWidth'] If the
  * 		image is smaller than the given minimal width then our logo will be
  * 		shown instead.
  * @param integer $parameters['widthOfBlock']                         the
  * 		width of the block in pixels
  * @return string the parsed block of the logos
  * @uses DOMAIN for addressing
  * @uses O_FOLDER to access the manager for errors
  * @uses View     for managing errors
  */
 protected static function buildLogos($parameters)
 {
     require_once O_FOLDER . 'errors/ErrorView.php';
     \PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array(new ErroView(), 'raiseError'));
     require_once 'HTML/Template/IT.php';
     $tpl = new \HTML_Template_IT(dirname(__FILE__) . $folder);
     $tpl->loadTemplatefile($file . '.tpl');
     foreach ($logos as $idx => $logo) {
         require_once dirname(__FILE__) . '/../pildid/Pic.php';
         $firstImage = new Pic();
         $firstImage->getFirstImage('inquiry', $logo['idInquiry'], $sizes, isset($parameters['minimalWidth']) ? $parameters['minimalWidth'] : 200);
         $infoAboutFinalTargetInWeb = getimagesize($firstImage->src);
         $tpl->setCurrentBlock($block . '-supporter-logo');
         $tpl->setVariable(array($block . '-CAPTION-OF-LOGO' => $logo['nimi'], $block . '-CATEGORY-IN-LOGO' => $category['id'], $block . '-INDEX' => $idx, $block . '-LINK-OF-LOGO' => $logo['hrefOLogo'], $block . '-WIDTH-OF-LOGO' => $infoAboutFinalTargetInWeb[0], $block . '-HEIGHT-OF-LOGO' => $infoAboutFinalTargetInWeb[1], $block . '-SUPPORTER-LOGO' => $firstImage->src, $block . '-WIDTH-OF-BLOCK' => $parameters['widthOfBlock']));
         $tpl->parseCurrentBlock();
     }
     $tpl->setCurrentBlock($block . '-supporter-logos');
     $tpl->setVariable(array($block . '-CATEGORY' => $category['id'], $block . '-CATEGORY-TRANSLATION' => $category['translation']));
     $tpl->parseCurrentBlock();
     return $tpl->get($block . '-supporter-logos');
 }
Example #5
0
 /**
  * 获取图片路径
  * 
  * @param	int		$index	图片标示(调用者必须先判断该参数合法, 比如为用户图片的话,要先判断$index是否为合法QQ号)
  * @param	string	$type	图片类型
  * 
  * @return	string	若用户QQ号不正确, 返回空字符串, 否则返回图片路径
  */
 public static function getPhotoPath($index, $type)
 {
     self::clearERR();
     if (!in_array($type, self::$typeArr)) {
         self::$errCode = 10621;
         self::$errMsg = "input type-{$type} is illegal.";
         return false;
     }
     $mdstr = md5($index);
     $lvl1 = substr($mdstr, 0, 2);
     $lvl2 = substr($mdstr, -2);
     $oitstr = oi_symmetry_encrypt2($index, 'QzoneCommunity' . $type, true);
     $path = $type . '/' . $lvl1 . '/' . $lvl2 . '/' . $oitstr . '.jpg';
     return $path;
 }
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return Pic the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Pic::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Example #7
0
 /**
  * 选择图片
  */
 public function actionChangePro()
 {
     $this->pageTitle = "修改商品";
     $user_id = Yii::app()->user->getId();
     if (isset($_GET['id'])) {
         $product = Product::model()->find("product_id=:pid and product_user_id=:uid", array(":pid" => $_GET['id'], ":uid" => $user_id));
         if ($product) {
             if (isset($_POST) && isset($_POST['Product'])) {
                 #更改数据的处理
                 $picarray = $_POST['Product'];
                 if (isset($_POST['pic_id'])) {
                     $pic_select = Pic::model()->findByPk($_POST['pic_id'], "user_id=:user_id", array(":user_id" => $user_id));
                     if ($pic_select) {
                         $picarray['product_s_img'] = $pic_select->pic_s_img;
                         $picarray['product_m_img'] = $pic_select->pic_m_img;
                         $picarray['product_b_img'] = $pic_select->pic_b_img;
                     }
                 }
                 $product->setAttributes($picarray);
                 if ($product->validate() && $product->save()) {
                     $this->redirect(Yii::app()->createUrl('/wechat/product/addProduct'));
                 }
             }
             $this->render('product_ch', array("product" => $product));
             Yii::app()->end();
         }
     }
     $this->redirect(Yii::app()->createUrl('/wechat/product/index'));
 }
Example #8
0
                    } else {
                        $sinid .= ',' . $sval["pis_id"];
                    }
                }
                $sqlQuery = " SELECT pic_id, pic_name , pic_url, pic_uptime   FROM  " . SQL_PREFIX . "picture   WHERE pic_delete = 0 AND  pic_enabled = 1 and  pis_id in ( " . $sinid . " )  GROUP BY  pic_id ORDER BY pic_uptime DESC, `pic_id` LIMIT  0 , 8 ";
                $info[$akey]["Arr"] = $GLOBALS['MySql']->selectInfo($sqlQuery);
                foreach ($info[$akey]["Arr"] as $pkey => $pval) {
                    $info[$akey]["Arr"][$pkey]["pic_url"] = $GLOBALS['Helpe']->buildImg($info[$akey]["Arr"][$pkey]["pic_url"]);
                }
            }
        }
        $GLOBALS['Templ']->assign('webtitle', $webtitle);
        $GLOBALS['Templ']->assign('nowaddress', $nowaddress);
        $GLOBALS['Templ']->assign('info', $info);
        $GLOBALS['Templ']->display('picindex_tpl.html', $cache_id);
    }
}
$Pic = new Pic();
if ($GLOBALS['Webur']->getval["act"] == 'list') {
    $Pic->infolist();
} else {
    if ($GLOBALS['Webur']->getval["type"] == 'search') {
        $Pic->infolist();
    } else {
        if (intval($GLOBALS['Webur']->getval["idval"]) != '') {
            $Pic->detail();
        } else {
            $Pic->index();
        }
    }
}
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($idpic)
 {
     $pic = Pic::find($idpic)->delete();
     return Redirect::to('pic');
 }
Example #10
0
} else {
    echo '暂无图片';
}
?>
                    </div>
                </div>
                <div class="row qys_addp_row">
                    <div class="col-lg-6 col-md-6 col-xs-6 col-sm-6 text-left">更换产品图片:</div>
                    <div class="col-lg-6 col-md-6 col-xs-6 col-sm-6"></div>
                </div>
                <div class="row">
                    <div class="col-lg-12" style="text-align: left;">
                        <?php 
#获得当前用户的图片
$user_id = Yii::app()->user->getId();
$imagelist = Pic::model()->findAll("user_id=:user_id", array(":user_id" => $user_id));
foreach ($imagelist as $key => $value) {
    ?>
                        <label class="radio-inline">
                            <input type="radio" name="pic_id" value="<?php 
    echo $value->id;
    ?>
"> <img style="width:60px;height:40px;" src="<?php 
    echo $value->pic_s_img;
    ?>
"/>
                        </label>
                        <?php 
}
?>
                    </div>
<?php

if ($picId == 'new') {
    $picInsert = new PicInsert();
    $pic = new Pic();
} else {
    $picUpdate = new PicUpdate($picId);
    $pics = new Pics($picId);
    $pic = new Pic($pics->getPic());
}
$picDelete = new PicDelete($pic);
?>

<form enctype="multipart/form-data" class="box pics" method="post" action="<?php 
echo BASEPATH . DS . $page . DS . $tab . DS . $picId;
?>
" name="picform">
	<ul class="layout">
		<li>
			<label for="pic_name">Name: </label>
			<input id="pic_name" class="pic_input" type="text" value="<?php 
echo $pic->getName();
?>
" name="name" autocomplete="off" placeholder="Bildbeschreibung eingeben" required />
		</li>
		<li>
			<label for="pic_image">Image: </label><br>
			<img src="<?php 
echo $pic->getFilename();
?>
">