/**
  * Save an uploaded file to a new location.
  *
  * @param   mixed    name of $_FILE input or array of upload data
  * @param   string   new filename
  * @param   string   new directory
  * @param   integer  chmod mask
  * @return  string   full path to new file
  */
 public static function save($file, $filename = NULL, $directory = NULL, $chmod = 0755)
 {
     // Load file data from FILES if not passed as array
     $file = is_array($file) ? $file : $_FILES[$file];
     if ($filename === NULL) {
         // Use the default filename, with a timestamp pre-pended
         $filename = time() . $file['name'];
     }
     // Remove spaces from the filename
     $filename = preg_replace('/\\s+/', '_', $filename);
     if ($directory === NULL) {
         // Use the pre-configured upload directory
         $directory = WWW_ROOT . 'files/';
     }
     // Make sure the directory ends with a slash
     $directory = rtrim($directory, '/') . '/';
     if (!is_dir($directory)) {
         // Create the upload directory
         mkdir($directory, 0777, TRUE);
     }
     //if ( ! is_writable($directory))
     //throw new exception;
     if (is_uploaded_file($file['tmp_name']) and move_uploaded_file($file['tmp_name'], $filename = $directory . $filename)) {
         if ($chmod !== FALSE) {
             // Set permissions on filename
             chmod($filename, $chmod);
         }
         //$all_file_name = array(FILE_INFO => $filename);
         // Return new file path
         return $filename;
     }
     return FALSE;
 }
Example #2
2
 public function responseMsg()
 {
     //get post data, May be due to the different environments
     $postStr = $GLOBALS["HTTP_RAW_POST_DATA"];
     //extract post data
     if (!empty($postStr)) {
         /* libxml_disable_entity_loader is to prevent XML eXternal Entity Injection,
            the best way is to check the validity of xml by yourself */
         libxml_disable_entity_loader(true);
         $postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);
         $fromUsername = $postObj->FromUserName;
         $toUsername = $postObj->ToUserName;
         $keyword = trim($postObj->Content);
         $time = time();
         $textTpl = "<xml>\n\t\t\t\t\t\t\t<ToUserName><![CDATA[%s]]></ToUserName>\n\t\t\t\t\t\t\t<FromUserName><![CDATA[%s]]></FromUserName>\n\t\t\t\t\t\t\t<CreateTime>%s</CreateTime>\n\t\t\t\t\t\t\t<MsgType><![CDATA[%s]]></MsgType>\n\t\t\t\t\t\t\t<Content><![CDATA[%s]]></Content>\n\t\t\t\t\t\t\t<FuncFlag>0</FuncFlag>\n\t\t\t\t\t\t\t</xml>";
         if (!empty($keyword)) {
             $msgType = "text";
             $contentStr = "Welcome to wechat world!";
             $resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, $msgType, $contentStr);
             echo $resultStr;
         } else {
             echo "Input something...";
         }
     } else {
         echo "";
         exit;
     }
 }
 public static function getAge($unix_timestamp)
 {
     $t = time();
     $age = $unix_timestamp < 0 ? $t + $unix_timestamp * -1 : $t - $unix_timestamp;
     $year = 60 * 60 * 24 * 365;
     return floor($age / $year);
 }
function flickr_faves_add_fave(&$viewer, &$photo, $date_faved = 0)
{
    if (!$date_faved) {
        $date_faved = time();
    }
    $cluster_id = $viewer['cluster_id'];
    $fave = array('user_id' => $viewer['id'], 'photo_id' => $photo['id'], 'owner_id' => $photo['user_id'], 'date_faved' => $date_faved);
    $insert = array();
    foreach ($fave as $k => $v) {
        $insert[$k] = AddSlashes($v);
    }
    $rsp = db_insert_users($cluster_id, 'FlickrFaves', $insert);
    if (!$rsp['ok'] && $rsp['error_code'] != 1062) {
        return $rsp;
    }
    # now update the photo owner side of things
    $owner = users_get_by_id($photo['user_id']);
    $cluster_id = $owner['cluster_id'];
    $fave = array('user_id' => $owner['id'], 'photo_id' => $photo['id'], 'viewer_id' => $viewer['id']);
    $insert = array();
    foreach ($fave as $k => $v) {
        $insert[$k] = AddSlashes($v);
    }
    $rsp = db_insert_users($cluster_id, 'FlickrFavesUsers', $insert);
    if (!$rsp['ok'] && $rsp['error_code'] != 1062) {
        return $rsp;
    }
    # TO DO: index/update the photo in solr and insert $viewer['id']
    # into the faved_by column (20111123/straup)
    return okay();
}
Example #5
1
 /**
  *
  * @ORM\PrePersist
  */
 public function generateSecurekey()
 {
     $generator = new SecureRandom();
     $random = $generator->nextBytes(150);
     $securekey = md5($random . time());
     $this->setSecurekey($securekey);
 }
 /**
  * 登陆,如果失败,返回失败原因(用户名或者密码不正确),如果成功,返回用户信息,
  * 附带返回系统服务器时间戳
  */
 public function login()
 {
     //查user表
     $User = M('User');
     check_error($User);
     $user = $User->field(array('id' => 'userId', 'username' => 'userName', 'name', 'role_id' => 'roleId', 'role'))->where(array('username' => safe_post_param('username'), '_string' => "`password`=MD5('" . safe_post_param('password') . "')"))->find();
     if (!empty($user)) {
         //根据权限查菜单
         $Menu = M('Menu');
         check_error($Menu);
         $menu = $Menu->join('`role_privilege` on `menu`.`id`=`role_privilege`.`menu_id`')->join('`user` on `user`.`role_id`=`role_privilege`.`role_id`')->field(array('`menu`.`id`', 'level', 'label', 'icon', 'widget', 'show', 'big_icon'))->where("`user`.`id`='" . $user['userId'] . "'")->order('`level` ASC')->select();
         check_error($Menu);
         //保存session
         session('logined', true);
         session('user', $user);
         session('menu', $menu);
         //设置返回数据
         $data = array();
         $data['serverTime'] = time();
         $data['user'] = $user;
         $data['menu'] = $menu;
         //保存日志
         R('Log/adduserlog', array('登录', '登录成功', '成功'));
         //返回结果:用户数据+服务器时间
         return_value_json(true, 'data', $data);
     } else {
         //保存日志
         R('Log/adduserlog', array('登录', '登录失败:用户名或者密码不正确', '失败:权限不够', '用户名:' . safe_post_param('username')));
         return_value_json(false, 'msg', '用户名或者密码不正确');
     }
 }
