├── ctl ├── .htaccess ├── _hookBefore.php ├── Logout.php ├── task │ ├── tag │ │ ├── List.php │ │ ├── Edit.php │ │ ├── Update.php │ │ └── Assign.php │ ├── Testchecker.php │ ├── Preparedata.php │ ├── Text.php │ ├── Star.php │ ├── Edit.php │ ├── Success.php │ ├── Save.php │ ├── Solvers.php │ ├── Solution.php │ ├── View.php │ ├── Attempt2.php │ └── List.php ├── api │ └── Weekbest.php ├── forum │ ├── Main.php │ ├── Newtopic.php │ ├── Delete.php │ ├── Edit.php │ ├── Update.php │ ├── View.php │ ├── Rename.php │ ├── Topic.php │ └── Post.php ├── tools │ └── Calcpoints.php ├── user │ ├── settings │ │ ├── Info.php │ │ ├── Country.php │ │ ├── Email.php │ │ ├── Chname.php │ │ ├── Avatar.php │ │ └── Password.php │ ├── Settings.php │ ├── Unsolved.php │ ├── Profile.php │ └── Ranking.php ├── Main.php ├── wiki │ ├── Edit.php │ └── Save.php ├── mess │ └── Hall.php ├── Wiki.php └── Login.php ├── docker-build.sh ├── fragments ├── .htaccess ├── tasklist │ └── notice.html ├── main │ ├── middlenote.html │ ├── bottomnote.html │ ├── image.html │ ├── lasttasks.html │ ├── rank.html │ ├── lastforum.html │ └── login.html ├── flash.html ├── langselect.html ├── countryselect.html ├── metas.html ├── taskview │ ├── errorsmodal.html │ ├── runtools.html │ ├── solcaption.html │ └── badattempt.html ├── rankline.html ├── cssandjs.html ├── footer.html ├── menu-bs.html └── forumform.html ├── layouts ├── .htaccess └── default_bs.html ├── module ├── .htaccess ├── service │ ├── CertService.php │ ├── StrUtils.php │ ├── CheatService.php │ ├── LocaleService.php │ ├── FriendService.php │ ├── MsgService.php │ ├── ChallengeService.php │ ├── LoginService.php │ ├── LangService.php │ └── MiscService.php ├── dao │ ├── ForumTopicsDao.php │ ├── ChallengesDao.php │ ├── TasksDao.php │ ├── UserDataDao.php │ ├── UserTasksDao.php │ └── MysqlDao.php ├── sys │ ├── Elems.php │ ├── ProtoContext.php │ └── Util.php ├── Context.php └── auth │ └── Auth.php ├── pages ├── .htaccess ├── error.php ├── message.php ├── forum │ ├── edit.php │ ├── list.php │ ├── newtopic.php │ ├── noaccess.php │ ├── main.php │ ├── view.php │ └── topic.php ├── error404.php ├── error403.php ├── wiki │ ├── index.php │ └── edit.php ├── wiki.php ├── task │ ├── tag │ │ ├── list.php │ │ └── edit.php │ ├── edit.php │ ├── solvers.php │ ├── success.php │ ├── solution.php │ ├── list.php │ └── view.php ├── main.php ├── user │ ├── unsolved.php │ └── ranking.php ├── mess │ └── hall.php └── login.php ├── img ├── facade.gif ├── logout.png ├── random.png ├── flags │ └── zz.gif ├── logingg.png ├── logingh.png ├── profile.png ├── search2.png └── settings.png ├── docker-run.sh ├── css ├── task │ └── view.css ├── bs_cm.php └── highlight.css ├── Dockerfile ├── js ├── jq_bs_cm.php ├── _ace │ ├── test-it.html │ ├── mode-plain_text.js │ ├── mode-python.js │ └── mode-sql.js ├── wiki │ └── edit.js ├── task │ └── edit.js └── _cm │ └── matchbrackets.js ├── .htaccess ├── LICENSE.txt ├── sqlexec.php ├── taskinit.sql ├── conf.php ├── index.php └── countries.sql /ctl/.htaccess: -------------------------------------------------------------------------------- 1 | Order deny,allow 2 | Deny from all 3 | -------------------------------------------------------------------------------- /docker-build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | docker build --tag ca-base . -------------------------------------------------------------------------------- /fragments/.htaccess: -------------------------------------------------------------------------------- 1 | Order deny,allow 2 | Deny from all 3 | -------------------------------------------------------------------------------- /layouts/.htaccess: -------------------------------------------------------------------------------- 1 | Order deny,allow 2 | Deny from all 3 | -------------------------------------------------------------------------------- /module/.htaccess: -------------------------------------------------------------------------------- 1 | Order deny,allow 2 | Deny from all 3 | -------------------------------------------------------------------------------- /pages/.htaccess: -------------------------------------------------------------------------------- 1 | Order deny,allow 2 | Deny from all 3 | -------------------------------------------------------------------------------- /img/facade.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeAbbey/src/HEAD/img/facade.gif -------------------------------------------------------------------------------- /img/logout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeAbbey/src/HEAD/img/logout.png -------------------------------------------------------------------------------- /img/random.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeAbbey/src/HEAD/img/random.png -------------------------------------------------------------------------------- /img/flags/zz.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeAbbey/src/HEAD/img/flags/zz.gif -------------------------------------------------------------------------------- /img/logingg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeAbbey/src/HEAD/img/logingg.png -------------------------------------------------------------------------------- /img/logingh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeAbbey/src/HEAD/img/logingh.png -------------------------------------------------------------------------------- /img/profile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeAbbey/src/HEAD/img/profile.png -------------------------------------------------------------------------------- /img/search2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeAbbey/src/HEAD/img/search2.png -------------------------------------------------------------------------------- /img/settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeAbbey/src/HEAD/img/settings.png -------------------------------------------------------------------------------- /pages/error.php: -------------------------------------------------------------------------------- 1 |

