RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / 问题

全部问题

Martin Hope
Terra
Asked: 2024-11-01 13:06:58 +0000 UTC

如何更改反应对象中的布尔逻辑

  • 5
const [data, setData] = useState(AccordionData)

const AccordionItems = data.map((item) => {

    const OpenClose = (id) => {

        if (id === item.id) {
            setData(data => ([{
                ...data,
                open: true
            }]))

        } else {
            setData(data => ([{
                ...data,
                open: false
            }]))
        }
    }

    return <AccordionItem 
    item={item} 
    key={item.id} 
    OpenClose={OpenClose} 
    id={item.id}
    open={item.open}
    />
})

当我运行该函数时,所有元素都会重置,只有一个元素保留为无文本

javascript
  • 1 个回答
  • 37 Views
Martin Hope
user501848
Asked: 2024-11-01 05:54:11 +0000 UTC

为什么在使用curl 的函数内调用unlink() 后cookie 文件仍然存在?

  • 4
<?
  function request($url, $method = 'GET', $fields = null, $cookiesPath = null, $keepCookies = true) {
    $ch = curl_init();

    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

    if (strtoupper($method) === 'GET' && $fields) {
      $url .= '?' . http_build_query($fields);
      curl_setopt($ch, CURLOPT_URL, $url);
    } else if (strtoupper($method) === 'POST') {
      curl_setopt($ch, CURLOPT_POST, true);
      curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
      curl_setopt($ch, CURLOPT_HTTPHEADER, [
        'Content-Type: application/json',
        'Content-Length: ' . strlen(json_encode($fields))
      ]);
    }

    if (!$cookiesPath) {
      $cookiesRandomName = substr(str_shuffle(str_repeat('0123456789abcdefghijklmnopqrstuvwxyz', ceil(30 / 36))), 0, 30);
      $cookiesPath = __DIR__ . $cookiesRandomName . '.txt';
    }

    curl_setopt($ch, CURLOPT_COOKIEJAR, $cookiesPath);
    curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiesPath);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);

    $response = curl_exec($ch);

    if ($errorCode = curl_errno($ch)) {
      $errorMessage = curl_error($ch);
        
      curl_close($ch);

      if (file_exists($cookiesPath)) {
        unlink($cookiesPath);
      }

      return [ 'error' => [ 'code' => $errorCode, 'message' => $errorMessage ] ];
    }

    $HTTP_CODE = curl_getinfo($ch, CURLINFO_HTTP_CODE);

    curl_close($ch);

    if ($keepCookies) {
      return [ 'HTTP_CODE' => $HTTP_CODE, 'response' => json_decode($response, true), 'cookiesPath' => $cookiesPath ];
    } else {
      if (file_exists($cookiesPath)) {
        unlink($cookiesPath); // Место ошибки
      }

      return [ 'HTTP_CODE' => $HTTP_CODE, 'response' => json_decode($response, true) ];
    }
  }

我正在编写一个 PHP 脚本,它使用 request() 函数发出 HTTP 请求。在此函数内,我尝试使用 unlink() 删除临时 cookie 文件,但尽管该函数返回成功删除消息,但该文件仍存在于磁盘上。使用示例:

$response = request('https://example.com/login', 'post', [ 'login' => 'name', 'password' => 'hash' ]);
$response = request('https://example.com/profile', 'get', null, $response['cookiesPath'], false);

令人惊讶的是,当 unlink() 在函数外部使用时,不会发生此类事件。一般来说,有趣的行为和最大的陌生感。使用适用于 Windows 11 的 XAMPP。还在 Apache/2.4.6 上的托管上进行了测试。

php
  • 1 个回答
  • 77 Views
Martin Hope
frank.whittle
Asked: 2024-11-01 02:49:56 +0000 UTC

MapKit 和 Flutter - 未加载图块

  • 5

我将 yandex_maps_mapkit 包添加到项目中,并根据 Yandex 文档(链接)向小部件添加了一个控件。在模拟器中启动时,会显示 YandexMap 控件,甚至右下角可以看到徽标,但地图本身不会加载: 在此输入图像描述

我还在本地启动了Yandex 应用程序的测试示例- 地图在其中正确显示。我没有看到我的项目和这些测试项目之间的设置有任何差异。有一个区别 - 测试用例请求使用地理位置数据的许可,但这会影响地图的加载吗?

android/app/src/main/AndroidManifest.xml中的权限部分在我的和测试项目中是相同的:

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>

Flutter 代码也取自文档 - 在入口点初始化,并在小部件上创建控件:

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
    
  await init.initMapkit(
    apiKey: 'YOUR_API_KEY'
  );
            
  runApp(const MyApp());
}
  
class MyApp extends StatefulWidget {
  const MyApp({super.key});
  
  @override
  State<MyApp> createState() => _MyAppState();
}
  
class _MyAppState extends State<MyApp> {
  
  MapWindow? _mapWindow;
  
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: YandexMap(onMapCreated: (mapWindow) => _mapWindow = mapWindow)
      )
    );
  }
}

我使用包 yandex_maps_mapkit 版本 4.8.2-beta

IDE Android Studio 瓢虫 2024.2.1

颤振3.24.4

android-studio
  • 1 个回答
  • 27 Views
