Exemplo n.º 1
0
    $conf = infra_config();
    return infra_err($ans, $conf['subscribe']['msg']);
}
if (strlen($_REQUEST['email']) > 1000) {
    return infra_err($ans, 'Слишком много данных. ' . $conf['subscribe']['msg']);
}
$email = strip_tags($_REQUEST['email']);
$email = trim($email);
$email = infra_forFS($email);
$agent = $_SERVER['HTTP_USER_AGENT'];
$ip = $_SERVER['REMOTE_ADDR'];
session_start();
if (empty($_SESSION['submit_time'])) {
    $_SESSION['submit_time'] = 0;
}
if (time() - $_SESSION['submit_time'] < 60) {
    return infra_err($ans, 'Письмо уже отправлено! Новое сообщение можно будет отправить через 1 минуту!');
}
$_SESSION['submit_time'] = time();
$data = array('email' => $email, 'agent' => $agent, 'ip' => $ip, 'host' => $_SERVER['HTTP_HOST']);
$body = infra_template_parse('*order.tpl', $data);
infra_mail_toAdmin('Запрос ' . $data['host'] . ' ' . $email, 'noreplay@' . $data['host'], $body);
$dirs = infra_dirs();
$src = $dirs['data'] . '.subscribe.json';
$subs = infra_loadJSON($src);
if (!$subs) {
    $subs = array();
}
$subs[$email] = date('d.m.Y');
file_put_contents($src, infra_json_encode($subs));
return infra_ret($ans, 'Ваша заявка принята');
Exemplo n.º 2
0
 private function makeMark($data)
 {
     if (!$data) {
         return '';
     }
     self::rksort($data);
     $key = md5(serialize($data));
     $that = $this;
     $mark = infra_once($this->prefix . $key, function () use($data, $that, $key) {
         $isoutdate = true;
         $raise = $this->raise;
         //На сколько символов разрешено увеличивать хэш
         $note = $this->note;
         //При увеличении на сколько записывается сообщение в лог
         $len = $this->len - 1;
         while ($isoutdate && $len < $this->len + $raise) {
             $len++;
             $mark = substr($key, 0, $len);
             $src = infra_theme('~.marks/' . $that->prefix . $mark . '.json');
             if ($src) {
                 $otherdata = file_get_contents($src);
                 $otherdata = infra_json_decode($otherdata);
             } else {
                 $otherdata = false;
             }
             //$otherdata=infra_mem_get($that->prefix.$mark);
             if ($otherdata && is_array($otherdata['data']) && $otherdata['time']) {
                 if ($otherdata['data'] == $data) {
                     $isoutdate = false;
                     //Такая метка уже есть и она правильная
                 } else {
                     //Решается судьба старой метки
                     $isoutdate = time() > $data['time'] + $this->warrantytime;
                 }
             } else {
                 $isoutdate = false;
             }
         }
         if ($len >= $this->len + $note) {
             $that->notice = 'Mark adding to hash ' . ($len - $this->len) . ' symbol(s) for save time warranty ' . print_r($data, true);
             error_log($that->notice);
         }
         if ($isoutdate) {
             //Все метки актуальны... перезаписываем первую
             $that->error = 'Mark rewrite actual hashmark';
             error_log($that->error);
             $mark = substr($key, 0, $this->len);
         }
         $src = infra_theme('~.marks/');
         if (!$src) {
             die('Fatal error no marks dir');
         }
         $src = $src . $this->prefix . $mark . '.json';
         $data = infra_json_encode(array('time' => time(), 'data' => $data));
         $data = file_put_contents($src, $data);
         //infra_mem_set($that->prefix.$mark, array(
         //	'time'=>time(),
         //	'data'=>$data
         //));
         return $mark;
     });
     return $mark;
 }
Exemplo n.º 3
0
function seo_normalizeValue($key)
{
    if (is_integer($key)) {
        $key = (string) $key;
    }
    if (is_array($key)) {
        $key = infra_json_encode($key);
    }
    if (!is_string($key)) {
        $key = '';
    }
    $key = strip_tags($key);
    $key = infra_State_forFS($key);
    return $key;
}
Exemplo n.º 4
0
}
$ans['cat_id'] = $id;
$ans['cat_time'] = $time;
$user = array('cat_id' => $id, 'list' => array(), 'time' => time());
foreach ($data['users'] as $k => $v) {
    if ($v['cat_id'] == $id) {
        $user = $v;
        unset($data['users'][$k]);
        break;
    }
}
$data['users'] = array_values($data['users']);
foreach ($user['list'] as $k => $v) {
    if ($v['val'] == $val) {
        unset($user['list'][$k]);
        break;
    }
}
$user['list'] = array_values($user['list']);
$search = infra_loadJSON('*catalog/search.php?val=' . $val);
array_unshift($user['list'], array('val' => $val, 'time' => time(), 'count' => $search['count']));
if (sizeof($user['list']) > 10) {
    $user['list'] = array_slice($user['list'], 0, 10);
}
array_unshift($data['users'], $user);
if (sizeof($data['users']) > 100) {
    $data['users'] = array_slice($data['users'], 0, 50);
}
file_put_contents($dir . 'catalog_stat.json', infra_json_encode($data));
$ans['data'] = $data;
return infra_ret($ans);
Exemplo n.º 5
0
function infrajs_seo_save()
{
    $conf = infra_config();
    if (!$conf['seo']['seo']) {
        return;
    }
    infra_admin_cache('infrajs_seo_save', function () {
        $store =& infrajs_store();
        $dir = 'infra/cache/seo/';
        if (is_dir($dir)) {
            $list = infra_loadJSON('*pages/list.php?src=' . $dir . '&onlyname=1');
            foreach ($list as $file) {
                unlink($dir . infra_tofs($file));
            }
            $r = rmdir($dir);
            if (!$r) {
                $conf = infra_config();
                if ($conf['debug']) {
                    die('Не удалось удалить папку ' . $dir);
                }
            }
        }
        @mkdir($dir);
        foreach ($store['seo'] as $name => $seo) {
            file_put_contents($dir . infra_tofs($name) . '.json', infra_json_encode($seo));
        }
    });
}