Example #7
1
 public function collectData(array $param)
 {
     $html = $this->file_get_html('http://www.maliki.com/') or $this->returnError('Could not request Maliki.', 404);
     $count = 0;
     $latest = 1;
     $latest_title = "";
     $latest = $html->find('div.conteneur_page a', 1)->href;
     $latest_title = $html->find('div.conteneur_page img', 0)->title;
     function MalikiExtractContent($url)
     {
         $html2 = $this->file_get_html($url);
         $text = 'http://www.maliki.com/' . $html2->find('img', 0)->src;
         $text = '<img alt="" src="' . $text . '"/><br>' . $html2->find('div.imageetnews', 0)->plaintext;
         return $text;
     }
     $item = new \Item();
     $item->uri = 'http://www.maliki.com/' . $latest;
     $item->title = $latest_title;
     $item->timestamp = time();
     $item->content = MalikiExtractContent($item->uri);
     $this->items[] = $item;
     foreach ($html->find('div.boite_strip') as $element) {
         if (!empty($element->find('a', 0)->href) and $count < 3) {
             $item = new \Item();
             $item->uri = 'http://www.maliki.com/' . $element->find('a', 0)->href;
             $item->title = $element->find('img', 0)->title;
             $item->timestamp = strtotime(str_replace('/', '-', $element->find('span.stylepetit', 0)->innertext));
             $item->content = MalikiExtractContent($item->uri);
             $this->items[] = $item;
             $count++;
         }
     }
 }
Example #8
1
 public function format_time($timestamp, $date_only = false, $date_format = null, $time_format = null, $time_only = false, $no_text = false)
 {
     global $forum_date_formats, $forum_time_formats;
     if ($timestamp == '') {
         return __('Never');
     }
     $diff = ($this->feather->user->timezone + $this->feather->user->dst) * 3600;
     $timestamp += $diff;
     $now = time();
     if (is_null($date_format)) {
         $date_format = $forum_date_formats[$this->feather->user->date_format];
     }
     if (is_null($time_format)) {
         $time_format = $forum_time_formats[$this->feather->user->time_format];
     }
     $date = gmdate($date_format, $timestamp);
     $today = gmdate($date_format, $now + $diff);
     $yesterday = gmdate($date_format, $now + $diff - 86400);
     if (!$no_text) {
         if ($date == $today) {
             $date = __('Today');
         } elseif ($date == $yesterday) {
             $date = __('Yesterday');
         }
     }
     if ($date_only) {
         return $date;
     } elseif ($time_only) {
         return gmdate($time_format, $timestamp);
     } else {
         return $date . ' ' . gmdate($time_format, $timestamp);
     }
 }
/**
 * test if a value is a valid credit card expiration date
 *
 * @param string $value the value being tested
 * @param boolean $empty if field can be empty
 * @param array params validate parameter values
 * @param array formvars form var values
 */