Martin Hope
Tixin
Asked: 2024-11-01 01:57:31 +0000 UTC

用户电子邮件确认

  • 5

我在注册新帐户时正在写用户电子邮件的确认信息

一切都按照以下原则进行:我们接收用户的电子邮件,创建一个 10000 - 99999 之间的随机数,使用此代码创建 cookie 并通过电子邮件将代码发送给他

$user_email = trim(filter_var($_POST['email'], FILTER_SANITIZE_EMAIL));
$code = trim(rand(10000, 99999));
setcookie("code", $code, time() + 60 * 5, "/lib/check_mail.php");
mail($user_email, 'Код подтверждения адреса Эл.Почты', $code);
header('Location: /lib/check_mail.php');

在下一个窗口中,我们将用户输入的代码与通过电子邮件发送的代码进行比较

$code = $_POST['code'];
$user_code = $_COOKIE['code'];

if ($code == $user_code){
 // Код введен верно
} else {
 // Код введен НЕ верно
}

问题:此代码的安全性和最新程度如何?如何使检查用户的电子邮件更加相关和安全?

php
  • 1 个回答
  • 45 Views
Martin Hope
Davit Kobalia
Asked: 2024-10-31 17:52:10 +0000 UTC

帮助重构

  • 5

我为我公司的 Java 后端职位空缺编写了一个测试,以下是包含任务的文档文本:

User ManagProject 标题:图书馆管理系统 该项目旨在创建一个图书馆管理系统,这是一个帮助图书馆工作人员以简单有效的方式管理图书、顾客(图书馆用户)和图书借阅的软件工具。
主要功能: ement:创建和管理图书管理员帐户。允许图书馆员登录。

Book Management:
    Add new books with details like title, author, ISBN, and genre.
    Edit and update book info.
    Remove books from the library.
    Display a list of all library books.

Patron Management:
    Add new patrons with their names, contact info, and membership status.
    Edit and update patron details.
    Remove patrons from the library.
    Show a list of all library patrons.

Borrowing System:
    Enable library patrons to borrow books.
    Track due dates for borrowed books.
    Allow librarians to mark books as returned.
    Notify patrons if they have overdue books.

Search and Filtering:
    Create a search feature for books and patrons based on criteria like title, author, and name.
    Add options to sort and filter lists of books and patrons.

Reporting:
    Generate reports that display overdue books and transaction history.
    Provide statistics about the library's book collection and patron activity.   Technical Details:

User Interface:
    Design an easy-to-use web-based interface for librarians.
    Ensure it works well on different screen sizes.

Security:
    Set up user login and access control for librarians.
    Safeguard sensitive information, like passwords and patron data.

Database:
    Use a relational database (e.g., MySQL, PostgreSQL) to store book, patron, and transaction data.
    Create a suitable database structure and relationships.

Performance:
    Optimize how the system fetches data from the database.
    Ensure the system can handle multiple users at once.

Scalability:
    Design the system to grow smoothly as the library's needs expand.   Technology Stack:

Backend: Java (with Spring Boot)
Frontend: HTML, CSS, JavaScript
Database: Relational (e.g., MySQL, PostgreSQL)
Security: Spring Security
Database Access: Hibernate
User Interface Templating: Thymeleaf or similar   Project Deliverables:

The project's source code.
Documentation (README) explaining how to set up and run the application.
Brief documentation describing the project's structure and design choices.
Source code should be provided as a git repository.   Evaluation Criteria:   The project will be assessed based on:

Functionality: Does the system meet all functional requirements?
User Interface: Is the interface user-friendly and adaptable to different devices?
Code Quality: Is the code well-organized, readable, and maintainable?
Security: Is user authentication and data protection implemented correctly?
Database Design: Does the database structure fit the project's needs?
Documentation: Is there clear documentation for setting up and using the application?
Error Handling: Does the application handle errors gracefully?
Performance: How efficiently does the application perform its tasks?

通过测试后,他们说很明显“是我自己写的”(确实如此)并告诉我改正然后再试,但不幸的是他们没有告诉我任务到底出了什么问题。我自己找不到具体需要纠正的地方,如果您能告诉我,我会很高兴这是Github上该项目的链接。

java
  • 1 个回答
  • 43 Views
上一页
下一页

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    我看不懂措辞

    • 1 个回答
  • Marko Smith

    请求的模块“del”不提供名为“default”的导出

    • 3 个回答
  • Marko Smith

    "!+tab" 在 HTML 的 vs 代码中不起作用

    • 5 个回答
  • Marko Smith

    我正在尝试解决“猜词”的问题。Python

    • 2 个回答
  • Marko Smith

    可以使用哪些命令将当前指针移动到指定的提交而不更改工作目录中的文件?

    • 1 个回答
  • Marko Smith

    Python解析野莓

    • 1 个回答
  • Marko Smith

    问题:“警告:检查最新版本的 pip 时出错。”

    • 2 个回答
  • Marko Smith

    帮助编写一个用值填充变量的循环。解决这个问题

    • 2 个回答
  • Marko Smith

    尽管依赖数组为空,但在渲染上调用了 2 次 useEffect

    • 2 个回答
  • Marko Smith

    数据不通过 Telegram.WebApp.sendData 发送

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5