$fileName = time() . $_FILES["filename"]["name"]; $size = $_FILES['flImage']["size"]; $size = $size / 1024 / 1024; // converting in MB $MAX_FILESIZE = MAX_FILESIZE; if (move_uploaded_file($_FILES["filename"]["tmp_name"], "question_images/" . $fileName)) { list($width, $height) = getimagesize("question_images/" . $fileName); if ($width < MIN_ENTRY_RESOLUTION_WIDTH || $height < MIN_ENTRY_RESOLUTION_HEIGHT) { $isValidUpload = false; } else { $pic = new Thumbnail(); $pic->filename = "question_images/" . $fileName; $pic->filename2 = "question_images/image/image_" . $fileName; $pic->maxW = 400; $pic->SetNewWH(); $pic->MakeNew(); $pic->FinirPImage(); } } } ?> <!--------------content bar--------> <div id="main_bar"> <div id="main_box"> <div id="left_box"> <?php if ($_SESSION['admin_type'] == 1) {
public function fbauth($me) { //echo "it makes it here"; session_start(); unset($authData); $_SESSION[SESSION_AUTHDATA] = $authData; //$id=$me['id']; $db = new Database(); $db->connect(); $where = "`id`='" . $me['id'] . "' "; $db->select('`user`', '`id`,`name`,`accountstatusid`, `password`, `schoolid`', $where); $result = $db->getresult(); extract($result); //echo "its trying to auth with id". $id; if ($accountstatusid > 1 || $accountstatusid == -1) { $revports = FBData::$user_ports; $revports = array_flip($revports); if ($revports[$id] > 0) { $fbid = $revports[$id]; } else { $fbid = $id; } $authData = array(); $authData['name'] = $name; $authData['id'] = $id; $authData['fbid'] = $fbid; $authData['accountstatus'] = $accountstatusid; $authData['schoolid'] = $schoolid; $authData['fblogin'] = TRUE; $authData['logoutUrl'] = $me['fblogout']; $_SESSION['authData'] = $authData; session_write_close(); $friends = $me['friends']; $importfriendquery = "INSERT IGNORE INTO user(`id`,`name`,`password`,`accountstatusid`,`schoolid`) VALUES "; foreach ($friends as $arrid => $frienddata) { $fname = str_replace("'", "'", $frienddata['name']); $importfriendquery .= "('" . $frienddata['id'] . "','" . $fname . "','fblogin','1','" . $schoolid . "')"; if (!next($friends) === FALSE) { $importfriendquery .= ", "; } } $dbimport = new Database(); $dbimport->connect(); $dbimport->query($importfriendquery); if ($this->newuser == true) { return true; } else { return false; } } else { //register the new user automatically $affs = $me['affiliations']; $schoolid = -1; $affs2 = array_reverse($affs); if (is_array($affs2[0])) { foreach ($affs2 as $indaff) { if ($indaff['type'] == "college") { $schoolid = $indaff['nid']; $schoolname = $indaff['name']; break; } } } if ($me['id'] == "100002408771848") { $schoolid = -1; } if ($schoolid == "16777217") { $schoolid = 1; } $checkschool = "select name from school where id='" . $schoolid . "'"; $db = new Database(); $db->query($checkschool); $result = $db->getresult(); if (strlen($result['name'] < 1)) { $insertschool = "insert into school set id='" . $schoolid . "', name='" . $schoolname . "'"; $db->query($insertschool); } if ($me['gender'] == 'male') { $sex = 2; } else { $sex = 1; } $defaultpicture = "http://graph.facebook.com/" . $me['id'] . "/picture?type=large"; $contents = file_get_contents($defaultpicture); $target_path = "/home/newportb/public_html/photos/"; $firstsubset = rand(100000, 9999999); $secondsubset = rand(100000, 9999999); $thirdsubset = rand(1000000, 99989999); $generated_path = $target_path . $firstsubset . "_" . $secondsubset . "_" . $thirdsubset . "_n.jpg"; while (file_exists($generated_path)) { $firstsubset = rand(100000, 9999999); $secondsubset = rand(100000, 9999999); $thirdsubset = rand(1000000, 99989999); $generated_path = $target_path . $firstsubset . "_" . $secondsubset . "_" . $thirdsubset . "_n.jpg"; } $full_target_path = $target_path . $firstsubset . "_" . $secondsubset . "_" . $thirdsubset . "_f.jpg"; file_put_contents($full_target_path, $contents); //NORMAL $pic3 = new Thumbnail(); $pic3->filename = $full_target_path; $pic3->filename2 = $target_path . $firstsubset . "_" . $secondsubset . "_" . $thirdsubset . "_n.jpg"; $pic3->maxW = 170; $pic3->maxH = 400; $pic3->Text = ""; $pic3->SetNewWH(); $pic3->MakeNew(); $pic3->FinirPImage(); //SEARCH $pic2 = new Thumbnail(); $pic2->filename = $full_target_path; $pic2->filename2 = $target_path . $firstsubset . "_" . $secondsubset . "_" . $thirdsubset . "_s.jpg"; $pic2->maxW = 100; $pic2->maxH = 200; $pic2->Text = ""; $pic2->SetNewWH(); $pic2->MakeNew(); $pic2->FinirPImage(); //THUMBNAIL $pic2 = new Thumbnail(); $pic2->filename = $full_target_path; $pic2->filename2 = $target_path . $firstsubset . "_" . $secondsubset . "_" . $thirdsubset . "_t.jpg"; $pic2->maxW = 50; $pic2->maxH = 50; $pic2->Text = ""; $pic2->SetNewWH(); $pic2->MakeNew(); $pic2->FinirPImage(); unlink($full_target_path); $registerdate = date("Y-m-d"); $dtime = date('Y-m-d H:i:s'); $me['name'] = str_replace("'", "'", $me['name']); if ($accountstatusid != 1) { $newfbuser = "******" . $me['id'] . "', '" . $me['email'] . "', 'fblogin', '2', '" . $registerdate . "', '" . $me['name'] . "', '" . $schoolid . "', '', '', '', '1', '" . $sex . "', '', '" . $me['birthday'] . "', '', '', '', '', '');"; } else { $newfbuser = "******" . $me['email'] . "',\n\t\t\t\t\t`accountstatusid`='2', \n\t\t\t\t\t`registerdate`='" . $registerdate . "', \n\t\t\t\t\t`schoolid`='" . $schoolid . "', \n\t\t\t\t\t`schoolstatusid`='1', \n\t\t\t\t\t`sexid`='" . $sex . "', \n\t\t\t\t\t`birthday`='" . $me['birthday'] . "'\n\t\t\t\t\tWHERE `id`='" . $me['id'] . "' LIMIT 1\n\t\t\t\t\t"; } $updateprofile = "insert into `profileupdates` (`id`, `userid`, `timestamp`) VALUES (NULL, '" . $me['id'] . "', '" . $dtime . "');"; $setpicture = "insert into `picture` (`userid`, `albumid`, `link`) VALUES ('" . $me['id'] . "', '0', '" . $firstsubset . "_" . $secondsubset . "_" . $thirdsubset . "');"; $site = new site(); if ($site->get_setting('email_alerts') == 1) { $body = "Name: " . $me['name'] . ".<br>Email: " . $me['email']; email::send('*****@*****.**', 'New Registration', $body); } $db->query($newfbuser); $db->query($updateprofile); $db->query($setpicture); $this->newuser = true; $this->fbauth($me); return true; } }