Error

2 | 3 |

Excuse us, some error have happened.

4 | -------------------------------------------------------------------------------- /pages/message.php: -------------------------------------------------------------------------------- 1 |

Warning!

2 | 3 |

msg ?>

-------------------------------------------------------------------------------- /fragments/tasklist/notice.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docker-run.sh: -------------------------------------------------------------------------------- 1 | docker run --rm --name ca-run -p 8080:80 -v $(pwd):/var/www/html -e CA_TEST=1 ca-base 2 | -------------------------------------------------------------------------------- /pages/forum/edit.php: -------------------------------------------------------------------------------- 1 |

Edit forum post

2 | 3 | util->fragment('forumform') ?> 4 | 5 | -------------------------------------------------------------------------------- /pages/error404.php: -------------------------------------------------------------------------------- 1 | 4 |

Page not found

5 |

Excuse us, but there is no such page.

6 | -------------------------------------------------------------------------------- /fragments/main/middlenote.html: -------------------------------------------------------------------------------- 1 | What certificates and achievements can you win here? Learn more... 2 |
3 | -------------------------------------------------------------------------------- /pages/error403.php: -------------------------------------------------------------------------------- 1 | 4 |

Access denied

5 |

Excuse us, you have not access rights for this page.

6 | -------------------------------------------------------------------------------- /fragments/main/bottomnote.html: -------------------------------------------------------------------------------- 1 | 2 | Do you know you can set up similar website in 15 minutes? Check link at the bottom of the page! 3 | 4 | -------------------------------------------------------------------------------- /ctl/_hookBefore.php: -------------------------------------------------------------------------------- 1 | httpReferrer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''; 5 | -------------------------------------------------------------------------------- /ctl/Logout.php: -------------------------------------------------------------------------------- 1 | auth->logout(); 4 | 5 | session_unset(); 6 | 7 | $ctx->util->flash('Logout successful. See you later!'); 8 | $ctx->util->redirect('main'); 9 | -------------------------------------------------------------------------------- /fragments/main/image.html: -------------------------------------------------------------------------------- 1 |

2 | <?= $ctx->elems->conf->projectName ?> 4 |

5 | -------------------------------------------------------------------------------- /pages/forum/list.php: -------------------------------------------------------------------------------- 1 |

List of forums

2 | 3 |

Currently under construction

4 | 5 |

General Discussions

6 | 7 | -------------------------------------------------------------------------------- /css/task/view.css: -------------------------------------------------------------------------------- 1 | #task-attempt input[type=submit] { 2 | width:150px; 3 | height:50px; 4 | font-size:200%; 5 | } 6 | 7 | #code-tools input { 8 | width: 105px; 9 | } 10 | -------------------------------------------------------------------------------- /pages/forum/newtopic.php: -------------------------------------------------------------------------------- 1 |

Creating new topic for forum->title ?>

2 | 3 | util->fragment('forumform') ?> 4 | 5 | -------------------------------------------------------------------------------- /module/service/CertService.php: -------------------------------------------------------------------------------- 1 | Sorry! 2 | 3 |
You need to be logged in and solve 4 | forTask->title ?> 5 | to get access to this topic!
6 |
7 | -------------------------------------------------------------------------------- /ctl/task/tag/List.php: -------------------------------------------------------------------------------- 1 | tags = $ctx->tagsDao->find(); 4 | 5 | if ($ctx->auth->user()) { 6 | shuffle($model->tags); 7 | } 8 | 9 | $ctx->elems->scripts[] = 'cloud'; 10 | $ctx->elems->title = 'Tags for Problems'; 11 | $ctx->elems->analytics = true; 12 | -------------------------------------------------------------------------------- /ctl/task/Testchecker.php: -------------------------------------------------------------------------------- 1 | auth->admin()) { 4 | $ctx->util->changePage('error404'); 5 | return; 6 | } 7 | 8 | $code = file_get_contents("php://input"); 9 | 10 | echo $ctx->taskService->testChecker($code); 11 | 12 | $ctx->util->changePage(null); 13 | -------------------------------------------------------------------------------- /fragments/main/lasttasks.html: -------------------------------------------------------------------------------- 1 |
Latest problems
2 | lastTasks as $task): ?> 3 | title ?> 4 | #id ?>
5 | 6 |
7 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:8.3-apache 2 | 3 | RUN docker-php-ext-install mysqli && a2enmod rewrite \ 4 | && apt-get update && apt-get install -y mariadb-server \ 5 | && mkdir /run/mysqld \ 6 | && chmod a+s /usr/bin/mariadb 7 | 8 | CMD ["/bin/bash", "-c", "coproc mariadbd --user=root && sleep 5 && apache2-foreground"] 9 | -------------------------------------------------------------------------------- /fragments/flash.html: -------------------------------------------------------------------------------- 1 | util->flash(); 3 | if ($_flash !== null) : 4 | ?> 5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | 13 | 14 | -------------------------------------------------------------------------------- /js/jq_bs_cm.php: -------------------------------------------------------------------------------- 1 | util->paramGet('param'); 4 | 5 | $userid = $ctx->auth->loggedUser(); 6 | 7 | if (!$userid || !is_numeric($taskid)) { 8 | $ctx->util->changePage('error404'); 9 | return; 10 | } 11 | 12 | $data = $ctx->taskService->prepareData($taskid); 13 | 14 | $ctx->util->plainOutput($data); 15 | -------------------------------------------------------------------------------- /fragments/langselect.html: -------------------------------------------------------------------------------- 1 | 7 | 8 | -------------------------------------------------------------------------------- /pages/wiki/index.php: -------------------------------------------------------------------------------- 1 |

Contents 2 | 3 | auth->admin()) : ?> 4 | Add new article 5 | 6 |

