text:
/**************************************************************
   WiFiManager is a library for the ESP8266/Arduino platform
   (https://github.com/esp8266/Arduino) to enable easy
   configuration and reconfiguration of WiFi credentials using a Captive Portal
   inspired by:
   http://www.esp8266.com/viewtopic.php?f=29&t=2520
   https://github.com/chriscook8/esp-arduino-apboot
   https://github.com/esp8266/Arduino/blob/master/libraries/DNSServer/examples/CaptivePortalAdvanced/
   Forked from Tzapu https://github.com/tzapu/WiFiManager
   Built by Ken Taylor https://github.com/kentaylor
   Licensed under MIT license
 **************************************************************/

#include "WiFiManager.h"

WiFiManagerParameter::WiFiManagerParameter(const char *custom) {
  _id = NULL;
  _placeholder = NULL;
  _length = 0;
  _value = NULL;
  _labelPlacement = WFM_LABEL_BEFORE;

  _customHTML = custom;
}

WiFiManagerParameter::WiFiManagerParameter(const char *id, const char *placeholder, const char *defaultValue, int length) {
  init(id, placeholder, defaultValue, length, "", WFM_LABEL_BEFORE);
}

WiFiManagerParameter::WiFiManagerParameter(const char *id, const char *placeholder, const char *defaultValue, int length, const char *custom) {
  init(id, placeholder, defaultValue, length, custom, WFM_LABEL_BEFORE);
}

WiFiManagerParameter::WiFiManagerParameter(const char *id, const char *placeholder, const char *defaultValue, int length, const char *custom, int labelPlacement) {
  init(id, placeholder, defaultValue, length, custom, labelPlacement);
}

void WiFiManagerParameter::init(const char *id, const char *placeholder, const char *defaultValue, int length, const char *custom, int labelPlacement) {
  _id = id;
  _placeholder = placeholder;
  _length = length;
  _labelPlacement = labelPlacement;
  _value = new char[length + 1];
  for (int i = 0; i < length; i++) {
    _value[i] = 0;
  }
  if (defaultValue != NULL) {
    strncpy(_value, defaultValue, length);
  }

  _customHTML = custom;
}

const char* WiFiManagerParameter::getValue() {
  return _value;
}
const char* WiFiManagerParameter::getID() {
  return _id;
}
const char* WiFiManagerParameter::getPlaceholder() {
  return _placeholder;
}
int WiFiManagerParameter::getValueLength() {
  return _length;
}
int WiFiManagerParameter::getLabelPlacement() {
  return _labelPlacement;
}
const char* WiFiManagerParameter::getCustomHTML() {
  return _customHTML;
}

WiFiManager::WiFiManager() {
	//Do a network scan before setting up an access point so as not to close WiFiNetwork while scanning.
	numberOfNetworks = scanWifiNetworks(networkIndicesptr);
}
WiFiManager::~WiFiManager() {
    free(networkIndices); //indices array no longer required so free memory
}

void WiFiManager::addParameter(WiFiManagerParameter *p) {
  _params[_paramsCount] = p;
  _paramsCount++;
  DEBUG_WM("Adding parameter");
  DEBUG_WM(p->getID());
}

void WiFiManager::setupConfigPortal() {
  stopConfigPortal = false; //Signal not to close config portal
  /*This library assumes autoconnect is set to 1. It usually is
  but just in case check the setting and turn on autoconnect if it is off.
  Some useful discussion at https://github.com/esp8266/Arduino/issues/1615*/
  if (WiFi.getAutoConnect()==0)WiFi.setAutoConnect(1);
  dnsServer.reset(new DNSServer());
  server.reset(new ESP8266WebServer(80));

  DEBUG_WM(F(""));
  _configPortalStart = millis();

  DEBUG_WM(F("Configuring access point... "));
  DEBUG_WM(_apName);
  if (_apPassword != NULL) {
    if (strlen(_apPassword) < 8 || strlen(_apPassword) > 63) {
      // fail passphrase to short or long!
      DEBUG_WM(F("Invalid AccessPoint password. Ignoring"));
      _apPassword = NULL;
    }
    DEBUG_WM(_apPassword);
  }

  //optional soft ip config
  if (_ap_static_ip) {
    DEBUG_WM(F("Custom AP IP/GW/Subnet"));
    WiFi.softAPConfig(_ap_static_ip, _ap_static_gw, _ap_static_sn);
  }

  if (_apPassword != NULL) {
    WiFi.softAP(_apName, _apPassword);//password option
  } else {
    WiFi.softAP(_apName);
  }

  delay(500); // Without delay I've seen the IP address blank
  DEBUG_WM(F("AP IP address: "));
  DEBUG_WM(WiFi.softAPIP());

  /* Setup the DNS server redirecting all the domains to the apIP */
  dnsServer->setErrorReplyCode(DNSReplyCode::NoError);
  dnsServer->start(DNS_PORT, "*", WiFi.softAPIP());

  /* Setup web pages: root, wifi config pages, SO captive portal detectors and not found. */
  server->on("/", std::bind(&WiFiManager::handleRoot, this));
  server->on("/wifi", std::bind(&WiFiManager::handleWifi, this));
  server->on("/wifisave", std::bind(&WiFiManager::handleWifiSave, this));
  server->on("/close", std::bind(&WiFiManager::handleServerClose, this));
  server->on("/i", std::bind(&WiFiManager::handleInfo, this));
  server->on("/r", std::bind(&WiFiManager::handleReset, this));
  server->on("/state", std::bind(&WiFiManager::handleState, this));
  server->on("/scan", std::bind(&WiFiManager::handleScan, this));
  server->onNotFound (std::bind(&WiFiManager::handleNotFound, this));
  server->begin(); // Web server start
  DEBUG_WM(F("HTTP server started"));

}

boolean WiFiManager::autoConnect() {
  String ssid = "ESP" + String(ESP.getChipId());
  return autoConnect(ssid.c_str(), NULL);
}
/* This is not very useful as there has been an assumption that device has to be
told to connect but Wifi already does it's best to connect in background. Calling this
method will block until WiFi connects. Sketch can avoid
blocking call then use (WiFi.status()==WL_CONNECTED) test to see if connected yet.
See some discussion at https://github.com/tzapu/WiFiManager/issues/68
*/
boolean WiFiManager::autoConnect(char const *apName, char const *apPassword) {
  DEBUG_WM(F(""));
  DEBUG_WM(F("AutoConnect"));

  // read eeprom for ssid and pass
  //String ssid = getSSID();
  //String pass = getPassword();

  // device will attempt to connect by itself; wait 10 secs
  // to see if it succeeds and should it fail, fall back to AP
  WiFi.mode(WIFI_STA);
  unsigned long startedAt = millis();
    while(millis() - startedAt < 10000)
    {
        delay(100);
        if (WiFi.status()==WL_CONNECTED) {
			float waited = (millis()- startedAt);
			DEBUG_WM(F("After waiting "));
			DEBUG_WM(waited/1000);
			DEBUG_WM(F(" secs local ip: "));
			DEBUG_WM(WiFi.localIP());
            return true;
		}
    }

  return startConfigPortal(apName, apPassword);
}

boolean  WiFiManager::startConfigPortal() {
  String ssid = "ESP" + String(ESP.getChipId());
  return startConfigPortal(ssid.c_str(),NULL);
}

