Beispiel #1
0
//var_dump($res);

if(empty($res)) {  echo "已花费时间:".$eclapsetime; exit('处理完毕!');}

$uidlist='';
$comma='';
foreach($res as $k=>$v){
	$filename=$v['mainimg'];
	if(!file_exists('/wwwroot/zays/'.$filename)){
		$_r_=array();
	    $sql="select `imgurl` from web_pic where uid={$v['uid']}";
	    $_r_=$GLOBALS['_MooClass']['MooMySQL']->getOne($sql);
		if(!empty($_r_)) $filename=$_r_['imgurl'];
	}
	
    if(file_exists('/wwwroot/zays/'.$filename)) savePhoto($v['uid'],$filename);
   
    
	$filename = str_replace(".","_nowater.",$filename);
	if(file_exists('/wwwroot/zays/'.$filename)) {
	    @unlink('/wwwroot/zays/'.$filename);
	}
					
   $uidlist.=$comma;
   $uidlist.=$v['uid'];
   $comma=',';
}

//echo $uidlist;exit;

if($uidlist){
Beispiel #2
0
function check_photo()
{
    $sid = $GLOBALS['adminid'];
    $pass = MooGetGPC('pass', 'integer');
    $type = MooGetGPC('type', 'string') == '' ? 'list' : MooGetGPC('type', 'string');
    $usersid = MooGetGPC('usersid', 'string', 'G');
    $lei = "会员形象照审核";
    $uid = MooGetGPC('uid', 'integer');
    $id = MooGetGPC('id', 'integer');
    $checkArr = array(1 => '审核通过', 0 => '未审核');
    switch ($type) {
        case 'list':
            //note 获得当前url
            $currenturl = "index.php?action=check&h=photo";
            $currenturl2 = preg_replace("/(&page=\\d+)/", "", $currenturl);
            $currenturl2 = preg_replace("/(&pass=\\d+)/", "", $currenturl2) . "&pass={$pass}";
            $currenturl2 = preg_replace("/(&usersid=\\d+)/", '', $currenturl2);
            $page = get_page();
            $prepage = 20;
            $start = ($page - 1) * $prepage;
            $sql_where = $sql_and = '';
            $condition[] = " WHERE images_ischeck={$pass}";
            //所管理的客服id列表
            if (isset($_GET['usersid']) && MooGetGPC('usersid', 'string', 'G') == 0) {
                salert("无所属客服");
            }
            if (empty($myservice_idlist)) {
                $condition[] = " sid IN({$GLOBALS['adminid']})";
            } elseif ($myservice_idlist == 'all') {
                if (isset($_GET['usersid'])) {
                    $condition[] = " sid='{$usersid}'";
                }
                //all为客服主管能查看所有的
            } else {
                $condition[] = " sid IN({$myservice_idlist})";
                if (isset($_GET['usersid'])) {
                    $condition[] = " sid='{$usersid}'";
                }
            }
            if (!empty($uid)) {
                $condition[] = " uid='{$uid}'";
            }
            $sql_where = implode(' AND', $condition);
            $sql = "SELECT count(1) as c FROM {$GLOBALS['dbTablePre']}members {$sql_where}";
            $total_count = $GLOBALS['_MooClass']['MooMySQL']->getOne($sql);
            //			echo $sql;
            //			echo '<br />';
            $total = $total_count['c'];
            $sql = "SELECT `mainimg`,`lastvisit`,`sid`,`uid`,`uid` AS id,`images_ischeck` AS syscheck,`nickname`,`birthyear`,`gender` FROM {$GLOBALS['dbTablePre']}members {$sql_where} ORDER BY `lastvisit`,`uid` DESC LIMIT {$start},{$prepage}";
            $list = $GLOBALS['_MooClass']['MooMySQL']->getAll($sql);
            //			echo $sql;
            echo "<span style='display:none;'>{$sql}</span>";
            require adminTemplate("check_list");
            break;
        case 'show':
            header("Cache-Control: no-cache, must-revalidate");
            // HTTP/1.1
            header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
            // 过去的时间
            $bili = "4:5";
            $photo = $GLOBALS['_MooClass']['MooMySQL']->getOne("SELECT `mainimg`,`images_ischeck` AS syscheck,`birthyear`,`gender` FROM {$GLOBALS['dbTablePre']}members WHERE `uid`='{$uid}'");
            $mainimg_preg = preg_replace("(\\.)", "_nowater.", $photo['mainimg']);
            $photo_src = $mainimg_preg;
            $photo_arr = explode('.', $photo_src);
            $count = count($photo_arr);
            $num = MooGetGPC('num', 'integer', 'G');
            if (isset($_GET['num'])) {
                if (file_exists('../' . $mainimg_preg)) {
                    $src = $photo_arr[0] . '.' . ($num + 1) % 4 . '.' . $photo_arr[$count - 1];
                } else {
                    $src = preg_replace("(_nowater)", '.' . ($num + 1) % 4, $mainimg_preg);
                }
                if (file_exists('../' . $src)) {
                    $photo['mainimg'] = $src;
                } else {
                }
            } else {
                $src = $mainimg_preg;
                if (file_exists('../' . $src)) {
                    $photo['mainimg'] = $src;
                }
            }
            $url = "http://" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
            //$user_introduce=$GLOBALS['_MooClass']['MooMySQL']->getOne("SELECT `introduce`,`introduce_check` FROM {$GLOBALS['dbTablePre']}choice WHERE `uid`='$uid'");
            serverlog(1, $dbTablePre . "members", "{$GLOBALS['username']}查询{$uid}会员印象照", $GLOBALS['adminid'], $uid);
            require adminTemplate("check_show");
            break;
        case 'submit':
            $is_pass = MooGetGPC('pass', 'string');
            $is_onpass = MooGetGPC('nopass', 'string');
            if ($is_onpass) {
                global $_MooClass, $dbTablePre;
                MooAutoLoad('MooFiles', 'libraries');
                if ($uid == '') {
                    salert('没用传入参数', 'index.php?action=check&h=list', 1);
                }
                $GLOBALS['_MooClass']['MooMySQL']->query("UPDATE {$GLOBALS['dbTablePre']}members SET `mainimg` = '',`pic_date` = '',`pic_name` = '',`images_ischeck`='-1' WHERE `uid`='{$uid}'");
                if (MOOPHP_ALLOW_FASTDB) {
                    $value['mainimg'] = '';
                    $value['pic_date'] = '';
                    $value['images_ischeck'] = '';
                    MooFastdbUpdate("members", 'uid', $uid, $value);
                }
                serverlog(2, $dbTablePre . "members", "{$GLOBALS['username']}未通过会员{$uid}的形象照" . $id, $GLOBALS['adminid'], $uid);
                if (MooGetGPC("userphoto", 'integer')) {
                    sendusermessage($uid, "您的形象照不符合图片要求,已被红娘删除,请您重新上传", "形象照审核");
                    //salert('成功设置形象照未通过');
                    $alert = '成功设置形象照未通过';
                }
            } else {
                if ($is_pass) {
                    $userphoto = MooGetGPC('userphoto', 'string');
                    $incoduce = MooGetGPC('incoduce', 'string');
                    $contentincoduce = MooGetGPC('contentincoduce', 'string');
                    if ($userphoto) {
                        //保存形象照
                        savePhoto($uid);
                        $filename = MooGetGPC('photoimage');
                        if (file_exists($filename)) {
                            $file_arr = explode('.', $filename);
                            $num = count($file_arr) - 2;
                            if (strlen($file_arr[$num]) == 1) {
                                $_MooClass['MooFiles']->fileDelete($filename);
                            }
                        }
                    }
                    //更新诚信值
                    reset_integrity($uid);
                    $alert = '审核成功';
                    //note 审核通过后,写入前台搜索表
                    fastsearch_update($uid, 1);
                    //note 写入常用搜索表
                    fastsearch_update($uid, 2);
                    //note 写入高级搜索表
                }
            }
            salert($alert, 'index.php?action=check&h=photo');
            break;
    }
}
Beispiel #3
0
    $newImg = imagecreatefromstring($fileContents);
    if ($newImg === false) {
        return false;
    }
    return imagepng($newImg, $target);
}
$file = "data.txt";
$data = file($file);
$count = 1;
$target_dir = './images';
if (!file_exists($target_dir)) {
    mkdir($target_dir);
}
if (!is_dir($target_dir)) {
    echo "{$target_dir} exists and is not a dir? I don't know what to do...\n";
    exit(1);
}
foreach ($data as $piclink) {
    $piclink = trim($piclink);
    if ($piclink == '') {
        continue;
    }
    $res = savePhoto($piclink, "{$target_dir}/{$count}.png");
    if ($res) {
        echo "Processing {$count}.png\r";
    } else {
        echo "\n{$count}.png not created! url: '{$piclink}'\n";
    }
    $count++;
}
echo "\nDone!\n\n";
			$pic = null;
			exec("./exif/Image-ExifTool-9.56/exiftool -a -u -j -g1 '$filename' ", $pic);
			
			$pic = join("\n", $pic);
			$g = json_decode($pic, true);
			$pos = $g[0]["Composite"]["GPSPosition"];
			$gpsresult = check_gps($pos);
			$_SESSION['gpsresult'] = $gpsresult;
			
			if($gpsresult){
				$location = decimal_lat_long($pos);
				$lat = $location[0];
				$long = $location[1];
				$_SESSION['lat'] = $lat;
				$_SESSION['lon'] = $long;
				savePhoto($usrn, $filename, $lat, $long, $alname);
			}else{ 
			unlink(realpath($filename));
			}
		}
	 // }
	/*else
	  {
	  echo "Invalid file";
	  }*/