7 | 8 | pages as $page) : ?> 9 |
title ?>
10 | 11 | 12 |
13 | -------------------------------------------------------------------------------- /ctl/api/Weekbest.php: -------------------------------------------------------------------------------- 1 | userService->topOfWeek(); 4 | 5 | $res = ''; 6 | foreach ($best as $entry) { 7 | $url = url('user_profile', 'param', $entry->url); 8 | $res .= "{$entry->username}" 9 | . "{$entry->rank}{$entry->cnt}\n"; 10 | } 11 | 12 | header('Cache-Control: max-age=1200'); 13 | $ctx->util->plainOutput($res); 14 | -------------------------------------------------------------------------------- /fragments/countryselect.html: -------------------------------------------------------------------------------- 1 | 7 | 8 | -------------------------------------------------------------------------------- /ctl/forum/Main.php: -------------------------------------------------------------------------------- 1 | forums = $ctx->forumsDao->makeLookup(); 4 | 5 | foreach ($model->forums as $forum) { 6 | $forum->info = $ctx->markdown->parse(base64_decode($forum->info)); 7 | } 8 | 9 | $model->topics = $ctx->forumService->recentList($model->forums); 10 | 11 | $ctx->elems->title = "Forums"; 12 | $ctx->elems->description = 'Dicussion forum about solving programming problems and learning to code'; 13 | $ctx->elems->analytics = true; 14 | 15 | -------------------------------------------------------------------------------- /module/service/StrUtils.php: -------------------------------------------------------------------------------- 1 | elems->conf->author ?>"> 2 | 3 | elems->get('robots', 'index,follow'); ?> 4 | 5 | elems->conf->canonical) && strpos($metaRobots, 'noindex') === false): ?> 6 | 7 | 8 | -------------------------------------------------------------------------------- /ctl/task/tag/Edit.php: -------------------------------------------------------------------------------- 1 | auth->admin()) { 4 | $ctx->util->changePage('error404'); 5 | return; 6 | } 7 | 8 | $taskid = $ctx->util->paramGet('param'); 9 | 10 | $model->tags = $ctx->tagsDao->makeLookup('id'); 11 | 12 | if (!empty($taskid)) { 13 | $model->task = $ctx->tasksDao->read($taskid); 14 | $model->taskTags = $ctx->taskService->tagNamesForTask($taskid); 15 | } else { 16 | $model->task = null; 17 | $model->taskTags = array(); 18 | } 19 | 20 | -------------------------------------------------------------------------------- /module/service/CheatService.php: -------------------------------------------------------------------------------- 1 | status($userid)->suspended; 9 | } 10 | 11 | public function status($userid) { 12 | $res = new \stdClass(); 13 | $res->score = 7; 14 | $res->suspended = false; 15 | $res->msg = ''; 16 | $res->note = ''; 17 | return $res; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /module/dao/ForumTopicsDao.php: -------------------------------------------------------------------------------- 1 | query('select * from ' 13 | . $this->getTable() . " where lastpost > '$from' order by lastpost desc limit 20"); 14 | return $this->objectsArray($res); 15 | } 16 | 17 | } 18 | 19 | -------------------------------------------------------------------------------- /js/_ace/test-it.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /js/_ace/mode-plain_text.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/mode/plain_text",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/text_highlight_rules","ace/mode/behaviour"],function(e,t,n){"use strict";var r=e("../lib/oop"),i=e("./text").Mode,s=e("./text_highlight_rules").TextHighlightRules,o=e("./behaviour").Behaviour,u=function(){this.HighlightRules=s,this.$behaviour=new o};r.inherits(u,i),function(){this.type="text",this.getNextLineIndent=function(e,t,n){return t.match(/^\s*/)[0]},this.$id="ace/mode/plain_text"}.call(u.prototype),t.Mode=u}) 2 | -------------------------------------------------------------------------------- /pages/wiki.php: -------------------------------------------------------------------------------- 1 |
2 |
3 | Contents 4 | auth->admin()) : ?> 5 | Edit 6 | Add new article 7 | 8 |

9 |

title ?>

