readDocument($id); if($doc){ $dt=$doc->docType; return "$txt"; } } return "$txt(?)"; } //----------------------------------------------------------- // printMultiImgBox //----------------------------------------------------------- // show gallery in a $width * ??? table function printMultiImgBox($heading, $id, $pin, $styleClass, $width, $sizeX) { print $this->makeMultiImgBox($heading, $id, $pin, $styleClass, $width, $sizeX); } //----------------------------------------------------------- // makeMultiImgBox //----------------------------------------------------------- // show gallery in a $width * ??? table function makeMultiImgBox($heading, $id, $pin, $styleClass, $width, $sizeX) { global $db, $groupID, $ownerID; $rv=""; $doc=$db->readDocument($id); $docType=$doc->docType; $coll=$doc->plugins[$pin]; if(!$coll->pluginType=="COLLECTION"){ $rv.= "
NO COLLECTION!!
"; return $rv; } $rv .= ""; $rv .= ""; $items=count($coll->values); for($i=0;$i<$items; $i+=$width){ $rv .= ""; for($j=0;$j<$width;$j++) { list ( $idx, $val ) = each ($coll->values); $src="/sys/image-scale.php?ID=$id&pin=$pin&idx=$idx"; if($val) $rv .= ""; else $rv .= ""; } $rv .= ""; } $rv .= "
$heading
 