?>

<html>
 <head>
	  <style>
      #map_canvas {
        }
    }
    $response = $response->withHeader('Content-type', 'application/json;charset=utf-8');
    return $response->write(json_encode($res));
});
// Send photo
$app->post('/toilet-add-photo', function ($request, $response, $args) {
    $uuid = $request->getParsedBody()['uuid'];
    $toilet_id = $request->getParsedBody()['toilet_id'];
    $files = $request->getUploadedFiles();
    $result = array();
    $photo = '';
    if (isset($files['photo'])) {
        $photo = $files['photo'];
    }
    $result['error'] = savePhoto($uuid, $toilet_id, $photo);
    $response = $response->withHeader('Content-type', 'application/json;charset=utf-8');
    return $response->write(json_encode($result));
});
// Send comment
$app->post('/toilet-add-comment', function ($request, $response, $args) {
    $uuid = $request->getParsedBody()['uuid'];
    $toilet_id = $request->getParsedBody()['toilet_id'];
    $username = $request->getParsedBody()['username'];
    $content = $request->getParsedBody()['content'];
    $result = array();
    $result['error'] = saveComment($uuid, $toilet_id, $username, $content);
    $response = $response->withHeader('Content-type', 'application/json;charset=utf-8');
    return $response->write(json_encode($result));
});
// Get photo list for a given toilet sheet
Beispiel #6
0
/**
 *  usersid : -1 无限
 *          :0   0客服
 */
