public function providerUpdateDocuments()
 {
     $inputs = Input::all();
     $walker_id = Session::get('walker_id');
     foreach ($inputs as $key => $input) {
         $walker_document = WalkerDocument::where('walker_id', $walker_id)->where('document_id', $key)->first();
         if (!$walker_document) {
             $walker_document = new WalkerDocument();
         }
         $walker_document->walker_id = $walker_id;
         $walker_document->document_id = $key;
         if ($input) {
             $file_name = time();
             $file_name .= rand();
             $file_name = sha1($file_name);
             $ext = $input->getClientOriginalExtension();
             $input->move(public_path() . "/uploads", $file_name . "." . $ext);
             $local_url = $file_name . "." . $ext;
             // Upload to S3
             if (Config::get('app.s3_bucket') != "") {
                 $s3 = App::make('aws')->get('s3');
                 $pic = $s3->putObject(array('Bucket' => Config::get('app.s3_bucket'), 'Key' => $file_name, 'SourceFile' => public_path() . "/uploads/" . $local_url));
                 $s3->putObjectAcl(array('Bucket' => Config::get('app.s3_bucket'), 'Key' => $file_name, 'ACL' => 'public-read'));
                 $s3_url = $s3->getObjectUrl(Config::get('app.s3_bucket'), $file_name);
             } else {
                 $s3_url = asset_url() . '/uploads/' . $local_url;
             }
             // send email
             $get = Walker::where('id', '=', $walker_id)->first();
             $pattern = "Hi, " . $get->first_name . ", ID " . $walker_id . " Uploaded his/her Document and waiting for the admin Approval.";
             $subject = "Waiting for an Approval";
             /* email_notification('', 'admin', $pattern, $subject); */
             if (isset($walker_document->url)) {
                 if ($walker_document->url != "") {
                     $icon = $walker_document->url;
                     unlink_image($icon);
                 }
             }
             $walker_document->url = $s3_url;
             $walker_document->save();
             /* if ($walker_document->save()) {
                echo 'asdasd';
                } */
         }
     }
     $message = "Your documents are successfully updated.";
     $type = "success";
     return Redirect::to('/provider/documents')->with('message', $message)->with('type', $type);
 }
Ejemplo n.º 2
0
     if ($uid == $_SESSION['token']) {
         if ($del > 0) {
             $del = implode(',', $del);
             if (is_writeable(BASEDIR . '/load/files')) {
                 $querydel = DB::run()->query("SELECT `downs`.*, `cats`.* FROM `downs` LEFT JOIN `cats` ON `downs`.`downs_cats_id`=`cats`.`cats_id` WHERE `downs_id` IN (" . $del . ");");
                 $arr_script = $querydel->fetchAll();
                 DB::run()->query("DELETE FROM `commload` WHERE `commload_down` IN (" . $del . ");");
                 $deldowns = DB::run()->exec("DELETE FROM `downs` WHERE `downs_id` IN (" . $del . ");");
                 // Обновление счетчиков
                 DB::run()->query("UPDATE `cats` SET `cats_count`=`cats_count`-? WHERE `cats_id`=?", array($deldowns, $cid));
                 foreach ($arr_script as $delfile) {
                     $folder = $delfile['folder'] ? $delfile['folder'] . '/' : '';
                     if (!empty($delfile['downs_link']) && file_exists(BASEDIR . '/load/files/' . $folder . $delfile['downs_link'])) {
                         unlink(BASEDIR . '/load/files/' . $folder . $delfile['downs_link']);
                     }
                     unlink_image('load/screen/' . $folder, $delfile['downs_screen']);
                 }
                 notice('Выбранные файлы успешно удалены!');
                 //redirect("load.php?act=down&cid=$cid&start=$start");
             } else {
                 show_error('Ошибка! Не установлены атрибуты доступа на дирекоторию с файлами!');
             }
         } else {
             show_error('Ошибка! Отсутствуют выбранные файлы!');
         }
     } else {
         show_error('Ошибка! Неверный идентификатор сессии, повторите действие!');
     }
 } else {
     show_error('Ошибка! Удалять файлы могут только суперадмины!');
 }