"; return $rv; } //----------------------------------------------------------- // printTocBox //----------------------------------------------------------- // show gallery in a $width * ??? table // style: show it in Lines, show it function printTocBox($heading, $docType, $chn, $kid, $query, $style) { print $this->makeTocBox($heading, $docType, $chn, $kid, $query, $style); } //----------------------------------------------------------- // makeTocBox //----------------------------------------------------------- // style: show it in Lines, show it function makeTocBox($title, $docType, $chn, $kid, $query, $style) { global $db, $groupID, $ownerID; $rv=""; //print "QUERY: $query!"; if($query){ $data = $db->search($docType, $groupID, $ownerID, $query, 0, 12); } else $data = $db->selectPrivateDocuments($docType, $groupID, "", $chn, $kid, 0, 20); // style one Cell //print "STYLE: $style!"; switch($style) { case 'inline': if(!empty($data)) while ( list ( $key,$val ) = each ($data)) { } return $rv; case 'simple': if(!empty($data)) while ( list ( $key,$val ) = each ($data)) { $ID=$val[ID]; $alias=$val[alias]==$ID?"":"".$val[alias].":"; //$rv.= $this->makeObjectLink($ID, $val[alias], $val[title])." "; $lnk=$this->makeObjectLink($ID, $val[alias], $val[title])." "; $rv.="
$lnk
"; } return $rv; case 'menu': if(!empty($data)) while ( list ( $key,$val ) = each ($data)) { $ID=$val[ID]; $alias=$val[alias]==$ID?"":$val[alias]; //$rv.= $this->makeObjectLink($ID, $val[alias], $val[title])." "; $lnk=$this->makeObjectLink($ID, $val[alias], $val[title])." "; $rv.="$lnk
"; } return $rv; default: $rv.= ""; $rv.= "
$title
"; if(!empty($data)) while ( list ( $key,$val ) = each ($data)) { $ID=$val[ID]; $alias=$val[alias]==$ID?"":"".$val[alias].":"; $rv.= $this->makeObjectLink($ID, $val[alias], $val[title])." | "; } $rv.= "
"; return $rv; } //end switch } // HOOk Core function makeObjectLink($id, $alias, $title) { global $docType; return "$title"; } } // end: class AppContext //----------------------------------------------------------- // imageDir (id: j4mt4gneej95) //----------------------------------------------------------- function imageDir($id){ global $CMS; return $CMS['imageurl'].substr($id,4,1); } //----------------------------------------------------------- // imagePath //----------------------------------------------------------- # deprecated function imagePath($id){ global $CMS; return $CMS['sys_imagepath'].substr($id,4,1); } //----------------------------------------------------------- // printImageUrl //----------------------------------------------------------- function printImageUrl($id, $size="", $default="blank.gif", $pin="", $idx=""){ print getImageUrl($id, $size, $default, $pin, $idx); } //----------------------------------------------------------- // getImageUrl //----------------------------------------------------------- function getImageUrl($id, $size="L", $default="blank.gif", $pin="", $idx=""){ global $CMS, $ZACK; if($ZACK->currentObj && $ZACK->currentObj->groupID=='zack'){ return "http://w3-x.net/".$CMS['rsrc_path'].$ZACK->rsrc_RelPath(null, $id)."__${size}.".'jpg'; } return "http://".$CMS['rsrc_server'].$CMS['rsrc_path'].$ZACK->rsrc_RelPath(null, $id)."__${size}.".'jpg'; } //----------------------------------------------------------- // function: dateFormat //----------------------------------------------------------- // $date=> yyyy-mm-dd [hh:ss] // $format => date() format string function dateFormat($date, $format) { if(strlen($date)>11){ $hh=substr($date, 11,2); $mm=substr($date, 14,2); } $t=mktime ($hh,$mm,0, substr($date, 5,2) ,substr($date, 8,2), substr($date, 0,4)); if($format!='RELATIV') return date($format, $t); $now=Time(); if($now-$t<24*3600){ $h=round(($now-$t)/(3600)); return "vor $h Stunde(n)"; } elseif($now-$t<24*3600*31){ $d=round(($now-$t)/(3600*24)); return "vor $d Tag(en)"; } elseif($now-$t<24*3600*30.5*3){ $m=round(($now-$t)/(3600*24*30.5)); return "vor $m Monat(en)"; } return date('j.n.Y', $t); } //----------------------------------------------------------- // function: _validateEmail //----------------------------------------------------------- function _validateEmail($email){ // Create the syntactical validation regular expression $regexp = "^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})$"; $valid = 0; // Validate the syntax if (eregi($regexp, $email)){ return true; list($username,$domaintld) = split("@",$email); // Validate the domain if (getmxrr($domaintld, $mxrecords)) $valid = 1; } else { $valid = 0; } return $valid; } ?> 0x00000001, 'zack_perm_editDocument' => 0x00000002, 'zack_perm_editGroup' => 0x00000004, 'zack_perm_readGroup' => 0x00000008, 'zack_perm_editReview' => 0x00000010, 'zack_perm_createSet' => 0x00000020, 'zack_perm_editSet' => 0x00000040, 'zack_perm_viewSet' => 0x00000080, 'zack_perm_uploadRessource' => 0x00000100, 'zack_perm_partner_php' => 0x00000200, # partner.php allowed 'zack_perm_admin_php' => 0x00000400, # admin.php allowed 'zack_perm_deleteDocument' => 0x00000800, 'zack_perm_publish' => 0x00001000, 'zack_perm_publish_extern' => 0x00002000, 'zack_perm_torrent_distribute'=> 0x00004000, 'zack_perm_upload_stream' => 0x00008000, 'zack_perm_access_user' => 0x00010000, # only permitted to admin 'zack_perm_download_hires' => 0x00020000, # download hires images 'zack_perm_download_layout' => 0x00040000, # download layout images 'zack_perm_edit' => 0x00080000, 'zack_perm_read' => 0x00100000, 'zack_perm_addRemSet' => 0x00200000, ); //----------------------------------------------------------- // ZKIT SIMPLE API PERMS //----------------------------------------------------------- /* auth_token - string user_id|perms|expires|sig (i.e. xdzqhppx|11000|ab234562ad...) sig=zkitSignature(user_id.perms.expires) *perms* perms[0]==1 - read: read own private images, user data perms[1]==1 - write: edit/update own data perms[2]==1 - delete: delete own data perms[3]==1 - download HIRES own images perms[3]==2 - download HIRES group images how many downloads is limited in static.../download.php -------------------------------------------------------------*/ # indexes into perms-string 0,1 define(ZKIT_SAPI_READ, 0); # read non public photos define(ZKIT_SAPI_WRITE, 1); # write own data define(ZKIT_SAPI_DELETE, 2); # delete own data define(ZKIT_SAPI_DOWNLOAD, 3); //----------------------------------------------------------- // SYS_RELATIONEN //----------------------------------------------------------- define(SYS_RELATION_SET, 'RSET'); # define SETS: Galleries, Pool,... define(SYS_RELATION_POOL, 'POOL'); # define Pool-Items define(SYS_RELATION_MEMBER, 'MMBR'); # Group Member define(SYS_RELATION_SETA, 'ASET'); # used for lightbox etc. define(SYS_RELATION_SETB, 'BSET'); # used for shotlists etc. define(SYS_RELATION_EVENT, 'EVNT'); # obj rel event define(SYS_RELATION_LTBX, 'LTBX'); # obj rel Lightbox define(SYS_RELATION_CART, 'CART'); # obj rel Shopping Cart //----------------------------------------------------------- // RELATIONEN //----------------------------------------------------------- define(RELATION_REVIEW, 'REVW'); # Reviews, Rezension define(RELATION_THIS_THAT, 'OFLT'); # Wer Movie a gekauft hat, hat auch Movie B gekauft define(RELATION_RECOM, 'RCOM'); # Wer Movie a angeschaut hat, hat auch Movie B angeschaut define(RELATION_BOUGHT, 'BOGT'); # Kunde A hat Movie X gekauft define(RELATION_GROUP_EVENT, 'GEVN'); # Group Event define(RELATION_EZSL, 'EZSL'); # eazy syndication license Image->License, fotograf->License //----------------------------------------------------------- // Properties //----------------------------------------------------------- $ALL_PROPERTIES=array( # MEDIA-ITEMS/ Global Properties 'zack:tag'=> 2, # just a plain old tag 'zack:topic'=> 2, # topic 'zack:can'=> 2, # can: blog 'zack:yop'=> 1, # year of production/creation (YYYY) 'zack:author'=> 2, # creator of a media piece 'zack:contributor'=> 2, # contributor to a media piece 'zack:chn'=> 2, # channel (bb/news, idoxx/features) 'zack:fld'=> 1, # folder - only one FOLDER allowed 'zack:licn'=> 1, # License (rm,rf,cc) 'zack:rating'=> 1, # rating of an item 'zack:rank'=> 1, # rank according to rating sum/rating count 'zack:login'=> 1, # allows check for user mail addr 'zack:cmslogin'=> 1, # login prelim 'zack:applogin'=> 1, # login prelim 'zack:producerID'=> 2, # producer of a media piece 'zack:concept'=> 2, # abstrakter begriff f. Image, Movie,... 'zack:newsletter'=> 1, # newsletter receiver. 'zack:member'=> 1, # becoming some kind of member while register 'z:country' => 1, # country - other than image type 'z:zip' => 1, # zip Code # Properties for localHeroes Bands 'heroes:BF' => 2, # bundes finale z.B. heroes:BF=2009 # Properties for IMAGES 'img:wregion'=> 1, # world region 'img:country'=> 1, # country (DE, DEU, US, ...) 'img:region'=> 1, # region 'img:city'=> 1, # city 'img:eventDate'=> 1, # (yyyy-mm-dd) 'img:bw'=> 1, # black and white (1) 'img:format '=> 1 , # P or L - Portrait or Landscape 'img:modrelease'=> 1, # has model release (1) 'img:proprelease'=> 1, # has property release (1) 'img:person'=> 2, # person in a photo # Properties for MOVIES 'mv:bw'=> 1, # black and white film? 'mv:genre'=> 2, # black and white film? # media:credit role (EBU) 'mcr:director' => 2, 'mcr:dop' => 2, 'mcr:photographer' => 2, 'mcr:editor' => 2, 'mcr:sound recordist' => 2, 'mcr:actor' => 2, 'mcr:producer' => 2, # videoclips 'vc:format'=> 2, # videoclips format (report, roughcut,..) 'vc:eventDate'=> 1, # videoclips format (report, roughcut,..) 'vc:csnum'=> 1, # videoclips (footage) archive-number # videoclips 'wnet:region'=> 1, # 'wnet:thema'=> 2, # ); ?> null ownerID => =, <> groupdID => =, <> +Sets => null +Tags => null +Properties => null property => = <>, <, >, LIKE public => null isPublic => null isPrivate => null isa => = <> srcDate => <,>,=, <> alias => = <> like title => = <> like memberOf => RZNS, MMBR, ADMN, ... ID => in | comma separated list of ids quickList => null, bool .return a list core fields only (title, alias, srcdate - no UNSERIALIZE Content Order title => asc,desc alias => asc,desc setOrder => asc,desc srcDate => asc,desc *Tags -Filter Params ownerID objectID docType isa ? timeStamp public cluster sysTag (attrs) => =, <>, LIKE Tags -Order Tag Count Tags -Return Values Tag TagCount *Categories - Filter parent children siblings [path] *Account - Filter userID itemID txType ------------------------------------------------------------------*/ /*------------------------------------------------------------------ class ZA_Query ------------------------------------------------------------------*/ class ZA_Query { var $type, # Content, Tags, Relation $token, # token where data is stored in zack->ctx[data][token] $filter, $relName, $relObjID, $order, $baserec, $maxrec, $error, $errorText, $numRows; # number of rows in a complete select /*------------------------------------------------------------------ ZA_Query::CTOR ------------------------------------------------------------------*/ function ZA_Query($type, $token=null){ $this->type=$type; $this->token=$token; } /*------------------------------------------------------------------ ZA_Query::create ------------------------------------------------------------------*/ function create($type, $token=null){ $query= & new ZA_Query($type, $token); return $query; } /*------------------------------------------------------------------ ZA_Query::filter ------------------------------------------------------------------*/ # preliminary as op we only know == function filter($field, $op, $val){ switch($this->type){ case 'Content': case 'Tags': case 'Categories': case 'Account': switch($field){ case 'srcDate': case 'txStart': // transactions only case 'txEnd': // transactions only $val='{'.$op.'}'.$val; break; case 'memberOf': $val='{'.$op.'}'.$val; break; } $this->filter[$field]=$val; break; # op is always member case 'Relation': $this->relName=$field; $this->relObjID=$val; break; } return $this; } /*------------------------------------------------------------------ ZA_Query::order ------------------------------------------------------------------*/ # preliminary as op we only know == function order($field, $ascdesc){ $this->order="$field $ascdesc"; } /*------------------------------------------------------------------ ZA_Query::limit ------------------------------------------------------------------*/ function limit($base, $max){ $this->baserec=$base; $this->maxrec=$max; } /*------------------------------------------------------------------ ZA_Query::exec ------------------------------------------------------------------*/ # preliminary we only know one operator: == function exec(){ global $ZACK; switch($this->type){ case 'Content': $data=$ZACK->list_getList($this->filter, $this->baserec, $this->maxrec, $this->order, $this->token); $this->numRows=$ZACK->numRows; return $data; case 'Tags': return $ZACK->list_getTags($this->filter, $this->maxrec, $this->order); case 'Relation': return $data=$ZACK->rel_getRelated($this->relObjID, $this->relName, $this->baserec, $this->maxrec); // max? case 'Account': return $data=$ZACK->list_getAccnt($this->filter, $this->baserec, $this->maxrec, $this->order); // max? } // end switch } /*------------------------------------------------------------------ ZA_Query::execApplyTemplate ------------------------------------------------------------------*/ function execApplyTemplate($addValues, $tpl, $itemsPerLine=1, $listMode=''){ global $ZACK, $CMS, $APP; # template params $TPL_image_size=$addValues['TPL_image_size']; unset($addValues['TPL_image_size']); switch($this->type){ case 'Content': $data=$ZACK->list_getList($this->filter, $this->baserec, $this->maxrec, $this->order, $this->token); if($data){ $flip=$item=0; $Xvalues=array(); # TODO: Move this whole processing -> zackapi.local! foreach($data as $key=>$val){ $flip++; $ID = $val["ID"]; $content=$val["content"]; $docType=$val['docType'];$isa=$val['isa']; $alias=$val["alias"]; #var_dump($val); #set $doc->ownerID, groupID??? require_once ($CMS['sys_path']."/api/doctypes/$docType.php"); $ZOBJ=unserialize($content); if($ZOBJ){ $values=$ZOBJ->getValues(); $components=$ZOBJ->components; } else continue; #$values['intro']=parseText($values['intro']); $values=array_merge($values, $addValues); $values['alias']=$alias; # nobody knows why we need this $values['channels']=$ZOBJ->properties['zack:chn']; $values['isa']=$isa; $values['ID']=$ID; $values['docType']=$docType; $values['viewCount']=$val['viewCount']; $values['default_image_S']=$val['default_image_S']; $values['default_image_Q']=$val['default_image_Q']; $values['default_image_M']=$val['default_image_M']; $values['default_image_L']=$val['default_image_L']; $images=$ZOBJ->attachments['DEFAULT_IMAGES']; if(!$images['S'])unset($values['default_image_S']); if(!$images['M'])unset($values['default_image_M']); $values['title']=$val['title']; $values['keywords']=$val['keywords']; if($itemsPerLine==1){ if(function_exists($tpl)) $tpl($flip, $values); else include $tpl; } else { $Xvalues[$item]=$values; $item++; if($item>=$itemsPerLine){ if(function_exists($tpl)) $tpl($flip, $values); else include $tpl; $item=0;$Xvalues=array(); } } } # end foreach if($item>0){ if(function_exists($tpl)) $tpl($flip, $values); else include $tpl; } } # end if data return $this->numRows=$ZACK->numRows; case 'Account': $data=$ZACK->list_getAccnt($this->filter, $this->baserec, $this->maxrec, $this->order); if($data){ $flip=$item=0; $Xvalues=array(); foreach($data as $key=>$val){ $flip++; $values=&$val; if($itemsPerLine==1){ if(function_exists($tpl)) $tpl($flip, $values); else include $tpl; } else { $item++; if($item>=$itemsPerLine){ if(function_exists($tpl)) $tpl($flip, $values); else include $tpl; $item=0;$Xvalues=array(); } } } # end foreach if($item>0) include $tpl; } # end if data return $this->numRows=$ZACK->numRows; case 'Tags': break; case 'Relation': break; case 'Files': break; } // end switch } // end execApplyTemplate /*------------------------------------------------------------------ ZA_Query::dataApplyTemplate ------------------------------------------------------------------*/ function dataApplyTemplate($data, $tpl, $itemsPerLine=1, $listMode=''){ global $ZACK, $CMS, $APP; if($data){ $flip=$item=0; $Xvalues=array(); foreach($data as $key=>$val){ $flip++; $values=$data[$key]; if($itemsPerLine==1) if(function_exists($tpl)) $tpl($flip, $values); else include $tpl; else { $Xvalues[$item]=$values; $item++; if($item>=$itemsPerLine){ if(function_exists($tpl)) $tpl($flip, $values); else include $tpl; $item=0;$Xvalues=array(); } } } # end foreach if($item>0){ if(function_exists($tpl)) $tpl($flip, $values); else include $tpl; } } # end if data return $this->numRows=sizeof($data); } // end dataApplayTemplate } // end ZA_Query ?>Container, Movie, ... * @param string $isa subtype like SET, PERSON,... * @return ZA_Object * @access public */ function createObject($docType, $isa=null){ global $ZACK; return $ZACK->obj_create($docType, $isa); } /*------------------------------------------------------------------ ZA_ContentStore::createSet ------------------------------------------------------------------*/ function createSet(){ return null; } /*------------------------------------------------------------------ ZA_ContentStore::loadObject ------------------------------------------------------------------*/ function loadObject($objID){ global $ZACK; return $ZACK->obj_readDocument($objID); } /*------------------------------------------------------------------ ZA_ContentStore::storeObject ------------------------------------------------------------------*/ function storeObject($zobj, $user=null){ global $ZACK; return $ZACK->obj_store($zobj, $user); } /*------------------------------------------------------------------ ZA_ContentStore::deleteObject ------------------------------------------------------------------*/ function deleteObject($zobjID){ global $ZACK; return $ZACK->obj_delete($zobjID); } /*------------------------------------------------------------------ ZA_ContentStore::viewCountAdd ------------------------------------------------------------------*/ function viewCountAdd($zobjID, $ownerID){ global $ZACK; return $ZACK->obj_viewCountAdd($zobjID, $ownerID); } /*------------------------------------------------------------------ ZA_ContentStore::lockObject ------------------------------------------------------------------*/ function lockObject($zobjID){ return; } /*------------------------------------------------------------------ ZA_ContentStore::unlockObject ------------------------------------------------------------------*/ function unlockObject($zobjID){ return; } /*------------------------------------------------------------------ ZA_ContentStore::storeAttachedFile ???!!! ------------------------------------------------------------------*/ function storeAttachedFile($zobj, $aName, $idx, $file){ return; } /*------------------------------------------------------------------ ZA_ContentStore::addRelatedObject ------------------------------------------------------------------*/ function addRelatedObject($zobjID, $relationName, $ID){ return; } /*------------------------------------------------------------------ ZA_ContentStore::removeRelatedObject ------------------------------------------------------------------*/ function removeRelatedObject($zobjID, $relationName, $ID){ return; } /*------------------------------------------------------------------ ZA_ContentStore::add2Set ------------------------------------------------------------------*/ function add2Set($zobjID, $setID){ return; } /*------------------------------------------------------------------ ZA_ContentStore::removeFromSet ------------------------------------------------------------------*/ function removeFromSet($zobjID, $setID){ return; } } // end ZA_ContentStore ?>init()) { print "db-init fails!
\n"; exit; } $db->setRepository($CMS['repository']); } /*------------------------------------------------------------------ class zackAPI ------------------------------------------------------------------*/ class zackAPI { var $user, $appKey, $db, $error, $errorText, $numRows, # number of rows in a complete select $currentObj; # needed by wiki parser /*------------------------------------------------------------------ zackAPI::CTOR ------------------------------------------------------------------*/ function zackAPI($appKey){ global $CMS, $db; $this->appKey=$appKey; $this->db=$db; } //----------------------------------------------------------- // function: cleanOutput (f. txt-mail) //----------------------------------------------------------- function cleanOutput($str){ $trans = get_html_translation_table(HTML_SPECIALCHARS); return strtr($str, array_flip($trans)); } //----------------------------------------------------------- // _genPass //----------------------------------------------------------- function _genPass($size=10) { $vocales="aeiouAEIOU"; $consonantes="bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ0123456789_"; $r=''; for($i=0; $i<$size; $i++){ if ($i%2) $r.=$vocales{rand(0,strlen($vocales)-1)}; else $r.=$consonantes{rand(0,strlen($consonantes)-1)}; } return $r; } //------------------------------------------------------ // confirm register send mail (bilderbeute) //------------------------------------------------------ function confirmRegister($values){ global $CMS; ob_start(); include $CMS['sys_path'].'/templates/mail.register.confirm.php'; $txtMailBody=ob_get_contents(); ob_end_clean(); $mail = new htmlMimeMail(); $mail->setHTMLEncoding('8Bit'); $mail->setHTMLCharset('utf-8'); $mail->setHTML($this->cleanOutput($txtMailBody), ''); $mail->setReturnPath('noreply@'.$CMS['domain']); $mail->setFrom('noreply@'.$CMS['domain']); $mail->setSubject("Ihre Registrierung: ".$CMS['domain']); $mail->send(array($values['kontakt_email']), 'mail'); $mail->send(array('webmaster@'.$CMS['domain']), 'mail'); $mail->setSubject("Registrierung: ".$CMS['domain'].":".$values['kontakt_email']); #print "
$$txtMailBody