function check_photo()
{
    global $_MooCookie, $dbTablePre, $allow_order, $rsort;
    //$sid=$GLOBALS['adminid'];
    //$pass = MooGetGPC('pass','integer','R');
    $type = MooGetGPC('type', 'string', 'R') == '' ? 'list' : MooGetGPC('type', 'string', 'R');
    //$usersid=MooGetGPC('usersid','string','R');
    $lei = "会员形象照审核";
    $uid = MooGetGPC('uid', 'integer', 'R');
    $id = MooGetGPC('id', 'integer', 'R');
    $myservice_idlist = get_myservice_idlist();
    $checkArr = array(1 => '审核通过', 2 => '未审核');
    switch ($type) {
        case 'list':
            //note 获得当前url
            $pass = MooGetGPC('pass', 'integer', 'R');
            //是否审核
            $pass = $pass ? $pass : 2;
            //分页
            $page = get_page();
            $prepage = 20;
            $start = ($page - 1) * $prepage;
            $sql_where = $sql_and = '';
            $condition[] = " WHERE s.images_ischeck={$pass}";
            //返回的会员ID
            $usersid = MooGetGPC('usersid', 'string', 'R');
            if ($usersid === null) {
                $usersid = -1;
            } else {
                $usersid = intval($usersid);
            }
            //echo $_MooCookie['usersid'].'and'.$usersid;
            if (isset($_MooCookie['usersid']) && $_MooCookie['usersid'] != $usersid || MooGetGPC('submit', 'string', 'P')) {
                //刷新了会员
                $start = 0;
            }
            //==各组权限==
            if (empty($myservice_idlist) || $myservice_idlist === $GLOBALS['adminid']) {
                //本客服
                $condition[] = " s.sid ={$GLOBALS['adminid']}";
            } elseif ($myservice_idlist == 'all') {
                //all为客服主管能查看所有的
                if ($usersid >= 0) {
                    $condition[] = " s.sid='{$usersid}'";
                }
                $adminUser = $GLOBALS['_MooClass']['MooMySQL']->getAll("select uid,username from web_admin_user", 0, 0, 0, true);
            } else {
                $condition[] = " s.sid IN({$myservice_idlist})";
                if ($usersid >= 0) {
                    $condition[] = " s.sid='{$usersid}'";
                }
                $adminUser = $GLOBALS['_MooClass']['MooMySQL']->getAll("select uid,username from web_admin_user  where uid in ({$myservice_idlist}) ", 0, 0, 0, true);
            }
            $currenturl = "index.php?action=check&h=photo&pass={$pass}";
            $currenturl = preg_replace("/(&page=\\d+)/", "", $currenturl);
            $currenturl2 = preg_replace("/(&pass=\\d+)/", "", $currenturl) . "&pass={$pass}";
            //如果按照uid查看,客服是不限的
            if (!empty($uid)) {
                $condition[] = " s.uid='{$uid}'";
                $usersid = -1;
            }
            if ($usersid >= 0) {
                $currenturl2 = $currenturl = $currenturl2 . "&usersid={$usersid}";
            }
            $sql_where = implode(' AND', $condition);
            MooSetCookie('usersid', $usersid);
            //写当前所属客服COOKIE
            //排序
            $query_builder = get_query_builder($sql_where, $allow_order, '', '', 'pic_date', 'asc', $rsort);
            $sort_arr = $query_builder['sort_arr'];
            $rsort_arr = $query_builder['rsort_arr'];
            $sql_sort = $query_builder['sort'];
            $order = MooGetGPC('order', 'string', 'R');
            $method = MooGetGPC('method', 'string', 'R');
            if (!empty($order) && !empty($method)) {
                $sql_sort = "order by {$order} {$method} ";
                $currenturl2 .= "&order={$order}&method={$method}";
            }
            $sql = "SELECT count(1) as c FROM {$GLOBALS['dbTablePre']}members_search as s left join {$GLOBALS['dbTablePre']}members_base b on s.uid=b.uid {$sql_where}";
            $total_count = $GLOBALS['_MooClass']['MooMySQL']->getOne($sql, true);
            $total = $total_count['c'];
            $sql = "SELECT `mainimg`,`lastvisit`,`allotdate`,`sid`,s.uid,s.uid as id,`images_ischeck` AS syscheck,`nickname`,`birthyear`,`gender` FROM {$GLOBALS['dbTablePre']}members_search as s left join {$GLOBALS['dbTablePre']}members_base as b on s.uid=b.uid left join {$GLOBALS['dbTablePre']}members_login as l on l.uid=b.uid  {$sql_where} {$sql_sort} LIMIT {$start},{$prepage}";
            //`lastvisit`,
            $list = array();
            $list = $GLOBALS['_MooClass']['MooMySQL']->getAll($sql, 0, 0, 0, true);
            //获取形象照的上传日期
            foreach ($list as $key => $val) {
                $uidpic = $val['uid'];
                $sql = "select pic_date from web_pic where uid='{$uidpic}'";
                $resultpic = $GLOBALS['_MooClass']['MooMySQL']->getOne($sql);
                if (!empty($resultpic)) {
                    $picdate = date('Y-m-d', strtotime($resultpic['pic_date']));
                    $list[$key]['pic_date'] = $picdate;
                } else {
                    $list[$key]['pic_date'] = null;
                }
            }
            $currenturl = $currenturl2;
            require adminTemplate("check_list");
            break;
        case 'show':
            header("Cache-Control: no-cache, must-revalidate");
            // HTTP/1.1
            header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
            // 过去的时间
            $bili = "4:5";
            $photo = MooMembersData($uid);
            //var_dump($photo);echo '<br/>';
            $mainimg_preg = preg_replace("(\\.)", "_nowater.", $photo['mainimg']);
            //var_dump($mainimg_preg);
            $photo_src = $mainimg_preg;
            $photo_arr = explode('.', $photo_src);
            $count = count($photo_arr);
            $num = MooGetGPC('num', 'integer', 'G');
            if (isset($_GET['num'])) {
                if (file_exists('../' . $mainimg_preg)) {
                    $src = $photo_arr[0] . '.' . ($num + 1) % 4 . '.' . $photo_arr[$count - 1];
                } else {
                    $src = preg_replace("(_nowater)", '.' . ($num + 1) % 4, $mainimg_preg);
                }
                if (file_exists('../' . $src)) {
                    $photo['mainimg'] = $src;
                } else {
                }
            } else {
                $src = $mainimg_preg;
                if (file_exists('../' . $src)) {
                    $photo['mainimg'] = $src;
                }
            }
            //==========页面返回url=====取值================================
            $usersid = MooGetGPC('usersid', 'string', 'R');
            if ($usersid === null) {
                $usersid = -1;
            } else {
                $usersid = intval($usersid);
            }
            MooSetCookie('usersid', null);
            //作为标志位
            $url = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
            $url = preg_replace("/www./", "", $url);
            $url2 = $url;
            $url = preg_replace("/show/", "list", $url);
            $url = preg_replace("/&uid=\\d+/", "", $url);
            $url = preg_replace("/&usersid=\\d+/", "", $url);
            $url .= "&usersid={$usersid}";
            serverlog(1, $dbTablePre . "members_search", "{$GLOBALS['username']}查询{$uid}会员印象照", $GLOBALS['adminid'], $uid);
            require adminTemplate("check_show");
            break;
        case 'submit':
            $is_pass = MooGetGPC('pass', 'string', 'P');
            $is_onpass = MooGetGPC('nopass', 'string', 'P');
            if ($is_onpass) {
                global $_MooClass, $dbTablePre;
                MooAutoLoad('MooFiles', 'libraries');
                if ($uid == '') {
                    salert('没用传入参数', 'index.php?action=check&h=list', 1);
                }
                $GLOBALS['_MooClass']['MooMySQL']->query("UPDATE {$GLOBALS['dbTablePre']}members_search SET  `images_ischeck`='0' WHERE `uid`='{$uid}'");
                searchApi('members_man members_women')->updateAttr(array('images_ischeck'), array($uid => array(2)));
                $GLOBALS['_MooClass']['MooMySQL']->query("UPDATE {$GLOBALS['dbTablePre']}members_base SET `mainimg` = '',`pic_date` = '',`pic_name` = '' WHERE `uid`='{$uid}'");
                //更新索引数据的属性值
                if (MOOPHP_ALLOW_FASTDB) {
                    $value_b['mainimg'] = '';
                    $value_b['pic_date'] = '';
                    $value_s['images_ischeck'] = '2';
                    MooFastdbUpdate("members_search", 'uid', $uid, $value_s);
                    MooFastdbUpdate("members_base", 'uid', $uid, $value_b);
                }
                serverlog(2, $dbTablePre . "members_search", "{$GLOBALS['username']}未通过会员{$uid}的形象照" . $id, $GLOBALS['adminid'], $uid);
                if (MooGetGPC("userphoto", 'integer')) {
                    sendusermessage($uid, "您的形象照不符合图片要求,已被红娘删除,请您重新上传", "形象照审核");
                    //salert('成功设置形象照未通过');
                    $alert = '形象照未通过';
                }
                $url = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
                //http://7651.com/ework/index.php?action=check&h=photo&type=submit&id=21291982&uid=21291982
                // $url=preg_replace("/www./", "", $url);
                //$url=preg_replace("/submit/", "list", $url);
                //$url=preg_replace("/&uid=\d+/", "", $url);
                $usersid = MooGetGPC('usersid', 'string', 'R');
                if ($usersid < 0 || $usersid == null) {
                    $usersid = 0;
                    $sql = "SELECT `uid` FROM {$GLOBALS['dbTablePre']}members_search where images_ischeck=2  limit 1";
                    //`lastvisit`,
                } else {
                    $usersid = intval($usersid);
                    $sql = "SELECT `uid` FROM {$GLOBALS['dbTablePre']}members_search where images_ischeck=2 and sid={$usersid}  limit 1";
                    //`lastvisit`,
                }
                /*    $usersid=MooGetGPC('usersid','string','R');
                				if($usersid<0 || $usersid==null){ 
                					$usersid=-1;
                					$sql = "SELECT `uid` FROM {$GLOBALS['dbTablePre']}members_search where images_ischeck=0  limit 1";//`lastvisit`,
                				}else{
                					$usersid=intval($usersid);
                					$sql = "SELECT `uid` FROM {$GLOBALS['dbTablePre']}members_search where images_ischeck=0 and sid={$usersid}  limit 1";//`lastvisit`,
                				}
                			*/
                $list = $GLOBALS['_MooClass']['MooMySQL']->getOne($sql, true);
                if (!empty($list)) {
                    $url = preg_replace("/submit/", "show", $url);
                    $url = preg_replace("/&uid=\\d+/", "", $url);
                    $url = $url . "&uid={$list['uid']}&ispass=0";
                } else {
                    $url = preg_replace("/submit/", "list", $url);
                    $url = preg_replace("/&uid=\\d+/", "", $url);
                }
                salert($alert, $url);
                break;
            } elseif ($is_pass) {
                $userphoto = MooGetGPC('userphoto', 'string', 'P');
                //$incoduce=MooGetGPC('incoduce','string','P');
                //$contentincoduce=MooGetGPC('contentincoduce','string','P');
                if ($userphoto) {
                    //保存形象照
                    savePhoto($uid);
                    $filename = MooGetGPC('photoimage');
                    if (file_exists($filename)) {
                        $file_arr = explode('.', $filename);
                        $num = count($file_arr) - 2;
                        if (strlen($file_arr[$num]) == 1) {
                            $_MooClass['MooFiles']->fileDelete($filename);
                        }
                    }
                }
                //更新诚信值
                reset_integrity($uid);
                $alert = '审核成功';
                //note 审核通过后,写入前台搜索表
                //                fastsearch_update($uid,1); //note 写入常用搜索表
                //                fastsearch_update($uid,2); //note 写入高级搜索表
                $url = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
                //http://7651.com/ework/index.php?action=check&h=photo&type=submit&id=21291982&uid=21291982
                $url = preg_replace("/www./", "", $url);
                $usersid = MooGetGPC('usersid', 'string', 'R');
                if ($usersid < 0 || $usersid == null) {
                    $usersid = 0;
                    $sql = "SELECT `uid` FROM {$GLOBALS['dbTablePre']}members_search where images_ischeck=2  limit 1";
                    //`lastvisit`,
                } else {
                    $usersid = intval($usersid);
                    $sql = "SELECT `uid` FROM {$GLOBALS['dbTablePre']}members_search where images_ischeck=2 and sid={$usersid}  limit 1";
                    //`lastvisit`,
                }
                /*    $usersid=MooGetGPC('usersid','string','R');
                				if($usersid<0 || $usersid==null){ 
                					$usersid=-1;
                					$sql = "SELECT `uid` FROM {$GLOBALS['dbTablePre']}members_search where images_ischeck=0  limit 1";//`lastvisit`,
                				}else{
                					$usersid=intval($usersid);
                					$sql = "SELECT `uid` FROM {$GLOBALS['dbTablePre']}members_search where images_ischeck=0 and sid={$usersid}  limit 1";//`lastvisit`,
                				}
                			*/
                $list = $GLOBALS['_MooClass']['MooMySQL']->getOne($sql, true);
                if (!empty($list)) {
                    $url = preg_replace("/submit/", "show", $url);
                    $url = preg_replace("/&uid=\\d+/", "", $url);
                    $url = $url . "&uid={$list['uid']}&ispass=0";
                } else {
                    $url = preg_replace("/submit/", "list", $url);
                    $url = preg_replace("/&uid=\\d+/", "", $url);
                }
                salert($alert, $url);
                break;
            }
    }
}
Beispiel #7
0
print_r($search);
foreach ($search['photo'] as $photo) {
    $photoid_match = $photo['id'];
    //echo($photoid_match);
    //	if ($photo['id'] <= $since_id) continue;
    $idmatches = preg_grep("#{$photoid_match}#", $allflickrids);
    //	print_r($idmatches);
    if (sizeof($idmatches) > 0) {
        continue;
    }
    $owner = $f->people_getInfo($photo['owner']);
    $info = $f->photos_getInfo($photo['id']);
    $geo = $f->photos_geo_getLocation($photo['id']);
    //	print_r($info);
    $obslat = $geo['location']['latitude'];
    $obslng = $geo['location']['longitude'];
    $flickrid = quote_smart(htmlentities(strip_tags($photo['id'])));
    $obsdatetime = quote_smart(htmlentities(strip_tags($info['dates']['taken'])));
    $obstype = quote_smart('flickr');
    $obsemail = quote_smart(htmlentities(strip_tags($owner['username'])));
    $obsnotes = quote_smart(htmlentities(strip_tags($photo['title'])));
    $link_a = "http://www.flickr.com/photos/" . $photo['owner'] . "/" . $photo['id'];
    $link = quote_smart($link_a);
    $photolink_d = 'http://farm' . $info['farm'] . '.static.flickr.com/' . $info['server'] . '/' . $info['id'] . '_' . $info['secret'] . '_m.jpg';
    savePhoto($photolink_d, $photo['id']);
    $photolink = quote_smart($photolink_d);
    $insert = sprintf("INSERT INTO icrows (id, flickrid, obsdatetime, obstype, flickrowner, obsnotes, obslat, obslng, link, photolink) VALUES ('',%s,%s,%s,%s,%s,%s,%s,%s,%s)", $flickrid, $obsdatetime, $obstype, $obsemail, $obsnotes, $obslat, $obslng, $link, $photolink);
    //	echo("$insert" . "\n<br>");
    $result = mysql_query($insert, $mysqllink);
    echo "inserted {$flickrid} ? {$result}\n<br>";
}
Beispiel #8
0
require_once 'Klase/KorisnikDao.php';
require_once 'Klase/Korisnik.php';
require_once 'Klase/SlikaDao.php';
require_once 'Klase/Slika.php';
if (isset($_FILES["file"]["type"])) {
    $validextensions = array("jpeg", "jpg", "png");
    $temporary = explode(".", $_FILES["file"]["name"]);
    $file_extension = end($temporary);
    if (($_FILES["file"]["type"] == "image/png" || $_FILES["file"]["type"] == "image/jpg" || $_FILES["file"]["type"] == "image/jpeg") && $_FILES["file"]["size"] < 10000000 && in_array($file_extension, $validextensions)) {
        if ($_FILES["file"]["error"] > 0) {
            echo "Return Code: " . $_FILES["file"]["error"] . "<br/><br/>";
        } else {
            if (file_exists("uploads/" . $_FILES["file"]["name"])) {
                echo $_FILES["file"]["name"] . " <span id='invalid'><b>already exists.</b></span> ";
            } else {
                savePhoto($file_extension);
            }
        }
    } else {
        echo "<span id='invalid'>***Invalid file Size or Type***<span>";
    }
}
function savePhoto($file_extension)
{
    try {
        $sourcePath = $_FILES['file']['tmp_name'];
        // Storing source path of the file in a variable
        $hash = md5(time() . $_FILES['file']['name']);
        $fileName = $_FILES['file']['name'];
        $_FILES['file']['name'] = $hash . "." . $file_extension;
        $targetPath = "uploads/" . $_FILES['file']['name'];