function smarty_validate_criteria_isCCExpDate($value, $empty, &$params, &$formvars)
{
    if (strlen($value) == 0) {
        return $empty;
    }
    if (!preg_match('!^(\\d+)\\D+(\\d+)$!', $value, $_match)) {
        return false;
    }
    $_month = $_match[1];
    $_year = $_match[2];
    if (strlen($_year) == 2) {
        $_year = substr(date('Y', time()), 0, 2) . $_year;
    }
    $_month = (int) $_month;
    $_year = (int) $_year;
    if ($_month < 1 || $_month > 12) {
        return false;
    }
    if (date('Y', time()) > $_year) {
        return false;
    }
    if (date('Y', time()) == $_year && date('m', time()) > $_month) {
        return false;
    }
    return true;
}
Example #10
0
 /**
  * 欢迎页面
  */
 public function welcomeOp()
 {
     /**
      * 管理员信息
      */
     $model_admin = Model('admin');
     $tmp = $this->getAdminInfo();
     $condition['admin_id'] = $tmp['id'];
     $admin_info = $model_admin->infoAdmin($condition);
     $admin_info['admin_login_time'] = date('Y-m-d H:i:s', $admin_info['admin_login_time'] == '' ? time() : $admin_info['admin_login_time']);
     /**
      * 系统信息
      */
     $version = C('version');
     $setup_date = C('setup_date');
     $statistics['os'] = PHP_OS;
     $statistics['web_server'] = $_SERVER['SERVER_SOFTWARE'];
     $statistics['php_version'] = PHP_VERSION;
     $statistics['sql_version'] = Db::getServerInfo();
     $statistics['shop_version'] = $version;
     $statistics['setup_date'] = substr($setup_date, 0, 10);
     // 运维舫 c extension
     try {
         $r = new ReflectionExtension('shopnc');
         $statistics['php_version'] .= ' / ' . $r->getVersion();
     } catch (ReflectionException $ex) {
     }
     Tpl::output('statistics', $statistics);
     Tpl::output('admin_info', $admin_info);
     Tpl::showpage('welcome');
 }
 protected function getData($nowPage,$pageSize)
 {/*{{{*/
     $dataList = $this->prepareData($nowPage, $pageSize);
     $res = array();
     foreach ($dataList as $data)
     {
         $provinceKey = Area::getProvKeyByName($data['prov']);
         $tempData = array();
         $tempData['item']['key'] = $data['prov'].$data['dname'].'医院';
         $tempData['item']['url'] =  'http://www.haodf.com/jibing/'.$data['dkey'].'/yiyuan.htm?province='.$provinceKey;
         $tempData['item']['showurl'] = 'www.haodf.com';
         $tempData['item']['title'] = $data['prov'].$data['dname']."推荐医院_好大夫在线";
         $tempData['item']['pagesize'] = rand(58, 62).'K';
         $tempData['item']['date'] = date('Y-m-d', time());
         $tempData['item']['content1'] = "根据".$data['diseasevote']."位".$data['dname']."患者投票得出的医院排行";
         $tempData['item']['link'] = $tempData['item']['url'];
         foreach ($data['formdata'] as $formData)
         {
             $tempData['item'][] = $formData;
             unset($formData);
         }
         $res[] = $tempData;
         unset($data);
     }
     return $res;
 }/*}}}*/
Example #12
0
 public function callback()
 {
     //$_REQUEST['MerchantTradeNo'] = "65";
     $this->load->model('checkout/order');
     //$query_url = "https://payment.allpay.com.tw/Cashier/QueryTradeInfo";
     $query_url = "https://payment.allpay.com.tw/Cashier/QueryTradeInfo";
     $timestamp = time();
     $hash_iv = $this->config->get('allpay_credit18_iv_key');
     $hash_key = $this->config->get('allpay_credit18_hash_key');
     $order_id = $_REQUEST['MerchantTradeNo'];
     $mer_id = $this->config->get('allpay_credit18_account');
     $order_finish_statu = $this->config->get('allpay_credit18_order_finish_status_id');
     $input_array = array("MerchantID" => $mer_id, "MerchantTradeNo" => $order_id, "TimeStamp" => $timestamp);
     ksort($input_array);
     $checkvalue = "HashKey={$hash_key}&" . urldecode(http_build_query($input_array)) . "&HashIV={$hash_iv}";
     $checkvalue = strtolower(urlencode($checkvalue));
     $checkvalue = md5($checkvalue);
     $input_array["CheckMacValue"] = $checkvalue;
     $post_data = http_build_query($input_array);
     $result = $this->curl_work($query_url, "POST", $post_data);
     parse_str($result["web_info"], $query_result);
     $order_info = $this->model_checkout_order->getOrder($order_id);
     $system_total_amt = intval(round($order_info['total']));
     if ($query_result["TradeStatus"] == "1" && $query_result["TradeAmt"] == $system_total_amt) {
         $this->db->query("UPDATE `" . DB_PREFIX . "order` SET order_status_id = '{$order_finish_statu}', date_modified = NOW() WHERE order_id = '" . $order_id . "'");
     }
 }
Example #13
0
 public function collectData(array $param)
 {
     $page = 0;
     $tags = '';
     if (isset($param['p'])) {
         $page = (int) preg_replace("/[^0-9]/", '', $param['p']);
         $page = $page - 1;
         $page = $page * 50;
     }
     if (isset($param['t'])) {
         $tags = urlencode($param['t']);
     }
     $html = $this->file_get_html("http://mspabooru.com/index.php?page=post&s=list&tags={$tags}&pid={$page}") or $this->returnError('Could not request Mspabooru.', 404);
     foreach ($html->find('div[class=content] span') as $element) {
         $item = new \Item();
         $item->uri = 'http://mspabooru.com/' . $element->find('a', 0)->href;
         $item->postid = (int) preg_replace("/[^0-9]/", '', $element->getAttribute('id'));
         $item->timestamp = time();
         $item->thumbnailUri = $element->find('img', 0)->src;
         $item->tags = $element->find('img', 0)->getAttribute('alt');
         $item->title = 'Mspabooru | ' . $item->postid;
         $item->content = '<a href="' . $item->uri . '"><img src="' . $item->thumbnailUri . '" /></a><br>Tags: ' . $item->tags;
         $this->items[] = $item;
     }
 }