"; } //------------------------------------------------------ // confirm signup/ send mail (partner/idoxx) //------------------------------------------------------ function confirmSignup($values){ global $CMS; ob_start(); include $CMS['sys_path'].'/templates/mail.signup.confirm.php'; $txtMailBody=ob_get_contents(); ob_end_clean(); $mail = new htmlMimeMail(); $mail->setHTMLEncoding('8Bit'); $mail->setHTMLCharset('utf-8'); $mail->setHTML($this->cleanOutput($txtMailBody), ''); $mail->setReturnPath('signup@'.$CMS['domain']); $mail->setFrom('signup@'.$CMS['domain']); $mail->setSubject("Ihre Registrierung"); $mail->send(array($values['kontakt_email']), 'mail'); $mail->setSubject("Signup/".$CMS['domain']."/:".$values['kontakt_email']); $mail->send(array('signup@'.$CMS['domain']), 'mail'); #print "
$$txtMailBody

"; } //----------------------------------------------------------- // Class Func:: rsrc_Path //----------------------------------------------------------- # finally the full downloadpath for an Attachment # path looks like p1/p2/objID/... where p1,p2 in a...f and is computed from byte 3 + 4 of ID # ID -> xxxxxxxxxx function rsrc_Path($userID, $objID, $makedir){ global $CMS; $p1=bin2hex(substr($objID,3,1)); $p1=substr($p1,1,1); $p2=bin2hex(substr($objID,4,1)); $p2=substr($p2,1,1); $path=$_SERVER['DOCUMENT_ROOT'].$CMS['rsrc_path']."/$p1"; # HACK? if($makedir){ if(!file_exists($path)) mkdir ($path, 0755); $path.="/$p2/"; if(!file_exists($path)) mkdir ($path, 0755); $path.="$objID/"; if(!file_exists($path)) mkdir ($path, 0755); } else $path.="/$p2/$objID/"; return $path; } //----------------------------------------------------------- // Class Func:: rsrc_RelPath //----------------------------------------------------------- function rsrc_RelPath($userID, $objID){ $p1=bin2hex(substr($objID,3,1)); $p1=substr($p1,1,1); $p2=bin2hex(substr($objID,4,1)); $p2=substr($p2,1,1); return "/$p1/$p2/$objID/"; } /*------------------------------------------------------------------ ZACK: rsrc_getAbsUrl (class func) ------------------------------------------------------------------*/ # return a valid abs url for a ressource (attachment) function rsrc_objGetAbsUrl($obj, $sel, $idx) { global $CMS; $rsrc=$obj->attachments[$sel][$idx]; # footage jpgs on s3 if($rsrc->rServer=='bbcom.s3.amazonaws.com/'){ return "http://".$rsrc->rServer.$rsrc->rRelPath.$rsrc->rFileName; } $server=$obj->values['rsrc_server']?$obj->values['rsrc_server'].'/':$CMS['rsrc_server']; return "http://".$server.$CMS['rsrc_path'].$rsrc->rRelPath.$rsrc->rFileName; } /*------------------------------------------------------------------ ZACK: rsrc_getAbsUrlByID (class func) ------------------------------------------------------------------*/ # return a valid abs url for a ressource (attachment) function rsrc_objGetAbsUrlByID($id, $sel, $idx) { global $CMS; $obj=$this->obj_read($id); $rv=$this->rsrc_objGetAbsUrl($obj, $sel, $idx); return $rv; } /*------------------------------------------------------------------ ZACK: rsrc_getImgUrlsID (class func) ------------------------------------------------------------------*/ # return a valid abs url for a ressource (attachment) function rsrc_getImgUrls($id, $sel) { global $CMS; $obj=$this->obj_read($id); $ar=Array(); $images=$obj->attachments[$sel]; if($images && is_array($images)) foreach($images as $idx=>$tmp) $ar['default_image_'.$idx]=$this->rsrc_objGetAbsUrl($obj, $sel, $idx); return $ar; } /*------------------------------------------------------------------ ZACK: rsrc_objGetImageUrl (class func) ------------------------------------------------------------------*/ # return a valid abs url for a ressource (attachment) function rsrc_objGetImageUrl($obj, $sel, $idx, $scaleX=null) { global $CMS; $rsrc=$obj->attachments[$sel][$idx]; $path=$rsrc->rRelPath.$rsrc->rFileName; $server=$rsrc->rServer=='bbcom.s3.amazonaws.com/'?$rsrc->rServer:$CMS['rsrc_server']; $server=$CMS['rsrc_server']; if($scaleX) return "http://".$server."/image-scale.php?path=".$path."&scaleX=$scaleX"; else return "http://".$server.$path; } /*------------------------------------------------------------------ zackAPI:: Payment + Events ------------------------------------------------------------------*/ function TX($txType, $params){ global $CMS, $myUser; switch($txType){ case 'voucher': case 'vchr': $voucherID=$params['voucherID']; if($voucherID == 'XAHOQAGU4USU' || $voucherID == '9OGO9IFAZU6U' || $voucherID == 'HOWUGIBU4EPU'){ $wert=5.00; } else ; #read voucher if($user=$this->obj_readDocument($params['userID'])){ $user->values['credits']+=$wert; $myUser['credits']=$user->values['credits']; $this->obj_store($user); $params['text']='Gutschein eingel�st'; $params['txType']='vchr'; $params['txID']=$voucherID; $params['amount']=$wert; $this->db->TxEvent(&$params); return true; } break; case 'buy': if($user=$this->obj_readDocument($params['userID'])){ $user->values['credits']-=$params['amount']; $myUser['credits']=$user->values['credits']; $this->obj_store($user); $this->db->TxEvent(&$params); return true; } case 'ppay': if($user=$this->obj_readDocument($params['userID'])){ $user->values['credits']+=$params['amount']; $myUser['credits']=$user->values['credits']; $this->obj_store($user); $params['text']='*** - paypal Payment'; $params['txType']='ppay'; $this->db->TxEvent(&$params); return true; } case 'dwnl': # account - amount case 'licn': # account - amount if($user=$this->obj_readDocument($params['userID'])){ $user->values['credits']-=$params['amount']; $myUser['credits']=$user->values['credits']; $this->obj_store($user); $params['text']='Download'; $params['txType']='dwnl'; $params['amount']=-(float)$params['amount']; $this->db->TxEvent(&$params); return true; } case 'sals': # SALES if($user=$this->obj_readDocument($params['userID'])){ $user->values['credits']+=$params['amount']; if($myUser['user_id']==$params['userID']) $myUser['credits']=$user->values['credits']; $this->obj_store($user); #$params['text']='Verkauf'; $params['txType']='sals'; $params['amount']=+(float)$params['amount']; $this->db->TxEvent(&$params); return true; } case 'view': # some Item case 'ppvw': # some Item case 'advw': # some Item case 'vshw': # some Item case 'dlla': # download layout case 'dlhi': # download hires case 'dtan': # download by tan case 'vpts': # count articles*viewpoints case 'vote': # voting case 'rate': # voting #$params['text']='Stat'; $this->db->TxEvent(&$params); return true; } return false; } /*------------------------------------------------------------------ zackAPI::CLASSFUNC Permission ------------------------------------------------------------------*/ function Permission($name){ global $ZACK_PERMITS; return $ZACK_PERMITS[$name]; } /*------------------------------------------------------------------ zackAPI:: userCanDo ------------------------------------------------------------------*/ function userCanDo($name){ global $ZACK_PERMITS; return $this->user['user_perms'] & $ZACK_PERMITS[$name]; } /*------------------------------------------------------------------ zackAPI:: userCanEdit ------------------------------------------------------------------*/ function userCanEdit($itemID){ global $ZACK_PERMITS; $obj= &$this->obj_read($itemID); if(!$obj) return false; if($obj->docType=='User' && $obj->values['_ownerID']==$this->user['ownerID'] && $ZACK_PERMITS['zack_perm_edit']) return true; if($this->user['user_perms'] & $ZACK_PERMITS['zack_perm_editGroup']) if($this->user['groupID'] == $obj->groupID) return true; if($this->user['user_perms'] & $ZACK_PERMITS['zack_perm_edit']) if($this->user['ownerID'] == $obj->ownerID) return true; return false; } /*------------------------------------------------------------------ zackAPI:: permit ------------------------------------------------------------------*/ function permit($name){ global $ZACK_PERMITS; $this->user['user_perms'] |= $ZACK_PERMITS[$name]; } /*------------------------------------------------------------------ zackAPI:: checkAccess ------------------------------------------------------------------*/ function checkAccess($obj){ global $ZACK_PERMITS; $pubStatus=$obj->values['pubStatus']; if($pubStatus>=cms_pub_status_set_public) return true; if($this->user['ownerID']==$obj->ownerID) return true; return false; } /*------------------------------------------------------------------ zackAPI::registerPartner ------------------------------------------------------------------*/ # asking for PARTNER account # function registerPartner($values, $login=true){ global $myUser, $CMS; # no email **** if(!$values['kontakt_email']) return 2; if(!validateEmail($values['kontakt_email'], true, true, 'webmaster@wendland-net.de', $CMS['domain'])) return 3; # BUILD Partner Record $values['kontakt_email']=strtolower($values['kontakt_email']); if(!$this->db->getIDbyAttr2("zack:login", $values['kontakt_email'])){ #if(!$this->obj_getIDFromAlias($values['kontakt_email'])) { $customer=$this->obj_create('User', 'Partner', $CMS['group'], 'root'); $customer->values['alias']=$customer->values['kontakt_email']=$values['kontakt_email']; $customer->values['title']=$values['person_vorname'].' '.$values['person_name']; $customer->values['person_vorname']=$values['person_vorname']; $customer->values['person_name']=$values['person_name']; $customer->values['user_type']='PARTNER'; $customer->values['user_role']=$values['user_role']; $customer->values['_ownerID']=$customer->ID; $customer->values['_groupID']=$CMS['group']; $customer->values['cmsTitle']=$CMS['domain']; $customer->values['doctypes']='Image'; $customer->values['credits']=0.00; $customer->values['loginRedirect']='/admin/'; if($values['adr_plz']){ $addr=array( 'caFirstName' => $values['person_vorname'], 'caLastName' => $values['person_name'], 'caZip' => $values['adr_plz'], 'caCity' => $values['adr_ort'], 'caStreet' => $values['adr_strasse'], 'caFon' => $values['kontakt_fon'], 'caFax' => $values['kontakt_fax'], 'caEmail' => $values['kontakt_email'], 'caCompany' => $values['adr_firma'], ); $customer->components['ADDR']=new cAddr('ADDR', &$addr); } $customer->values['user_pass']=$values['passw']=$this->_genPass(8); $customer->values['user_name']=$values['user']=$values['kontakt_email']; $customer->setProperty('zack:cmslogin', $values['kontakt_email'].'|'.md5($values['passw'])); # LOGIN Properties built in CleanupOnStore $customer->values['pubStatus']=cms_pub_status_uinactive; $this->obj_store($customer); $this->confirmSignup(&$values); return 0; } } // end function /*------------------------------------------------------------------ zackAPI::registerUser ------------------------------------------------------------------*/ function registerUser($values, $login=true){ global $myUser, $CMS; # no email **** if(!$values['kontakt_email']) return 2; if(!validateEmail($values['kontakt_email'], true, true, 'webmaster@wendland-net.de', $CMS['domain'])) return 3; if($values['alias']){ if($this->obj_getIDFromAlias($values['alias'])) # the requested alias is not available return 4; $alias=$values['alias']; } else $alias=$values['kontakt_email']; # BUILD Customer $values['kontakt_email']=strtolower($values['kontakt_email']); # exclude a comma separated list of addrs list($values['kontakt_email'],$tmp)=split(',', $values['kontakt_email'], 1); # check for existence of email addr if(!$this->db->getIDbyAttr2("zack:login", $values['kontakt_email'])){ #if(!$this->obj_getIDFromAlias($values['kontakt_email'])) { $customer=$this->obj_create('User', 'Reg', $CMS['group'], 'root'); $customer->values['kontakt_email']=$values['kontakt_email']; $customer->alias=$customer->values['alias']=$alias; $customer->values['title']=$values['person_vorname'].' '.$values['person_name'].' <'.$values['kontakt_email'].' >'; $customer->values['person_vorname']=$values['person_vorname']; $customer->values['person_name']=$values['person_name']; $customer->values['user_site']=$values['user_site']; $customer->values['_ownerID']=$customer->ID; $customer->values['_groupID']=$CMS['group']; $customer->values['cmsTitle']=$CMS['title']; $customer->values['user_type']='REGUSER'; $customer->values['user_role']='none'; $customer->values['user_perms']=0; $customer->values['credits']=0.00; $customer->values['appKey']=$CMS['appKey']; # special properties if($values['x-app-newsletter']){ $customer->setProperty('zack:newsletter','1'); } if($values['x-app-member']){ $customer->setProperty('zack:member',$values['x-app-member']); } # app dependent user types if($values['x-app-isa']){ $customer->isa=$customer->values['isa']=$values['x-app-isa']; } if($values['adr_plz']){ $addr=array( 'caFirstName' => $values['person_vorname'], 'caLastName' => $values['person_name'], 'caZip' => $values['adr_plz'], 'caCity' => $values['adr_ort'], 'caCountry' => $values['adr_country'], 'caStreet' => $values['adr_strasse'], 'caFon' => $values['kontakt_fon'], 'caFax' => $values['kontakt_fax'], 'caEmail' => $values['kontakt_email'], 'caCompany' => $values['adr_firma'], ); $customer->components['ADDR']=new cAddr('ADDR', &$addr); } //if($login){ if(false){ # Login Customer as User $myUser['user_id']=$myUser['ownerID']=$customer->ID; #$myUser['user_name']=$customer->values['title']; $myUser['kontakt_email']=$values['kontakt_email']; $myUser['credits']=0.00; $myUser['credit_limit']=0.00; $myUser['groupID']=$CMS['group']; unset($myUser['_groupID'], $myUser['_ownerID']); $myUser['user_name']=$customer->values['person_vorname']." ".$customer->values['person_name']; $myUser['person_vorname']=$customer->values['person_vorname']; $myUser['person_name']=$customer->values['person_name']; $role=$myUser['user_type']='REGUSER'; $_SESSION['myUser']=$myUser; } if(!$values['passw']) $values['passw']=$this->_genPass(8); $customer->values['user_name']=$customer->values['kontakt_email']; $customer->values['user_pass']=$values['passw']; #$customer->setProperty('zack:applogin', $values['kontakt_email'].'|'.md5($values['passw'])); $customer->values['pubStatus']=cms_pub_status_uinactive; $this->obj_store($customer); if($CMS['register_policy']=='activation'){ $reg_key=array( 'id'=>$customer->ID, 'ti'=>Time() ); $values['reg_key']= zack_encodeProperties($reg_key); } $this->confirmRegister(&$values); } else { // already registered return 1; } return 0; } /*------------------------------------------------------------------ zackAPI::loginUser ------------------------------------------------------------------*/ function loginUser($user, $pass){ $user=strtolower($user); if($user && $pass && ($myID=$this->db->getIDbyAttr2("zack:applogin", "$user|".md5($pass)))){ $userObj=$this->db->readDocument($myID); if($userObj)error_log("id:".$myID); $this->user=array(); if($userObj && $userObj->values['pubStatus']>=cms_pub_status_uactive) { $uvalues=$userObj->getValues(); $this->user['kontakt_email'] =$uvalues['kontakt_email']; $this->user['user_name'] =$uvalues['person_vorname']." ".$uvalues['person_name']; $this->user['user_id'] =$myID; $this->user['person_vorname'] =$uvalues['person_vorname']; $this->user['person_name'] =$uvalues['person_name']; $this->user['credits'] =$uvalues['credits']; $this->user['credit_limit'] =$uvalues['credit_limit']; $this->user['ownerID'] =$myID; $this->user['groupID'] =$uvalues['groupID']; $this->user['pubStatus'] =$uvalues['pubStatus']; $this->user['isa'] =$userObj->isa; # *** REGUSER gets ALL==NONE Permits here*** $this->user['user_perms']=$uvalues['user_perms']; $this->user['user_type']='REGUSER'; $this->user['user_role']=$uvalues['user_role']; if($uvalues['user_constraint_image_size']) $this->user['user_constraint_image_size']=$uvalues['user_constraint_image_size']; $this->permit('zack_perm_editReview'); $this->permit('zack_perm_read'); $this->permit('zack_perm_download_layout'); $this->permit('zack_perm_addRemSet'); # authKey valid in session $this->user['authKey']=$this->db->uniqID(19, true); return $this->user; } } // CMS-login if($myID=$this->db->getIDbyAttr2("zack:cmslogin", "$user|".md5($pass))){ $user=$this->db->readDocument($myID); if($user && $user->values['pubStatus']>=cms_pub_status_uactive) { $uvalues=$user->getValues(); $this->user['kontakt_email'] =$uvalues['kontakt_email']; $this->user['user_name'] =$uvalues['person_vorname']." ".$uvalues['person_name']; $this->user['user_id'] =$myID; $this->user['person_vorname'] =$uvalues['person_vorname']; $this->user['person_name'] =$uvalues['person_name']; $this->user['credits'] =$uvalues['credits']; $this->user['credit_limit'] =$uvalues['credit_limit']; $this->user['ownerID'] =$uvalues['_ownerID']?$uvalues['_ownerID']:$myID; $this->user['groupID'] =$uvalues['_groupID']; $this->user['user_perms'] =$uvalues['user_perms']; $this->user['user_type'] =$uvalues['user_type']; $this->user['appKey'] =$this->appKey; if($uvalues['appKey']) $this->user['appKey']=$uvalues['appKey']; $this->user['user_type']='PARTNER'; $this->user['user_role']=$uvalues['user_role']; if($uvalues['user_constraint_image_size']) $this->user['user_constraint_image_size']=$uvalues['user_constraint_image_size']; #$this->user['user_perms']=0; # Min Set for PARTNER, ADMIN, ... $this->permit('zack_perm_editReview'); $this->permit('zack_perm_read'); $this->permit('zack_perm_write'); $this->permit('zack_perm_download_layout'); $this->permit('zack_perm_addRemSet'); $this->permit('zack_perm_deleteDocument'); $this->permit('zack_perm_partner_php'); if($this->user['user_role']=='admin'){ $this->permit('zack_perm_readGroup'); $this->permit('zack_perm_editGroup'); $this->permit('zack_perm_admin_php'); $this->permit('zack_perm_access_user'); } if($this->user['user_role']=='chiefeditor'){ $this->permit('zack_perm_readGroup'); $this->permit('zack_perm_editGroup'); $this->permit('zack_perm_admin_php'); } # authKey valid in session $this->user['authKey']=$this->db->uniqID(19, true); return $this->user; } } return null; } /*------------------------------------------------------------------ zackAPI::autoLoginUser ------------------------------------------------------------------*/ function autoLoginUser($id){ $obj=$this->db->readDocument($id); if(!$obj) return null; # TODO: this is prelim. $user=$obj->values['user_name']; $pass=$obj->values['user_pass']; if($user && $pass && ($myID=$this->db->getIDbyAttr2("zack:applogin", "$user|".md5($pass)))){ $userObj=$this->db->readDocument($myID); if($userObj)error_log("id:".$myID); $this->user=array(); if($userObj && $userObj->values['pubStatus']==cms_pub_status_uactive) { $uvalues=$userObj->getValues(); $this->user['kontakt_email'] =$uvalues['kontakt_email']; $this->user['user_name'] =$uvalues['person_vorname']." ".$uvalues['person_name']; $this->user['user_id'] =$myID; $this->user['person_vorname'] =$uvalues['person_vorname']; $this->user['person_name'] =$uvalues['person_name']; $this->user['credits'] =$uvalues['credits']; $this->user['credit_limit'] =$uvalues['credit_limit']; $this->user['ownerID'] =$myID; $this->user['groupID'] =$uvalues['groupID']; $this->user['pubStatus'] =$uvalues['pubStatus']; # *** REGUSER gets ALL==NONE Permits here*** $this->user['user_perms']=$uvalues['user_perms']; $this->user['user_type']='REGUSER'; $this->user['user_role']=$uvalues['user_role']; $this->user['isa']=$uvalues['isa']; $this->permit('zack_perm_editReview'); $this->permit('zack_perm_read'); $this->permit('zack_perm_download_layout'); $this->permit('zack_perm_addRemSet'); # authKey valid in session $this->user['authKey']=$this->db->uniqID(19, true); return $this->user; } } // CMS-login if($myID=$this->db->getIDbyAttr2("zack:cmslogin", "$user|".md5($pass))){ $user=$this->db->readDocument($myID); if($user && $user->values['pubStatus']==cms_pub_status_uactive) { $uvalues=$user->getValues(); $this->user['kontakt_email'] =$uvalues['kontakt_email']; $this->user['user_name'] =$uvalues['person_vorname']." ".$uvalues['person_name']; $this->user['user_id'] =$myID; $this->user['person_vorname'] =$uvalues['person_vorname']; $this->user['person_name'] =$uvalues['person_name']; $this->user['credits'] =$uvalues['credits']; $this->user['credit_limit'] =$uvalues['credit_limit']; $this->user['ownerID'] =$uvalues['_ownerID']?$uvalues['_ownerID']:$myID; $this->user['groupID'] =$uvalues['_groupID']; $this->user['user_perms'] =$uvalues['user_perms']; $this->user['user_type'] =$uvalues['user_type']; $this->user['appKey'] =$this->appKey; if($uvalues['appKey']) $this->user['appKey']=$uvalues['appKey']; $this->user['user_type']='PARTNER'; $this->user['user_role']=$uvalues['user_role']; #$this->user['user_perms']=0; # Min Set for PARTNER, ADMIN, ... $this->permit('zack_perm_editReview'); $this->permit('zack_perm_read'); $this->permit('zack_perm_write'); $this->permit('zack_perm_download_layout'); $this->permit('zack_perm_addRemSet'); $this->permit('zack_perm_deleteDocument'); $this->permit('zack_perm_partner_php'); if($this->user['user_role']=='admin'){ $this->permit('zack_perm_readGroup'); $this->permit('zack_perm_editGroup'); $this->permit('zack_perm_admin_php'); $this->permit('zack_perm_access_user'); } if($this->user['user_role']=='chiefeditor'){ $this->permit('zack_perm_readGroup'); $this->permit('zack_perm_editGroup'); $this->permit('zack_perm_admin_php'); } # authKey valid in session $this->user['authKey']=$this->db->uniqID(19, true); return $this->user; } } return null; } /*------------------------------------------------------------------ zackAPI::setUser ------------------------------------------------------------------*/ function setUser($user){ $this->user=$user; } /*------------------------------------------------------------------ zackAPI::checkPrivilege ------------------------------------------------------------------*/ function checkPrivilege($what, $objOrID=null){ return true; } /*------------------------------------------------------------------ ZACK:: getUniqAlias ------------------------------------------------------------------*/ function getUniqAlias($size=12){ while($this->db->getIDFromAlias($tK=$this->db->uniqID($size))); // trackingKey return $tK; } /*------------------------------------------------------------------ ZACK:: object Handling ------------------------------------------------------------------*/ /*------------------------------------------------------------------ ZACK:: obj_read !PRIVATE! ------------------------------------------------------------------*/ function obj_read($objID){ $doc= $this->db->readDocument($objID); return $doc; } /*------------------------------------------------------------------ ZACK:: obj_getIDFromAlias ------------------------------------------------------------------*/ function obj_getIDFromAlias($alias){ # TODO !!!! list($name, $group)=split('@',$alias); $group=''; #echo (" name: $name group: $group|"); return $this->db->getIDFromAlias($alias, $group); } /*------------------------------------------------------------------ ZACK:: obj_readDocument ------------------------------------------------------------------*/ /* - has user privilege to read this document? i.e. user is owner and doc is private - count Views ! */ function obj_readDocument($objID){ global $CMS; $doc= $this->db->readDocument($objID); if($doc){ if(isset($doc->attachments['DEFAULT_IMAGES']) && is_array($images=$doc->attachments['DEFAULT_IMAGES'])) foreach($images as $idx => $rsrc) $doc->values['default_image_'.$idx]=$this->rsrc_objGetAbsUrl($doc,'DEFAULT_IMAGES',$idx ); } return $doc; } /*------------------------------------------------------------------ ZACK::obj_create (obj.create) ------------------------------------------------------------------*/ /** * object Factory which create ZA_Objects * @param string $docType one of Container, Movie, ... * @param string $isa subtype like PERSON,... * @return ZA_Object * @access public */ function obj_create($docType, $isa=null, $groupID=null, $ownerID=null, $ID=null ){ global $CMS; require_once($CMS['sys_path']."/api/doctypes/$docType.php"); $_zobj= new $docType($isa); #$_zobj->isa=$_zobj->values['isa']=$isa; $_zobj->ID=$_zobj->alias=$_zobj->values['ID']=$ID; $_zobj->values['pubStatus']='0'; $_zobj->values['groupID']=$_zobj->groupID=($groupID?$groupID:$this->user['groupID']); $_zobj->values['ownerID']=$_zobj->ownerID=($ownerID?$ownerID:$this->user['ownerID']); $_zobj->values['title']='untitled'; #var_dump($_zobj); #return $_zobj; return $this->db->storeObject($ID, $_zobj); } /*------------------------------------------------------------------ ZACK:: obj_store ------------------------------------------------------------------*/ function obj_store($obj){ $obj->cleanUpOnStore(); unset($obj->values['default_image_Q'],$obj->values['default_image_S'],$obj->values['default_image_L'], $obj->values['default_image_L']); $this->db->storeObject($obj->ID, $obj); } /*------------------------------------------------------------------ ZACK:: obj_clone ------------------------------------------------------------------*/ function obj_clone($obj){ global $CMS; require_once($CMS['sys_path']."/api/doctypes/".$obj->docType.".php"); $new=new $obj->docType(); $values=$obj->getValues(); $values['srcDate']=$new->values['srcDate']; $values['expDate']=$new->values['expDate']; $new->values=$values; $new->properties=$obj->properties; $new->components=$obj->components; $this->attachments=array(); $this->attachments['DEFAULT_IMAGES']=array(); // ...[S], [Q], ... $this->attachments['EXTRA_IMAGES']=array(); // ...[S], [Q], ... $new->isa=$new->values['isa']=$obj->isa; $new->alias=$new->values['alias']=''; $new->groupID=$obj->groupID; $new->ownerID=$obj->ownerID; $new->values['pubStatus']='0'; return $this->db->storeObject(null, $new);; } /*------------------------------------------------------------------ ZACK:: obj_update ------------------------------------------------------------------*/ # check user rights to update object # must be owner or admin # must be allowed function obj_update($obj){ $ID=$obj->values[ID]; $groupID=$obj->values['groupID']; $ownerID=$obj->values['ownerID']; $content=serialize($obj); $this->db->updateObject($ID, $groupID, $ownerID, $obj->docType, $content, $obj->values, $obj->properties); } /*------------------------------------------------------------------ ZACK:: obj_rateIt ------------------------------------------------------------------*/ # check user rights to update object # must be owner or admin # must be allowed function obj_rateIt($ID, $newrating){ $obj=& $this->db->readDocument($ID); $ip=$_SERVER["REMOTE_ADDR"]; $uid=$_COOKIE['UID']; if($obj){ if($rating=$obj->properties['zack:rating']){ list($sum, $count)=explode('|', $rating); $sum+=$newrating; $count++; } else {$sum=$newrating; $count=1;} $date=Date('Y-m-d'); $query=" txID ='$ip' AND itemType='rate' AND itemID='$ID' AND txDate>'$date 00:00:00'"; $c1=$this->db->dbCount($this->db->TX, $query); $query=" userID ='$uid' AND itemType='rate' AND itemID='$ID' AND txDate>'$date 00:00:00'"; $c2=$this->db->dbCount($this->db->TX, $query); #echo '/* q: '.$query.'*/'; if(!$c1 && !$c2){ $obj->properties['zack:rating']=sprintf('%09d', $sum)."|$count"; $this->obj_store($obj); $tx=array('txType' => 'rate', 'itemType' => 'rate', 'userID' => $_COOKIE['UID'], 'itemID' => $ID, 'txID' => $ip, 'amount' => $newrating, 'text'=>$vote ); $this->TX('vote', $tx); return $count; } } return $count-1; } /*------------------------------------------------------------------ ZACK:: obj_vote ------------------------------------------------------------------*/ function obj_vote($ID, $vote){ $obj=& $this->db->readDocument($ID); $ip=$_SERVER["REMOTE_ADDR"]; $uid=$_COOKIE['UID']; if($obj){ # voting for 0 ist not valid $obj->values['x_user_votes'][0]=0; $date=Date('Y-m-d'); $query=" txID ='$ip' AND itemType='poll' AND itemID='$ID' AND txDate>'$date 00:00:00'"; $c1=$this->db->dbCount($this->db->TX, $query); $query=" userID ='$uid' AND itemType='poll' AND itemID='$ID' AND txDate>'$date 00:00:00'"; $c2=$this->db->dbCount($this->db->TX, $query); #echo '/* q: '.$query.'*/'; if(!$c1 && !$c2){ $obj->values['x_user_votes'][$vote]++; $this->obj_store($obj); $tx=array('txType' => 'vote', 'itemType' => 'poll', 'userID' => $_COOKIE['UID'], 'itemID' => $ID, 'txID' => $ip, 'amount' => 1, 'text'=>$vote ); if($vote) $this->TX('vote', $tx); } foreach($obj->values['x_user_votes'] as $count) $total+=$count; for($i=0;$i<100;$i++) $result[]=(float)0.0; foreach($obj->values['x_user_votes'] as $i=>$count) if($total) $result[$i] =sprintf("%01.1f", (float)($count*100.0)/$total); else $result[$i]=0.0; $result[0]=$total; return $result; } return 0; } /*------------------------------------------------------------------ ZACK:: obj_addReview ------------------------------------------------------------------*/ function obj_addReview($ID, $values, $stat=cms_pub_status_public){ global $CMS; # values: title, intro, kontakt_email, person_name, person_vorname, ownerID $obj=& $this->db->readDocument($ID); if($obj){ $rvw=& $this->obj_create('Container', 'cReview', $values['groupID'], $values['ownerID']); $values['itemID']=$ID; $values['pubStatus']=$stat; $values['alias']=$this->getUniqAlias(); $rvw->mergeValues(&$values); $this->obj_store($rvw); $this->rel_addRelation($ID, RELATION_REVIEW, $rvw->ID ); return $rvw->ID; } return false; } /*------------------------------------------------------------------ ZACK:: obj_viewCountAdd ------------------------------------------------------------------*/ # check user rights to update object # must be owner or admin # must be allowed function obj_viewCountAdd($ID, $ownerID){ $this->db->viewCountAdd($ID, $ownerID ); } /*------------------------------------------------------------------ ZACK:: obj_delete ------------------------------------------------------------------*/ function obj_delete($objID){ global $CMS; $obj=& $this->db->readDocument($objID); if($obj){ #$server=$obj->values['rsrc_server']?$obj->values['rsrc_server']:$CMS['rsrc_server']; $server=$CMS['rsrc_server']; $req=array( cmd=>'deleteAllImages', ID => $objID ); $url='http://'.$server.'/handler.php'; $rpc=rpcRequest($url, $req); $this->db->deleteObject($objID); } } /*------------------------------------------------------------------ ZACK:: relations ------------------------------------------------------------------*/ /*------------------------------------------------------------------ getRelated ------------------------------------------------------------------*/ # return an array of IDs function rel_getRelated($objID, $relation, $base, $max){ return $this->db->selectRelation($objID, $relation, $base, $max); } /*------------------------------------------------------------------ rel_addRelation ------------------------------------------------------------------*/ function rel_addRelation($objID, $relation, $relObjID, $aux=''){ return $this->db->addRelation($objID, $relObjID, $relation, $aux); } /*------------------------------------------------------------------ rel_isRelated ------------------------------------------------------------------*/ function rel_isRelated($objID, $relation, $relObjID){ return $this->db->isRelated($objID, $relObjID, $relation); } /*------------------------------------------------------------------ rel_deleteRelated ------------------------------------------------------------------*/ function rel_deleteRelated($objID, $relation, $relObjID){ $this->db->deleteRelationTupel($objID, $relObjID, $relation); } /*------------------------------------------------------------------ rel_deleteRelation ------------------------------------------------------------------*/ function rel_deleteRelation($objID, $relation){ $this->db->deleteRelation($objID, $relation); } /*------------------------------------------------------------------ ZACK:: tags Handling ------------------------------------------------------------------*/ /*------------------------------------------------------------------ obj_addTags (zack.obj.addTags) ------------------------------------------------------------------*/ function obj_addTags($objID, $tags){ } /*------------------------------------------------------------------ list_getTags (zack.list.getTags) ------------------------------------------------------------------*/ function list_getTags($filter, $limit=144, $order=''){ $data=$this->db->selectTags($filter, $limit, $order); $words=array(); if($data) foreach($data as $tmp=>$item){ $words[$item['tag']]=$item['tagCount']; } return $words; } /*------------------------------------------------------------------ obj_addComponent (zack.obj.addComponent) ------------------------------------------------------------------*/ function obj_addComponent($objID, $selector, $componentType, $values){ if($obj=& $this->db->readDocument($objID)){ $cName=$values['cName']; unset($values['cName']); $component=new $componentType($cName, $values); $obj->components[$selector][]=$component; $this->obj_store($obj); return true; } return false; } /*------------------------------------------------------------------ obj_updateComponent (zack.obj.updateComponent) ------------------------------------------------------------------*/ function obj_updateComponent($objID, $selector, $idx, $values){ if($obj=$this->db->readDocument($objID)){ $obj->components[$selector][$idx]->updateFields($values); $this->obj_store($obj); return true; } return false; } /*------------------------------------------------------------------ obj_removeComponent (zack.obj.removeComponent) ------------------------------------------------------------------*/ function obj_removeComponent($objID, $selector, $idx){ if($obj=$this->db->readDocument($objID)){ unset($obj->components[$selector][$idx]); $this->obj_store($obj); return true; } return false; } /*------------------------------------------------------------------ obj_deleteAttachment (zack.obj.deleteAttachment) ------------------------------------------------------------------*/ function obj_deleteAttachment($objID, $selector, $idx){ global $CMS; if($obj=$this->obj_readDocument($objID)){ $rsrc=& $obj->attachments[$selector][$idx]; $server=$obj->values['rsrc_server']?$obj->values['rsrc_server']:$CMS['rsrc_server']; $req=array( cmd=>'deleteImage', filepath=>$CMS['rsrc_path'].$rsrc->rRelPath.$rsrc->rFileName, ID => $objID ); $url='http://'.$server.'/handler.php'; $rpc=rpcRequest($url, $req); unset($obj->attachments[$selector][$idx]); $this->obj_store($obj); return true; } return false; } /*------------------------------------------------------------------ list_getList ------------------------------------------------------------------*/ function list_getList($filter, $base, $maxrec, $order=null){ global $CMS; $data= & $this->db->selectDocuments($filter, $base, $maxrec, $order); $this->numRows=$this->db->NUMROWS; if($data) foreach($data as $i=>$rec){ $ownerID=$rec['owner']; $ID=$rec['ID']; $data[$i]=array_merge($data[$i], $this->rsrc_getImgUrls($ID, 'DEFAULT_IMAGES')); /**** $data[$i]['default_image_S']=$this->rsrc_objGetAbsUrlByID($ID,'DEFAULT_IMAGES','S' ); $data[$i]['default_image_Q']=$this->rsrc_objGetAbsUrlByID($ID,'DEFAULT_IMAGES','Q' ); $data[$i]['default_image_M']=$this->rsrc_objGetAbsUrlByID($ID,'DEFAULT_IMAGES','M' ); $data[$i]['default_image_L']=$this->rsrc_objGetAbsUrlByID($ID,'DEFAULT_IMAGES','L' );***/ } return $data; } /*------------------------------------------------------------------ list_getAccnt ------------------------------------------------------------------*/ function list_getAccnt($filter, $base, $maxrec, $order=null){ global $CMS; $data= & $this->db->selectAccnt($filter, $base, $maxrec, $order); $this->numRows=$this->db->NUMROWS; if($data) foreach($data as $i=>$rec){ $ownerID=$rec['owner']; $ID=$rec['ID']; $data[$i]['default_image_S']=$this->rsrc_objGetAbsUrlByID($ID,'DEFAULT_IMAGES','S' ); } return $data; } /*------------------------------------------------------------------ ZACK:Sets and Relations ------------------------------------------------------------------*/ /*------------------------------------------------------------------ obj_add2Set (zack.obj.add2Set) ------------------------------------------------------------------*/ function obj_add2Set($objID, $cid){ newCategoryForLink($objID, $cid); } /*------------------------------------------------------------------ obj_removeFromSet (zack.obj.removeFromSet) ------------------------------------------------------------------*/ function obj_removeFromSet($objID, $cid){ removeLinkFromCategory($objID, $cid); } /*------------------------------------------------------------------ user_getAllSets (zack.user.getAllSets) ------------------------------------------------------------------*/ function user_getAllSets($userID){ return $this->db->getAllSetsbyUser($userID); } /*------------------------------------------------------------------ zackAPI::utility functions ------------------------------------------------------------------*/ /*------------------------------------------------------------------ zackAPI::util_invite2View ------------------------------------------------------------------*/ /** * params ($values): * email_to - email receiver * email_from - email-addr sender * text - message to receiver * $ID - ID of object to view * $ownerID - * */ function util_invite2View($ID, $values, $private=false){ global $CMS; // ob_start(); // print_r($values); // error_log("invite2View:".ob_get_contents()); // ob_end_clean(); if($values['itemID']) $values[link]="http://".$_SERVER['HTTP_HOST']."?ID=".$values['itemID']; $inv=true; # invitation to view private Video - with feedback --------------------------------- if($private){ $invitation=$this->obj_create('Container', 'Invitation', 'doxx', $values['ownerID']); $invitation->title='Invitation'; $invitation->values=array_merge($invitation->values, $values); $invitation->values['title']=$invitation->title; $invitation->values['alias']=$invitation->alias; # certificate expires after 60 days $invitationCert=array( 'ID'=>$ID, 'inv'=>$invitation->ID, 'm'=>'view', 'expires' => time()+60*24*60*60 ); $inv=zack_encodeProperties($invitationCert); $url="http://".$_SERVER['HTTP_HOST']."?inv=$inv"; $values['link']=$invitation->values['link']=$url; $this->obj_store($invitation); } ob_start(); include $CMS['sys_path'].'/templates/mail.invite.view.php'; $txtMailBody=ob_get_contents(); ob_end_clean(); #print_r($values); $mail = new htmlMimeMail(); $mail->setHTMLEncoding('8Bit'); $mail->setTextEncoding('8Bit'); $mail->setHTMLCharset('utf-8'); $mail->setHTML($txtMailBody, ''); #$mail->setReturnPath('webmaster@wendland-net.de'); $mail->setReturnPath($values['email_from']); $mail->setFrom($values['email_from']); $mail->setSubject("Einladung von ".$values['email_from_name']); $mail->send(array($values['email_to']), 'mail' ); #error_log($txtMailBody); return $inv; } } // end zackAPI ?>