10 |
11 | util->fragment('adblock') ?> 12 |
13 | 14 | text ?> 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /ctl/tools/Calcpoints.php: -------------------------------------------------------------------------------- 1 | elems->conf->calcPointsSecret 4 | || $ctx->util->paramGet('param') != $ctx->elems->conf->calcPointsSecret) { 5 | $ctx->util->changePage('error404'); 6 | return; 7 | } 8 | 9 | $timeStart = microtime(true); 10 | 11 | $ctx->util->plainOutput("Calculations: \n"); 12 | 13 | $taskPoints = $ctx->miscService->calcPoints(); 14 | 15 | $timeEnd = microtime(true); 16 | $deltaTime = number_format(($timeEnd - $timeStart), 3); 17 | 18 | echo implode('', $taskPoints); 19 | echo "\nPoints Calculation completed in $deltaTime seconds\n"; 20 | -------------------------------------------------------------------------------- /ctl/forum/Newtopic.php: -------------------------------------------------------------------------------- 1 | util->paramGet('param'); 4 | 5 | if (empty($url) || !$ctx->miscService->validUrlParam($url)) { 6 | $url = 'general'; 7 | } 8 | 9 | $forum = $ctx->forumsDao->findFirst("url = '$url'"); 10 | 11 | if (!is_object($forum)) { 12 | $ctx->util->changePage('error404'); 13 | return; 14 | } 15 | 16 | $model->forum = $forum; 17 | $model->newTopic = true; 18 | 19 | $ctx->forumService->resourcesForCodeMirror(); 20 | 21 | $ctx->elems->robots = 'noindex,nofollow'; 22 | $ctx->elems->title = 'Create forum topic'; 23 | $ctx->elems->analytics = false; 24 | 25 | -------------------------------------------------------------------------------- /ctl/user/settings/Info.php: -------------------------------------------------------------------------------- 1 | util->paramPost('info'); 4 | 5 | if (!$ctx->userService->personalInfoAllowed()) { 6 | $ctx->util->changePage('error404'); 7 | return; 8 | } 9 | 10 | $userid = $ctx->auth->loggedUser(); 11 | 12 | $userInfo = $ctx->taskDataDao->findFirst("taskid = $userid and type = 'uinfo'"); 13 | if (!is_object($userInfo)) { 14 | $userInfo = new \stdClass(); 15 | $userInfo->taskid = $userid; 16 | $userInfo->type = 'uinfo'; 17 | } 18 | $userInfo->data = base64_encode($info); 19 | $ctx->taskDataDao->save($userInfo); 20 | 21 | $ctx->util->redirect('user_profile'); 22 | -------------------------------------------------------------------------------- /ctl/task/Text.php: -------------------------------------------------------------------------------- 1 | auth->loggedUser()) { 4 | $ctx->util->changePage('error404'); 5 | return; 6 | } 7 | 8 | $url = $ctx->util->paramGet('param'); 9 | if (!$ctx->miscService->validUrlParam($url)) { 10 | $ctx->util->changePage('error404'); 11 | return; 12 | } 13 | 14 | $task = $ctx->tasksDao->findFirst("url = '$url'"); 15 | if (!is_object($task)) { 16 | $ctx->util->changePage('error404'); 17 | return; 18 | } 19 | 20 | $taskdata = $ctx->taskDataDao->findFirst("taskid = {$task->id} and type = 'text'"); 21 | 22 | $ctx->util->plainOutput(base64_decode($taskdata->data)); 23 | -------------------------------------------------------------------------------- /module/dao/ChallengesDao.php: -------------------------------------------------------------------------------- 1 | query("select userid, sum(total) as points from " 13 | . $this->getTable() . " where userid <> 0 group by userid"); 14 | $res = $this->objectsArray($res); 15 | $lookup = array(); 16 | foreach ($res as $rec) { 17 | $lookup[$rec->userid] = $rec->points; 18 | } 19 | return $lookup; 20 | } 21 | 22 | } 23 | 24 | -------------------------------------------------------------------------------- /ctl/forum/Delete.php: -------------------------------------------------------------------------------- 1 | auth->admin()) { 4 | $ctx->util->changePage('error404'); 5 | return; 6 | } 7 | 8 | $url = $ctx->util->paramGet('param'); 9 | 10 | $topic = $ctx->forumService->loadTopicByUrl($url); 11 | if (!is_object($topic)) { 12 | $ctx->util->changePage('error404'); 13 | return; 14 | } 15 | 16 | $posts = $ctx->forumPostsDao->find("topicid = {$topic->id}"); 17 | 18 | $ctx->forumTopicsDao->delete($topic->id); 19 | 20 | foreach ($posts as $p) { 21 | $ctx->forumPostsDao->delete($p->id); 22 | } 23 | 24 | $ctx->util->flash('Topic deleted'); 25 | $ctx->util->redirect('forum_view'); 26 | -------------------------------------------------------------------------------- /ctl/forum/Edit.php: -------------------------------------------------------------------------------- 1 | util->paramGet('param'); 4 | 5 | if (!empty($url) && preg_match('/[0-9A-F]{32}/i', $url)) { 6 | $id = $ctx->miscService->decryptInt($url); 7 | if ($id !== null) { 8 | $post = $ctx->forumPostsDao->read($id); 9 | } 10 | } 11 | 12 | if (empty($post)) { 13 | $ctx->util->changePage('error404'); 14 | return; 15 | } 16 | 17 | $model->postText = base64_decode($post->post); 18 | $model->url = $url; 19 | 20 | $ctx->forumService->resourcesForCodeMirror(); 21 | 22 | $ctx->elems->robots = 'noindex,nofollow'; 23 | $ctx->elems->title = 'Editing forum post'; 24 | $ctx->elems->analytics = false; 25 | 26 | -------------------------------------------------------------------------------- /ctl/forum/Update.php: -------------------------------------------------------------------------------- 1 | util->paramPost('url'); 4 | $text = $ctx->util->paramPost('text'); 5 | 6 | if (!empty($id) && !empty($text) && preg_match('/[0-9A-F]{32}/i', $id)) { 7 | $id = $ctx->miscService->decryptInt($id); 8 | if ($id !== null) { 9 | $post = $ctx->forumPostsDao->read($id); 10 | } 11 | } 12 | 13 | if (empty($post)) { 14 | $ctx->util->changePage('error404'); 15 | return; 16 | } 17 | 18 | $post->post = base64_encode($text); 19 | $ctx->forumPostsDao->save($post); 20 | 21 | $topic = $ctx->forumTopicsDao->read($post->topicid); 22 | 23 | $ctx->util->redirect(url('forum_topic', 'param', $topic->url)); 24 | 25 | -------------------------------------------------------------------------------- /js/wiki/edit.js: -------------------------------------------------------------------------------- 1 | $(function() { 2 | 3 | var editor = CodeMirror.fromTextArea($("#text").get(0), { 4 | lineNumbers: true, 5 | mode: "markdown", 6 | indentUnit: 4, 7 | indentWithTabs: true, 8 | enterMode: "keep", 9 | tabMode: "shift", 10 | }); 11 | 12 | $("input[type=submit]").click(function() { 13 | $("#text").val(editor.getValue()); 14 | return true; 15 | }); 16 | 17 | function nameChanged() { 18 | var s = $(this).val(); 19 | s = nameToUrl(s); 20 | $("input[name=url]").val(s); 21 | } 22 | 23 | $("input[name=title]").change(nameChanged); 24 | 25 | }); 26 | -------------------------------------------------------------------------------- /pages/task/tag/list.php: -------------------------------------------------------------------------------- 1 |

