Ejemplo n.º 1
0
 /**
  * Редактирование объявления
  */
 function edit()
 {
     $page =& Registry::get('TPage');
     $id = 0;
     $real_path = $_SERVER['REQUEST_URI'];
     if (substr($real_path, -1) != '/') {
         $real_path .= '/';
     }
     $query = explode('?', $real_path);
     $pids = explode('/', $query[0]);
     $pos = array_search('edit', $pids);
     if ($pos !== false) {
         $id = (int) $pids[$pos + 1];
     }
     if (!$id) {
         $page->tpl->assign(array('errors' => array('Объявление не указано!')));
         $ret['errors_box'] = $page->tpl->fetch('errors_box.html');
         $page->tpl->clear_assign('errors_box');
         return $ret;
     }
     $auth =& Registry::get('TUserAuth');
     $userid = (int) $auth->getCurrentUserId();
     if (!$userid) {
         $page->tpl->assign(array('errors' => array('Вы не авторизованы!')));
         $ret['errors_box'] = $page->tpl->fetch('errors_box.html');
         $page->tpl->clear_assign('errors_box');
         return $ret;
     }
     $row = sql_getRow("SELECT * FROM `objects` WHERE id='{$id}' AND client_id='{$userid}'");
     if (!$row) {
         $page->tpl->assign(array('errors' => array('Нет такого объявления или объявление принадлежит не Вам!')));
         $ret['errors_box'] = $page->tpl->fetch('errors_box.html');
         $page->tpl->clear_assign('errors_box');
         return $ret;
     }
     if (isset($_POST['fld'])) {
         $post = $_POST['fld'];
         if ($post['city'] == 1) {
             unset($this->req_fields['district_id']);
         } else {
             unset($this->req_fields['metro_id']);
             unset($this->req_fields['metro_time']);
             unset($this->req_fields['metro_time_type']);
         }
         foreach ($this->req_fields as $key => $val) {
             if (empty($post[$key])) {
                 $errors[] = $this->req_fields[$key];
             }
         }
         foreach ($post['delphoto'] as $delphoto => $smth) {
             $this->deletePhoto($delphoto);
         }
         foreach ($post['delplan'] as $delplan => $smth) {
             $this->deletePlan($delplan);
         }
         if (isset($_FILES)) {
             $photo = $plan = array();
             foreach ($_FILES['fld'] as $key => $value) {
                 if (isset($value['photo'])) {
                     $photo[$key] = $value['photo'];
                 }
                 if (isset($value['plan'])) {
                     $plan[$key] = $value['plan'];
                 }
             }
             include_once 'functions.php';
             $dir = 'files/objects/' . $id;
             if (!is_dir($dir)) {
                 mkdir($dir);
                 chmod($dir, 0775);
             }
             if ($photo) {
                 $sizes = array('im_small' => array('50', '36'), 'image_small' => array('250', '250'), 'image_large' => array('640', '480'));
                 $images_photo = downloadFiles($_FILES, count($photo['name']), 'photo', "files/objects/{$id}", $sizes, 85, true);
                 if (!empty($images_photo)) {
                     $ret['files_photo'] = $images_photo;
                 }
             }
             if ($plan) {
                 $sizes = array('image_small' => array('50', '36'), 'image_large' => array('640', '480'));
                 $images_plan = downloadFiles($_FILES, count($plan['name']), 'plan', "files/objects/{$id}", $sizes, 85, true);
                 if (!empty($images_plan)) {
                     $ret['files_plan'] = $images_plan;
                 }
             }
         }
         $ret['metro_dest'] = intval($post['select_metro_time']);
         $ret['metro_dest_text'] = intval($post['select_metro_time_type']);
         foreach ($post as $key => $val) {
             $ret[$key] = $post[$key];
         }
         if ($errors) {
             array_unshift($errors, '<b>Не заполнены следующие поля</b>');
             $page->tpl->assign(array('errors' => $errors));
             $ret['errors_box'] = $page->tpl->fetch('errors_box.html');
             $page->tpl->clear_assign('errors_box');
         } else {
             $this->updateObject($id, $ret);
             $row = sql_getRow("SELECT * FROM `objects` WHERE `id`='{$id}' AND `client_id`='{$userid}'");
         }
     }
     $ret = array();
     $ret['id'] = $id;
     $ret['metrostations'] = array('' => '- не выбрано -') + sql_getRows('SELECT id, name FROM `obj_locat_metrostations` WHERE 1 ORDER BY name', true);
     $ret['districs_mo'] = array('' => '- не выбрано -') + $this->getDistricsAndCities();
     $ret['house_type'] = array('' => '- не выбрано -') + sql_getRows('SELECT id, name FROM `obj_housetypes` WHERE 1 ORDER BY id', true);
     $ret['city_id'] = $row['city_id'];
     $ret['district_id'] = $row['distrcit_id'];
     $ret['metro_id'] = $row['metro_id'];
     $ret['select_metro_time'] = $row['metro_dest_value'];
     $ret['select_metro_time_type'] = intval($row['metro_dest_text']) + 1;
     $ret['rooms'] = $row['room'];
     $ret['addres'] = sql_getValue("SELECT `address` FROM `obj_address` WHERE `id`='" . $row['address_id'] . "'");
     $ret['new_house'] = $row['market'] == "first" ? 1 : 0;
     $ret['storey'] = $row['storey'];
     $ret['storey_number'] = $row['storeys_number'];
     $ret['house_type_id'] = $row['house_type'];
     $ret['total_area'] = $row['total_area'];
     $ret['live_area'] = $row['living_area'];
     $ret['kitchen_area'] = $row['kitchen_area'];
     $ret['lavatory'] = $row['lavatory'];
     $ret['balcony'] = $row['balcony'];
     $ret['phones'] = $row['phone'];
     $ret['description'] = $row['short_description'];
     $ret['price_rub'] = $row['price_rub'];
     $profile = $auth->getCurrentUserData();
     $ret['fio'] = $profile['fio'];
     $ret['email'] = $profile['login'];
     $contact_phones = explode(",", $row['contact_phone']);
     $ret['phone'] = trim($contact_phones[0]);
     $ret['phone2'] = trim($contact_phones[1]);
     $fotki = sql_getRows("SELECT * FROM `obj_elem_images` WHERE `type`='photo' AND `pid`='{$id}'");
     foreach ($fotki as $fotka) {
         $ret['photos'][] = array('id' => $fotka['id'], 'link' => $fotka['imagepath'], 'filename' => substr($fotka['imagepath'], strrpos($fotka['imagepath'], '/') + 1));
     }
     $plans = sql_getRows("SELECT * FROM `obj_elem_plans` WHERE `pid`='{$id}'");
     foreach ($plans as $plan) {
         $ret['plans'][] = array('id' => $plan['id'], 'link' => $plan['image'], 'filename' => substr($plan['image'], strrpos($plan['image'], '/') + 1));
     }
     return $ret;
 }