Ejemplo n.º 3
0
 public function theme()
 {
     $th = Theme::all()->count();
     if ($th == 1) {
         $theme = Theme::first();
     } else {
         $theme = new Theme();
     }
     $theme->theme_color = '#' . Input::get('color1');
     $theme->secondary_color = '#' . Input::get('color3');
     $theme->primary_color = '#' . Input::get('color2');
     $theme->hover_color = '#' . Input::get('color4');
     $theme->active_color = '#' . Input::get('color5');
     $css_msg = ".btn-default {\n  color: #ffffff;\n  background-color: {$theme->theme_color};\n}\n.navbar-nav > li {\n  float: left;\n}\n.btn-info{\n    color: #000;\n    background: #fff;\n    border-radius: 0px;\n    border:1px solid {$theme->theme_color};\n}\n.nav-admin .dropdown :hover, .nav-admin .dropdown :hover {\n    background: {$theme->hover_color};\n    color: #000;\n}\n.navbar-nav > li > a {\n  border-radius: 0px;\n}\n.navbar-nav > li + li {\n  margin-left: 2px;\n}\n.navbar-nav > li.active > a,\n.navbar-nav> li.active > a:hover,\n.navbar-nav > li.active > a:focus {\n  color: #ffffff;\n  background-color: {$theme->active_color}!important;\n}\n.logo_img_login{\nborder-radius: 30px;border: 4px solid {$theme->theme_color};\n}\n.btn-success {\n  color: #ffffff;\n  background-color: {$theme->theme_color};\n  border-color: {$theme->theme_color};\n}\n.btn-success:hover,\n.btn-success:focus,\n.btn-success:active,\n.btn-success.active,\n.open .dropdown-toggle.btn-success {\n  color: #ffffff;\n  background-color: {$theme->theme_color};\n  border-color: {$theme->theme_color};\n\n}\n\n\n.btn-success.disabled,\n.btn-success[disabled],\nfieldset[disabled] .btn-success,\n.btn-success.disabled:hover,\n.btn-success[disabled]:hover,\nfieldset[disabled] .btn-success:hover,\n.btn-success.disabled:focus,\n.btn-success[disabled]:focus,\nfieldset[disabled] .btn-success:focus,\n.btn-success.disabled:active,\n.btn-success[disabled]:active,\nfieldset[disabled] .btn-success:active,\n.btn-success.disabled.active,\n.btn-success[disabled].active,\nfieldset[disabled] .btn-success.active {\n\n  background-color: {$theme->theme_color};\n  border-color: {$theme->theme_color};\n}\n.btn-success .badge {\n  color: {$theme->theme_color};\n  background-color: #ffffff;\n}\n.btn-info {\n  color: #ffffff;\n  background-color: {$theme->theme_color};\n  border-color: {$theme->theme_color};\n}\n.btn-info:hover,\n.btn-info:focus,\n.btn-info:active,\n.btn-info.active,\n.open .dropdown-toggle.btn-info {\n  color: #000;\n  background-color: #FFFF;\n  border-color: {$theme->theme_color};\n}\n.btn-info:active,\n.btn-info.active,\n.open .dropdown-toggle.btn-info {\n  background-image: none;\n}\n.btn-info.disabled,\n.btn-info[disabled],\nfieldset[disabled] .btn-info,\n.btn-info.disabled:hover,\n.btn-info[disabled]:hover,\nfieldset[disabled] .btn-info:hover,\n.btn-info.disabled:focus,\n.btn-info[disabled]:focus,\nfieldset[disabled] .btn-info:focus,\n.btn-info.disabled:active,\n.btn-info[disabled]:active,\nfieldset[disabled] .btn-info:active,\n.btn-info.disabled.active,\n.btn-info[disabled].active,\nfieldset[disabled] .btn-info.active {\n  background-color: {$theme->theme_color};\n  border-color: {$theme->theme_color};\n}\n.btn-info .badge {\n  color: {$theme->theme_color};\n  background-color: #029acf;\n  border-color: #029acf;\n}\n.btn-success,\n.btn-success:hover {\n  background-image: -webkit-linear-gradient({$theme->theme_color} {$theme->theme_color} 6%, {$theme->theme_color});\n  background-image: linear-gradient({$theme->theme_color}, {$theme->theme_color} 6%, {$theme->theme_color});\n  background-repeat: no-repeat;\n  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='{$theme->theme_color}', endColorstr='{$theme->theme_color}', GradientType=0);\n  filter: none;\n  border: 1px solid {$theme->theme_color};\n}\n.btn-info,\n.btn-info:hover {\n  background-image: -webkit-linear-gradient({$theme->theme_color}, {$theme->theme_color} 6%, {$theme->theme_color});\n  background-image: linear-gradient({$theme->theme_color}, {$theme->theme_color} 6%, {$theme->theme_color});\n  background-repeat: no-repeat;\n  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='{$theme->theme_color}', endColorstr='{$theme->theme_color}', GradientType=0);\n  filter: none;\n  border: 1px solid {$theme->theme_color};\n}\n.logo h3{\n    margin: 0px;\n    color: {$theme->theme_color};\n}\n\n.second-nav{\n    background: {$theme->theme_color};\n}\n.login_back{background-color: {$theme->theme_color};}\n.no_radious:hover{background-image: -webkit-linear-gradient({$theme->theme_color}, {$theme->theme_color} 6%, {$theme->theme_color});background-image: linear-gradient(#5d4dd1, #5d4dd1 6%, #5d4dd1);background-repeat: no-repeat;filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#5d4dd1', endColorstr='#5d4dd1', GradientType=0);filter: none;border: 1px solid #5d4dd1;}\n.navbar-nav li:nth-child(1) a{\n    background: {$theme->primary_color};\n}\n\n.navbar-nav li:nth-child(2) a{\n    background: {$theme->secondary_color};\n}\n\n.navbar-nav li:nth-child(3) a{\n    background: {$theme->primary_color};\n}\n\n.navbar-nav li:nth-child(4) a{\n    background: {$theme->secondary_color};\n}\n\n.navbar-nav li:nth-child(5) a{\n    background: {$theme->primary_color};\n}\n\n.navbar-nav li:nth-child(6) a{\n    background: {$theme->secondary_color};\n}\n\n.navbar-nav li:nth-child(7) a{\n    background: {$theme->primary_color};\n}\n\n.navbar-nav li:nth-child(8) a{\n    background: {$theme->secondary_color};\n}\n\n.navbar-nav li:nth-child(9) a{\n    background: {$theme->primary_color};\n}\n\n.navbar-nav li:nth-child(10) a{\n    background: {$theme->secondary_color};\n}\n\n.navbar-nav li a:hover{\n    background: {$theme->hover_color};\n}\n.btn-green{\n\n    background: {$theme->theme_color};\n    color: #fff;\n}\n.btn-green:hover{\n    background: {$theme->hover_color};\n    color: #fff;\n}\n";
     $t = file_put_contents(public_path() . '/stylesheet/theme_cus.css', $css_msg);
     /* chmod(public_path() . '/stylesheet/theme_cus.css', 0777); */
     if (Input::hasFile('logo')) {
         // Upload File
         $file_name = time();
         $file_name .= rand();
         $ext = Input::file('logo')->getClientOriginalExtension();
         Input::file('logo')->move(public_path() . "/uploads", $file_name . "." . $ext);
         $local_url = $file_name . "." . $ext;
         /* $new = Image::make(public_path() . "/uploads/" . $local_url)->resize(70, 70)->save(); */
         // Upload to S3
         if (Config::get('app.s3_bucket') != "") {
             $s3 = App::make('aws')->get('s3');
             $pic = $s3->putObject(array('Bucket' => Config::get('app.s3_bucket'), 'Key' => $file_name, 'SourceFile' => public_path() . "/uploads/" . $local_url));
             $s3->putObjectAcl(array('Bucket' => Config::get('app.s3_bucket'), 'Key' => $file_name, 'ACL' => 'public-read'));
             $s3_url = $s3->getObjectUrl(Config::get('app.s3_bucket'), $file_name);
         } else {
             $s3_url = asset_url() . '/uploads/' . $local_url;
         }
         if (isset($theme->logo)) {
             $icon = asset_url() . '/uploads/' . $theme->logo;
             unlink_image($icon);
         }
         $theme->logo = $local_url;
     }
     if (Input::hasFile('icon')) {
         // Upload File
         $file_name1 = time();
         $file_name1 .= rand();
         $file_name1 .= 'icon';
         $ext1 = Input::file('icon')->getClientOriginalExtension();
         Input::file('icon')->move(public_path() . "/uploads", $file_name1 . "." . $ext1);
         $local_url1 = $file_name1 . "." . $ext1;
         // Upload to S3
         if (Config::get('app.s3_bucket') != "") {
             $s3 = App::make('aws')->get('s3');
             $pic = $s3->putObject(array('Bucket' => Config::get('app.s3_bucket'), 'Key' => $file_name1, 'SourceFile' => public_path() . "/uploads/" . $local_url1));
             $s3->putObjectAcl(array('Bucket' => Config::get('app.s3_bucket'), 'Key' => $file_name1, 'ACL' => 'public-read'));
             $s3_url1 = $s3->getObjectUrl(Config::get('app.s3_bucket'), $file_name1);
         } else {
             $s3_url1 = asset_url() . '/uploads/' . $local_url1;
         }
         if (isset($theme->favicon)) {
             $icon = asset_url() . '/uploads/' . $theme->favicon;
             unlink_image($icon);
         }
         $theme->favicon = $local_url1;
     }
     $theme->save();
     return Redirect::to("/admin/settings");
 }