Tags for Problems

2 | 3 |
4 | tags as $tag) : ?> 5 | title ?> 6 | 7 |
8 | 13 |
14 |
15 | 16 | 19 | -------------------------------------------------------------------------------- /ctl/user/settings/Country.php: -------------------------------------------------------------------------------- 1 | util->paramPost('code'); 4 | $userid = $ctx->auth->loggedUser(); 5 | 6 | if (empty($userid) || empty($code) || !preg_match('/[a-z]{2,3}/i', $code)) { 7 | $ctx->util->changePage('error404'); 8 | return; 9 | } 10 | 11 | $country = $ctx->countriesDao->findFirst("code = '$code'"); 12 | 13 | if (!is_object($country)) { 14 | $ctx->util->changePage('error404'); 15 | return; 16 | } 17 | 18 | $userdata = $ctx->userDataDao->findFirst("userid = $userid"); 19 | $userdata->country = $code; 20 | $ctx->userDataDao->save($userdata); 21 | 22 | $ctx->util->flash('Country info updated!'); 23 | $ctx->util->redirect('user_settings'); 24 | -------------------------------------------------------------------------------- /pages/wiki/edit.php: -------------------------------------------------------------------------------- 1 |

Wiki edit

2 | 3 |
4 | 5 |

8 | 9 |

12 | 13 |
16 | 17 | 18 |
19 | 20 | -------------------------------------------------------------------------------- /ctl/Main.php: -------------------------------------------------------------------------------- 1 | util->redirect(preg_replace('/index.*$/', '', $requestUri)); 7 | } 8 | 9 | $model->rank = $ctx->userService->topOfWeek(); 10 | 11 | $taskIds = $ctx->tasksDao->findIds('shown <> 0'); 12 | $taskIds = array_slice($taskIds, sizeof($taskIds) - 7); 13 | $taskIds = implode(',', $taskIds); 14 | $model->lastTasks = $taskIds ? array_reverse($ctx->tasksDao->find("id in ($taskIds)")) : []; 15 | 16 | $model->lastForum = 17 | array_slice($ctx->forumService->recentList(), 0, 5); 18 | 19 | $ctx->elems->analytics = true; 20 | 21 | $model->logged = ($ctx->auth->loggedUser() !== null); 22 | -------------------------------------------------------------------------------- /fragments/taskview/errorsmodal.html: -------------------------------------------------------------------------------- 1 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /module/dao/TasksDao.php: -------------------------------------------------------------------------------- 1 | query('update ' . $this->getTable() 13 | . ' set solved = (select count(userid) from ' 14 | . $this->getPrefix() . 'usertasks where solved > 0 and taskid = ' . $this->getTable() . '.id)'); 15 | } 16 | 17 | function updateCosts() { 18 | $this->query('update ' . $this->getTable() . ' full join ' 19 | . '(select max(solved) + 1 as maxsolved from ' . $this->getTable() . ') mx ' 20 | . 'set cost = 1 + log10(maxsolved / (solved + 1)) * 4'); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /pages/main.php: -------------------------------------------------------------------------------- 1 |
2 |
3 |

elems->conf->motto ?>
4 | util->fragment('main_image') ?> 5 |
6 | util->fragment('main_login') ?> 7 |
8 |
9 | util->fragment('main_middlenote') ?> 10 | util->fragment('main_lasttasks') ?> 11 | util->fragment('main_bottomnote') ?> 12 |
13 |
14 | 19 |
20 |
21 | -------------------------------------------------------------------------------- /ctl/wiki/Edit.php: -------------------------------------------------------------------------------- 1 | auth->admin()) { 4 | $ctx->util->changePage('error404'); 5 | return; 6 | } 7 | 8 | $title = $ctx->util->paramGet('url'); 9 | 10 | if (!empty($title)) { 11 | $model->wikipage = $ctx->wikiDao->findFirst("url = '$title'"); 12 | if (!is_object($model->wikipage)) { 13 | $ctx->util->changePage('error404'); 14 | return; 15 | } 16 | $model->wikipage->data = base64_decode($model->wikipage->data); 17 | } else { 18 | $model->wikipage = new stdClass(); 19 | $model->wikipage->title = ''; 20 | $model->wikipage->url = ''; 21 | $model->wikipage->data = ''; 22 | } 23 | 24 | array_push($ctx->elems->styles, 'codemirror'); 25 | array_push($ctx->elems->scripts, '_cm/codemirror'); 26 | array_push($ctx->elems->scripts, '_cm/markdown'); 27 | array_push($ctx->elems->scripts, '_cm/xml'); 28 | -------------------------------------------------------------------------------- /fragments/main/rank.html: -------------------------------------------------------------------------------- 1 |
2 | 8 |
Top Brethren and Sistren of the Week
9 | (see best of all times)
10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
UserRankSolved
21 | 22 |
23 | 24 | -------------------------------------------------------------------------------- /fragments/main/lastforum.html: -------------------------------------------------------------------------------- 1 |
2 |
3 | Recent at 4 | Forums: 5 | 6 |
7 | lastForum as $topic) : ?> 8 |
9 | title ?> 10 |
11 |
12 | from user->username ?>,   13 | last lastUser->username ?> 14 |
15 |
16 | last at lastpost ?> 17 |
18 | 19 |
20 | 21 | -------------------------------------------------------------------------------- /fragments/main/login.html: -------------------------------------------------------------------------------- 1 |
2 |
3 | logged) : ?> 4 |
5 | 10 | or else
11 | 12 | Login with GitHub 13 | 14 | 15 | Login with Google 16 | 17 |
18 | 19 |

Hello, auth->username() ?>!