Example #14
0
/**
 * Initialize session.
 * @param boolean $keepopen keep session open? The default is
 * 			to close the session after $_SESSION has been populated.
 * @uses $_SESSION
 */
function session_init($keepopen = false)
{
    $settings = new phpVBoxConfigClass();
    // Sessions provided by auth module?
    if (@$settings->auth->capabilities['sessionStart']) {
        call_user_func(array($settings->auth, $settings->auth->capabilities['sessionStart']), $keepopen);
        return;
    }
    // No session support? No login...
    if (@$settings->noAuth || !function_exists('session_start')) {
        global $_SESSION;
        $_SESSION['valid'] = true;
        $_SESSION['authCheckHeartbeat'] = time();
        $_SESSION['admin'] = true;
        return;
    }
    // start session
    session_start();
    // Session is auto-started by PHP?
    if (!ini_get('session.auto_start')) {
        ini_set('session.use_trans_sid', 0);
        ini_set('session.use_only_cookies', 1);
        // Session path
        if (isset($settings->sessionSavePath)) {
            session_save_path($settings->sessionSavePath);
        }
        session_name(isset($settings->session_name) ? $settings->session_name : md5('phpvbx' . $_SERVER['DOCUMENT_ROOT'] . $_SERVER['HTTP_USER_AGENT']));
        session_start();
    }
    if (!$keepopen) {
        session_write_close();
    }
}
 /** @dataProvider provideStorage */
 public function testSetRefreshToken(RefreshTokenInterface $storage)
 {
     if ($storage instanceof NullStorage) {
         $this->markTestSkipped('Skipped Storage: ' . $storage->getMessage());
         return;
     }
     // assert token we are about to add does not exist
     $token = $storage->getRefreshToken('refreshtoken');
     $this->assertFalse($token);
     // add new token
     $expires = time() + 20;
     $success = $storage->setRefreshToken('refreshtoken', 'oauth_test_client', '1', $expires, 'supportedscope1 supportedscope2');
     $this->assertTrue($success);
     $token = $storage->getRefreshToken('refreshtoken');
     $this->assertNotNull($token);
     $this->assertArrayHasKey('refresh_token', $token);
     $this->assertArrayHasKey('client_id', $token);
     $this->assertArrayHasKey('user_id', $token);
     $this->assertArrayHasKey('expires', $token);
     $this->assertEquals($token['refresh_token'], 'refreshtoken');
     $this->assertEquals($token['client_id'], 'oauth_test_client');
     $this->assertEquals($token['user_id'], '1');
     # reference from client
     $this->assertEquals($token['expires'], $expires);
     # should be expreRefreshToken?
     $this->assertTrue($storage->unsetRefreshToken('refreshtoken'));
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  int $mcid
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $mcid_id)
 {
     $this->validate($request, ['file' => 'required']);
     $mcid = MCID::findOrFail($mcid_id);
     $file = $_FILES['file'];
     $fileName = md5($mcid_id . $file['name'] . time());
     $path = str_finish($this->skin_path, '/') . $fileName;
     $content = File::get($file['tmp_name']);
     if (is_image($file['type']) && $file['size'] <= 150 * 1000) {
         list($img_w, $img_h) = getimagesize($file['tmp_name']);
         if ($img_w > 64 || $img_h > 64) {
             $error = "皮肤文件 '{$fileName}' 尺寸不正确.";
         } else {
             $result = $this->manager->saveFile($path, $content);
             if ($result === true) {
                 $skin = Skin::where('mcid_id', $mcid->id)->first();
                 if ($skin == null) {
                     $skin = new Skin();
                 }
                 $skin->mcid_id = $mcid->id;
                 $skin->url = $path;
                 $skin->save();
                 return redirect()->back()->withSuccess("皮肤文件 '{$fileName}' 上传成功.");
             } else {
                 $error = $result ?: "皮肤文件 '{$fileName}' 上传失败.";
             }
         }
     } else {
         $error = "皮肤文件 '{$fileName}' 格式或大小不正确.";
     }
     return redirect()->back()->withErrors([$error]);
 }