Ejemplo n.º 4
0
     ############################################################################################
     ##                                    Выбор аватара                                       ##
     ############################################################################################
 ############################################################################################
 ##                                    Выбор аватара                                       ##
 ############################################################################################
 case 'select':
     $uid = check($_GET['uid']);
     $id = abs(intval($_GET['id']));
     if ($uid == $_SESSION['token']) {
         $queryav = DB::run()->querySingle("SELECT `avatars_name` FROM `avatars` WHERE `avatars_id`=?  LIMIT 1;", array($id));
         if (!empty($queryav)) {
             if ($udata['users_avatar'] != 'images/avatars/' . $queryav) {
                 DB::run()->query("UPDATE `users` SET `users_avatar`=? WHERE `users_login`=?;", array('images/avatars/' . $queryav, $log));
                 save_avatar();
                 unlink_image('upload/avatars/', $log . '.gif');
                 echo '<img src="/images/img/open.gif" alt="image" /> <b>Аватар успешно выбран!</b><br /><br />';
             } else {
                 show_error('Ошибка! Вы уже выбрали это аватар!');
             }
         } else {
             show_error('Ошибка! Такого аватара не существует!');
         }
     } else {
         show_error('Ошибка! Неверный идентификатор сессии, повторите действие!');
     }
     echo '<img src="/images/img/back.gif" alt="image" /> <a href="avatars.php">Вернуться</a><br />';
     break;
     ############################################################################################
     ##                              Подготовка к загрузке аватара                             ##
     ############################################################################################
 public function update_profile()
 {
     $token = Input::get('token');
     $owner_id = Input::get('id');
     $first_name = $last_name = $phone = $password = $picture = $bio = $address = $state = $country = $zipcode = 0;
     if (Input::has('first_name')) {
         $first_name = Input::get('first_name');
     }
     if (Input::has('last_name')) {
         $last_name = Input::get('last_name');
     }
     if (Input::has('phone')) {
         $phone = Input::get('phone');
     }
     if (Input::has('password')) {
         $password = Input::get('password');
     }
     if (Input::hasFile('picture')) {
         $picture = Input::file('picture');
     }
     if (Input::has('bio')) {
         $bio = Input::get('bio');
     }
     if (Input::has('address')) {
         $address = Input::get('address');
     }
     if (Input::has('state')) {
         $state = Input::get('state');
     }
     if (Input::has('country')) {
         $country = Input::get('country');
     }
     if (Input::has('zipcode')) {
         $zipcode = Input::get('zipcode');
     }
     $new_password = Input::get('new_password');
     $old_password = Input::get('old_password');
     $validator = Validator::make(array('token' => $token, 'owner_id' => $owner_id, 'picture' => $picture, 'zipcode' => $zipcode), array('token' => 'required', 'owner_id' => 'required|integer', 'picture' => '', 'zipcode' => 'integer'));
     if ($validator->fails()) {
         $error_messages = $validator->messages()->all();
         $response_array = array('success' => false, 'error' => 'Invalid Input', 'error_code' => 401, 'error_messages' => $error_messages);
         $response_code = 200;
     } else {
         $is_admin = $this->isAdmin($token);
         if ($owner_data = $this->getOwnerData($owner_id, $token, $is_admin)) {
             // check for token validity
             if (is_token_active($owner_data->token_expiry) || $is_admin) {
                 if (Input::get('new_password')) {
                     if (Input::get('old_password') != "") {
                         if (Hash::check($old_password, $owner_data->password)) {
                             // Do necessary operations
                             $owner = Owner::find($owner_id);
                             if ($first_name) {
                                 $owner->first_name = $first_name;
                             }
                             if ($last_name) {
                                 $owner->last_name = $last_name;
                             }
                             if ($phone) {
                                 $owner->phone = $phone;
                             }
                             if ($bio) {
                                 $owner->bio = $bio;
                             }
                             if ($address) {
                                 $owner->address = $address;
                             }
                             if ($state) {
                                 $owner->state = $state;
                             }
                             if ($country) {
                                 $owner->country = $country;
                             }
                             if ($zipcode) {
                                 $owner->zipcode = $zipcode;
                             }
                             if ($new_password) {
                                 $owner->password = Hash::make($new_password);
                             }
                             if (Input::hasFile('picture')) {
                                 if ($owner->picture != "") {
                                     $path = $owner->picture;
                                     Log::info($path);
                                     $filename = basename($path);
                                     Log::info($filename);
                                     if (file_exists($path)) {
                                         unlink(public_path() . "/uploads/" . $filename);
                                     }
                                 }
                                 // upload image
                                 $file_name = time();
                                 $file_name .= rand();
                                 $file_name = sha1($file_name);
                                 $ext = Input::file('picture')->getClientOriginalExtension();
                                 Input::file('picture')->move(public_path() . "/uploads", $file_name . "." . $ext);
                                 $local_url = $file_name . "." . $ext;
                                 // Upload to S3
                                 if (Config::get('app.s3_bucket') != "") {
                                     $s3 = App::make('aws')->get('s3');
                                     $pic = $s3->putObject(array('Bucket' => Config::get('app.s3_bucket'), 'Key' => $file_name, 'SourceFile' => public_path() . "/uploads/" . $local_url));
                                     $s3->putObjectAcl(array('Bucket' => Config::get('app.s3_bucket'), 'Key' => $file_name, 'ACL' => 'public-read'));
                                     $s3_url = $s3->getObjectUrl(Config::get('app.s3_bucket'), $file_name);
                                 } else {
                                     $s3_url = asset_url() . '/uploads/' . $local_url;
                                 }
                                 if (isset($owner->picture)) {
                                     if ($owner->picture != "") {
                                         $icon = $owner->picture;
                                         unlink_image($icon);
                                     }
                                 }
                                 $owner->picture = $s3_url;
                             }
                             if (Input::has('timezone')) {
                                 $owner->timezone = Input::get('timezone');
                             }
                             $owner->save();
                             $code_data = Ledger::where('owner_id', '=', $owner->id)->first();
                             /* SEND REFERRAL & PROMO INFO */
                             $settings = Settings::where('key', 'referral_code_activation')->first();
                             $referral_code_activation = $settings->value;
                             if ($referral_code_activation) {
                                 $referral_code_activation_txt = "referral on";
                             } else {
                                 $referral_code_activation_txt = "referral off";
                             }
                             $settings = Settings::where('key', 'promotional_code_activation')->first();
                             $promotional_code_activation = $settings->value;
                             if ($promotional_code_activation) {
                                 $promotional_code_activation_txt = "promo on";
                             } else {
                                 $promotional_code_activation_txt = "promo off";
                             }
                             /* SEND REFERRAL & PROMO INFO */
                             $response_array = array('success' => true, 'id' => $owner->id, 'first_name' => $owner->first_name, 'last_name' => $owner->last_name, 'phone' => $owner->phone, 'email' => $owner->email, 'picture' => $owner->picture, 'bio' => $owner->bio, 'address' => $owner->address, 'state' => $owner->state, 'country' => $owner->country, 'zipcode' => $owner->zipcode, 'login_by' => $owner->login_by, 'social_unique_id' => $owner->social_unique_id, 'device_token' => $owner->device_token, 'device_type' => $owner->device_type, 'timezone' => $owner->timezone, 'token' => $owner->token, 'referral_code' => $code_data->referral_code, 'is_referee' => $owner->is_referee, 'promo_count' => $owner->promo_count, 'is_referral_active' => $referral_code_activation, 'is_referral_active_txt' => $referral_code_activation_txt, 'is_promo_active' => $promotional_code_activation, 'is_promo_active_txt' => $promotional_code_activation_txt);
                             $response_code = 200;
                         } else {
                             $response_array = array('success' => false, 'error' => 'Invalid Old Password', 'error_code' => 501);
                             $response_code = 200;
                         }
                     } else {
                         $response_array = array('success' => false, 'error' => 'Old Password must not be blank', 'error_code' => 502);
                         $response_code = 200;
                     }
                 } else {
                     // Do necessary operations
                     $owner = Owner::find($owner_id);
                     if ($first_name) {
                         $owner->first_name = $first_name;
                     }
                     if ($last_name) {
                         $owner->last_name = $last_name;
                     }
                     if ($phone) {
                         $owner->phone = $phone;
                     }
                     if ($bio) {
                         $owner->bio = $bio;
                     }
                     if ($address) {
                         $owner->address = $address;
                     }
                     if ($state) {
                         $owner->state = $state;
                     }
                     if ($country) {
                         $owner->country = $country;
                     }
                     if ($zipcode) {
                         $owner->zipcode = $zipcode;
                     }
                     if (Input::hasFile('picture')) {
                         if ($owner->picture != "") {
                             $path = $owner->picture;
                             Log::info($path);
                             $filename = basename($path);
                             Log::info($filename);
                             if (file_exists($path)) {
                                 unlink(public_path() . "/uploads/" . $filename);
                             }
                         }
                         // upload image
                         $file_name = time();
                         $file_name .= rand();
                         $file_name = sha1($file_name);
                         $ext = Input::file('picture')->getClientOriginalExtension();
                         Input::file('picture')->move(public_path() . "/uploads", $file_name . "." . $ext);
                         $local_url = $file_name . "." . $ext;
                         // Upload to S3
                         if (Config::get('app.s3_bucket') != "") {
                             $s3 = App::make('aws')->get('s3');
                             $pic = $s3->putObject(array('Bucket' => Config::get('app.s3_bucket'), 'Key' => $file_name, 'SourceFile' => public_path() . "/uploads/" . $local_url));
                             $s3->putObjectAcl(array('Bucket' => Config::get('app.s3_bucket'), 'Key' => $file_name, 'ACL' => 'public-read'));
                             $s3_url = $s3->getObjectUrl(Config::get('app.s3_bucket'), $file_name);
                         } else {
                             $s3_url = asset_url() . '/uploads/' . $local_url;
                         }
                         if (isset($owner->picture)) {
                             if ($owner->picture != "") {
                                 $icon = $owner->picture;
                                 unlink_image($icon);
                             }
                         }
                         $owner->picture = $s3_url;
                     }
                     if (Input::has('timezone')) {
                         $owner->timezone = Input::get('timezone');
                     }
                     $owner->save();
                     $code_data = Ledger::where('owner_id', '=', $owner->id)->first();
                     /* SEND REFERRAL & PROMO INFO */
                     $settings = Settings::where('key', 'referral_code_activation')->first();
                     $referral_code_activation = $settings->value;
                     if ($referral_code_activation) {
                         $referral_code_activation_txt = "referral on";
                     } else {
                         $referral_code_activation_txt = "referral off";
                     }
                     $settings = Settings::where('key', 'promotional_code_activation')->first();
                     $promotional_code_activation = $settings->value;
                     if ($promotional_code_activation) {
                         $promotional_code_activation_txt = "promo on";
                     } else {
                         $promotional_code_activation_txt = "promo off";
                     }
                     /* SEND REFERRAL & PROMO INFO */
                     $response_array = array('success' => true, 'id' => $owner->id, 'first_name' => $owner->first_name, 'last_name' => $owner->last_name, 'phone' => $owner->phone, 'email' => $owner->email, 'picture' => $owner->picture, 'bio' => $owner->bio, 'address' => $owner->address, 'state' => $owner->state, 'country' => $owner->country, 'zipcode' => $owner->zipcode, 'login_by' => $owner->login_by, 'social_unique_id' => $owner->social_unique_id, 'device_token' => $owner->device_token, 'device_type' => $owner->device_type, 'timezone' => $owner->timezone, 'token' => $owner->token, 'referral_code' => $code_data->referral_code, 'is_referee' => $owner->is_referee, 'promo_count' => $owner->promo_count, 'is_referral_active' => $referral_code_activation, 'is_referral_active_txt' => $referral_code_activation_txt, 'is_promo_active' => $promotional_code_activation, 'is_promo_active_txt' => $promotional_code_activation_txt);
                     $response_code = 200;
                 }
             } else {
                 $response_array = array('success' => false, 'error' => 'Token Expired', 'error_code' => 405);
                 $response_code = 200;
             }
         } else {
             if ($is_admin) {
                 /* $var = Keywords::where('id', 2)->first();
                    $response_array = array('success' => false, 'error' => '' . $var->keyword . ' ID not Found', 'error_code' => 410); */
                 $response_array = array('success' => false, 'error' => '' . Config::get('app.generic_keywords.User') . ' ID not Found', 'error_code' => 410);
             } else {
                 $response_array = array('success' => false, 'error' => 'Not a valid token', 'error_code' => 406);
             }
             $response_code = 200;
         }
     }
     $response = Response::json($response_array, $response_code);
     return $response;
 }
