Skip to content

Instantly share code, notes, and snippets.

View gbasov's full-sized avatar

Gennady Basov gbasov

  • Amsterdam, The Netherlands
View GitHub Profile
<?php
/**
* @author Philip Sturgeon
* @created 9 Dec 2008
*/
class cURL {
private $session; // Contains the cURL handler for a session
<?php
public function executeVkUploadFile(sfWebRequest $request)
{
$this->forward404Unless($request->isXmlHttpRequest() && $request->isMethod(sfRequest::POST));
$this->forward404Unless($t_participant = Doctrine::getTable('TParticipant')->find($request->getParameter('id')));
$url = $request->getParameter('url');
$file = $t_participant->getResizedPath();
$curl = new cURL($url);
$response = $curl->post([ 'photo' => '@' . $file ]);
jQuery(function($) {
var
$body = $('body'),
$formStart = $('.b-formStart'),
$formStartOne = $formStart.find('.column_one'),
$formStartTwo = $formStart.find('.column_two');
$(function() {
var ids_hash = {};
$('[data-replace=name], [data-replace=image]').each(function(i, el) {
@gbasov
gbasov / gist:4128094
Created November 21, 2012 21:51
localized_current_url
function localized_current_url($sf_culture = null)
{
if (! $sf_culture)
{
throw new sfException(sprintf('Invalid parameter $sf_culture "%s".', $sf_culture));
}
$routing = sfContext::getInstance()->getRouting();
$request = sfContext::getInstance()->getRequest();
$controller = sfContext::getInstance()->getController();
@gbasov
gbasov / gist:3804348
Created September 29, 2012 15:23
Format date
function date_format_ago($timestamp)
{
$diff = time() - $timestamp;
if ($diff < 5)
{
return 'только что';
}
if ($diff < 60)
@gbasov
gbasov / gist:3804346
Created September 29, 2012 15:23
Word form
function word_form($value, $one_form, $two_form, $five_form){
$form = null;
$han_value = $value%100;
$ten_value = $value%10;
// x05 - x20, x0, x5 - x9,
if( ($han_value >= 5 && $han_value <= 20) || in_array( $ten_value, array(0, 5, 6, 7, 8, 9) ) ){
$form = $five_form;
@gbasov
gbasov / gist:3804294
Created September 29, 2012 15:11
Convert urls to links
function url_to_link($text)
{
$text = preg_replace("@\b(https?://)?(([0-9a-zA-Z_!~*'().&=+$%-]+:)?[0-9a-zA-Z_!~*'().&=+$%-]+\@)?(([0-9]{1,3}\.){3}[0-9]{1,3}|([0-9a-zA-Z_!~*'()-]+\.)*([0-9a-zA-Z][0-9a-zA-Z-]{0,61})?[0-9a-zA-Z]\.[a-zA-Z]{2,6})(:[0-9]{1,4})?((/[0-9a-zA-Z_!~*'().;?:\@&=+$,%#-]+)*/?)@", '<a href="\0" target="_blank">\0</a>', $text);
$text = preg_replace("/href=\"([0-9a-zA-Z_\-]+\.)/U", 'href="http://$1', $text);
return $text;
}