Example #1
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.

import sys
from phpbb import phpBB


if __name__ == "__main__":
    if len(sys.argv) < 2:
        print(("Usage: %s <limit>" % sys.argv[0]))
        sys.exit(1)

    p = phpBB("http://mydomain.com/forum/")
    p.login("username", "password")
    limit = int(sys.argv[1])
    ulist = p.getUserList(limit)
    res = list()
    for u in ulist:
        r = p.queryJoinIP(u["id"])
        if r:
            r["user"] = u["name"]
            r["id"] = u["id"]
            r["posts"] = u["posts"]
            r["group"] = u["group"]
            res.append(r)
    p._table_print(
        res,
        [
    "user_agent",
    "add_signature",
    "ban_tab",
]

if __name__ == "__main__":
    import sys

    if len(sys.argv) < 3:
        print(("Usage: %s <config-name> <profile url>" % sys.argv[0]))
        sys.exit(1)

    user = int(sys.argv[2])
    cfg = Settings("ban.cfg")
    if cfg.load(sys.argv[1], cfg_opts):
        forum = phpBB(cfg.host)
        forum.setUserAgent(cfg.user_agent)
        if forum.login(cfg.username, cfg.password):
            username = forum.getUsername(user)
            print("> Processing user %s\n" % username)
            posts = forum.searchPosts(user)
            post_info = None
            if posts:
                post_info = forum.queryPostInfo(posts[0]["f"], posts[0]["p"])
                forum.showPosts(posts)
                print()
                if input('Do you want to delete those posts? type "delete" to confirm: ') == "delete":
                    print()

                    def callback_msg(post, msg):
                        print("Delete post #%i: %s" % (post, msg))