Ejemplo n.º 6
0
     }
     echo '<img src="/images/img/back.gif" alt="image" /> <a href="add.php?act=view&amp;id=' . $id . '">Вернуться</a><br />';
     break;
     /**
      * Удаление скриншота
      */
 /**
  * Удаление скриншота
  */
 case 'delscreen':
     $screen = DB::run()->queryFetch("SELECT `downs`.*, `cats`.`folder` FROM `downs` LEFT JOIN `cats` ON `downs`.`downs_cats_id`=`cats`.`cats_id` WHERE `downs_id`=? LIMIT 1;", array($id));
     if (!empty($screen)) {
         if ($screen['downs_user'] == $log) {
             if (empty($screen['downs_active'])) {
                 $folder = $screen['folder'] ? $screen['folder'] . '/' : '';
                 unlink_image('load/screen/' . $folder, $screen['downs_screen']);
                 DB::run()->query("UPDATE `downs` SET `downs_screen`=? WHERE `downs_id`=?;", array('', $id));
                 notice('Скриншот успешно удален!');
                 redirect("add.php?act=view&id={$id}");
             } else {
                 show_error('Ошибка! Данный файл уже проверен модератором!');
             }
         } else {
             show_error('Ошибка! Удаление невозможно, вы не автор данного файла!');
         }
     } else {
         show_error('Ошибка! Данного файла не существует!');
     }
     echo '<img src="/images/img/back.gif" alt="image" /> <a href="add.php?act=view&amp;id=' . $id . '">Вернуться</a><br />';
     break;
     /**
Ejemplo n.º 7
0
 public function update_thing()
 {
     if (Request::isMethod('post')) {
         $name = ucwords(trim(Input::get('name')));
         $age = Input::get('age');
         $breed = Input::get('type');
         $likes = Input::get('notes');
         $token = Input::get('token');
         $owner_id = Input::get('id');
         $picture = Input::file('picture');
         $validator = Validator::make(array('token' => $token, 'owner_id' => $owner_id, 'age' => $age, 'picture' => $picture), array('token' => 'required', 'owner_id' => 'required|integer', 'age' => 'integer', 'picture' => ''));
         if ($validator->fails()) {
             $error_messages = $validator->messages()->all();
             $response_array = array('success' => false, 'error' => 'Invalid Input', 'error_code' => 401, 'error_messages' => $error_messages);
             $response_code = 200;
         } else {
             $is_admin = $this->isAdmin($token);
             if ($owner_data = $this->getOwnerData($owner_id, $token, $is_admin)) {
                 // check for token validity
                 if (is_token_active($owner_data->token_expiry) || $is_admin) {
                     $dog_data = Dog::where('owner_id', $owner_id)->first();
                     if ($dog_data) {
                         $dog = Dog::find($dog_data->id);
                         if ($name) {
                             $dog->name = $name;
                         }
                         if ($age) {
                             $dog->age = $age;
                         }
                         if ($breed) {
                             $dog->breed = $breed;
                         }
                         if ($likes) {
                             $dog->likes = $likes;
                         }
                         if (Input::hasFile('picture')) {
                             // upload image
                             $file_name = time();
                             $file_name .= rand();
                             $file_name = sha1($file_name);
                             $ext = Input::file('picture')->getClientOriginalExtension();
                             Input::file('picture')->move(public_path() . "/uploads", $file_name . "." . $ext);
                             $local_url = $file_name . "." . $ext;
                             // Upload to S3
                             if (Config::get('app.s3_bucket') != "") {
                                 $s3 = App::make('aws')->get('s3');
                                 $pic = $s3->putObject(array('Bucket' => Config::get('app.s3_bucket'), 'Key' => $file_name, 'SourceFile' => public_path() . "/uploads/" . $local_url));
                                 $s3->putObjectAcl(array('Bucket' => Config::get('app.s3_bucket'), 'Key' => $file_name, 'ACL' => 'public-read'));
                                 $s3_url = $s3->getObjectUrl(Config::get('app.s3_bucket'), $file_name);
                             } else {
                                 $s3_url = asset_url() . '/uploads/' . $local_url;
                             }
                             if (isset($dog->image_url)) {
                                 if ($dog->image_url != "") {
                                     $icon = $dog->image_url;
                                     unlink_image($icon);
                                 }
                             }
                             $dog->image_url = $s3_url;
                         }
                         $dog->save();
                         $response_array = array('success' => true);
                         $response_code = 200;
                     } else {
                         $response_array = array('success' => false, 'error' => 'No Dog Found', 'error_code' => 405);
                         $response_code = 200;
                     }
                 } else {
                     $response_array = array('success' => false, 'error' => 'Token Expired', 'error_code' => 405);
                     $response_code = 200;
                 }
             } else {
                 if ($is_admin) {
                     $response_array = array('success' => false, 'error' => 'Owner ID not Found', 'error_code' => 410);
                 } else {
                     $response_array = array('success' => false, 'error' => 'Not a valid token', 'error_code' => 406);
                 }
                 $response_code = 200;
             }
         }
     }
     $response = Response::json($response_array, $response_code);
     return $response;
 }
Ejemplo n.º 8
0
     ##                                   Удаление фотографий                                  ##
     ############################################################################################
 ############################################################################################
 ##                                   Удаление фотографий                                  ##
 ############################################################################################
 case 'delphoto':
     $uid = check($_GET['uid']);
     if (is_user()) {
         if ($uid == $_SESSION['token']) {
             if (is_writeable(BASEDIR . '/upload/pictures')) {
                 $querydel = DB::run()->queryfetch("SELECT `photo_id`, `photo_link`, `photo_comments` FROM `photo` WHERE `photo_id`=? AND `photo_user`=? LIMIT 1;", array($gid, $log));
                 if (!empty($querydel)) {
                     if (empty($querydel['photo_comments'])) {
                         DB::run()->query("DELETE FROM `photo` WHERE `photo_id`=? LIMIT 1;", array($querydel['photo_id']));
                         DB::run()->query("DELETE FROM `commphoto` WHERE `commphoto_gid`=?;", array($querydel['photo_id']));
                         unlink_image('upload/pictures/', $querydel['photo_link']);
                         $_SESSION['note'] = 'Фотография успешно удалена!';
                         redirect("album.php?act=photo&start={$start}");
                     } else {
                         show_error('Ошибка! Запрещено удалять фотографии к которым имеются комментарии!');
                     }
                 } else {
                     show_error('Ошибка! Данная фотография не существует или вы не автор этой фотографии!');
                 }
             } else {
                 show_error('Ошибка! Не установлены атрибуты доступа на дирекоторию с фотографиями!');
             }
         } else {
             show_error('Ошибка! Неверный идентификатор сессии, повторите действие!');
         }
     } else {
Ejemplo n.º 9
0
     ############################################################################################
 ############################################################################################
 ##                                    Удаление новостей                                   ##
 ############################################################################################
 case 'del':
     $uid = check($_GET['uid']);
     $del = isset($_REQUEST['del']) ? intar($_REQUEST['del']) : 0;
     if ($uid == $_SESSION['token']) {
         if (!empty($del)) {
             if (is_writeable(BASEDIR . '/upload/news')) {
                 $del = implode(',', $del);
                 $querydel = DB::run()->query("SELECT `news_image` FROM `news` WHERE `news_id` IN (" . $del . ");");
                 $arr_image = $querydel->fetchAll();
                 if (count($arr_image) > 0) {
                     foreach ($arr_image as $delete) {
                         unlink_image('upload/news/', $delete['news_image']);
                     }
                 }
                 DB::run()->query("DELETE FROM `news` WHERE `news_id` IN (" . $del . ");");
                 DB::run()->query("DELETE FROM `commnews` WHERE `commnews_news_id` IN (" . $del . ");");
                 notice('Выбранные новости успешно удалены!');
                 redirect("news.php?start={$start}");
             } else {
                 show_error('Ошибка! Не установлены атрибуты доступа на дирекоторию с изображениями!');
             }
         } else {
             show_error('Ошибка! Отсутствуют выбранные новости!');
         }
     } else {
         show_error('Ошибка! Неверный идентификатор сессии, повторите действие!');
     }
Ejemplo n.º 10
0
 } elseif (isset($_GET['del'])) {
     $del = array(abs(intval($_GET['del'])));
 } else {
     $del = 0;
 }
 if ($uid == $_SESSION['token']) {
     if (!empty($del)) {
         $del = implode(',', $del);
         if (is_writeable(BASEDIR . '/upload/pictures')) {
             $querydel = DB::run()->query("SELECT `photo_id`, `photo_link` FROM `photo` WHERE `photo_id` IN (" . $del . ");");
             $arr_photo = $querydel->fetchAll();
             if (count($arr_photo) > 0) {
                 foreach ($arr_photo as $delete) {
                     DB::run()->query("DELETE FROM `photo` WHERE `photo_id`=? LIMIT 1;", array($delete['photo_id']));
                     DB::run()->query("DELETE FROM `commphoto` WHERE `commphoto_gid`=?;", array($delete['photo_id']));
                     unlink_image('upload/pictures/', $delete['photo_link']);
                 }
                 $_SESSION['note'] = 'Выбранные фотографии успешно удалены!';
                 redirect("gallery.php?start={$start}");
             } else {
                 show_error('Ошибка! Данных фотографий не существует!');
             }
         } else {
             show_error('Ошибка! Не установлены атрибуты доступа на дирекоторию с фотографиями!');
         }
     } else {
         show_error('Ошибка! Отсутствуют выбранные фотографии!');
     }
 } else {
     show_error('Ошибка! Неверный идентификатор сессии, повторите действие!');
 }
Ejemplo n.º 11
0
 public function updateUserProfile()
 {
     $owner_id = Session::get('user_id');
     $first_name = Input::get('first_name');
     $last_name = Input::get('last_name');
     $phone = Input::get('phone');
     $picture = Input::file('picture');
     $bio = Input::get('bio');
     $address = Input::get('address');
     $state = Input::get('state');
     $country = Input::get('country');
     $zipcode = Input::get('zipcode');
     $timezone = Input::get('timezone');
     $validator = Validator::make(array('user_id' => $owner_id), array('user_id' => 'required'));
     if ($validator->fails()) {
         $error_messages = $validator->messages();
         Log::info('picture type not valid. Error = ' . print_r($error_messages, true));
         return Redirect::to('/user/profile')->with('error', 'Invalid image format (Allowed formats jpeg,bmp and png)');
     } else {
         $owner = Owner::find($owner_id);
         if (Input::hasFile('picture')) {
             if ($owner->picture != "") {
                 $path = $owner->picture;
                 Log::info($path);
                 $filename = basename($path);
                 Log::info($filename);
                 unlink(public_path() . "/uploads/" . $filename);
             }
             // upload image
             $file_name = time();
             $file_name .= rand();
             $file_name = sha1($file_name);
             $ext = Input::file('picture')->getClientOriginalExtension();
             Input::file('picture')->move(public_path() . "/uploads", $file_name . "." . $ext);
             $local_url = $file_name . "." . $ext;
             // Upload to S3
             if (Config::get('app.s3_bucket') != "") {
                 $s3 = App::make('aws')->get('s3');
                 $pic = $s3->putObject(array('Bucket' => Config::get('app.s3_bucket'), 'Key' => $file_name, 'SourceFile' => public_path() . "/uploads/" . $local_url));
                 $s3->putObjectAcl(array('Bucket' => Config::get('app.s3_bucket'), 'Key' => $file_name, 'ACL' => 'public-read'));
                 $s3_url = $s3->getObjectUrl(Config::get('app.s3_bucket'), $file_name);
             } else {
                 $s3_url = asset_url() . '/uploads/' . $local_url;
             }
             if (isset($owner->picture)) {
                 if ($owner->picture != "") {
                     $icon = $owner->picture;
                     unlink_image($icon);
                 }
             }
             $owner->picture = $s3_url;
         }
         $owner->first_name = $first_name;
         $owner->last_name = $last_name;
         $owner->phone = $phone;
         $owner->bio = $bio;
         $owner->address = $address;
         $owner->state = $state;
         $owner->country = $country;
         $owner->zipcode = $zipcode;
         $owner->timezone = $timezone;
         $owner->save();
         return Redirect::to('/user/profile')->with('message', 'Your profile has been updated successfully')->with('type', 'success');
     }
 }
Ejemplo n.º 12
0
     $del = 0;
 }
 if ($uid == $_SESSION['token']) {
     if (utf_strlen($msg) >= 5 && utf_strlen($msg) <= $config['forumtextlength']) {
         $post = DB::run()->queryFetch("SELECT * FROM `posts` WHERE `posts_id`=? LIMIT 1;", array($pid));
         if (!empty($post)) {
             DB::run()->query("UPDATE `posts` SET `posts_text`=?, `posts_edit`=?, `posts_edit_time`=? WHERE `posts_id`=?;", array($msg, $log, SITETIME, $pid));
             // ------ Удаление загруженных файлов -------//
             if (!empty($del)) {
                 $del = implode(',', $del);
                 $queryfiles = DB::run()->query("SELECT * FROM `files_forum` WHERE `file_posts_id`=? AND `file_id` IN (" . $del . ");", array($pid));
                 $files = $queryfiles->fetchAll();
                 if (!empty($files)) {
                     foreach ($files as $file) {
                         if (file_exists(BASEDIR . '/upload/forum/' . $file['file_topics_id'] . '/' . $file['file_hash'])) {
                             unlink_image('upload/forum/', $file['file_topics_id'] . '/' . $file['file_hash']);
                         }
                     }
                     DB::run()->query("DELETE FROM `files_forum` WHERE `file_posts_id`=? AND `file_id` IN (" . $del . ");", array($pid));
                 }
             }
             // ------ Удаление загруженных файлов -------//
             notice('Сообщение успешно отредактировано!');
             redirect("forum.php?act=topic&tid={$tid}&start={$start}");
         } else {
             show_error('Ошибка! Данного сообщения не существует!');
         }
     } else {
         show_error('Ошибка! Слишком длинное или короткое сообщение!');
     }
 } else {
Ejemplo n.º 13
0
                show_error('Ошибка! Неверный идентификатор сессии, повторите действие!');
            }
            echo '<img src="/images/img/back.gif" alt="image" /> <a href="pictures.php">Вернуться</a><br />';
            break;
            ############################################################################################
            ##                                  Удаление фотографии                                   ##
            ############################################################################################
        ############################################################################################
        ##                                  Удаление фотографии                                   ##
        ############################################################################################
        case 'del':
            $uid = check($_GET['uid']);
            if ($uid == $_SESSION['token']) {
                $userpic = DB::run()->querySingle("SELECT `users_picture` FROM `users` WHERE `users_login`=? LIMIT 1;", array($log));
                if (!empty($userpic)) {
                    unlink_image('upload/photos/', $userpic);
                    DB::run()->query("UPDATE `users` SET `users_picture`=? WHERE `users_login`=?", array('', $log));
                    $_SESSION['note'] = 'Фотография успешно удалена!';
                    redirect("profile.php");
                } else {
                    show_error('Ошибка! Фотографии для удаления не существует!');
                }
            } else {
                show_error('Ошибка! Неверный идентификатор сессии, повторите действие!');
            }
            echo '<img src="/images/img/back.gif" alt="image" /> <a href="profile.php">Вернуться</a><br />';
            break;
        default:
            redirect("pictures.php");
    }
} else {
Ejemplo n.º 14
0
     ############################################################################################
 ############################################################################################
 ##                                    Удаление событий                                    ##
 ############################################################################################
 case 'del':
     $uid = check($_GET['uid']);
     $del = isset($_REQUEST['del']) ? intar($_REQUEST['del']) : 0;
     if ($uid == $_SESSION['token']) {
         if (!empty($del)) {
             if (is_writeable(BASEDIR . '/upload/events')) {
                 $del = implode(',', $del);
                 $querydel = DB::run()->query("SELECT `event_image` FROM `events` WHERE `event_id` IN (" . $del . ");");
                 $arr_image = $querydel->fetchAll();
                 if (count($arr_image) > 0) {
                     foreach ($arr_image as $delete) {
                         unlink_image('upload/events/', $delete['event_image']);
                     }
                 }
                 DB::run()->query("DELETE FROM `events` WHERE `event_id` IN (" . $del . ");");
                 DB::run()->query("DELETE FROM `commevents` WHERE `commevent_event_id` IN (" . $del . ");");
                 notice('Выбранные события успешно удалены!');
                 redirect("events.php?start={$start}");
             } else {
                 show_error('Ошибка! Не установлены атрибуты доступа на директорию с изображениями!');
             }
         } else {
             show_error('Ошибка! Отсутствуют выбранные события!');
         }
     } else {
         show_error('Ошибка! Неверный идентификатор сессии, повторите действие!');
     }
Ejemplo n.º 15
0
 $top = !is_admin() || empty($_POST['top']) ? 0 : 1;
 $closed = !is_admin() || empty($_POST['closed']) ? 0 : 1;
 if (is_user()) {
     $dataevent = DB::run()->queryFetch("SELECT * FROM `events` WHERE `event_id`=? LIMIT 1;", array($id));
     $validation = new Validation();
     $validation->addRule('equal', array($uid, $_SESSION['token']), 'Неверный идентификатор сессии, повторите действие!')->addRule('not_empty', $dataevent, 'Выбранного события не существует, возможно оно было удалено!')->addRule('equal', array($log, $dataevent['event_author']), 'Изменение невозможно, вы не автор данного события!')->addRule('max', array($dataevent['event_time'] + 3600, SITETIME), 'Изменение невозможно, прошло более 1 часа!')->addRule('string', $title, 'Слишком длинный или короткий заголовок события!', true, 5, 50)->addRule('string', $msg, 'Слишком длинный или короткий текст события!', true, 5, 10000);
     if ($validation->run()) {
         $msg = antimat($msg);
         DB::run()->query("UPDATE `events` SET `event_title`=?, `event_text`=?, `event_closed`=?, `event_top`=? WHERE `event_id`=? LIMIT 1;", array($title, $msg, $closed, $top, $id));
         // ---------------------------- Загрузка изображения -------------------------------//
         if (is_uploaded_file($_FILES['image']['tmp_name'])) {
             $handle = upload_image($_FILES['image'], $config['filesize'], $config['fileupfoto'], $id);
             if ($handle) {
                 // Удаление старой картинки
                 if (!empty($dataevent['event_image'])) {
                     unlink_image('upload/events/', $dataevent['event_image']);
                 }
                 $handle->process(BASEDIR . '/upload/events/');
                 if ($handle->processed) {
                     DB::run()->query("UPDATE `events` SET `event_image`=? WHERE `event_id`=? LIMIT 1;", array($handle->file_dst_name, $id));
                     $handle->clean();
                 } else {
                     notice($handle->error, 'danger');
                 }
             }
         }
         // ---------------------------------------------------------------------------------//
         notice('Событие успешно отредактировано!');
         redirect("index.php?act=editevent&id={$id}");
     } else {
         show_error($validation->getErrors());