function addQuestion($eventID, $userID, $questionName, $questionDesc, $tags) { /* deal with tags first */ $tags = str_replace(array(' ', "\t"), '', $tags); $a = explode(',', $tags); $tags = array(); foreach ($a as $v) { if (!empty($v)) { $tags[] = $v; } } global $dbf; $tempArray = $tags; foreach ($tempArray as $k => $v) { $tempArray[$k] = '\'' . $v . '\''; } $dbf->query('SELECT tag_id, value FROM cn_tags WHERE value IN (' . implode(',', $tempArray) . ')'); $existingKs; $existingVs; while ($row = $dbf->next()) { $existingKs[] = $row[0]; $existingVs[] = $row[1]; } $diff = array_diff($tags, $existingVs); $newKs = array(); if (!empty($diff)) { foreach ($diff as $v) { if ($k = insertTag($v)) { $newKs[] = $k; } } } $newKs = array_merge($newKs, $existingKs); /* insert the question*/ $query = "INSERT INTO cn_questions (question_name, question_desc, fk_user_id, fk_event_id) "; $query .= "VALUES ('{$questionName}', '{$questionDesc}', {$userID}, {$eventID})"; if ($dbf->query($query)) { $questionID = $dbf->last_id(); } /* insert proper associations */ if (isset($questionID)) { foreach ($newKs as $v) { insertTagAssociation($questionID, $v, $userID); } } echo 'success!'; }
continue; } echo $file . "\n"; $sing = getDirectionPath($dirFiles . $file); if (empty($sing)) { echo "...is empty\n"; continue; } if (in_array($sing, $hashObj)) { echo "...isset\n"; continue; } $id = registerTObject($idFetch, $sing); echo "\n"; echo $sing, '-', $id; echo "\n"; //find tags $tags = findTags($sing, $hashObj); //add new object to hash $hashObj[$id] = $sing; if (!empty($tags)) { echo "... add " . count($tags) . " tags\n"; foreach ($tags as $tag) { list($idref, $tagData) = $tag; $tagId = !isset($hashTags[$tagData]) ? insertTag($tagData) : $hashTags[$tagData]; $hashTags[$tagData] = $tagId; insertTagToTempl($idref, $tagId); insertTagToTempl($id, $tagId); } } }
function resolveEvenimente() { echo "\nEvenimente\n"; // Select evenimente $q = "SELECT * FROM pec_videos_list WHERE category_id = 3 order by id"; $r = mysql_query($q); while ($row = mysql_fetch_assoc($r)) { $data = $row['datainsert']; $data_adaugare = $row['datainsert']; $titlu = trim($row['title']); var_dump($titlu); $autor_poarta_cerului = "Poarta Cerului"; $autor_id = checkExistingAuthor($autor_poarta_cerului); if ($autor_id == -1) { $autor_id = insertAutor($autor_poarta_cerului); } $resurse_id = insertResursa($titlu, $autor_id, null, null, 14, null, $data, $data_adaugare, $row['views']); insertTag(7, $resurse_id, $titlu); if ($row['description'] != '') { insertTag(3, $resurse_id, $row['description']); } $src = $row['source']; if ($row['description'] != '' && strpos($row['embed_code'], "href") === false) { $src = str_replace('Pentru a descarca programul <a href="', '', $row['description']); $src = str_replace('Pentru a descarca programul <a href=', '', $src); $pos = strpos($src, '"'); $src = substr($src, 0, $pos); } insertAttachment($src, $row['embed_code'], 'flv', $resurse_id, $row['source_thumb']); } }