Example #17
0
 function reply($id)
 {
     if ($_POST) {
         $tto = (int) $this->input->post('tto');
         $id = (int) $this->input->post('id');
         $parent = (int) $this->input->post('parent');
         $subject = $this->input->post('subject');
         $msg = $this->input->post('msg');
         if ($id) {
             if (!$tto || !$subject || !$msg || !$parent) {
                 __set_error_msg(array('error' => 'Data that you entered is incomplete !!!'));
                 redirect(site_url('panel/support/reply/' . $id));
             } else {
                 if ($this->support_model->__insert_tickets(array('tto' => $tto, 'tuid' => $this->memcachedlib->sesresult['uid'], 'tdate' => time(), 'tsubject' => $subject, 'tmsg' => $msg, 'tparent' => $parent, 'tstatus' => 1))) {
                     __set_error_msg(array('info' => 'Ticket successfully sent !!!'));
                     redirect(site_url('panel/support'));
                 } else {
                     __set_error_msg(array('error' => 'Dissmiss input data !!!'));
                     redirect(site_url('panel/support/reply/' . $id));
                 }
             }
         } else {
             __set_error_msg(array('error' => 'Dissmiss input data !!!'));
             redirect(site_url('panel/support'));
         }
     } else {
         $view['id'] = $id;
         $view['detail'] = $this->support_model->__get_tickets_detail($this->memcachedlib->sesresult['uid'], $id);
         if (!$view['detail']) {
             __set_error_msg(array('error' => 'Dissmiss input data !!!'));
             redirect(site_url('panel/support'));
         }
         $this->load->view('pages/support_reply', $view);
     }
 }