Ejemplo n.º 2
0
setUploadLimit();
# LOAD CONTENT
// These check vars are set in the "SET VARS" section
if ($ftpAction == "download" || $ftpAction == "download_zip" || $ftpAction == "iframe_upload" || $ftpAction == "editProcess") {
    // Login
    attemptLogin();
    // Check referer
    if (checkReferer() == 1) {
        // Display content when logged in
        if ($_SESSION["loggedin"] == 1) {
            if ($ftpAction == "download") {
                downloadFile();
                parentOpenFolder();
            }
            if ($ftpAction == "download_zip") {
                downloadFiles();
                parentOpenFolder();
            }
            if ($ftpAction == "iframe_upload") {
                iframeUpload();
                parentOpenFolder();
            }
            if ($ftpAction == "editProcess") {
                editProcess();
            }
        }
    }
} else {
    if ($ajaxRequest == 0) {
        // Check if logout link has been clicked
        checkLogOut();
Ejemplo n.º 3
0
    }
}
if (0 == errorCount()) {
    $tmp_folder = setupTmpFolder($folders);
}
if (0 == errorCount()) {
    $cache = setupGitCacheFolder($folders);
}
define('GIT_CACHE_DEST', $cache[0]);
if (0 == errorCount()) {
    for ($x = 0; $x < count($folders); $x++) {
        buildFilesList($cache, $files_list, GIT, $exclude_files, $folders[$x]);
    }
}
if (0 == errorCount() && $cache[1] == GITNEW) {
    downloadFiles($files_list);
}
if (0 == errorCount()) {
    backupFiles($tmp_folder, $files_list);
}
if (0 == errorCount()) {
    copyFiles($files_list);
}
if (0 == errorCount()) {
    $dbupdate = updateDB($nuConfigDBHost, $nuConfigDBName, $nuConfigDBUser, $nuConfigDBPassword);
}
if (errorCount() > 0) {
    $finalResult['message'] = 'ERRORS';
} else {
    $finalResult['message'] = 'SUCCESS';
}
$tokenFileLocation = __DIR__ . "/../../github_oauth_token.txt";
$existingToken = @file_get_contents($tokenFileLocation);
$existingToken = trim($existingToken);
if (!$existingToken) {
    echo "token not found\n";
    exit(0);
}
echo "Using token from file {$tokenFileLocation} \n";
$token = new Oauth2Token($existingToken);
$githubClient = new GithubService(new ArtaxClient(), \Amp\reactor(), new FileResponseCache(new FileCachePath(__DIR__ . "/fileCache")), 'Danack/GithubArtaxService');
$downloadedFiles = [];
if (false) {
    // for debugging
    //$downloadedFiles[] = "./download/phanan_koel_8c862cb9cc43a6715fbd9d9a289ef7e2ac81b523.tar.gz";
} else {
    $downloadedFiles = downloadFiles($githubClient, $token);
}
analyzeFiles($downloadedFiles);
echo "fin\n";
exit(0);
function removeDirectory($path)
{
    if (is_dir($path) == false) {
        //Directory doesn't exist.
        return;
    }
    $files = new DirectoryIterator($path);
    foreach ($files as $file) {
        if (!$file->isDot()) {
            if (is_dir($file->getPathname())) {
                removeDirectory($file->getPathname());
Ejemplo n.º 5
0
function cron()
{
    connectDB();
    downloadFiles();
    parseFiles();
}