boolean  WiFiManager::startConfigPortal(char const *apName, char const *apPassword) {
  //setup AP
  int connRes = WiFi.waitForConnectResult();
  if (connRes == WL_CONNECTED){
	  WiFi.mode(WIFI_AP_STA); //Dual mode works fine if it is connected to WiFi
	  DEBUG_WM("SET AP STA");
  	}
  	else {
    WiFi.mode(WIFI_AP); // Dual mode becomes flaky if not connected to a WiFi network.
    // When ESP8266 station is trying to find a target AP, it will scan on every channel,
    // that means ESP8266 station is changing its channel to scan. This makes the channel of ESP8266 softAP keep changing too..
    // So the connection may break. From http://bbs.espressif.com/viewtopic.php?t=671#p2531
    DEBUG_WM("SET AP");
	}
  _apName = apName;
  _apPassword = apPassword;

  //notify we entered AP mode
  if ( _apcallback != NULL) {
    _apcallback(this);
  }

  connect = false;
  setupConfigPortal();
  bool TimedOut=true;
  while (_configPortalTimeout == 0 || millis() < _configPortalStart + _configPortalTimeout) {
    //DNS
    dnsServer->processNextRequest();
    //HTTP
    server->handleClient();

    if (connect) {
      connect = false;
      TimedOut=false;
      delay(2000);
      DEBUG_WM(F("Connecting to new AP"));

      // using user-provided  _ssid, _pass in place of system-stored ssid and pass
      if (connectWifi(_ssid, _pass) != WL_CONNECTED) {
        DEBUG_WM(F("Failed to connect."));
        WiFi.mode(WIFI_AP); // Dual mode becomes flaky if not connected to a WiFi network.
		    // I think this might be because too much of the processor is being utilised
    //trying to connect to the network.
      } else {
        //notify that configuration has changed and any optional parameters should be saved
        if ( _savecallback != NULL) {
          //todo: check if any custom parameters actually exist, and check if they really changed maybe
          _savecallback();
        }
        //break;
      }

      if (_shouldBreakAfterConfig) {
        //flag set to exit after config after trying to connect
        //notify that configuration has changed and any optional parameters should be saved
        if ( _savecallback != NULL) {
          //todo: check if any custom parameters actually exist, and check if they really changed maybe
          _savecallback();
        }
        break;
      }
    }
    if (stopConfigPortal) {
	  stopConfigPortal = false;
	  break;
    }
    yield();
  }
  WiFi.mode(WIFI_STA);
  if (TimedOut & WiFi.status() != WL_CONNECTED) {
	WiFi.begin();
    int connRes = waitForConnectResult();
    DEBUG_WM ("Timed out connection result: ");
    DEBUG_WM ( getStatus(connRes));
    }
  server.reset();
  dnsServer.reset();
  return  WiFi.status() == WL_CONNECTED;
}

int WiFiManager::connectWifi(String ssid, String pass) {
  DEBUG_WM(F("Connecting wifi with new parameters..."));
  if (ssid != "") {
	resetSettings(); /*Disconnect from the network and wipe out old values
	if no values were entered into form. If you don't do this
    esp8266 will sometimes lock up when SSID or password is different to
	the already stored values and device is in the process of trying to connect
	to the network. Mostly it doesn't but occasionally it does.
	*/
  // check if we've got static_ip settings, if we do, use those.
  if (_sta_static_ip) {
	    DEBUG_WM(F("Custom STA IP/GW/Subnet"));
	    WiFi.config(_sta_static_ip, _sta_static_gw, _sta_static_sn);
	    DEBUG_WM(WiFi.localIP());
  }
	WiFi.mode(WIFI_AP_STA); //It will start in station mode if it was previously in AP mode.
    WiFi.begin(ssid.c_str(), pass.c_str());// Start Wifi with new values.
  } else if(!WiFi.SSID()) {
      DEBUG_WM(F("No saved credentials"));
  }

  int connRes = waitForConnectResult();
  DEBUG_WM ("Connection result: ");
  DEBUG_WM ( getStatus(connRes));
  //not connected, WPS enabled, no pass - first attempt
  if (_tryWPS && connRes != WL_CONNECTED && pass == "") {
    startWPS();
    //should be connected at the end of WPS
    connRes = waitForConnectResult();
  }
  return connRes;
}

uint8_t WiFiManager::waitForConnectResult() {
  if (_connectTimeout == 0) {
	unsigned long startedAt = millis();
	DEBUG_WM (F("After waiting..."));
	int connRes = WiFi.waitForConnectResult();
	float waited = (millis()- startedAt);
	DEBUG_WM (waited/1000);
	DEBUG_WM (F("seconds"));
    return connRes;
  } else {
    DEBUG_WM (F("Waiting for connection result with time out"));
    unsigned long start = millis();
    boolean keepConnecting = true;
    uint8_t status;
    while (keepConnecting) {
      status = WiFi.status();
      if (millis() > start + _connectTimeout) {
        keepConnecting = false;
        DEBUG_WM (F("Connection timed out"));
      }
      if (status == WL_CONNECTED || status == WL_CONNECT_FAILED) {
        keepConnecting = false;
      }
      delay(100);
    }
    return status;
  }
}

void WiFiManager::startWPS() {
  DEBUG_WM(F("START WPS"));
  WiFi.beginWPSConfig();
  DEBUG_WM(F("END WPS"));
}
//Convenient for debugging but wasteful of program space.
//Remove if short of space
char* WiFiManager::getStatus(int status)
{
   switch (status)
   {
      case WL_IDLE_STATUS: return "WL_IDLE_STATUS";
      case WL_NO_SSID_AVAIL: return "WL_NO_SSID_AVAIL";
      case WL_CONNECTED: return "WL_CONNECTED";
	  case WL_CONNECT_FAILED: return "WL_CONNECT_FAILED";
      case WL_DISCONNECTED: return "WL_DISCONNECTED";
      default: return "UNKNOWN";
   }
}

String WiFiManager::getConfigPortalSSID() {
  return _apName;
}

void WiFiManager::resetSettings() {
  DEBUG_WM(F("previous settings invalidated"));
  WiFi.disconnect(true);
  delay(200);
  return;
}
void WiFiManager::setTimeout(unsigned long seconds) {
  setConfigPortalTimeout(seconds);
}

void WiFiManager::setConfigPortalTimeout(unsigned long seconds) {
  _configPortalTimeout = seconds * 1000;
}

void WiFiManager::setConnectTimeout(unsigned long seconds) {
  _connectTimeout = seconds * 1000;
}

void WiFiManager::setDebugOutput(boolean debug) {
  _debug = debug;
}

void WiFiManager::setAPStaticIPConfig(IPAddress ip, IPAddress gw, IPAddress sn) {
  _ap_static_ip = ip;
  _ap_static_gw = gw;
  _ap_static_sn = sn;
}

void WiFiManager::setSTAStaticIPConfig(IPAddress ip, IPAddress gw, IPAddress sn) {
  _sta_static_ip = ip;
  _sta_static_gw = gw;
  _sta_static_sn = sn;
}

void WiFiManager::setMinimumSignalQuality(int quality) {
  _minimumQuality = quality;
}

void WiFiManager::setBreakAfterConfig(boolean shouldBreak) {
  _shouldBreakAfterConfig = shouldBreak;
}

void WiFiManager::reportStatus(String &page){
  if (WiFi.SSID() != ""){
	  page += F("Configured to connect to access point ");
	  page += WiFi.SSID();
	  if (WiFi.status()==WL_CONNECTED){
		  page += F(" and currently connected on IP ");
		  page += WiFi.localIP().toString();
		  page += F("");
	   }
	  else {
		  page += F(" but not currently connected to network.");
	  }
    }
    else {
		page += F("No network currently configured.");
	}
}