Example #18
0
function getTop3($db)
{
    $userid = $_SESSION['users'];
    $nowdate = date('Y-m-d', time());
    $datetime = strtotime(date("Y-m-d", time()));
    //获取当前日期并转换成时间戳
    $tomorrow = date('Y-m-d', $datetime + 86400);
    //在时间戳的基础上加一天(即60*60*24)
    $searchsql = "Select userid,sum(calorie) as allcal from Exercise where ( userid='{$userid}' or userid in (select friendid from Friendship where userid = '{$userid}')) and endTime<'{$tomorrow}' and endTime>='{$nowdate}' group by userid order by allcal desc limit 3";
    $result = $db->query($searchsql);
    $joinlist = '[';
    $count = 0;
    while ($row = $result->fetchArray(SQLITE3_ASSOC)) {
        $usersid = $row['userid'];
        $sql = "Select nickname from user where userid='{$usersid}'";
        $rec = $db->query($sql);
        if ($row2 = $rec->fetchArray(SQLITE3_ASSOC)) {
            $username = $row2['nickname'];
        }
        $joinnode = array("username" => $username, "calorie" => $row['allcal']);
        foreach ($joinnode as $key => $value) {
            $joinnode[$key] = urlencode($value);
        }
        if ($count > 0) {
            $joinlist = $joinlist . ',';
        }
        $joinlist = $joinlist . urldecode(json_encode($joinnode));
        $count = $count + 1;
    }
    $joinlist = $joinlist . ']';
    echo $joinlist;
}
function page()
{
    $tpl = new templates();
    $page = CurrentPageName();
    $alias = $tpl->_ENGINE_parse_body("{alias}");
    $directory = $tpl->_ENGINE_parse_body("{directory}");
    $description = $tpl->_ENGINE_parse_body("{description}");
    $new_alias = $tpl->_ENGINE_parse_body("{new_directory}");
    $t = time();
    $buttons = "\n\tbuttons : [\n\t{name: '<b>{$new_alias}</b>', bclass: 'Add', onpress : AddNewAlias{$t}},\n\t\n\t\t],";
    $html = "\n\n<table class='flexRT{$t}' style='display: none' id='flexRT{$t}' style='width:100%'></table>\n\n\t\n<script>\nvar mem{$t}='';\n\$(document).ready(function(){\n\$('#flexRT{$t}').flexigrid({\n\turl: '{$page}?freeweb-aliases-list=yes&servername={$_GET["servername"]}&t={$t}',\n\tdataType: 'json',\n\tcolModel : [\n\t\t{display: '{$directory}', name : 'directory', width :796, sortable : false, align: 'left'},\n\t\t{display: '&nbsp;', name : 'del', width : 31, sortable : true, align: 'center'},\n\t\t\n\t\t],\n\t{$buttons}\n\tsearchitems : [\n\t\t{display: '{$directory}', name : 'directory'},\n\t\t],\n\tsortname: 'directory',\n\tsortorder: 'asc',\n\tusepager: true,\n\ttitle: '',\n\tuseRp: true,\n\trp: 50,\n\tshowTableToggleBtn: false,\n\twidth: 900,\n\theight: 400,\n\tsingleSelect: true,\n\trpOptions: [10, 20, 30, 50,100,200]\n\t\n\t});   \n});\n\tfunction AddNewAlias{$t}(){\n\t\tYahooWin6('600','{$page}?new-alias=yes&servername={$_GET["servername"]}&t={$t}','{$new_alias}');\n\t}\n\t\n\t\tvar x_FreeWebAddAlias{$t}=function (obj) {\n\t\t\tvar results=obj.responseText;\n\t\t\tif(results.length>0){alert(results);return;}\t\n\t\t\t\$('#row'+mem{$t}).remove();\n\t\t}\t\t\n\t\n\tfunction FreeWebDelAlias{$t}(id){\n\t\tmem{$t}=id;\n\t\t\tvar XHR = new XHRConnection();\n\t\t\tXHR.appendData('DelAlias',id);\n\t\t\tXHR.appendData('servername','{$_GET["servername"]}');\n    \t\tXHR.sendAndLoad('{$page}', 'POST',x_FreeWebAddAlias{$t});\t\t\n\t}\n\n\n</script>\n\n";
    //$('#flexRT$t').flexReload();
    echo $html;
    return;
    $page = CurrentPageName();
    $tpl = new templates();
    $free = new freeweb($_GET["servername"]);
    //if($free->groupware<>null){
    //echo $tpl->_ENGINE_parse_body("<div class=text-info>{freeweb_is_groupware_feature_disabled}</div>");
    //return;
    //}
    $free->CheckWorkingDirectory();
    $direnc = urlencode(base64_encode($free->WORKING_DIRECTORY));
    $html = "\n\t<p>&nbsp;</p>\n\t<div id='freeweb-aliases-list' style='width:100%;heigth:350px;overflow:auto'></div>\n\t\n\t\n\t\n\t<script>\n\t\tvar x_FreeWebAddAlias=function (obj) {\n\t\t\tvar results=obj.responseText;\n\t\t\tif(results.length>0){alert(results);}\t\n\t\t\tFreeWebAliasList();\t\n\t\t}\t\t\t\n\t\t\n\t\tfunction FreeWebAddAliasCheck(e){\n\t\t\tif(checkEnter(e)){FreeWebAddAlias();}\n\t\t}\n\t\t\n\t\tfunction FreeWebAddAlias(){\n\t\t\tvar XHR = new XHRConnection();\n\t\t\tvar Alias=document.getElementById('alias_freeweb').value;\n\t\t\tif(Alias.length<2){return;}\n\t\t\tvar directory=document.getElementById('alias_dir').value;\n\t\t\tif(directory.length<2){return;}\t\t\t\n\t\t\tXHR.appendData('Alias',document.getElementById('alias_freeweb').value);\n\t\t\tXHR.appendData('directory',document.getElementById('alias_dir').value);\n\t\t\tXHR.appendData('servername','{$_GET["servername"]}');\n\t\t\tAnimateDiv('freeweb-aliases-list');\n    \t\tXHR.sendAndLoad('{$page}', 'POST',x_FreeWebAddAlias);\t\t\t\n\t\t}\n\t\t\n\t\tfunction FreeWebDelAlias(id){\n\t\t\tvar XHR = new XHRConnection();\n\t\t\tXHR.appendData('DelAlias',id);\n\t\t\tXHR.appendData('servername','{$_GET["servername"]}');\n\t\t\tAnimateDiv('freeweb-aliases-list');\n    \t\tXHR.sendAndLoad('{$page}', 'POST',x_FreeWebAddAlias);\t\t\t\n\t\t}\t\t\n\t\t\n\t\tfunction FreeWebAliasList(){\n\t\t\tLoadAjax('freeweb-aliases-list','{$page}?freeweb-aliases-list=yes&servername={$_GET["servername"]}');\n\t\t}\n\tFreeWebAliasList();\n\t</script>\n\t\n\t\n\t";
    echo $tpl->_ENGINE_parse_body($html);
}
Example #20
0
 public function save()
 {
     $cover = $this->upload_file('product_cover');
     $download = $this->upload_file('userfile');
     $_POST['cover'] = $cover === '' ? $_POST['cover'] : '/uploads/' . $cover;
     $_POST['download'] = $download == '' ? '' : $download;
     foreach ($_POST as $key => $item) {
         if ($key === 'is_hot' || $key === 'desc' || $key === 'keywords') {
             continue;
         }
         //指定允许空值的字段
         if (empty($_POST[$key])) {
             unset($_POST[$key]);
         }
     }
     if (isset($_POST['id'])) {
         $_POST['ctime'] = strtotime($_POST['ctime']);
         $_POST['mtime'] = time();
         $this->articles_model->update($_POST);
     } else {
         $_POST['ctime'] = time();
         $_POST['mtime'] = time();
         $this->articles_model->insert($_POST);
     }
     echo json_encode(array('success' => true));
 }
 /**
  *用户ID方式登录
  */
 public function getQuestionListAction()
 {
     //基础元素,必须参与验证
     $Config['Time'] = abs(intval($this->request->Time));
     $Config['ReturnType'] = $this->request->ReturnType ? $this->request->ReturnType : 2;
     //URL验证码
     $sign = trim($this->request->sign);
     //私钥,以后要移开到数据库存储
     $p_sign = 'lm';
     $sign_to_check = Base_common::check_sign($Config, $p_sign);
     //不参与验证的元素
     //验证URL是否来自可信的发信方
     if ($sign_to_check == $sign) {
         //验证时间戳,时差超过600秒即认为非法
         if (abs($Config['Time'] - time()) <= 600) {
             $QuestionList = $this->oSecurityAnswer->getAll();
             $result = array('return' => 1, 'QuestionList' => $QuestionList);
         } else {
             $result = array('return' => 0, 'comment' => "时间有误");
         }
     } else {
         $result = array('return' => 0, 'comment' => "验证失败,请检查URL");
     }
     if ($Config['ReturnType']) {
         echo json_encode($result);
     } else {
         //			$r = $result['return']."|".iconv('UTF-8','GBK',$result['comment']);;
         //			if($result['return']==1)
         //			{
         //				$r = $r."|".$result['LoginId']."|".$result['adult'];
         //			}
         //			echo $r;
     }
 }
