Пример #1
0
bool IniSetting::Set(CStrRef name, CStrRef value) {
    CallbackMap::iterator iter = s_callbacks->find(name.data());
    if (iter != s_callbacks->end()) {
        return (*iter->second.callback)(value, iter->second.p);
    }
    if (name == "memory_limit") {
        if (!value.empty()) {
            int64_t newInt = value.toInt64();
            char lastChar = value.charAt(value.size() - 1);
            if (lastChar == 'K' || lastChar == 'k') {
                newInt <<= 10;
            } else if (lastChar == 'M' || lastChar == 'm') {
                newInt <<= 20;
            } else if (lastChar == 'G' || lastChar == 'g') {
                newInt <<= 30;
            }
            g_context->setRequestMemoryMaxBytes(newInt);
            return true;
        }
    } else if (name == "max_execution_time" || name == "maximum_execution_time") {
        int64_t limit = value.toInt64();
        TimeoutThread::DeferTimeout(limit);
        // Just for ini_get
        g_context->setRequestTimeLimit(limit);
        return true;
    } else if (name == "arg_separator.output") {
        g_context->setArgSeparatorOutput(value);
        return true;
    } else if (name == "log_errors") {
        bool log;
        ini_on_update_bool(value, &log);
        g_context->setLogErrors(log);
        return true;
    } else if (name == "error_log") {
        g_context->setErrorLog(value);
        return true;
    } else if (name == "notice_frequency") {
        RuntimeOption::NoticeFrequency = value.toInt64();
        return true;
    } else if (name == "warning_frequency") {
        RuntimeOption::WarningFrequency = value.toInt64();
        return true;
    } else if (name == "include_path") {
        g_context->setIncludePath(value);
        return true;
    }

    return false;
}
Пример #2
0
bool IniSetting::Set(CStrRef name, CStrRef value) {
  CallbackMap::iterator iter = s_callbacks->find(name.data());
  if (iter != s_callbacks->end()) {
    return (*iter->second.callback)(value, iter->second.p);
  }
  if (name == s_memory_limit) {
    if (!value.empty()) {
      int64_t newInt = value.toInt64();
      char lastChar = value.charAt(value.size() - 1);
      if (lastChar == 'K' || lastChar == 'k') {
        newInt <<= 10;
      } else if (lastChar == 'M' || lastChar == 'm') {
        newInt <<= 20;
      } else if (lastChar == 'G' || lastChar == 'g') {
        newInt <<= 30;
      }
      g_context->setRequestMemoryMaxBytes(newInt);
      return true;
    }
  } else if (name == s_max_execution_time || name == s_maximum_execution_time){
    int64_t limit = value.toInt64();
    ThreadInfo::s_threadInfo.getNoCheck()->
      m_reqInjectionData.setTimeout(limit);
    return true;
  } else if (name == s_arg_separator_output) {
    g_context->setArgSeparatorOutput(value);
    return true;
  } else if (name == s_log_errors) {
    bool log;
    ini_on_update_bool(value, &log);
    g_context->setLogErrors(log);
    return true;
  } else if (name == s_error_log) {
    g_context->setErrorLog(value);
    return true;
  } else if (name == s_notice_frequency) {
    RuntimeOption::NoticeFrequency = value.toInt64();
    return true;
  } else if (name == s_warning_frequency) {
    RuntimeOption::WarningFrequency = value.toInt64();
    return true;
  } else if (name == s_include_path) {
    g_context->setIncludePath(value);
    return true;
  }

  return false;
}
Пример #3
0
bool ini_on_update_non_negative(CStrRef value, void *p) {
    int64_t v = value.toInt64();
    if (v < 0) {
        return false;
    }
    if (p) {
        *((int64_t*)p) = v;
    }
    return true;
}
Пример #4
0
bool ini_on_update_long(CStrRef value, void *p) {
    if (p) {
        *((int64_t*)p) = value.toInt64();
    }
    return true;
}