20 | 21 |
22 |
23 | -------------------------------------------------------------------------------- /fragments/taskview/runtools.html: -------------------------------------------------------------------------------- 1 |
2 | 3 | 7 | 8 | 17 | 18 |
4 | Code Running Tools 5 |

6 |
9 |
12 |

13 | Web Compilers
14 | IdeOne.com
15 | CodePad.org 16 |
19 |
20 | -------------------------------------------------------------------------------- /fragments/rankline.html: -------------------------------------------------------------------------------- 1 | curEntry ?> 2 | 3 | rankpos ?> 4 | 5 | avatar != '') : ?> 6 | User avatar 8 | 9 |   10 | 11 | 12 | 13 | username ?> 14 |   15 | <?= $entry->countryTitle ?> 18 | 19 | language ?> 20 | rank ?> 21 | points ?> 22 | solved ?> 23 | 24 | 25 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | CodeAbbey License 2 | 3 | Copyright (c) 2013 Rodion Gorkovenko 4 | 5 | Permission is granted to run, study, share, modify this software, 6 | free of charge, to anyone, provided the following condition is met: 7 | 8 | 1. The reference to original repository https://github.com/codeabbey/src 9 | should be retained in unobscured way in user-facing interface (e.g. 10 | link with words "based upon CodeAbbey sources" in the footer of every web-page) 11 | 12 | 2. Redistributed copies and derived works should contain the above copyright 13 | notice and the link to original repository https://github.com/codeabbey/src 14 | 15 | The motivation is that any end-user may in turn obtain the copy of the original 16 | software. No conditions on publishing any changes, improvements, additions in 17 | derived works are imposed. 18 | 19 | The software is provided "AS IS", with no warranty of any kind. Reusing it you 20 | agree that the author is not responsible for any effects due to its use or misuse. 21 | -------------------------------------------------------------------------------- /ctl/user/settings/Email.php: -------------------------------------------------------------------------------- 1 | util->paramPost('newemail'); 4 | $pwd = $ctx->util->paramPost('chkpwd'); 5 | $userid = $ctx->auth->loggedUser(); 6 | 7 | if (empty($userid) || is_null($email) || is_null($pwd)) { 8 | $ctx->util->changePage('error404'); 9 | return; 10 | } 11 | 12 | $user = $ctx->usersDao->findFirst("id = $userid"); 13 | 14 | if (substr($user->loginid, 0, 2) != '!!') { 15 | $ctx->util->changePage('error404'); 16 | return; 17 | } 18 | 19 | if ($ctx->loginService->hashPassword($pwd) != $user->password) { 20 | $message = 'Error: Password is wrong!'; 21 | } else { 22 | $chk = $ctx->userService->checkEmail($email); 23 | if (is_null($chk)) { 24 | $user->loginid = '!!' . $ctx->loginService->hashEmail($email); 25 | $ctx->usersDao->save($user); 26 | $message = 'E-mail updated! '; 27 | } else { 28 | $message = "Error: $chk"; 29 | } 30 | } 31 | 32 | $ctx->util->flash($message); 33 | $ctx->util->redirect('user_settings'); 34 | -------------------------------------------------------------------------------- /ctl/user/settings/Chname.php: -------------------------------------------------------------------------------- 1 | util->paramPost('newname'); 4 | 5 | if (!$ctx->auth->user() || empty($newname)) { 6 | $ctx->util->changePage('error404'); 7 | return; 8 | } 9 | 10 | $user = $ctx->usersDao->findFirst("id = " . $ctx->auth->loggedUser()); 11 | $userData = $ctx->userDataDao->findFirst("userid = {$user->id}"); 12 | 13 | $loginType = substr($user->loginid, 0, 2); 14 | if ($loginType == '!!') { 15 | if ($userData->solved < $ctx->elems->conf->nameChangeLevel) { 16 | $ctx->util->changePage('error404'); 17 | return; 18 | } 19 | } 20 | 21 | $checkName = $ctx->userService->checkNewUsername($newname, true); 22 | if ($checkName !== null) { 23 | $ctx->util->flash("Error: $checkName"); 24 | $ctx->util->redirect('user_profile'); 25 | return; 26 | } 27 | 28 | if (!$ctx->cheatService->isSuspended($user->id)) { 29 | $user->username = $newname; 30 | $ctx->usersDao->save($user); 31 | } 32 | 33 | $ctx->util->flash('Name was changed!'); 34 | $ctx->util->redirect('user_settings'); 35 | 36 | -------------------------------------------------------------------------------- /ctl/task/Star.php: -------------------------------------------------------------------------------- 1 | auth->user()) { 4 | $ctx->util->changePage('error404'); 5 | return; 6 | } 7 | 8 | $ctx->util->plainOutput(''); 9 | 10 | $userid = $ctx->auth->loggedUser(); 11 | $taskid = $ctx->util->paramPost('task'); 12 | $star = $ctx->util->paramPost('star'); 13 | 14 | if (!is_numeric($taskid) || !in_array($star, ['0','1'], true)) { 15 | echo "badparams"; 16 | return; 17 | } 18 | 19 | $tag = "star.$userid"; 20 | $starred = $ctx->miscService->getTaggedValue($tag); 21 | echo "already starred: $starred\n"; 22 | $starred = $starred ? explode(',', $starred) : []; 23 | $exists = array_search($taskid, $starred); 24 | if ($star) { 25 | if ($exists !== false) return; 26 | $starred[] = $taskid; 27 | echo "added star\n"; 28 | } else { 29 | if ($exists === false) return; 30 | array_splice($starred, $exists, 1); 31 | echo "removed star\n"; 32 | } 33 | echo "remaining starred: " . json_encode($starred) . "\n"; 34 | $ctx->miscService->setTaggedValue($tag, 35 | $starred ? implode(',', $starred) : null); 36 | -------------------------------------------------------------------------------- /ctl/wiki/Save.php: -------------------------------------------------------------------------------- 1 | util->paramPost('title'); 4 | $url = $ctx->util->paramPost('url'); 5 | $data = $ctx->util->paramPost('data'); 6 | 7 | if (!$ctx->auth->admin() || empty($title) || empty($url)) { 8 | $ctx->util->changePage('error404'); 9 | return; 10 | } 11 | 12 | $url = $ctx->strUtils->nameToUrl($url); 13 | $wikipage = $ctx->wikiDao->findFirst("url = '$url'"); 14 | if (!is_object($wikipage)) { 15 | $wikipage = new stdClass(); 16 | } 17 | 18 | if (trim($data) != 'DELETE') { 19 | $wikipage->title = $title; 20 | $wikipage->url = $url; 21 | $wikipage->data = base64_encode($data); 22 | $wikipage->lastmod = date('Y-m-d'); 23 | 24 | $ctx->wikiDao->save($wikipage); 25 | 26 | $ctx->util->redirect(url('wiki', 'param', $wikipage->url)); 27 | } else { 28 | if ($wikipage->id) { 29 | $ctx->wikiDao->delete($wikipage->id); 30 | $ctx->util->flash("Wiki on $url was deleted!"); 31 | } else { 32 | $ctx->util->flash("Page to delete was not found!"); 33 | } 34 | $ctx->util->redirect('wiki'); 35 | } -------------------------------------------------------------------------------- /ctl/mess/Hall.php: -------------------------------------------------------------------------------- 1 | records = $ctx->chatViewDao->find(); 4 | 5 | $oldestTime = time() - 86400; 6 | for ($i = 0; $i < count($model->records); $i++) { 7 | $rec = $model->records[$i]; 8 | $time = strtotime($rec->created); 9 | if ($time < $oldestTime) { 10 | array_splice($model->records, $i); 11 | break; 12 | } 13 | $rec->message = $ctx->markdown->parse(base64_decode($rec->message)); 14 | $rec->created = date('H:i:s', $time); 15 | $rec->rank = $ctx->userService->rank($rec->solved, $rec->username); 16 | } 17 | 18 | $model->stats = $ctx->userTasksDao->solvingStats(date('Y-m-d', time() - 86400 * 15)); 19 | if ($ctx->auth->admin()) { 20 | $statsAvg = 0; 21 | for ($i = 1; $i < count($model->stats); $i++) { 22 | $statsAvg += $model->stats[$i]->cnt; 23 | } 24 | $model->statsAvg = number_format($statsAvg / (count($model->stats) - 1), 1); 25 | } 26 | 27 | $model->rights = $ctx->userService->messAllowed(); 28 | 29 | $ctx->elems->robots = 'noindex,nofollow'; 30 | $ctx->elems->title = 'Mess Hall'; 31 | $ctx->elems->analytics = true; 32 | 33 | -------------------------------------------------------------------------------- /ctl/task/tag/Update.php: -------------------------------------------------------------------------------- 1 | auth->admin()) { 4 | $ctx->util->changePage('error404'); 5 | return; 6 | } 7 | 8 | $tag = $ctx->util->paramPost('tag'); 9 | $taskid = $ctx->util->paramPost('task'); 10 | 11 | $returnLink = url('task_tag_edit', 'param', $taskid); 12 | 13 | $tag = strtolower(trim($tag)); 14 | 15 | if (!preg_match('/^[a-z]+(?:\-[a-z0-9]+)*$/', $tag)) { 16 | $ctx->util->redirect($returnLink); 17 | $ctx->util->flash("Bad tag title"); 18 | return; 19 | } 20 | 21 | $existing = $ctx->tagsDao->findFirst("title = '$tag'"); 22 | if (is_object($existing)) { 23 | $cnt = $ctx->taskTagsDao->getCount("tagid = {$existing->id}"); 24 | if ($cnt > 0) { 25 | $ctx->util->flash("Some tasks have this tag"); 26 | } else { 27 | $ctx->tagsDao->delete($existing->id); 28 | $ctx->util->flash("Removed: {$existing->title}"); 29 | } 30 | } else { 31 | $entity = new \stdClass(); 32 | $entity->title = $tag; 33 | $ctx->tagsDao->save($entity); 34 | $ctx->util->flash("Added: {$entity->title}"); 35 | } 36 | 37 | $ctx->util->redirect($returnLink); 38 | 39 | -------------------------------------------------------------------------------- /ctl/Wiki.php: -------------------------------------------------------------------------------- 1 | util->paramGet('param'); 4 | 5 | if (!$url) { 6 | $ctx->util->changePage('wiki/index'); 7 | $model->pages = $ctx->wikiDao->find(); 8 | $ctx->elems->title = 'Wiki: index'; 9 | $model->lastmod = '2014-01-01 00:00:00'; 10 | } else { 11 | $url = $ctx->strUtils->nameToUrl($url); 12 | $wikipage = $ctx->wikiDao->findFirst("url = '$url'"); 13 | 14 | if (!is_object($wikipage)) { 15 | $ctx->util->changePage('error404'); 16 | return; 17 | } 18 | 19 | $model->title = $wikipage->title; 20 | $model->url = $wikipage->url; 21 | $model->text = $ctx->markDown->parse(base64_decode($wikipage->data)); 22 | $model->lastmod = $wikipage->lastmod; 23 | 24 | $ctx->elems->title = 'Wiki: ' . $wikipage->title; 25 | if (strpos($model->text, '') !== false) { 26 | $ctx->elems->robots = 'noindex,nofollow'; 27 | } 28 | } 29 | 30 | $ctx->miscService->headerLastModified($model->lastmod); 31 | 32 | $ctx->elems->styles[] = 'jsmonoterm'; 33 | $ctx->elems->scripts[] = 'jsmonoterm'; 34 | $ctx->elems->analytics = true; 35 | 36 | 37 | -------------------------------------------------------------------------------- /ctl/forum/View.php: -------------------------------------------------------------------------------- 1 | util->paramGet('param'); 4 | 5 | if (empty($url) || !$ctx->miscService->validUrlParam($url)) { 6 | $forum = new \stdClass(); 7 | $forum->id = null; 8 | $forum->info = ''; 9 | } else { 10 | $forum = $ctx->forumsDao->findFirst("url = '$url'"); 11 | } 12 | 13 | if (!is_object($forum)) { 14 | $ctx->util->changePage('error404'); 15 | return; 16 | } 17 | 18 | $model->topics = $ctx->forumService->loadTopics($forum->id); 19 | 20 | foreach ($model->topics as $topic) { 21 | if ($topic->taskid) { 22 | $topic->title = "[Task#{$topic->taskid}] {$topic->title}"; 23 | } 24 | } 25 | 26 | if (!empty($forum->info)) { 27 | $forum->info = $ctx->markdown->parse(base64_decode($forum->info)); 28 | } 29 | 30 | $model->forum = $forum; 31 | 32 | $model->otherForums = !empty($url) ? $ctx->forumsDao->find("url != '$url'") : array(); 33 | 34 | $model->showCreateLink = $ctx->userService->forumAllowed(); 35 | 36 | $ctx->elems->title = 'Forum'; 37 | if (!empty($forum->title)) { 38 | $ctx->elems->title .= ": {$forum->title}"; 39 | } 40 | $ctx->elems->analytics = true; 41 | 42 | -------------------------------------------------------------------------------- /fragments/cssandjs.html: -------------------------------------------------------------------------------- 1 | util->sessionGet('css-random-key'); 4 | if ($cssRandomKey === null) { 5 | $cssRandomKey = rand(); 6 | $ctx->util->sessionPut('css-random-key', $cssRandomKey); 7 | } 8 | 9 | foreach ($ctx->elems->styles as $name) { 10 | if (strpos($name, '.') === false) $name .= ".css"; 11 | $file = "css/$name"; 12 | $tag = '"; 13 | if (!file_exists($file)) { 14 | $tag = ""; 15 | } 16 | echo "$tag\n"; 17 | } 18 | 19 | echo ''; 20 | 21 | foreach ($ctx->elems->scripts as $name) { 22 | if (strpos($name, '://') !== false) { 23 | echo ""; 24 | continue; 25 | } 26 | if (strpos($name, '.') === false) $name .= ".js"; 27 | $file = "js/$name"; 28 | $tag = '"; 29 | if (!file_exists($file)) { 30 | $tag = ""; 31 | } 32 | echo "$tag\n"; 33 | } 34 | 35 | ?> 36 | -------------------------------------------------------------------------------- /module/sys/Elems.php: -------------------------------------------------------------------------------- 1 | layout = 'default_bs'; 22 | $this->styles = []; 23 | $this->scripts = []; 24 | $this->conf = new \stdClass(); 25 | $this->conf->custFrag = []; 26 | $this->conf->custSvc = []; 27 | $this->conf->logging = []; 28 | $this->modules = array(); 29 | $this->moduleOrder = array(); 30 | $this->errors = array(); 31 | self::$elems = $this; 32 | } 33 | 34 | function get($field, $default = '') { 35 | if (isset($this->$field)) { 36 | return $this->$field; 37 | } 38 | return $default; 39 | } 40 | 41 | function addError($e) { 42 | array_push($this->errors, $e); 43 | } 44 | } 45 | 46 | -------------------------------------------------------------------------------- /ctl/forum/Rename.php: -------------------------------------------------------------------------------- 1 | auth->admin()) { 4 | $ctx->util->changePage('error404'); 5 | return; 6 | } 7 | 8 | $newName = $ctx->util->paramPost('newname'); 9 | $url = $ctx->util->paramPost('url'); 10 | 11 | $newName = trim($newName); 12 | $topic = $ctx->forumService->loadTopicByUrl($url); 13 | 14 | if (!is_object($topic) || strlen($newName) < 3) { 15 | $ctx->util->changePage('error404'); 16 | return; 17 | } 18 | 19 | if ($newName[0] != '/') { 20 | $newName = $ctx->forumService->stripTopicTitle($newName); 21 | if (!is_object($topic) || strlen($newName) < 5) { 22 | $ctx->util->flash('Bad title?'); 23 | $ctx->util->redirect('error'); 24 | return; 25 | } 26 | $topic->title = $newName; 27 | } else { 28 | $forumUrl = substr($newName, 1); 29 | $forum = $ctx->forumService->loadForumByUrl($forumUrl); 30 | if (!is_object($forum)) { 31 | $ctx->util->flash('No such forum?'); 32 | $ctx->util->redirect('error'); 33 | return; 34 | } 35 | $topic->forumid = $forum->id; 36 | } 37 | 38 | $ctx->forumTopicsDao->save($topic); 39 | $ctx->util->redirect(url('forum_topic', 'param', $url)); 40 | 41 | -------------------------------------------------------------------------------- /fragments/taskview/solcaption.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 | Your solution: 5 |
6 |
Note: it is not checked automatically, it is saved so you 7 | can later reuse your code in other problems.
8 | You can write in any language you want. 9 | For some of them we have built-in tools (see buttons below on right).
10 |
11 |
12 |
Select Language:
13 | 19 | 20 |
21 | 26 |
27 | -------------------------------------------------------------------------------- /fragments/footer.html: -------------------------------------------------------------------------------- 1 |
2 |
3 | elems->conf->copyright ?> 4 |
5 | based upon CodeAbbey opensource 6 |
7 |
8 | Contacts and Support 9 |
10 | Issues and Ideas 11 |
12 |
13 | Privacy Policy 14 |
15 |
16 |