Example #22
0
function acm_get_next_cron_execution($timestamp)
{
    if ($timestamp - time() <= 0) {
        return __('At next page refresh', 'acm');
    }
    return __('In', 'acm') . ' ' . human_time_diff(current_time('timestamp'), $timestamp) . '<br>' . date("d.m.Y H:i:s", $timestamp);
}
Example #23
0
 function close()
 {
     global $CFG;
     require_once $CFG->libdir . '/filelib.php';
     $dir = 'temp/ods/' . time();
     make_upload_directory($dir);
     make_upload_directory($dir . '/META-INF');
     $dir = "{$CFG->dataroot}/{$dir}";
     $files = array();
     $handle = fopen("{$dir}/mimetype", 'w');
     fwrite($handle, get_ods_mimetype());
     $files[] = "{$dir}/mimetype";
     $handle = fopen("{$dir}/content.xml", 'w');
     fwrite($handle, get_ods_content($this->worksheets));
     $files[] = "{$dir}/content.xml";
     $handle = fopen("{$dir}/meta.xml", 'w');
     fwrite($handle, get_ods_meta());
     $files[] = "{$dir}/meta.xml";
     $handle = fopen("{$dir}/styles.xml", 'w');
     fwrite($handle, get_ods_styles());
     $files[] = "{$dir}/styles.xml";
     $handle = fopen("{$dir}/META-INF/manifest.xml", 'w');
     fwrite($handle, get_ods_manifest());
     $files[] = "{$dir}/META-INF";
     $filename = "{$dir}/result.ods";
     zip_files($files, $filename);
     $handle = fopen($filename, 'rb');
     $contents = fread($handle, filesize($filename));
     fclose($handle);
     remove_dir($dir);
     // cleanup the temp directory
     send_file($contents, $this->filename, 0, 0, true, true, 'application/vnd.oasis.opendocument.spreadsheet');
 }
Example #24
0
 function handle_ajax_call(&$event, $param)
 {
     global $auth;
     if ($event->data != 'blogtng__comment_preview') {
         return;
     }
     $event->preventDefault();
     $event->stopPropagation();
     @(require_once DOKU_PLUGIN . 'blogtng/helper/comments.php');
     $comment = new blogtng_comment();
     $comment->data['text'] = $_REQUEST['text'];
     $comment->data['name'] = $_REQUEST['name'];
     $comment->data['mail'] = $_REQUEST['mail'];
     $comment->data['web'] = isset($_REQUEST['web']) ? $_REQUEST['web'] : '';
     $comment->data['cid'] = 'preview';
     $comment->data['created'] = time();
     $comment->data['status'] = 'visible';
     if (!$comment->data['name'] && $_SERVER['REMOTE_USER']) {
         if ($auth) {
             $info = $auth->getUserData($_SERVER['REMOTE_USER']);
             $comment->data['name'] = $info['name'];
             $comment->data['mail'] = $info['mail'];
         }
         // FIXME ???
         $comment->data['name'] = $_SERVER['REMOTE_USER'];
     }
     // FIXME this has to be the template of the used blog
     $comment->output('default');
 }
Example #25
0
function twitter_time($time)
{
    // Get the number of seconds elapsed since this date
    $delta = time() - strtotime($time);
    if ($delta < 60) {
        return 'minder dan een minuut geleden';
    } else {
        if ($delta < 120) {
            return 'ongeveer een minuut geleden';
        } else {
            if ($delta < 60 * 60) {
                return floor($delta / 60) . ' minuten geleden';
            } else {
                if ($delta < 120 * 60) {
                    return 'ongeveer een uur geleden';
                } else {
                    if ($delta < 24 * 60 * 60) {
                        return floor($delta / 3600) . ' uren geleden';
                    } else {
                        if ($delta < 48 * 60 * 60) {
                            return 'gisteren';
                        } else {
                            return number_format(floor($delta / 86400)) . ' dagen geleden';
                        }
                    }
                }
            }
        }
    }
}
Example #26
0
 /**
  * do backup from file
  *
  * @param $fileName
  *
  * @return bool
  */
 public function doBackup($fileName)
 {
     if (copy($fileName, $fileName . '.' . time() . '.bak')) {
         return true;
     }
     return false;
 }
Example #27
0
 private function _init_env()
 {
     error_reporting(E_ERROR);
     define('MAGIC_QUOTES_GPC', function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc());
     // ' " \ NULL 等字符转义 当magic_quotes_gpc=On的时候,函数get_magic_quotes_gpc()就会返回1
     define('GZIP', function_exists('ob_gzhandler'));
     // ob 缓存压缩输出
     if (function_exists('date_default_timezone_set')) {
         @date_default_timezone_set('Etc/GMT-8');
         //东八区 北京时间
     }
     define('TIMESTAMP', time());
     if (!defined('BLOG_FUNCTION') && !@(include BLOG_ROOT . '/source/functions.php')) {
         exit('functions.php is missing');
     }
     define('IS_ROBOT', checkrobot());
     global $_B;
     $_B = array('uid' => 0, 'username' => '', 'groupid' => 0, 'timestamp' => TIMESTAMP, 'clientip' => $this->_get_client_ip(), 'mobile' => '', 'agent' => '', 'admin' => 0);
     checkmobile();
     $_B['PHP_SELF'] = bhtmlspecialchars($this->_get_script_url());
     $_B['basefilename'] = basename($_B['PHP_SELF']);
     $sitepath = substr($_B['PHP_SELF'], 0, strrpos($_B['PHP_SELF'], '/'));
     $_B['siteurl'] = bhtmlspecialchars('http://' . $_SERVER['HTTP_HOST'] . $sitepath . '/');
     getReferer();
     $url = parse_url($_B['siteurl']);
     $_B['siteroot'] = isset($url['path']) ? $url['path'] : '';
     $_B['siteport'] = empty($_SERVER['SERVER_PORT']) || $_SERVER['SERVER_PORT'] == '80' ? '' : ':' . $_SERVER['SERVER_PORT'];
     $this->b =& $_B;
 }
