<?xml version="1.0" encoding="utf-8"?>
<service name="photobucket"
         version="$Id: photobucket.xml 23059 2010-08-10 17:02:23Z campbell $"
         xmlns="http://www.flock.com/web-detective#">

  <strings>
    <string name="domains" value="photobucket.com"/>
    <string name="userprofileURL">
      <![CDATA[http://photobucket.com/images/search/%accountid%]]>
    </string>
    <string name="serviceloginURL">
      <![CDATA[http://photobucket.com/svc/servicelogin.php]]>
    </string>
    <string name="apiURL">
      <![CDATA[http://photobucket.com/svc/api.php]]>
    </string>
    <string name="homePageURL" locale="default">
      <![CDATA[http://photobucket.com/]]>
    </string>
    <string name="loginURL" locale="default">
      <![CDATA[http://photobucket.com/login]]>
    </string>
  </strings>

  <sessioncookies>
    <cookie host=".photobucket.com" name="PHPSESSID" path="/"/>
    <cookie host=".photobucket.com" name="GUID" path="/"/>
    <cookie host=".photobucket.com" name="pbauth" path="/"/>
    <cookie host=".photobucket.com" name="pbpassword" path="/"/>
    <cookie host=".photobucket.com" name="pbusername" path="/"/>
    <cookie host=".photobucket.com" name="AAMBLC" path="/"/>
    <cookie host=".photobucket.com" name="BLCOOKIE" path="/"/>
    <cookie host=".photobucket.com" name="pb_action_bitmask" path="/"/>
    <cookie host=".photobucket.com" name="pb_action_timestamp" path="/"/>
    <cookie host=".photobucket.com" name="LE0" path="/"/>
    <cookie host=".photobucket.com" name="LE1" path="/"/>
    <cookie host=".photobucket.com" name="LE2" path="/"/>
    <cookie host=".photobucket.com" name="LE3" path="/"/>
    <cookie host=".photobucket.com" name="LE4" path="/"/>
  </sessioncookies>

  <detect type="login">
    <url domain="photobucket.com"/>
    <form>
      <xpath name="username" extract="value">
        <![CDATA[//input[@id="username"]]]>
      </xpath>
      <xpath name="password" extract="value">
        <![CDATA[//input[@id="password"][@type="password"]]]>
      </xpath>
    </form>
  </detect>

  <!-- Matches on photobucket.com/login as of 2008-05-14 -->
  <detect type="login">
    <url domain="photobucket.com"><path contains="/login" /></url>
    <form>
      <field fieldid="usernameemail" extractas="username" />
      <field fieldid="password" type="password" extractas="password" />
    </form>
  </detect>

  <detect type="login">
    <url domain="photobucket.com" />
    <form>
      <field fieldid="usernameemail" extractas="username" />
      <field fieldid="password" type="password" />
    </form>
  </detect>
  
  <detect type="login">
    <url domain="photobucket.com">
      <path contains="svc/servicelogin.php"/>
    </url>
    <form>
      <field name="username"/>  
      <field name="password" type="password"/>
    </form>
  </detect>

  <detect type="signup">
    <url domain="register.photobucket.com" />
    <form>
      <field tagname="input" fieldid="username" />
      <field tagname="input" fieldid="password2" type="password" extractas="password" />
    </form>
  </detect>

  <detect type="changepassword">
    <url domain="photobucket.com">
      <querystring contains="action=accountoptions"/>
      <querystring contains="category=password"/>
    </url>
    <document>
      <regexp re1="username">
        <![CDATA[/Username: .*>(.*)<\/span>/]]>
      </regexp>
    </document>
    <form>
      <xpath name="password" extract="value">
        <![CDATA[[@name="changePW"]//input[@type="password"][@name="accountOptions[confirmPW]"]]]>
      </xpath>
    </form>
  </detect>

  <detect type="loggedin">
    <!-- Matches on front page login as of 2010-07-09 -->
    <xpath><![CDATA[//td[contains(@class,"accountContainer")]//a[contains(@href,"/logout")]]]></xpath>
  </detect>

  <detect type="loggedin">
    <!-- Matches on front page login as of 2009-12-10 -->
    <xpath><![CDATA[//td[contains(@class,"accountContainer")]//a[@href="http://photobucket.com/logout"]]]></xpath>
  </detect>

  <detect type="loggedin">
    <!-- Matches on front page login as of 2009-02-25 -->
    <xpath><![CDATA[//div[@id="containerUserCtrls"]//a[contains(@href,"photobucket.com/logout")]]]></xpath>
  </detect>

  <detect type="loggedin">
    <!-- Matches on front page login as of 2008-05-14 -->
    <xpath><![CDATA[//div[@id="containerUserCtrls"]//a[contains(@href,"special_track=nav_logout")]]]></xpath>
  </detect>

  <detect type="loggedin">
    <xpath><![CDATA[//table[@id="panelHeader"]//div[@id="menuWelcome"]/a/text()[contains(.,"logout")]]]></xpath>
  </detect>

  <detect type="loggedin">
    <xpath><![CDATA[//table[@id="tblHeaderFrame"]//td[@id="navUserMenu"]/a/text()[contains(.,"logout")]]]></xpath>
  </detect>
  
  <detect type="loggedin">
    <url><path contains="svc/servicelogin.php"/></url>
    <xpath><![CDATA[//p/text()[contains(.,"You have granted Flock")]]]></xpath>
  </detect>

  <detect type="loggedout">
    <url domain="photobucket.com" />
    <xpath>
      <![CDATA[//form[@action="https://login.photobucket.com/login"]]]>
    </xpath>
  </detect>

  <detect type="loggedout">
    <url domain="photobucket.com" />
    <xpath>
      <![CDATA[//form[@action="http://photobucket.com/login"]]]>
    </xpath>
  </detect>

  <detect type="loggedout">
    <url domain="photobucket.com">
      <querystring contains="action=logout"/>
    </url>
  </detect>

  <detect type="loggedoutcookies">
    <cookies>
      <cookie nomatch="true" host=".photobucket.com" name="pbauth" path="/"/>
    </cookies>
  </detect>

  <detect type="loggedout">
    <xpath><![CDATA[//table[@id="menuTop"]//a/text()[contains(.,"log in")]]]></xpath>
  </detect>

  <detect type="loggedout">
    <xpath><![CDATA[//form[@id="formHeaderLogin"]//input[@type="submit"][@name="login"]]]></xpath>
  </detect>

  <detect type="loggedout">
    <xpath><![CDATA[//div[@id="groupHeaderLoginLinks"]//a[@href="http://photobucket.com/login"]]]></xpath>
  </detect>

  <detect type="accountinfo">
    <xpath>
      <![CDATA[//td[contains(@class,"accountContainer")]//a/@href]]>
      <regexp re1="userid">
        <![CDATA[/home\/(.+)\/index/]]>
      </regexp>
    </xpath>
  </detect>

  <detect type="accountinfo">
    <regexp re1="userid">
      <![CDATA[/welcome,&nbsp;(.+?)</]]>
    </regexp>
  </detect>

  <detect type="person">
    <regexp re1="userid">
      <![CDATA[/^https?:\/\/[^\/]*\.?photobucket\.com\/albums\/[^\/]+\/([^\/]+)\/.+/]]>
    </regexp>
  </detect>

  <detect type="person">
    <regexp re1="userid">
      <![CDATA[/\/player.swf\?.*\.photobucket\.com\/albums\/[^\/]+\/([^\/]+)\/.+/]]>
    </regexp>
  </detect>

  <detect type="media">
    <url>
      <regexp re1="userid">
        <![CDATA[/photobucket\.com\/albums\/\w*?\/(\w*)/]]>
      </regexp>
    </url>
  </detect>

  <detect type="apiauth">
    <regexp re1="user_id"><![CDATA[/name="user_id" value="(\w+)"/]]></regexp>
  </detect>

  <detect type="isStreamUrl">
    <regexp><![CDATA[/^\/player.swf\?.*\.photobucket\.com\/albums\/[^\/]+\/([^\/]+)\/.+/]]></regexp>
  </detect>

  <detect type="isStreamUrl">
    <regexp><![CDATA[/^https?:\/\/[^\/]*\.?photobucket\.com\/albums\/[^\/]+\/([^\/]+)\/.+/]]></regexp>
  </detect>

  <detect type="isStreamUrl">
    <regexp><![CDATA[/^https?:\/\/[^\/]*\.?photobucket\.com\/player.swf\?.*\.photobucket\.com\/albums\/[^\/]+\/([^\/]+)\/.+/]]></regexp>
  </detect>

</service>