/** Handle root or redirect to captive portal */
void WiFiManager::handleRoot() {
  DEBUG_WM(F("Handle root"));
  if (captivePortal()) { // If caprive portal redirect instead of displaying the error page.
      return;
  }
  server->sendHeader("Cache-Control", "no-cache, no-store, must-revalidate");
  server->sendHeader("Pragma", "no-cache");
  server->sendHeader("Expires", "-1");
  String page = FPSTR(HTTP_HEAD);
  page.replace("{v}", "Options");
  page += FPSTR(HTTP_SCRIPT);
  page += FPSTR(HTTP_STYLE);
  page += _customHeadElement;
  page += FPSTR(HTTP_HEAD_END);
  page += "
";
  page += _apName;
  if (WiFi.SSID() != ""){
	  if (WiFi.status()==WL_CONNECTED){
		  page += " on ";
		  page += WiFi.SSID();
	  }
	  else{
		  page += " <s>on ";
		  page += WiFi.SSID();
		  page += "</s>";
	  }

  }
  page += "
";
  page += FPSTR(HTTP_PORTAL_OPTIONS);
  page += F("
");
  reportStatus(page);
  page += F("
");
  page += FPSTR(HTTP_END);

  server->send(200, "text/html", page);

}

/** Wifi config page handler */
void WiFiManager::handleWifi() {
  server->sendHeader("Cache-Control", "no-cache, no-store, must-revalidate");
  server->sendHeader("Pragma", "no-cache");
  server->sendHeader("Expires", "-1");
  String page = FPSTR(HTTP_HEAD);
  page.replace("{v}", "Config ESP");
  page += FPSTR(HTTP_SCRIPT);
  page += FPSTR(HTTP_STYLE);
  page += _customHeadElement;
  page += FPSTR(HTTP_HEAD_END);
  page += F("
Configuration
");
  //Print list of WiFi networks that were found in earlier scan
    if (numberOfNetworks == 0) {
      page += F("WiFi scan found no networks. Restart configuration portal to scan again.");
    } else {
      //display networks in page
      for (int i = 0; i < numberOfNetworks; i++) {
        if(networkIndices[i] == -1) continue; // skip dups and those that are below the required quality

        DEBUG_WM(WiFi.SSID(networkIndices[i]));
        DEBUG_WM(WiFi.RSSI(networkIndices[i]));
        int quality = getRSSIasQuality(WiFi.RSSI(networkIndices[i]));

        String item = FPSTR(HTTP_ITEM);
        String rssiQ;
        rssiQ += quality;
        item.replace("{v}", WiFi.SSID(networkIndices[i]));
        item.replace("{r}", rssiQ);
        if (WiFi.encryptionType(networkIndices[i]) != ENC_TYPE_NONE) {
          item.replace("{i}", "l");
        } else {
            item.replace("{i}", "");
        }
        //DEBUG_WM(item);
        page += item;
        delay(0);
        }
    page += "
";
    }

  page += FPSTR(HTTP_FORM_START);
  char parLength[2];
  // add the extra parameters to the form
  for (int i = 0; i < _paramsCount; i++) {
    if (_params[i] == NULL) {
      break;
    }

	String pitem;
	switch (_params[i]->getLabelPlacement()) {
    case WFM_LABEL_BEFORE:
	  pitem = FPSTR(HTTP_FORM_LABEL);
	  pitem += FPSTR(HTTP_FORM_PARAM);
      break;
    case WFM_LABEL_AFTER:
	  pitem = FPSTR(HTTP_FORM_PARAM);
	  pitem += FPSTR(HTTP_FORM_LABEL);
      break;
    default:
	  // WFM_NO_LABEL
      pitem = FPSTR(HTTP_FORM_PARAM);
    break;
  }

    if (_params[i]->getID() != NULL) {
      pitem.replace("{i}", _params[i]->getID());
      pitem.replace("{n}", _params[i]->getID());
      pitem.replace("{p}", _params[i]->getPlaceholder());
      snprintf(parLength, 2, "%d", _params[i]->getValueLength());
      pitem.replace("{l}", parLength);
      pitem.replace("{v}", _params[i]->getValue());
      pitem.replace("{c}", _params[i]->getCustomHTML());
    } else {
      pitem = _params[i]->getCustomHTML();
    }

    page += pitem;
  }
  if (_params[0] != NULL) {
    page += "
";
  }

  if (_sta_static_ip) {

    String item = FPSTR(HTTP_FORM_PARAM);
    item.replace("{i}", "ip");
    item.replace("{n}", "ip");
    item.replace("{p}", "Static IP");
    item.replace("{l}", "15");
    item.replace("{v}", _sta_static_ip.toString());

    page += item;

    item = FPSTR(HTTP_FORM_PARAM);
    item.replace("{i}", "gw");
    item.replace("{n}", "gw");
    item.replace("{p}", "Static Gateway");
    item.replace("{l}", "15");
    item.replace("{v}", _sta_static_gw.toString());

    page += item;

    item = FPSTR(HTTP_FORM_PARAM);
    item.replace("{i}", "sn");
    item.replace("{n}", "sn");
    item.replace("{p}", "Subnet");
    item.replace("{l}", "15");
    item.replace("{v}", _sta_static_sn.toString());

    page += item;

    page += "
";
  }

  page += FPSTR(HTTP_FORM_END);

  page += FPSTR(HTTP_END);

  server->send(200, "text/html", page);

  DEBUG_WM(F("Sent config page"));
}

/** Handle the WLAN save form and redirect to WLAN config page again */
void WiFiManager::handleWifiSave() {
  DEBUG_WM(F("WiFi save"));

  //SAVE/connect here
  _ssid = server->arg("s").c_str();
  _pass = server->arg("p").c_str();

  //parameters
  for (int i = 0; i < _paramsCount; i++) {
    if (_params[i] == NULL) {
      break;
    }
    //read parameter
    String value = server->arg(_params[i]->getID()).c_str();
    //store it in array
    value.toCharArray(_params[i]->_value, _params[i]->_length);
    DEBUG_WM(F("Parameter"));
    DEBUG_WM(_params[i]->getID());
    DEBUG_WM(value);
  }

  if (server->arg("ip") != "") {
    DEBUG_WM(F("static ip"));
    DEBUG_WM(server->arg("ip"));
    //_sta_static_ip.fromString(server->arg("ip"));
    String ip = server->arg("ip");
    optionalIPFromString(&_sta_static_ip, ip.c_str());
  }
  if (server->arg("gw") != "") {
    DEBUG_WM(F("static gateway"));
    DEBUG_WM(server->arg("gw"));
    String gw = server->arg("gw");
    optionalIPFromString(&_sta_static_gw, gw.c_str());
  }
  if (server->arg("sn") != "") {
    DEBUG_WM(F("static netmask"));
    DEBUG_WM(server->arg("sn"));
    String sn = server->arg("sn");
    optionalIPFromString(&_sta_static_sn, sn.c_str());
  }

  String page = FPSTR(HTTP_HEAD);
  page.replace("{v}", "Credentials Saved");
  page += FPSTR(HTTP_SCRIPT);
  page += FPSTR(HTTP_STYLE);
  page += _customHeadElement;
  page += FPSTR(HTTP_HEAD_END);
  page += FPSTR(HTTP_SAVED);
  page.replace("{v}", _apName);
  page.replace("{x}", _ssid);
  page += FPSTR(HTTP_END);

  server->send(200, "text/html", page);

  DEBUG_WM(F("Sent wifi save page"));

  connect = true; //signal ready to connect/reset
}
/** Handle shut down the server page */
void WiFiManager::handleServerClose() {
    DEBUG_WM(F("Server Close"));
    server->sendHeader("Cache-Control", "no-cache, no-store, must-revalidate");
    server->sendHeader("Pragma", "no-cache");
    server->sendHeader("Expires", "-1");
    String page = FPSTR(HTTP_HEAD);
    page.replace("{v}", "Close Server");
    page += FPSTR(HTTP_SCRIPT);
    page += FPSTR(HTTP_STYLE);
    page += _customHeadElement;
    page += FPSTR(HTTP_HEAD_END);
    page += F("
");
    page += F("My network is ");
    page += WiFi.SSID();
    page += F("
");
    page += F("My IP address is ");
    page += WiFi.localIP().toString();
    page += F("

");
    page += F("Configuration server closed...

");
    //page += F("Push button on device to restart configuration server!");
    page += FPSTR(HTTP_END);
    server->send(200, "text/html", page);
    stopConfigPortal = true; //signal ready to shutdown config portal
  DEBUG_WM(F("Sent server close page"));

}
/** Handle the info page */
void WiFiManager::handleInfo() {
  DEBUG_WM(F("Info"));
  server->sendHeader("Cache-Control", "no-cache, no-store, must-revalidate");
  server->sendHeader("Pragma", "no-cache");
  server->sendHeader("Expires", "-1");
  String page = FPSTR(HTTP_HEAD);
  page.replace("{v}", "Info");
  page += FPSTR(HTTP_SCRIPT);
  page += FPSTR(HTTP_STYLE);
  page += _customHeadElement;
  page += FPSTR(HTTP_HEAD_END);
  page += F("
WiFi Information
");
  page += F("Android app from https://play.google.com/store/apps/details?id=au.com.umranium.espconnect provides easier ESP WiFi configuration.
");
  reportStatus(page);
  page += F("
Device Data
");
  page += F("
");
  page += F("

Name	Value

Chip ID	");
  page += ESP.getChipId();
  page += F("
");
  page += F("
Flash Chip ID	");
  page += ESP.getFlashChipId();
  page += F("
");
  page += F("
IDE Flash Size	");
  page += ESP.getFlashChipSize();
  page += F(" bytes
");
  page += F("
Real Flash Size	");
  page += ESP.getFlashChipRealSize();
  page += F(" bytes
");
  page += F("
Access Point IP	");
  page += WiFi.softAPIP().toString();
  page += F("
");
  page += F("
Access Point MAC	");
  page += WiFi.softAPmacAddress();
  page += F("
");

  page += F("
SSID	");
  page += WiFi.SSID();
  page += F("
");

  page += F("
Station IP	");
  page += WiFi.localIP().toString();
  page += F("
");

  page += F("
Station MAC	");
  page += WiFi.macAddress();
  page += F("
");
  page += F("

");

  page += F("
Available Pages
");
  page += F("
");
  page += F("

Page	Function

");
  page += F("
/	");
  page += F("Menu page.
");
  page += F("
/wifi	");
  page += F("Show WiFi scan results and enter WiFi configuration.
");
  page += F("
/wifisave\	");
  page += F("Save WiFi configuration information and configure device. Needs variables supplied.
");
  page += F("
/close	");
  page += F("Close the configuration server and configuration WiFi network.
");
  page += F("
/i	");
  page += F("This page.
");
  page += F("
/r	");
  page += F("Delete WiFi configuration and reboot. ESP device will not reconnect to a network until new WiFi configuration data is entered.
");
  page += F("
/state	");
  page += F("Current device state in JSON format. Interface for programmatic WiFi configuration.
");
  page += F("
/scan	");
  page += F("Run a WiFi scan and return results in JSON format. Interface for programmatic WiFi configuration.
");
  page += F("
");
  page += F("
More information about WiFiManager at https://github.com/kentaylor/WiFiManager.");
  page += FPSTR(HTTP_END);

  server->send(200, "text/html", page);

  DEBUG_WM(F("Sent info page"));
}
/** Handle the state page */
void WiFiManager::handleState() {
  DEBUG_WM(F("State - json"));
  server->sendHeader("Cache-Control", "no-cache, no-store, must-revalidate");
  server->sendHeader("Pragma", "no-cache");
  server->sendHeader("Expires", "-1");
  String page = F("{\"Soft_AP_IP\":\"");
  page += WiFi.softAPIP().toString();
  page += F("\",\"Soft_AP_MAC\":\"");
  page += WiFi.softAPmacAddress();
  page += F("\",\"Station_IP\":\"");
  page += WiFi.localIP().toString();
  page += F("\",\"Station_MAC\":\"");
  page += WiFi.macAddress();
  page += F("\",");
  if (WiFi.psk()!=""){
  	  page += F("\"Password\":true,");
    }
  else {
  	  page += F("\"Password\":false,");
    }
  page += F("\"SSID\":\"");
  page += WiFi.SSID();
  page += F("\"}");
  server->send(200, "application/json", page);
  DEBUG_WM(F("Sent state page in json format"));
}

/** Handle the scan page */
void WiFiManager::handleScan() {
  DEBUG_WM(F("State - json"));
  server->sendHeader("Cache-Control", "no-cache, no-store, must-revalidate");
  server->sendHeader("Pragma", "no-cache");
  server->sendHeader("Expires", "-1");

  int n;
  int *indices;
  int **indicesptr = &indices;
  //Space for indices array allocated on heap in scanWifiNetworks
  //and should be freed when indices no longer required.
  n = scanWifiNetworks(indicesptr);
  DEBUG_WM(F("In handleScan, scanWifiNetworks done"));
  String page = F("{\"Access_Points\":[");
  //display networks in page
  for (int i = 0; i < n; i++) {
          if(indices[i] == -1) continue; // skip duplicates and those that are below the required quality
          if(i != 0) page += F(", ");
          DEBUG_WM(WiFi.SSID(indices[i]));
          DEBUG_WM(WiFi.RSSI(indices[i]));
          int quality = getRSSIasQuality(WiFi.RSSI(indices[i]));
          String item = FPSTR(JSON_ITEM);
          String rssiQ;
          rssiQ += quality;
          item.replace("{v}", WiFi.SSID(indices[i]));
          item.replace("{r}", rssiQ);
          if (WiFi.encryptionType(indices[i]) != ENC_TYPE_NONE) {
            item.replace("{i}", "true");
          } else {
            item.replace("{i}", "false");
          }
          //DEBUG_WM(item);
          page += item;
          delay(0);
  }
  free(indices); //indices array no longer required so free memory
  page += F("]}");
  server->send(200, "application/json", page);
  DEBUG_WM(F("Sent WiFi scan data ordered by signal strength in json format"));
}

/** Handle the reset page */
void WiFiManager::handleReset() {
  DEBUG_WM(F("Reset"));
  server->sendHeader("Cache-Control", "no-cache, no-store, must-revalidate");
  server->sendHeader("Pragma", "no-cache");
  server->sendHeader("Expires", "-1");
  String page = FPSTR(HTTP_HEAD);
  page.replace("{v}", "WiFi Information");
  page += FPSTR(HTTP_SCRIPT);
  page += FPSTR(HTTP_STYLE);
  page += _customHeadElement;
  page += FPSTR(HTTP_HEAD_END);
  page += F("Module will reset in a few seconds.");
  page += FPSTR(HTTP_END);
  server->send(200, "text/html", page);

  DEBUG_WM(F("Sent reset page"));
  delay(5000);
  WiFi.disconnect(true); // Wipe out WiFi credentials.
  ESP.reset();
  delay(2000);
}

void WiFiManager::handleNotFound() {
  if (captivePortal()) { // If caprive portal redirect instead of displaying the error page.
      return;
  }
  String message = "File Not Found\n\n";
  message += "URI: ";
  message += server->uri();
  message += "\nMethod: ";
  message += ( server->method() == HTTP_GET ) ? "GET" : "POST";
  message += "\nArguments: ";
  message += server->args();
  message += "\n";

  for ( uint8_t i = 0; i < server->args(); i++ ) {
    message += " " + server->argName ( i ) + ": " + server->arg ( i ) + "\n";
  }
  server->sendHeader("Cache-Control", "no-cache, no-store, must-revalidate");
  server->sendHeader("Pragma", "no-cache");
  server->sendHeader("Expires", "-1");
  server->send ( 404, "text/plain", message );
}

/** Redirect to captive portal if we got a request for another domain. Return true in
that case so the page handler do not try to handle the request again. */
boolean WiFiManager::captivePortal() {
  if (!isIp(server->hostHeader()) && server->hostHeader() != (String(myHostname))) {
    DEBUG_WM(F("Request redirected to captive portal"));
    server->sendHeader("Location", ("http://") +String(myHostname), true);
    server->setContentLength(0);
    server->send ( 302, "text/plain", ""); // Empty content inhibits Content-length header so we have to close the socket ourselves.
//    server->client().stop(); // Stop is needed because we sent no content length
    return true;
  }
  return false;
}

//start up config portal callback
void WiFiManager::setAPCallback( void (*func)(WiFiManager* myWiFiManager) ) {
  _apcallback = func;
}

//start up save config callback
void WiFiManager::setSaveConfigCallback( void (*func)(void) ) {
  _savecallback = func;
}

//sets a custom element to add to head, like a new style tag
void WiFiManager::setCustomHeadElement(const char* element) {
  _customHeadElement = element;
}

//if this is true, remove duplicated Access Points - defaut true
void WiFiManager::setRemoveDuplicateAPs(boolean removeDuplicates) {
  _removeDuplicateAPs = removeDuplicates;
}

//Scan for WiFiNetworks in range and sort by signal strength
//space for indices array allocated on the heap and should be freed when no longer required
int WiFiManager::scanWifiNetworks(int **indicesptr) {
    int n = WiFi.scanNetworks();
    DEBUG_WM(F("Scan done"));
    if (n == 0) {
      DEBUG_WM(F("No networks found"));
      return(0);
    } else {
	  // Allocate space off the heap for indices array.
	  // This space should be freed when no longer required.
 	  int* indices = (int *)malloc(n*sizeof(int));
					if (indices == NULL){
						DEBUG_WM(F("ERROR: Out of memory"));
						return(0);
						}
	  *indicesptr = indices;
      //sort networks
      for (int i = 0; i < n; i++) {
        indices[i] = i;
      }

      std::sort(indices, indices + n, [](const int & a, const int & b) -> bool
      {
        return WiFi.RSSI(a) > WiFi.RSSI(b);
      });
      // remove duplicates ( must be RSSI sorted )
      if(_removeDuplicateAPs) {
        String cssid;
        for (int i = 0; i < n; i++) {
          if(indices[i] == -1) continue;
          cssid = WiFi.SSID(indices[i]);
          for (int j = i + 1; j < n; j++) {
            if(cssid == WiFi.SSID(indices[j])){
              DEBUG_WM("DUP AP: " + WiFi.SSID(indices[j]));
              indices[j] = -1; // set dup aps to index -1
            }
          }
        }
      }

      for (int i = 0; i < n; i++) {
        if(indices[i] == -1) continue; // skip dups

        int quality = getRSSIasQuality(WiFi.RSSI(indices[i]));
        if (!(_minimumQuality == -1 || _minimumQuality < quality)) {
          indices[i] == -1;
          DEBUG_WM(F("Skipping due to quality"));
        }
      }

      return (n);
    }
}

template <typename Generic>
void WiFiManager::DEBUG_WM(Generic text) {
  if (_debug) {
    Serial.print("*WM: ");
    Serial.println(text);
  }
}

int WiFiManager::getRSSIasQuality(int RSSI) {
  int quality = 0;

  if (RSSI <= -100) {
    quality = 0;
  } else if (RSSI >= -50) {
    quality = 100;
  } else {
    quality = 2 * (RSSI + 100);
  }
  return quality;
}

/** Is this an IP? */
boolean WiFiManager::isIp(String str) {
  for (int i = 0; i < str.length(); i++) {
    int c = str.charAt(i);
    if (c != '.' && (c < '0' || c > '9')) {
      return false;
    }
  }
  return true;
}

/** IP to String? */
String WiFiManager::toStringIp(IPAddress ip) {
  String res = "";
  for (int i = 0; i < 3; i++) {
    res += String((ip >> (8 * i)) & 0xFF) + ".";
  }
  res += String(((ip >> 8 * 3)) & 0xFF);
  return res;
}


text:
PersistentEditText is a subclass of the EditText widgets that helps you saving and retrieving user entered text.

## Example Usage

You can add it as a library in your build.gradle file. PersistentEditText is hosted on the maven central repository. For instance:

    dependencies {
        // use the latest 1.x version
        compile 'org.wordpress:persistentedittext:1.+'
    }

Sample usage:

    <org.wordpress.persistentedittext.PersistentEditText
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/my_id"
        app:persistenceEnabled="true"/>

## Hack it

### Directory structure

	|-- PersistentEditText
	|   |-- build.gradle      # main build file
	|   `-- src
	|       |-- androidTest   # tests
	|       `-- main          # main code and resources
	|-- README.md
	|-- local.properties
	`-- settings.gradle

### Build

* Setup

Create your `local.properties` file or copy it from another project, then you can generate the aar file:

	$ echo "sdk.dir=YOUR_SDK_DIR" > local.properties

* Build

    $ ./gradlew build

* Publish to bintray:

```
$ ./gradlew assemble publishToMavenLocal bintrayUpload -PbintrayUser=XXX -PbintrayKey=XXX -PdryRun=false
```

## Apps that use this library

* [WordPress for Android][1]

## LICENSE

This library is dual licensed unded MIT and GPL v2.

## CHANGELOG

### 1.0

* Initial release

[1]: https://github.com/wordpress-mobile/WordPress-Android

redpajama_set_name: RedPajamaGithub


text:
import expect from 'expect.js'
import {stripIndent} from 'common-tags'
import {create, hasCSSTOMSupport} from '../../src'
import {resetSheets, createGenerateId} from '../../../../tests/utils'

describe('Integration: houdini', () => {
  if (!hasCSSTOMSupport) return

  beforeEach(resetSheets())

  let jss

  beforeEach(() => {
    jss = create({createGenerateId})
  })

  describe('use unit value', () => {
    let sheet
    const margin = CSS.px(42)

    beforeEach(() => {
      sheet = jss.createStyleSheet({
        a: {
          margin
        }
      })
    })

    it('should get value from .prop()', () => {
      expect(sheet.getRule('a').prop('margin')).to.be(margin)
    })

    it('should set valid value with .prop()', () => {
      const width = CSS.px(10)
      const rule = sheet.getRule('a')
      rule.prop('width', width)
      expect(rule.prop('width')).to.be(width)
    })

    it('should return valid .toString()', () => {
      expect(sheet.toString()).to.be(stripIndent`
        .a-id {
          margin: 42px;
        }
      `)
    })
  })
})


text:
import { suite } from 'uvu'
import * as assert from 'uvu/assert'
import { analyze } from '../index.js'

const BoxShadows = suite('BoxShadows')

BoxShadows('finds simple values', () => {
  const fixture = `
    box-shadows-simple {
      box-shadow: 1px 1px 2px black;
    }
  `
  const actual = analyze(fixture).values.boxShadows
  const expected = {
    total: 1,
    unique: {
      '1px 1px 2px black': 1,
    },
    totalUnique: 1,
    uniquenessRatio: 1
  }

  assert.equal(actual, expected)
})

BoxShadows('finds complex values', () => {
  const fixture = `
    box-shadows-complex {
      box-shadow: 1px 1px 1px black,inset 2px 3px 5px rgba(0,0,0,0.3),inset -2px -3px 5px rgba(255,255,255,0.5);
    }
  `
  const actual = analyze(fixture).values.boxShadows
  const expected = {
    total: 1,
    unique: {
      '1px 1px 1px black,inset 2px 3px 5px rgba(0,0,0,0.3),inset -2px -3px 5px rgba(255,255,255,0.5)': 1,
    },
    totalUnique: 1,
    uniquenessRatio: 1
  }

  assert.equal(actual, expected)
})

BoxShadows('finds vendor prefixed values', () => {
  const fixture = `
    box-shadows-vendor-prefixed {
      -webkit-box-shadow: 1px 1px 2px black;
    }
  `
  const actual = analyze(fixture).values.boxShadows
  const expected = {
    total: 1,
    unique: {
      '1px 1px 2px black': 1,
    },
    totalUnique: 1,
    uniquenessRatio: 1
  }

  assert.equal(actual, expected)
})

BoxShadows('ignores keywords', () => {
  const fixture = `
    box-shadows-keyword {
      box-shadow: initial;
      box-shadow: none;
    }
  `
  const actual = analyze(fixture).values.boxShadows
  const expected = {
    total: 0,
    unique: {},
    totalUnique: 0,
    uniquenessRatio: 0
  }

  assert.equal(actual, expected)
})

BoxShadows.run()


text:
import { Meteor } from 'meteor/meteor';
import { Session } from 'meteor/session';
import { Template } from 'meteor/templating';

import { ChatSubscription } from '../../../../models/client';
import { Layout, menu } from '../../../../ui-utils/client';
import { getUserPreference } from '../../../../utils';

Template.burger.helpers({
	unread() {
		const userUnreadAlert = getUserPreference(Meteor.userId(), 'unreadAlert');
		const [unreadCount, unreadAlert] = ChatSubscription
			.find({
				open: true,
				hideUnreadStatus: { $ne: true },
				rid: { $ne: Session.get('openedRoom') },
			}, {
				fields: {
					unread: 1,
					alert: 1,
					unreadAlert: 1,
				},
			})
			.fetch()
			.reduce(([unreadCount, unreadAlert], { alert, unread, unreadAlert: alertType }) => {
				if (alert || unread > 0) {
					unreadCount += unread;
					if (alert === true && alertType !== 'nothing') {
						if (alertType === 'all' || userUnreadAlert !== false) {
							unreadAlert = '•';
						}
					}
				}

				return [unreadCount, unreadAlert];
			}, [0, false]);

		if (unreadCount > 0) {
			return unreadCount > 99 ? '99+' : unreadCount;
		}

		return unreadAlert || '';
	},

	isMenuOpen() {
		if (Session.equals('isMenuOpen', true)) {
			return 'menu-opened';
		}
	},

	embeddedVersion() {
		return Layout.isEmbedded();
	},
});

Template.burger.events({
	'click div.burger'() {
		return menu.toggle();
	},
});


text:
import time

import Adafruit_GPIO.SPI as SPI
import Adafruit_SSD1351

import Image
import ImageDraw
import ImageFont

# Raspberry Pi pin configuration:
RST = 24
# Note the following are only used with SPI:
DC = 23
SPI_PORT = 0
SPI_DEVICE = 0

# Beaglebone Black pin configuration:
# RST = 'P9_12'
# Note the following are only used with SPI:
# DC = 'P9_15'
# SPI_PORT = 1
# SPI_DEVICE = 0

# 128x32 display with hardware I2C:
# disp = Adafruit_SSD1351.SSD1351_128_32(rst=RST)

# 128x96 display with hardware I2C:
# disp = Adafruit_SSD1351.SSD1351_128_64(rst=RST)

# Note you can change the I2C address by passing an i2c_address parameter like:
# disp = Adafruit_SSD1351.SSD1351_128_64(rst=RST, i2c_address=0x3C)

# Alternatively you can specify an explicit I2C bus number, for example
# with the 128x32 display you would use:
# disp = Adafruit_SSD1351.SSD1351_128_32(rst=RST, i2c_bus=2)

# 128x32 display with hardware SPI:
# disp = Adafruit_SSD1351.SSD1351_128_32(rst=RST, dc=DC, spi=SPI.SpiDev(SPI_PORT, SPI_DEVICE, max_speed_hz=8000000))

# 128x96 display with hardware SPI:
disp = Adafruit_SSD1351.SSD1351_128_96(rst=RST, dc=DC, spi=SPI.SpiDev(SPI_PORT, SPI_DEVICE, max_speed_hz=8000000))

# Alternatively you can specify a software SPI implementation by providing
# digital GPIO pin numbers for all the required display pins.  For example
# on a Raspberry Pi with the 128x32 display you might use:
# disp = Adafruit_SSD1351.SSD1351_128_32(rst=RST, dc=DC, sclk=18, din=25, cs=22)

# Initialize library.
disp.begin()

# Clear display.
disp.clear()
disp.display()
disp.rawfill(0,0,128,96,0)
disp.rawfill(35,65,15,15,255)


text:
{{ 'font-family' | attr}} specifies the font used to render 3D text.

All [Google fonts](https://www.google.com/fonts) are available for use.

Some of the popular fonts are:
* [Roboto](https://www.google.com/fonts/specimen/Roboto)
* [Oswald](https://www.google.com/fonts/specimen/Oswald)
* [Lora](https://www.google.com/fonts/specimen/Lora)
* [Raleway](https://www.google.com/fonts/specimen/Raleway)

{% craftml %}
<col spacing="5">

  Roboto

  Oswald

  Lora

  Raleway

</col>
{% endcraftml %}


text:
BSLS_IDENT_RCSID(bbldc_basicsia30360neom_cpp,"$Id$ $CSID$")

#include <bdlt_date.h>

#include <bsls_platform.h>

namespace BloombergLP {
namespace bbldc {

// STATIC METHODS
inline
static int computeDaysDiff(const bdlt::Date& beginDate,
                           const bdlt::Date& endDate)
    // Return the number of days between the specified 'beginDate' and
    // 'endDate' according to the SIA 30/360 no-end-of-month day-count
    // convention.  If 'beginDate <= endDate', then the result is non-negative.
    // Note that reversing the order of 'beginDate' and 'endDate' negates the
    // result.
{
    int y1, m1, d1, y2, m2, d2;
    int negationFlag = beginDate > endDate;
    if (negationFlag) {
        endDate.getYearMonthDay(  &y1, &m1, &d1);
        beginDate.getYearMonthDay(&y2, &m2, &d2);
    } else {
        beginDate.getYearMonthDay(&y1, &m1, &d1);
        endDate.getYearMonthDay(  &y2, &m2, &d2);
    }

    if (31 == d1) {
        d1 = 30;
    }

    if (30 == d1 && 31 == d2) {
        d2 = 30;
    }

    int result = (y2 - y1) * 360 + (m2 - m1) * 30 + d2 - d1;

    if (negationFlag) {
        result = -result;
    }

    return result;
}

                         // ------------------------
                         // struct BasicSia30360Neom
                         // ------------------------

// CLASS METHODS
int BasicSia30360Neom::daysDiff(const bdlt::Date& beginDate,
                                const bdlt::Date& endDate)
{
    return computeDaysDiff(beginDate, endDate);
}

double BasicSia30360Neom::yearsDiff(const bdlt::Date& beginDate,
                                    const bdlt::Date& endDate)
{
#if defined(BSLS_PLATFORM_CMP_GNU) && (BSLS_PLATFORM_CMP_VERSION >= 50301)
    // Storing the result value in a 'volatile double' removes extra-precision
    // available in floating-point registers.

    const volatile double rv =
#else
    const double rv =
#endif
              static_cast<double>(computeDaysDiff(beginDate, endDate)) / 360.0;

    return rv;
}

}  // close package namespace
}  // close enterprise namespace

// ----------------------------------------------------------------------------
// Copyright 2017 Bloomberg Finance L.P.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------- END-OF-FILE ----------------------------------


text:
<?xml version="1.0" encoding="utf-8"?>

<resources>

    <string name="hello">Hello World!</string>
    <string name="app_name">com.lnidigitalmarketing.aacc.testsTest</string>

</resources>


text:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<TITLE>
org.apache.tools.zip Class Hierarchy (Apache Ant API)
</TITLE>

<META NAME="date" CONTENT="2013-12-23">

<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../stylesheet.css" TITLE="Style">

      Overview
      Package
      Class
    Tree
      Deprecated
      Index
      Help

 PREV
 NEXT

  FRAMES
 NO FRAMES

  All Classes

Hierarchy For Package org.apache.tools.zip

Package Hierarchies:
All Packages

Class Hierarchy

java.lang.Object

org.apache.tools.zip.AbstractUnicodeExtraField (implements org.apache.tools.zip.ZipExtraField)

org.apache.tools.zip.UnicodeCommentExtraField
org.apache.tools.zip.UnicodePathExtraField

org.apache.tools.zip.AsiExtraField (implements java.lang.Cloneable, org.apache.tools.zip.UnixStat, org.apache.tools.zip.ZipExtraField)

org.apache.tools.zip.ExtraFieldUtils
org.apache.tools.zip.ExtraFieldUtils.UnparseableExtraField
org.apache.tools.zip.GeneralPurposeBit
org.apache.tools.zip.JarMarker (implements org.apache.tools.zip.ZipExtraField)

java.io.OutputStream (implements java.io.Closeable, java.io.Flushable)

java.io.FilterOutputStream

org.apache.tools.zip.ZipOutputStream

java.lang.Throwable (implements java.io.Serializable)

java.lang.Exception

java.io.IOException

java.util.zip.ZipException

org.apache.tools.zip.UnsupportedZipFeatureException
org.apache.tools.zip.Zip64RequiredException

org.apache.tools.zip.UnparseableExtraFieldData (implements org.apache.tools.zip.CentralDirectoryParsingZipExtraField)

org.apache.tools.zip.UnrecognizedExtraField (implements org.apache.tools.zip.CentralDirectoryParsingZipExtraField)

org.apache.tools.zip.UnsupportedZipFeatureException.Feature
org.apache.tools.zip.Zip64ExtendedInformationExtraField (implements org.apache.tools.zip.CentralDirectoryParsingZipExtraField)

org.apache.tools.zip.ZipEightByteInteger
org.apache.tools.zip.ZipEncodingHelper
java.util.zip.ZipEntry (implements java.lang.Cloneable)

org.apache.tools.zip.ZipEntry (implements java.lang.Cloneable)

org.apache.tools.zip.ZipFile
org.apache.tools.zip.ZipLong (implements java.lang.Cloneable)

org.apache.tools.zip.ZipOutputStream.UnicodeExtraFieldPolicy
org.apache.tools.zip.ZipShort (implements java.lang.Cloneable)

org.apache.tools.zip.ZipUtil

Interface Hierarchy

org.apache.tools.zip.UnixStat
org.apache.tools.zip.ZipEncoding
org.apache.tools.zip.ZipExtraField

org.apache.tools.zip.CentralDirectoryParsingZipExtraField

Enum Hierarchy

java.lang.Object

java.lang.Enum<E> (implements java.lang.Comparable<T>, java.io.Serializable)

org.apache.tools.zip.Zip64Mode

      Overview
      Package
      Class
    Tree
      Deprecated
      Index
      Help

 PREV
 NEXT

  FRAMES
 NO FRAMES

  All Classes


text:
<?php

/* @FOSUser/ChangePassword/changePassword.html.twig */
class __TwigTemplate_45139fbdf6ece912f117df273c313964b3d5a01ba3cd9c1f44f2bfafe910a1dc extends Twig_Template
{
    public function __construct(Twig_Environment $env)
    {
        parent::__construct($env);

        $this->parent = false;

        $this->blocks = array(
            'fos_user_content' => array($this, 'block_fos_user_content'),
        );
    }

    protected function doDisplay(array $context, array $blocks = array())
    {
        $__internal_950822d13f98a5230d0d778cb45b24a695b9de8a17c38b8ac18fd26fad0959fa = $this->env->getExtension("Symfony\\Bridge\\Twig\\Extension\\ProfilerExtension");
        $__internal_950822d13f98a5230d0d778cb45b24a695b9de8a17c38b8ac18fd26fad0959fa->enter($__internal_950822d13f98a5230d0d778cb45b24a695b9de8a17c38b8ac18fd26fad0959fa_prof = new Twig_Profiler_Profile($this->getTemplateName(), "template", "@FOSUser/ChangePassword/changePassword.html.twig"));

        // line 1
        echo "

";
        // line 3
        $this->displayBlock('fos_user_content', $context, $blocks);

        $__internal_950822d13f98a5230d0d778cb45b24a695b9de8a17c38b8ac18fd26fad0959fa->leave($__internal_950822d13f98a5230d0d778cb45b24a695b9de8a17c38b8ac18fd26fad0959fa_prof);

    }

    public function block_fos_user_content($context, array $blocks = array())
    {
        $__internal_cf303c44d42d95814693feaacd85ebaa0b9a8b22fc4d0f82c6ae2e7a3ba838ae = $this->env->getExtension("Symfony\\Bridge\\Twig\\Extension\\ProfilerExtension");
        $__internal_cf303c44d42d95814693feaacd85ebaa0b9a8b22fc4d0f82c6ae2e7a3ba838ae->enter($__internal_cf303c44d42d95814693feaacd85ebaa0b9a8b22fc4d0f82c6ae2e7a3ba838ae_prof = new Twig_Profiler_Profile($this->getTemplateName(), "block", "fos_user_content"));

        // line 4
        $this->loadTemplate("FOSUserBundle:ChangePassword:changePassword_content.html.twig", "@FOSUser/ChangePassword/changePassword.html.twig", 4)->display($context);

        $__internal_cf303c44d42d95814693feaacd85ebaa0b9a8b22fc4d0f82c6ae2e7a3ba838ae->leave($__internal_cf303c44d42d95814693feaacd85ebaa0b9a8b22fc4d0f82c6ae2e7a3ba838ae_prof);

    }

    public function getTemplateName()
    {
        return "@FOSUser/ChangePassword/changePassword.html.twig";
    }

    public function getDebugInfo()
    {
        return array (  39 => 4,  27 => 3,  23 => 1,);
    }

    /** @deprecated since 1.27 (to be removed in 2.0). Use getSourceContext() instead */
    public function getSource()
    {
        @trigger_error('The '.__METHOD__.' method is deprecated since version 1.27 and will be removed in 2.0. Use getSourceContext() instead.', E_USER_DEPRECATED);

        return $this->getSourceContext()->getCode();
    }

    public function getSourceContext()
    {
        return new Twig_Source("

{% block fos_user_content %}
{% include \"FOSUserBundle:ChangePassword:changePassword_content.html.twig\" %}
{% endblock fos_user_content %}
", "@FOSUser/ChangePassword/changePassword.html.twig", "C:\\wamp64\\www\\serveurDeVoeux\\vendor\\friendsofsymfony\\user-bundle\\Resources\\views\\ChangePassword\\changePassword.html.twig");
    }
}


text:
<!DOCTYPE html>

      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <title><div> with role main; global state or property "aria-controls" value of "obj1"</title>

Placeholder content

obj1

obj2


text:
var moodzt = "0";
var http_request = false;
function makeRequest(url, functionName, httpType, sendData) {

	http_request = false;
	if (!httpType) httpType = "GET";

	if (window.XMLHttpRequest) { // Non-IE...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			http_request.overrideMimeType('text/plain');
		}
	} else if (window.ActiveXObject) { // IE
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}

	if (!http_request) {
		alert('Cannot send an XMLHTTP request');
		return false;
	}

	var changefunc="http_request.onreadystatechange = "+functionName;
	eval (changefunc);
	//http_request.onreadystatechange = alertContents;
	http_request.open(httpType, url, true);
	http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	http_request.send(sendData);
}
function $() {
  var elements = new Array();

  for (var i = 0; i < arguments.length; i++) {
    var element = arguments[i];
    if (typeof element == 'string')
      element = document.getElementById(element);

    if (arguments.length == 1)
      return element;

    elements.push(element);
  }

  return elements;
}
function get_cookie(Name) {
  var search = Name + "="
  var returnvalue = "";
  if (document.cookie.length > 0) {
    offset = document.cookie.indexOf(search)
    if (offset != -1) {
      offset += search.length
      end = document.cookie.indexOf(";", offset);
      if (end == -1)
      end = document.cookie.length;
      returnvalue=unescape(document.cookie.substring(offset, end))
    }
  }
  return returnvalue;
}
function get_mood(mood_id)
{
	//if(moodzt == "1")
	if (get_cookie('wkmood'+infoid+'')==''+infoid+'')
	{
		alert("-_-|||,你不是表过态了嘛!?");
	}
	else {
		url ="http://"+window.location.host+root+"/index.php?m=Mood&a=update&aid="+infoid+"&type="+mood_id+"&random=" + Math.random();
		makeRequest(url,'return_review1','GET','');
		//moodzt = "1";
		document.cookie='wkmood'+infoid+'='+infoid+'';
	}
}
function remood()
{
	url ="http://"+window.location.host+root+"/index.php?m=Mood&a=index&aid="+infoid+"&random=" + Math.random();
	makeRequest(url,'return_review1','GET','');
}
function return_review1(ajax)
{
	if (http_request.readyState == 4) {
		if (http_request.status == 200) {
			var str_error_num = http_request.responseText;
			if(str_error_num=="error")
			{
				alert("信息不存在!");
			}
			else if(str_error_num==0)
			{
				alert("-_-|||,你不是表过态了嘛?!");
			}
			else
			{
				moodinner(str_error_num);
				//alert(str_error_num);
			}
		} else {
			alert('发生了未知错误!!');
		}
	}
}
function moodinner(moodtext)
{
	var imga = tpl+"/images/mood/pre_02.gif";
	var imgb = tpl+"/images/mood/pre_01.gif";
	var color1 = "#666666";
	var color2 = "#EB610E";
	var heightz = "80";	//图片100%时的高
	var hmax = 0;
	var hmaxpx = 0;
	var heightarr = new Array();
	var moodarr = moodtext.split(",");
	var moodzs = 0;
	for(k=0;k<8;k++) {
		moodarr[k] = parseInt(moodarr[k]);
		moodzs += moodarr[k];
	}
	for(i=0;i<8;i++) {
		heightarr[i]= Math.round(moodarr[i]/moodzs*heightz);
		if(heightarr[i]<1) heightarr[i]=1;
		if(moodarr[i]>hmaxpx) {
		hmaxpx = moodarr[i];
		}
	}
	$("moodtitle").innerHTML = "请选择您看到这篇文章时的心情 已有"+moodzs+"人表态:";
	for(j=0;j<8;j++)
	{
		if(moodarr[j]==hmaxpx && moodarr[j]!=0) {
			$("moodinfo"+j).innerHTML = ""+moodarr[j]+"
";
		} else {
			$("moodinfo"+j).innerHTML = ""+moodarr[j]+"
";
		}
	}
}
document.writeln("
");
document.writeln("
");
document.writeln("<\/td>");
document.writeln("<\/tr>");
document.writeln("
");
document.writeln("<\/td>");
document.writeln("<\/td>");
document.writeln("<\/td>");
document.writeln("<\/td>");
document.writeln("<\/td>");
document.writeln("<\/td>");
document.writeln("<\/td>");
document.writeln("<\/td><\/tr>");
document.writeln("
");
document.writeln("<\/td>");
document.writeln("<\/td>");
document.writeln("<\/td>");
document.writeln("<\/td>");
document.writeln("<\/td>");
document.writeln("<\/td>");
document.writeln("<\/td>");
document.writeln("<\/td>");
document.writeln("<\/tr>");
document.writeln("
");
document.writeln("惊呀<\/td>");
document.writeln("欠揍<\/td>");
document.writeln("支持<\/td>");
document.writeln("很棒<\/td>");
document.writeln("愤怒<\/td>");
document.writeln("搞笑<\/td>");
document.writeln("恶心<\/td>");
document.writeln("不解<\/td>");
document.writeln("<\/tr>");
document.writeln("
");
document.writeln("<input onClick=\"get_mood(\'mood1\')\" type=\"radio\" name=\"radiobutton\" value=\"radiobutton\"><\/td>");
document.writeln("<input onClick=\"get_mood(\'mood2\')\" type=\"radio\" name=\"radiobutton\" value=\"radiobutton\"><\/td>");
document.writeln("<input onClick=\"get_mood(\'mood3\')\" type=\"radio\" name=\"radiobutton\" value=\"radiobutton\"><\/td>");
document.writeln("<input onClick=\"get_mood(\'mood4\')\" type=\"radio\" name=\"radiobutton\" value=\"radiobutton\"><\/td>");
document.writeln("<input onClick=\"get_mood(\'mood5\')\" type=\"radio\" name=\"radiobutton\" value=\"radiobutton\"><\/td>");
document.writeln("<input onClick=\"get_mood(\'mood6\')\" type=\"radio\" name=\"radiobutton\" value=\"radiobutton\"><\/td>");
document.writeln("<input onClick=\"get_mood(\'mood7\')\" type=\"radio\" name=\"radiobutton\" value=\"radiobutton\"><\/td>");
document.writeln("<input onClick=\"get_mood(\'mood8\')\" type=\"radio\" name=\"radiobutton\" value=\"radiobutton\"><\/td>");
document.writeln("<\/tr>");
document.writeln("<\/table>")
remood();


text:
package com.tp.gl;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

public class MainActivity extends Activity {

    // Used to load the 'native-lib' library on application startup.
    static {
        System.loadLibrary("native-lib");
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // Example of a call to a native method
        TextView tv = (TextView) findViewById(R.id.sample_text);
        tv.setText(stringFromJNI());
    }

    /**
     * A native method that is implemented by the 'native-lib' native library,
     * which is packaged with this application.
     */
    public native String stringFromJNI();
}


text:
<?php
namespace App\Model\Entity;

use Cake\ORM\Entity;

/**
 * Session Entity
 *
 * @property int $id
 * @property int $user_id
 * @property string $timestamp
 *
 * @property \App\Model\Entity\User $user
 */
class Session extends Entity
{

    /**
     * Fields that can be mass assigned using newEntity() or patchEntity().
     *
     * Note that when '*' is set to true, this allows all unspecified fields to
     * be mass assigned. For security purposes, it is advised to set '*' to false
     * (or remove it), and explicitly make individual fields accessible as needed.
     *
     * @var array
     */
    protected $_accessible = [
        '*' => true,
        'id' => false
    ];
}


text:
<?php
// $Id$

/**
 * @file
 * Default theme implementation for displaying a user and their profile data
 * for member listing pages.
 *
 * @see profile-wrapper.tpl.php
 *      where all the data is collected and printed out.
 *
 * Available variables:
 * - $account: User's account object.
 * - $user_picture: Image configured for the account linking to the users page.
 * - $name: User's account name linking to the users page.
 * - $profile: Keyed array of all profile fields that are set as visible
 *   in member list pages (configured by site administrators). It also needs
 *   to have a value in order to be present.
 *
 * Each $field in $profile contains:
 * - $field->title: Title of the profile field.
 * - $field->value: Value of the profile field.
 * - $field->type: Type of the profile field, i.e., checkbox, textfield,
 *   textarea, selection, list, url or date.
 *
 * Since $profile is keyed, a direct print of the field is possible. Not
 * all accounts may have a value for a profile so do a check first. If a field
 * of "last_name" was set for the site, the following can be used.
 *
 *  <?php if (isset($profile['last_name'])): ?>
 *

 *      <?php print $profile['last_name']->title; ?>:

 *      <?php print $profile['last_name']->value; ?>
 *

 *  <?php endif; ?>
 *
 * @see template_preprocess_profile_listing()
 */
?>

  <?php print $user_picture; ?>

    <?php print $name; ?>

  <?php foreach ($profile as $field) : ?>

      <?php print $field->value; ?>

  <?php endforeach; ?>


text:
require 'google/apis/fusiontables_v2/service.rb'
require 'google/apis/fusiontables_v2/classes.rb'
require 'google/apis/fusiontables_v2/representations.rb'

module Google
  module Apis
    # Fusion Tables API
    #
    # API for working with Fusion Tables data.
    #
    # @see https://developers.google.com/fusiontables
    module FusiontablesV2
      VERSION = 'V2'
      REVISION = '20170413'

      # Manage your Fusion Tables
      AUTH_FUSIONTABLES = 'https://www.googleapis.com/auth/fusiontables'

      # View your Fusion Tables
      AUTH_FUSIONTABLES_READONLY = 'https://www.googleapis.com/auth/fusiontables.readonly'
    end
  end
end


text:
package pro.foundev.cassandra.commons.test.mapper.support;

import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.PreparedStatement;
import com.datastax.driver.core.Session;

public enum TestDataSupport {
    INSTANCE;

    private Cluster cluster;
    private Session session;
    private PreparedStatement selectStatement;
    private PreparedStatement insertStatement;

    public PreparedStatement getSelectStatement() {
        return selectStatement;
    }

    public PreparedStatement getInsertStatement() {
        return insertStatement;
    }

    public void init(){
        cluster = Cluster.builder()
                .addContactPoint("127.0.0.1")
                .build();
        session = cluster.connect();
        session.execute("CREATE KEYSPACE IF NOT EXISTS my_spring_test_keyspace with replication " +
                "= { 'class':'SimpleStrategy', 'replication_factor':1 }");
        session.execute("CREATE TABLE IF NOT EXISTS my_spring_test_keyspace.records " +
                "(id uuid, data text, PRIMARY KEY(id))");
        session.execute("TRUNCATE my_spring_test_keyspace.records");
        selectStatement = session.prepare("SELECT * FROM my_spring_test_keyspace.records where id=?");
        insertStatement = session.prepare("INSERT INTO my_spring_test_keyspace.records (id, data) values (?,?)");
    }

    public void close(){
        session.execute("DROP KEYSPACE IF EXISTS my_spring_test_keyspace");
        if(session!=null) {
            session.close();
        }
        if(cluster!=null) {
            cluster.close();
        }
    }

    public Session getSession() {
        return session;
    }
}


text:
package org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.segment.impl.window;

import lombok.Getter;
import lombok.Setter;
import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.segment.AbstractExpectedSQLSegment;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;

/**
 * Expected window clause.
 */
@Getter
@Setter
@XmlAccessorType(XmlAccessType.FIELD)
public final class ExpectedWindowClause extends AbstractExpectedSQLSegment {
}


text:
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Affecto.Patterns.Domain.UnitOfWork
{
    /// <summary>
    /// A broker that publishes domain events to domain event handlers.
    /// </summary>
    public class UnitOfWorkDomainEventBroker<TUnitOfWork> : DomainEventBrokerBase
        where TUnitOfWork : class, IUnitOfWork
    {
        private readonly IUnitOfWorkDomainEventHandlerResolver eventHandlerResolver;
        private readonly TUnitOfWork unitOfWork;

        /// <summary>
        /// Initializes a new instance of the <see cref="UnitOfWorkDomainEventBroker{TUnitOfWork}"/> class.
        /// </summary>
        /// <param name="eventHandlerResolver">Event handler resolver instance for finding domain event handlers.</param>
        /// <param name="unitOfWork">The Unit of Work context instance.</param>
        public UnitOfWorkDomainEventBroker(IUnitOfWorkDomainEventHandlerResolver eventHandlerResolver, TUnitOfWork unitOfWork)
        {
            this.eventHandlerResolver = eventHandlerResolver ?? throw new ArgumentNullException(nameof(eventHandlerResolver));
            this.unitOfWork = unitOfWork ?? throw new ArgumentNullException(nameof(unitOfWork));
        }

        /// <summary>
        /// Publishes the given domain event to all registered event handlers for the event type.
        /// </summary>
        /// <typeparam name="TDomainEvent">The type of the domain event.</typeparam>
        /// <param name="domainEvent">The domain event instance to execute.</param>
        protected override async Task PublishAsync<TDomainEvent>(TDomainEvent domainEvent)
        {
            IReadOnlyCollection<IUnitOfWorkDomainEventHandler<TDomainEvent, TUnitOfWork>> eventHandlers = eventHandlerResolver.ResolveEventHandlers<IUnitOfWorkDomainEventHandler<TDomainEvent, TUnitOfWork>>();

            foreach (IUnitOfWorkDomainEventHandler<TDomainEvent, TUnitOfWork> eventHandler in eventHandlers)
            {
                await eventHandler.ExecuteAsync(domainEvent, unitOfWork).ConfigureAwait(false);
            }
        }
    }
}


text:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_pressed="true">
        <shape android:shape="rectangle">
            <corners android:radius="4dp" />
            <solid android:color="@color/rc_emoji_grid_item_bg" />
        </shape>
    </item>
</selector>