Example #28
0
/**
 * RSSをダウンロードし、パース結果を返す
 */
function p2GetRSS($remotefile, $atom = 0)
{
    global $_conf;
    $refresh = !empty($_GET['refresh']) || !empty($_POST['refresh']);
    $localpath = rss_get_save_path($remotefile);
    if (PEAR::isError($localpath)) {
        P2Util::pushInfoHtml('<p>' . $localpath->getMessage() . '</p>');
        return $localpath;
    }
    // 保存用ディレクトリがなければつくる
    if (!is_dir(dirname($localpath))) {
        FileCtl::mkdirFor($localpath);
    }
    // If-Modified-Sinceつきでダウンロード(ファイルが無いか、古いか、強制リロードのとき)
    if (!file_exists($localpath) || $refresh || filemtime($localpath) < time() - $_conf['expack.rss.check_interval'] * 60) {
        $dl = P2Util::fileDownload($remotefile, $localpath, true, 301);
        if ($dl->isSuccess()) {
            chmod($localpath, $_conf['expack.rss.setting_perm']);
        }
    }
    // キャッシュが更新されなかったか、ダウンロード成功ならRSSをパース
    if (file_exists($localpath) && (!isset($dl) || $dl->isSuccess())) {
        if ($atom) {
            $atom = isset($dl) && $dl->code == 200 ? 2 : 1;
        }
        $rss = p2ParseRSS($localpath, $atom);
        return $rss;
    } else {
        return $dl;
    }
}
 function ajax_calls($call, $data)
 {
     global $sitepress_settings, $sitepress;
     switch ($call) {
         case 'set_pickup_mode':
             $method = intval($data['icl_translation_pickup_method']);
             $iclsettings['translation_pickup_method'] = $method;
             $sitepress->save_settings($iclsettings);
             if (!empty($sitepress_settings)) {
                 $data['site_id'] = $sitepress_settings['site_id'];
                 $data['accesskey'] = $sitepress_settings['access_key'];
                 $data['create_account'] = 0;
                 $data['pickup_type'] = $method;
                 $icl_query = new ICanLocalizeQuery();
                 $res = $icl_query->updateAccount($data);
             }
             if ($method == ICL_PRO_TRANSLATION_PICKUP_XMLRPC) {
                 wp_clear_scheduled_hook('icl_hourly_translation_pickup');
             } else {
                 wp_schedule_event(time(), 'hourly', 'icl_hourly_translation_pickup');
             }
             echo json_encode(array('message' => 'OK'));
             break;
         case 'pickup_translations':
             if ($sitepress_settings['translation_pickup_method'] == ICL_PRO_TRANSLATION_PICKUP_POLLING) {
                 $fetched = $this->poll_for_translations(true);
                 echo json_encode(array('message' => 'OK', 'fetched' => urlencode('&nbsp;' . sprintf(__('Fetched %d translations.', 'sitepress'), $fetched))));
             } else {
                 echo json_encode(array('error' => __('Manual pick up is disabled.', 'sitepress')));
             }
             break;
     }
 }
Example #30
0
 public function addUser($add = array())
 {
     if (empty($add['staff_name']) and empty($add['username']) and empty($add['password'])) {
         return TRUE;
     }
     $this->db->where('staff_email', strtolower($add['site_email']));
     $this->db->delete('staffs');
     $this->db->set('staff_email', strtolower($add['site_email']));
     $this->db->set('staff_name', $add['staff_name']);
     $this->db->set('staff_group_id', '11');
     $this->db->set('staff_location_id', '0');
     $this->db->set('language_id', '11');
     $this->db->set('timezone', '0');
     $this->db->set('staff_status', '1');
     $this->db->set('date_added', mdate('%Y-%m-%d', time()));
     $query = $this->db->insert('staffs');
     if ($this->db->affected_rows() > 0 and $query === TRUE) {
         $staff_id = $this->db->insert_id();
         $this->db->where('username', $add['username']);
         $this->db->delete('users');
         $this->db->set('username', $add['username']);
         $this->db->set('staff_id', $staff_id);
         $this->db->set('salt', $salt = substr(md5(uniqid(rand(), TRUE)), 0, 9));
         $this->db->set('password', sha1($salt . sha1($salt . sha1($add['password']))));
         $query = $this->db->insert('users');
     }
     return $query;
 }